sanity-plugin-taxonomy-manager 4.7.1 → 4.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.esm.js +164 -168
- package/lib/index.esm.esm.js.map +1 -1
- package/lib/index.esm.mjs +164 -168
- package/lib/index.esm.mjs.map +1 -1
- package/lib/index.js +21 -25
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/inputs/ArrayHierarchyInput.tsx +13 -8
- package/src/components/inputs/ReferenceHierarchyInput.tsx +13 -8
package/lib/index.esm.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.esm.js","sources":["../src/helpers/createId.ts","../src/components/inputs/Identifier.tsx","../node_modules/sanity-plugin-utils/lib/index.js","../src/context.ts","../src/queries.ts","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/rng.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/stringify.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/regex.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/v4.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/validate.js","../src/config.ts","../src/hooks/useCreateConcept.tsx","../src/hooks/useOpenNewConceptPane.tsx","../src/hooks/useRemoveConcept.tsx","../src/hooks/useEmbeddingsRecs.tsx","../src/components/interactions/ConceptDetailDialogue.tsx","../src/components/interactions/ConceptDetailLink.tsx","../src/components/interactions/ConceptEditAction.tsx","../src/components/interactions/ConceptSelectLink.tsx","../src/components/interactions/StructureDetailDialogue.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/components/interactions/ToggleButton.tsx","../src/components/Children.tsx","../src/components/ChildConcepts.tsx","../src/components/Concepts.tsx","../src/components/guides/NewScheme.tsx","../src/hooks/useAddTitle.tsx","../src/components/guides/NoConcepts.tsx","../src/components/TopConcepts.tsx","../src/components/TreeStructure.tsx","../src/components/inputs/InputHierarchy.tsx","../src/static/NodeTree.tsx","../src/components/Hierarchy.tsx","../src/components/TreeView.tsx","../src/components/inputs/ReferenceHierarchyInput.tsx","../src/components/inputs/ArrayHierarchyInput.tsx","../src/components/inputs/ManagementControls.tsx","../src/helpers/schemeFilter.ts","../src/helpers/branchFilter.ts","../src/helpers/baseIriField.tsx","../src/components/inputs/RdfUri.tsx","../src/skosConcept.tsx","../src/skosConceptScheme.tsx","../node_modules/@sanity/types/lib/index.mjs","../node_modules/@sanity/util/lib/paths.mjs","../src/views/ConceptUseView.tsx","../src/structure.ts","../src/index.ts"],"sourcesContent":["import {customAlphabet} from 'nanoid'\n\nimport type {Options} from '../types'\n\nconst defaultAlphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\nconst defaultLength = 6\nconst defaultPrefix = ''\n\n/**\n * #### Create Unique Identifier\n * Used for creating the unique identification segment\n * of URIs.\n */\nexport function createId(ident?: Options['ident']): string {\n const alphabet = ident?.pattern || defaultAlphabet\n const length = ident?.length || defaultLength\n const prefix = ident?.prefix || defaultPrefix\n const nanoid = customAlphabet(alphabet, length)\n return prefix + nanoid()\n}\n","import {GenerateIcon} from '@sanity/icons'\nimport {Button, Stack, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {set} from 'sanity'\nimport type {StringInputProps} from 'sanity'\n\nimport {createId} from '../../helpers/createId'\nimport type {Options} from '../../types'\n\ntype IdentifierProps = StringInputProps & {\n ident?: Options['ident']\n}\n\n/**\n * #### Create Unique Identifier\n * For schemes and concepts created in previous versions of the\n * plugin.\n * - Input is only visible if no identifier has been assigned\n * - Input disappears once an ID is generated\n */\nexport const Identifier = (props: IdentifierProps) => {\n const {onChange, ident} = props\n const toast = useToast()\n\n const handleChange = useCallback(() => {\n const id = createId(ident)\n onChange(set(id))\n toast.push({\n status: 'success',\n title: 'Identifier created.',\n closable: true,\n })\n }, [onChange, toast, ident])\n\n return (\n <Stack space={2}>\n <Button\n icon={GenerateIcon}\n mode=\"ghost\"\n width=\"fill\"\n onClick={handleChange}\n text=\"Generate identifier\"\n />\n </Stack>\n )\n}\n\nIdentifier.defaultProps = {\n ident: undefined,\n}\n","import { jsx, jsxs } from \"react/jsx-runtime\";\nimport { Card, Flex, Box, Stack, Text, Menu, MenuItem, TextInput, Badge } from \"@sanity/ui\";\nimport { styled, css } from \"styled-components\";\nimport { RemoveCircleIcon, AddCircleIcon, RestoreIcon } from \"@sanity/icons\";\nimport { useState, useRef, useMemo, useEffect, useContext, useCallback } from \"react\";\nimport { UserAvatar, useClient, useDocumentStore, useWorkspace } from \"sanity\";\nimport isEqual from \"react-fast-compare\";\nimport { distinctUntilChanged, catchError } from \"rxjs/operators\";\nimport { RouterContext } from \"sanity/router\";\nimport { usePaneRouter } from \"sanity/structure\";\nvar __defProp$3 = Object.defineProperty, __getOwnPropSymbols$3 = Object.getOwnPropertySymbols, __hasOwnProp$3 = Object.prototype.hasOwnProperty, __propIsEnum$3 = Object.prototype.propertyIsEnumerable, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$3 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);\n if (__getOwnPropSymbols$3)\n for (var prop of __getOwnPropSymbols$3(b))\n __propIsEnum$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);\n return a;\n};\nconst DEFAULT_PROPS = {\n tone: \"primary\"\n};\nfunction Feedback(props) {\n const { title, description, icon, tone, children } = __spreadValues$3(__spreadValues$3({}, DEFAULT_PROPS), props);\n return /* @__PURE__ */ jsx(Card, { tone, padding: 4, radius: 3, border: !0, children: /* @__PURE__ */ jsxs(Flex, { children: [\n icon ? \"display icon\" : null,\n children || /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [\n title ? /* @__PURE__ */ jsx(Text, { weight: \"semibold\", children: title }) : null,\n description ? /* @__PURE__ */ jsx(Text, { size: 2, children: description }) : null\n ] }) })\n ] }) });\n}\nvar __defProp$2 = Object.defineProperty, __defProps$1 = Object.defineProperties, __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$2 = Object.getOwnPropertySymbols, __hasOwnProp$2 = Object.prototype.hasOwnProperty, __propIsEnum$2 = Object.prototype.propertyIsEnumerable, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$2 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);\n if (__getOwnPropSymbols$2)\n for (var prop of __getOwnPropSymbols$2(b))\n __propIsEnum$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);\n return a;\n}, __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)), __objRest = (source, exclude) => {\n var target = {};\n for (var prop in source)\n __hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);\n if (source != null && __getOwnPropSymbols$2)\n for (var prop of __getOwnPropSymbols$2(source))\n exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop) && (target[prop] = source[prop]);\n return target;\n};\nconst TableWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"table\" }, props)), StyledTable = styled(TableWrapper)(\n () => css`\n display: table;\n width: 100%;\n border-collapse: collapse;\n\n &:not([hidden]) {\n display: table;\n border-collapse: collapse;\n }\n `\n);\nfunction Table(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledTable, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nconst RowWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"tr\" }, props)), StyledRow = styled(RowWrapper)(\n () => css`\n display: table-row;\n\n &:not([hidden]) {\n display: table-row;\n }\n `\n);\nfunction Row(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledRow, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nconst CellWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"td\" }, props)), StyledCell = styled(CellWrapper)(\n () => css`\n display: table-cell;\n\n &:not([hidden]) {\n display: table-cell;\n }\n `\n);\nfunction Cell(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledCell, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nvar __defProp$1 = Object.defineProperty, __getOwnPropSymbols$1 = Object.getOwnPropertySymbols, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __propIsEnum$1 = Object.prototype.propertyIsEnumerable, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$1 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);\n if (__getOwnPropSymbols$1)\n for (var prop of __getOwnPropSymbols$1(b))\n __propIsEnum$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);\n return a;\n};\nfunction searchUsers(users, searchString) {\n return users.filter((user) => !!((user.displayName || \"\").toLowerCase().startsWith(searchString) || (user.givenName || \"\").toLowerCase().startsWith(searchString) || (user.middleName || \"\").toLowerCase().startsWith(searchString) || (user.familyName || \"\").toLowerCase().startsWith(searchString)));\n}\nconst LABELS = {\n addMe: \"Assign myself\",\n removeMe: \"Unassign myself\",\n clear: \"Clear assignees\",\n searchPlaceholder: \"Search users\",\n notFound: \"No users found\"\n};\nfunction UserSelectMenu(props) {\n const {\n value = [],\n userList = [],\n onAdd,\n onRemove,\n onClear,\n style = {}\n } = props, labels = props != null && props.labels ? __spreadValues$1(__spreadValues$1({}, LABELS), props.labels) : LABELS, [searchString, setSearchString] = useState(\"\"), searchResults = searchUsers(userList || [], searchString), me = userList.find((u) => u.isCurrentUser), meAssigned = me && value.includes(me.id), input = useRef(null), handleSearchChange = (event) => {\n setSearchString(event.target.value);\n }, handleSelect = (isChecked, user) => {\n isChecked ? onRemove && onRemove(user.id) : onAdd && onAdd(user.id);\n }, handleAssignMyself = () => {\n me && onAdd && onAdd(me.id);\n }, handleUnassignMyself = () => {\n me && onRemove && onRemove(me.id);\n }, handleClearAssigneesClick = () => {\n onClear && onClear();\n };\n return /* @__PURE__ */ jsxs(Menu, { style, children: [\n meAssigned ? /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"caution\",\n disabled: !me,\n onClick: handleUnassignMyself,\n icon: RemoveCircleIcon,\n text: labels.removeMe\n }\n ) : /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"positive\",\n onClick: handleAssignMyself,\n icon: AddCircleIcon,\n text: labels.addMe\n }\n ),\n /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"critical\",\n disabled: value.length === 0,\n onClick: handleClearAssigneesClick,\n icon: RestoreIcon,\n text: labels.clear\n }\n ),\n /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(\n TextInput,\n {\n ref: input,\n onChange: handleSearchChange,\n placeholder: labels.searchPlaceholder,\n value: searchString\n }\n ) }),\n searchString && (searchResults == null ? void 0 : searchResults.length) === 0 && /* @__PURE__ */ jsx(MenuItem, { disabled: !0, text: labels.notFound }),\n searchResults && searchResults.map((user) => /* @__PURE__ */ jsx(\n MenuItem,\n {\n pressed: value.includes(user.id),\n onClick: () => handleSelect(value.indexOf(user.id) > -1, user),\n children: /* @__PURE__ */ jsxs(Flex, { align: \"center\", children: [\n /* @__PURE__ */ jsx(UserAvatar, { user, size: 1 }),\n /* @__PURE__ */ jsx(Box, { paddingX: 2, flex: 1, children: /* @__PURE__ */ jsx(Text, { children: user.displayName }) }),\n user.isCurrentUser && /* @__PURE__ */ jsx(Badge, { fontSize: 1, tone: \"positive\", mode: \"outline\", children: \"Me\" })\n ] })\n },\n user.id\n ))\n ] });\n}\nfunction getDefaultExportFromCjs(x) {\n return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, \"default\") ? x.default : x;\n}\nvar builder = {}, urlForImage = {}, parseAssetId = {}, hasRequiredParseAssetId;\nfunction requireParseAssetId() {\n if (hasRequiredParseAssetId) return parseAssetId;\n hasRequiredParseAssetId = 1, Object.defineProperty(parseAssetId, \"__esModule\", { value: !0 });\n var example = \"image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg\";\n function parseAssetId$1(ref) {\n var _a = ref.split(\"-\"), id = _a[1], dimensionString = _a[2], format = _a[3];\n if (!id || !dimensionString || !format)\n throw new Error(\"Malformed asset _ref '\".concat(ref, `'. Expected an id like \"`).concat(example, '\".'));\n var _b = dimensionString.split(\"x\"), imgWidthStr = _b[0], imgHeightStr = _b[1], width = +imgWidthStr, height = +imgHeightStr, isValidAssetId = isFinite(width) && isFinite(height);\n if (!isValidAssetId)\n throw new Error(\"Malformed asset _ref '\".concat(ref, `'. Expected an id like \"`).concat(example, '\".'));\n return { id, width, height, format };\n }\n return parseAssetId.default = parseAssetId$1, parseAssetId;\n}\nvar parseSource = {}, hasRequiredParseSource;\nfunction requireParseSource() {\n if (hasRequiredParseSource) return parseSource;\n hasRequiredParseSource = 1;\n var __assign = parseSource && parseSource.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n };\n Object.defineProperty(parseSource, \"__esModule\", { value: !0 });\n var isRef = function(src) {\n var source = src;\n return source ? typeof source._ref == \"string\" : !1;\n }, isAsset = function(src) {\n var source = src;\n return source ? typeof source._id == \"string\" : !1;\n }, isAssetStub = function(src) {\n var source = src;\n return source && source.asset ? typeof source.asset.url == \"string\" : !1;\n };\n function parseSource$1(source) {\n if (!source)\n return null;\n var image;\n if (typeof source == \"string\" && isUrl(source))\n image = {\n asset: { _ref: urlToId(source) }\n };\n else if (typeof source == \"string\")\n image = {\n asset: { _ref: source }\n };\n else if (isRef(source))\n image = {\n asset: source\n };\n else if (isAsset(source))\n image = {\n asset: {\n _ref: source._id || \"\"\n }\n };\n else if (isAssetStub(source))\n image = {\n asset: {\n _ref: urlToId(source.asset.url)\n }\n };\n else if (typeof source.asset == \"object\")\n image = __assign({}, source);\n else\n return null;\n var img = source;\n return img.crop && (image.crop = img.crop), img.hotspot && (image.hotspot = img.hotspot), applyDefaults(image);\n }\n parseSource.default = parseSource$1;\n function isUrl(url) {\n return /^https?:\\/\\//.test(\"\".concat(url));\n }\n function urlToId(url) {\n var parts = url.split(\"/\").slice(-1);\n return \"image-\".concat(parts[0]).replace(/\\.([a-z]+)$/, \"-$1\");\n }\n function applyDefaults(image) {\n if (image.crop && image.hotspot)\n return image;\n var result = __assign({}, image);\n return result.crop || (result.crop = {\n left: 0,\n top: 0,\n bottom: 0,\n right: 0\n }), result.hotspot || (result.hotspot = {\n x: 0.5,\n y: 0.5,\n height: 1,\n width: 1\n }), result;\n }\n return parseSource;\n}\nvar hasRequiredUrlForImage;\nfunction requireUrlForImage() {\n return hasRequiredUrlForImage || (hasRequiredUrlForImage = 1, function(exports) {\n var __assign = urlForImage && urlForImage.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n }, __importDefault = urlForImage && urlForImage.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { default: mod };\n };\n Object.defineProperty(exports, \"__esModule\", { value: !0 }), exports.parseSource = exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = void 0;\n var parseAssetId_1 = __importDefault(requireParseAssetId()), parseSource_1 = __importDefault(requireParseSource());\n exports.parseSource = parseSource_1.default, exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = [\n [\"width\", \"w\"],\n [\"height\", \"h\"],\n [\"format\", \"fm\"],\n [\"download\", \"dl\"],\n [\"blur\", \"blur\"],\n [\"sharpen\", \"sharp\"],\n [\"invert\", \"invert\"],\n [\"orientation\", \"or\"],\n [\"minHeight\", \"min-h\"],\n [\"maxHeight\", \"max-h\"],\n [\"minWidth\", \"min-w\"],\n [\"maxWidth\", \"max-w\"],\n [\"quality\", \"q\"],\n [\"fit\", \"fit\"],\n [\"crop\", \"crop\"],\n [\"saturation\", \"sat\"],\n [\"auto\", \"auto\"],\n [\"dpr\", \"dpr\"],\n [\"pad\", \"pad\"]\n ];\n function urlForImage$1(options) {\n var spec = __assign({}, options || {}), source = spec.source;\n delete spec.source;\n var image = (0, parseSource_1.default)(source);\n if (!image)\n throw new Error(\"Unable to resolve image URL from source (\".concat(JSON.stringify(source), \")\"));\n var id = image.asset._ref || image.asset._id || \"\", asset = (0, parseAssetId_1.default)(id), cropLeft = Math.round(image.crop.left * asset.width), cropTop = Math.round(image.crop.top * asset.height), crop = {\n left: cropLeft,\n top: cropTop,\n width: Math.round(asset.width - image.crop.right * asset.width - cropLeft),\n height: Math.round(asset.height - image.crop.bottom * asset.height - cropTop)\n }, hotSpotVerticalRadius = image.hotspot.height * asset.height / 2, hotSpotHorizontalRadius = image.hotspot.width * asset.width / 2, hotSpotCenterX = image.hotspot.x * asset.width, hotSpotCenterY = image.hotspot.y * asset.height, hotspot = {\n left: hotSpotCenterX - hotSpotHorizontalRadius,\n top: hotSpotCenterY - hotSpotVerticalRadius,\n right: hotSpotCenterX + hotSpotHorizontalRadius,\n bottom: hotSpotCenterY + hotSpotVerticalRadius\n };\n return spec.rect || spec.focalPoint || spec.ignoreImageParams || spec.crop || (spec = __assign(__assign({}, spec), fit({ crop, hotspot }, spec))), specToImageUrl(__assign(__assign({}, spec), { asset }));\n }\n exports.default = urlForImage$1;\n function specToImageUrl(spec) {\n var cdnUrl = (spec.baseUrl || \"https://cdn.sanity.io\").replace(/\\/+$/, \"\"), filename = \"\".concat(spec.asset.id, \"-\").concat(spec.asset.width, \"x\").concat(spec.asset.height, \".\").concat(spec.asset.format), baseUrl = \"\".concat(cdnUrl, \"/images/\").concat(spec.projectId, \"/\").concat(spec.dataset, \"/\").concat(filename), params = [];\n if (spec.rect) {\n var _a = spec.rect, left = _a.left, top_1 = _a.top, width = _a.width, height = _a.height, isEffectiveCrop = left !== 0 || top_1 !== 0 || height !== spec.asset.height || width !== spec.asset.width;\n isEffectiveCrop && params.push(\"rect=\".concat(left, \",\").concat(top_1, \",\").concat(width, \",\").concat(height));\n }\n spec.bg && params.push(\"bg=\".concat(spec.bg)), spec.focalPoint && (params.push(\"fp-x=\".concat(spec.focalPoint.x)), params.push(\"fp-y=\".concat(spec.focalPoint.y)));\n var flip = [spec.flipHorizontal && \"h\", spec.flipVertical && \"v\"].filter(Boolean).join(\"\");\n return flip && params.push(\"flip=\".concat(flip)), exports.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach(function(mapping) {\n var specName = mapping[0], param = mapping[1];\n typeof spec[specName] < \"u\" ? params.push(\"\".concat(param, \"=\").concat(encodeURIComponent(spec[specName]))) : typeof spec[param] < \"u\" && params.push(\"\".concat(param, \"=\").concat(encodeURIComponent(spec[param])));\n }), params.length === 0 ? baseUrl : \"\".concat(baseUrl, \"?\").concat(params.join(\"&\"));\n }\n function fit(source, spec) {\n var cropRect, imgWidth = spec.width, imgHeight = spec.height;\n if (!(imgWidth && imgHeight))\n return { width: imgWidth, height: imgHeight, rect: source.crop };\n var crop = source.crop, hotspot = source.hotspot, desiredAspectRatio = imgWidth / imgHeight, cropAspectRatio = crop.width / crop.height;\n if (cropAspectRatio > desiredAspectRatio) {\n var height = Math.round(crop.height), width = Math.round(height * desiredAspectRatio), top_2 = Math.max(0, Math.round(crop.top)), hotspotXCenter = Math.round((hotspot.right - hotspot.left) / 2 + hotspot.left), left = Math.max(0, Math.round(hotspotXCenter - width / 2));\n left < crop.left ? left = crop.left : left + width > crop.left + crop.width && (left = crop.left + crop.width - width), cropRect = { left, top: top_2, width, height };\n } else {\n var width = crop.width, height = Math.round(width / desiredAspectRatio), left = Math.max(0, Math.round(crop.left)), hotspotYCenter = Math.round((hotspot.bottom - hotspot.top) / 2 + hotspot.top), top_3 = Math.max(0, Math.round(hotspotYCenter - height / 2));\n top_3 < crop.top ? top_3 = crop.top : top_3 + height > crop.top + crop.height && (top_3 = crop.top + crop.height - height), cropRect = { left, top: top_3, width, height };\n }\n return {\n width: imgWidth,\n height: imgHeight,\n rect: cropRect\n };\n }\n }(urlForImage)), urlForImage;\n}\nvar hasRequiredBuilder;\nfunction requireBuilder() {\n if (hasRequiredBuilder) return builder;\n hasRequiredBuilder = 1;\n var __assign = builder && builder.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n }, __createBinding = builder && builder.__createBinding || (Object.create ? function(o, m, k, k2) {\n k2 === void 0 && (k2 = k), Object.defineProperty(o, k2, { enumerable: !0, get: function() {\n return m[k];\n } });\n } : function(o, m, k, k2) {\n k2 === void 0 && (k2 = k), o[k2] = m[k];\n }), __setModuleDefault = builder && builder.__setModuleDefault || (Object.create ? function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: !0, value: v });\n } : function(o, v) {\n o.default = v;\n }), __importStar = builder && builder.__importStar || function(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);\n return __setModuleDefault(result, mod), result;\n };\n Object.defineProperty(builder, \"__esModule\", { value: !0 }), builder.ImageUrlBuilder = void 0;\n var urlForImage_1 = __importStar(requireUrlForImage()), validFits = [\"clip\", \"crop\", \"fill\", \"fillmax\", \"max\", \"scale\", \"min\"], validCrops = [\"top\", \"bottom\", \"left\", \"right\", \"center\", \"focalpoint\", \"entropy\"], validAutoModes = [\"format\"];\n function isSanityModernClientLike(client) {\n return client && \"config\" in client ? typeof client.config == \"function\" : !1;\n }\n function isSanityClientLike(client) {\n return client && \"clientConfig\" in client ? typeof client.clientConfig == \"object\" : !1;\n }\n function rewriteSpecName(key) {\n for (var specs = urlForImage_1.SPEC_NAME_TO_URL_NAME_MAPPINGS, _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {\n var entry = specs_1[_i], specName = entry[0], param = entry[1];\n if (key === specName || key === param)\n return specName;\n }\n return key;\n }\n function urlBuilder(options) {\n if (isSanityModernClientLike(options)) {\n var _a = options.config(), apiUrl = _a.apiHost, projectId = _a.projectId, dataset = _a.dataset, apiHost = apiUrl || \"https://api.sanity.io\";\n return new ImageUrlBuilder(null, {\n baseUrl: apiHost.replace(/^https:\\/\\/api\\./, \"https://cdn.\"),\n projectId,\n dataset\n });\n }\n var client = options;\n if (isSanityClientLike(client)) {\n var _b = client.clientConfig, apiUrl = _b.apiHost, projectId = _b.projectId, dataset = _b.dataset, apiHost = apiUrl || \"https://api.sanity.io\";\n return new ImageUrlBuilder(null, {\n baseUrl: apiHost.replace(/^https:\\/\\/api\\./, \"https://cdn.\"),\n projectId,\n dataset\n });\n }\n return new ImageUrlBuilder(null, options);\n }\n builder.default = urlBuilder;\n var ImageUrlBuilder = (\n /** @class */\n function() {\n function ImageUrlBuilder2(parent, options) {\n this.options = parent ? __assign(__assign({}, parent.options || {}), options || {}) : __assign({}, options || {});\n }\n return ImageUrlBuilder2.prototype.withOptions = function(options) {\n var baseUrl = options.baseUrl || this.options.baseUrl, newOptions = { baseUrl };\n for (var key in options)\n if (options.hasOwnProperty(key)) {\n var specKey = rewriteSpecName(key);\n newOptions[specKey] = options[key];\n }\n return new ImageUrlBuilder2(this, __assign({ baseUrl }, newOptions));\n }, ImageUrlBuilder2.prototype.image = function(source) {\n return this.withOptions({ source });\n }, ImageUrlBuilder2.prototype.dataset = function(dataset) {\n return this.withOptions({ dataset });\n }, ImageUrlBuilder2.prototype.projectId = function(projectId) {\n return this.withOptions({ projectId });\n }, ImageUrlBuilder2.prototype.bg = function(bg) {\n return this.withOptions({ bg });\n }, ImageUrlBuilder2.prototype.dpr = function(dpr) {\n return this.withOptions(dpr && dpr !== 1 ? { dpr } : {});\n }, ImageUrlBuilder2.prototype.width = function(width) {\n return this.withOptions({ width });\n }, ImageUrlBuilder2.prototype.height = function(height) {\n return this.withOptions({ height });\n }, ImageUrlBuilder2.prototype.focalPoint = function(x, y) {\n return this.withOptions({ focalPoint: { x, y } });\n }, ImageUrlBuilder2.prototype.maxWidth = function(maxWidth) {\n return this.withOptions({ maxWidth });\n }, ImageUrlBuilder2.prototype.minWidth = function(minWidth) {\n return this.withOptions({ minWidth });\n }, ImageUrlBuilder2.prototype.maxHeight = function(maxHeight) {\n return this.withOptions({ maxHeight });\n }, ImageUrlBuilder2.prototype.minHeight = function(minHeight) {\n return this.withOptions({ minHeight });\n }, ImageUrlBuilder2.prototype.size = function(width, height) {\n return this.withOptions({ width, height });\n }, ImageUrlBuilder2.prototype.blur = function(blur) {\n return this.withOptions({ blur });\n }, ImageUrlBuilder2.prototype.sharpen = function(sharpen) {\n return this.withOptions({ sharpen });\n }, ImageUrlBuilder2.prototype.rect = function(left, top, width, height) {\n return this.withOptions({ rect: { left, top, width, height } });\n }, ImageUrlBuilder2.prototype.format = function(format) {\n return this.withOptions({ format });\n }, ImageUrlBuilder2.prototype.invert = function(invert) {\n return this.withOptions({ invert });\n }, ImageUrlBuilder2.prototype.orientation = function(orientation) {\n return this.withOptions({ orientation });\n }, ImageUrlBuilder2.prototype.quality = function(quality) {\n return this.withOptions({ quality });\n }, ImageUrlBuilder2.prototype.forceDownload = function(download) {\n return this.withOptions({ download });\n }, ImageUrlBuilder2.prototype.flipHorizontal = function() {\n return this.withOptions({ flipHorizontal: !0 });\n }, ImageUrlBuilder2.prototype.flipVertical = function() {\n return this.withOptions({ flipVertical: !0 });\n }, ImageUrlBuilder2.prototype.ignoreImageParams = function() {\n return this.withOptions({ ignoreImageParams: !0 });\n }, ImageUrlBuilder2.prototype.fit = function(value) {\n if (validFits.indexOf(value) === -1)\n throw new Error('Invalid fit mode \"'.concat(value, '\"'));\n return this.withOptions({ fit: value });\n }, ImageUrlBuilder2.prototype.crop = function(value) {\n if (validCrops.indexOf(value) === -1)\n throw new Error('Invalid crop mode \"'.concat(value, '\"'));\n return this.withOptions({ crop: value });\n }, ImageUrlBuilder2.prototype.saturation = function(saturation) {\n return this.withOptions({ saturation });\n }, ImageUrlBuilder2.prototype.auto = function(value) {\n if (validAutoModes.indexOf(value) === -1)\n throw new Error('Invalid auto mode \"'.concat(value, '\"'));\n return this.withOptions({ auto: value });\n }, ImageUrlBuilder2.prototype.pad = function(pad) {\n return this.withOptions({ pad });\n }, ImageUrlBuilder2.prototype.url = function() {\n return (0, urlForImage_1.default)(this.options);\n }, ImageUrlBuilder2.prototype.toString = function() {\n return this.url();\n }, ImageUrlBuilder2;\n }()\n );\n return builder.ImageUrlBuilder = ImageUrlBuilder, builder;\n}\nvar node, hasRequiredNode;\nfunction requireNode() {\n if (hasRequiredNode) return node;\n hasRequiredNode = 1;\n var __importDefault = node && node.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { default: mod };\n }, builder_1 = __importDefault(requireBuilder());\n return node = builder_1.default, node;\n}\nvar nodeExports = /* @__PURE__ */ requireNode(), createImageUrlBuilder = /* @__PURE__ */ getDefaultExportFromCjs(nodeExports);\nfunction useImageUrlBuilder(clientOptions) {\n const client = useClient(clientOptions);\n return useMemo(() => createImageUrlBuilder(client), [client]);\n}\nfunction useImageUrlBuilderImage(source, clientOptions) {\n const builder2 = useImageUrlBuilder(clientOptions);\n return useMemo(\n () => source && builder2 ? builder2.image(source) : null,\n [builder2, source]\n );\n}\nconst DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: \"v2023-05-01\" }, DEFAULT_INITIAL_VALUE = null;\nfunction useParams(params) {\n const stringifiedParams = useMemo(\n () => JSON.stringify(params || {}),\n [params]\n );\n return useMemo(() => JSON.parse(stringifiedParams), [stringifiedParams]);\n}\nfunction useListeningQuery(query, {\n params = DEFAULT_PARAMS,\n options = DEFAULT_OPTIONS,\n initialValue = DEFAULT_INITIAL_VALUE\n}) {\n const [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(initialValue), memoParams = useParams(params), memoOptions = useParams(options), subscription = useRef(null), documentStore = useDocumentStore();\n return useEffect(() => {\n if (query && !error && !subscription.current)\n try {\n subscription.current = documentStore.listenQuery(query, memoParams, memoOptions).pipe(\n distinctUntilChanged(isEqual),\n catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))\n ).subscribe((documents) => {\n setData(\n (current) => isEqual(current, documents) ? current : documents\n ), setLoading(!1), setError(!1);\n });\n } catch (err) {\n console.error(err), setLoading(!1), setError(err);\n }\n return error && subscription.current && subscription.current.unsubscribe(), () => {\n var _a;\n subscription.current && ((_a = subscription == null ? void 0 : subscription.current) == null || _a.unsubscribe(), subscription.current = null);\n };\n }, [query, error, memoParams, memoOptions, documentStore]), { data, loading, error };\n}\nfunction useOpenInNewPane(id, type) {\n const routerContext = useContext(RouterContext), { routerPanesState, groupIndex } = usePaneRouter();\n return useCallback(() => {\n if (!routerContext || !id || !type)\n return;\n const panes = [...routerPanesState];\n panes.splice(groupIndex + 1, 0, [\n {\n id,\n params: { type }\n }\n ]);\n const href = routerContext.resolvePathFromState({ panes });\n routerContext.navigateUrl({ path: href });\n }, [id, type, routerContext, routerPanesState, groupIndex]);\n}\nvar __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b))\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n return a;\n}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));\nfunction chunkArray(array, size) {\n const chunks = [];\n for (let i = 0; i < array.length; i += size)\n chunks.push(array.slice(i, i + size));\n return chunks;\n}\nfunction useProjectUsers({ apiVersion }) {\n const { currentUser } = useWorkspace(), client = useClient({ apiVersion: apiVersion != null ? apiVersion : \"2023-01-01\" }), [users, setUsers] = useState([]);\n return useEffect(() => {\n const { projectId } = client.config();\n async function getUsersWithRoles() {\n try {\n const aclData = await client.request({\n url: `/projects/${projectId}/acl`\n }), userIds = aclData.map((user) => user.projectUserId), userIdChunks = chunkArray(userIds, 200);\n let usersData = [];\n for (const chunk of userIdChunks) {\n const chunkedUserIds = chunk.join(\",\"), response = await client.request({\n url: `/projects/${projectId}/users/${chunkedUserIds}`\n });\n usersData = [...usersData, ...response];\n }\n const usersWithRoles = usersData.map((user) => {\n var _a;\n const userRoles = ((_a = aclData.find(\n (aclUser) => aclUser.projectUserId === user.id\n )) == null ? void 0 : _a.roles) || [];\n return __spreadProps(__spreadValues({}, user), {\n isCurrentUser: user.id === (currentUser == null ? void 0 : currentUser.id),\n roles: userRoles\n });\n });\n setUsers(usersWithRoles);\n } catch (err) {\n console.error(\"Failed to fetch users:\", err);\n }\n }\n users.length || getUsersWithRoles();\n }, [client, currentUser == null ? void 0 : currentUser.id, users.length]), users;\n}\nexport {\n Cell,\n Feedback,\n Row,\n Table,\n UserSelectMenu,\n useImageUrlBuilder,\n useImageUrlBuilderImage,\n useListeningQuery,\n useOpenInNewPane,\n useProjectUsers\n};\n//# sourceMappingURL=index.js.map\n","import {createContext} from 'react'\n\nimport type {ConceptSchemeDocument} from './types'\n\ntype TreeContextType = {\n globalVisibility?: {treeId: string; treeVisibility: 'open' | 'closed'}\n editControls?: boolean\n setEditControls?: (value: boolean) => void\n}\n\nexport type ReleaseContextType = {\n isPublished?: boolean\n isInRelease: boolean\n releaseName?: string\n documentId: string\n versionId?: string\n}\n\nexport const SchemeContext = createContext<ConceptSchemeDocument | null>(null)\nexport const TreeContext = createContext<TreeContextType>({editControls: false})\n// export const ReleaseContext = createContext<ReleaseContextType>({\n// isInRelease: false,\n// documentId: '',\n// })\nexport const ReleaseContext = createContext<any>(undefined)\n","/**\n * ### Tree Builder\n * Recursive function to build out successive branches of the hierarchy\n * up to five levels deep.\n */\n\n/**\n * #### Branch Builder\n * Recursive function to build out successive branches of the hierarchy\n * up to five levels deep.\n */\nconst branchBuilder = (level = 1): string | void => {\n let reference = '^.^.concepts[]._ref'\n let i = 1\n while (level > i) {\n reference = `^.${reference}`\n i++\n }\n if (level > 6) {\n return ''\n }\n return `\"childConcepts\": *[_id in ${reference} && ^._id in broader[]._ref]|order(prefLabel)\n {\n \"id\": _id,\n \"level\": ${level},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${branchBuilder(level + 1) || ''}\n }`\n}\n\n/**\n * #### Trunk Builder\n * Fetch the top concepts, their child concepts, and orphan concepts\n * and their child concepts.\n *\n * To get orphans:\n * - filter to concepts in this scheme only\n * - filter out concepts that reference a topConcept in this scheme as\n * a broader term\n * - filter out concepts that reference other concepts in this scheme\n * as a broader term\n *\n * Used in Hierarchy.tsx\n */\nexport const trunkBuilder = (): string => {\n return `*[_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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\n }\n }`\n}\n\n/**\n * #### Input Builder\n * Accept a branchId parameter, and filter to topConcepts and Concepts\n * in that branch only. Then call branchBuilder recursively — it will\n * only build terms in the scheme referenced by that concept.\n *\n * - trunkBuilder() is called in Hierarchy.tsx\n * - inputBuilder() is called in InputHierarchy.tsx\n */\nexport const inputBuilder = (): string => {\n return `\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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\n }\n }\n )`\n}\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nvar byteToHex = [];\n\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","export default /^(?:[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;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import type {Options} from './types'\n\nlet taxonomyManagerConfig: Options | undefined\n\n/**\n * #### Manage Plugin Config\n * Store the user preferences config in a module-level\n * variable when the plugin initializes\n */\nexport function setPluginConfig(config: Options | undefined): void {\n taxonomyManagerConfig = config\n}\n\nexport function getPluginConfig(): Options | undefined {\n return taxonomyManagerConfig\n}\n","import {\n DocumentId,\n getDraftId,\n getVersionId,\n getVersionNameFromId,\n isVersionId,\n getPublishedId,\n type VersionId,\n} from '@sanity/id-utils'\nimport {useToast} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback} from 'react'\nimport {isPublishedId, useClient} from 'sanity'\n\nimport {getPluginConfig} from '../config'\nimport {createId} from '../helpers/createId'\nimport type {SkosConceptDocument, SkosConceptReference, ConceptSchemeDocument} from '../types'\n\nimport {useOpenNewConceptPane} from './useOpenNewConceptPane'\n\n/**\n * #### Concept Creation Hook\n * Used for creating concepts and top concepts from the\n * Concept Scheme hierarchy view.\n */\nexport function useCreateConcept(document: ConceptSchemeDocument) {\n const toast = useToast()\n const client = useClient({apiVersion: '2025-02-19'})\n const openInNewPane = useOpenNewConceptPane()\n\n // Get ident config from plugin\n const pluginConfig = getPluginConfig()\n const ident = pluginConfig?.ident\n\n const schemaBaseIri = document.displayed.baseIri\n\n const createConcept = useCallback(\n (\n conceptType: 'topConcept' | 'concept',\n concept?: {\n id: string\n _originalId?: string\n }\n ) => {\n // destructure IDs and rename for this context\n const {id: broaderConceptId, _originalId: broaderConceptOriginalId = ''} = concept || {}\n // check if the skosConceptScheme is in a release\n const isInRelease = isVersionId(document.displayed._id as DocumentId)\n // if so, get the release name\n const releaseName = isInRelease\n ? getVersionNameFromId(document.displayed._id as VersionId)\n : undefined\n\n // create a scheme ID based on context\n const schemeId = isInRelease\n ? getVersionId(DocumentId(document.displayed._id), releaseName as string)\n : getDraftId(DocumentId(document.displayed._id))\n\n // Generate the appropriate concept ID based on context\n const newConceptId = isInRelease\n ? getVersionId(DocumentId(uuid()), releaseName as string)\n : getDraftId(DocumentId(uuid()))\n\n // create the new skosConcept document\n const skosConcept: SkosConceptDocument = {\n _id: newConceptId, // either a draft ID or a release ID\n _type: 'skosConcept',\n conceptId: createId(ident),\n prefLabel: '',\n baseIri: schemaBaseIri,\n broader: [],\n related: [],\n }\n\n // if a broader concept ID is provided, add it to the skosConcept\n if (broaderConceptId) {\n // check if the broader concept is published\n const isPublished = isPublishedId(DocumentId(broaderConceptOriginalId))\n // add broader as _strengthenOnPublish if it's not published\n skosConcept.broader = [\n {\n _key: uuid(),\n _ref: getPublishedId(DocumentId(broaderConceptId)),\n _type: 'reference',\n _weak: !isPublished,\n _strengthenOnPublish: isPublished\n ? undefined\n : {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n },\n },\n ]\n }\n\n const skosConceptReference: SkosConceptReference = {\n _ref: getPublishedId(newConceptId),\n _type: 'reference',\n _key: uuid(),\n _strengthenOnPublish: {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n },\n _weak: true,\n }\n\n client\n .transaction()\n .createIfNotExists({...document.displayed, _id: schemeId})\n .create(skosConcept)\n .patch(schemeId, (patch) => {\n if (conceptType === 'topConcept') {\n return patch\n .setIfMissing({topConcepts: []})\n .append('topConcepts', [skosConceptReference])\n }\n return patch.setIfMissing({concepts: []}).append('concepts', [skosConceptReference])\n })\n .commit({autoGenerateArrayKeys: true})\n .then((_res) => {\n toast.push({\n closable: true,\n status: 'success',\n title: 'Created new concept',\n })\n openInNewPane(newConceptId)\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'Error creating concept',\n description: err instanceof Error ? err.message : 'Unknown error occurred',\n })\n })\n },\n [document.displayed, ident, schemaBaseIri, client, toast, openInNewPane]\n )\n return createConcept\n}\n","import {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\n/**\n * Open in New Pane Link for Concepts\n */\nexport function useOpenNewConceptPane() {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const openInNewPane = useCallback(\n (conceptId: string) => {\n if (!routerContext || !conceptId) {\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, groupIndex + 1, [\n {\n id: conceptId,\n params: {type: 'skosConcept'},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n },\n [routerContext, routerPanesState, groupIndex]\n )\n\n return openInNewPane\n}\n","import {\n DocumentId,\n getDraftId,\n getVersionId,\n getVersionNameFromId,\n isVersionId,\n type VersionId,\n} from '@sanity/id-utils'\nimport {useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {useClient} from 'sanity'\n\nimport type {ConceptSchemeDocument} from '../types'\n\n/**\n * #### Concept Removal Hook\n * Used for removing concepts and top concepts from\n * the Concept Scheme hierarchy view.\n */\nexport function useRemoveConcept(document: ConceptSchemeDocument) {\n const toast = useToast()\n const client = useClient({apiVersion: '2025-02-19'})\n\n // conceptId is the id of the concept to be removed\n const removeConcept = useCallback(\n (conceptId: string, conceptType: string, prefLabel?: string) => {\n const type = conceptType == 'topConcept' ? 'topConcepts' : 'concepts'\n\n const isInRelease = isVersionId(document.displayed._id as DocumentId)\n const releaseName = isInRelease\n ? getVersionNameFromId(document.displayed._id as VersionId)\n : undefined\n\n const schemeId = isInRelease\n ? getVersionId(DocumentId(document.displayed._id), releaseName as string)\n : getDraftId(DocumentId(document.displayed._id))\n\n // Ensure concepts are removed from a draft of the concept scheme document\n // const draftConceptScheme = JSON.parse(JSON.stringify(document.displayed))\n\n // if (!draftConceptScheme._id.includes('drafts.')) {\n // draftConceptScheme._id = `drafts.${draftConceptScheme._id}`\n // }\n\n client\n .transaction()\n .createIfNotExists({...document.displayed, _id: schemeId})\n .patch(schemeId, (patch) => patch.unset([`${type}[_ref==\"${conceptId}\"]`]))\n .commit()\n .then((_res) => {\n toast.push({\n closable: true,\n status: 'success',\n title: `${prefLabel ? `\"${prefLabel}\"` : 'Concept'} removed from scheme`,\n })\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'Error removing concept',\n description: err instanceof Error ? err.message : 'Unknown error occurred',\n })\n })\n },\n [client, document.displayed, toast]\n )\n return removeConcept\n}\n","import {useState, useCallback} from 'react'\nimport {useClient, useDataset, useGetFormValue} from 'sanity'\n\nimport type {EmbeddingsIndexConfig, EmbeddingsResult} from '../types'\n\n/**\n * Queries a Sanity embeddings index using values from specified form fields.\n * Returns matching concept scores and any validation errors.\n */\nexport function useEmbeddingsRecs(embeddingsIndex?: EmbeddingsIndexConfig) {\n const client = useClient({apiVersion: 'vX'})\n const dataset = useDataset()\n const getFormValue = useGetFormValue()\n\n const [conceptRecs, setConceptRecs] = useState<EmbeddingsResult[]>([])\n const [recsError, setRecsError] = useState<string | null>(null)\n\n const buildQueryString = useCallback(\n (fieldReferences: string[]): string => {\n const emptyFields: string[] = []\n const values = fieldReferences.map((fieldName) => {\n const val = getFormValue([fieldName])\n if (typeof val === 'string' && val.trim() !== '') {\n return val\n }\n emptyFields.push(fieldName)\n return ''\n })\n if (emptyFields.length === 1) {\n throw new Error(`Please fill out the ${emptyFields[0]} field to enable match scores.`)\n } else if (emptyFields.length > 1) {\n throw new Error(\n `The following fields must be filled out to enable match scores: ${emptyFields.join(\n ', '\n )}`\n )\n }\n return values.filter(Boolean).join(' ')\n },\n [getFormValue]\n )\n\n const fetchConceptRecs = useCallback(\n async (query: string, indexName: string, maxResults: number) => {\n const returnedRecs: EmbeddingsResult[] = await client.request({\n url: `/embeddings-index/query/${dataset}/${indexName}`,\n method: 'POST',\n body: {\n query,\n maxResults,\n },\n })\n setConceptRecs(returnedRecs)\n },\n [client, dataset]\n )\n\n const triggerEmbeddingsSearch = useCallback(() => {\n setRecsError(null)\n if (!embeddingsIndex) return\n const {indexName, fieldReferences, maxResults = 3} = embeddingsIndex\n try {\n const query = buildQueryString(fieldReferences)\n fetchConceptRecs(query, indexName, maxResults).catch((error) =>\n console.error('Error with embeddings index fetch: ', error)\n )\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'One or more required fields are empty'\n setRecsError(errorMessage)\n }\n }, [buildQueryString, embeddingsIndex, fetchConceptRecs])\n\n return {conceptRecs, recsError, triggerEmbeddingsSearch}\n}\n","import {InfoOutlineIcon} from '@sanity/icons'\nimport {Dialog, Box, Text, Stack, Label, Button, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\n\nimport type {ChildConceptTerm, TopConceptTerm} from '../../types'\n\nconst MessageHelper = ({title, message}: {title: string; message: string}) => {\n return (\n <Stack space={2}>\n <Label size={1}>{title}</Label>\n <Text size={2} muted style={{whiteSpace: 'pre-wrap'}}>\n {message}\n </Text>\n </Stack>\n )\n}\n\n/**\n * #### Information Icon and Dialogue with Concept Details\n * - Affords Tree View access to Definition, Examples, and Scope Notes\n * - Rendered only when concept details are present\n */\nexport const ConceptDetailDialogue = ({\n concept,\n}: {\n concept: (ChildConceptTerm | TopConceptTerm) & {\n definition?: string\n example?: string\n scopeNote?: string\n }\n}) => {\n const [open, setOpen] = useState(false)\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n if (!concept || (!concept.definition && !concept.example && !concept.scopeNote)) return null\n\n return (\n <>\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n View concept details\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button icon={InfoOutlineIcon} mode={'bleed'} onClick={onOpen} tone={'default'} />\n </Tooltip>\n\n {open && (\n <Dialog\n header={concept.prefLabel}\n id=\"dialog-example\"\n onClose={onClose}\n zOffset={1000}\n width={1}\n >\n <Box padding={4} paddingTop={2} paddingBottom={5}>\n <Stack space={4}>\n {concept.definition && (\n <MessageHelper title={'Definition'} message={concept.definition} />\n )}\n {concept.example && <MessageHelper title={'Examples'} message={concept.example} />}\n {concept.scopeNote && (\n <MessageHelper title={'Scope Notes'} message={concept.scopeNote} />\n )}\n </Stack>\n </Box>\n </Dialog>\n )}\n </>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport {Button, Text, Box, Badge, Tooltip} from '@sanity/ui'\nimport {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport type {ChildConceptTerm} from '../../types'\n\n/**\n * #### Concept Detail Link\n * Renders a link to a concept in the hierarchy tree that opens in a new pane.\n */\nexport function ConceptDetailLink({\n concept,\n topConcept = false,\n orphan = false,\n}: {\n concept: ChildConceptTerm\n topConcept?: boolean\n orphan?: boolean\n}) {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const {id, prefLabel} = concept ?? {}\n const displayLabel = prefLabel || '[new concept]'\n\n const openInNewPane = useCallback(() => {\n if (!routerContext || !id) {\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, groupIndex + 1, [\n {\n id: id,\n params: {type: 'skosConcept'},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n }, [id, routerContext, routerPanesState, groupIndex])\n\n return (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {`View \"${prefLabel}\"`}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n >\n <Button\n mode=\"bleed\"\n paddingLeft={0}\n onClick={openInNewPane}\n width=\"fill\"\n justify={'flex-start'}\n >\n <Text size={2} weight={topConcept ? 'bold' : 'regular'} textOverflow=\"ellipsis\">\n {displayLabel}\n {(topConcept || orphan) && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {topConcept ? 'top concept' : 'orphan'}\n </Badge>\n )}\n </Text>\n </Button>\n </Tooltip>\n )\n}\n","import {TrashIcon, AddCircleIcon} from '@sanity/icons'\nimport {Box, Text, Button, Tooltip} from '@sanity/ui'\n// import {useCallback, useState} from 'react'\n\nexport const ConceptEditAction = ({\n action,\n handler,\n}: {\n action: 'remove' | 'add'\n handler: () => void\n}) => {\n // const [open, setOpen] = useState(false)\n // const onClose = useCallback(() => setOpen(false), [])\n // const onOpen = useCallback(() => setOpen(true), [])\n\n const typeMap = {\n add: {\n message: 'Add a child concept below this concept' as const,\n icon: AddCircleIcon,\n tone: 'positive' as const,\n },\n remove: {\n message: 'Remove this concept from this scheme' as const,\n icon: TrashIcon,\n tone: 'critical' as const,\n },\n }\n\n return (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {typeMap[action].message}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n >\n <Button\n icon={typeMap[action].icon}\n mode={'bleed'}\n onClick={handler}\n tone={typeMap[action].tone}\n aria-label=\"Remove this concept from this scheme\"\n />\n </Tooltip>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport {Button, Text, Box, Badge, Tooltip} from '@sanity/ui'\nimport {useCallback} from 'react'\n\nimport type {ChildConceptTerm} from '../../types'\n\n/**\n * #### Concept Select Link\n * Writes a concept _ref from the hierarchy tree to the current document\n */\nexport function ConceptSelectLink({\n concept,\n topConcept = false,\n orphan = false,\n selectConcept,\n}: {\n concept: ChildConceptTerm\n topConcept?: boolean\n orphan?: boolean\n selectConcept?: (conceptRef: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n}) {\n const {prefLabel, id, _originalId, score} = concept ?? {}\n const displayLabel = prefLabel || '[new concept]'\n\n const handleClick = useCallback(() => {\n if (!selectConcept) return\n\n const conceptRef = {\n _ref: id,\n _type: 'reference' as const,\n _originalId,\n }\n selectConcept(conceptRef)\n }, [id, _originalId, selectConcept])\n\n return (\n <>\n {selectConcept && (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {`Select \"${prefLabel}\"`}\n {score && ` (${(score * 100).toFixed(1)}% resource match)`}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left', 'bottom']}\n placement=\"top\"\n portal\n >\n <Button\n mode=\"bleed\"\n paddingLeft={0}\n onClick={handleClick}\n width=\"fill\"\n justify={'flex-start'}\n >\n <Text size={2} weight={topConcept ? 'bold' : 'regular'} textOverflow=\"ellipsis\">\n {displayLabel}\n {(topConcept || orphan) && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {topConcept ? 'top concept' : 'orphan'}\n </Badge>\n )}\n {score && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {`${(score * 100).toFixed(1)}%`}\n </Badge>\n )}\n </Text>\n </Button>\n </Tooltip>\n )}\n </>\n )\n}\n","import {InfoOutlineIcon, ErrorOutlineIcon} from '@sanity/icons'\nimport {Dialog, Box, Text, Button, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\n\n/**\n * #### Information Icon and Dialogue with Structure Details\n * Provide feedback on concepts that are at the limit of\n * or have children beyond the supported hierarchy depth\n */\nexport const StructureDetailDialogue = ({\n message,\n title,\n type,\n}: {\n message: string\n title: string\n type: 'info' | 'warn' | 'error'\n}) => {\n const [open, setOpen] = useState(false)\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n const toneMap = {\n info: 'default' as const,\n warn: 'caution' as const,\n error: 'critical' as const,\n }\n\n return (\n <>\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {title}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button\n icon={type == 'error' ? ErrorOutlineIcon : InfoOutlineIcon}\n mode={'bleed'}\n onClick={onOpen}\n tone={toneMap[type]}\n />\n </Tooltip>\n\n {open && (\n <Dialog header={title} id=\"dialog-example\" onClose={onClose} zOffset={1000} width={1}>\n <Box padding={4} paddingBottom={5}>\n <Text>{message}</Text>\n </Box>\n </Dialog>\n )}\n </>\n )\n}\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","// import styles from '../styles/toggleButton.module.css'\nimport {ToggleArrowRightIcon} from '@sanity/icons'\nimport {Button} from '@sanity/ui'\n\nimport styles from './ToggleButton.module.css'\n\nexport function ToggleButton({handler, visibility}: {handler: () => void; visibility: string}) {\n return (\n <Button\n icon={ToggleArrowRightIcon}\n mode={'bleed'}\n aria-expanded={visibility == 'open'}\n onClick={handler}\n className={styles.toggleButton}\n />\n )\n}\n","/* eslint-disable complexity */\nimport {Inline, Box, Flex} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext, TreeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ChildConceptTerm, ConceptSchemeDocument} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {StructureDetailDialogue} from './interactions/StructureDetailDialogue'\nimport {ToggleButton} from './interactions/ToggleButton'\n\n/**\n * #### Child Concept Component\n * Renders a list of child concepts and applicable\n * actions for a given concept.\n */\nexport const Children = ({\n concept,\n selectConcept,\n inputComponent = false,\n}: {\n concept: ChildConceptTerm\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n inputComponent: boolean\n}) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n const {globalVisibility: {treeVisibility} = {treeVisibility: 'open' as const}} =\n useContext(TreeContext) || {}\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept.id, 'concept', concept?.prefLabel)\n }, [concept.id, concept?.prefLabel, removeConcept])\n\n const [levelVisibility, setLevelVisibility] = useState<'open' | 'closed'>(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility || 'open'\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink concept={concept} selectConcept={selectConcept} />\n ) : (\n <ConceptDetailLink concept={concept} />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent &&\n releaseContext !== 'published' &&\n concept?.level &&\n concept.level < 5 && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n {!inputComponent &&\n releaseContext !== 'published' &&\n concept.childConcepts?.length == 0 &&\n concept.level == 5 && (\n <Inline>\n <StructureDetailDialogue\n type={'warn'}\n title={'Taxonomy Manager structure notice'}\n message={\n 'This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels. Additional child terms are not shown in the hierarchy tree.'\n }\n />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n {concept?.childConcepts && concept?.childConcepts?.length > 0 && concept.level == 5 && (\n <Inline>\n <StructureDetailDialogue\n type={'error'}\n title={'Taxonomy Manager structure warning'}\n message={\n 'This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels.'\n }\n />\n {!inputComponent && releaseContext !== 'published' && (\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n )}\n </Inline>\n )}\n </Flex>\n {/* Child elements the next level down, if any */}\n {concept?.childConcepts &&\n concept.childConcepts.length > 0 &&\n concept?.level &&\n concept.level < 5 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {Box, Stack} from '@sanity/ui'\n\nimport type {ChildConceptTerm} from '../types'\n\nimport {Children} from './Children'\n\n/**\n * #### Child Concepts\n * Lenders a list of child concepts for a given concept\n * with a `<ul>` wrapper for each level of nesting\n */\nexport const ChildConcepts = ({\n concepts,\n inputComponent = false,\n selectConcept,\n childVisibility,\n}: {\n concepts: ChildConceptTerm[]\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n inputComponent: boolean\n childVisibility: string // retype to 'open' | 'closed\n}) => {\n return (\n // the container for child terms\n <Box marginLeft={4} marginTop={2} display={childVisibility == 'closed' ? 'none' : 'block'}>\n <Stack space={3}>\n {concepts.map((concept: ChildConceptTerm) => {\n return (\n <Children\n key={concept.id}\n concept={concept}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n />\n )\n })}\n </Stack>\n </Box>\n )\n}\n","import {Inline, Box, Flex} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ChildConceptTerm, ConceptSchemeDocument} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {ToggleButton} from './interactions/ToggleButton'\n\ntype ConceptProps = {\n concept: ChildConceptTerm\n treeVisibility: string\n inputComponent: boolean\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n}\n\n/**\n * #### Concept Component\n * Renders a list of concepts for a given schema.\n */\nexport const Concepts = ({\n concept,\n treeVisibility,\n inputComponent,\n selectConcept,\n}: ConceptProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const hasTopConcept = !!document.displayed?.topConcepts?.length && !inputComponent\n\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const [levelVisibility, setLevelVisibility] = useState(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept.id, 'concept', concept?.prefLabel)\n }, [concept.id, concept?.prefLabel, removeConcept])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} orphan={hasTopConcept} />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink\n concept={concept}\n selectConcept={selectConcept}\n orphan={hasTopConcept}\n />\n ) : (\n <ConceptDetailLink concept={concept} orphan={hasTopConcept} />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent && releaseContext !== 'published' && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n </Flex>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {AddIcon} from '@sanity/icons'\nimport {Card, Label, Stack, Text, Button, Dialog, Box, TextArea, TextInput} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport type {SanityDocument} from 'sanity'\n\nimport {useAddTitle} from '../../hooks'\n\n/**\n * #### New Concept Scheme Guide\n * - Prompts adding title and description to new concept scheme.\n * - Data must be saved to newly created Concept Scheme documents before\n * add top concept / add concept buttons will work.\n */\nexport const NewScheme = ({document}: {document: SanityDocument}) => {\n const [open, setOpen] = useState(false)\n const [titleValue, setTitleValue] = useState('')\n const [descriptionValue, setDescriptionValue] = useState('')\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n const handleTitleChange = useCallback((event: any) => {\n setTitleValue(event.currentTarget.value)\n }, [])\n const handleDescriptionChange = useCallback((event: any) => {\n setDescriptionValue(event.currentTarget.value)\n }, [])\n\n const addTitle = useAddTitle()\n\n const handleAddTitle = useCallback(() => {\n addTitle(document, titleValue, descriptionValue)\n }, [addTitle, descriptionValue, document, titleValue])\n\n return (\n <div style={{marginTop: '2rem'}}>\n <Card padding={[3, 3, 4]} radius={2} shadow={1} tone=\"primary\">\n <Stack space={6}>\n <Stack space={4}>\n <Label size={4}>New Concept Scheme</Label>\n <Text size={2}>\n To start using hierarchy view taxonomy builder, first give your concept scheme a name\n and optional description. You can also use the \"Editor\" tab to add concepts to the\n tree manually.\n </Text>\n </Stack>\n <Button tone=\"primary\" fontSize={2} icon={AddIcon} onClick={onOpen} text=\"Add Title\" />\n </Stack>\n </Card>\n {open && (\n <Dialog\n header=\"Title & Description\"\n id=\"title-description\"\n onClose={onClose}\n zOffset={1000}\n width={1}\n >\n <Box padding={4}>\n <Stack space={4}>\n <Stack space={2}>\n <Label size={1}>Title</Label>\n <Text size={1} muted>\n Describe the concept scheme in one or two words.\n </Text>\n </Stack>\n <TextInput\n fontSize={2}\n onChange={handleTitleChange}\n padding={3}\n placeholder=\"\"\n value={titleValue}\n />\n <Stack space={2}>\n <Label size={1}>Description (optional)</Label>\n <Text size={1} muted>\n Describe the intended use of this concept scheme.\n </Text>\n </Stack>\n <TextArea\n fontSize={2}\n onChange={handleDescriptionChange}\n padding={3}\n placeholder=\"\"\n value={descriptionValue}\n rows={3}\n />\n <Button tone=\"primary\" fontSize={2} onClick={handleAddTitle} text=\"Save\" />\n </Stack>\n </Box>\n </Dialog>\n )}\n </div>\n )\n}\n","import {useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {useClient} from 'sanity'\n\n/**\n * #### Add Title and Description to New Concept Scheme\n * Good for user experience, and also needed to write the\n * new scheme to the content lake, prior to which add top\n * concept / add concept buttons will not work.\n */\nexport function useAddTitle() {\n const toast = useToast()\n const client = useClient({apiVersion: '2021-10-21'})\n\n const addTitle = useCallback(\n (document: any, titleValue: string, descriptionValue?: string) => {\n const documentId = document.displayed?._id\n const schemaBaseIri = document.displayed?.baseIri\n const schemeId = document.displayed?.schemeId\n\n const doc = {\n _id: `drafts.${documentId}`,\n _type: 'skosConceptScheme',\n schemeId: schemeId,\n baseIri: schemaBaseIri,\n title: titleValue,\n description: descriptionValue ? descriptionValue : '',\n }\n\n client\n .createIfNotExists(doc)\n .then((_) => {\n if (descriptionValue) {\n return toast.push({\n closable: true,\n status: 'success',\n title: 'Title and Description added.',\n })\n }\n return toast.push({\n closable: true,\n status: 'success',\n title: 'Title added.',\n })\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'There has been an error',\n description: err.message,\n })\n })\n },\n [client, toast]\n )\n\n return addTitle\n}\n","import {Card, Label, Stack, Text} from '@sanity/ui'\n\n/**\n * #### No Concepts Guide\n * Prompts adding concepts to an empty scheme.\n */\nexport const NoConcepts = () => {\n return (\n <div style={{marginTop: '2rem'}}>\n <Card padding={[3, 3, 4]} radius={2} shadow={1} tone=\"primary\">\n <Stack space={4}>\n <Label size={4}>No Concepts</Label>\n <Text size={2}>\n There are not yet any concepts assigned to this scheme. To create a multi-level\n hierarchy with specific entry points, create Top Concepts first, then add child concepts\n to them. To create a flat list of concepts, create Concepts directly.\n </Text>\n </Stack>\n </Card>\n </div>\n )\n}\n","import {Flex, Inline, Box} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ConceptSchemeDocument, TopConceptTerm} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {ToggleButton} from './interactions/ToggleButton'\n\ntype TopConceptsProps = {\n concept: TopConceptTerm\n treeVisibility: string\n inputComponent: boolean\n selectConcept: (conceptId: {_ref: string; _type: 'reference'}) => void\n}\n\n/**\n * #### Top Concept Component\n * Renders a list of top concepts for a given schema.\n */\nexport const TopConcepts = ({\n concept,\n treeVisibility,\n inputComponent,\n selectConcept,\n}: TopConceptsProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const [levelVisibility, setLevelVisibility] = useState(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept?.id, 'topConcept', concept?.prefLabel)\n }, [concept?.id, concept?.prefLabel, removeConcept])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} topConcept />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink concept={concept} selectConcept={selectConcept} topConcept />\n ) : (\n <ConceptDetailLink concept={concept} topConcept />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent && releaseContext !== 'published' && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n </Flex>\n {/* Child Concepts */}\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {Box, Stack} from '@sanity/ui'\nimport {useContext} from 'react'\n\nimport {TreeContext} from '../context'\nimport type {DocumentConcepts, TopConceptTerm, ChildConceptTerm} from '../types'\n\nimport {Concepts} from './Concepts'\nimport {NoConcepts} from './guides'\nimport {TopConcepts} from './TopConcepts'\n\n/**\n * #### Tree View\n * Fetches the complete tree of concepts in a concept scheme, stemming\n * from Top Concepts or Orphans. Displays the tree in a nested list.\n */\nexport const TreeStructure = ({\n concepts,\n inputComponent,\n selectConcept,\n}: {\n concepts: DocumentConcepts\n inputComponent: boolean\n selectConcept: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void\n}) => {\n const {globalVisibility: {treeId, treeVisibility} = {treeId: 'default', treeVisibility: 'open'}} =\n useContext(TreeContext) || {}\n\n if (!concepts?.topConcepts?.length && !concepts?.concepts?.length) {\n return <NoConcepts />\n }\n\n return (\n <Box paddingTop={4}>\n <Stack space={3} style={{listStyle: 'none', paddingLeft: '0', marginBlockStart: '0'}}>\n {concepts.topConcepts?.map((concept: TopConceptTerm) => (\n <TopConcepts\n key={`${concept?.id}+${treeId}`}\n concept={concept}\n treeVisibility={treeVisibility}\n inputComponent={inputComponent}\n selectConcept={selectConcept}\n />\n ))}\n {concepts.concepts\n ?.filter((concept: ChildConceptTerm) => concept?.isOrphan)\n .map((concept: ChildConceptTerm) => {\n return (\n <Concepts\n key={`${concept.id}+${treeId}`}\n concept={concept}\n treeVisibility={treeVisibility}\n inputComponent={inputComponent}\n selectConcept={selectConcept}\n />\n )\n })}\n </Stack>\n </Box>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport type {DocumentId} from '@sanity/id-utils'\nimport {getPublishedId} from '@sanity/id-utils'\nimport {Flex, Spinner, Box, Text, Card} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useContext, useMemo} from 'react'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {ReleaseContext, SchemeContext, TreeContext} from '../../context'\nimport {inputBuilder} from '../../queries'\nimport type {\n ChildConceptTerm,\n ConceptSchemeDocument,\n DocumentConcepts,\n TreeViewProps,\n} from '../../types'\nimport {TreeStructure} from '../TreeStructure'\n\n/**\n * #### Input Hierarchy Component\n * - Provides a frame for global controls and tree structure\n * - Fetches the complete tree of concepts in a concept scheme.\n * - Displays the tree in a nested list.\n * @param inputComponent - Specifies whether the component is a Studio\n * input component. Set in HierarchyInput and passed through TreeView\n */\nexport const InputHierarchy = ({\n branchId = '',\n selectConcept,\n inputComponent,\n expanded,\n conceptRecs,\n recsError,\n}: TreeViewProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const documentId = getPublishedId(document.displayed?._id as DocumentId)\n const releaseContext: string = useContext(ReleaseContext) as string\n const initialVisibility = expanded ? 'open' : 'closed'\n const {data, loading, error} = useListeningQuery<DocumentConcepts>(\n {\n fetch: inputBuilder(),\n listen: `*[_type == \"skosConcept\" || _id == $id]`,\n },\n {\n // GROQ's select($branchId != null => ...) requires null, not empty string.\n // ListenQueryParams doesn't accept null, so we cast past it.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n params: {id: documentId, branchId} as any,\n options: {\n perspective: releaseContext === undefined ? 'drafts' : [releaseContext],\n },\n }\n ) as {data: DocumentConcepts; loading: boolean; error: Error | null}\n\n // Build a score lookup map from conceptRecs:\n const scoreMap = useMemo(() => {\n const map = new Map<string, number>()\n if (Array.isArray(conceptRecs)) {\n for (const rec of conceptRecs) {\n map.set(rec.value.documentId, rec.score)\n }\n }\n return map\n }, [conceptRecs])\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const treeId = useMemo(() => nanoid(6), [scoreMap])\n\n // Recursively annotate tree nodes\n // Walk the tree creating new objects with score attached where\n // there's a match. Use getPublishedId() to normalize the tree\n // node id before comparing against the lookup map.\n // Process children first, then check if any child has score\n // or hasMatchingDescendant.\n const addScores = useCallback(function addScores<T extends ChildConceptTerm>(\n node: T,\n scores: Map<string, number>\n ): T {\n const publishedId = getPublishedId(node.id as DocumentId)\n const score = scores.get(publishedId)\n\n const annotatedChildren = node.childConcepts?.map((c) => addScores(c, scores))\n\n const hasMatchingDescendant =\n annotatedChildren?.some((c) => c.score !== undefined || c.hasMatchingDescendant) ?? false\n\n return {\n ...node,\n ...(score === undefined ? {} : {score}),\n ...(hasMatchingDescendant ? {hasMatchingDescendant: true} : {}),\n ...(annotatedChildren ? {childConcepts: annotatedChildren} : {}),\n } as T\n },\n [])\n\n // Compute merged data with useMemo:\n const mergedData = useMemo(() => {\n if (!data || scoreMap.size === 0 || recsError) return data\n return {\n topConcepts: data.topConcepts?.map((tc) => addScores(tc, scoreMap)),\n concepts: data.concepts?.map((c) => addScores(c, scoreMap)),\n }\n }, [addScores, data, scoreMap, recsError])\n\n if (loading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading hierarchy…\n </Text>\n </Flex>\n </Box>\n )\n } else if (error) {\n console.warn(error)\n return (\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading terms. Please check the scheme configuration and try again.\n </Text>\n </Card>\n </Box>\n )\n } else if (!data) {\n return (\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n This configuration does not have any terms associated with it. Please check the scheme\n and branch supplied and try again.\n </Text>\n </Card>\n </Box>\n )\n }\n return (\n <TreeContext.Provider value={{globalVisibility: {treeId, treeVisibility: initialVisibility}}}>\n <Box padding={4} paddingTop={0}>\n {recsError && (\n <Card marginTop={2} padding={3} radius={2} shadow={1} tone=\"caution\">\n <Text size={2}>{recsError}</Text>\n </Card>\n )}\n <TreeStructure\n concepts={mergedData}\n inputComponent={inputComponent || false}\n selectConcept={selectConcept || (() => undefined)}\n />\n </Box>\n </TreeContext.Provider>\n )\n}\n","export default function NodeTree() {\n return (\n <svg\n data-sanity-icon\n width=\"25\"\n height=\"25\"\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n 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\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n","import {AddCircleIcon} from '@sanity/icons'\nimport type {DocumentId} from '@sanity/id-utils'\nimport {getPublishedId} from '@sanity/id-utils'\nimport {Flex, Spinner, Stack, Box, Text, Inline, Card, Button} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useContext, useState} from 'react'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {SchemeContext, TreeContext, ReleaseContext} from '../context'\nimport {useCreateConcept} from '../hooks'\nimport {trunkBuilder} from '../queries'\nimport type {DocumentConcepts, ConceptSchemeDocument, TreeViewProps} from '../types'\n\nimport {NewScheme} from './guides'\nimport {TreeStructure} from './TreeStructure'\n\n/**\n * #### Hierarchy Component\n * Provides a frame for global controls and tree structure and displays\n * controls to add concepts or top concepts when in draft mode or release mode.\n * @param inputComponent - Whether this is an input component.\n * @param branchId - Input component: The branch ID to fetch concepts from.\n * @param selectConcept - Input component: The function to call when a concept is selected.\n */\nexport const Hierarchy = ({\n inputComponent = false,\n // branchId = '',\n selectConcept,\n}: TreeViewProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const documentId = getPublishedId(document.displayed?._id as DocumentId)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const createConcept = useCreateConcept(document)\n const createTopConcept = useCallback(() => {\n createConcept('topConcept')\n }, [createConcept])\n const createEntryConcept = useCallback(() => {\n createConcept('concept')\n }, [createConcept])\n\n // Expand & Collapse Controls\n // short IDs are used on treeId to initiate a re-rendering of all child\n // elements on expand/collapse and re-initialize any local toggle state\n // that had been set.\n const [globalVisibility, setGlobalVisibility] = useState<{\n treeId: string\n treeVisibility: 'open' | 'closed'\n }>({\n treeId: nanoid(6),\n treeVisibility: 'open',\n })\n const handleExpand = useCallback(() => {\n setGlobalVisibility({treeId: nanoid(6), treeVisibility: 'open'})\n }, [])\n const handleCollapse = useCallback(() => {\n setGlobalVisibility({treeId: nanoid(6), treeVisibility: 'closed'})\n }, [])\n\n const {data, loading, error} = useListeningQuery<DocumentConcepts>(\n {\n fetch: trunkBuilder(),\n listen: `*[_type == \"skosConcept\" || _type == \"skosConceptScheme\" ]`,\n },\n {\n params: {\n id: documentId,\n },\n options: {\n perspective: releaseContext === undefined ? 'drafts' : [releaseContext],\n },\n }\n ) as {data: DocumentConcepts; loading: boolean; error: Error | null}\n if (loading) {\n return (\n <Box padding={4} paddingTop={6}>\n <Flex align=\"center\" direction=\"column\" gap={5} height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Text muted size={1}>\n Loading hierarchy…\n </Text>\n </Flex>\n </Box>\n )\n } else if (error) {\n console.error(error)\n return <div>Error here</div>\n } else if (!data) {\n return <NewScheme document={document} />\n }\n return (\n <TreeContext.Provider value={{globalVisibility}}>\n <Box padding={4}>\n <>\n <Stack space={4}>\n <Card borderBottom paddingBottom={1} display={'flex'} flex={1}>\n <Flex justify={'space-between'} flex={1}>\n <Card>\n {(data.topConcepts?.filter((concept) => (concept?.childConcepts?.length ?? 0) > 0)\n .length > 0 ||\n data.concepts?.filter((concept) => (concept?.childConcepts?.length ?? 0) > 0)\n .length > 0) && (\n <Inline space={1}>\n <Button\n text={'Collapse'}\n paddingY={2}\n mode={'bleed'}\n onClick={handleCollapse}\n />\n <Text weight=\"semibold\" muted size={1}>\n |\n </Text>\n <Button text={'Expand'} paddingY={2} mode={'bleed'} onClick={handleExpand} />\n </Inline>\n )}\n </Card>\n <Card>\n {releaseContext !== 'published' && (\n <Inline space={1}>\n <Button\n text={'Add Top Concept'}\n icon={AddCircleIcon}\n mode={'bleed'}\n tone={'positive'}\n paddingY={2}\n onClick={createTopConcept}\n />\n <Button\n text={'Add Concept'}\n icon={AddCircleIcon}\n mode={'bleed'}\n tone={'positive'}\n paddingY={2}\n onClick={createEntryConcept}\n />\n </Inline>\n )}\n </Card>\n </Flex>\n </Card>\n </Stack>\n <TreeStructure\n concepts={data}\n inputComponent={inputComponent}\n selectConcept={selectConcept || (() => undefined)}\n />\n </>\n </Box>\n </TreeContext.Provider>\n )\n}\n\nexport default Hierarchy\n","import {Box, Container, Stack, Text} from '@sanity/ui'\nimport {usePerspective} from 'sanity'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport type {ConceptSchemeDocument, TreeViewProps} from '../types'\n\nimport {Hierarchy} from './Hierarchy'\nimport {InputHierarchy} from './inputs'\n\n/**\n * #### Tree View Component Wrapper\n * This is the view component for the hierarchy tree. It is the\n * top level of concept scheme views and is passed into Desk\n * structure to render the primary view for taxonomy documents.\n * @param document - The document to render.\n * @param branchId - The branch ID to fetch concepts from.\n * @param inputComponent - Specifies whether the component is Studio input component, which will hide tree view controls and chrome.\n * @param selectConcept - The function to call when a concept is selected.\n */\nexport const TreeView = ({\n document,\n branchId,\n inputComponent = false,\n selectConcept,\n expanded,\n conceptRecs,\n recsError,\n}: TreeViewProps) => {\n const {selectedPerspectiveName} = usePerspective()\n return (\n <SchemeContext.Provider value={document || ({} as ConceptSchemeDocument)}>\n <ReleaseContext.Provider value={selectedPerspectiveName}>\n {inputComponent ? (\n <InputHierarchy\n inputComponent={inputComponent}\n branchId={branchId}\n selectConcept={selectConcept}\n expanded={expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n ) : (\n <Container width={1}>\n {document?.displayed?.description && (\n <Box padding={4} paddingTop={6}>\n <Stack space={4}>\n <Stack space={2}>\n <Text size={1} weight=\"semibold\">\n Description\n </Text>\n <Text size={2} muted>\n {document?.displayed.description}\n </Text>\n </Stack>\n </Stack>\n </Box>\n )}\n <Hierarchy inputComponent={inputComponent} branchId={branchId} />\n </Container>\n )}\n </ReleaseContext.Provider>\n </SchemeContext.Provider>\n )\n}\n\nexport default TreeView\n","/* eslint-disable react/require-default-props */\nimport {isVersionId} from '@sanity/id-utils'\nimport type {DocumentId} from '@sanity/id-utils'\nimport {Grid, Stack, Button, Dialog, Box, Spinner, Text, Flex, Card} from '@sanity/ui'\nimport {useState, useEffect, useCallback} from 'react'\nimport type {ObjectFieldProps, ObjectOptions, Reference} from 'sanity'\nimport {isDraftId, useClient, useFormValue, usePerspective} from 'sanity'\n\nimport {useEmbeddingsRecs} from '../../hooks'\nimport NodeTree from '../../static/NodeTree'\nimport type {ConceptSchemeDocument, EmbeddingsIndexConfig} from '../../types'\nimport {TreeView} from '../TreeView'\n\ntype ReferenceOptions = ObjectOptions & {\n filter: ({getClient}: {getClient: () => ReturnType<typeof useClient>}) => Promise<{\n filter: string\n params: {\n concepts: string[]\n topConcepts?: string[]\n schemeId: string\n branchId?: string\n }\n expanded?: boolean\n browseOnly?: boolean\n }>\n}\n\ntype HierarchyInput = ObjectFieldProps<Reference> & {\n embeddingsIndex?: EmbeddingsIndexConfig\n}\n\n// Extract the return type of the filter function\ntype FilterResult = Awaited<ReturnType<ReferenceOptions['filter']>>\n\n/**\n * Input component that replaces Sanity's default reference field input with a\n * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms\n * organized in their scheme hierarchy and select a single term for the field.\n *\n * @remarks\n * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's\n * `options.filter`. Rendering without a filter will display a configuration warning.\n * - Taxonomy selection is disabled when viewing the published perspective.\n * - When `browseOnly` is set in the filter configuration, Sanity's default search input\n * is suppressed and only the tree browser is available for term selection.\n * - When `expanded` is set in the filter configuration, the hierarchy tree loads open\n * by default instead of collapsed.\n *\n * @param props - Standard Sanity `ObjectFieldProps<Reference>` extended with an optional\n * `embeddingsIndex` configuration object.\n * @param props.embeddingsIndex - Optional configuration for AI-assisted term\n * recommendations via a Sanity Embeddings Index. When provided, opening the tree\n * browser queries the specified index and annotates matching taxonomy terms with\n * a relevance score to help authors identify the most appropriate term.\n * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index\n * to query. Must be an index that includes `skosConcept` documents.\n * @param props.embeddingsIndex.fieldReferences - An array of field names from the\n * current document whose values are concatenated and sent as the embeddings search\n * query. All listed fields must contain values when the tree browser is opened;\n * empty fields will display an error message in the tree view rather than scores.\n * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching\n * terms to return from the embeddings index. Defaults to `3`.\n *\n * @example\n * Basic usage with a scheme filter:\n * ```js\n * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'gradeLevel',\n * title: 'Grade Level',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * Branch filter with tree expanded by default:\n * ```js\n * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * Browse-only mode (suppresses the default Sanity search input):\n * ```js\n * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * AI-assisted recommendations via an embeddings index:\n * ```jsx\n * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: [{type: 'skosConcept'}],\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * components: {\n * field: (props) => (\n * <ReferenceHierarchyInput\n * {...props}\n * embeddingsIndex={{\n * indexName: 'my-taxonomy-index',\n * fieldReferences: ['title', 'metaDescription'],\n * maxResults: 4,\n * }}\n * />\n * ),\n * },\n * })\n * ```\n *\n * @see {@link ArrayHierarchyInput} for multi-value `array` fields\n * @see {@link schemeFilter} for filtering by a full concept scheme\n * @see {@link branchFilter} for filtering by a branch within a concept scheme\n */\nexport function ReferenceHierarchyInput(props: HierarchyInput) {\n const client = useClient({apiVersion: 'vX'})\n\n // the resource document in which the input component appears:\n const documentId = useFormValue(['_id']) as string\n\n // name of the field to input a value\n const {name, title, value, embeddingsIndex} = props\n\n const {conceptRecs, recsError, triggerEmbeddingsSearch} = useEmbeddingsRecs(embeddingsIndex)\n\n // Get release and draft status of the document\n const isInRelease = isVersionId(documentId as DocumentId)\n const isDraft = isDraftId(documentId as DocumentId)\n\n // Selected Perspective is also used in the Tree view component. Consider tidying.\n const {selectedPerspectiveName} = usePerspective()\n\n const [schemeLoading, setSchemeLoading] = useState(true)\n const [valuesLoading, setValuesLoading] = useState(true)\n const [open, setOpen] = useState(false)\n\n // the skosConceptScheme document identified by the field filter options:\n const [scheme, setScheme] = useState<ConceptSchemeDocument | undefined>(undefined)\n\n // State to store resolved filter values:\n const [filterValues, setFilterValues] = useState<FilterResult | undefined>()\n\n // use filterValues if available, otherwise fallback to default:\n const {schemeId, branchId = null} = filterValues?.params || {}\n\n const {filter} = props.schemaType.options as ReferenceOptions\n\n // Fetch filter values from `reference` field filter asynchronously.\n useEffect(() => {\n async function fetchFilterValues() {\n try {\n const resolvedFilterValues = await filter({getClient: () => client})\n setFilterValues(resolvedFilterValues)\n // Store the resolved filter values in state\n setValuesLoading(false)\n } catch (error) {\n console.error('Error fetching filter values: ', error)\n }\n }\n fetchFilterValues().catch((error) => console.error('Error fetching filter values: ', error))\n }, [filter, client])\n\n // get the skosConceptScheme document identified by the field filter options\n useEffect(() => {\n if (!schemeId) return\n client\n .fetch('{\"displayed\": *[schemeId == $schemeId][0]}', {schemeId})\n .then((res: {displayed?: ConceptSchemeDocument['displayed']}) => {\n if (res?.displayed) {\n setScheme(res as ConceptSchemeDocument)\n setSchemeLoading(false)\n }\n })\n .catch((err) => console.warn(err))\n }, [client, schemeId])\n\n const browseHierarchy = useCallback(() => {\n setOpen(true)\n triggerEmbeddingsSearch()\n }, [triggerEmbeddingsSearch])\n\n const handleClose = useCallback(() => {\n setOpen(false)\n }, [])\n\n /**\n * #### Term Select Action\n * Writes the selected taxonomy term to the document field\n */\n const handleAction = useCallback(\n (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId?: string\n _strengthenOnPublish?: {type: 'skosConcept'; template: {id: 'skosConcept'}}\n _weak?: boolean\n }) => {\n if (\n isDraftId(conceptId?._originalId as DocumentId) ||\n isVersionId(conceptId?._originalId as DocumentId)\n ) {\n conceptId._strengthenOnPublish = {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n }\n conceptId._weak = true\n }\n\n delete conceptId._originalId\n\n // if there is a draft document, patch the new reference and\n // commit the change\n if (isDraft || isInRelease) {\n client\n .patch(documentId)\n .set({[name]: conceptId})\n .commit()\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n return\n }\n // if there is not a draft document, fetch the published\n // version and create a new document with the published\n // document id in the `drafts.` path and the new reference\n client\n .fetch('*[_id == $id][0]', {id: documentId})\n .then((res: ConceptSchemeDocument) => {\n res._id = `drafts.${res._id}`\n res[name] = conceptId\n client.create(res).catch((error) => console.error('Error creating draft: ', error))\n })\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n },\n [client, documentId, isDraft, isInRelease, name]\n )\n\n // Check to be sure a filter is present\n if (!(props.schemaType.options as ReferenceOptions)?.filter) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n The <code>ReferenceHierarchyInput()</code> component must be used with an accompanying{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code>. Please add an appropriate\n filter to the configuration for the {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // ... and that it is a scheme or branch filter and configured correctly\n else if ((props.schemaType.options as ReferenceOptions)?.filter.length === 0) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading your filter settings. Please check the{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code> configuration for the{' '}\n {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n } else if (schemeLoading || valuesLoading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading input component…\n </Text>\n </Flex>\n </Box>\n )\n }\n const isPublished = selectedPerspectiveName === 'published'\n\n // Render the browse-only preview UI\n const renderBrowseOnlyPreview = () => {\n if (value) {\n return props.renderDefault(props)\n }\n return (\n <Stack space={2}>\n <Box paddingY={3}>\n <Text size={1} weight={'medium'}>\n {title}\n </Text>\n </Box>\n <Card padding={3} radius={2} border>\n <Text muted align=\"center\" size={1}>\n No items\n </Text>\n </Card>\n </Stack>\n )\n }\n\n return (\n <Stack space={4}>\n {filterValues?.browseOnly ? renderBrowseOnlyPreview() : props.renderDefault(props)}\n\n <Grid columns={1} gap={3}>\n <Button\n disabled={isPublished}\n icon={NodeTree}\n text=\"Browse taxonomy tree\"\n mode=\"ghost\"\n onClick={browseHierarchy}\n />\n </Grid>\n {open && scheme && (\n <Dialog\n header={title}\n id=\"concept-select-dialog\"\n onClose={handleClose}\n zOffset={900}\n width={1}\n >\n <Box padding={10}>\n <TreeView\n document={scheme}\n branchId={branchId}\n inputComponent\n selectConcept={handleAction}\n expanded={filterValues?.expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n </Box>\n </Dialog>\n )}\n </Stack>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport type {DocumentId} from '@sanity/id-utils'\nimport {\n Grid,\n Stack,\n Button,\n Dialog,\n Box,\n Card,\n Label,\n Text,\n useToast,\n Flex,\n Spinner,\n} from '@sanity/ui'\nimport {useState, useEffect, useCallback} from 'react'\nimport type {ArrayFieldProps, ObjectOptions} from 'sanity'\nimport {useClient, useFormValue, isVersionId, isDraftId, usePerspective} from 'sanity'\n\nimport {useEmbeddingsRecs} from '../../hooks'\nimport NodeTree from '../../static/NodeTree'\nimport type {ConceptSchemeDocument, EmbeddingsIndexConfig} from '../../types'\nimport {TreeView} from '../TreeView'\n\ntype ReferenceOptions = ObjectOptions & {\n filter: ({getClient}: {getClient: () => ReturnType<typeof useClient>}) => Promise<{\n filter: string\n params: {\n concepts: string[]\n topConcepts?: string[]\n schemeId: string\n branchId?: string\n }\n expanded?: boolean\n browseOnly?: boolean\n }>\n}\n\ntype ArrayHierarchyInputProps = ArrayFieldProps & {\n embeddingsIndex?: EmbeddingsIndexConfig\n}\n\n// Extract the return type of the filter function\ntype FilterResult = Awaited<ReturnType<ReferenceOptions['filter']>>\n\n/**\n * Input component that replaces Sanity's default array field input with a\n * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms\n * organized in their scheme hierarchy and select terms to add to the array field.\n *\n * @remarks\n * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's\n * `options.filter`. Rendering without a filter will display a configuration warning.\n * - Supports only **single-schema arrays** (i.e., `of: [{type: 'reference'}]`). Arrays\n * with multiple schema types will render a warning and fall back to the default input.\n * - Taxonomy selection is disabled when viewing the published perspective.\n * - When `browseOnly` is set in the filter configuration, Sanity's default search input\n * is suppressed and only the tree browser is available for term selection.\n * - When `expanded` is set in the filter configuration, the hierarchy tree loads open\n * by default instead of collapsed.\n *\n * @param props - Standard Sanity `ArrayFieldProps` extended with an optional\n * `embeddingsIndex` configuration object.\n * @param props.embeddingsIndex - Optional configuration for AI-assisted term\n * recommendations via a Sanity Embeddings Index. When provided, opening the tree\n * browser queries the specified index and annotates matching taxonomy terms with\n * a relevance score to help authors identify the most appropriate terms.\n * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index\n * to query. Must be an index that includes `skosConcept` documents.\n * @param props.embeddingsIndex.fieldReferences - An array of field names from the\n * current document whose values are concatenated and sent as the embeddings search\n * query. All listed fields must contain values when the tree browser is opened;\n * empty fields will display an error message in the tree view rather than scores.\n * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching\n * terms to return from the embeddings index. Defaults to `3`.\n *\n * @example\n * Basic usage with a scheme filter:\n * ```js\n * import {ArrayHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'categories',\n * title: 'Categories',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * Branch filter with tree expanded by default:\n * ```js\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'habitats',\n * title: 'Habitats',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * Browse-only mode (suppresses the default Sanity search input):\n * ```js\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'habitats',\n * title: 'Habitats',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * AI-assisted recommendations via an embeddings index:\n * ```jsx\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'categories',\n * title: 'Categories',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: [{type: 'skosConcept'}],\n * options: {\n * filter: branchFilter({schemeId: 'f3deba', branchId: '25f826'}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {\n * field: (props) => (\n * <ArrayHierarchyInput\n * {...props}\n * embeddingsIndex={{\n * indexName: 'my-taxonomy-index',\n * fieldReferences: ['title', 'description'],\n * maxResults: 4,\n * }}\n * />\n * ),\n * },\n * })\n * ```\n *\n * @see {@link ReferenceHierarchyInput} for single-value `reference` fields\n * @see {@link schemeFilter} for filtering by a full concept scheme\n * @see {@link branchFilter} for filtering by a branch within a concept scheme\n */\nexport function ArrayHierarchyInput(props: ArrayHierarchyInputProps) {\n const client = useClient({apiVersion: '2025-02-19'})\n\n // the resource document in which the input component appears:\n const documentId = useFormValue(['_id']) as string\n // name of the field to input a value:\n const {name, title, value = [], embeddingsIndex} = props\n\n // Get release and draft status of the document\n const isInRelease = isVersionId(documentId as DocumentId)\n const isDraft = isDraftId(documentId as DocumentId)\n // Selected Perspective is also used in the Tree view component. Consider tidying.\n const {selectedPerspectiveName} = usePerspective()\n\n const [schemeLoading, setSchemeLoading] = useState(true)\n const [valuesLoading, setValuesLoading] = useState(true)\n const [open, setOpen] = useState(false)\n\n // the skosConceptScheme document identified by the field filter options:\n const [scheme, setScheme] = useState({})\n // State to store resolved filter values:\n const [filterValues, setFilterValues] = useState<FilterResult | undefined>()\n\n // use filterValues if available, otherwise fallback to default:\n const {schemeId, branchId = null} = filterValues?.params || {}\n\n const {filter} = props.schemaType.of[0].options as ReferenceOptions\n\n const {conceptRecs, recsError, triggerEmbeddingsSearch} = useEmbeddingsRecs(embeddingsIndex)\n\n const toast = useToast()\n\n // Fetch filter values from `reference` field filter asynchronously\n useEffect(() => {\n async function fetchFilterValues() {\n try {\n const resolvedFilterValues = await filter({getClient: () => client})\n setFilterValues(resolvedFilterValues)\n // Store the resolved filter values in state\n setValuesLoading(false)\n } catch (error) {\n console.error('Error fetching filter values: ', error)\n }\n }\n fetchFilterValues().catch((error) => console.error('Error fetching filter values: ', error))\n }, [filter, client])\n\n // get the skosConceptScheme document identified by the field filter options\n useEffect(() => {\n if (!schemeId) return\n client\n .fetch(`{\"displayed\": *[schemeId == \"${schemeId}\"][0]}`)\n .then((res: {displayed?: ConceptSchemeDocument['displayed']}) => {\n if (res?.displayed) {\n setScheme(res)\n setSchemeLoading(false)\n }\n })\n .catch((err) => console.warn(err))\n }, [client, schemeId])\n\n const browseHierarchy = useCallback(() => {\n setOpen(true)\n triggerEmbeddingsSearch()\n }, [triggerEmbeddingsSearch])\n\n const handleClose = useCallback(() => {\n setOpen(false)\n }, [])\n\n /**\n * #### Term Select Action\n * Writes the selected taxonomy term to the array field\n */\n const handleAction = useCallback(\n (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId?: string\n _strengthenOnPublish?: {type: 'skosConcept'; template: {id: 'skosConcept'}}\n _weak?: boolean\n }) => {\n if (\n isDraftId(conceptId?._originalId as string) ||\n isVersionId(conceptId?._originalId as string)\n ) {\n conceptId._strengthenOnPublish = {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n }\n conceptId._weak = true\n }\n\n delete conceptId._originalId\n\n // If the ref of the selected term is already in the field close the dialog\n // and provide a toast message that tht entry is already in the field.\n const typedValue = value as Array<{_key: string; _ref: string}> | undefined\n if (typedValue?.map((item) => item._ref).includes(conceptId._ref)) {\n setOpen(false)\n toast.push({\n status: 'warning',\n title: 'Taxonomy Term Not Added',\n description: 'The selected concept is already included in this field.',\n duration: 5000,\n closable: true,\n })\n return\n }\n // if there is a draft document, patch the new reference and\n // commit the change\n if (isDraft || isInRelease) {\n client\n .patch(documentId)\n .setIfMissing({[name]: []})\n .append(name, [conceptId])\n .commit({autoGenerateArrayKeys: true})\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n return\n }\n // if there is not a draft document, fetch the published\n // version and create a new document with the published\n // document id in the `drafts.` path and the new reference\n client\n .fetch(`*[_id == \"${documentId}\"][0]`)\n .then((res: ConceptSchemeDocument) => {\n res._id = `drafts.${res._id}`\n client.create(res).catch((error) => console.error('Error creating draft: ', error))\n })\n .then(() => {\n client\n .patch(`drafts.${documentId}`)\n .setIfMissing({[name]: []})\n .append(name, [conceptId])\n .commit({autoGenerateArrayKeys: true})\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n })\n .catch((err) => console.error(err))\n },\n [value, isDraft, isInRelease, client, documentId, toast, name]\n )\n\n // Check to be sure a filter is present\n if (!(props.schemaType.of[0].options as ReferenceOptions)?.filter) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n The <code>ArrayHierarchyInput()</code> component must be used with an accompanying{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code>. Please add an appropriate\n filter to the configuration for the {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // ... and that it is a scheme or branch filter and configured correctly\n else if ((props.schemaType.of[0].options as ReferenceOptions)?.filter?.length === 0) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading your filter settings. Please check the{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code> configuration for the{' '}\n {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // Check to see if array uses more than one schema and bail with a notification if more than one is detected.\n else if (props.schemaType.of.length > 1) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Stack space={4}>\n <Stack space={2}>\n <Label size={2}>Input Component Not Supported for Multi-Schema Arrays</Label>\n <Text size={1}>\n The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support\n array inputs with more than one schema type. Please see the{' '}\n <a href=\"https://sanitytaxonomymanager.com\">Taxonomy Manager docs</a> for more\n information.\n </Text>\n </Stack>\n </Stack>\n </Card>\n </Stack>\n )\n } else if (schemeLoading || valuesLoading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading input component…\n </Text>\n </Flex>\n </Box>\n )\n }\n\n const isPublished = selectedPerspectiveName === 'published'\n\n // Render the browse-only preview UI for arrays\n const renderBrowseOnlyPreview = () => {\n if (value.length > 0) {\n return props.renderDefault(props)\n }\n\n return (\n <Stack space={2}>\n <Box paddingY={3}>\n <Text size={1} weight={'medium'}>\n {title}\n </Text>\n </Box>\n <Card padding={3} radius={2} border>\n <Text muted align=\"center\" size={1}>\n No items\n </Text>\n </Card>\n </Stack>\n )\n }\n\n return (\n <Stack space={3}>\n {filterValues?.browseOnly ? renderBrowseOnlyPreview() : props.renderDefault(props)}\n\n <Grid columns={1} gap={3}>\n <Button\n disabled={isPublished}\n icon={NodeTree}\n text=\"Browse taxonomy tree\"\n mode=\"ghost\"\n onClick={browseHierarchy}\n />\n </Grid>\n {open && (\n <Dialog\n header={title}\n id=\"concept-select-dialog\"\n onClose={handleClose}\n zOffset={900}\n width={1}\n >\n <Box>\n <TreeView\n document={scheme as ConceptSchemeDocument}\n branchId={branchId}\n inputComponent\n selectConcept={handleAction}\n expanded={filterValues?.expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n </Box>\n </Dialog>\n )}\n </Stack>\n )\n}\n","import {Button, Inline, Stack, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {unset} from 'sanity'\n\n/**\n * #### Input Component for Deprecated Management Controls Field\n * The Management Controls field was used for a previous version\n * of the plugin and was set by default when creating a new scheme.\n * It has been set to \"Deprecated.\" This control will allow users\n * to delete the value from the input to hide the field, without\n * otherwise seeing an error int their schema.\n * - Input is only visible if no identifier has been assigned\n * - Input disappears once an ID is generated\n */\nexport const ManagementControls = (props: any) => {\n const {onChange} = props\n const toast = useToast()\n\n const handleChange = useCallback(() => {\n onChange(unset())\n toast.push({\n status: 'success',\n title: 'Value removed.',\n duration: 2500,\n closable: true,\n })\n }, [onChange, toast])\n\n return (\n <Stack space={2}>\n <Inline space={[3, 3, 4]}>\n {props.renderDefault(props)}\n <Button tone=\"primary\" fontSize={2} onClick={handleChange} text=\"Remove Value\" />\n </Inline>\n </Stack>\n )\n}\n","import type {useClient} from 'sanity'\n\ntype SchemeOptions = {\n schemeId: string\n expanded?: boolean\n browseOnly?: boolean\n}\n\ntype SchemeFilterResult = {\n filter: string\n params: {\n schemeId: string\n concepts: string[]\n topConcepts: string[]\n }\n expanded?: boolean\n browseOnly?: boolean\n}\n\n/**\n * #### Reference Field Scheme Filter\n * Pluggable Function for Filtering to a Single SKOS Concept Scheme.\n * @param {string} schemeId - The unique six character concept identifier for\n * the Concept Scheme to which you wish to filter.\n * @param {boolean} [expanded] - Set to `true` to display open hierarchy trees for\n * input components. Input component trees load closed by default.\n * @param {boolean} [browseOnly] - Set to `true` to hide the default Sanity search\n * input and display only the \"Browse Taxonomy Tree\" button for selecting terms.\n * @returns A reference type filter for Concepts and Top Concepts in\n * the selected Concept Scheme test\n * @example\n * ```ts\n * import { schemeFilter } from 'sanity-plugin-taxonomy-manager'\n * ...\n * {\n * name: 'test',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({\n * schemeId: 'a1b2c3',\n * expanded: true, // optional; defaults to false (closed tree)\n * browseOnly: true, // optional; hides search input\n * }),\n * disableNew: true,\n * },\n * },\n * ],\n * }\n * ```\n */\nexport const schemeFilter = (\n options: SchemeOptions\n): (({\n getClient,\n}: {\n getClient: (clientOptions: {apiVersion: string}) => ReturnType<typeof useClient>\n}) => Promise<SchemeFilterResult>) => {\n // Get and validate the schemeId from options\n const {schemeId} = options || {}\n\n if (!schemeId || typeof schemeId !== 'string') {\n throw new Error('Invalid or missing schemeId: scheme Id must be a string')\n }\n\n return async (props) => {\n const client = props?.getClient({apiVersion: '2025-02-19'})\n if (!client) {\n throw new Error('Client not available')\n }\n // Fetch concepts and topConcepts for the given schemeId\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion\n const {concepts, topConcepts} = (await client.fetch(\n `{\n \"concepts\": *[_type==\"skosConceptScheme\" && schemeId == \"${schemeId}\"].concepts[]._ref,\n \"topConcepts\": *[_type==\"skosConceptScheme\" && schemeId == \"${schemeId}\"].topConcepts[]._ref\n }`\n )) as {concepts: string[]; topConcepts: string[]}\n // schemeId is included in params for use by the ArrayHierarchyInput component\n return {\n filter: `(_id in $concepts\n || _id in $topConcepts)`,\n params: {concepts, topConcepts, schemeId},\n expanded: options?.expanded,\n browseOnly: options?.browseOnly,\n }\n }\n}\n","import type {useClient} from 'sanity'\n\ntype BranchOptions = {\n schemeId: string\n branchId: string\n expanded?: boolean\n browseOnly?: boolean\n}\n\ntype BranchFilterResult = {\n filter: string\n params: {\n schemeId: string\n branchId: string\n concepts: string[]\n }\n expanded?: boolean\n browseOnly?: boolean\n}\n\n/**\n * #### Reference Field Scheme & Branch Filter\n * A pluggable Function for Filtering to a Top Concept Branch within a SKOS Concept Scheme\n * @param {string} schemeId - The unique six character concept identifier for\n * the Concept Scheme to which you wish to filter.\n * @param {string} branchId - The unique six character concept identifier of\n * a branch. Child concepts will be returned.\n * @param {boolean} [expanded] - Set to `true` to display open hierarchy trees for\n * input components. Input component trees load closed by default.\n * @param {boolean} [browseOnly] - Set to `true` to hide the default Sanity search\n * input and display only the \"Browse Taxonomy Tree\" button for selecting terms.\n * @returns A reference type filter for the child concepts of the designated branch in the selected Concept Scheme\n * @example\n * ```ts\n * import { branchFilter } from 'sanity-plugin-taxonomy-manager'\n * ...\n * {\n * name: 'test',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({\n * schemeId: 'a1b2c3',\n * branchId: 'd4e5f6',\n * expanded: true, // optional; defaults to false (closed tree)\n * browseOnly: true, // optional; hides search input\n * }),\n * disableNew: true,\n * },\n * },\n * ],\n * }\n * ```\n */\nexport const branchFilter = (\n options: BranchOptions\n): (({\n getClient,\n}: {\n getClient: (clientOptions: {apiVersion: string}) => ReturnType<typeof useClient>\n}) => Promise<BranchFilterResult>) => {\n const {schemeId, branchId = null} = options || {}\n\n if (!schemeId || typeof schemeId !== 'string') {\n throw new Error('Invalid or missing schemeId: scheme Id must be a string')\n }\n\n if (!branchId || typeof branchId !== 'string') {\n throw new Error('Invalid or missing branchId: branch Id must be a string')\n }\n\n return async (props) => {\n const client = props?.getClient({apiVersion: '2023-01-01'})\n if (!client) {\n throw new Error('Client not available')\n }\n\n // Fetch concepts for the given schemeId and branchId\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion\n const {concepts} = (await client.fetch(\n `{ \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 }`,\n {schemeId, branchId}\n )) as {concepts: string[]}\n // schemeId is included in params for use by the ArrayHierarchyInput component\n return {\n filter: `_id in $concepts`,\n params: {concepts, schemeId, branchId},\n expanded: options?.expanded,\n browseOnly: options?.browseOnly,\n }\n }\n}\n","import {defineField} from 'sanity'\n\nimport {RdfUri} from '../components/inputs'\n\nimport styles from './baseIriField.module.css'\n\n/**\n * #### Base Universal Resource Identifier object for Sanity Taxonomy Manager\n * Used for Concept and Concept Scheme URI fields\n */\nexport default [\n defineField({\n name: 'baseIri',\n title: 'Base URI',\n type: 'url',\n validation: (Rule) =>\n Rule.required().error(`Please supply a base URI in the format 'http://example.com/'`),\n description: (\n <details className={styles.description}>\n <summary>\n The root URI (Uniform Resource Identifier) used to create unique concept identifiers.\n </summary>\n <div>\n Unique identifiers allow for the clear an unambiguous identification of concepts across\n namespaces, for example between <code>https://shipparts.com/vocab#Bow</code> and {}\n <code>https://wrappingsupplies.com/vocab#Bow</code>.\n </div>\n <div>\n In most cases, it makes sense for your base URI to be the root or a subdirectory of your\n website. In all cases, the URI you choose should be in a domain that you control.\n </div>\n <div>\n For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the\n most recently used Base URI value.\n </div>\n </details>\n ),\n components: {\n input: RdfUri as any,\n },\n }),\n]\n","import {Stack, Text} from '@sanity/ui'\nimport {useFormValue} from 'sanity'\nimport type {StringInputProps} from 'sanity'\n\n/**\n * #### SKOS Concept Base URI input component\n * Used for Concept and Concept Scheme URI preview\n */\nexport function RdfUri(props: StringInputProps) {\n const conceptId = useFormValue(['conceptId'])\n const schemeId = useFormValue(['schemeId'])\n return (\n <Stack space={2}>\n {props.renderDefault(props)}\n <Text muted size={1}>\n <>\n <strong>RDF URI: </strong>\n {props.value ? props.value : '[base URI not defined] '}\n {conceptId || schemeId || ' [identifier not assigned]'}\n </>\n </Text>\n </Stack>\n )\n}\n","import {WarningOutlineIcon} from '@sanity/icons'\nimport {DocumentId, getPublishedId} from '@sanity/id-utils'\nimport {AiOutlineTag, AiOutlineTags} from 'react-icons/ai'\nimport {defineType, defineField} from 'sanity'\nimport type {SanityDocument} from 'sanity'\n\nimport {Identifier} from './components/inputs'\nimport baseIriField from './helpers/baseIriField'\nimport {createId} from './helpers/createId'\nimport styles from './skosConcept.module.css'\nimport type {Options} from './types'\n\nconst conceptFilter = ({document}: {document: SanityDocument}) => {\n const publishedId = getPublishedId(DocumentId(document._id))\n return {\n filter: '!(_id in $broader || _id in $related || _id == $self)',\n params: {\n self: publishedId,\n broader: Array.isArray(document?.broader)\n ? document.broader.map(({_ref}: {_ref: string}) => _ref)\n : [],\n related: Array.isArray(document?.related)\n ? document.related.map(({_ref}: {_ref: string}) => _ref)\n : [],\n },\n }\n}\n\n/**\n * Sanity document scheme for SKOS Taxonomy Concepts\n */\nexport default function skosConcept(\n baseUri?: Options['baseUri'],\n customConceptFields: Options['customConceptFields'] = [],\n ident?: Options['ident']\n) {\n return defineType({\n name: 'skosConcept',\n title: 'Concept',\n type: 'document',\n icon: AiOutlineTags,\n initialValue: async (_, context) => {\n if (baseUri)\n return {\n baseIri: baseUri,\n broader: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n related: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n }\n\n const {getClient} = context\n const client = getClient({apiVersion: '2021-03-25'})\n const baseIri =\n (await client.fetch<string | null>(`\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n `)) ?? undefined\n return {\n baseIri: baseIri,\n broader: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n related: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n }\n },\n fields: [\n defineField({\n name: 'prefLabel',\n title: 'Preferred Label',\n type: 'string',\n description: 'The preferred lexical label for this concept.',\n validation: (Rule) =>\n Rule.required().custom((prefLabel, context) => {\n const {getClient} = context\n const client = getClient({apiVersion: '2025-06-10'}).withConfig({perspective: 'raw'})\n return client\n .fetch(\n `*[_type == \"skosConcept\" && prefLabel == \"${\n prefLabel as string\n }\" && !(_id in path(\"drafts.**\") || _id in path(\"versions.**\"))][0]._id`\n )\n .then((conceptId) => {\n if (conceptId && !context.document?._id.includes(conceptId as string)) {\n return 'Preferred Label must be unique.'\n }\n return true\n })\n }),\n }),\n defineField({\n name: 'definition',\n title: 'Definition',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>A complete explanation of the intended meaning of the concept.</summary>\n <div>\n <kbd>\n Example: documentation\n <br />\n Definition: \"The process of storing and retrieving information in all fields of\n knowledge.\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'example',\n title: 'Examples',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>An example of the use of the concept.</summary>\n <div>\n <kbd>\n Example: organizations of science and culture\n <br />\n Example: \"academies of science, general museums, world fairs\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'scopeNote',\n title: 'Scope Note',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n A brief statement on the intended meaning of this concept, especially as an indication\n of how the use of the concept is limited in indexing practice.\n </summary>\n <div>\n <kbd>\n Example: microwave frequencies\n <br />\n Scope Note: \"Used for frequencies between 1Ghz and 300Ghz\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'altLabel',\n title: 'Alternate Label(s)',\n type: 'array',\n description: (\n <details className={styles.description}>\n <summary>Synonyms, near-synonyms, abbreviations, and acronyms to a concept.</summary>\n <div>\n <p>\n <WarningOutlineIcon /> Preferred, alternative, and hidden label sets must not\n overlap.\n </p>\n </div>\n </details>\n ),\n of: [{type: 'string'}],\n validation: (Rule) => Rule.unique(),\n }),\n defineField({\n name: 'hiddenLabel',\n title: 'Hidden Label(s)',\n type: 'array',\n description: (\n <details className={styles.description}>\n <summary>\n Character strings that need to be accessible to applications performing text-based\n indexing and search operations, but which should not be displayed to end users.\n </summary>\n <div>\n <p>\n Hidden labels may for instance be used to include misspelled variants of other\n lexical labels.\n </p>\n <p>\n <WarningOutlineIcon /> Preferred, alternative, and hidden label sets must not\n overlap.\n </p>\n </div>\n </details>\n ),\n of: [{type: 'string'}],\n validation: (Rule) => Rule.unique(),\n }),\n ...baseIriField,\n defineField({\n name: 'conceptId',\n title: 'Identifier',\n description:\n \"Generate or re-generate the identifier for this concept according to parameters set in Taxonomy Manager plugin options. Note that this changes the concept's URI, which is not advisable if the concept is already in use in production. Use with caution.\",\n type: 'string',\n initialValue: createId(ident),\n hidden: ({document}) => !!document?.conceptId && !ident?.regenUi,\n readOnly: ({document}) => !!document?.conceptId,\n components: {\n input: (props) => <Identifier {...props} ident={ident} />,\n },\n }),\n defineField({\n name: 'broader',\n title: 'Broader Concept(s)',\n description: (\n <details className={styles.description}>\n <summary>\n Create hierarchy between concepts, for example to create category/subcategory,\n part/whole, or class/instance relationships.\n </summary>\n <div>\n <p>Broader and Associated relationships are mutually exclusive.</p>\n </div>\n </details>\n ),\n type: 'array',\n of: [\n {\n type: 'reference',\n to: {type: 'skosConcept'},\n options: {\n filter: conceptFilter,\n },\n },\n ],\n }),\n defineField({\n name: 'related',\n title: 'Related Concept(s)',\n description: (\n <details className={styles.description}>\n <summary>\n Indicate that two concepts are inherently \"related\", but that one is not in any way\n more general than the other.\n </summary>\n <div>\n <p>Broader and Associated relationships are mutually exclusive.</p>\n </div>\n </details>\n ),\n type: 'array',\n of: [\n {\n type: 'reference',\n to: [{type: 'skosConcept'}],\n options: {\n filter: conceptFilter,\n },\n },\n ],\n }),\n ...customConceptFields,\n defineField({\n name: 'historyNote',\n title: 'History Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>Significant changes to the meaning or the form of this concept.</summary>\n <div>\n <kbd>\n Example: person with disabilities\n <br />\n History Note: \"Estab. 1992; heading was: handicapped [1884 - 1992].\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'editorialNote',\n title: 'Editorial Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n Information to aid in administrative housekeeping, such as reminders of editorial work\n still to be done, or warnings in the event that future editorial changes might be\n made.\n </summary>\n <div>\n <kbd>\n Example: doubleclick\n <br />\n Editorial Note: \"Review this term after the company merger is complete.\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'changeNote',\n title: 'Change Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n Fine-grained changes to a concept, for the purposes of administration and maintenance.\n </summary>\n <div>\n <kbd>\n Example: tomato\n <br />\n Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n ],\n orderings: [\n {\n title: 'Top Concepts',\n name: 'topConcept',\n by: [\n {field: 'topConcept', direction: 'desc'},\n {field: 'prefLabel', direction: 'asc'},\n ],\n },\n {\n title: 'Preferred Label',\n name: 'prefLabel',\n by: [{field: 'prefLabel', direction: 'asc'}],\n },\n ],\n preview: {\n select: {\n title: 'prefLabel',\n },\n prepare({title}: {title: string}) {\n return {\n title: title,\n media: AiOutlineTag,\n }\n },\n },\n })\n}\n","// import {nanoid} from 'nanoid'\n// import type {FieldDefinition} from 'sanity'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nimport {Identifier, ManagementControls} from './components/inputs'\nimport baseIriField from './helpers/baseIriField'\nimport {createId} from './helpers/createId'\nimport NodeTree from './static/NodeTree'\nimport type {Options} from './types'\n\n/**\n * Sanity document scheme for SKOS Concept Schemes\n */\nexport default function skosConceptScheme(\n baseUri?: Options['baseUri'],\n customSchemeFields: Options['customSchemeFields'] = [],\n ident?: Options['ident']\n) {\n return defineType({\n name: 'skosConceptScheme',\n title: 'Concept Scheme',\n type: 'document',\n icon: NodeTree,\n initialValue: async (_, context) => {\n if (baseUri) return {baseIri: baseUri}\n const {getClient} = context\n const client = getClient({apiVersion: '2021-03-25'})\n const baseIri =\n (await client.fetch<string | null>(`\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n `)) ?? undefined\n return {\n baseIri: baseIri,\n }\n },\n fields: [\n defineField({\n name: 'title',\n title: 'Title',\n type: 'string',\n description:\n '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',\n }),\n defineField({\n name: 'description',\n title: 'Description',\n type: 'text',\n rows: 5,\n description: 'Describe the intended use of this scheme.',\n }),\n defineField({\n name: 'controls',\n title: 'Concept Management Controls',\n deprecated: {\n reason:\n 'This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field.',\n },\n type: 'boolean',\n readOnly: true,\n hidden: ({document}) => document?.controls === undefined,\n components: {\n input: ManagementControls,\n },\n }),\n ...baseIriField,\n defineField({\n name: 'schemeId',\n title: 'Identifier',\n description:\n \"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.\",\n type: 'string',\n initialValue: createId(ident),\n hidden: ({document}) => !!document?.schemeId && !ident?.regenUi,\n readOnly: ({document}) => !!document?.schemeId,\n components: {\n input: (props) => <Identifier {...props} ident={ident} />,\n },\n }),\n defineField({\n name: 'topConcepts',\n title: 'Top Concepts',\n type: 'array',\n validation: (Rule) => Rule.unique(),\n of: [\n defineArrayMember({\n type: 'reference',\n to: [{type: 'skosConcept'}],\n }),\n ],\n options: {\n sortable: false,\n },\n }),\n defineField({\n name: 'concepts',\n title: 'Concepts',\n type: 'array',\n validation: (Rule) => Rule.unique(),\n of: [\n defineArrayMember({\n type: 'reference',\n to: [{type: 'skosConcept'}],\n }),\n ],\n options: {\n sortable: false,\n },\n }),\n ...customSchemeFields,\n ],\n preview: {\n select: {\n title: 'title',\n },\n prepare({title}: {title: string}) {\n return {\n title: title,\n media: NodeTree,\n }\n },\n },\n })\n}\n","function isObject(obj) {\n return typeof obj == \"object\" && obj !== null && !Array.isArray(obj);\n}\nfunction isReference(reference) {\n return isObject(reference) && typeof reference._ref == \"string\";\n}\nfunction isImage(value) {\n return isObject(value) && isReference(value.asset) && value.asset._ref.startsWith(\"image-\");\n}\nfunction isCrossDatasetReference(reference) {\n return isObject(reference) && typeof reference._ref == \"string\" && typeof reference._dataset == \"string\" && typeof reference._projectId == \"string\";\n}\nfunction isSanityDocument(document) {\n return isObject(document) && typeof document._id == \"string\" && typeof document._type == \"string\";\n}\nfunction isTypedObject(obj) {\n return isObject(obj) && typeof obj._type == \"string\";\n}\nfunction isKeyedObject(obj) {\n return isObject(obj) && typeof obj._key == \"string\";\n}\nfunction isGlobalDocumentReference(reference) {\n return !isObject(reference) || typeof reference._ref != \"string\" ? !1 : reference._ref.split(\":\").length === 3;\n}\nfunction isValidationErrorMarker(marker) {\n return marker.level === \"error\";\n}\nfunction isValidationWarningMarker(marker) {\n return marker.level === \"warning\";\n}\nfunction isValidationInfoMarker(marker) {\n return marker.level === \"info\";\n}\nconst MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME = \"sanity.asset.aspect\";\nfunction isAssetAspect(maybeAssetAspect) {\n return typeof maybeAssetAspect == \"object\" && maybeAssetAspect !== null && \"_type\" in maybeAssetAspect && maybeAssetAspect._type === MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME;\n}\nfunction defineAssetAspect(definition) {\n const { assetType, name } = definition;\n return {\n _type: MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME,\n _id: `${name}`,\n definition,\n ...assetType && {\n assetType: Array.isArray(assetType) ? assetType : [assetType]\n },\n public: definition.public\n };\n}\nfunction isCreateMutation(mutation) {\n return \"create\" in mutation;\n}\nfunction isCreateIfNotExistsMutation(mutation) {\n return \"createIfNotExists\" in mutation;\n}\nfunction isCreateOrReplaceMutation(mutation) {\n return \"createOrReplace\" in mutation;\n}\nfunction isDeleteMutation(mutation) {\n return \"delete\" in mutation;\n}\nfunction isPatchMutation(mutation) {\n return \"patch\" in mutation;\n}\nconst reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, reIndexTuple = /^\\d*:\\d*$/;\nfunction isIndexSegment(segment) {\n return typeof segment == \"number\" || typeof segment == \"string\" && /^\\[\\d+\\]$/.test(segment);\n}\nfunction isKeySegment(segment) {\n return typeof segment == \"string\" ? reKeySegment.test(segment.trim()) : typeof segment == \"object\" && \"_key\" in segment;\n}\nfunction isIndexTuple(segment) {\n if (typeof segment == \"string\" && reIndexTuple.test(segment))\n return !0;\n if (!Array.isArray(segment) || segment.length !== 2)\n return !1;\n const [from, to] = segment;\n return (typeof from == \"number\" || from === \"\") && (typeof to == \"number\" || to === \"\");\n}\nfunction isRecord$1(value) {\n return !!value && (typeof value == \"object\" || typeof value == \"function\");\n}\nfunction isPortableTextTextBlock(value) {\n return isRecord$1(value) && typeof value._type == \"string\" && // block types can be named, so expect anything here.\n Array.isArray(value.children) && value.children.every((child) => isRecord$1(child)) && (\"markDefs\" in value ? Array.isArray(value.markDefs) && value.markDefs.every((def) => isRecord$1(def)) : !0) && (\"style\" in value ? typeof value.style == \"string\" : !0);\n}\nfunction isPortableTextSpan(value) {\n return isRecord$1(value) && value._type === \"span\" && typeof value.text == \"string\" && (\"marks\" in value ? Array.isArray(value.marks) && value.marks.every((mark) => typeof mark == \"string\") : !0);\n}\nfunction isPortableTextListBlock(value) {\n return isPortableTextTextBlock(value) && \"listItem\" in value && typeof value.listItem == \"string\" && \"level\" in value && Number.isInteger(value.level);\n}\nfunction isRecord(value) {\n return !!value && (typeof value == \"object\" || typeof value == \"function\");\n}\nfunction isDocumentSchemaType(type) {\n if (!isObjectSchemaType(type))\n return !1;\n let current = type;\n for (; current; ) {\n if (current.name === \"document\")\n return !0;\n current = current.type;\n }\n return !1;\n}\nfunction isObjectSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"object\" : !1;\n}\nfunction isArraySchemaType(type) {\n return isRecord(type) ? type.jsonType === \"array\" : !1;\n}\nfunction isArrayOfBlocksSchemaType(type) {\n return isArraySchemaType(type) && type.of.some((memberType) => isBlockSchemaType(memberType));\n}\nfunction isArrayOfObjectsSchemaType(type) {\n return isArraySchemaType(type) && type.of.every((memberType) => isObjectSchemaType(memberType));\n}\nfunction isArrayOfPrimitivesSchemaType(type) {\n return isArraySchemaType(type) && type.of.every((memberType) => isPrimitiveSchemaType(memberType));\n}\nfunction isBooleanSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"boolean\" : !1;\n}\nfunction isStringSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"string\" : !1;\n}\nfunction isDateTimeSchemaType(type) {\n return isStringSchemaType(type) ? type.name === \"datetime\" : !1;\n}\nfunction isNumberSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"number\" : !1;\n}\nfunction isPrimitiveSchemaType(type) {\n return isBooleanSchemaType(type) || isStringSchemaType(type) || isNumberSchemaType(type);\n}\nfunction isReferenceSchemaType(type) {\n return isRecord(type) && (type.name === \"reference\" || isReferenceSchemaType(type.type));\n}\nfunction isImageSchemaType(type) {\n return isRecord(type) && (type.name === \"image\" || isImageSchemaType(type.type));\n}\nfunction isFileSchemaType(type) {\n return isRecord(type) && (type.name === \"file\" || isFileSchemaType(type.type));\n}\nfunction isDeprecatedSchemaType(type) {\n return isRecord(type) ? typeof type.deprecated < \"u\" : !1;\n}\nfunction isDeprecationConfiguration(type) {\n return isRecord(type) ? typeof type.deprecated < \"u\" : !1;\n}\nfunction isCrossDatasetReferenceSchemaType(type) {\n return isRecord(type) && (type.name === \"crossDatasetReference\" || isCrossDatasetReferenceSchemaType(type.type));\n}\nfunction isTitledListValue(item) {\n return typeof item == \"object\" && item !== null && \"title\" in item && \"value\" in item;\n}\nfunction isSpanSchemaType(type) {\n return isRecord(type) ? Array.isArray(type.annotations) && Array.isArray(type.decorators) : !1;\n}\nfunction isBlockSchemaType(type) {\n if (!isRecord(type) || !Array.isArray(type.fields)) return !1;\n const maybeSpanChildren = type.fields.find(isBlockChildrenObjectField), maybeStyle = type.fields.find(isBlockStyleObjectField), maybeList = type.fields.find(isBlockListObjectField);\n return isBlockChildrenObjectField(maybeSpanChildren) && isBlockStyleObjectField(maybeStyle) && isBlockListObjectField(maybeList);\n}\nfunction isBlockStyleObjectField(field) {\n return !isRecord(field) || field.name !== \"style\" ? !1 : isRecord(field.type) && field.type.jsonType === \"string\";\n}\nfunction isBlockListObjectField(field) {\n return !isRecord(field) || field.name !== \"listItem\" ? !1 : isRecord(field.type) && field.type.jsonType === \"string\";\n}\nfunction isBlockChildrenObjectField(field) {\n return !isRecord(field) || field.name !== \"children\" || !isArraySchemaType(field.type) ? !1 : field.type.of.some(isSpanSchemaType);\n}\nfunction defineType(schemaDefinition, defineOptions) {\n return schemaDefinition;\n}\nfunction defineField(schemaField, defineOptions) {\n return schemaField;\n}\nfunction defineArrayMember(arrayOfSchema, defineOptions) {\n return arrayOfSchema;\n}\nfunction typed(input) {\n return input;\n}\nconst searchStrategies = [\"groqLegacy\", \"groq2024\"];\nfunction isSearchStrategy(maybeSearchStrategy) {\n return searchStrategies.includes(maybeSearchStrategy);\n}\nfunction isSlug(thing) {\n return isObject(thing) && typeof thing.current == \"string\";\n}\nfunction isCreateSquashedMutation(mutation) {\n return \"createSquashed\" in mutation;\n}\nfunction isValidationError(node) {\n return node.level === \"error\";\n}\nfunction isValidationWarning(node) {\n return node.level === \"warning\";\n}\nfunction isValidationInfo(node) {\n return node.level === \"info\";\n}\nexport {\n MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME,\n defineArrayMember,\n defineAssetAspect,\n defineField,\n defineType,\n isArrayOfBlocksSchemaType,\n isArrayOfObjectsSchemaType,\n isArrayOfPrimitivesSchemaType,\n isArraySchemaType,\n isAssetAspect,\n isBlockChildrenObjectField,\n isBlockListObjectField,\n isBlockSchemaType,\n isBlockStyleObjectField,\n isBooleanSchemaType,\n isCreateIfNotExistsMutation,\n isCreateMutation,\n isCreateOrReplaceMutation,\n isCreateSquashedMutation,\n isCrossDatasetReference,\n isCrossDatasetReferenceSchemaType,\n isDateTimeSchemaType,\n isDeleteMutation,\n isDeprecatedSchemaType,\n isDeprecationConfiguration,\n isDocumentSchemaType,\n isFileSchemaType,\n isGlobalDocumentReference,\n isImage,\n isImageSchemaType,\n isIndexSegment,\n isIndexTuple,\n isKeySegment,\n isKeyedObject,\n isNumberSchemaType,\n isObjectSchemaType,\n isPatchMutation,\n isPortableTextListBlock,\n isPortableTextSpan,\n isPortableTextTextBlock,\n isPrimitiveSchemaType,\n isReference,\n isReferenceSchemaType,\n isSanityDocument,\n isSearchStrategy,\n isSlug,\n isSpanSchemaType,\n isStringSchemaType,\n isTitledListValue,\n isTypedObject,\n isValidationError,\n isValidationErrorMarker,\n isValidationInfo,\n isValidationInfoMarker,\n isValidationWarning,\n isValidationWarningMarker,\n searchStrategies,\n typed\n};\n//# sourceMappingURL=index.mjs.map\n","import { isIndexSegment, isKeySegment, isIndexTuple } from \"@sanity/types\";\nconst rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g, reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, EMPTY_PATH = [], FOCUS_TERMINATOR = \"$\", GROQ_DATA_TYPE_VALUES = [\"true\", \"false\", \"null\"];\nfunction get(obj, path, defaultVal) {\n const select = typeof path == \"string\" ? fromString(path) : path;\n if (!Array.isArray(select))\n throw new Error(\"Path must be an array or a string\");\n let acc = obj;\n for (let i = 0; i < select.length; i++) {\n const segment = select[i];\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc[segment];\n }\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc.find((item) => item._key === segment._key);\n }\n if (typeof segment == \"string\" && (acc = typeof acc == \"object\" && acc !== null ? acc[segment] : void 0), typeof acc > \"u\")\n return defaultVal;\n }\n return acc;\n}\nconst pathsMemo = /* @__PURE__ */ new Map();\nfunction pathFor(path) {\n if (path.length === 0)\n return EMPTY_PATH;\n const asString = toString(path);\n return pathsMemo.has(asString) ? pathsMemo.get(asString) : (pathsMemo.set(asString, path), Object.freeze(path), path);\n}\nfunction isEqual(path, otherPath) {\n return path.length === otherPath.length && path.every((segment, i) => isSegmentEqual(segment, otherPath[i]));\n}\nfunction numEqualSegments(path, otherPath) {\n const length = Math.min(path.length, otherPath.length);\n for (let i = 0; i < length; i++)\n if (!isSegmentEqual(path[i], otherPath[i]))\n return i;\n return length;\n}\nfunction isSegmentEqual(segmentA, segmentB) {\n return isKeySegment(segmentA) && isKeySegment(segmentB) ? segmentA._key === segmentB._key : isIndexSegment(segmentA) ? Number(segmentA) === Number(segmentB) : isIndexTuple(segmentA) && isIndexTuple(segmentB) ? segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1] : segmentA === segmentB;\n}\nfunction hasFocus(focusPath, path) {\n const withoutTerminator = focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath;\n return isEqual(withoutTerminator, path);\n}\nfunction hasItemFocus(focusPath, item) {\n return focusPath.length === 1 && isSegmentEqual(focusPath[0], item);\n}\nfunction isExpanded(segment, focusPath) {\n const [head, ...tail] = focusPath;\n return tail.length > 0 && isSegmentEqual(segment, head);\n}\nfunction startsWith(prefix, path) {\n return prefix.every((segment, i) => isSegmentEqual(segment, path[i]));\n}\nfunction trimLeft(prefix, path) {\n if (prefix.length === 0 || path.length === 0)\n return path;\n const [prefixHead, ...prefixTail] = prefix, [pathHead, ...pathTail] = path;\n return isSegmentEqual(prefixHead, pathHead) ? pathFor(trimLeft(prefixTail, pathTail)) : path;\n}\nfunction trimRight(suffix, path) {\n const sufLen = suffix.length, pathLen = path.length;\n if (sufLen === 0 || pathLen === 0)\n return path;\n let i = 0;\n for (; i < sufLen && i < pathLen && isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1]); )\n i++;\n return pathFor(path.slice(0, pathLen - i));\n}\nfunction trimChildPath(path, childPath) {\n return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const isHead = i === 0;\n if (typeof segment == \"number\")\n return `${target}[${segment}]`;\n if (typeof segment == \"string\")\n return isHead ? segment : GROQ_DATA_TYPE_VALUES.includes(segment) ? `${target}[\"${segment}\"]` : `${target}.${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nfunction _resolveKeyedPath(value, path) {\n if (path.length === 0)\n return path;\n const [next, ...rest] = path;\n if (typeof next == \"number\") {\n if (!Array.isArray(value) || !(next in value))\n return [];\n const item = value[next];\n return [typeof item?._key == \"string\" ? { _key: item._key } : next, ..._resolveKeyedPath(item, rest)];\n }\n const nextVal = get(value, [next]);\n return [next, ..._resolveKeyedPath(nextVal, rest)];\n}\nfunction resolveKeyedPath(value, path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return pathFor(_resolveKeyedPath(value, path));\n}\nfunction fromString(path) {\n if (typeof path != \"string\")\n throw new Error(\"Path is not a string\");\n const segments = path.match(rePropName);\n if (!segments)\n throw new Error(\"Invalid path string\");\n return segments.map(normalizePathSegment);\n}\nfunction normalizePathSegment(segment) {\n return isIndexSegment(segment) ? normalizeIndexSegment(segment) : isKeySegment(segment) ? normalizeKeySegment(segment) : isIndexTuple(segment) ? normalizeIndexTupleSegment(segment) : segment;\n}\nfunction normalizeIndexSegment(segment) {\n return Number(segment.replace(/[^\\d]/g, \"\"));\n}\nfunction normalizeKeySegment(segment) {\n return { _key: segment.match(reKeySegment)[1] };\n}\nfunction normalizeIndexTupleSegment(segment) {\n const [from, to] = segment.split(\":\").map((seg) => seg === \"\" ? seg : Number(seg));\n return [from, to];\n}\nexport {\n FOCUS_TERMINATOR,\n _resolveKeyedPath,\n fromString,\n get,\n hasFocus,\n hasItemFocus,\n isEqual,\n isExpanded,\n isSegmentEqual,\n numEqualSegments,\n pathFor,\n resolveKeyedPath,\n startsWith,\n toString,\n trimChildPath,\n trimLeft,\n trimRight\n};\n//# sourceMappingURL=paths.mjs.map\n","import {Flex, Spinner, Stack, Box, Card, Inline, Text, Button} from '@sanity/ui'\nimport {fromString as pathFromString} from '@sanity/util/paths'\nimport {useCallback} from 'react'\nimport {Preview, useSchema, usePerspective, getPublishedId} from 'sanity'\nimport type {SanityDocument} from 'sanity'\nimport type {UserViewComponent} from 'sanity/structure'\nimport {usePaneRouter} from 'sanity/structure'\nimport {Feedback, useListeningQuery} from 'sanity-plugin-utils'\n\ninterface TagReference {\n _id: string\n _type: string\n title: string\n}\n\nexport const ConceptUseView: UserViewComponent<Record<string, never>> = ({\n document,\n}: {\n document: {displayed: {_id?: string}}\n}) => {\n const {selectedPerspectiveName} = usePerspective()\n const {routerPanesState, groupIndex, handleEditReference} = usePaneRouter()\n const schema = useSchema()\n\n const refId = getPublishedId((document.displayed as {_id?: string})?._id ?? '')\n\n const handleClick = useCallback(\n (id: string, type: string) => {\n const childParams = routerPanesState[groupIndex + 1]?.[0].params || {}\n const {parentRefPath} = childParams\n\n handleEditReference({\n id,\n type,\n parentRefPath: parentRefPath ? pathFromString(parentRefPath) : [``],\n template: {id},\n })\n },\n [routerPanesState, groupIndex, handleEditReference]\n )\n\n const {data, loading, error} = useListeningQuery<SanityDocument[]>(\n `*[!(_type in [\"skosConcept\",\"skosConceptScheme\"]) && references($refId)]{_id,_type,title}`,\n {\n params: {refId},\n options: {\n perspective: selectedPerspectiveName ? [selectedPerspectiveName] : 'drafts',\n },\n }\n ) as {\n data: TagReference[]\n loading: boolean\n error: Error | null\n }\n\n if (loading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading usage…\n </Text>\n </Flex>\n </Box>\n )\n }\n\n if (error) {\n return (\n <Stack padding={4} space={5}>\n <Feedback tone={'caution'}>There was en error fetching use data</Feedback>\n </Stack>\n )\n }\n\n if (!data?.length) {\n return (\n <Stack padding={4} space={5}>\n <Feedback>This concept is not currently in use</Feedback>\n </Stack>\n )\n }\n\n return (\n <Box padding={4} paddingTop={4}>\n <Stack space={2}>\n <Card borderBottom paddingTop={3} paddingBottom={3}>\n <Inline paddingTop={1}>\n <Text weight=\"semibold\" muted size={1}>\n Resource count (all schemes): {data.length}\n </Text>\n </Inline>\n </Card>\n <Stack space={1}>\n {data?.map((d: TagReference) => {\n const schemaType = schema.get(d._type)\n return (\n schemaType && (\n <Button\n key={d._id}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={() => handleClick(d._id, d._type)}\n padding={2}\n mode=\"bleed\"\n >\n <Preview value={d} schemaType={schemaType} layout=\"block\" />\n </Button>\n )\n )\n })}\n </Stack>\n </Stack>\n </Box>\n )\n}\n","import {EditIcon, DocumentsIcon} from '@sanity/icons'\nimport type {StructureBuilder, ListBuilder, DefaultDocumentNodeResolver} from 'sanity/structure'\n\nimport {TreeView} from './components/TreeView'\nimport NodeTree from './static/NodeTree'\nimport {ConceptUseView} from './views/ConceptUseView'\n\n/**\n * #### Default Desk Structure for Concept and Concept Scheme\n * Sets defaultDocumentNode. Consider exporting in the future,\n * if there is a use case for mixing taxonomy views in the main\n * desk structure.\n */\nexport const structure = (S: StructureBuilder): ListBuilder =>\n S.list()\n .title('Taxonomy Manager')\n .items([\n S.documentTypeListItem('skosConceptScheme').title('Concept Schemes'),\n S.documentTypeListItem('skosConcept').title('Concepts'),\n ])\n\n// set default document node here — so that if users want concepts\n// and schemes elsewhere in desk, they'll get the right views.\nexport const defaultDocumentNode: DefaultDocumentNodeResolver = (S, {schemaType}) => {\n // Conditionally return a different configuration based on the schema type\n switch (schemaType) {\n case 'skosConceptScheme':\n return S.document().views([\n S.view.component(TreeView).title('Tree View').icon(NodeTree),\n S.view.form().icon(EditIcon),\n ])\n case 'skosConcept':\n return S.document().views([\n S.view.form().icon(EditIcon),\n S.view.component(ConceptUseView).title('Tagged Resources').icon(DocumentsIcon),\n ])\n default:\n return S.document().views([S.view.form().icon(EditIcon)])\n }\n}\n","import {definePlugin} from 'sanity'\nimport {structureTool} from 'sanity/structure'\n\nimport {ReferenceHierarchyInput, ArrayHierarchyInput} from './components/inputs'\nimport {TreeView} from './components/TreeView'\nimport {setPluginConfig} from './config'\nimport {schemeFilter, branchFilter} from './helpers'\nimport skosConcept from './skosConcept'\nimport skosConceptScheme from './skosConceptScheme'\nimport NodeTree from './static/NodeTree'\nimport {defaultDocumentNode, structure} from './structure'\nimport type {Options} from './types'\n\n/**\n * #### Sanity Taxonomy Manager\n * Defines a Sanity plugin for managing SKOS compliant taxonomies in Sanity Studio.\n * #### Options\n * @param baseUri - The base URI to use for SKOS concepts and concept schemes. BaseURI should follow an IANA http/s scheme and should terminate with either a / or #.\n * @param customConceptFields - An array of additional fields to add to the skosConcept type.\n * @param customSchemeFields - An array of additional fields to add to the skosConceptScheme type.\n * #### Identifier Configuration\n * @param ident.pattern - The character set to use for identifiers (default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz').\n * @param ident.length - The length of the generated identifier (default: 6).\n * @param ident.prefix - A prefix to prepend to generated identifiers, for example to use Wikidata style IDs like \"Q27521\" (default: '').\n * @param ident.regenUi - Whether to display the \"Create Unique Identifier\" button in the UI by default.\n * @returns A Sanity plugin object.\n */\nconst taxonomyManager = definePlugin((options?: Options) => {\n const {baseUri, customConceptFields, customSchemeFields, ident} = options || {}\n\n // Store config for access in hooks\n setPluginConfig(options)\n\n return {\n name: 'taxonomyManager',\n options,\n schema: {\n types: [\n skosConcept(baseUri, customConceptFields, ident),\n skosConceptScheme(baseUri, customSchemeFields, ident),\n ],\n },\n plugins: [\n structureTool({\n name: 'taxonomy',\n title: 'Taxonomy',\n structure,\n defaultDocumentNode,\n icon: NodeTree,\n }),\n ],\n }\n})\n\nexport {\n taxonomyManager,\n TreeView,\n schemeFilter,\n branchFilter,\n ReferenceHierarchyInput,\n ArrayHierarchyInput,\n}\n"],"names":["createId","ident","alphabet","pattern","length","prefix","customAlphabet","nanoid","Identifier","props","onChange","toast","useToast","handleChange","useCallback","id","set","push","status","title","closable","jsx","Stack","space","children","Button","icon","GenerateIcon","mode","width","onClick","text","defaultProps","__defProp$3","Object","defineProperty","__getOwnPropSymbols$3","getOwnPropertySymbols","__hasOwnProp$3","prototype","hasOwnProperty","__propIsEnum$3","propertyIsEnumerable","__defNormalProp$3","obj","key","value","enumerable","configurable","writable","__spreadValues$3","a","b","prop","call","DEFAULT_PROPS","tone","Feedback","description","Card","padding","radius","border","jsxs","Flex","Box","flex","Text","weight","size","__defProp$2","__getOwnPropSymbols$2","__hasOwnProp$2","__propIsEnum$2","__defNormalProp$2","__spreadValues$2","styled","as","css","DEFAULT_PARAMS","DEFAULT_OPTIONS","apiVersion","useParams","params","stringifiedParams","useMemo","JSON","stringify","parse","useListeningQuery","query","options","initialValue","loading","setLoading","useState","error","setError","data","setData","memoParams","memoOptions","subscription","useRef","documentStore","useDocumentStore","useEffect","current","listenQuery","pipe","distinctUntilChanged","isEqual","catchError","err","console","subscribe","documents","unsubscribe","_a","SchemeContext","createContext","TreeContext","editControls","ReleaseContext","branchBuilder","level","reference","i","getRandomValues","rnds8","Uint8Array","rng","crypto","bind","msCrypto","Error","byteToHex","toString","substr","v4","buf","offset","rnds","random","arr","arguments","uuid","toLowerCase","REGEX","test","validate","TypeError","taxonomyManagerConfig","useCreateConcept","document","client","useClient","openInNewPane","routerContext","useContext","RouterContext","routerPanesState","groupIndex","usePaneRouter","conceptId","panes","splice","type","href","resolvePathFromState","navigateUrl","path","useOpenNewConceptPane","schemaBaseIri","displayed","baseIri","conceptType","concept","broaderConceptId","_originalId","broaderConceptOriginalId","isInRelease","isVersionId","_id","releaseName","getVersionNameFromId","schemeId","getVersionId","DocumentId","getDraftId","newConceptId","skosConcept","_type","prefLabel","broader","related","isPublished","isPublishedId","_key","_ref","getPublishedId","_weak","_strengthenOnPublish","template","skosConceptReference","transaction","createIfNotExists","create","patch","setIfMissing","topConcepts","append","concepts","commit","autoGenerateArrayKeys","then","_res","catch","message","useRemoveConcept","unset","useEmbeddingsRecs","embeddingsIndex","dataset","useDataset","getFormValue","useGetFormValue","conceptRecs","setConceptRecs","recsError","setRecsError","buildQueryString","fieldReferences","emptyFields","values","map","fieldName","val","trim","join","filter","Boolean","fetchConceptRecs","async","indexName","maxResults","returnedRecs","request","url","method","body","triggerEmbeddingsSearch","errorMessage","MessageHelper","Label","muted","style","whiteSpace","ConceptDetailDialogue","open","setOpen","onClose","onOpen","definition","example","scopeNote","Fragment","Tooltip","delay","content","sizing","fallbackPlacements","placement","portal","InfoOutlineIcon","Dialog","header","zOffset","paddingTop","paddingBottom","ConceptDetailLink","topConcept","orphan","displayLabel","paddingLeft","justify","textOverflow","Badge","fontSize","marginLeft","verticalAlign","ConceptEditAction","action","handler","typeMap","add","AddCircleIcon","remove","TrashIcon","ConceptSelectLink","selectConcept","score","handleClick","toFixed","StructureDetailDialogue","ErrorOutlineIcon","info","warn","styleInject","ref","insertAt","head","getElementsByTagName","createElement","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","ToggleButton","visibility","ToggleArrowRightIcon","className","Children","inputComponent","releaseContext","globalVisibility","treeVisibility","createConcept","removeConcept","handleAddChild","handleRemoveConcept","levelVisibility","setLevelVisibility","hasMatchingDescendant","handleToggle","align","wrap","gap","minWidth","childConcepts","Inline","ChildConcepts","childVisibility","marginTop","display","Concepts","hasTopConcept","NewScheme","titleValue","setTitleValue","descriptionValue","setDescriptionValue","handleTitleChange","event","currentTarget","handleDescriptionChange","addTitle","documentId","doc","_","useAddTitle","handleAddTitle","shadow","AddIcon","TextInput","placeholder","TextArea","rows","NoConcepts","TopConcepts","TreeStructure","treeId","listStyle","marginBlockStart","isOrphan","InputHierarchy","branchId","expanded","initialVisibility","fetch","listen","perspective","scoreMap","Map","Array","isArray","rec","addScores","node","scores","publishedId","get","annotatedChildren","c","some","mergedData","tc","direction","height","Spinner","Provider","NodeTree","viewBox","fill","xmlns","d","Hierarchy","createTopConcept","createEntryConcept","setGlobalVisibility","handleExpand","handleCollapse","borderBottom","paddingY","TreeView","selectedPerspectiveName","usePerspective","Container","ReferenceHierarchyInput","useFormValue","name","isDraft","isDraftId","schemeLoading","setSchemeLoading","valuesLoading","setValuesLoading","scheme","setScheme","filterValues","setFilterValues","schemaType","resolvedFilterValues","getClient","fetchFilterValues","res","browseHierarchy","handleClose","handleAction","renderDefault","browseOnly","Grid","columns","disabled","ArrayHierarchyInput","of","item","includes","duration","ManagementControls","schemeFilter","branchFilter","baseIriField","defineField","validation","Rule","required","components","input","conceptFilter","self","baseUri","customConceptFields","defineType","AiOutlineTags","context","fields","custom","withConfig","styles","target","rel","WarningOutlineIcon","unique","hidden","regenUi","readOnly","to","orderings","by","field","preview","select","prepare","media","AiOutlineTag","skosConceptScheme","customSchemeFields","deprecated","reason","controls","defineArrayMember","sortable","reKeySegment","reIndexTuple","rePropName","fromString","segments","match","normalizePathSegment","segment","isIndexSegment","Number","replace","normalizeIndexSegment","isKeySegment","normalizeKeySegment","from","isIndexTuple","split","seg","normalizeIndexTupleSegment","ConceptUseView","handleEditReference","schema","useSchema","refId","childParams","parentRefPath","pathFromString","Preview","layout","structure","S","list","items","documentTypeListItem","defaultDocumentNode","views","view","component","form","EditIcon","DocumentsIcon","taxonomyManager","definePlugin","types","plugins","structureTool"],"mappings":"m+CAaO,SAASA,GAASC,GACvB,MAAMC,EAAWD,GAAOE,SAVF,iEAWhBC,EAASH,GAAOG,QAVF,EAapB,OAFeH,GAAOI,QAVF,IAWLC,GAAeJ,EAAUE,EACxBG,EAClB,CCCO,MAAMC,GAAcC,IACzB,MAAMC,SAACA,EAAAT,MAAUA,GAASQ,EACpBE,EAAQC,IAERC,EAAeC,EAAY,KAC/B,MAAMC,EAAKf,GAASC,GACpBS,EAASM,EAAID,IACbJ,EAAMM,KAAK,CACTC,OAAQ,UACRC,MAAO,sBACPC,UAAU,KAEX,CAACV,EAAUC,EAAOV;AAErB,OACEoB,EAACC,EAAA,CAAMC,MAAO,EACZC,wBAAAH,EAACI,EAAA,CACCC,KAAMC,EACNC,KAAK,QACLC,MAAM,OACNC,QAASjB,EACTkB,KAAK,2BAMbvB,GAAWwB,aAAe,CACxB/B,WAAO,GCtCT,IAAIgC,GAAcC,OAAOC,eAAgBC,GAAwBF,OAAOG,sBAAuBC,GAAiBJ,OAAOK,UAAUC,eAAgBC,GAAiBP,OAAOK,UAAUG,qBAAsBC,GAAoB,CAACC,EAAKC,EAAKC,IAAUD,KAAOD,EAAMX,GAAYW,EAAKC,EAAK,CAAEE,YAAY,EAAIC,cAAc,EAAIC,UAAU,EAAIH,UAAWF,EAAIC,GAAOC,EAAOI,GAAmB,CAACC,EAAGC,KACzX,IAAA,IAASC,KAAQD,IAAMA,EAAI,CAAA,GACzBd,GAAegB,KAAKF,EAAGC,IAASV,GAAkBQ,EAAGE,EAAMD,EAAEC,IAC/D,GAAIjB,GACF,IAAA,IAASiB,KAAQjB,GAAsBgB,GACrCX,GAAea,KAAKF,EAAGC,IAASV,GAAkBQ,EAAGE,EAAMD,EAAEC,IACjE,OAAOF,GAET,MAAMI,GAAgB,CACpBC,KAAM,WAER,SAASC,GAAShD,GAChB,MAAMU,MAAEA,EAAAuC,YAAOA,EAAA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V9CE,GAAkBC,EAAc9b,IACpC,MAAMoX,QAACA,EAAAC,oBAASA,EAAAyB,mBAAqBA,QAAoBxe,GAAS0F,GAAW,CAAA,EAG7E,OrCrBA6D,GqCqBgB7D,EAET,CACL2U,KAAM,kBACN3U,UACAya,OAAQ,CACNsB,MAAO,CACL3V,GAAYgR,EAASC,EAAqB/c,GAC1Cue,GAAkBzB,EAAS0B,EAAoBxe,KAGnD0hB,QAAS,CACPC,EAAc,CACZtH,KAAM,WACNnZ,MAAO,WACPyf,aACAK,uBACAvf,KAAMyX","x_google_ignoreList":[2,5,6,7,8,9,20,43,44]}
|
|
1
|
+
{"version":3,"file":"index.esm.esm.js","sources":["../src/helpers/createId.ts","../src/components/inputs/Identifier.tsx","../node_modules/sanity-plugin-utils/lib/index.js","../src/context.ts","../src/queries.ts","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/rng.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/stringify.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/regex.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/v4.js","../node_modules/@sanity/uuid/node_modules/uuid/dist/esm-browser/validate.js","../src/config.ts","../src/hooks/useCreateConcept.tsx","../src/hooks/useOpenNewConceptPane.tsx","../src/hooks/useRemoveConcept.tsx","../src/hooks/useEmbeddingsRecs.tsx","../src/components/interactions/ConceptDetailDialogue.tsx","../src/components/interactions/ConceptDetailLink.tsx","../src/components/interactions/ConceptEditAction.tsx","../src/components/interactions/ConceptSelectLink.tsx","../src/components/interactions/StructureDetailDialogue.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/components/interactions/ToggleButton.tsx","../src/components/Children.tsx","../src/components/ChildConcepts.tsx","../src/components/Concepts.tsx","../src/components/guides/NewScheme.tsx","../src/hooks/useAddTitle.tsx","../src/components/guides/NoConcepts.tsx","../src/components/TopConcepts.tsx","../src/components/TreeStructure.tsx","../src/components/inputs/InputHierarchy.tsx","../src/static/NodeTree.tsx","../src/components/Hierarchy.tsx","../src/components/TreeView.tsx","../src/components/inputs/ReferenceHierarchyInput.tsx","../src/components/inputs/ArrayHierarchyInput.tsx","../src/components/inputs/ManagementControls.tsx","../src/helpers/schemeFilter.ts","../src/helpers/branchFilter.ts","../src/helpers/baseIriField.tsx","../src/components/inputs/RdfUri.tsx","../src/skosConcept.tsx","../src/skosConceptScheme.tsx","../node_modules/@sanity/types/lib/index.mjs","../node_modules/@sanity/util/lib/paths.mjs","../src/views/ConceptUseView.tsx","../src/structure.ts","../src/index.ts"],"sourcesContent":["import {customAlphabet} from 'nanoid'\n\nimport type {Options} from '../types'\n\nconst defaultAlphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\nconst defaultLength = 6\nconst defaultPrefix = ''\n\n/**\n * #### Create Unique Identifier\n * Used for creating the unique identification segment\n * of URIs.\n */\nexport function createId(ident?: Options['ident']): string {\n const alphabet = ident?.pattern || defaultAlphabet\n const length = ident?.length || defaultLength\n const prefix = ident?.prefix || defaultPrefix\n const nanoid = customAlphabet(alphabet, length)\n return prefix + nanoid()\n}\n","import {GenerateIcon} from '@sanity/icons'\nimport {Button, Stack, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {set} from 'sanity'\nimport type {StringInputProps} from 'sanity'\n\nimport {createId} from '../../helpers/createId'\nimport type {Options} from '../../types'\n\ntype IdentifierProps = StringInputProps & {\n ident?: Options['ident']\n}\n\n/**\n * #### Create Unique Identifier\n * For schemes and concepts created in previous versions of the\n * plugin.\n * - Input is only visible if no identifier has been assigned\n * - Input disappears once an ID is generated\n */\nexport const Identifier = (props: IdentifierProps) => {\n const {onChange, ident} = props\n const toast = useToast()\n\n const handleChange = useCallback(() => {\n const id = createId(ident)\n onChange(set(id))\n toast.push({\n status: 'success',\n title: 'Identifier created.',\n closable: true,\n })\n }, [onChange, toast, ident])\n\n return (\n <Stack space={2}>\n <Button\n icon={GenerateIcon}\n mode=\"ghost\"\n width=\"fill\"\n onClick={handleChange}\n text=\"Generate identifier\"\n />\n </Stack>\n )\n}\n\nIdentifier.defaultProps = {\n ident: undefined,\n}\n","import { jsx, jsxs } from \"react/jsx-runtime\";\nimport { Card, Flex, Box, Stack, Text, Menu, MenuItem, TextInput, Badge } from \"@sanity/ui\";\nimport { styled, css } from \"styled-components\";\nimport { RemoveCircleIcon, AddCircleIcon, RestoreIcon } from \"@sanity/icons\";\nimport { useState, useRef, useMemo, useEffect, useContext, useCallback } from \"react\";\nimport { UserAvatar, useClient, useDocumentStore, useWorkspace } from \"sanity\";\nimport isEqual from \"react-fast-compare\";\nimport { distinctUntilChanged, catchError } from \"rxjs/operators\";\nimport { RouterContext } from \"sanity/router\";\nimport { usePaneRouter } from \"sanity/structure\";\nvar __defProp$3 = Object.defineProperty, __getOwnPropSymbols$3 = Object.getOwnPropertySymbols, __hasOwnProp$3 = Object.prototype.hasOwnProperty, __propIsEnum$3 = Object.prototype.propertyIsEnumerable, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$3 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);\n if (__getOwnPropSymbols$3)\n for (var prop of __getOwnPropSymbols$3(b))\n __propIsEnum$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);\n return a;\n};\nconst DEFAULT_PROPS = {\n tone: \"primary\"\n};\nfunction Feedback(props) {\n const { title, description, icon, tone, children } = __spreadValues$3(__spreadValues$3({}, DEFAULT_PROPS), props);\n return /* @__PURE__ */ jsx(Card, { tone, padding: 4, radius: 3, border: !0, children: /* @__PURE__ */ jsxs(Flex, { children: [\n icon ? \"display icon\" : null,\n children || /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [\n title ? /* @__PURE__ */ jsx(Text, { weight: \"semibold\", children: title }) : null,\n description ? /* @__PURE__ */ jsx(Text, { size: 2, children: description }) : null\n ] }) })\n ] }) });\n}\nvar __defProp$2 = Object.defineProperty, __defProps$1 = Object.defineProperties, __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$2 = Object.getOwnPropertySymbols, __hasOwnProp$2 = Object.prototype.hasOwnProperty, __propIsEnum$2 = Object.prototype.propertyIsEnumerable, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$2 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);\n if (__getOwnPropSymbols$2)\n for (var prop of __getOwnPropSymbols$2(b))\n __propIsEnum$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);\n return a;\n}, __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)), __objRest = (source, exclude) => {\n var target = {};\n for (var prop in source)\n __hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);\n if (source != null && __getOwnPropSymbols$2)\n for (var prop of __getOwnPropSymbols$2(source))\n exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop) && (target[prop] = source[prop]);\n return target;\n};\nconst TableWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"table\" }, props)), StyledTable = styled(TableWrapper)(\n () => css`\n display: table;\n width: 100%;\n border-collapse: collapse;\n\n &:not([hidden]) {\n display: table;\n border-collapse: collapse;\n }\n `\n);\nfunction Table(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledTable, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nconst RowWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"tr\" }, props)), StyledRow = styled(RowWrapper)(\n () => css`\n display: table-row;\n\n &:not([hidden]) {\n display: table-row;\n }\n `\n);\nfunction Row(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledRow, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nconst CellWrapper = (props = {}) => /* @__PURE__ */ jsx(Card, __spreadValues$2({ as: \"td\" }, props)), StyledCell = styled(CellWrapper)(\n () => css`\n display: table-cell;\n\n &:not([hidden]) {\n display: table-cell;\n }\n `\n);\nfunction Cell(props) {\n const _a = props, { children } = _a, rest = __objRest(_a, [\"children\"]);\n return /* @__PURE__ */ jsx(StyledCell, __spreadProps$1(__spreadValues$2({}, rest), { children }));\n}\nvar __defProp$1 = Object.defineProperty, __getOwnPropSymbols$1 = Object.getOwnPropertySymbols, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __propIsEnum$1 = Object.prototype.propertyIsEnumerable, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$1 = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);\n if (__getOwnPropSymbols$1)\n for (var prop of __getOwnPropSymbols$1(b))\n __propIsEnum$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);\n return a;\n};\nfunction searchUsers(users, searchString) {\n return users.filter((user) => !!((user.displayName || \"\").toLowerCase().startsWith(searchString) || (user.givenName || \"\").toLowerCase().startsWith(searchString) || (user.middleName || \"\").toLowerCase().startsWith(searchString) || (user.familyName || \"\").toLowerCase().startsWith(searchString)));\n}\nconst LABELS = {\n addMe: \"Assign myself\",\n removeMe: \"Unassign myself\",\n clear: \"Clear assignees\",\n searchPlaceholder: \"Search users\",\n notFound: \"No users found\"\n};\nfunction UserSelectMenu(props) {\n const {\n value = [],\n userList = [],\n onAdd,\n onRemove,\n onClear,\n style = {}\n } = props, labels = props != null && props.labels ? __spreadValues$1(__spreadValues$1({}, LABELS), props.labels) : LABELS, [searchString, setSearchString] = useState(\"\"), searchResults = searchUsers(userList || [], searchString), me = userList.find((u) => u.isCurrentUser), meAssigned = me && value.includes(me.id), input = useRef(null), handleSearchChange = (event) => {\n setSearchString(event.target.value);\n }, handleSelect = (isChecked, user) => {\n isChecked ? onRemove && onRemove(user.id) : onAdd && onAdd(user.id);\n }, handleAssignMyself = () => {\n me && onAdd && onAdd(me.id);\n }, handleUnassignMyself = () => {\n me && onRemove && onRemove(me.id);\n }, handleClearAssigneesClick = () => {\n onClear && onClear();\n };\n return /* @__PURE__ */ jsxs(Menu, { style, children: [\n meAssigned ? /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"caution\",\n disabled: !me,\n onClick: handleUnassignMyself,\n icon: RemoveCircleIcon,\n text: labels.removeMe\n }\n ) : /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"positive\",\n onClick: handleAssignMyself,\n icon: AddCircleIcon,\n text: labels.addMe\n }\n ),\n /* @__PURE__ */ jsx(\n MenuItem,\n {\n tone: \"critical\",\n disabled: value.length === 0,\n onClick: handleClearAssigneesClick,\n icon: RestoreIcon,\n text: labels.clear\n }\n ),\n /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(\n TextInput,\n {\n ref: input,\n onChange: handleSearchChange,\n placeholder: labels.searchPlaceholder,\n value: searchString\n }\n ) }),\n searchString && (searchResults == null ? void 0 : searchResults.length) === 0 && /* @__PURE__ */ jsx(MenuItem, { disabled: !0, text: labels.notFound }),\n searchResults && searchResults.map((user) => /* @__PURE__ */ jsx(\n MenuItem,\n {\n pressed: value.includes(user.id),\n onClick: () => handleSelect(value.indexOf(user.id) > -1, user),\n children: /* @__PURE__ */ jsxs(Flex, { align: \"center\", children: [\n /* @__PURE__ */ jsx(UserAvatar, { user, size: 1 }),\n /* @__PURE__ */ jsx(Box, { paddingX: 2, flex: 1, children: /* @__PURE__ */ jsx(Text, { children: user.displayName }) }),\n user.isCurrentUser && /* @__PURE__ */ jsx(Badge, { fontSize: 1, tone: \"positive\", mode: \"outline\", children: \"Me\" })\n ] })\n },\n user.id\n ))\n ] });\n}\nfunction getDefaultExportFromCjs(x) {\n return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, \"default\") ? x.default : x;\n}\nvar builder = {}, urlForImage = {}, parseAssetId = {}, hasRequiredParseAssetId;\nfunction requireParseAssetId() {\n if (hasRequiredParseAssetId) return parseAssetId;\n hasRequiredParseAssetId = 1, Object.defineProperty(parseAssetId, \"__esModule\", { value: !0 });\n var example = \"image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg\";\n function parseAssetId$1(ref) {\n var _a = ref.split(\"-\"), id = _a[1], dimensionString = _a[2], format = _a[3];\n if (!id || !dimensionString || !format)\n throw new Error(\"Malformed asset _ref '\".concat(ref, `'. Expected an id like \"`).concat(example, '\".'));\n var _b = dimensionString.split(\"x\"), imgWidthStr = _b[0], imgHeightStr = _b[1], width = +imgWidthStr, height = +imgHeightStr, isValidAssetId = isFinite(width) && isFinite(height);\n if (!isValidAssetId)\n throw new Error(\"Malformed asset _ref '\".concat(ref, `'. Expected an id like \"`).concat(example, '\".'));\n return { id, width, height, format };\n }\n return parseAssetId.default = parseAssetId$1, parseAssetId;\n}\nvar parseSource = {}, hasRequiredParseSource;\nfunction requireParseSource() {\n if (hasRequiredParseSource) return parseSource;\n hasRequiredParseSource = 1;\n var __assign = parseSource && parseSource.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n };\n Object.defineProperty(parseSource, \"__esModule\", { value: !0 });\n var isRef = function(src) {\n var source = src;\n return source ? typeof source._ref == \"string\" : !1;\n }, isAsset = function(src) {\n var source = src;\n return source ? typeof source._id == \"string\" : !1;\n }, isAssetStub = function(src) {\n var source = src;\n return source && source.asset ? typeof source.asset.url == \"string\" : !1;\n };\n function parseSource$1(source) {\n if (!source)\n return null;\n var image;\n if (typeof source == \"string\" && isUrl(source))\n image = {\n asset: { _ref: urlToId(source) }\n };\n else if (typeof source == \"string\")\n image = {\n asset: { _ref: source }\n };\n else if (isRef(source))\n image = {\n asset: source\n };\n else if (isAsset(source))\n image = {\n asset: {\n _ref: source._id || \"\"\n }\n };\n else if (isAssetStub(source))\n image = {\n asset: {\n _ref: urlToId(source.asset.url)\n }\n };\n else if (typeof source.asset == \"object\")\n image = __assign({}, source);\n else\n return null;\n var img = source;\n return img.crop && (image.crop = img.crop), img.hotspot && (image.hotspot = img.hotspot), applyDefaults(image);\n }\n parseSource.default = parseSource$1;\n function isUrl(url) {\n return /^https?:\\/\\//.test(\"\".concat(url));\n }\n function urlToId(url) {\n var parts = url.split(\"/\").slice(-1);\n return \"image-\".concat(parts[0]).replace(/\\.([a-z]+)$/, \"-$1\");\n }\n function applyDefaults(image) {\n if (image.crop && image.hotspot)\n return image;\n var result = __assign({}, image);\n return result.crop || (result.crop = {\n left: 0,\n top: 0,\n bottom: 0,\n right: 0\n }), result.hotspot || (result.hotspot = {\n x: 0.5,\n y: 0.5,\n height: 1,\n width: 1\n }), result;\n }\n return parseSource;\n}\nvar hasRequiredUrlForImage;\nfunction requireUrlForImage() {\n return hasRequiredUrlForImage || (hasRequiredUrlForImage = 1, function(exports) {\n var __assign = urlForImage && urlForImage.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n }, __importDefault = urlForImage && urlForImage.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { default: mod };\n };\n Object.defineProperty(exports, \"__esModule\", { value: !0 }), exports.parseSource = exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = void 0;\n var parseAssetId_1 = __importDefault(requireParseAssetId()), parseSource_1 = __importDefault(requireParseSource());\n exports.parseSource = parseSource_1.default, exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = [\n [\"width\", \"w\"],\n [\"height\", \"h\"],\n [\"format\", \"fm\"],\n [\"download\", \"dl\"],\n [\"blur\", \"blur\"],\n [\"sharpen\", \"sharp\"],\n [\"invert\", \"invert\"],\n [\"orientation\", \"or\"],\n [\"minHeight\", \"min-h\"],\n [\"maxHeight\", \"max-h\"],\n [\"minWidth\", \"min-w\"],\n [\"maxWidth\", \"max-w\"],\n [\"quality\", \"q\"],\n [\"fit\", \"fit\"],\n [\"crop\", \"crop\"],\n [\"saturation\", \"sat\"],\n [\"auto\", \"auto\"],\n [\"dpr\", \"dpr\"],\n [\"pad\", \"pad\"]\n ];\n function urlForImage$1(options) {\n var spec = __assign({}, options || {}), source = spec.source;\n delete spec.source;\n var image = (0, parseSource_1.default)(source);\n if (!image)\n throw new Error(\"Unable to resolve image URL from source (\".concat(JSON.stringify(source), \")\"));\n var id = image.asset._ref || image.asset._id || \"\", asset = (0, parseAssetId_1.default)(id), cropLeft = Math.round(image.crop.left * asset.width), cropTop = Math.round(image.crop.top * asset.height), crop = {\n left: cropLeft,\n top: cropTop,\n width: Math.round(asset.width - image.crop.right * asset.width - cropLeft),\n height: Math.round(asset.height - image.crop.bottom * asset.height - cropTop)\n }, hotSpotVerticalRadius = image.hotspot.height * asset.height / 2, hotSpotHorizontalRadius = image.hotspot.width * asset.width / 2, hotSpotCenterX = image.hotspot.x * asset.width, hotSpotCenterY = image.hotspot.y * asset.height, hotspot = {\n left: hotSpotCenterX - hotSpotHorizontalRadius,\n top: hotSpotCenterY - hotSpotVerticalRadius,\n right: hotSpotCenterX + hotSpotHorizontalRadius,\n bottom: hotSpotCenterY + hotSpotVerticalRadius\n };\n return spec.rect || spec.focalPoint || spec.ignoreImageParams || spec.crop || (spec = __assign(__assign({}, spec), fit({ crop, hotspot }, spec))), specToImageUrl(__assign(__assign({}, spec), { asset }));\n }\n exports.default = urlForImage$1;\n function specToImageUrl(spec) {\n var cdnUrl = (spec.baseUrl || \"https://cdn.sanity.io\").replace(/\\/+$/, \"\"), filename = \"\".concat(spec.asset.id, \"-\").concat(spec.asset.width, \"x\").concat(spec.asset.height, \".\").concat(spec.asset.format), baseUrl = \"\".concat(cdnUrl, \"/images/\").concat(spec.projectId, \"/\").concat(spec.dataset, \"/\").concat(filename), params = [];\n if (spec.rect) {\n var _a = spec.rect, left = _a.left, top_1 = _a.top, width = _a.width, height = _a.height, isEffectiveCrop = left !== 0 || top_1 !== 0 || height !== spec.asset.height || width !== spec.asset.width;\n isEffectiveCrop && params.push(\"rect=\".concat(left, \",\").concat(top_1, \",\").concat(width, \",\").concat(height));\n }\n spec.bg && params.push(\"bg=\".concat(spec.bg)), spec.focalPoint && (params.push(\"fp-x=\".concat(spec.focalPoint.x)), params.push(\"fp-y=\".concat(spec.focalPoint.y)));\n var flip = [spec.flipHorizontal && \"h\", spec.flipVertical && \"v\"].filter(Boolean).join(\"\");\n return flip && params.push(\"flip=\".concat(flip)), exports.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach(function(mapping) {\n var specName = mapping[0], param = mapping[1];\n typeof spec[specName] < \"u\" ? params.push(\"\".concat(param, \"=\").concat(encodeURIComponent(spec[specName]))) : typeof spec[param] < \"u\" && params.push(\"\".concat(param, \"=\").concat(encodeURIComponent(spec[param])));\n }), params.length === 0 ? baseUrl : \"\".concat(baseUrl, \"?\").concat(params.join(\"&\"));\n }\n function fit(source, spec) {\n var cropRect, imgWidth = spec.width, imgHeight = spec.height;\n if (!(imgWidth && imgHeight))\n return { width: imgWidth, height: imgHeight, rect: source.crop };\n var crop = source.crop, hotspot = source.hotspot, desiredAspectRatio = imgWidth / imgHeight, cropAspectRatio = crop.width / crop.height;\n if (cropAspectRatio > desiredAspectRatio) {\n var height = Math.round(crop.height), width = Math.round(height * desiredAspectRatio), top_2 = Math.max(0, Math.round(crop.top)), hotspotXCenter = Math.round((hotspot.right - hotspot.left) / 2 + hotspot.left), left = Math.max(0, Math.round(hotspotXCenter - width / 2));\n left < crop.left ? left = crop.left : left + width > crop.left + crop.width && (left = crop.left + crop.width - width), cropRect = { left, top: top_2, width, height };\n } else {\n var width = crop.width, height = Math.round(width / desiredAspectRatio), left = Math.max(0, Math.round(crop.left)), hotspotYCenter = Math.round((hotspot.bottom - hotspot.top) / 2 + hotspot.top), top_3 = Math.max(0, Math.round(hotspotYCenter - height / 2));\n top_3 < crop.top ? top_3 = crop.top : top_3 + height > crop.top + crop.height && (top_3 = crop.top + crop.height - height), cropRect = { left, top: top_3, width, height };\n }\n return {\n width: imgWidth,\n height: imgHeight,\n rect: cropRect\n };\n }\n }(urlForImage)), urlForImage;\n}\nvar hasRequiredBuilder;\nfunction requireBuilder() {\n if (hasRequiredBuilder) return builder;\n hasRequiredBuilder = 1;\n var __assign = builder && builder.__assign || function() {\n return __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);\n }\n return t;\n }, __assign.apply(this, arguments);\n }, __createBinding = builder && builder.__createBinding || (Object.create ? function(o, m, k, k2) {\n k2 === void 0 && (k2 = k), Object.defineProperty(o, k2, { enumerable: !0, get: function() {\n return m[k];\n } });\n } : function(o, m, k, k2) {\n k2 === void 0 && (k2 = k), o[k2] = m[k];\n }), __setModuleDefault = builder && builder.__setModuleDefault || (Object.create ? function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: !0, value: v });\n } : function(o, v) {\n o.default = v;\n }), __importStar = builder && builder.__importStar || function(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);\n return __setModuleDefault(result, mod), result;\n };\n Object.defineProperty(builder, \"__esModule\", { value: !0 }), builder.ImageUrlBuilder = void 0;\n var urlForImage_1 = __importStar(requireUrlForImage()), validFits = [\"clip\", \"crop\", \"fill\", \"fillmax\", \"max\", \"scale\", \"min\"], validCrops = [\"top\", \"bottom\", \"left\", \"right\", \"center\", \"focalpoint\", \"entropy\"], validAutoModes = [\"format\"];\n function isSanityModernClientLike(client) {\n return client && \"config\" in client ? typeof client.config == \"function\" : !1;\n }\n function isSanityClientLike(client) {\n return client && \"clientConfig\" in client ? typeof client.clientConfig == \"object\" : !1;\n }\n function rewriteSpecName(key) {\n for (var specs = urlForImage_1.SPEC_NAME_TO_URL_NAME_MAPPINGS, _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {\n var entry = specs_1[_i], specName = entry[0], param = entry[1];\n if (key === specName || key === param)\n return specName;\n }\n return key;\n }\n function urlBuilder(options) {\n if (isSanityModernClientLike(options)) {\n var _a = options.config(), apiUrl = _a.apiHost, projectId = _a.projectId, dataset = _a.dataset, apiHost = apiUrl || \"https://api.sanity.io\";\n return new ImageUrlBuilder(null, {\n baseUrl: apiHost.replace(/^https:\\/\\/api\\./, \"https://cdn.\"),\n projectId,\n dataset\n });\n }\n var client = options;\n if (isSanityClientLike(client)) {\n var _b = client.clientConfig, apiUrl = _b.apiHost, projectId = _b.projectId, dataset = _b.dataset, apiHost = apiUrl || \"https://api.sanity.io\";\n return new ImageUrlBuilder(null, {\n baseUrl: apiHost.replace(/^https:\\/\\/api\\./, \"https://cdn.\"),\n projectId,\n dataset\n });\n }\n return new ImageUrlBuilder(null, options);\n }\n builder.default = urlBuilder;\n var ImageUrlBuilder = (\n /** @class */\n function() {\n function ImageUrlBuilder2(parent, options) {\n this.options = parent ? __assign(__assign({}, parent.options || {}), options || {}) : __assign({}, options || {});\n }\n return ImageUrlBuilder2.prototype.withOptions = function(options) {\n var baseUrl = options.baseUrl || this.options.baseUrl, newOptions = { baseUrl };\n for (var key in options)\n if (options.hasOwnProperty(key)) {\n var specKey = rewriteSpecName(key);\n newOptions[specKey] = options[key];\n }\n return new ImageUrlBuilder2(this, __assign({ baseUrl }, newOptions));\n }, ImageUrlBuilder2.prototype.image = function(source) {\n return this.withOptions({ source });\n }, ImageUrlBuilder2.prototype.dataset = function(dataset) {\n return this.withOptions({ dataset });\n }, ImageUrlBuilder2.prototype.projectId = function(projectId) {\n return this.withOptions({ projectId });\n }, ImageUrlBuilder2.prototype.bg = function(bg) {\n return this.withOptions({ bg });\n }, ImageUrlBuilder2.prototype.dpr = function(dpr) {\n return this.withOptions(dpr && dpr !== 1 ? { dpr } : {});\n }, ImageUrlBuilder2.prototype.width = function(width) {\n return this.withOptions({ width });\n }, ImageUrlBuilder2.prototype.height = function(height) {\n return this.withOptions({ height });\n }, ImageUrlBuilder2.prototype.focalPoint = function(x, y) {\n return this.withOptions({ focalPoint: { x, y } });\n }, ImageUrlBuilder2.prototype.maxWidth = function(maxWidth) {\n return this.withOptions({ maxWidth });\n }, ImageUrlBuilder2.prototype.minWidth = function(minWidth) {\n return this.withOptions({ minWidth });\n }, ImageUrlBuilder2.prototype.maxHeight = function(maxHeight) {\n return this.withOptions({ maxHeight });\n }, ImageUrlBuilder2.prototype.minHeight = function(minHeight) {\n return this.withOptions({ minHeight });\n }, ImageUrlBuilder2.prototype.size = function(width, height) {\n return this.withOptions({ width, height });\n }, ImageUrlBuilder2.prototype.blur = function(blur) {\n return this.withOptions({ blur });\n }, ImageUrlBuilder2.prototype.sharpen = function(sharpen) {\n return this.withOptions({ sharpen });\n }, ImageUrlBuilder2.prototype.rect = function(left, top, width, height) {\n return this.withOptions({ rect: { left, top, width, height } });\n }, ImageUrlBuilder2.prototype.format = function(format) {\n return this.withOptions({ format });\n }, ImageUrlBuilder2.prototype.invert = function(invert) {\n return this.withOptions({ invert });\n }, ImageUrlBuilder2.prototype.orientation = function(orientation) {\n return this.withOptions({ orientation });\n }, ImageUrlBuilder2.prototype.quality = function(quality) {\n return this.withOptions({ quality });\n }, ImageUrlBuilder2.prototype.forceDownload = function(download) {\n return this.withOptions({ download });\n }, ImageUrlBuilder2.prototype.flipHorizontal = function() {\n return this.withOptions({ flipHorizontal: !0 });\n }, ImageUrlBuilder2.prototype.flipVertical = function() {\n return this.withOptions({ flipVertical: !0 });\n }, ImageUrlBuilder2.prototype.ignoreImageParams = function() {\n return this.withOptions({ ignoreImageParams: !0 });\n }, ImageUrlBuilder2.prototype.fit = function(value) {\n if (validFits.indexOf(value) === -1)\n throw new Error('Invalid fit mode \"'.concat(value, '\"'));\n return this.withOptions({ fit: value });\n }, ImageUrlBuilder2.prototype.crop = function(value) {\n if (validCrops.indexOf(value) === -1)\n throw new Error('Invalid crop mode \"'.concat(value, '\"'));\n return this.withOptions({ crop: value });\n }, ImageUrlBuilder2.prototype.saturation = function(saturation) {\n return this.withOptions({ saturation });\n }, ImageUrlBuilder2.prototype.auto = function(value) {\n if (validAutoModes.indexOf(value) === -1)\n throw new Error('Invalid auto mode \"'.concat(value, '\"'));\n return this.withOptions({ auto: value });\n }, ImageUrlBuilder2.prototype.pad = function(pad) {\n return this.withOptions({ pad });\n }, ImageUrlBuilder2.prototype.url = function() {\n return (0, urlForImage_1.default)(this.options);\n }, ImageUrlBuilder2.prototype.toString = function() {\n return this.url();\n }, ImageUrlBuilder2;\n }()\n );\n return builder.ImageUrlBuilder = ImageUrlBuilder, builder;\n}\nvar node, hasRequiredNode;\nfunction requireNode() {\n if (hasRequiredNode) return node;\n hasRequiredNode = 1;\n var __importDefault = node && node.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { default: mod };\n }, builder_1 = __importDefault(requireBuilder());\n return node = builder_1.default, node;\n}\nvar nodeExports = /* @__PURE__ */ requireNode(), createImageUrlBuilder = /* @__PURE__ */ getDefaultExportFromCjs(nodeExports);\nfunction useImageUrlBuilder(clientOptions) {\n const client = useClient(clientOptions);\n return useMemo(() => createImageUrlBuilder(client), [client]);\n}\nfunction useImageUrlBuilderImage(source, clientOptions) {\n const builder2 = useImageUrlBuilder(clientOptions);\n return useMemo(\n () => source && builder2 ? builder2.image(source) : null,\n [builder2, source]\n );\n}\nconst DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: \"v2023-05-01\" }, DEFAULT_INITIAL_VALUE = null;\nfunction useParams(params) {\n const stringifiedParams = useMemo(\n () => JSON.stringify(params || {}),\n [params]\n );\n return useMemo(() => JSON.parse(stringifiedParams), [stringifiedParams]);\n}\nfunction useListeningQuery(query, {\n params = DEFAULT_PARAMS,\n options = DEFAULT_OPTIONS,\n initialValue = DEFAULT_INITIAL_VALUE\n}) {\n const [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(initialValue), memoParams = useParams(params), memoOptions = useParams(options), subscription = useRef(null), documentStore = useDocumentStore();\n return useEffect(() => {\n if (query && !error && !subscription.current)\n try {\n subscription.current = documentStore.listenQuery(query, memoParams, memoOptions).pipe(\n distinctUntilChanged(isEqual),\n catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))\n ).subscribe((documents) => {\n setData(\n (current) => isEqual(current, documents) ? current : documents\n ), setLoading(!1), setError(!1);\n });\n } catch (err) {\n console.error(err), setLoading(!1), setError(err);\n }\n return error && subscription.current && subscription.current.unsubscribe(), () => {\n var _a;\n subscription.current && ((_a = subscription == null ? void 0 : subscription.current) == null || _a.unsubscribe(), subscription.current = null);\n };\n }, [query, error, memoParams, memoOptions, documentStore]), { data, loading, error };\n}\nfunction useOpenInNewPane(id, type) {\n const routerContext = useContext(RouterContext), { routerPanesState, groupIndex } = usePaneRouter();\n return useCallback(() => {\n if (!routerContext || !id || !type)\n return;\n const panes = [...routerPanesState];\n panes.splice(groupIndex + 1, 0, [\n {\n id,\n params: { type }\n }\n ]);\n const href = routerContext.resolvePathFromState({ panes });\n routerContext.navigateUrl({ path: href });\n }, [id, type, routerContext, routerPanesState, groupIndex]);\n}\nvar __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b))\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n return a;\n}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));\nfunction chunkArray(array, size) {\n const chunks = [];\n for (let i = 0; i < array.length; i += size)\n chunks.push(array.slice(i, i + size));\n return chunks;\n}\nfunction useProjectUsers({ apiVersion }) {\n const { currentUser } = useWorkspace(), client = useClient({ apiVersion: apiVersion != null ? apiVersion : \"2023-01-01\" }), [users, setUsers] = useState([]);\n return useEffect(() => {\n const { projectId } = client.config();\n async function getUsersWithRoles() {\n try {\n const aclData = await client.request({\n url: `/projects/${projectId}/acl`\n }), userIds = aclData.map((user) => user.projectUserId), userIdChunks = chunkArray(userIds, 200);\n let usersData = [];\n for (const chunk of userIdChunks) {\n const chunkedUserIds = chunk.join(\",\"), response = await client.request({\n url: `/projects/${projectId}/users/${chunkedUserIds}`\n });\n usersData = [...usersData, ...response];\n }\n const usersWithRoles = usersData.map((user) => {\n var _a;\n const userRoles = ((_a = aclData.find(\n (aclUser) => aclUser.projectUserId === user.id\n )) == null ? void 0 : _a.roles) || [];\n return __spreadProps(__spreadValues({}, user), {\n isCurrentUser: user.id === (currentUser == null ? void 0 : currentUser.id),\n roles: userRoles\n });\n });\n setUsers(usersWithRoles);\n } catch (err) {\n console.error(\"Failed to fetch users:\", err);\n }\n }\n users.length || getUsersWithRoles();\n }, [client, currentUser == null ? void 0 : currentUser.id, users.length]), users;\n}\nexport {\n Cell,\n Feedback,\n Row,\n Table,\n UserSelectMenu,\n useImageUrlBuilder,\n useImageUrlBuilderImage,\n useListeningQuery,\n useOpenInNewPane,\n useProjectUsers\n};\n//# sourceMappingURL=index.js.map\n","import {createContext} from 'react'\n\nimport type {ConceptSchemeDocument} from './types'\n\ntype TreeContextType = {\n globalVisibility?: {treeId: string; treeVisibility: 'open' | 'closed'}\n editControls?: boolean\n setEditControls?: (value: boolean) => void\n}\n\nexport type ReleaseContextType = {\n isPublished?: boolean\n isInRelease: boolean\n releaseName?: string\n documentId: string\n versionId?: string\n}\n\nexport const SchemeContext = createContext<ConceptSchemeDocument | null>(null)\nexport const TreeContext = createContext<TreeContextType>({editControls: false})\n// export const ReleaseContext = createContext<ReleaseContextType>({\n// isInRelease: false,\n// documentId: '',\n// })\nexport const ReleaseContext = createContext<any>(undefined)\n","/**\n * ### Tree Builder\n * Recursive function to build out successive branches of the hierarchy\n * up to five levels deep.\n */\n\n/**\n * #### Branch Builder\n * Recursive function to build out successive branches of the hierarchy\n * up to five levels deep.\n */\nconst branchBuilder = (level = 1): string | void => {\n let reference = '^.^.concepts[]._ref'\n let i = 1\n while (level > i) {\n reference = `^.${reference}`\n i++\n }\n if (level > 6) {\n return ''\n }\n return `\"childConcepts\": *[_id in ${reference} && ^._id in broader[]._ref]|order(prefLabel)\n {\n \"id\": _id,\n \"level\": ${level},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${branchBuilder(level + 1) || ''}\n }`\n}\n\n/**\n * #### Trunk Builder\n * Fetch the top concepts, their child concepts, and orphan concepts\n * and their child concepts.\n *\n * To get orphans:\n * - filter to concepts in this scheme only\n * - filter out concepts that reference a topConcept in this scheme as\n * a broader term\n * - filter out concepts that reference other concepts in this scheme\n * as a broader term\n *\n * Used in Hierarchy.tsx\n */\nexport const trunkBuilder = (): string => {\n return `*[_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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\n }\n }`\n}\n\n/**\n * #### Input Builder\n * Accept a branchId parameter, and filter to topConcepts and Concepts\n * in that branch only. Then call branchBuilder recursively — it will\n * only build terms in the scheme referenced by that concept.\n *\n * - trunkBuilder() is called in Hierarchy.tsx\n * - inputBuilder() is called in InputHierarchy.tsx\n */\nexport const inputBuilder = (): string => {\n return `\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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\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 ${branchBuilder() || ''}\n }\n }\n )`\n}\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nvar byteToHex = [];\n\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","export default /^(?:[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;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import type {Options} from './types'\n\nlet taxonomyManagerConfig: Options | undefined\n\n/**\n * #### Manage Plugin Config\n * Store the user preferences config in a module-level\n * variable when the plugin initializes\n */\nexport function setPluginConfig(config: Options | undefined): void {\n taxonomyManagerConfig = config\n}\n\nexport function getPluginConfig(): Options | undefined {\n return taxonomyManagerConfig\n}\n","import {\n DocumentId,\n getDraftId,\n getVersionId,\n getVersionNameFromId,\n isVersionId,\n getPublishedId,\n type VersionId,\n} from '@sanity/id-utils'\nimport {useToast} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback} from 'react'\nimport {isPublishedId, useClient} from 'sanity'\n\nimport {getPluginConfig} from '../config'\nimport {createId} from '../helpers/createId'\nimport type {SkosConceptDocument, SkosConceptReference, ConceptSchemeDocument} from '../types'\n\nimport {useOpenNewConceptPane} from './useOpenNewConceptPane'\n\n/**\n * #### Concept Creation Hook\n * Used for creating concepts and top concepts from the\n * Concept Scheme hierarchy view.\n */\nexport function useCreateConcept(document: ConceptSchemeDocument) {\n const toast = useToast()\n const client = useClient({apiVersion: '2025-02-19'})\n const openInNewPane = useOpenNewConceptPane()\n\n // Get ident config from plugin\n const pluginConfig = getPluginConfig()\n const ident = pluginConfig?.ident\n\n const schemaBaseIri = document.displayed.baseIri\n\n const createConcept = useCallback(\n (\n conceptType: 'topConcept' | 'concept',\n concept?: {\n id: string\n _originalId?: string\n }\n ) => {\n // destructure IDs and rename for this context\n const {id: broaderConceptId, _originalId: broaderConceptOriginalId = ''} = concept || {}\n // check if the skosConceptScheme is in a release\n const isInRelease = isVersionId(document.displayed._id as DocumentId)\n // if so, get the release name\n const releaseName = isInRelease\n ? getVersionNameFromId(document.displayed._id as VersionId)\n : undefined\n\n // create a scheme ID based on context\n const schemeId = isInRelease\n ? getVersionId(DocumentId(document.displayed._id), releaseName as string)\n : getDraftId(DocumentId(document.displayed._id))\n\n // Generate the appropriate concept ID based on context\n const newConceptId = isInRelease\n ? getVersionId(DocumentId(uuid()), releaseName as string)\n : getDraftId(DocumentId(uuid()))\n\n // create the new skosConcept document\n const skosConcept: SkosConceptDocument = {\n _id: newConceptId, // either a draft ID or a release ID\n _type: 'skosConcept',\n conceptId: createId(ident),\n prefLabel: '',\n baseIri: schemaBaseIri,\n broader: [],\n related: [],\n }\n\n // if a broader concept ID is provided, add it to the skosConcept\n if (broaderConceptId) {\n // check if the broader concept is published\n const isPublished = isPublishedId(DocumentId(broaderConceptOriginalId))\n // add broader as _strengthenOnPublish if it's not published\n skosConcept.broader = [\n {\n _key: uuid(),\n _ref: getPublishedId(DocumentId(broaderConceptId)),\n _type: 'reference',\n _weak: !isPublished,\n _strengthenOnPublish: isPublished\n ? undefined\n : {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n },\n },\n ]\n }\n\n const skosConceptReference: SkosConceptReference = {\n _ref: getPublishedId(newConceptId),\n _type: 'reference',\n _key: uuid(),\n _strengthenOnPublish: {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n },\n _weak: true,\n }\n\n client\n .transaction()\n .createIfNotExists({...document.displayed, _id: schemeId})\n .create(skosConcept)\n .patch(schemeId, (patch) => {\n if (conceptType === 'topConcept') {\n return patch\n .setIfMissing({topConcepts: []})\n .append('topConcepts', [skosConceptReference])\n }\n return patch.setIfMissing({concepts: []}).append('concepts', [skosConceptReference])\n })\n .commit({autoGenerateArrayKeys: true})\n .then((_res) => {\n toast.push({\n closable: true,\n status: 'success',\n title: 'Created new concept',\n })\n openInNewPane(newConceptId)\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'Error creating concept',\n description: err instanceof Error ? err.message : 'Unknown error occurred',\n })\n })\n },\n [document.displayed, ident, schemaBaseIri, client, toast, openInNewPane]\n )\n return createConcept\n}\n","import {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\n/**\n * Open in New Pane Link for Concepts\n */\nexport function useOpenNewConceptPane() {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const openInNewPane = useCallback(\n (conceptId: string) => {\n if (!routerContext || !conceptId) {\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, groupIndex + 1, [\n {\n id: conceptId,\n params: {type: 'skosConcept'},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n },\n [routerContext, routerPanesState, groupIndex]\n )\n\n return openInNewPane\n}\n","import {\n DocumentId,\n getDraftId,\n getVersionId,\n getVersionNameFromId,\n isVersionId,\n type VersionId,\n} from '@sanity/id-utils'\nimport {useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {useClient} from 'sanity'\n\nimport type {ConceptSchemeDocument} from '../types'\n\n/**\n * #### Concept Removal Hook\n * Used for removing concepts and top concepts from\n * the Concept Scheme hierarchy view.\n */\nexport function useRemoveConcept(document: ConceptSchemeDocument) {\n const toast = useToast()\n const client = useClient({apiVersion: '2025-02-19'})\n\n // conceptId is the id of the concept to be removed\n const removeConcept = useCallback(\n (conceptId: string, conceptType: string, prefLabel?: string) => {\n const type = conceptType == 'topConcept' ? 'topConcepts' : 'concepts'\n\n const isInRelease = isVersionId(document.displayed._id as DocumentId)\n const releaseName = isInRelease\n ? getVersionNameFromId(document.displayed._id as VersionId)\n : undefined\n\n const schemeId = isInRelease\n ? getVersionId(DocumentId(document.displayed._id), releaseName as string)\n : getDraftId(DocumentId(document.displayed._id))\n\n // Ensure concepts are removed from a draft of the concept scheme document\n // const draftConceptScheme = JSON.parse(JSON.stringify(document.displayed))\n\n // if (!draftConceptScheme._id.includes('drafts.')) {\n // draftConceptScheme._id = `drafts.${draftConceptScheme._id}`\n // }\n\n client\n .transaction()\n .createIfNotExists({...document.displayed, _id: schemeId})\n .patch(schemeId, (patch) => patch.unset([`${type}[_ref==\"${conceptId}\"]`]))\n .commit()\n .then((_res) => {\n toast.push({\n closable: true,\n status: 'success',\n title: `${prefLabel ? `\"${prefLabel}\"` : 'Concept'} removed from scheme`,\n })\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'Error removing concept',\n description: err instanceof Error ? err.message : 'Unknown error occurred',\n })\n })\n },\n [client, document.displayed, toast]\n )\n return removeConcept\n}\n","import {useState, useCallback} from 'react'\nimport {useClient, useDataset, useGetFormValue} from 'sanity'\n\nimport type {EmbeddingsIndexConfig, EmbeddingsResult} from '../types'\n\n/**\n * Queries a Sanity embeddings index using values from specified form fields.\n * Returns matching concept scores and any validation errors.\n */\nexport function useEmbeddingsRecs(embeddingsIndex?: EmbeddingsIndexConfig) {\n const client = useClient({apiVersion: 'vX'})\n const dataset = useDataset()\n const getFormValue = useGetFormValue()\n\n const [conceptRecs, setConceptRecs] = useState<EmbeddingsResult[]>([])\n const [recsError, setRecsError] = useState<string | null>(null)\n\n const buildQueryString = useCallback(\n (fieldReferences: string[]): string => {\n const emptyFields: string[] = []\n const values = fieldReferences.map((fieldName) => {\n const val = getFormValue([fieldName])\n if (typeof val === 'string' && val.trim() !== '') {\n return val\n }\n emptyFields.push(fieldName)\n return ''\n })\n if (emptyFields.length === 1) {\n throw new Error(`Please fill out the ${emptyFields[0]} field to enable match scores.`)\n } else if (emptyFields.length > 1) {\n throw new Error(\n `The following fields must be filled out to enable match scores: ${emptyFields.join(\n ', '\n )}`\n )\n }\n return values.filter(Boolean).join(' ')\n },\n [getFormValue]\n )\n\n const fetchConceptRecs = useCallback(\n async (query: string, indexName: string, maxResults: number) => {\n const returnedRecs: EmbeddingsResult[] = await client.request({\n url: `/embeddings-index/query/${dataset}/${indexName}`,\n method: 'POST',\n body: {\n query,\n maxResults,\n },\n })\n setConceptRecs(returnedRecs)\n },\n [client, dataset]\n )\n\n const triggerEmbeddingsSearch = useCallback(() => {\n setRecsError(null)\n if (!embeddingsIndex) return\n const {indexName, fieldReferences, maxResults = 3} = embeddingsIndex\n try {\n const query = buildQueryString(fieldReferences)\n fetchConceptRecs(query, indexName, maxResults).catch((error) =>\n console.error('Error with embeddings index fetch: ', error)\n )\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'One or more required fields are empty'\n setRecsError(errorMessage)\n }\n }, [buildQueryString, embeddingsIndex, fetchConceptRecs])\n\n return {conceptRecs, recsError, triggerEmbeddingsSearch}\n}\n","import {InfoOutlineIcon} from '@sanity/icons'\nimport {Dialog, Box, Text, Stack, Label, Button, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\n\nimport type {ChildConceptTerm, TopConceptTerm} from '../../types'\n\nconst MessageHelper = ({title, message}: {title: string; message: string}) => {\n return (\n <Stack space={2}>\n <Label size={1}>{title}</Label>\n <Text size={2} muted style={{whiteSpace: 'pre-wrap'}}>\n {message}\n </Text>\n </Stack>\n )\n}\n\n/**\n * #### Information Icon and Dialogue with Concept Details\n * - Affords Tree View access to Definition, Examples, and Scope Notes\n * - Rendered only when concept details are present\n */\nexport const ConceptDetailDialogue = ({\n concept,\n}: {\n concept: (ChildConceptTerm | TopConceptTerm) & {\n definition?: string\n example?: string\n scopeNote?: string\n }\n}) => {\n const [open, setOpen] = useState(false)\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n if (!concept || (!concept.definition && !concept.example && !concept.scopeNote)) return null\n\n return (\n <>\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n View concept details\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button icon={InfoOutlineIcon} mode={'bleed'} onClick={onOpen} tone={'default'} />\n </Tooltip>\n\n {open && (\n <Dialog\n header={concept.prefLabel}\n id=\"dialog-example\"\n onClose={onClose}\n zOffset={1000}\n width={1}\n >\n <Box padding={4} paddingTop={2} paddingBottom={5}>\n <Stack space={4}>\n {concept.definition && (\n <MessageHelper title={'Definition'} message={concept.definition} />\n )}\n {concept.example && <MessageHelper title={'Examples'} message={concept.example} />}\n {concept.scopeNote && (\n <MessageHelper title={'Scope Notes'} message={concept.scopeNote} />\n )}\n </Stack>\n </Box>\n </Dialog>\n )}\n </>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport {Button, Text, Box, Badge, Tooltip} from '@sanity/ui'\nimport {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport type {ChildConceptTerm} from '../../types'\n\n/**\n * #### Concept Detail Link\n * Renders a link to a concept in the hierarchy tree that opens in a new pane.\n */\nexport function ConceptDetailLink({\n concept,\n topConcept = false,\n orphan = false,\n}: {\n concept: ChildConceptTerm\n topConcept?: boolean\n orphan?: boolean\n}) {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const {id, prefLabel} = concept ?? {}\n const displayLabel = prefLabel || '[new concept]'\n\n const openInNewPane = useCallback(() => {\n if (!routerContext || !id) {\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, groupIndex + 1, [\n {\n id: id,\n params: {type: 'skosConcept'},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n }, [id, routerContext, routerPanesState, groupIndex])\n\n return (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {`View \"${prefLabel}\"`}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n >\n <Button\n mode=\"bleed\"\n paddingLeft={0}\n onClick={openInNewPane}\n width=\"fill\"\n justify={'flex-start'}\n >\n <Text size={2} weight={topConcept ? 'bold' : 'regular'} textOverflow=\"ellipsis\">\n {displayLabel}\n {(topConcept || orphan) && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {topConcept ? 'top concept' : 'orphan'}\n </Badge>\n )}\n </Text>\n </Button>\n </Tooltip>\n )\n}\n","import {TrashIcon, AddCircleIcon} from '@sanity/icons'\nimport {Box, Text, Button, Tooltip} from '@sanity/ui'\n// import {useCallback, useState} from 'react'\n\nexport const ConceptEditAction = ({\n action,\n handler,\n}: {\n action: 'remove' | 'add'\n handler: () => void\n}) => {\n // const [open, setOpen] = useState(false)\n // const onClose = useCallback(() => setOpen(false), [])\n // const onOpen = useCallback(() => setOpen(true), [])\n\n const typeMap = {\n add: {\n message: 'Add a child concept below this concept' as const,\n icon: AddCircleIcon,\n tone: 'positive' as const,\n },\n remove: {\n message: 'Remove this concept from this scheme' as const,\n icon: TrashIcon,\n tone: 'critical' as const,\n },\n }\n\n return (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {typeMap[action].message}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n >\n <Button\n icon={typeMap[action].icon}\n mode={'bleed'}\n onClick={handler}\n tone={typeMap[action].tone}\n aria-label=\"Remove this concept from this scheme\"\n />\n </Tooltip>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport {Button, Text, Box, Badge, Tooltip} from '@sanity/ui'\nimport {useCallback} from 'react'\n\nimport type {ChildConceptTerm} from '../../types'\n\n/**\n * #### Concept Select Link\n * Writes a concept _ref from the hierarchy tree to the current document\n */\nexport function ConceptSelectLink({\n concept,\n topConcept = false,\n orphan = false,\n selectConcept,\n}: {\n concept: ChildConceptTerm\n topConcept?: boolean\n orphan?: boolean\n selectConcept?: (conceptRef: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n}) {\n const {prefLabel, id, _originalId, score} = concept ?? {}\n const displayLabel = prefLabel || '[new concept]'\n\n const handleClick = useCallback(() => {\n if (!selectConcept) return\n\n const conceptRef = {\n _ref: id,\n _type: 'reference' as const,\n _originalId,\n }\n selectConcept(conceptRef)\n }, [id, _originalId, selectConcept])\n\n return (\n <>\n {selectConcept && (\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {`Select \"${prefLabel}\"`}\n {score && ` (${(score * 100).toFixed(1)}% resource match)`}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left', 'bottom']}\n placement=\"top\"\n portal\n >\n <Button\n mode=\"bleed\"\n paddingLeft={0}\n onClick={handleClick}\n width=\"fill\"\n justify={'flex-start'}\n >\n <Text size={2} weight={topConcept ? 'bold' : 'regular'} textOverflow=\"ellipsis\">\n {displayLabel}\n {(topConcept || orphan) && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {topConcept ? 'top concept' : 'orphan'}\n </Badge>\n )}\n {score && (\n <Badge fontSize={0} marginLeft={3} style={{verticalAlign: 'middle'}}>\n {`${(score * 100).toFixed(1)}%`}\n </Badge>\n )}\n </Text>\n </Button>\n </Tooltip>\n )}\n </>\n )\n}\n","import {InfoOutlineIcon, ErrorOutlineIcon} from '@sanity/icons'\nimport {Dialog, Box, Text, Button, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\n\n/**\n * #### Information Icon and Dialogue with Structure Details\n * Provide feedback on concepts that are at the limit of\n * or have children beyond the supported hierarchy depth\n */\nexport const StructureDetailDialogue = ({\n message,\n title,\n type,\n}: {\n message: string\n title: string\n type: 'info' | 'warn' | 'error'\n}) => {\n const [open, setOpen] = useState(false)\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n const toneMap = {\n info: 'default' as const,\n warn: 'caution' as const,\n error: 'critical' as const,\n }\n\n return (\n <>\n <Tooltip\n delay={{open: 750}}\n content={\n <Box padding={1} sizing=\"content\">\n <Text muted size={1}>\n {title}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button\n icon={type == 'error' ? ErrorOutlineIcon : InfoOutlineIcon}\n mode={'bleed'}\n onClick={onOpen}\n tone={toneMap[type]}\n />\n </Tooltip>\n\n {open && (\n <Dialog header={title} id=\"dialog-example\" onClose={onClose} zOffset={1000} width={1}>\n <Box padding={4} paddingBottom={5}>\n <Text>{message}</Text>\n </Box>\n </Dialog>\n )}\n </>\n )\n}\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","// import styles from '../styles/toggleButton.module.css'\nimport {ToggleArrowRightIcon} from '@sanity/icons'\nimport {Button} from '@sanity/ui'\n\nimport styles from './ToggleButton.module.css'\n\nexport function ToggleButton({handler, visibility}: {handler: () => void; visibility: string}) {\n return (\n <Button\n icon={ToggleArrowRightIcon}\n mode={'bleed'}\n aria-expanded={visibility == 'open'}\n onClick={handler}\n className={styles.toggleButton}\n />\n )\n}\n","/* eslint-disable complexity */\nimport {Inline, Box, Flex} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext, TreeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ChildConceptTerm, ConceptSchemeDocument} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {StructureDetailDialogue} from './interactions/StructureDetailDialogue'\nimport {ToggleButton} from './interactions/ToggleButton'\n\n/**\n * #### Child Concept Component\n * Renders a list of child concepts and applicable\n * actions for a given concept.\n */\nexport const Children = ({\n concept,\n selectConcept,\n inputComponent = false,\n}: {\n concept: ChildConceptTerm\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n inputComponent: boolean\n}) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n const {globalVisibility: {treeVisibility} = {treeVisibility: 'open' as const}} =\n useContext(TreeContext) || {}\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept.id, 'concept', concept?.prefLabel)\n }, [concept.id, concept?.prefLabel, removeConcept])\n\n const [levelVisibility, setLevelVisibility] = useState<'open' | 'closed'>(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility || 'open'\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink concept={concept} selectConcept={selectConcept} />\n ) : (\n <ConceptDetailLink concept={concept} />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent &&\n releaseContext !== 'published' &&\n concept?.level &&\n concept.level < 5 && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n {!inputComponent &&\n releaseContext !== 'published' &&\n concept.childConcepts?.length == 0 &&\n concept.level == 5 && (\n <Inline>\n <StructureDetailDialogue\n type={'warn'}\n title={'Taxonomy Manager structure notice'}\n message={\n 'This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels. Additional child terms are not shown in the hierarchy tree.'\n }\n />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n {concept?.childConcepts && concept?.childConcepts?.length > 0 && concept.level == 5 && (\n <Inline>\n <StructureDetailDialogue\n type={'error'}\n title={'Taxonomy Manager structure warning'}\n message={\n 'This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels.'\n }\n />\n {!inputComponent && releaseContext !== 'published' && (\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n )}\n </Inline>\n )}\n </Flex>\n {/* Child elements the next level down, if any */}\n {concept?.childConcepts &&\n concept.childConcepts.length > 0 &&\n concept?.level &&\n concept.level < 5 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {Box, Stack} from '@sanity/ui'\n\nimport type {ChildConceptTerm} from '../types'\n\nimport {Children} from './Children'\n\n/**\n * #### Child Concepts\n * Lenders a list of child concepts for a given concept\n * with a `<ul>` wrapper for each level of nesting\n */\nexport const ChildConcepts = ({\n concepts,\n inputComponent = false,\n selectConcept,\n childVisibility,\n}: {\n concepts: ChildConceptTerm[]\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n inputComponent: boolean\n childVisibility: string // retype to 'open' | 'closed\n}) => {\n return (\n // the container for child terms\n <Box marginLeft={4} marginTop={2} display={childVisibility == 'closed' ? 'none' : 'block'}>\n <Stack space={3}>\n {concepts.map((concept: ChildConceptTerm) => {\n return (\n <Children\n key={concept.id}\n concept={concept}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n />\n )\n })}\n </Stack>\n </Box>\n )\n}\n","import {Inline, Box, Flex} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ChildConceptTerm, ConceptSchemeDocument} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {ToggleButton} from './interactions/ToggleButton'\n\ntype ConceptProps = {\n concept: ChildConceptTerm\n treeVisibility: string\n inputComponent: boolean\n selectConcept: (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId: string | undefined\n }) => void\n}\n\n/**\n * #### Concept Component\n * Renders a list of concepts for a given schema.\n */\nexport const Concepts = ({\n concept,\n treeVisibility,\n inputComponent,\n selectConcept,\n}: ConceptProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const hasTopConcept = !!document.displayed?.topConcepts?.length && !inputComponent\n\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const [levelVisibility, setLevelVisibility] = useState(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept.id, 'concept', concept?.prefLabel)\n }, [concept.id, concept?.prefLabel, removeConcept])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} orphan={hasTopConcept} />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink\n concept={concept}\n selectConcept={selectConcept}\n orphan={hasTopConcept}\n />\n ) : (\n <ConceptDetailLink concept={concept} orphan={hasTopConcept} />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent && releaseContext !== 'published' && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n </Flex>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {AddIcon} from '@sanity/icons'\nimport {Card, Label, Stack, Text, Button, Dialog, Box, TextArea, TextInput} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport type {SanityDocument} from 'sanity'\n\nimport {useAddTitle} from '../../hooks'\n\n/**\n * #### New Concept Scheme Guide\n * - Prompts adding title and description to new concept scheme.\n * - Data must be saved to newly created Concept Scheme documents before\n * add top concept / add concept buttons will work.\n */\nexport const NewScheme = ({document}: {document: SanityDocument}) => {\n const [open, setOpen] = useState(false)\n const [titleValue, setTitleValue] = useState('')\n const [descriptionValue, setDescriptionValue] = useState('')\n const onClose = useCallback(() => setOpen(false), [])\n const onOpen = useCallback(() => setOpen(true), [])\n\n const handleTitleChange = useCallback((event: any) => {\n setTitleValue(event.currentTarget.value)\n }, [])\n const handleDescriptionChange = useCallback((event: any) => {\n setDescriptionValue(event.currentTarget.value)\n }, [])\n\n const addTitle = useAddTitle()\n\n const handleAddTitle = useCallback(() => {\n addTitle(document, titleValue, descriptionValue)\n }, [addTitle, descriptionValue, document, titleValue])\n\n return (\n <div style={{marginTop: '2rem'}}>\n <Card padding={[3, 3, 4]} radius={2} shadow={1} tone=\"primary\">\n <Stack space={6}>\n <Stack space={4}>\n <Label size={4}>New Concept Scheme</Label>\n <Text size={2}>\n To start using hierarchy view taxonomy builder, first give your concept scheme a name\n and optional description. You can also use the \"Editor\" tab to add concepts to the\n tree manually.\n </Text>\n </Stack>\n <Button tone=\"primary\" fontSize={2} icon={AddIcon} onClick={onOpen} text=\"Add Title\" />\n </Stack>\n </Card>\n {open && (\n <Dialog\n header=\"Title & Description\"\n id=\"title-description\"\n onClose={onClose}\n zOffset={1000}\n width={1}\n >\n <Box padding={4}>\n <Stack space={4}>\n <Stack space={2}>\n <Label size={1}>Title</Label>\n <Text size={1} muted>\n Describe the concept scheme in one or two words.\n </Text>\n </Stack>\n <TextInput\n fontSize={2}\n onChange={handleTitleChange}\n padding={3}\n placeholder=\"\"\n value={titleValue}\n />\n <Stack space={2}>\n <Label size={1}>Description (optional)</Label>\n <Text size={1} muted>\n Describe the intended use of this concept scheme.\n </Text>\n </Stack>\n <TextArea\n fontSize={2}\n onChange={handleDescriptionChange}\n padding={3}\n placeholder=\"\"\n value={descriptionValue}\n rows={3}\n />\n <Button tone=\"primary\" fontSize={2} onClick={handleAddTitle} text=\"Save\" />\n </Stack>\n </Box>\n </Dialog>\n )}\n </div>\n )\n}\n","import {useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {useClient} from 'sanity'\n\n/**\n * #### Add Title and Description to New Concept Scheme\n * Good for user experience, and also needed to write the\n * new scheme to the content lake, prior to which add top\n * concept / add concept buttons will not work.\n */\nexport function useAddTitle() {\n const toast = useToast()\n const client = useClient({apiVersion: '2021-10-21'})\n\n const addTitle = useCallback(\n (document: any, titleValue: string, descriptionValue?: string) => {\n const documentId = document.displayed?._id\n const schemaBaseIri = document.displayed?.baseIri\n const schemeId = document.displayed?.schemeId\n\n const doc = {\n _id: `drafts.${documentId}`,\n _type: 'skosConceptScheme',\n schemeId: schemeId,\n baseIri: schemaBaseIri,\n title: titleValue,\n description: descriptionValue ? descriptionValue : '',\n }\n\n client\n .createIfNotExists(doc)\n .then((_) => {\n if (descriptionValue) {\n return toast.push({\n closable: true,\n status: 'success',\n title: 'Title and Description added.',\n })\n }\n return toast.push({\n closable: true,\n status: 'success',\n title: 'Title added.',\n })\n })\n .catch((err) => {\n toast.push({\n closable: true,\n status: 'error',\n title: 'There has been an error',\n description: err.message,\n })\n })\n },\n [client, toast]\n )\n\n return addTitle\n}\n","import {Card, Label, Stack, Text} from '@sanity/ui'\n\n/**\n * #### No Concepts Guide\n * Prompts adding concepts to an empty scheme.\n */\nexport const NoConcepts = () => {\n return (\n <div style={{marginTop: '2rem'}}>\n <Card padding={[3, 3, 4]} radius={2} shadow={1} tone=\"primary\">\n <Stack space={4}>\n <Label size={4}>No Concepts</Label>\n <Text size={2}>\n There are not yet any concepts assigned to this scheme. To create a multi-level\n hierarchy with specific entry points, create Top Concepts first, then add child concepts\n to them. To create a flat list of concepts, create Concepts directly.\n </Text>\n </Stack>\n </Card>\n </div>\n )\n}\n","import {Flex, Inline, Box} from '@sanity/ui'\nimport {useCallback, useContext, useState} from 'react'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport {useCreateConcept, useRemoveConcept} from '../hooks'\nimport type {ConceptSchemeDocument, TopConceptTerm} from '../types'\n\nimport {ChildConcepts} from './ChildConcepts'\nimport {ConceptDetailDialogue} from './interactions/ConceptDetailDialogue'\nimport {ConceptDetailLink} from './interactions/ConceptDetailLink'\nimport {ConceptEditAction} from './interactions/ConceptEditAction'\nimport {ConceptSelectLink} from './interactions/ConceptSelectLink'\nimport {ToggleButton} from './interactions/ToggleButton'\n\ntype TopConceptsProps = {\n concept: TopConceptTerm\n treeVisibility: string\n inputComponent: boolean\n selectConcept: (conceptId: {_ref: string; _type: 'reference'}) => void\n}\n\n/**\n * #### Top Concept Component\n * Renders a list of top concepts for a given schema.\n */\nexport const TopConcepts = ({\n concept,\n treeVisibility,\n inputComponent,\n selectConcept,\n}: TopConceptsProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const createConcept = useCreateConcept(document)\n const removeConcept = useRemoveConcept(document)\n\n const [levelVisibility, setLevelVisibility] = useState(\n treeVisibility === 'closed' && concept.hasMatchingDescendant ? 'open' : treeVisibility\n )\n\n const handleToggle = useCallback(() => {\n if (levelVisibility == 'open') {\n setLevelVisibility('closed')\n } else if (levelVisibility == 'closed') {\n setLevelVisibility('open')\n }\n }, [levelVisibility])\n\n const handleAddChild = useCallback(() => {\n createConcept('concept', concept)\n }, [concept, createConcept])\n\n const handleRemoveConcept = useCallback(() => {\n removeConcept(concept?.id, 'topConcept', concept?.prefLabel)\n }, [concept?.id, concept?.prefLabel, removeConcept])\n\n return (\n <Box className={levelVisibility}>\n <Flex align={'center'} justify={'space-between'} wrap={'nowrap'}>\n {/* Toggle, label, tag — left half of flexbox */}\n <Flex align=\"center\" gap={0} flex={1} style={{minWidth: 0}}>\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ToggleButton handler={handleToggle} visibility={levelVisibility} />\n )}\n {!concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n <ConceptDetailLink concept={concept} topConcept />\n </Box>\n )}\n {concept?.prefLabel && (\n <Box\n flex={1}\n marginLeft={!concept?.childConcepts || concept.childConcepts.length == 0 ? 5 : 0}\n >\n {inputComponent ? (\n <ConceptSelectLink concept={concept} selectConcept={selectConcept} topConcept />\n ) : (\n <ConceptDetailLink concept={concept} topConcept />\n )}\n </Box>\n )}\n </Flex>\n {/* Concept info and edit actions — right half of flexbox */}\n {inputComponent && <ConceptDetailDialogue concept={concept} />}\n {!inputComponent && releaseContext !== 'published' && (\n <Inline>\n <ConceptEditAction action={'add'} handler={handleAddChild} />\n <ConceptEditAction action={'remove'} handler={handleRemoveConcept} />\n </Inline>\n )}\n </Flex>\n {/* Child Concepts */}\n {concept?.childConcepts && concept.childConcepts.length > 0 && (\n <ChildConcepts\n concepts={concept.childConcepts}\n selectConcept={selectConcept}\n inputComponent={inputComponent}\n childVisibility={levelVisibility}\n />\n )}\n </Box>\n )\n}\n","import {Box, Stack} from '@sanity/ui'\nimport {useContext} from 'react'\n\nimport {TreeContext} from '../context'\nimport type {DocumentConcepts, TopConceptTerm, ChildConceptTerm} from '../types'\n\nimport {Concepts} from './Concepts'\nimport {NoConcepts} from './guides'\nimport {TopConcepts} from './TopConcepts'\n\n/**\n * #### Tree View\n * Fetches the complete tree of concepts in a concept scheme, stemming\n * from Top Concepts or Orphans. Displays the tree in a nested list.\n */\nexport const TreeStructure = ({\n concepts,\n inputComponent,\n selectConcept,\n}: {\n concepts: DocumentConcepts\n inputComponent: boolean\n selectConcept: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void\n}) => {\n const {globalVisibility: {treeId, treeVisibility} = {treeId: 'default', treeVisibility: 'open'}} =\n useContext(TreeContext) || {}\n\n if (!concepts?.topConcepts?.length && !concepts?.concepts?.length) {\n return <NoConcepts />\n }\n\n return (\n <Box paddingTop={4}>\n <Stack space={3} style={{listStyle: 'none', paddingLeft: '0', marginBlockStart: '0'}}>\n {concepts.topConcepts?.map((concept: TopConceptTerm) => (\n <TopConcepts\n key={`${concept?.id}+${treeId}`}\n concept={concept}\n treeVisibility={treeVisibility}\n inputComponent={inputComponent}\n selectConcept={selectConcept}\n />\n ))}\n {concepts.concepts\n ?.filter((concept: ChildConceptTerm) => concept?.isOrphan)\n .map((concept: ChildConceptTerm) => {\n return (\n <Concepts\n key={`${concept.id}+${treeId}`}\n concept={concept}\n treeVisibility={treeVisibility}\n inputComponent={inputComponent}\n selectConcept={selectConcept}\n />\n )\n })}\n </Stack>\n </Box>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport type {DocumentId} from '@sanity/id-utils'\nimport {getPublishedId} from '@sanity/id-utils'\nimport {Flex, Spinner, Box, Text, Card} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useContext, useMemo} from 'react'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {ReleaseContext, SchemeContext, TreeContext} from '../../context'\nimport {inputBuilder} from '../../queries'\nimport type {\n ChildConceptTerm,\n ConceptSchemeDocument,\n DocumentConcepts,\n TreeViewProps,\n} from '../../types'\nimport {TreeStructure} from '../TreeStructure'\n\n/**\n * #### Input Hierarchy Component\n * - Provides a frame for global controls and tree structure\n * - Fetches the complete tree of concepts in a concept scheme.\n * - Displays the tree in a nested list.\n * @param inputComponent - Specifies whether the component is a Studio\n * input component. Set in HierarchyInput and passed through TreeView\n */\nexport const InputHierarchy = ({\n branchId = '',\n selectConcept,\n inputComponent,\n expanded,\n conceptRecs,\n recsError,\n}: TreeViewProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const documentId = getPublishedId(document.displayed?._id as DocumentId)\n const releaseContext: string = useContext(ReleaseContext) as string\n const initialVisibility = expanded ? 'open' : 'closed'\n const {data, loading, error} = useListeningQuery<DocumentConcepts>(\n {\n fetch: inputBuilder(),\n listen: `*[_type == \"skosConcept\" || _id == $id]`,\n },\n {\n // GROQ's select($branchId != null => ...) requires null, not empty string.\n // ListenQueryParams doesn't accept null, so we cast past it.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n params: {id: documentId, branchId} as any,\n options: {\n perspective: releaseContext === undefined ? 'drafts' : [releaseContext],\n },\n }\n ) as {data: DocumentConcepts; loading: boolean; error: Error | null}\n\n // Build a score lookup map from conceptRecs:\n const scoreMap = useMemo(() => {\n const map = new Map<string, number>()\n if (Array.isArray(conceptRecs)) {\n for (const rec of conceptRecs) {\n map.set(rec.value.documentId, rec.score)\n }\n }\n return map\n }, [conceptRecs])\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const treeId = useMemo(() => nanoid(6), [scoreMap])\n\n // Recursively annotate tree nodes\n // Walk the tree creating new objects with score attached where\n // there's a match. Use getPublishedId() to normalize the tree\n // node id before comparing against the lookup map.\n // Process children first, then check if any child has score\n // or hasMatchingDescendant.\n const addScores = useCallback(function addScores<T extends ChildConceptTerm>(\n node: T,\n scores: Map<string, number>\n ): T {\n const publishedId = getPublishedId(node.id as DocumentId)\n const score = scores.get(publishedId)\n\n const annotatedChildren = node.childConcepts?.map((c) => addScores(c, scores))\n\n const hasMatchingDescendant =\n annotatedChildren?.some((c) => c.score !== undefined || c.hasMatchingDescendant) ?? false\n\n return {\n ...node,\n ...(score === undefined ? {} : {score}),\n ...(hasMatchingDescendant ? {hasMatchingDescendant: true} : {}),\n ...(annotatedChildren ? {childConcepts: annotatedChildren} : {}),\n } as T\n },\n [])\n\n // Compute merged data with useMemo:\n const mergedData = useMemo(() => {\n if (!data || scoreMap.size === 0 || recsError) return data\n return {\n topConcepts: data.topConcepts?.map((tc) => addScores(tc, scoreMap)),\n concepts: data.concepts?.map((c) => addScores(c, scoreMap)),\n }\n }, [addScores, data, scoreMap, recsError])\n\n if (loading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading hierarchy…\n </Text>\n </Flex>\n </Box>\n )\n } else if (error) {\n console.warn(error)\n return (\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading terms. Please check the scheme configuration and try again.\n </Text>\n </Card>\n </Box>\n )\n } else if (!data) {\n return (\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n This configuration does not have any terms associated with it. Please check the scheme\n and branch supplied and try again.\n </Text>\n </Card>\n </Box>\n )\n }\n return (\n <TreeContext.Provider value={{globalVisibility: {treeId, treeVisibility: initialVisibility}}}>\n <Box padding={4} paddingTop={0}>\n {recsError && (\n <Card marginTop={2} padding={3} radius={2} shadow={1} tone=\"caution\">\n <Text size={2}>{recsError}</Text>\n </Card>\n )}\n <TreeStructure\n concepts={mergedData}\n inputComponent={inputComponent || false}\n selectConcept={selectConcept || (() => undefined)}\n />\n </Box>\n </TreeContext.Provider>\n )\n}\n","export default function NodeTree() {\n return (\n <svg\n data-sanity-icon\n width=\"25\"\n height=\"25\"\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n 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\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n","import {AddCircleIcon} from '@sanity/icons'\nimport type {DocumentId} from '@sanity/id-utils'\nimport {getPublishedId} from '@sanity/id-utils'\nimport {Flex, Spinner, Stack, Box, Text, Inline, Card, Button} from '@sanity/ui'\nimport {nanoid} from 'nanoid'\nimport {useCallback, useContext, useState} from 'react'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {SchemeContext, TreeContext, ReleaseContext} from '../context'\nimport {useCreateConcept} from '../hooks'\nimport {trunkBuilder} from '../queries'\nimport type {DocumentConcepts, ConceptSchemeDocument, TreeViewProps} from '../types'\n\nimport {NewScheme} from './guides'\nimport {TreeStructure} from './TreeStructure'\n\n/**\n * #### Hierarchy Component\n * Provides a frame for global controls and tree structure and displays\n * controls to add concepts or top concepts when in draft mode or release mode.\n * @param inputComponent - Whether this is an input component.\n * @param branchId - Input component: The branch ID to fetch concepts from.\n * @param selectConcept - Input component: The function to call when a concept is selected.\n */\nexport const Hierarchy = ({\n inputComponent = false,\n // branchId = '',\n selectConcept,\n}: TreeViewProps) => {\n const document: ConceptSchemeDocument = useContext(SchemeContext) || ({} as ConceptSchemeDocument)\n const documentId = getPublishedId(document.displayed?._id as DocumentId)\n const releaseContext: string = useContext(ReleaseContext) as string\n\n const createConcept = useCreateConcept(document)\n const createTopConcept = useCallback(() => {\n createConcept('topConcept')\n }, [createConcept])\n const createEntryConcept = useCallback(() => {\n createConcept('concept')\n }, [createConcept])\n\n // Expand & Collapse Controls\n // short IDs are used on treeId to initiate a re-rendering of all child\n // elements on expand/collapse and re-initialize any local toggle state\n // that had been set.\n const [globalVisibility, setGlobalVisibility] = useState<{\n treeId: string\n treeVisibility: 'open' | 'closed'\n }>({\n treeId: nanoid(6),\n treeVisibility: 'open',\n })\n const handleExpand = useCallback(() => {\n setGlobalVisibility({treeId: nanoid(6), treeVisibility: 'open'})\n }, [])\n const handleCollapse = useCallback(() => {\n setGlobalVisibility({treeId: nanoid(6), treeVisibility: 'closed'})\n }, [])\n\n const {data, loading, error} = useListeningQuery<DocumentConcepts>(\n {\n fetch: trunkBuilder(),\n listen: `*[_type == \"skosConcept\" || _type == \"skosConceptScheme\" ]`,\n },\n {\n params: {\n id: documentId,\n },\n options: {\n perspective: releaseContext === undefined ? 'drafts' : [releaseContext],\n },\n }\n ) as {data: DocumentConcepts; loading: boolean; error: Error | null}\n if (loading) {\n return (\n <Box padding={4} paddingTop={6}>\n <Flex align=\"center\" direction=\"column\" gap={5} height=\"fill\" justify=\"center\">\n <Spinner muted />\n <Text muted size={1}>\n Loading hierarchy…\n </Text>\n </Flex>\n </Box>\n )\n } else if (error) {\n console.error(error)\n return <div>Error here</div>\n } else if (!data) {\n return <NewScheme document={document} />\n }\n return (\n <TreeContext.Provider value={{globalVisibility}}>\n <Box padding={4}>\n <>\n <Stack space={4}>\n <Card borderBottom paddingBottom={1} display={'flex'} flex={1}>\n <Flex justify={'space-between'} flex={1}>\n <Card>\n {(data.topConcepts?.filter((concept) => (concept?.childConcepts?.length ?? 0) > 0)\n .length > 0 ||\n data.concepts?.filter((concept) => (concept?.childConcepts?.length ?? 0) > 0)\n .length > 0) && (\n <Inline space={1}>\n <Button\n text={'Collapse'}\n paddingY={2}\n mode={'bleed'}\n onClick={handleCollapse}\n />\n <Text weight=\"semibold\" muted size={1}>\n |\n </Text>\n <Button text={'Expand'} paddingY={2} mode={'bleed'} onClick={handleExpand} />\n </Inline>\n )}\n </Card>\n <Card>\n {releaseContext !== 'published' && (\n <Inline space={1}>\n <Button\n text={'Add Top Concept'}\n icon={AddCircleIcon}\n mode={'bleed'}\n tone={'positive'}\n paddingY={2}\n onClick={createTopConcept}\n />\n <Button\n text={'Add Concept'}\n icon={AddCircleIcon}\n mode={'bleed'}\n tone={'positive'}\n paddingY={2}\n onClick={createEntryConcept}\n />\n </Inline>\n )}\n </Card>\n </Flex>\n </Card>\n </Stack>\n <TreeStructure\n concepts={data}\n inputComponent={inputComponent}\n selectConcept={selectConcept || (() => undefined)}\n />\n </>\n </Box>\n </TreeContext.Provider>\n )\n}\n\nexport default Hierarchy\n","import {Box, Container, Stack, Text} from '@sanity/ui'\nimport {usePerspective} from 'sanity'\n\nimport {ReleaseContext, SchemeContext} from '../context'\nimport type {ConceptSchemeDocument, TreeViewProps} from '../types'\n\nimport {Hierarchy} from './Hierarchy'\nimport {InputHierarchy} from './inputs'\n\n/**\n * #### Tree View Component Wrapper\n * This is the view component for the hierarchy tree. It is the\n * top level of concept scheme views and is passed into Desk\n * structure to render the primary view for taxonomy documents.\n * @param document - The document to render.\n * @param branchId - The branch ID to fetch concepts from.\n * @param inputComponent - Specifies whether the component is Studio input component, which will hide tree view controls and chrome.\n * @param selectConcept - The function to call when a concept is selected.\n */\nexport const TreeView = ({\n document,\n branchId,\n inputComponent = false,\n selectConcept,\n expanded,\n conceptRecs,\n recsError,\n}: TreeViewProps) => {\n const {selectedPerspectiveName} = usePerspective()\n return (\n <SchemeContext.Provider value={document || ({} as ConceptSchemeDocument)}>\n <ReleaseContext.Provider value={selectedPerspectiveName}>\n {inputComponent ? (\n <InputHierarchy\n inputComponent={inputComponent}\n branchId={branchId}\n selectConcept={selectConcept}\n expanded={expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n ) : (\n <Container width={1}>\n {document?.displayed?.description && (\n <Box padding={4} paddingTop={6}>\n <Stack space={4}>\n <Stack space={2}>\n <Text size={1} weight=\"semibold\">\n Description\n </Text>\n <Text size={2} muted>\n {document?.displayed.description}\n </Text>\n </Stack>\n </Stack>\n </Box>\n )}\n <Hierarchy inputComponent={inputComponent} branchId={branchId} />\n </Container>\n )}\n </ReleaseContext.Provider>\n </SchemeContext.Provider>\n )\n}\n\nexport default TreeView\n","/* eslint-disable react/require-default-props */\nimport {isVersionId} from '@sanity/id-utils'\nimport type {DocumentId} from '@sanity/id-utils'\nimport {Grid, Stack, Button, Dialog, Box, Spinner, Text, Flex, Card} from '@sanity/ui'\nimport {useState, useEffect, useCallback} from 'react'\nimport type {ObjectFieldProps, ObjectOptions, Reference} from 'sanity'\nimport {FormField, isDraftId, useClient, useFormValue, usePerspective} from 'sanity'\n\nimport {useEmbeddingsRecs} from '../../hooks'\nimport NodeTree from '../../static/NodeTree'\nimport type {ConceptSchemeDocument, EmbeddingsIndexConfig} from '../../types'\nimport {TreeView} from '../TreeView'\n\ntype ReferenceOptions = ObjectOptions & {\n filter: ({getClient}: {getClient: () => ReturnType<typeof useClient>}) => Promise<{\n filter: string\n params: {\n concepts: string[]\n topConcepts?: string[]\n schemeId: string\n branchId?: string\n }\n expanded?: boolean\n browseOnly?: boolean\n }>\n}\n\ntype HierarchyInput = ObjectFieldProps<Reference> & {\n embeddingsIndex?: EmbeddingsIndexConfig\n}\n\n// Extract the return type of the filter function\ntype FilterResult = Awaited<ReturnType<ReferenceOptions['filter']>>\n\n/**\n * Input component that replaces Sanity's default reference field input with a\n * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms\n * organized in their scheme hierarchy and select a single term for the field.\n *\n * @remarks\n * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's\n * `options.filter`. Rendering without a filter will display a configuration warning.\n * - Taxonomy selection is disabled when viewing the published perspective.\n * - When `browseOnly` is set in the filter configuration, Sanity's default search input\n * is suppressed and only the tree browser is available for term selection.\n * - When `expanded` is set in the filter configuration, the hierarchy tree loads open\n * by default instead of collapsed.\n *\n * @param props - Standard Sanity `ObjectFieldProps<Reference>` extended with an optional\n * `embeddingsIndex` configuration object.\n * @param props.embeddingsIndex - Optional configuration for AI-assisted term\n * recommendations via a Sanity Embeddings Index. When provided, opening the tree\n * browser queries the specified index and annotates matching taxonomy terms with\n * a relevance score to help authors identify the most appropriate term.\n * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index\n * to query. Must be an index that includes `skosConcept` documents.\n * @param props.embeddingsIndex.fieldReferences - An array of field names from the\n * current document whose values are concatenated and sent as the embeddings search\n * query. All listed fields must contain values when the tree browser is opened;\n * empty fields will display an error message in the tree view rather than scores.\n * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching\n * terms to return from the embeddings index. Defaults to `3`.\n *\n * @example\n * Basic usage with a scheme filter:\n * ```js\n * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'gradeLevel',\n * title: 'Grade Level',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * Branch filter with tree expanded by default:\n * ```js\n * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * Browse-only mode (suppresses the default Sanity search input):\n * ```js\n * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),\n * disableNew: true,\n * },\n * components: {field: ReferenceHierarchyInput},\n * })\n * ```\n *\n * @example\n * AI-assisted recommendations via an embeddings index:\n * ```jsx\n * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'topics',\n * title: 'Topics',\n * type: 'reference',\n * to: [{type: 'skosConcept'}],\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * components: {\n * field: (props) => (\n * <ReferenceHierarchyInput\n * {...props}\n * embeddingsIndex={{\n * indexName: 'my-taxonomy-index',\n * fieldReferences: ['title', 'metaDescription'],\n * maxResults: 4,\n * }}\n * />\n * ),\n * },\n * })\n * ```\n *\n * @see {@link ArrayHierarchyInput} for multi-value `array` fields\n * @see {@link schemeFilter} for filtering by a full concept scheme\n * @see {@link branchFilter} for filtering by a branch within a concept scheme\n */\nexport function ReferenceHierarchyInput(props: HierarchyInput) {\n const client = useClient({apiVersion: 'vX'})\n\n // the resource document in which the input component appears:\n const documentId = useFormValue(['_id']) as string\n\n // name of the field to input a value\n const {name, title, value, embeddingsIndex} = props\n\n const {conceptRecs, recsError, triggerEmbeddingsSearch} = useEmbeddingsRecs(embeddingsIndex)\n\n // Get release and draft status of the document\n const isInRelease = isVersionId(documentId as DocumentId)\n const isDraft = isDraftId(documentId as DocumentId)\n\n // Selected Perspective is also used in the Tree view component. Consider tidying.\n const {selectedPerspectiveName} = usePerspective()\n\n const [schemeLoading, setSchemeLoading] = useState(true)\n const [valuesLoading, setValuesLoading] = useState(true)\n const [open, setOpen] = useState(false)\n\n // the skosConceptScheme document identified by the field filter options:\n const [scheme, setScheme] = useState<ConceptSchemeDocument | undefined>(undefined)\n\n // State to store resolved filter values:\n const [filterValues, setFilterValues] = useState<FilterResult | undefined>()\n\n // use filterValues if available, otherwise fallback to default:\n const {schemeId, branchId = null} = filterValues?.params || {}\n\n const {filter} = props.schemaType.options as ReferenceOptions\n\n // Fetch filter values from `reference` field filter asynchronously.\n useEffect(() => {\n async function fetchFilterValues() {\n try {\n const resolvedFilterValues = await filter({getClient: () => client})\n setFilterValues(resolvedFilterValues)\n // Store the resolved filter values in state\n setValuesLoading(false)\n } catch (error) {\n console.error('Error fetching filter values: ', error)\n }\n }\n fetchFilterValues().catch((error) => console.error('Error fetching filter values: ', error))\n }, [filter, client])\n\n // get the skosConceptScheme document identified by the field filter options\n useEffect(() => {\n if (!schemeId) return\n client\n .fetch('{\"displayed\": *[schemeId == $schemeId][0]}', {schemeId})\n .then((res: {displayed?: ConceptSchemeDocument['displayed']}) => {\n if (res?.displayed) {\n setScheme(res as ConceptSchemeDocument)\n setSchemeLoading(false)\n }\n })\n .catch((err) => console.warn(err))\n }, [client, schemeId])\n\n const browseHierarchy = useCallback(() => {\n setOpen(true)\n triggerEmbeddingsSearch()\n }, [triggerEmbeddingsSearch])\n\n const handleClose = useCallback(() => {\n setOpen(false)\n }, [])\n\n /**\n * #### Term Select Action\n * Writes the selected taxonomy term to the document field\n */\n const handleAction = useCallback(\n (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId?: string\n _strengthenOnPublish?: {type: 'skosConcept'; template: {id: 'skosConcept'}}\n _weak?: boolean\n }) => {\n if (\n isDraftId(conceptId?._originalId as DocumentId) ||\n isVersionId(conceptId?._originalId as DocumentId)\n ) {\n conceptId._strengthenOnPublish = {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n }\n conceptId._weak = true\n }\n\n delete conceptId._originalId\n\n // if there is a draft document, patch the new reference and\n // commit the change\n if (isDraft || isInRelease) {\n client\n .patch(documentId)\n .set({[name]: conceptId})\n .commit()\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n return\n }\n // if there is not a draft document, fetch the published\n // version and create a new document with the published\n // document id in the `drafts.` path and the new reference\n client\n .fetch('*[_id == $id][0]', {id: documentId})\n .then((res: ConceptSchemeDocument) => {\n res._id = `drafts.${res._id}`\n res[name] = conceptId\n client.create(res).catch((error) => console.error('Error creating draft: ', error))\n })\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n },\n [client, documentId, isDraft, isInRelease, name]\n )\n\n // Check to be sure a filter is present\n if (!(props.schemaType.options as ReferenceOptions)?.filter) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n The <code>ReferenceHierarchyInput()</code> component must be used with an accompanying{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code>. Please add an appropriate\n filter to the configuration for the {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // ... and that it is a scheme or branch filter and configured correctly\n else if ((props.schemaType.options as ReferenceOptions)?.filter.length === 0) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading your filter settings. Please check the{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code> configuration for the{' '}\n {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n } else if (schemeLoading || valuesLoading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading input component…\n </Text>\n </Flex>\n </Box>\n )\n }\n const isPublished = selectedPerspectiveName === 'published'\n\n // Render the browse-only preview UI\n const renderBrowseOnlyPreview = () => {\n if (value) {\n return props.renderDefault(props)\n }\n // Wrap the empty state in `FormField` so the field exposes the same\n // DOM target Sanity's Validation panel uses for scroll-to-field /\n // highlight on click. Without this wrapper, clicking a required\n // browse-only field's validation error has no effect.\n return (\n <FormField\n title={title}\n description={props.description}\n level={props.level}\n validation={props.validation}\n __unstable_presence={props.presence}\n >\n <Card padding={3} radius={2} border>\n <Text muted align=\"center\" size={1}>\n No items\n </Text>\n </Card>\n </FormField>\n )\n }\n\n return (\n <Stack space={4}>\n {filterValues?.browseOnly ? renderBrowseOnlyPreview() : props.renderDefault(props)}\n\n <Grid columns={1} gap={3}>\n <Button\n disabled={isPublished}\n icon={NodeTree}\n text=\"Browse taxonomy tree\"\n mode=\"ghost\"\n onClick={browseHierarchy}\n />\n </Grid>\n {open && scheme && (\n <Dialog\n header={title}\n id=\"concept-select-dialog\"\n onClose={handleClose}\n zOffset={900}\n width={1}\n >\n <Box padding={10}>\n <TreeView\n document={scheme}\n branchId={branchId}\n inputComponent\n selectConcept={handleAction}\n expanded={filterValues?.expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n </Box>\n </Dialog>\n )}\n </Stack>\n )\n}\n","/* eslint-disable react/require-default-props */\nimport type {DocumentId} from '@sanity/id-utils'\nimport {\n Grid,\n Stack,\n Button,\n Dialog,\n Box,\n Card,\n Label,\n Text,\n useToast,\n Flex,\n Spinner,\n} from '@sanity/ui'\nimport {useState, useEffect, useCallback} from 'react'\nimport type {ArrayFieldProps, ObjectOptions} from 'sanity'\nimport {FormField, useClient, useFormValue, isVersionId, isDraftId, usePerspective} from 'sanity'\n\nimport {useEmbeddingsRecs} from '../../hooks'\nimport NodeTree from '../../static/NodeTree'\nimport type {ConceptSchemeDocument, EmbeddingsIndexConfig} from '../../types'\nimport {TreeView} from '../TreeView'\n\ntype ReferenceOptions = ObjectOptions & {\n filter: ({getClient}: {getClient: () => ReturnType<typeof useClient>}) => Promise<{\n filter: string\n params: {\n concepts: string[]\n topConcepts?: string[]\n schemeId: string\n branchId?: string\n }\n expanded?: boolean\n browseOnly?: boolean\n }>\n}\n\ntype ArrayHierarchyInputProps = ArrayFieldProps & {\n embeddingsIndex?: EmbeddingsIndexConfig\n}\n\n// Extract the return type of the filter function\ntype FilterResult = Awaited<ReturnType<ReferenceOptions['filter']>>\n\n/**\n * Input component that replaces Sanity's default array field input with a\n * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms\n * organized in their scheme hierarchy and select terms to add to the array field.\n *\n * @remarks\n * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's\n * `options.filter`. Rendering without a filter will display a configuration warning.\n * - Supports only **single-schema arrays** (i.e., `of: [{type: 'reference'}]`). Arrays\n * with multiple schema types will render a warning and fall back to the default input.\n * - Taxonomy selection is disabled when viewing the published perspective.\n * - When `browseOnly` is set in the filter configuration, Sanity's default search input\n * is suppressed and only the tree browser is available for term selection.\n * - When `expanded` is set in the filter configuration, the hierarchy tree loads open\n * by default instead of collapsed.\n *\n * @param props - Standard Sanity `ArrayFieldProps` extended with an optional\n * `embeddingsIndex` configuration object.\n * @param props.embeddingsIndex - Optional configuration for AI-assisted term\n * recommendations via a Sanity Embeddings Index. When provided, opening the tree\n * browser queries the specified index and annotates matching taxonomy terms with\n * a relevance score to help authors identify the most appropriate terms.\n * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index\n * to query. Must be an index that includes `skosConcept` documents.\n * @param props.embeddingsIndex.fieldReferences - An array of field names from the\n * current document whose values are concatenated and sent as the embeddings search\n * query. All listed fields must contain values when the tree browser is opened;\n * empty fields will display an error message in the tree view rather than scores.\n * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching\n * terms to return from the embeddings index. Defaults to `3`.\n *\n * @example\n * Basic usage with a scheme filter:\n * ```js\n * import {ArrayHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'categories',\n * title: 'Categories',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({schemeId: 'f3deba'}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * Branch filter with tree expanded by default:\n * ```js\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'habitats',\n * title: 'Habitats',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * Browse-only mode (suppresses the default Sanity search input):\n * ```js\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'habitats',\n * title: 'Habitats',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {field: ArrayHierarchyInput},\n * })\n * ```\n *\n * @example\n * AI-assisted recommendations via an embeddings index:\n * ```jsx\n * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'\n *\n * defineField({\n * name: 'categories',\n * title: 'Categories',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: [{type: 'skosConcept'}],\n * options: {\n * filter: branchFilter({schemeId: 'f3deba', branchId: '25f826'}),\n * disableNew: true,\n * },\n * },\n * ],\n * components: {\n * field: (props) => (\n * <ArrayHierarchyInput\n * {...props}\n * embeddingsIndex={{\n * indexName: 'my-taxonomy-index',\n * fieldReferences: ['title', 'description'],\n * maxResults: 4,\n * }}\n * />\n * ),\n * },\n * })\n * ```\n *\n * @see {@link ReferenceHierarchyInput} for single-value `reference` fields\n * @see {@link schemeFilter} for filtering by a full concept scheme\n * @see {@link branchFilter} for filtering by a branch within a concept scheme\n */\nexport function ArrayHierarchyInput(props: ArrayHierarchyInputProps) {\n const client = useClient({apiVersion: '2025-02-19'})\n\n // the resource document in which the input component appears:\n const documentId = useFormValue(['_id']) as string\n // name of the field to input a value:\n const {name, title, value = [], embeddingsIndex} = props\n\n // Get release and draft status of the document\n const isInRelease = isVersionId(documentId as DocumentId)\n const isDraft = isDraftId(documentId as DocumentId)\n // Selected Perspective is also used in the Tree view component. Consider tidying.\n const {selectedPerspectiveName} = usePerspective()\n\n const [schemeLoading, setSchemeLoading] = useState(true)\n const [valuesLoading, setValuesLoading] = useState(true)\n const [open, setOpen] = useState(false)\n\n // the skosConceptScheme document identified by the field filter options:\n const [scheme, setScheme] = useState({})\n // State to store resolved filter values:\n const [filterValues, setFilterValues] = useState<FilterResult | undefined>()\n\n // use filterValues if available, otherwise fallback to default:\n const {schemeId, branchId = null} = filterValues?.params || {}\n\n const {filter} = props.schemaType.of[0].options as ReferenceOptions\n\n const {conceptRecs, recsError, triggerEmbeddingsSearch} = useEmbeddingsRecs(embeddingsIndex)\n\n const toast = useToast()\n\n // Fetch filter values from `reference` field filter asynchronously\n useEffect(() => {\n async function fetchFilterValues() {\n try {\n const resolvedFilterValues = await filter({getClient: () => client})\n setFilterValues(resolvedFilterValues)\n // Store the resolved filter values in state\n setValuesLoading(false)\n } catch (error) {\n console.error('Error fetching filter values: ', error)\n }\n }\n fetchFilterValues().catch((error) => console.error('Error fetching filter values: ', error))\n }, [filter, client])\n\n // get the skosConceptScheme document identified by the field filter options\n useEffect(() => {\n if (!schemeId) return\n client\n .fetch(`{\"displayed\": *[schemeId == \"${schemeId}\"][0]}`)\n .then((res: {displayed?: ConceptSchemeDocument['displayed']}) => {\n if (res?.displayed) {\n setScheme(res)\n setSchemeLoading(false)\n }\n })\n .catch((err) => console.warn(err))\n }, [client, schemeId])\n\n const browseHierarchy = useCallback(() => {\n setOpen(true)\n triggerEmbeddingsSearch()\n }, [triggerEmbeddingsSearch])\n\n const handleClose = useCallback(() => {\n setOpen(false)\n }, [])\n\n /**\n * #### Term Select Action\n * Writes the selected taxonomy term to the array field\n */\n const handleAction = useCallback(\n (conceptId: {\n _ref: string\n _type: 'reference'\n _originalId?: string\n _strengthenOnPublish?: {type: 'skosConcept'; template: {id: 'skosConcept'}}\n _weak?: boolean\n }) => {\n if (\n isDraftId(conceptId?._originalId as string) ||\n isVersionId(conceptId?._originalId as string)\n ) {\n conceptId._strengthenOnPublish = {\n type: 'skosConcept',\n template: {id: 'skosConcept'},\n }\n conceptId._weak = true\n }\n\n delete conceptId._originalId\n\n // If the ref of the selected term is already in the field close the dialog\n // and provide a toast message that tht entry is already in the field.\n const typedValue = value as Array<{_key: string; _ref: string}> | undefined\n if (typedValue?.map((item) => item._ref).includes(conceptId._ref)) {\n setOpen(false)\n toast.push({\n status: 'warning',\n title: 'Taxonomy Term Not Added',\n description: 'The selected concept is already included in this field.',\n duration: 5000,\n closable: true,\n })\n return\n }\n // if there is a draft document, patch the new reference and\n // commit the change\n if (isDraft || isInRelease) {\n client\n .patch(documentId)\n .setIfMissing({[name]: []})\n .append(name, [conceptId])\n .commit({autoGenerateArrayKeys: true})\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n return\n }\n // if there is not a draft document, fetch the published\n // version and create a new document with the published\n // document id in the `drafts.` path and the new reference\n client\n .fetch(`*[_id == \"${documentId}\"][0]`)\n .then((res: ConceptSchemeDocument) => {\n res._id = `drafts.${res._id}`\n client.create(res).catch((error) => console.error('Error creating draft: ', error))\n })\n .then(() => {\n client\n .patch(`drafts.${documentId}`)\n .setIfMissing({[name]: []})\n .append(name, [conceptId])\n .commit({autoGenerateArrayKeys: true})\n .then(() => setOpen(false))\n .catch((err) => console.error(err))\n })\n .catch((err) => console.error(err))\n },\n [value, isDraft, isInRelease, client, documentId, toast, name]\n )\n\n // Check to be sure a filter is present\n if (!(props.schemaType.of[0].options as ReferenceOptions)?.filter) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n The <code>ArrayHierarchyInput()</code> component must be used with an accompanying{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code>. Please add an appropriate\n filter to the configuration for the {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // ... and that it is a scheme or branch filter and configured correctly\n else if ((props.schemaType.of[0].options as ReferenceOptions)?.filter?.length === 0) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Box padding={4}>\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n There was a problem loading your filter settings. Please check the{' '}\n <code>schemeFilter()</code> or <code>branchFilter()</code> configuration for the{' '}\n {title} field.\n </Text>\n </Card>\n </Box>\n </Stack>\n )\n }\n // Check to see if array uses more than one schema and bail with a notification if more than one is detected.\n else if (props.schemaType.of.length > 1) {\n return (\n <Stack space={3}>\n {props.renderDefault(props)}\n <Card padding={[3]} radius={2} shadow={1} tone=\"caution\">\n <Stack space={4}>\n <Stack space={2}>\n <Label size={2}>Input Component Not Supported for Multi-Schema Arrays</Label>\n <Text size={1}>\n The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support\n array inputs with more than one schema type. Please see the{' '}\n <a href=\"https://sanitytaxonomymanager.com\">Taxonomy Manager docs</a> for more\n information.\n </Text>\n </Stack>\n </Stack>\n </Card>\n </Stack>\n )\n } else if (schemeLoading || valuesLoading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading input component…\n </Text>\n </Flex>\n </Box>\n )\n }\n\n const isPublished = selectedPerspectiveName === 'published'\n\n // Render the browse-only preview UI for arrays\n const renderBrowseOnlyPreview = () => {\n if (value.length > 0) {\n return props.renderDefault(props)\n }\n\n // Wrap the empty state in `FormField` so the field exposes the same\n // DOM target Sanity's Validation panel uses for scroll-to-field /\n // highlight on click. Without this wrapper, clicking a required\n // browse-only field's validation error has no effect.\n return (\n <FormField\n title={title}\n description={props.description}\n level={props.level}\n validation={props.validation}\n __unstable_presence={props.presence}\n >\n <Card padding={3} radius={2} border>\n <Text muted align=\"center\" size={1}>\n No items\n </Text>\n </Card>\n </FormField>\n )\n }\n\n return (\n <Stack space={3}>\n {filterValues?.browseOnly ? renderBrowseOnlyPreview() : props.renderDefault(props)}\n\n <Grid columns={1} gap={3}>\n <Button\n disabled={isPublished}\n icon={NodeTree}\n text=\"Browse taxonomy tree\"\n mode=\"ghost\"\n onClick={browseHierarchy}\n />\n </Grid>\n {open && (\n <Dialog\n header={title}\n id=\"concept-select-dialog\"\n onClose={handleClose}\n zOffset={900}\n width={1}\n >\n <Box>\n <TreeView\n document={scheme as ConceptSchemeDocument}\n branchId={branchId}\n inputComponent\n selectConcept={handleAction}\n expanded={filterValues?.expanded}\n conceptRecs={conceptRecs}\n recsError={recsError}\n />\n </Box>\n </Dialog>\n )}\n </Stack>\n )\n}\n","import {Button, Inline, Stack, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {unset} from 'sanity'\n\n/**\n * #### Input Component for Deprecated Management Controls Field\n * The Management Controls field was used for a previous version\n * of the plugin and was set by default when creating a new scheme.\n * It has been set to \"Deprecated.\" This control will allow users\n * to delete the value from the input to hide the field, without\n * otherwise seeing an error int their schema.\n * - Input is only visible if no identifier has been assigned\n * - Input disappears once an ID is generated\n */\nexport const ManagementControls = (props: any) => {\n const {onChange} = props\n const toast = useToast()\n\n const handleChange = useCallback(() => {\n onChange(unset())\n toast.push({\n status: 'success',\n title: 'Value removed.',\n duration: 2500,\n closable: true,\n })\n }, [onChange, toast])\n\n return (\n <Stack space={2}>\n <Inline space={[3, 3, 4]}>\n {props.renderDefault(props)}\n <Button tone=\"primary\" fontSize={2} onClick={handleChange} text=\"Remove Value\" />\n </Inline>\n </Stack>\n )\n}\n","import type {useClient} from 'sanity'\n\ntype SchemeOptions = {\n schemeId: string\n expanded?: boolean\n browseOnly?: boolean\n}\n\ntype SchemeFilterResult = {\n filter: string\n params: {\n schemeId: string\n concepts: string[]\n topConcepts: string[]\n }\n expanded?: boolean\n browseOnly?: boolean\n}\n\n/**\n * #### Reference Field Scheme Filter\n * Pluggable Function for Filtering to a Single SKOS Concept Scheme.\n * @param {string} schemeId - The unique six character concept identifier for\n * the Concept Scheme to which you wish to filter.\n * @param {boolean} [expanded] - Set to `true` to display open hierarchy trees for\n * input components. Input component trees load closed by default.\n * @param {boolean} [browseOnly] - Set to `true` to hide the default Sanity search\n * input and display only the \"Browse Taxonomy Tree\" button for selecting terms.\n * @returns A reference type filter for Concepts and Top Concepts in\n * the selected Concept Scheme test\n * @example\n * ```ts\n * import { schemeFilter } from 'sanity-plugin-taxonomy-manager'\n * ...\n * {\n * name: 'test',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: schemeFilter({\n * schemeId: 'a1b2c3',\n * expanded: true, // optional; defaults to false (closed tree)\n * browseOnly: true, // optional; hides search input\n * }),\n * disableNew: true,\n * },\n * },\n * ],\n * }\n * ```\n */\nexport const schemeFilter = (\n options: SchemeOptions\n): (({\n getClient,\n}: {\n getClient: (clientOptions: {apiVersion: string}) => ReturnType<typeof useClient>\n}) => Promise<SchemeFilterResult>) => {\n // Get and validate the schemeId from options\n const {schemeId} = options || {}\n\n if (!schemeId || typeof schemeId !== 'string') {\n throw new Error('Invalid or missing schemeId: scheme Id must be a string')\n }\n\n return async (props) => {\n const client = props?.getClient({apiVersion: '2025-02-19'})\n if (!client) {\n throw new Error('Client not available')\n }\n // Fetch concepts and topConcepts for the given schemeId\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion\n const {concepts, topConcepts} = (await client.fetch(\n `{\n \"concepts\": *[_type==\"skosConceptScheme\" && schemeId == \"${schemeId}\"].concepts[]._ref,\n \"topConcepts\": *[_type==\"skosConceptScheme\" && schemeId == \"${schemeId}\"].topConcepts[]._ref\n }`\n )) as {concepts: string[]; topConcepts: string[]}\n // schemeId is included in params for use by the ArrayHierarchyInput component\n return {\n filter: `(_id in $concepts\n || _id in $topConcepts)`,\n params: {concepts, topConcepts, schemeId},\n expanded: options?.expanded,\n browseOnly: options?.browseOnly,\n }\n }\n}\n","import type {useClient} from 'sanity'\n\ntype BranchOptions = {\n schemeId: string\n branchId: string\n expanded?: boolean\n browseOnly?: boolean\n}\n\ntype BranchFilterResult = {\n filter: string\n params: {\n schemeId: string\n branchId: string\n concepts: string[]\n }\n expanded?: boolean\n browseOnly?: boolean\n}\n\n/**\n * #### Reference Field Scheme & Branch Filter\n * A pluggable Function for Filtering to a Top Concept Branch within a SKOS Concept Scheme\n * @param {string} schemeId - The unique six character concept identifier for\n * the Concept Scheme to which you wish to filter.\n * @param {string} branchId - The unique six character concept identifier of\n * a branch. Child concepts will be returned.\n * @param {boolean} [expanded] - Set to `true` to display open hierarchy trees for\n * input components. Input component trees load closed by default.\n * @param {boolean} [browseOnly] - Set to `true` to hide the default Sanity search\n * input and display only the \"Browse Taxonomy Tree\" button for selecting terms.\n * @returns A reference type filter for the child concepts of the designated branch in the selected Concept Scheme\n * @example\n * ```ts\n * import { branchFilter } from 'sanity-plugin-taxonomy-manager'\n * ...\n * {\n * name: 'test',\n * type: 'array',\n * of: [\n * {\n * type: 'reference',\n * to: {type: 'skosConcept'},\n * options: {\n * filter: branchFilter({\n * schemeId: 'a1b2c3',\n * branchId: 'd4e5f6',\n * expanded: true, // optional; defaults to false (closed tree)\n * browseOnly: true, // optional; hides search input\n * }),\n * disableNew: true,\n * },\n * },\n * ],\n * }\n * ```\n */\nexport const branchFilter = (\n options: BranchOptions\n): (({\n getClient,\n}: {\n getClient: (clientOptions: {apiVersion: string}) => ReturnType<typeof useClient>\n}) => Promise<BranchFilterResult>) => {\n const {schemeId, branchId = null} = options || {}\n\n if (!schemeId || typeof schemeId !== 'string') {\n throw new Error('Invalid or missing schemeId: scheme Id must be a string')\n }\n\n if (!branchId || typeof branchId !== 'string') {\n throw new Error('Invalid or missing branchId: branch Id must be a string')\n }\n\n return async (props) => {\n const client = props?.getClient({apiVersion: '2023-01-01'})\n if (!client) {\n throw new Error('Client not available')\n }\n\n // Fetch concepts for the given schemeId and branchId\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion\n const {concepts} = (await client.fetch(\n `{ \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 }`,\n {schemeId, branchId}\n )) as {concepts: string[]}\n // schemeId is included in params for use by the ArrayHierarchyInput component\n return {\n filter: `_id in $concepts`,\n params: {concepts, schemeId, branchId},\n expanded: options?.expanded,\n browseOnly: options?.browseOnly,\n }\n }\n}\n","import {defineField} from 'sanity'\n\nimport {RdfUri} from '../components/inputs'\n\nimport styles from './baseIriField.module.css'\n\n/**\n * #### Base Universal Resource Identifier object for Sanity Taxonomy Manager\n * Used for Concept and Concept Scheme URI fields\n */\nexport default [\n defineField({\n name: 'baseIri',\n title: 'Base URI',\n type: 'url',\n validation: (Rule) =>\n Rule.required().error(`Please supply a base URI in the format 'http://example.com/'`),\n description: (\n <details className={styles.description}>\n <summary>\n The root URI (Uniform Resource Identifier) used to create unique concept identifiers.\n </summary>\n <div>\n Unique identifiers allow for the clear an unambiguous identification of concepts across\n namespaces, for example between <code>https://shipparts.com/vocab#Bow</code> and {}\n <code>https://wrappingsupplies.com/vocab#Bow</code>.\n </div>\n <div>\n In most cases, it makes sense for your base URI to be the root or a subdirectory of your\n website. In all cases, the URI you choose should be in a domain that you control.\n </div>\n <div>\n For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the\n most recently used Base URI value.\n </div>\n </details>\n ),\n components: {\n input: RdfUri as any,\n },\n }),\n]\n","import {Stack, Text} from '@sanity/ui'\nimport {useFormValue} from 'sanity'\nimport type {StringInputProps} from 'sanity'\n\n/**\n * #### SKOS Concept Base URI input component\n * Used for Concept and Concept Scheme URI preview\n */\nexport function RdfUri(props: StringInputProps) {\n const conceptId = useFormValue(['conceptId'])\n const schemeId = useFormValue(['schemeId'])\n return (\n <Stack space={2}>\n {props.renderDefault(props)}\n <Text muted size={1}>\n <>\n <strong>RDF URI: </strong>\n {props.value ? props.value : '[base URI not defined] '}\n {conceptId || schemeId || ' [identifier not assigned]'}\n </>\n </Text>\n </Stack>\n )\n}\n","import {WarningOutlineIcon} from '@sanity/icons'\nimport {DocumentId, getPublishedId} from '@sanity/id-utils'\nimport {AiOutlineTag, AiOutlineTags} from 'react-icons/ai'\nimport {defineType, defineField} from 'sanity'\nimport type {SanityDocument} from 'sanity'\n\nimport {Identifier} from './components/inputs'\nimport baseIriField from './helpers/baseIriField'\nimport {createId} from './helpers/createId'\nimport styles from './skosConcept.module.css'\nimport type {Options} from './types'\n\nconst conceptFilter = ({document}: {document: SanityDocument}) => {\n const publishedId = getPublishedId(DocumentId(document._id))\n return {\n filter: '!(_id in $broader || _id in $related || _id == $self)',\n params: {\n self: publishedId,\n broader: Array.isArray(document?.broader)\n ? document.broader.map(({_ref}: {_ref: string}) => _ref)\n : [],\n related: Array.isArray(document?.related)\n ? document.related.map(({_ref}: {_ref: string}) => _ref)\n : [],\n },\n }\n}\n\n/**\n * Sanity document scheme for SKOS Taxonomy Concepts\n */\nexport default function skosConcept(\n baseUri?: Options['baseUri'],\n customConceptFields: Options['customConceptFields'] = [],\n ident?: Options['ident']\n) {\n return defineType({\n name: 'skosConcept',\n title: 'Concept',\n type: 'document',\n icon: AiOutlineTags,\n initialValue: async (_, context) => {\n if (baseUri)\n return {\n baseIri: baseUri,\n broader: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n related: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n }\n\n const {getClient} = context\n const client = getClient({apiVersion: '2021-03-25'})\n const baseIri =\n (await client.fetch<string | null>(`\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n `)) ?? undefined\n return {\n baseIri: baseIri,\n broader: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n related: [], // an empty array is needed here in order to return concepts with no \"broader\" for \"related\"\n }\n },\n fields: [\n defineField({\n name: 'prefLabel',\n title: 'Preferred Label',\n type: 'string',\n description: 'The preferred lexical label for this concept.',\n validation: (Rule) =>\n Rule.required().custom((prefLabel, context) => {\n const {getClient} = context\n const client = getClient({apiVersion: '2025-06-10'}).withConfig({perspective: 'raw'})\n return client\n .fetch(\n `*[_type == \"skosConcept\" && prefLabel == \"${\n prefLabel as string\n }\" && !(_id in path(\"drafts.**\") || _id in path(\"versions.**\"))][0]._id`\n )\n .then((conceptId) => {\n if (conceptId && !context.document?._id.includes(conceptId as string)) {\n return 'Preferred Label must be unique.'\n }\n return true\n })\n }),\n }),\n defineField({\n name: 'definition',\n title: 'Definition',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>A complete explanation of the intended meaning of the concept.</summary>\n <div>\n <kbd>\n Example: documentation\n <br />\n Definition: \"The process of storing and retrieving information in all fields of\n knowledge.\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'example',\n title: 'Examples',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>An example of the use of the concept.</summary>\n <div>\n <kbd>\n Example: organizations of science and culture\n <br />\n Example: \"academies of science, general museums, world fairs\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'scopeNote',\n title: 'Scope Note',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n A brief statement on the intended meaning of this concept, especially as an indication\n of how the use of the concept is limited in indexing practice.\n </summary>\n <div>\n <kbd>\n Example: microwave frequencies\n <br />\n Scope Note: \"Used for frequencies between 1Ghz and 300Ghz\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'altLabel',\n title: 'Alternate Label(s)',\n type: 'array',\n description: (\n <details className={styles.description}>\n <summary>Synonyms, near-synonyms, abbreviations, and acronyms to a concept.</summary>\n <div>\n <p>\n <WarningOutlineIcon /> Preferred, alternative, and hidden label sets must not\n overlap.\n </p>\n </div>\n </details>\n ),\n of: [{type: 'string'}],\n validation: (Rule) => Rule.unique(),\n }),\n defineField({\n name: 'hiddenLabel',\n title: 'Hidden Label(s)',\n type: 'array',\n description: (\n <details className={styles.description}>\n <summary>\n Character strings that need to be accessible to applications performing text-based\n indexing and search operations, but which should not be displayed to end users.\n </summary>\n <div>\n <p>\n Hidden labels may for instance be used to include misspelled variants of other\n lexical labels.\n </p>\n <p>\n <WarningOutlineIcon /> Preferred, alternative, and hidden label sets must not\n overlap.\n </p>\n </div>\n </details>\n ),\n of: [{type: 'string'}],\n validation: (Rule) => Rule.unique(),\n }),\n ...baseIriField,\n defineField({\n name: 'conceptId',\n title: 'Identifier',\n description:\n \"Generate or re-generate the identifier for this concept according to parameters set in Taxonomy Manager plugin options. Note that this changes the concept's URI, which is not advisable if the concept is already in use in production. Use with caution.\",\n type: 'string',\n initialValue: createId(ident),\n hidden: ({document}) => !!document?.conceptId && !ident?.regenUi,\n readOnly: ({document}) => !!document?.conceptId,\n components: {\n input: (props) => <Identifier {...props} ident={ident} />,\n },\n }),\n defineField({\n name: 'broader',\n title: 'Broader Concept(s)',\n description: (\n <details className={styles.description}>\n <summary>\n Create hierarchy between concepts, for example to create category/subcategory,\n part/whole, or class/instance relationships.\n </summary>\n <div>\n <p>Broader and Associated relationships are mutually exclusive.</p>\n </div>\n </details>\n ),\n type: 'array',\n of: [\n {\n type: 'reference',\n to: {type: 'skosConcept'},\n options: {\n filter: conceptFilter,\n },\n },\n ],\n }),\n defineField({\n name: 'related',\n title: 'Related Concept(s)',\n description: (\n <details className={styles.description}>\n <summary>\n Indicate that two concepts are inherently \"related\", but that one is not in any way\n more general than the other.\n </summary>\n <div>\n <p>Broader and Associated relationships are mutually exclusive.</p>\n </div>\n </details>\n ),\n type: 'array',\n of: [\n {\n type: 'reference',\n to: [{type: 'skosConcept'}],\n options: {\n filter: conceptFilter,\n },\n },\n ],\n }),\n ...customConceptFields,\n defineField({\n name: 'historyNote',\n title: 'History Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>Significant changes to the meaning or the form of this concept.</summary>\n <div>\n <kbd>\n Example: person with disabilities\n <br />\n History Note: \"Estab. 1992; heading was: handicapped [1884 - 1992].\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'editorialNote',\n title: 'Editorial Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n Information to aid in administrative housekeeping, such as reminders of editorial work\n still to be done, or warnings in the event that future editorial changes might be\n made.\n </summary>\n <div>\n <kbd>\n Example: doubleclick\n <br />\n Editorial Note: \"Review this term after the company merger is complete.\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n defineField({\n name: 'changeNote',\n title: 'Change Notes',\n type: 'text',\n description: (\n <details className={styles.description}>\n <summary>\n Fine-grained changes to a concept, for the purposes of administration and maintenance.\n </summary>\n <div>\n <kbd>\n Example: tomato\n <br />\n Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\"\n </kbd>\n <p>\n For more information on the recommended usage of the SKOS documentation properties,\n see\n <a\n href=\"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation\"\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {' '}\n W3C SKOS Primer: 2.4 Documentary Notes\n </a>\n </p>\n </div>\n </details>\n ),\n rows: 3,\n }),\n ],\n orderings: [\n {\n title: 'Top Concepts',\n name: 'topConcept',\n by: [\n {field: 'topConcept', direction: 'desc'},\n {field: 'prefLabel', direction: 'asc'},\n ],\n },\n {\n title: 'Preferred Label',\n name: 'prefLabel',\n by: [{field: 'prefLabel', direction: 'asc'}],\n },\n ],\n preview: {\n select: {\n title: 'prefLabel',\n },\n prepare({title}: {title: string}) {\n return {\n title: title,\n media: AiOutlineTag,\n }\n },\n },\n })\n}\n","// import {nanoid} from 'nanoid'\n// import type {FieldDefinition} from 'sanity'\nimport {defineArrayMember, defineField, defineType} from 'sanity'\n\nimport {Identifier, ManagementControls} from './components/inputs'\nimport baseIriField from './helpers/baseIriField'\nimport {createId} from './helpers/createId'\nimport NodeTree from './static/NodeTree'\nimport type {Options} from './types'\n\n/**\n * Sanity document scheme for SKOS Concept Schemes\n */\nexport default function skosConceptScheme(\n baseUri?: Options['baseUri'],\n customSchemeFields: Options['customSchemeFields'] = [],\n ident?: Options['ident']\n) {\n return defineType({\n name: 'skosConceptScheme',\n title: 'Concept Scheme',\n type: 'document',\n icon: NodeTree,\n initialValue: async (_, context) => {\n if (baseUri) return {baseIri: baseUri}\n const {getClient} = context\n const client = getClient({apiVersion: '2021-03-25'})\n const baseIri =\n (await client.fetch<string | null>(`\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n `)) ?? undefined\n return {\n baseIri: baseIri,\n }\n },\n fields: [\n defineField({\n name: 'title',\n title: 'Title',\n type: 'string',\n description:\n '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',\n }),\n defineField({\n name: 'description',\n title: 'Description',\n type: 'text',\n rows: 5,\n description: 'Describe the intended use of this scheme.',\n }),\n defineField({\n name: 'controls',\n title: 'Concept Management Controls',\n deprecated: {\n reason:\n 'This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field.',\n },\n type: 'boolean',\n readOnly: true,\n hidden: ({document}) => document?.controls === undefined,\n components: {\n input: ManagementControls,\n },\n }),\n ...baseIriField,\n defineField({\n name: 'schemeId',\n title: 'Identifier',\n description:\n \"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.\",\n type: 'string',\n initialValue: createId(ident),\n hidden: ({document}) => !!document?.schemeId && !ident?.regenUi,\n readOnly: ({document}) => !!document?.schemeId,\n components: {\n input: (props) => <Identifier {...props} ident={ident} />,\n },\n }),\n defineField({\n name: 'topConcepts',\n title: 'Top Concepts',\n type: 'array',\n validation: (Rule) => Rule.unique(),\n of: [\n defineArrayMember({\n type: 'reference',\n to: [{type: 'skosConcept'}],\n }),\n ],\n options: {\n sortable: false,\n },\n }),\n defineField({\n name: 'concepts',\n title: 'Concepts',\n type: 'array',\n validation: (Rule) => Rule.unique(),\n of: [\n defineArrayMember({\n type: 'reference',\n to: [{type: 'skosConcept'}],\n }),\n ],\n options: {\n sortable: false,\n },\n }),\n ...customSchemeFields,\n ],\n preview: {\n select: {\n title: 'title',\n },\n prepare({title}: {title: string}) {\n return {\n title: title,\n media: NodeTree,\n }\n },\n },\n })\n}\n","function isObject(obj) {\n return typeof obj == \"object\" && obj !== null && !Array.isArray(obj);\n}\nfunction isReference(reference) {\n return isObject(reference) && typeof reference._ref == \"string\";\n}\nfunction isImage(value) {\n return isObject(value) && isReference(value.asset) && value.asset._ref.startsWith(\"image-\");\n}\nfunction isCrossDatasetReference(reference) {\n return isObject(reference) && typeof reference._ref == \"string\" && typeof reference._dataset == \"string\" && typeof reference._projectId == \"string\";\n}\nfunction isSanityDocument(document) {\n return isObject(document) && typeof document._id == \"string\" && typeof document._type == \"string\";\n}\nfunction isTypedObject(obj) {\n return isObject(obj) && typeof obj._type == \"string\";\n}\nfunction isKeyedObject(obj) {\n return isObject(obj) && typeof obj._key == \"string\";\n}\nfunction isGlobalDocumentReference(reference) {\n return !isObject(reference) || typeof reference._ref != \"string\" ? !1 : reference._ref.split(\":\").length === 3;\n}\nfunction isValidationErrorMarker(marker) {\n return marker.level === \"error\";\n}\nfunction isValidationWarningMarker(marker) {\n return marker.level === \"warning\";\n}\nfunction isValidationInfoMarker(marker) {\n return marker.level === \"info\";\n}\nconst MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME = \"sanity.asset.aspect\";\nfunction isAssetAspect(maybeAssetAspect) {\n return typeof maybeAssetAspect == \"object\" && maybeAssetAspect !== null && \"_type\" in maybeAssetAspect && maybeAssetAspect._type === MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME;\n}\nfunction defineAssetAspect(definition) {\n const { assetType, name } = definition;\n return {\n _type: MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME,\n _id: `${name}`,\n definition,\n ...assetType && {\n assetType: Array.isArray(assetType) ? assetType : [assetType]\n },\n public: definition.public\n };\n}\nfunction isCreateMutation(mutation) {\n return \"create\" in mutation;\n}\nfunction isCreateIfNotExistsMutation(mutation) {\n return \"createIfNotExists\" in mutation;\n}\nfunction isCreateOrReplaceMutation(mutation) {\n return \"createOrReplace\" in mutation;\n}\nfunction isDeleteMutation(mutation) {\n return \"delete\" in mutation;\n}\nfunction isPatchMutation(mutation) {\n return \"patch\" in mutation;\n}\nconst reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, reIndexTuple = /^\\d*:\\d*$/;\nfunction isIndexSegment(segment) {\n return typeof segment == \"number\" || typeof segment == \"string\" && /^\\[\\d+\\]$/.test(segment);\n}\nfunction isKeySegment(segment) {\n return typeof segment == \"string\" ? reKeySegment.test(segment.trim()) : typeof segment == \"object\" && \"_key\" in segment;\n}\nfunction isIndexTuple(segment) {\n if (typeof segment == \"string\" && reIndexTuple.test(segment))\n return !0;\n if (!Array.isArray(segment) || segment.length !== 2)\n return !1;\n const [from, to] = segment;\n return (typeof from == \"number\" || from === \"\") && (typeof to == \"number\" || to === \"\");\n}\nfunction isRecord$1(value) {\n return !!value && (typeof value == \"object\" || typeof value == \"function\");\n}\nfunction isPortableTextTextBlock(value) {\n return isRecord$1(value) && typeof value._type == \"string\" && // block types can be named, so expect anything here.\n Array.isArray(value.children) && value.children.every((child) => isRecord$1(child)) && (\"markDefs\" in value ? Array.isArray(value.markDefs) && value.markDefs.every((def) => isRecord$1(def)) : !0) && (\"style\" in value ? typeof value.style == \"string\" : !0);\n}\nfunction isPortableTextSpan(value) {\n return isRecord$1(value) && value._type === \"span\" && typeof value.text == \"string\" && (\"marks\" in value ? Array.isArray(value.marks) && value.marks.every((mark) => typeof mark == \"string\") : !0);\n}\nfunction isPortableTextListBlock(value) {\n return isPortableTextTextBlock(value) && \"listItem\" in value && typeof value.listItem == \"string\" && \"level\" in value && Number.isInteger(value.level);\n}\nfunction isRecord(value) {\n return !!value && (typeof value == \"object\" || typeof value == \"function\");\n}\nfunction isDocumentSchemaType(type) {\n if (!isObjectSchemaType(type))\n return !1;\n let current = type;\n for (; current; ) {\n if (current.name === \"document\")\n return !0;\n current = current.type;\n }\n return !1;\n}\nfunction isObjectSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"object\" : !1;\n}\nfunction isArraySchemaType(type) {\n return isRecord(type) ? type.jsonType === \"array\" : !1;\n}\nfunction isArrayOfBlocksSchemaType(type) {\n return isArraySchemaType(type) && type.of.some((memberType) => isBlockSchemaType(memberType));\n}\nfunction isArrayOfObjectsSchemaType(type) {\n return isArraySchemaType(type) && type.of.every((memberType) => isObjectSchemaType(memberType));\n}\nfunction isArrayOfPrimitivesSchemaType(type) {\n return isArraySchemaType(type) && type.of.every((memberType) => isPrimitiveSchemaType(memberType));\n}\nfunction isBooleanSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"boolean\" : !1;\n}\nfunction isStringSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"string\" : !1;\n}\nfunction isDateTimeSchemaType(type) {\n return isStringSchemaType(type) ? type.name === \"datetime\" : !1;\n}\nfunction isNumberSchemaType(type) {\n return isRecord(type) ? type.jsonType === \"number\" : !1;\n}\nfunction isPrimitiveSchemaType(type) {\n return isBooleanSchemaType(type) || isStringSchemaType(type) || isNumberSchemaType(type);\n}\nfunction isReferenceSchemaType(type) {\n return isRecord(type) && (type.name === \"reference\" || isReferenceSchemaType(type.type));\n}\nfunction isImageSchemaType(type) {\n return isRecord(type) && (type.name === \"image\" || isImageSchemaType(type.type));\n}\nfunction isFileSchemaType(type) {\n return isRecord(type) && (type.name === \"file\" || isFileSchemaType(type.type));\n}\nfunction isDeprecatedSchemaType(type) {\n return isRecord(type) ? typeof type.deprecated < \"u\" : !1;\n}\nfunction isDeprecationConfiguration(type) {\n return isRecord(type) ? typeof type.deprecated < \"u\" : !1;\n}\nfunction isCrossDatasetReferenceSchemaType(type) {\n return isRecord(type) && (type.name === \"crossDatasetReference\" || isCrossDatasetReferenceSchemaType(type.type));\n}\nfunction isTitledListValue(item) {\n return typeof item == \"object\" && item !== null && \"title\" in item && \"value\" in item;\n}\nfunction isSpanSchemaType(type) {\n return isRecord(type) ? Array.isArray(type.annotations) && Array.isArray(type.decorators) : !1;\n}\nfunction isBlockSchemaType(type) {\n if (!isRecord(type) || !Array.isArray(type.fields)) return !1;\n const maybeSpanChildren = type.fields.find(isBlockChildrenObjectField), maybeStyle = type.fields.find(isBlockStyleObjectField), maybeList = type.fields.find(isBlockListObjectField);\n return isBlockChildrenObjectField(maybeSpanChildren) && isBlockStyleObjectField(maybeStyle) && isBlockListObjectField(maybeList);\n}\nfunction isBlockStyleObjectField(field) {\n return !isRecord(field) || field.name !== \"style\" ? !1 : isRecord(field.type) && field.type.jsonType === \"string\";\n}\nfunction isBlockListObjectField(field) {\n return !isRecord(field) || field.name !== \"listItem\" ? !1 : isRecord(field.type) && field.type.jsonType === \"string\";\n}\nfunction isBlockChildrenObjectField(field) {\n return !isRecord(field) || field.name !== \"children\" || !isArraySchemaType(field.type) ? !1 : field.type.of.some(isSpanSchemaType);\n}\nfunction defineType(schemaDefinition, defineOptions) {\n return schemaDefinition;\n}\nfunction defineField(schemaField, defineOptions) {\n return schemaField;\n}\nfunction defineArrayMember(arrayOfSchema, defineOptions) {\n return arrayOfSchema;\n}\nfunction typed(input) {\n return input;\n}\nconst searchStrategies = [\"groqLegacy\", \"groq2024\"];\nfunction isSearchStrategy(maybeSearchStrategy) {\n return searchStrategies.includes(maybeSearchStrategy);\n}\nfunction isSlug(thing) {\n return isObject(thing) && typeof thing.current == \"string\";\n}\nfunction isCreateSquashedMutation(mutation) {\n return \"createSquashed\" in mutation;\n}\nfunction isValidationError(node) {\n return node.level === \"error\";\n}\nfunction isValidationWarning(node) {\n return node.level === \"warning\";\n}\nfunction isValidationInfo(node) {\n return node.level === \"info\";\n}\nexport {\n MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME,\n defineArrayMember,\n defineAssetAspect,\n defineField,\n defineType,\n isArrayOfBlocksSchemaType,\n isArrayOfObjectsSchemaType,\n isArrayOfPrimitivesSchemaType,\n isArraySchemaType,\n isAssetAspect,\n isBlockChildrenObjectField,\n isBlockListObjectField,\n isBlockSchemaType,\n isBlockStyleObjectField,\n isBooleanSchemaType,\n isCreateIfNotExistsMutation,\n isCreateMutation,\n isCreateOrReplaceMutation,\n isCreateSquashedMutation,\n isCrossDatasetReference,\n isCrossDatasetReferenceSchemaType,\n isDateTimeSchemaType,\n isDeleteMutation,\n isDeprecatedSchemaType,\n isDeprecationConfiguration,\n isDocumentSchemaType,\n isFileSchemaType,\n isGlobalDocumentReference,\n isImage,\n isImageSchemaType,\n isIndexSegment,\n isIndexTuple,\n isKeySegment,\n isKeyedObject,\n isNumberSchemaType,\n isObjectSchemaType,\n isPatchMutation,\n isPortableTextListBlock,\n isPortableTextSpan,\n isPortableTextTextBlock,\n isPrimitiveSchemaType,\n isReference,\n isReferenceSchemaType,\n isSanityDocument,\n isSearchStrategy,\n isSlug,\n isSpanSchemaType,\n isStringSchemaType,\n isTitledListValue,\n isTypedObject,\n isValidationError,\n isValidationErrorMarker,\n isValidationInfo,\n isValidationInfoMarker,\n isValidationWarning,\n isValidationWarningMarker,\n searchStrategies,\n typed\n};\n//# sourceMappingURL=index.mjs.map\n","import { isIndexSegment, isKeySegment, isIndexTuple } from \"@sanity/types\";\nconst rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g, reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, EMPTY_PATH = [], FOCUS_TERMINATOR = \"$\", GROQ_DATA_TYPE_VALUES = [\"true\", \"false\", \"null\"];\nfunction get(obj, path, defaultVal) {\n const select = typeof path == \"string\" ? fromString(path) : path;\n if (!Array.isArray(select))\n throw new Error(\"Path must be an array or a string\");\n let acc = obj;\n for (let i = 0; i < select.length; i++) {\n const segment = select[i];\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc[segment];\n }\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc.find((item) => item._key === segment._key);\n }\n if (typeof segment == \"string\" && (acc = typeof acc == \"object\" && acc !== null ? acc[segment] : void 0), typeof acc > \"u\")\n return defaultVal;\n }\n return acc;\n}\nconst pathsMemo = /* @__PURE__ */ new Map();\nfunction pathFor(path) {\n if (path.length === 0)\n return EMPTY_PATH;\n const asString = toString(path);\n return pathsMemo.has(asString) ? pathsMemo.get(asString) : (pathsMemo.set(asString, path), Object.freeze(path), path);\n}\nfunction isEqual(path, otherPath) {\n return path.length === otherPath.length && path.every((segment, i) => isSegmentEqual(segment, otherPath[i]));\n}\nfunction numEqualSegments(path, otherPath) {\n const length = Math.min(path.length, otherPath.length);\n for (let i = 0; i < length; i++)\n if (!isSegmentEqual(path[i], otherPath[i]))\n return i;\n return length;\n}\nfunction isSegmentEqual(segmentA, segmentB) {\n return isKeySegment(segmentA) && isKeySegment(segmentB) ? segmentA._key === segmentB._key : isIndexSegment(segmentA) ? Number(segmentA) === Number(segmentB) : isIndexTuple(segmentA) && isIndexTuple(segmentB) ? segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1] : segmentA === segmentB;\n}\nfunction hasFocus(focusPath, path) {\n const withoutTerminator = focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath;\n return isEqual(withoutTerminator, path);\n}\nfunction hasItemFocus(focusPath, item) {\n return focusPath.length === 1 && isSegmentEqual(focusPath[0], item);\n}\nfunction isExpanded(segment, focusPath) {\n const [head, ...tail] = focusPath;\n return tail.length > 0 && isSegmentEqual(segment, head);\n}\nfunction startsWith(prefix, path) {\n return prefix.every((segment, i) => isSegmentEqual(segment, path[i]));\n}\nfunction trimLeft(prefix, path) {\n if (prefix.length === 0 || path.length === 0)\n return path;\n const [prefixHead, ...prefixTail] = prefix, [pathHead, ...pathTail] = path;\n return isSegmentEqual(prefixHead, pathHead) ? pathFor(trimLeft(prefixTail, pathTail)) : path;\n}\nfunction trimRight(suffix, path) {\n const sufLen = suffix.length, pathLen = path.length;\n if (sufLen === 0 || pathLen === 0)\n return path;\n let i = 0;\n for (; i < sufLen && i < pathLen && isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1]); )\n i++;\n return pathFor(path.slice(0, pathLen - i));\n}\nfunction trimChildPath(path, childPath) {\n return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const isHead = i === 0;\n if (typeof segment == \"number\")\n return `${target}[${segment}]`;\n if (typeof segment == \"string\")\n return isHead ? segment : GROQ_DATA_TYPE_VALUES.includes(segment) ? `${target}[\"${segment}\"]` : `${target}.${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nfunction _resolveKeyedPath(value, path) {\n if (path.length === 0)\n return path;\n const [next, ...rest] = path;\n if (typeof next == \"number\") {\n if (!Array.isArray(value) || !(next in value))\n return [];\n const item = value[next];\n return [typeof item?._key == \"string\" ? { _key: item._key } : next, ..._resolveKeyedPath(item, rest)];\n }\n const nextVal = get(value, [next]);\n return [next, ..._resolveKeyedPath(nextVal, rest)];\n}\nfunction resolveKeyedPath(value, path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return pathFor(_resolveKeyedPath(value, path));\n}\nfunction fromString(path) {\n if (typeof path != \"string\")\n throw new Error(\"Path is not a string\");\n const segments = path.match(rePropName);\n if (!segments)\n throw new Error(\"Invalid path string\");\n return segments.map(normalizePathSegment);\n}\nfunction normalizePathSegment(segment) {\n return isIndexSegment(segment) ? normalizeIndexSegment(segment) : isKeySegment(segment) ? normalizeKeySegment(segment) : isIndexTuple(segment) ? normalizeIndexTupleSegment(segment) : segment;\n}\nfunction normalizeIndexSegment(segment) {\n return Number(segment.replace(/[^\\d]/g, \"\"));\n}\nfunction normalizeKeySegment(segment) {\n return { _key: segment.match(reKeySegment)[1] };\n}\nfunction normalizeIndexTupleSegment(segment) {\n const [from, to] = segment.split(\":\").map((seg) => seg === \"\" ? seg : Number(seg));\n return [from, to];\n}\nexport {\n FOCUS_TERMINATOR,\n _resolveKeyedPath,\n fromString,\n get,\n hasFocus,\n hasItemFocus,\n isEqual,\n isExpanded,\n isSegmentEqual,\n numEqualSegments,\n pathFor,\n resolveKeyedPath,\n startsWith,\n toString,\n trimChildPath,\n trimLeft,\n trimRight\n};\n//# sourceMappingURL=paths.mjs.map\n","import {Flex, Spinner, Stack, Box, Card, Inline, Text, Button} from '@sanity/ui'\nimport {fromString as pathFromString} from '@sanity/util/paths'\nimport {useCallback} from 'react'\nimport {Preview, useSchema, usePerspective, getPublishedId} from 'sanity'\nimport type {SanityDocument} from 'sanity'\nimport type {UserViewComponent} from 'sanity/structure'\nimport {usePaneRouter} from 'sanity/structure'\nimport {Feedback, useListeningQuery} from 'sanity-plugin-utils'\n\ninterface TagReference {\n _id: string\n _type: string\n title: string\n}\n\nexport const ConceptUseView: UserViewComponent<Record<string, never>> = ({\n document,\n}: {\n document: {displayed: {_id?: string}}\n}) => {\n const {selectedPerspectiveName} = usePerspective()\n const {routerPanesState, groupIndex, handleEditReference} = usePaneRouter()\n const schema = useSchema()\n\n const refId = getPublishedId((document.displayed as {_id?: string})?._id ?? '')\n\n const handleClick = useCallback(\n (id: string, type: string) => {\n const childParams = routerPanesState[groupIndex + 1]?.[0].params || {}\n const {parentRefPath} = childParams\n\n handleEditReference({\n id,\n type,\n parentRefPath: parentRefPath ? pathFromString(parentRefPath) : [``],\n template: {id},\n })\n },\n [routerPanesState, groupIndex, handleEditReference]\n )\n\n const {data, loading, error} = useListeningQuery<SanityDocument[]>(\n `*[!(_type in [\"skosConcept\",\"skosConceptScheme\"]) && references($refId)]{_id,_type,title}`,\n {\n params: {refId},\n options: {\n perspective: selectedPerspectiveName ? [selectedPerspectiveName] : 'drafts',\n },\n }\n ) as {\n data: TagReference[]\n loading: boolean\n error: Error | null\n }\n\n if (loading) {\n return (\n <Box padding={5}>\n <Flex\n align=\"center\"\n direction=\"column\"\n gap={5}\n height=\"fill\"\n justify=\"center\"\n style={{paddingTop: '1rem'}}\n >\n <Spinner muted />\n <Text muted size={1}>\n Loading usage…\n </Text>\n </Flex>\n </Box>\n )\n }\n\n if (error) {\n return (\n <Stack padding={4} space={5}>\n <Feedback tone={'caution'}>There was en error fetching use data</Feedback>\n </Stack>\n )\n }\n\n if (!data?.length) {\n return (\n <Stack padding={4} space={5}>\n <Feedback>This concept is not currently in use</Feedback>\n </Stack>\n )\n }\n\n return (\n <Box padding={4} paddingTop={4}>\n <Stack space={2}>\n <Card borderBottom paddingTop={3} paddingBottom={3}>\n <Inline paddingTop={1}>\n <Text weight=\"semibold\" muted size={1}>\n Resource count (all schemes): {data.length}\n </Text>\n </Inline>\n </Card>\n <Stack space={1}>\n {data?.map((d: TagReference) => {\n const schemaType = schema.get(d._type)\n return (\n schemaType && (\n <Button\n key={d._id}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={() => handleClick(d._id, d._type)}\n padding={2}\n mode=\"bleed\"\n >\n <Preview value={d} schemaType={schemaType} layout=\"block\" />\n </Button>\n )\n )\n })}\n </Stack>\n </Stack>\n </Box>\n )\n}\n","import {EditIcon, DocumentsIcon} from '@sanity/icons'\nimport type {StructureBuilder, ListBuilder, DefaultDocumentNodeResolver} from 'sanity/structure'\n\nimport {TreeView} from './components/TreeView'\nimport NodeTree from './static/NodeTree'\nimport {ConceptUseView} from './views/ConceptUseView'\n\n/**\n * #### Default Desk Structure for Concept and Concept Scheme\n * Sets defaultDocumentNode. Consider exporting in the future,\n * if there is a use case for mixing taxonomy views in the main\n * desk structure.\n */\nexport const structure = (S: StructureBuilder): ListBuilder =>\n S.list()\n .title('Taxonomy Manager')\n .items([\n S.documentTypeListItem('skosConceptScheme').title('Concept Schemes'),\n S.documentTypeListItem('skosConcept').title('Concepts'),\n ])\n\n// set default document node here — so that if users want concepts\n// and schemes elsewhere in desk, they'll get the right views.\nexport const defaultDocumentNode: DefaultDocumentNodeResolver = (S, {schemaType}) => {\n // Conditionally return a different configuration based on the schema type\n switch (schemaType) {\n case 'skosConceptScheme':\n return S.document().views([\n S.view.component(TreeView).title('Tree View').icon(NodeTree),\n S.view.form().icon(EditIcon),\n ])\n case 'skosConcept':\n return S.document().views([\n S.view.form().icon(EditIcon),\n S.view.component(ConceptUseView).title('Tagged Resources').icon(DocumentsIcon),\n ])\n default:\n return S.document().views([S.view.form().icon(EditIcon)])\n }\n}\n","import {definePlugin} from 'sanity'\nimport {structureTool} from 'sanity/structure'\n\nimport {ReferenceHierarchyInput, ArrayHierarchyInput} from './components/inputs'\nimport {TreeView} from './components/TreeView'\nimport {setPluginConfig} from './config'\nimport {schemeFilter, branchFilter} from './helpers'\nimport skosConcept from './skosConcept'\nimport skosConceptScheme from './skosConceptScheme'\nimport NodeTree from './static/NodeTree'\nimport {defaultDocumentNode, structure} from './structure'\nimport type {Options} from './types'\n\n/**\n * #### Sanity Taxonomy Manager\n * Defines a Sanity plugin for managing SKOS compliant taxonomies in Sanity Studio.\n * #### Options\n * @param baseUri - The base URI to use for SKOS concepts and concept schemes. BaseURI should follow an IANA http/s scheme and should terminate with either a / or #.\n * @param customConceptFields - An array of additional fields to add to the skosConcept type.\n * @param customSchemeFields - An array of additional fields to add to the skosConceptScheme type.\n * #### Identifier Configuration\n * @param ident.pattern - The character set to use for identifiers (default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz').\n * @param ident.length - The length of the generated identifier (default: 6).\n * @param ident.prefix - A prefix to prepend to generated identifiers, for example to use Wikidata style IDs like \"Q27521\" (default: '').\n * @param ident.regenUi - Whether to display the \"Create Unique Identifier\" button in the UI by default.\n * @returns A Sanity plugin object.\n */\nconst taxonomyManager = definePlugin((options?: Options) => {\n const {baseUri, customConceptFields, customSchemeFields, ident} = options || {}\n\n // Store config for access in hooks\n setPluginConfig(options)\n\n return {\n name: 'taxonomyManager',\n options,\n schema: {\n types: [\n skosConcept(baseUri, customConceptFields, ident),\n skosConceptScheme(baseUri, customSchemeFields, ident),\n ],\n },\n plugins: [\n structureTool({\n name: 'taxonomy',\n title: 'Taxonomy',\n structure,\n defaultDocumentNode,\n icon: NodeTree,\n }),\n ],\n }\n})\n\nexport {\n taxonomyManager,\n TreeView,\n schemeFilter,\n branchFilter,\n ReferenceHierarchyInput,\n ArrayHierarchyInput,\n}\n"],"names":["createId","ident","alphabet","pattern","length","prefix","customAlphabet","nanoid","Identifier","props","onChange","toast","useToast","handleChange","useCallback","id","set","push","status","title","closable","jsx","Stack","space","children","Button","icon","GenerateIcon","mode","width","onClick","text","defaultProps","__defProp$3","Object","defineProperty","__getOwnPropSymbols$3","getOwnPropertySymbols","__hasOwnProp$3","prototype","hasOwnProperty","__propIsEnum$3","propertyIsEnumerable","__defNormalProp$3","obj","key","value","enumerable","configurable","writable","__spreadValues$3","a","b","prop","call","DEFAULT_PROPS","tone","Feedback","description","Card","padding","radius","border","jsxs","Flex","Box","flex","Text","weight","size","__defProp$2","__getOwnPropSymbols$2","__hasOwnProp$2","__propIsEnum$2","__defNormalProp$2","__spreadValues$2","styled","as","css","DEFAULT_PARAMS","DEFAULT_OPTIONS","apiVersion","useParams","params","stringifiedParams","useMemo","JSON","stringify","parse","useListeningQuery","query","options","initialValue","loading","setLoading","useState","error","setError","data","setData","memoParams","memoOptions","subscription","useRef","documentStore","useDocumentStore","useEffect","current","listenQuery","pipe","distinctUntilChanged","isEqual","catchError","err","console","subscribe","documents","unsubscribe","_a","SchemeContext","createContext","TreeContext","editControls","ReleaseContext","branchBuilder","level","reference","i","getRandomValues","rnds8","Uint8Array","rng","crypto","bind","msCrypto","Error","byteToHex","toString","substr","v4","buf","offset","rnds","random","arr","arguments","uuid","toLowerCase","REGEX","test","validate","TypeError","taxonomyManagerConfig","useCreateConcept","document","client","useClient","openInNewPane","routerContext","useContext","RouterContext","routerPanesState","groupIndex","usePaneRouter","conceptId","panes","splice","type","href","resolvePathFromState","navigateUrl","path","useOpenNewConceptPane","schemaBaseIri","displayed","baseIri","conceptType","concept","broaderConceptId","_originalId","broaderConceptOriginalId","isInRelease","isVersionId","_id","releaseName","getVersionNameFromId","schemeId","getVersionId","DocumentId","getDraftId","newConceptId","skosConcept","_type","prefLabel","broader","related","isPublished","isPublishedId","_key","_ref","getPublishedId","_weak","_strengthenOnPublish","template","skosConceptReference","transaction","createIfNotExists","create","patch","setIfMissing","topConcepts","append","concepts","commit","autoGenerateArrayKeys","then","_res","catch","message","useRemoveConcept","unset","useEmbeddingsRecs","embeddingsIndex","dataset","useDataset","getFormValue","useGetFormValue","conceptRecs","setConceptRecs","recsError","setRecsError","buildQueryString","fieldReferences","emptyFields","values","map","fieldName","val","trim","join","filter","Boolean","fetchConceptRecs","async","indexName","maxResults","returnedRecs","request","url","method","body","triggerEmbeddingsSearch","errorMessage","MessageHelper","Label","muted","style","whiteSpace","ConceptDetailDialogue","open","setOpen","onClose","onOpen","definition","example","scopeNote","Fragment","Tooltip","delay","content","sizing","fallbackPlacements","placement","portal","InfoOutlineIcon","Dialog","header","zOffset","paddingTop","paddingBottom","ConceptDetailLink","topConcept","orphan","displayLabel","paddingLeft","justify","textOverflow","Badge","fontSize","marginLeft","verticalAlign","ConceptEditAction","action","handler","typeMap","add","AddCircleIcon","remove","TrashIcon","ConceptSelectLink","selectConcept","score","handleClick","toFixed","StructureDetailDialogue","ErrorOutlineIcon","info","warn","styleInject","ref","insertAt","head","getElementsByTagName","createElement","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","ToggleButton","visibility","ToggleArrowRightIcon","className","Children","inputComponent","releaseContext","globalVisibility","treeVisibility","createConcept","removeConcept","handleAddChild","handleRemoveConcept","levelVisibility","setLevelVisibility","hasMatchingDescendant","handleToggle","align","wrap","gap","minWidth","childConcepts","Inline","ChildConcepts","childVisibility","marginTop","display","Concepts","hasTopConcept","NewScheme","titleValue","setTitleValue","descriptionValue","setDescriptionValue","handleTitleChange","event","currentTarget","handleDescriptionChange","addTitle","documentId","doc","_","useAddTitle","handleAddTitle","shadow","AddIcon","TextInput","placeholder","TextArea","rows","NoConcepts","TopConcepts","TreeStructure","treeId","listStyle","marginBlockStart","isOrphan","InputHierarchy","branchId","expanded","initialVisibility","fetch","listen","perspective","scoreMap","Map","Array","isArray","rec","addScores","node","scores","publishedId","get","annotatedChildren","c","some","mergedData","tc","direction","height","Spinner","Provider","NodeTree","viewBox","fill","xmlns","d","Hierarchy","createTopConcept","createEntryConcept","setGlobalVisibility","handleExpand","handleCollapse","borderBottom","paddingY","TreeView","selectedPerspectiveName","usePerspective","Container","ReferenceHierarchyInput","useFormValue","name","isDraft","isDraftId","schemeLoading","setSchemeLoading","valuesLoading","setValuesLoading","scheme","setScheme","filterValues","setFilterValues","schemaType","resolvedFilterValues","getClient","fetchFilterValues","res","browseHierarchy","handleClose","handleAction","renderDefault","browseOnly","FormField","validation","__unstable_presence","presence","Grid","columns","disabled","ArrayHierarchyInput","of","item","includes","duration","ManagementControls","schemeFilter","branchFilter","baseIriField","defineField","Rule","required","components","input","conceptFilter","self","baseUri","customConceptFields","defineType","AiOutlineTags","context","fields","custom","withConfig","styles","target","rel","WarningOutlineIcon","unique","hidden","regenUi","readOnly","to","orderings","by","field","preview","select","prepare","media","AiOutlineTag","skosConceptScheme","customSchemeFields","deprecated","reason","controls","defineArrayMember","sortable","reKeySegment","reIndexTuple","rePropName","fromString","segments","match","normalizePathSegment","segment","isIndexSegment","Number","replace","normalizeIndexSegment","isKeySegment","normalizeKeySegment","from","isIndexTuple","split","seg","normalizeIndexTupleSegment","ConceptUseView","handleEditReference","schema","useSchema","refId","childParams","parentRefPath","pathFromString","Preview","layout","structure","S","list","items","documentTypeListItem","defaultDocumentNode","views","view","component","form","EditIcon","DocumentsIcon","taxonomyManager","definePlugin","types","plugins","structureTool"],"mappings":"m/CAaO,SAASA,GAASC,GACvB,MAAMC,EAAWD,GAAOE,SAVF,iEAWhBC,EAASH,GAAOG,QAVF,EAapB,OAFeH,GAAOI,QAVF,IAWLC,GAAeJ,EAAUE,EACxBG,EAClB,CCCO,MAAMC,GAAcC,IACzB,MAAMC,SAACA,EAAAT,MAAUA,GAASQ,EACpBE,EAAQC,IAERC,EAAeC,EAAY,KAC/B,MAAMC,EAAKf,GAASC,GACpBS,EAASM,EAAID,IACbJ,EAAMM,KAAK,CACTC,OAAQ,UACRC,MAAO,sBACPC,UAAU,KAEX,CAACV,EAAUC,EAAOV;AAErB,OACEoB,EAACC,EAAA,CAAMC,MAAO,EACZC,wBAAAH,EAACI,EAAA,CACCC,KAAMC,EACNC,KAAK,QACLC,MAAM,OACNC,QAASjB,EACTkB,KAAK,2BAMbvB,GAAWwB,aAAe,CACxB/B,WAAO,GCtCT,IAAIgC,GAAcC,OAAOC,eAAgBC,GAAwBF,OAAOG,sBAAuBC,GAAiBJ,OAAOK,UAAUC,eAAgBC,GAAiBP,OAAOK,UAAUG,qBAAsBC,GAAoB,CAACC,EAAKC,EAAKC,IAAUD,KAAOD,EAAMX,GAAYW,EAAKC,EAAK,CAAEE,YAAY,EAAIC,cAAc,EAAIC,UAAU,EAAIH,UAAWF,EAAIC,GAAOC,EAAOI,GAAmB,CAACC,EAAGC,KACzX,IAAA,IAASC,KAAQD,IAAMA,EAAI,CAAA,GACzBd,GAAegB,KAAKF,EAAGC,IAASV,GAAkBQ,EAAGE,EAAMD,EAAEC,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