@knapsack/core 4.68.7 → 4.68.8

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.1__@swc+core@1.3.57_@swc+helpers_ww5ypu3n2haukmlxcrky22ydmq/node_modules/tsup/assets/cjs_shims.js","../../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js","../../../node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js","../../../node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js","../../../node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js","../src/index.ts","../src/users.ts","../../types/src/ui-config.ts","../../types/src/color-config.ts","../../types/src/typography-config.ts","../../types/src/nav-customization-config.ts","../../types/src/app-client-data/index.ts","../../types/src/type-utils.ts","../../types/src/app-client-data/blocks.ts","../../types/src/app-client-data/design-tokens.ts","../../types/src/app-client-data/design-tokens-types/token-data.ts","../../types/src/app-client-data/design-tokens-types/token-definitions.ts","../../types/src/app-client-data/design-tokens-types/token-src-value-info.ts","../../types/src/app-client-data/design-tokens-types/token-src.ts","../../types/src/app-client-data/design-tokens-types/token-utils.ts","../../types/src/app-client-data/patterns.ts","../../types/src/app-client-data/page.header.ts","../../types/src/app-client-data-v3/index.ts","../../types/src/app-client-data-migrations/4.1.7-demos.ts","../../types/src/app-client-data-migrations/index.ts","../../types/src/json-schema.ts","../../types/src/changes.ts","../../types/src/renderers.ts","../../types/src/renderer-client-types.ts","../../types/src/web-sockets.ts","../../types/src/git-providers.ts","../../types/src/api/plugins.ts","../../types/src/api/files.ts","../../types/src/user-roles.ts","../src/webhooks.ts","../src/ks-urls.ts","../src/http-headers.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n","module.exports = function isArrayish(obj) {\n\tif (!obj || typeof obj === 'string') {\n\t\treturn false;\n\t}\n\n\treturn obj instanceof Array || Array.isArray(obj) ||\n\t\t(obj.length >= 0 && (obj.splice instanceof Function ||\n\t\t\t(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));\n};\n","'use strict';\n\nvar isArrayish = require('is-arrayish');\n\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\n\nvar swizzle = module.exports = function swizzle(args) {\n\tvar results = [];\n\n\tfor (var i = 0, len = args.length; i < len; i++) {\n\t\tvar arg = args[i];\n\n\t\tif (isArrayish(arg)) {\n\t\t\t// http://jsperf.com/javascript-array-concat-vs-push/98\n\t\t\tresults = concat.call(results, slice.call(arg));\n\t\t} else {\n\t\t\tresults.push(arg);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nswizzle.wrap = function (fn) {\n\treturn function () {\n\t\treturn fn(swizzle(arguments));\n\t};\n};\n","/* MIT license */\nvar colorNames = require('color-name');\nvar swizzle = require('simple-swizzle');\nvar hasOwnProperty = Object.hasOwnProperty;\n\nvar reverseNames = Object.create(null);\n\n// create a list of reverse color names\nfor (var name in colorNames) {\n\tif (hasOwnProperty.call(colorNames, name)) {\n\t\treverseNames[colorNames[name]] = name;\n\t}\n}\n\nvar cs = module.exports = {\n\tto: {},\n\tget: {}\n};\n\ncs.get = function (string) {\n\tvar prefix = string.substring(0, 3).toLowerCase();\n\tvar val;\n\tvar model;\n\tswitch (prefix) {\n\t\tcase 'hsl':\n\t\t\tval = cs.get.hsl(string);\n\t\t\tmodel = 'hsl';\n\t\t\tbreak;\n\t\tcase 'hwb':\n\t\t\tval = cs.get.hwb(string);\n\t\t\tmodel = 'hwb';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tval = cs.get.rgb(string);\n\t\t\tmodel = 'rgb';\n\t\t\tbreak;\n\t}\n\n\tif (!val) {\n\t\treturn null;\n\t}\n\n\treturn {model: model, value: val};\n};\n\ncs.get.rgb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar abbr = /^#([a-f0-9]{3,4})$/i;\n\tvar hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;\n\tvar rgba = /^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar per = /^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar keyword = /^(\\w+)$/;\n\n\tvar rgb = [0, 0, 0, 1];\n\tvar match;\n\tvar i;\n\tvar hexAlpha;\n\n\tif (match = string.match(hex)) {\n\t\thexAlpha = match[2];\n\t\tmatch = match[1];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\t// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19\n\t\t\tvar i2 = i * 2;\n\t\t\trgb[i] = parseInt(match.slice(i2, i2 + 2), 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(abbr)) {\n\t\tmatch = match[1];\n\t\thexAlpha = match[3];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i] + match[i], 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(rgba)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i + 1], 0);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(per)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(keyword)) {\n\t\tif (match[1] === 'transparent') {\n\t\t\treturn [0, 0, 0, 0];\n\t\t}\n\n\t\tif (!hasOwnProperty.call(colorNames, match[1])) {\n\t\t\treturn null;\n\t\t}\n\n\t\trgb = colorNames[match[1]];\n\t\trgb[3] = 1;\n\n\t\treturn rgb;\n\t} else {\n\t\treturn null;\n\t}\n\n\tfor (i = 0; i < 3; i++) {\n\t\trgb[i] = clamp(rgb[i], 0, 255);\n\t}\n\trgb[3] = clamp(rgb[3], 0, 1);\n\n\treturn rgb;\n};\n\ncs.get.hsl = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hsl = /^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hsl);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar s = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar l = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\n\t\treturn [h, s, l, a];\n\t}\n\n\treturn null;\n};\n\ncs.get.hwb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hwb = /^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hwb);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar w = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar b = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\t\treturn [h, w, b, a];\n\t}\n\n\treturn null;\n};\n\ncs.to.hex = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn (\n\t\t'#' +\n\t\thexDouble(rgba[0]) +\n\t\thexDouble(rgba[1]) +\n\t\thexDouble(rgba[2]) +\n\t\t(rgba[3] < 1\n\t\t\t? (hexDouble(Math.round(rgba[3] * 255)))\n\t\t\t: '')\n\t);\n};\n\ncs.to.rgb = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'\n\t\t: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';\n};\n\ncs.to.rgb.percent = function () {\n\tvar rgba = swizzle(arguments);\n\n\tvar r = Math.round(rgba[0] / 255 * 100);\n\tvar g = Math.round(rgba[1] / 255 * 100);\n\tvar b = Math.round(rgba[2] / 255 * 100);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'\n\t\t: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';\n};\n\ncs.to.hsl = function () {\n\tvar hsla = swizzle(arguments);\n\treturn hsla.length < 4 || hsla[3] === 1\n\t\t? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'\n\t\t: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';\n};\n\n// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax\n// (hwb have alpha optional & 1 is default value)\ncs.to.hwb = function () {\n\tvar hwba = swizzle(arguments);\n\n\tvar a = '';\n\tif (hwba.length >= 4 && hwba[3] !== 1) {\n\t\ta = ', ' + hwba[3];\n\t}\n\n\treturn 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';\n};\n\ncs.to.keyword = function (rgb) {\n\treturn reverseNames[rgb.slice(0, 3)];\n};\n\n// helpers\nfunction clamp(num, min, max) {\n\treturn Math.min(Math.max(min, num), max);\n}\n\nfunction hexDouble(num) {\n\tvar str = Math.round(num).toString(16).toUpperCase();\n\treturn (str.length < 2) ? '0' + str : str;\n}\n","export * from './users';\nexport * from './webhooks';\nexport * from './ks-urls';\nexport * from './http-headers';\n","/**\n * @file\n *\n * All things involving low-level user JWT parsing, claims, roles.\n */\n\nimport {\n array,\n boolean,\n Describe,\n enums,\n number,\n object,\n optional,\n string,\n type,\n union,\n record,\n assign,\n} from 'superstruct';\nimport { roles, type Role } from '@knapsack/types';\n\n// Superstruct runtime validation for Role\nexport const RolesEnums = enums(roles);\nexport const RolesEnumsStruct: Describe<Role> = RolesEnums;\n\nexport const canRoleAdmin = (role: Role): boolean => role === 'ADMIN';\n\nexport const rolesThatCanManageUsers: Role[] = ['ADMIN', 'MANAGER'];\n\nexport const canRoleManageUsers = (role: Role): boolean =>\n rolesThatCanManageUsers.includes(role);\n\nexport const rolesThatCanDelete: Role[] = [\n ...rolesThatCanManageUsers,\n 'EDITOR',\n];\n\nexport const canRoleDelete = (role: Role): boolean =>\n rolesThatCanDelete.includes(role);\n\nexport const rolesThatCanEdit: Role[] = [...rolesThatCanDelete, 'CONTRIBUTOR'];\n\nexport const canRoleEdit = (role: Role): boolean =>\n rolesThatCanEdit.includes(role);\n\nexport const rolesThatCanPublish: Role[] = ['ADMIN'];\n\nexport const canRolePublish = (role: Role): boolean =>\n rolesThatCanPublish.includes(role);\n\nexport const rolesThatCanView: Role[] = [...rolesThatCanEdit, 'VIEWER'];\n\nexport const canRoleView = (role: Role): boolean =>\n rolesThatCanView.includes(role);\n\nexport const isRoleValid = (role: string): role is Role =>\n RolesEnumsStruct.is(role);\n\n/**\n * Please note that these are not the same as the \"roles\" used on a per-site\n * basis, these are roles for the entire DB.\n */\nexport enum HasuraRoles {\n // yes, `admin` exists but no reason anyone should have it, yet\n user = 'user',\n anonymous = 'anonymous',\n}\nconst HasuraRolesStruct = enums(Object.values(HasuraRoles));\n\nexport type HasuraClaims = {\n 'x-hasura-allowed-roles': HasuraRoles[];\n 'x-hasura-default-role': HasuraRoles;\n 'x-hasura-user-id'?: string;\n};\n// Superstruct runtime validation for HasuraClaims\nexport const HasuraClaimsStruct: Describe<HasuraClaims> = object({\n 'x-hasura-allowed-roles': array(HasuraRolesStruct),\n 'x-hasura-default-role': HasuraRolesStruct,\n 'x-hasura-user-id': optional(string()),\n});\n\n/**\n * The specific Knapsack claims that live at 'https://knapsack.cloud' within JWT\n */\nexport type KnapsackClaims = {\n userId: string;\n /** For email address that end in `knapsack.cloud` */\n isSuperAdmin: boolean;\n /**\n * Keys are roleId, value are array of siteId strings\n * Purposely kept small for JWT payloads. Often expanded.\n * @see {SiteRoleMap}\n * @see {expandSitesByRole}\n * @example\n * {\n * sitesByRole: {\n * EDITOR: ['ks-demo-bootstrap', 'ks-demo-tailwind'],\n * VIEWER: ['site-id-1'],\n * },\n * }\n */\n sitesByRole: {\n [roleId in Role]?: string[];\n };\n};\n// Superstruct runtime validation for KnapsackClaims\nexport const KsClaimsStruct: Describe<KnapsackClaims> = object({\n userId: string(),\n isSuperAdmin: boolean(),\n sitesByRole: record(RolesEnums, array(string())),\n});\n\n/**\n * The easier to work with & expanded version of `sitesByRole` in KsClaims,\n * which is kept as small as possible for JWT payloads.\n * @see {KnapsackClaims}\n */\nexport type SiteRoleMap = {\n [siteId: string]: Role;\n};\n\n/**\n * Base JWT\n */\nexport type JwtBase = {\n /* Token expiration time; usually 1 hour after issued at time (`iat`), in seconds (not ms) */\n exp: number;\n /* Email exists on ID token, but not AUTH token */\n email?: string;\n /* WARNING: email_verified is not guaranteed to exst on SSO tokens, and is boolean or string! */\n email_verified?: string | boolean;\n /* Issued at Time, in seconds (not ms) */\n iat: number;\n /* Issuer */\n iss: string;\n /* Subject (userId) */\n sub: string;\n /* Audience */\n aud: string | string[];\n};\n// Superstruct runtime validation for JwtBase. Use type() to ignore extra keys\nexport const JwtBaseStruct: Describe<JwtBase> = type({\n exp: number(),\n email: optional(string()),\n email_verified: optional(union([string(), boolean()])),\n iat: number(),\n iss: string(),\n sub: string(),\n aud: union([string(), array(string())]),\n});\n\n/**\n * Bring it all together to make a full JWT\n */\nexport const HASURA_CLAIMS_NAMESPACE = 'https://hasura.io/jwt/claims';\nexport const KNAPSACK_CLAIMS_NAMESPACE = 'https://knapsack.cloud';\n\n// Just custom claims\nexport type JwtCustomClaims = {\n [HASURA_CLAIMS_NAMESPACE]: HasuraClaims;\n [KNAPSACK_CLAIMS_NAMESPACE]: KnapsackClaims;\n};\n// Superstruct runtime validation for JwtCustomClaims\nexport const JwtCustomClaimsStruct: Describe<JwtCustomClaims> = object({\n [HASURA_CLAIMS_NAMESPACE]: HasuraClaimsStruct,\n [KNAPSACK_CLAIMS_NAMESPACE]: KsClaimsStruct,\n});\n\n// The entire JWT, custom claims + base root keys\nexport type JwtWithCustomClaims = JwtBase & JwtCustomClaims;\n// Superstruct runtime validation for JwtWithCustomClaims\nexport const JwtWithCustomClaimsStruct: Describe<JwtWithCustomClaims> = assign(\n JwtBaseStruct,\n JwtCustomClaimsStruct,\n);\n\n/**\n * Convert sitesByRole to be a map of siteId to roleId. This is the format we\n * actually use within the app to determine what sites a user can access.\n */\nexport function expandSitesByRole(\n sitesByRole: KnapsackClaims['sitesByRole'],\n): SiteRoleMap {\n return Object.entries(sitesByRole).reduce((cur, [roleId, siteIds]) => {\n if (!isRoleValid(roleId)) return cur;\n siteIds.forEach((siteId) => {\n cur[siteId] = roleId;\n });\n return cur;\n }, {} as SiteRoleMap);\n}\n\nexport type KsClaimsHelper = Omit<KnapsackClaims, 'sitesByRole'> & {\n siteRoleMap: SiteRoleMap;\n /** Get the User's Role for particular site */\n getSiteRole: (siteId: string) => Role;\n};\n\nexport const defaultAnonymousKsClaims: KsClaimsHelper = {\n isSuperAdmin: false,\n userId: '',\n siteRoleMap: {},\n getSiteRole: () => 'ANONYMOUS',\n};\n\n/**\n * Picks off the KsClaims from the JWT (since it has a weird to use\n * `https://knapsack.cloud` namespace) and then also converts the size-conscious\n * `sitesByRole` into the more usable format of `siteRoleMap\n */\nexport const getKsClaims = (claims: unknown): KsClaimsHelper => {\n if (!JwtWithCustomClaimsStruct.is(claims)) {\n return defaultAnonymousKsClaims;\n }\n const { sitesByRole, ...ksClaims } = claims[KNAPSACK_CLAIMS_NAMESPACE];\n const siteRoleMap = expandSitesByRole(sitesByRole);\n return {\n ...ksClaims,\n siteRoleMap,\n getSiteRole: (siteId) => {\n if (ksClaims.isSuperAdmin) return 'ADMIN';\n return siteRoleMap[siteId] || 'ANONYMOUS';\n },\n };\n};\n","import {\n type,\n Describe,\n literal,\n optional,\n defaulted,\n boolean,\n array,\n object,\n} from 'superstruct';\n\nimport { ExpandRecursively } from '@knapsack/utils';\n\nimport {\n ColorConfig,\n ColorConfigStruct,\n ColorStringStruct,\n} from './color-config';\n\nimport {\n FontFaceConfigStruct,\n FontFaceConfig,\n TypographyConfigStruct,\n TypographyLinkConfigStruct,\n pageElements,\n pageElementsV2,\n} from './typography-config';\n\nimport {\n customizableNavElements,\n NavCustomizationConfigStruct,\n PrimaryNavCustomizationConfigStruct,\n SecondaryNavCustomizationConfigStruct,\n} from './nav-customization-config';\n\nexport type UiConfigV1 = {\n version: 1;\n oldSillySidebarBgColor: string;\n};\n\nexport const UiConfigV1Struct: Describe<UiConfigV1> = object({\n version: literal(1),\n oldSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV2 = {\n version: 2;\n anotherSillySidebarBgColor: string;\n};\n\nexport const UiConfigV2Struct: Describe<UiConfigV2> = object({\n version: literal(2),\n anotherSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV3 = {\n version: 3;\n sidebarBgColor: string;\n};\n\nexport const UiConfigV3Struct: Describe<UiConfigV3> = object({\n version: literal(3),\n sidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV4 = {\n version: 4;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n enableSidebarIcons?: boolean;\n};\nexport const UiConfigV4Struct: Describe<UiConfigV4> = object({\n version: literal(4),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport type UiConfigV5 = {\n version: 5;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n linkColor: ColorConfig;\n enableSidebarIcons: boolean;\n};\nexport const UiConfigV5Struct: Describe<UiConfigV5> = object({\n version: literal(5),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport interface _UiConfigV6 extends Omit<UiConfigV5, 'version'> {\n version: 6;\n appearance: {\n customFonts?: FontFaceConfig[];\n pageElements: typeof pageElements;\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfigV6' is not assignable to type 'Record<string, unknown>'.\" error\nexport type UiConfigV6 = ExpandRecursively<_UiConfigV6>;\n\nexport const UiConfigV6Struct: Describe<UiConfigV6> = object({\n version: literal(6),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV7 extends Omit<UiConfigV6, 'version'> {\n version: 7;\n appearance: {\n navigation?: typeof customizableNavElements;\n customFonts?: UiConfigV6['appearance']['customFonts'];\n pageElements: UiConfigV6['appearance']['pageElements'];\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig7' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\nexport type UiConfigV7 = ExpandRecursively<_UiConfigV7>;\n\nexport const UiConfigV7Struct: Describe<UiConfigV7> = object({\n version: literal(7),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV8\n extends Omit<UiConfigV7, 'version' | 'enableSidebarIcons'> {\n version: 8;\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig8' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\n// TODO: move this to @knapsack/types\nexport type UiConfigV8 = ExpandRecursively<_UiConfigV8>;\n\nexport const UiConfigV8Struct: Describe<UiConfigV8> = object({\n version: literal(8),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV9\n extends Omit<\n UiConfigV8,\n 'version' | 'primaryColor' | 'darkColor' | 'lightColor' | 'linkColor'\n > {\n version: 9;\n}\nexport type UiConfigV9 = ExpandRecursively<_UiConfigV9>;\n\nexport const UiConfigV9Struct: Describe<UiConfigV9> = object({\n version: literal(9),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV10 extends Omit<UiConfigV9, 'version'> {\n version: 10;\n appearance: {\n navigation?: UiConfigV9['appearance']['navigation'];\n customFonts?: UiConfigV9['appearance']['customFonts'];\n pageElements: typeof pageElementsV2;\n };\n}\nexport type UiConfigV10 = ExpandRecursively<_UiConfigV10>;\n\nexport const UiConfigV10Struct: Describe<UiConfigV10> = object({\n version: literal(10),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingXLarge: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n headingXSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport type UiConfigVersions =\n | typeof UiConfigV1Struct.TYPE\n | typeof UiConfigV2Struct.TYPE\n | typeof UiConfigV3Struct.TYPE\n | typeof UiConfigV4Struct.TYPE\n | typeof UiConfigV5Struct.TYPE\n | typeof UiConfigV6Struct.TYPE\n | typeof UiConfigV7Struct.TYPE\n | typeof UiConfigV8Struct.TYPE\n | typeof UiConfigV9Struct.TYPE\n | typeof UiConfigV10Struct.TYPE;\n\n// ALIASES FOR LATEST VERSIONS\nexport type UiConfig = UiConfigV10;\nexport const UiConfigStruct: typeof UiConfigV10Struct = UiConfigV10Struct;\n\nexport type NavElementNames = keyof UiConfig['appearance']['navigation'];\n","import colorString from 'color-string';\nimport { define, Describe, literal, string, type, union } from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n","import { Describe, type, union, optional } from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\nimport { TypographyConfig, TypographyConfigStruct } from './typography-config';\n\nexport interface NavCustomizationConfig extends TypographyConfig {\n accentColor?: ColorConfig;\n}\n\nexport interface PrimaryNavCustomizationConfig extends NavCustomizationConfig {\n hoverColor?: ColorConfig;\n backgroundColor?: ColorConfig;\n}\n\nexport type SecondaryNavCustomizationConfig = Omit<\n PrimaryNavCustomizationConfig,\n 'hoverColor'\n>;\n\nexport const NavCustomizationConfigStruct: Describe<NavCustomizationConfig> =\n union([\n TypographyConfigStruct,\n type({\n accentColor: optional(ColorConfigStruct),\n }),\n ]);\n\n// hoverColor: optional(ColorConfigStruct),\nexport const PrimaryNavCustomizationConfigStruct: Describe<PrimaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n hoverColor: optional(ColorConfigStruct),\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nexport const SecondaryNavCustomizationConfigStruct: Describe<SecondaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nconst navCustomizationConfig: NavCustomizationConfig = {};\nconst secondaryNavCustomizationConfig: SecondaryNavCustomizationConfig = {};\nconst primaryNavCustomizationConfig: PrimaryNavCustomizationConfig = {};\n\nexport const customizableNavElements = {\n primaryNav: primaryNavCustomizationConfig,\n secondaryNav: secondaryNavCustomizationConfig,\n tabs: navCustomizationConfig,\n} as const;\n\nexport type CustomizableNavElementNames = keyof typeof customizableNavElements;\nexport type CustomizableNavElementConfig =\n (typeof customizableNavElements)[CustomizableNavElementNames];\n","import {\n // type structs validate that a value has a set of properties on it, but it does not assert anything about unspecified properties. This allows you to assert that a particular set of functionality exists without a strict equality check for properties.\n type,\n string,\n Describe,\n boolean,\n optional,\n array,\n number,\n define,\n} from 'superstruct';\nimport { isObjKey, isObject } from '../type-utils';\nimport type { KnapsackAssetSetsData } from './asset-sets';\nimport type { TokenSrcGroup } from './design-tokens-types';\nimport type { MetaState } from './meta';\nimport type { KnapsackNavsConfig } from './nav';\nimport type { KsFiles } from './files';\nimport type { BlockConfig } from './blocks';\nimport type { KnapsackCustomPagesData } from './custom-pages';\nimport type { Demo, PatternsState } from './patterns';\nimport { UiConfig } from '../ui-config';\nimport { PagesSettings } from './page';\nimport { BlocksSettings } from './blocks.settings';\nimport { DesignSrcFile } from '../design-src.types';\n\nexport * from './asset-sets';\nexport * from './blocks';\nexport * from './custom-pages';\nexport * from './design-tokens';\nexport * from './design-tokens-types';\nexport * from './nav';\nexport * from './files';\nexport * from './meta';\nexport * from './patterns';\nexport { PageHeaderSizes } from './page.header';\nexport type { PageHeaderSettings } from './page.header';\nexport type { PageTab, PageType } from './page';\n\nexport interface KsAppClientData {\n patternsState: PatternsState;\n customPagesState: KnapsackCustomPagesData;\n assetSetsState: KnapsackAssetSetsData;\n navsState: KnapsackNavsConfig;\n tokensSrc: TokenSrcGroup;\n metaState?: MetaState;\n filesState: KsFiles;\n db: {\n blocks: {\n byId: Record<string, BlockConfig>;\n settings: BlocksSettings;\n };\n demos: {\n byId: Record<string, Demo>;\n // \"never\" for now until there are actual settings for demos\n settings: Record<string, never>;\n };\n settings: {\n title?: string;\n hideTitleInNavigation?: boolean;\n logoUrl?: string;\n favicon?: `https://${string}`;\n theme?: UiConfig;\n pages?: PagesSettings;\n designSrcs?: {\n files?: DesignSrcFile[];\n };\n tokens?: {\n theming?: {\n /** Which template languages theming controls will show up for next to the components preview stage. */\n enabledRendererIds?: string[];\n };\n };\n prototyping?: {\n patternId: string;\n };\n };\n };\n}\n\nexport type KsAppClientDataNoMeta = Omit<KsAppClientData, 'metaState'>;\nexport type KsAppClientDataAndMeta = Required<KsAppClientData>;\n\nexport function isKsAppClientDataNoMeta(\n data: unknown,\n): data is KsAppClientDataNoMeta {\n if (!isObject(data)) return false;\n // TODO: bring in exhaustive key checking here so all keys are caught\n const requiredKeys: Array<keyof KsAppClientDataNoMeta> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'tokensSrc',\n 'db',\n ];\n if (!requiredKeys.every((key) => isObjKey(key, data))) return false;\n if (!isObjKey('metaState', data)) return true;\n return false;\n}\n\nexport const KsAppClientDataNoMetaStruct = define<KsAppClientDataNoMeta>(\n 'KsAppClientDataNoMeta',\n isKsAppClientDataNoMeta,\n);\n\nexport function isKsAppClientDataAndMeta(\n data: unknown,\n): data is KsAppClientDataAndMeta {\n if (!isObject(data)) return false;\n // TODO: bring in exhaustive key checking here so all keys are caught\n const requiredKeys: Array<keyof KsAppClientDataAndMeta> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'tokensSrc',\n 'metaState',\n 'db',\n ];\n return requiredKeys.every((key) => isObjKey(key, data));\n}\n\nexport const KsAppClientDataAndMetaStruct = define<KsAppClientDataAndMeta>(\n 'KsAppClientDataAndMeta',\n isKsAppClientDataAndMeta,\n);\n\nexport const KsMetaStateStruct: Describe<KsAppClientData['metaState']> = type({\n isLocalDev: boolean(),\n plugins: array(\n type({\n id: string(),\n hasContent: boolean(),\n clientPluginPath: optional(string()),\n cssPath: optional(string()),\n }),\n ),\n meta: optional(\n type({\n version: optional(string()),\n hasKnapsackCloud: boolean(),\n knapsackCloudSiteId: optional(string()),\n serverPort: optional(number()),\n websocketsPort: optional(number()),\n https: optional(boolean()),\n cacheDir: optional(string()),\n ksVersions: type({\n app: string(),\n }),\n }),\n ),\n});\n\nexport const isKsMetaState = KsMetaStateStruct.is;\n","// backwards compatibile exports\n// this file used to have utilities for types, but those really belong\n// in `@knapsack/utils` so we're re-exporting them from there\n// look for `type-tools.ts` in `@knapsack/utils` for the source\nexport { isObjKey, isObject } from '@knapsack/utils';\nexport type {\n GetValueOrAsyncReturnValue,\n ValueOrGetValue,\n ValueOf,\n Except,\n Simplify,\n AsyncReturnType,\n PackageJson,\n TsConfigJson,\n} from '@knapsack/utils';\n","import type { JSONContent } from '@tiptap/core';\nimport { TokenType } from './design-tokens-types';\n\nexport const BlockSizes = ['large', 'medium', 'small'] as const;\ntype BlockSize = (typeof BlockSizes)[number];\n\nexport const BlockSpacings = ['large', 'medium', 'small'] as const;\ntype BlockSpacing = (typeof BlockSpacings)[number];\n\nexport type BlockHeader = {\n showHeader?: boolean;\n title?: string;\n description?: string;\n};\n\n/**\n * Data for blocks made using the `createEmbedBlock` function\n */\ntype IframeBlockData = {\n url?: string;\n clickToInteract: boolean;\n height?: number | string;\n};\n\ntype BlockConfigBase<\n BlockType extends string,\n Data extends Record<string, unknown> = never,\n> = {\n // Unique across all blocks, basically a UUID upon creation\n // e.g. `ut79D2X_H`\n id: string;\n // Match this to a Slices `id` to use it\n blockType: BlockType;\n data: Data;\n header?: BlockHeader;\n size?: BlockSize;\n /** Controls the amount of spacing AFTER a block */\n spacing?: BlockSpacing;\n};\n\ntype BlockConfigUnion =\n | BlockConfigBase<\n 'component-spec-block',\n {\n patternId?: string;\n templateId?: string;\n collapsible?: boolean;\n expanded?: boolean;\n }\n >\n | BlockConfigBase<\n 'pattern-template-block',\n {\n patternId?: string;\n templateId?: string;\n demoId?: string;\n demoSize?: string;\n showSchemaForm?: boolean;\n showCodeSnippet?: boolean;\n hideControls?: boolean;\n allowResizing?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-src-tiles',\n {\n columns?: '4' | '3' | '2' | '1';\n imageStyles?: {\n align?: 'left' | 'right' | 'center';\n background?: 'dark' | 'light';\n corners?: 'square' | 'rounded';\n fit?: 'contain' | 'fill';\n seamless?: boolean;\n size?: 'auto' | 'small' | 'medium' | 'large' | 'xsmall' | 'xlarge';\n };\n items: {\n description?: JSONContent;\n fileId: string;\n nodeId: string;\n title?: string;\n }[];\n layout?: 'grid' | 'list';\n hideComponentProps?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-src-component',\n {\n fileId: string;\n componentId: string;\n contents: Array<'variants' | 'spec' | 'usage'>;\n styles?: {\n columns?: '4' | '3' | '2' | '1';\n image?: {\n align?: 'left' | 'right' | 'center';\n background?: 'dark' | 'light';\n corners?: 'square' | 'rounded';\n size?: 'auto' | 'small' | 'medium' | 'large' | 'xsmall' | 'xlarge';\n };\n layout?: 'grid' | 'list';\n };\n hideComponentProps?: boolean;\n hideComponentTitles?: boolean;\n }\n >\n | BlockConfigBase<\n 'text-editor',\n {\n autoFocus?: boolean;\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'files-list',\n {\n files: string[];\n }\n >\n | BlockConfigBase<\n 'callout',\n {\n type: 'error' | 'info' | 'success' | 'warning';\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'code-snippet',\n {\n content: JSONContent;\n }\n >\n | BlockConfigBase<'divider-block', Record<string, never>>\n | BlockConfigBase<\n 'guidelines',\n {\n guidelines: {\n id: string;\n image?: {\n src: string;\n title?: string;\n alt?: string;\n };\n imageFit?: 'contain' | 'cover';\n type: 'caution' | 'do' | 'dont';\n content?: JSONContent;\n }[];\n gridStyles?: {\n centered?: boolean;\n columns?: '4' | '3' | '2' | '1';\n };\n tileStyles?: {\n headerBeforeImage?: boolean;\n imageOutlined?: boolean;\n imageRounded?: boolean;\n imageSize?:\n | 'none'\n | 'small'\n | 'medium'\n | 'large'\n | 'xsmall'\n | 'xlarge';\n };\n }\n >\n | BlockConfigBase<\n 'image-block',\n {\n imageSize?: 'xs' | 's' | 'm' | 'l' | 'full';\n images?: {\n caption?: string;\n src: string;\n }[];\n }\n >\n | BlockConfigBase<\n 'shortcut-tiles',\n {\n shortcuts: {\n description?: string;\n id: string;\n image?: string;\n link: {\n external?: boolean;\n name?: string;\n path: string;\n };\n title: string;\n }[];\n gridStyles?: {\n columns?: '4' | '3' | '2' | '1';\n centered?: boolean;\n gapSize?: number;\n };\n tileStyles?: {\n imageSize?: 'none' | 'xsmall' | 'small' | 'medium' | 'large';\n outlined?: boolean;\n rounded?: boolean;\n titleSize?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';\n };\n }\n >\n | BlockConfigBase<\n 'table',\n {\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'pattern-variations',\n {\n patternId?: string;\n templateId?: string;\n demoId?: string;\n variationId?: string;\n assetSetId?: string;\n excludePropValue?: string;\n includePropValue?: string;\n size?: 's' | 'm' | 'l' | 'full';\n hideBlockTitle?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-tokens',\n {\n tokenType: TokenType | '';\n demoId: string;\n groupIds: string[];\n exclude?: string;\n include?: string;\n }\n >\n | BlockConfigBase<\n 'design-token-collection',\n {\n collectionId: string;\n }\n >\n | BlockConfigBase<\n 'pattern-list-block',\n {\n itemSize?: 'small' | 'medium' | 'large' | 'full';\n showDescriptions?: boolean;\n excludePatterns?: string[];\n }\n >\n | BlockConfigBase<\n 'pattern-status-table-block',\n {\n excludeHiddenNavItems?: boolean;\n excludePatterns?: string[];\n }\n >\n | BlockConfigBase<\n 'video',\n {\n video: {\n format: string;\n name: string;\n size: string;\n url: string;\n };\n }\n >\n /** @deprecated */\n | BlockConfigBase<\n 'design-token-block',\n {\n tokens?: {\n type?: TokenType;\n category?: string;\n tags?: string[];\n name?: string;\n exclude?: string;\n };\n demo?: {\n id?: string;\n };\n }\n >\n | BlockConfigBase<'generic-iframe', IframeBlockData>\n | BlockConfigBase<'abstract-block', IframeBlockData>\n | BlockConfigBase<'adobe-xd-block', IframeBlockData>\n | BlockConfigBase<'airtable-block', IframeBlockData>\n | BlockConfigBase<'figma-block', IframeBlockData>\n | BlockConfigBase<'framer-cloud-block', IframeBlockData>\n | BlockConfigBase<'lucidchart-block', IframeBlockData>\n | BlockConfigBase<'vimeo-block', IframeBlockData>\n | BlockConfigBase<'youtube-block', IframeBlockData>\n | BlockConfigBase<'whimsical-block', IframeBlockData>\n | BlockConfigBase<\n 'markdown-block',\n {\n md?: string | string[];\n /** Automatically switches to edit mode + autofocuses on the editor */\n autoEdit?: boolean;\n columns?: number;\n }\n >;\n\n/**\n * This is the config for a block - which is what is stored in `block.ID.json` and available at `data.db.blocks.byId[blockId]`\n *\n * @example\n * // Use the first generic to filter down to a specific block type\n * type PatternListBlockConfig = BlockConfig<'pattern-list-block'>;\n * // Access the field `data` by doing this:\n * type Data= BlockConfig<'pattern-list-block'>['data'];\n */\nexport type BlockConfig<\n BlockType extends BlockConfigUnion['blockType'] = BlockConfigUnion['blockType'],\n> = Extract<BlockConfigUnion, { blockType: BlockType }>;\n\n/** Block Collections can be in several locations */\nexport type BlockCollectionLocation =\n | {\n type: 'page';\n pageId: string;\n }\n /** Tab on Pattern Page */\n | {\n type: 'patternSubPage';\n patternId: string;\n subPageId: string;\n }\n /** At bottom of Pattern Template page (under Spec table) - least used location */\n | {\n type: 'patternTemplate';\n patternId: string;\n templateId: string;\n };\n","export const tokenNameDisplayFormats = {\n default: 'Default',\n android: 'Android',\n cssVar: 'CSS Var',\n json: 'JSON',\n less: 'Less',\n scss: 'SCSS',\n swift: 'Swift',\n} as const;\n\nexport type TokenNameDisplayFormat = keyof typeof tokenNameDisplayFormats;\n","import { Simplify, expectType, isObjKey, isObject } from '@knapsack/utils';\nimport * as s from 'superstruct';\nimport {\n NotTokenReference,\n TokenDefinition,\n TokenDefinitionComposite,\n TokenDefinitionSingular,\n TokenReference,\n TokenReferenceStruct,\n TokenType,\n hasTokenReferences,\n isTokenTypeComposite,\n} from './token-definitions';\nimport { TokenKsExtensions, TokenOrder } from './token-misc';\nimport { TokenSrcValue } from './token-src';\n\n/** Used for tokens AND groups */\ntype TokenDataBothCommon = {\n id: string;\n description?: string;\n};\n\n// Shows what a fully de-referenced `value` of a composite token would be\ntype CreateDataValueForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]: TokenDefinitionSingular<\n ValueObj[Key]['type']\n >['value'];\n};\n\nexpectType<\n CreateDataValueForComposite<TokenDefinitionComposite<'shadow'>['value']>[]\n>([\n {\n inset: false,\n color: '#000',\n offsetX: '0px',\n offsetY: '0px',\n spread: '0px',\n blur: '0px',\n },\n {\n color: '#000',\n offsetX: '0px',\n offsetY: '0px',\n spread: '0px',\n blur: '0px',\n inset: true,\n },\n]);\n\ntype TokenDataCommon<\n Info extends {\n /** Basically the ID */\n type: TokenDefinition['type'];\n value: unknown;\n },\n> = TokenDataBothCommon & {\n type: Info['type'];\n value: Info['value'];\n /**\n * Extracted from `$extensions['cloud.knapsack'].token`\n */\n tokenConfig?: TokenKsExtensions['token'];\n /**\n * Tokens that are references by this token\n * @todo will need to change for shadow\n * @example\n * ```\n * [\n * ['color.primary', 'color.secondary'],\n * ['spacing.medium']\n * ]\n * ```\n */\n references?: Array<string[]>;\n /**\n * Tokens that use this as a reference token\n * @see {CreateTokenData.references}\n * @example\n * * ```\n * [\n * ['color.primary', 'color.secondary'],\n * ['spacing.medium']\n * ]\n * ```\n */\n // referencedBy?: Array<string[]>;\n};\n\ntype CreateTokenData<\n Info extends {\n type: TokenDefinition['type'];\n value: unknown;\n },\n> =\n | ({\n kind: 'ref';\n /** Has `{}` removed */\n referencedTokenId: string;\n originalValue: TokenReference;\n } & TokenDataCommon<Info>)\n | ({\n kind: 'static';\n originalValue: NotTokenReference<TokenSrcValue<Info['type']>>;\n } & TokenDataCommon<Info>);\n\nconst TokenDataBaseStruct: s.Describe<\n TokenDataBothCommon & {\n references?: Array<string[]>;\n tokenConfig?: TokenKsExtensions['token'];\n }\n> = s.type({\n id: s.string(),\n description: s.optional(s.string()),\n references: s.optional(s.array(s.array(s.string()))),\n tokenConfig: s.optional(\n s.type({\n purpose: s.optional(s.string()),\n }),\n ),\n});\n\ntype TokenDataSingularRaw = {\n // ignore the key, this makes a discriminated union out of the values\n [TokenDef in TokenDefinitionSingular as TokenDef['type']]: Simplify<\n CreateTokenData<TokenDef>\n >;\n}[TokenDefinitionSingular['type']];\n\nexport type TokenDataSingular<\n TT extends TokenDataSingularRaw['type'] = TokenDataSingularRaw['type'],\n> = Extract<TokenDataSingularRaw, { type: TT }>;\n\nexpectType<TokenDataSingular[]>([\n {\n type: 'duration',\n value: '1ms',\n originalValue: '1ms',\n id: '1',\n kind: 'static',\n },\n {\n type: 'duration',\n value: '1ms',\n kind: 'ref',\n id: '1',\n originalValue: '{a.b}',\n referencedTokenId: '1',\n },\n // @ts-expect-error - kind is wrong\n {\n type: 'duration',\n value: '1ms',\n originalValue: '1ms',\n id: '1',\n kind: 'ref',\n },\n // @ts-expect-error - kind is wrong\n {\n type: 'duration',\n value: '1ms',\n kind: 'static',\n id: '1',\n originalValue: '{a.b}',\n referencedTokenId: '1',\n },\n {\n type: 'color',\n value: '#000',\n kind: 'static',\n id: '1',\n originalValue: '#000',\n },\n {\n type: 'color',\n value: '#000',\n kind: 'ref',\n id: '1',\n originalValue: '{c.b}',\n referencedTokenId: 'c.b',\n },\n {\n type: 'cubicBezier',\n kind: 'static',\n value: [0, 0, 0, 1],\n originalValue: [0, 0, 0, 1],\n id: '1',\n },\n]);\n\ntype TokenDataCompositeRaw = {\n [TokenType in TokenDefinitionComposite['type']]: Simplify<\n CreateTokenData<{\n type: TokenType;\n value: Simplify<\n CreateDataValueForComposite<\n TokenDefinitionComposite<TokenType>['value']\n >\n >;\n }>\n >;\n}[TokenDefinitionComposite['type']];\n\nexport type TokenDataComposite<\n TheTokenType extends TokenDataCompositeRaw['type'] = TokenDataCompositeRaw['type'],\n> = Extract<TokenDataCompositeRaw, { type: TheTokenType }>;\n\nexport function isTokenDataComposite(\n tokenData: TokenData,\n): tokenData is TokenDataComposite {\n return isTokenTypeComposite(tokenData.type);\n}\n\nexpectType<TokenDataComposite[]>([\n {\n type: 'border',\n kind: 'static',\n id: '1',\n value: {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n originalValue: {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n },\n {\n type: 'border',\n kind: 'ref',\n referencedTokenId: 'a.b',\n id: '1',\n value: {\n color: 'red',\n style: 'dashed',\n width: '2px',\n },\n originalValue: '{a.b}',\n },\n {\n type: 'shadow',\n value: {\n color: '#000',\n offsetX: '1px',\n offsetY: '1px',\n blur: '1px',\n spread: '1px',\n inset: false,\n },\n originalValue: {\n color: '#000',\n offsetX: '{a.a}',\n offsetY: '1px',\n blur: '1px',\n spread: '1px',\n inset: false,\n },\n id: '1',\n kind: 'static',\n },\n {\n type: 'shadow',\n kind: 'ref',\n referencedTokenId: 'a.b',\n value: {\n inset: true,\n color: 'red',\n offsetX: '1px',\n blur: '2px',\n offsetY: '3px',\n spread: '4px',\n },\n originalValue: '{a.b}',\n id: '1',\n },\n {\n type: 'transition',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: '{a.b}',\n kind: 'ref',\n referencedTokenId: 'a.b',\n id: '1',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: {\n duration: '100ms',\n delay: '{a.c}',\n timingFunction: '{a.c}',\n },\n id: '1',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n id: '1',\n },\n]);\n\nexport type TokenData<\n TheTokenType extends TokenDataSingular['type'] | TokenDataComposite['type'] =\n | TokenDataSingular['type']\n | TokenDataComposite['type'],\n> = Extract<TokenDataSingular | TokenDataComposite, { type: TheTokenType }>;\n\nexport type TokenGroupData = Simplify<\n {\n type?: TokenType;\n /**\n * Extracted from `$extensions['cloud.knapsack'].group`\n */\n groupConfig?: TokenKsExtensions['group'];\n children: TokenOrder;\n } & TokenDataBothCommon\n>;\n\n/**\n * @deprecated Use `TokenValueColorStruct` instead\n */\nexport function isTokenValueColor(\n value: unknown,\n): value is TokenDefinitionSingular<'color'>['value'] {\n return typeof value === 'string' && !hasTokenReferences(value);\n}\n\nexport const TokenValueColorStruct = s.define<TokenData<'color'>['value']>(\n 'Color Value',\n (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (value === '') {\n return 'Value must not be empty';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n return true;\n },\n);\n\nconst TokenDataColorNonRefStruct: s.Describe<\n Extract<TokenData<'color'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('color'),\n value: TokenValueColorStruct,\n kind: s.literal('static'),\n originalValue: TokenValueColorStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataColorRefStruct: s.Describe<\n Extract<TokenData<'color'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('color'),\n value: TokenValueColorStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueDimensionStruct` instead\n */\nexport function isTokenValueDimension(\n value: unknown,\n): value is TokenDefinitionSingular<'dimension'>['value'] {\n return (\n typeof value === 'string' &&\n (value.endsWith('px') || value.endsWith('rem')) &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueDimensionStruct = s.define<\n TokenData<'dimension'>['value']\n>('Dimension Value', (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n if (\n !value.endsWith('px') &&\n !value.endsWith('rem') &&\n !value.endsWith('em') &&\n !value.endsWith('%')\n ) {\n return 'Value must end with px, rem, em or %';\n }\n return true;\n});\n\nconst TokenDataDimensionNonRefStruct: s.Describe<\n Extract<TokenData<'dimension'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('dimension'),\n value: TokenValueDimensionStruct,\n kind: s.literal('static'),\n originalValue: TokenValueDimensionStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataDimensionRefStruct: s.Describe<\n Extract<TokenData<'dimension'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('dimension'),\n value: TokenValueDimensionStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueDurationStruct` instead\n */\nexport function isTokenValueDuration(\n value: unknown,\n): value is TokenDefinitionSingular<'duration'>['value'] {\n return (\n typeof value === 'string' &&\n value.endsWith('ms') &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueDurationStruct = s.define<\n TokenData<'duration'>['value']\n>('Duration Value', (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n\n const durationRegex = /^\\d+ms$/;\n if (!durationRegex.test(value)) {\n return 'Value must be a number followed by \"ms\" (e.g., \"100ms\")';\n }\n\n return true;\n});\n\nconst TokenDataDurationNonRefStruct: s.Describe<\n Extract<TokenData<'duration'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('duration'),\n value: TokenValueDurationStruct,\n kind: s.literal('static'),\n originalValue: TokenValueDurationStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataDurationRefStruct: s.Describe<\n Extract<TokenData<'duration'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('duration'),\n value: TokenValueDurationStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueFontWeightStruct` instead\n */\nexport function isTokenValueFontWeight(\n value: unknown,\n): value is TokenDefinitionSingular<'fontWeight'>['value'] {\n return (\n (typeof value === 'string' || typeof value === 'number') &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueFontWeightStruct = s.define<\n TokenData<'fontWeight'>['value']\n>('Font Weight Value', (value) => {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return 'Value must be a string or number';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n return true;\n});\n\nconst TokenDataFontWeightNonRefStruct: s.Describe<\n Extract<TokenData<'fontWeight'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('fontWeight'),\n value: TokenValueFontWeightStruct,\n kind: s.literal('static'),\n originalValue: TokenValueFontWeightStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataFontWeightRefStruct: s.Describe<\n Extract<TokenData<'fontWeight'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('fontWeight'),\n value: TokenValueFontWeightStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nexport const TokenValueCubicBezierStruct = s.define<\n TokenData<'cubicBezier'>['value']\n>('Cubic Bezier Value', (value) => {\n if (!Array.isArray(value)) {\n return 'Value must be an array';\n }\n if (value.length !== 4) {\n return 'Value must be an array of 4 numbers';\n }\n if (!value.every((v) => typeof v === 'number')) {\n return 'Value must be an array of 4 numbers';\n }\n // check if the first and third values are between 0 and 1\n // cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )\n if (value[0] < 0 || value[0] > 1 || value[2] < 0 || value[2] > 1) {\n return 'The first and third cubicBezier values must be between 0 and 1';\n }\n return true;\n});\n\nconst TokenDataCubicBezierNonRefStruct: s.Describe<\n Extract<TokenData<'cubicBezier'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('cubicBezier'),\n value: TokenValueCubicBezierStruct,\n kind: s.literal('static'),\n originalValue: TokenValueCubicBezierStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataCubicBezierRefStruct: s.Describe<\n Extract<TokenData<'cubicBezier'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('cubicBezier'),\n value: TokenValueCubicBezierStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * Determines if it's a \"shadow\" token value AND totally de-referenced\n */\nexport function isTokenValueShadow(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'shadow'>['value']>\n> {\n return (\n isObject(value) &&\n isTokenValueColor(value.color) &&\n isTokenValueDimension(value.offsetX) &&\n isTokenValueDimension(value.offsetY) &&\n isTokenValueDimension(value.blur) &&\n isTokenValueDimension(value.spread)\n );\n}\n\nconst TokenValueShadowStruct = s.define<TokenData<'shadow'>['value']>(\n 'Shadow Value',\n (value) => {\n if (isTokenValueShadow(value)) return true;\n return `Expected a shadow value, got ${JSON.stringify(value)}`;\n },\n);\n\nconst TokenDataShadowNonRefStruct: s.Describe<\n Extract<TokenData<'shadow'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('shadow'),\n value: TokenValueShadowStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n color: s.union([TokenValueColorStruct, TokenReferenceStruct]),\n offsetX: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n offsetY: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n blur: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n spread: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n inset: s.union([\n // marking this as optional b/c it could be `undefined` instead of `false`\n s.optional(s.boolean()),\n TokenReferenceStruct,\n ]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataShadowRefStruct: s.Describe<\n Extract<TokenData<'shadow'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('shadow'),\n value: TokenValueShadowStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nexport const TokenValueStrokeStyleStruct = s.union([\n s.literal('solid'),\n s.literal('dashed'),\n s.literal('dotted'),\n s.literal('double'),\n s.literal('groove'),\n s.literal('ridge'),\n s.literal('outset'),\n s.literal('inset'),\n]);\n\n/**\n * Determines if it's a \"border\" token value AND totally de-referenced\n */\nexport function isTokenValueBorder(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'border'>['value']>\n> {\n return (\n isObject(value) &&\n TokenValueColorStruct.is(value.color) &&\n TokenValueStrokeStyleStruct.is(value.style) &&\n TokenValueDimensionStruct.is(value.width)\n );\n}\n\nconst TokenValueBorderStruct = s.define<TokenData<'border'>['value']>(\n 'Border Value',\n isTokenValueBorder,\n);\n\nconst TokenDataBorderNonRefStruct: s.Describe<\n Extract<TokenData<'border'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('border'),\n value: TokenValueBorderStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n color: s.union([TokenValueColorStruct, TokenReferenceStruct]),\n style: s.union([TokenValueStrokeStyleStruct, TokenReferenceStruct]),\n width: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBorderRefStruct: s.Describe<\n Extract<TokenData<'border'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('border'),\n value: TokenValueBorderStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * Determines if it's a \"transition\" token value AND totally de-referenced\n */\nexport function isTokenValueTransition(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'transition'>['value']>\n> {\n return (\n isObject(value) &&\n TokenValueCubicBezierStruct.is(value.timingFunction) &&\n TokenValueDurationStruct.is(value.duration) &&\n TokenValueDurationStruct.is(value.delay)\n );\n}\nconst TokenValueTransitionStruct = s.define<TokenData<'transition'>['value']>(\n 'Transition Value',\n isTokenValueTransition,\n);\n\nconst TokenDataTransitionNonRefStruct: s.Describe<\n Extract<TokenData<'transition'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('transition'),\n value: TokenValueTransitionStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n timingFunction: s.union([\n TokenValueCubicBezierStruct,\n TokenReferenceStruct,\n ]),\n duration: s.union([TokenValueDurationStruct, TokenReferenceStruct]),\n delay: s.union([TokenValueDurationStruct, TokenReferenceStruct]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataTransitionRefStruct: s.Describe<\n Extract<TokenData<'transition'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('transition'),\n value: TokenValueTransitionStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStringNonRefStruct: s.Describe<\n Extract<TokenData<'string'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('string'),\n value: s.string(),\n kind: s.literal('static'),\n originalValue: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStringRefStruct: s.Describe<\n Extract<TokenData<'string'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('string'),\n value: s.string(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStrokeStyleNonRefStruct: s.Describe<\n Extract<TokenData<'strokeStyle'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('strokeStyle'),\n value: TokenValueStrokeStyleStruct,\n kind: s.literal('static'),\n originalValue: TokenValueStrokeStyleStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStrokeStyleRefStruct: s.Describe<\n Extract<TokenData<'strokeStyle'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('strokeStyle'),\n value: TokenValueStrokeStyleStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: TokenValueStrokeStyleStruct,\n }),\n TokenDataBaseStruct,\n);\n// const TokenDataFontFamilyNonRefStruct: s.Describe<\n// Extract<TokenData<'fontFamily'>, { kind: 'static' }>\n// > = s.assign(\n// s.type({\n// type: s.literal('fontFamily'),\n// value: s.union([s.string(), s.array(s.string())]),\n// kind: s.literal('static'),\n// originalValue: s.union([s.string(), s.array(s.string())]),\n// }),\n// TokenDataBaseStruct,\n// );\n\n// const TokenDataFontFamilyRefStruct: s.Describe<\n// Extract<TokenData<'fontFamily'>, { kind: 'ref' }>\n// > = s.assign(\n// s.type({\n// type: s.literal('fontFamily'),\n// value: s.union([s.string(), s.array(s.string())]),\n// kind: s.literal('ref'),\n// originalValue: TokenReferenceStruct,\n// referencedTokenId: s.string(),\n// }),\n// TokenDataBaseStruct,\n// );\n\nconst TokenDataNumberNonRefStruct: s.Describe<\n Extract<TokenData<'number'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('number'),\n value: s.number(),\n kind: s.literal('static'),\n originalValue: s.number(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataNumberRefStruct: s.Describe<\n Extract<TokenData<'number'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('number'),\n value: s.number(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBooleanNonRefStruct: s.Describe<\n Extract<TokenData<'boolean'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('boolean'),\n value: s.boolean(),\n kind: s.literal('static'),\n originalValue: s.boolean(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBooleanRefStruct: s.Describe<\n Extract<TokenData<'boolean'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('boolean'),\n value: s.boolean(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n// Instead of using `s.union` to combine all the token data structs,\n// we first find out what \"type\" the token is\n// then we find out `kind` - which is our 2nd layer of discriminated union\n// and then use the specific struct\n// that way the errors are more specific to the actual declared token \"type\"\n// In a nutshell, `s.union` is not very good at discriminated unions errors\nexport const assertTokenData = (data: unknown): asserts data is TokenData => {\n if (!isObject(data)) {\n throw new Error(\n `Expected token data to be an object, got ${JSON.stringify(data)}`,\n );\n }\n if (!isObjKey('type', data)) {\n throw new Error(\n `Expected token data to have a \"type\" property, got ${JSON.stringify(\n data,\n )}`,\n );\n }\n if (typeof data.type !== 'string') {\n throw new Error(\n `Expected token data \"type\" property to be a string, got ${JSON.stringify(\n data,\n )}`,\n );\n }\n const type = data.type as TokenData['type'];\n const kind = data.kind as TokenData['kind'];\n try {\n switch (type) {\n case 'boolean':\n if (kind === 'ref') {\n TokenDataBooleanRefStruct.assert(data);\n } else {\n TokenDataBooleanNonRefStruct.assert(data);\n }\n return;\n case 'border':\n if (kind === 'ref') {\n TokenDataBorderRefStruct.assert(data);\n } else {\n TokenDataBorderNonRefStruct.assert(data);\n }\n return;\n case 'color':\n if (kind === 'ref') {\n TokenDataColorRefStruct.assert(data);\n } else {\n TokenDataColorNonRefStruct.assert(data);\n }\n return;\n case 'cubicBezier':\n if (kind === 'ref') {\n TokenDataCubicBezierRefStruct.assert(data);\n } else {\n TokenDataCubicBezierNonRefStruct.assert(data);\n }\n return;\n case 'dimension':\n if (kind === 'ref') {\n TokenDataDimensionRefStruct.assert(data);\n } else {\n TokenDataDimensionNonRefStruct.assert(data);\n }\n return;\n case 'duration':\n if (kind === 'ref') {\n TokenDataDurationRefStruct.assert(data);\n } else {\n TokenDataDurationNonRefStruct.assert(data);\n }\n return;\n case 'fontWeight':\n if (kind === 'ref') {\n TokenDataFontWeightRefStruct.assert(data);\n } else {\n TokenDataFontWeightNonRefStruct.assert(data);\n }\n return;\n case 'number':\n if (kind === 'ref') {\n TokenDataNumberRefStruct.assert(data);\n } else {\n TokenDataNumberNonRefStruct.assert(data);\n }\n return;\n case 'shadow':\n if (kind === 'ref') {\n TokenDataShadowRefStruct.assert(data);\n } else {\n TokenDataShadowNonRefStruct.assert(data);\n }\n return;\n case 'string':\n if (kind === 'ref') {\n TokenDataStringRefStruct.assert(data);\n } else {\n TokenDataStringNonRefStruct.assert(data);\n }\n return;\n case 'strokeStyle': // temp implementation\n if (kind === 'ref') {\n TokenDataStrokeStyleRefStruct.assert(data);\n } else {\n TokenDataStrokeStyleNonRefStruct.assert(data);\n }\n return;\n // case 'fontFamily':\n // if (kind === 'ref') {\n // TokenDataFontFamilyRefStruct.assert(data);\n // } else {\n // TokenDataFontFamilyNonRefStruct.assert(data);\n // }\n // return;\n case 'transition':\n if (kind === 'ref') {\n TokenDataTransitionRefStruct.assert(data);\n } else {\n TokenDataTransitionNonRefStruct.assert(data);\n }\n return;\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`Unknown token data type: ${type}`);\n }\n }\n } catch (error) {\n if (!(error instanceof s.StructError)) throw error;\n throw new Error(\n `Invalid token data for type \"${type}\": ${\n error.message\n }. Received this data: \"${JSON.stringify(data)}\"`,\n );\n }\n};\n","import * as s from 'superstruct';\n\nexport const strokeStyleValues = [\n 'solid',\n 'dashed',\n 'dotted',\n 'double',\n 'groove',\n 'ridge',\n 'outset',\n 'inset',\n] as const;\n\n/**\n * Don't use this one, use this instead:\n * @see {@link TokenDefinitionSingular}\n */\ntype TokenDefinitionSingularRaw =\n | { type: 'string'; value: string }\n | { type: 'number'; value: number }\n | { type: 'boolean'; value: boolean }\n | { type: 'color'; value: string }\n | {\n type: 'strokeStyle';\n value: (typeof strokeStyleValues)[number];\n }\n | { type: 'dimension'; value: `${number}${'px' | 'rem' | 'em' | '%'}` }\n | { type: 'duration'; value: `${number}ms` }\n // | { type: 'fontFamily'; value: string | string[] }\n | {\n type: 'fontWeight';\n // @TODO: Include union of possible strings https://tr.designtokens.org/format/#font-weight\n value: string | number;\n }\n | { type: 'cubicBezier'; value: [number, number, number, number] };\n\n/**\n * Definitions for both singular (non-composite) tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionDimension = TokenDefinitionSingular<'dimension'>\n * ```\n */\nexport type TokenDefinitionSingular<\n TheTokenType extends TokenDefinitionSingularRaw['type'] = TokenDefinitionSingularRaw['type'],\n> = Extract<TokenDefinitionSingularRaw, { type: TheTokenType }>;\n\n/**\n * Don't use this one, use this instead:\n * @see {@link TokenDefinitionComposite}\n */\ntype TokenDefinitionCompositeRaw =\n | {\n type: 'border';\n value: {\n color: { type: 'color' };\n style: { type: 'strokeStyle' };\n width: { type: 'dimension' };\n };\n }\n | {\n type: 'shadow';\n value: {\n color: { type: 'color' };\n offsetX: { type: 'dimension' };\n offsetY: { type: 'dimension' };\n spread: { type: 'dimension' };\n blur: { type: 'dimension' };\n inset: { type: 'boolean' };\n };\n }\n | {\n type: 'transition';\n value: {\n duration: { type: 'duration' };\n delay: { type: 'duration' };\n timingFunction: { type: 'cubicBezier' };\n };\n };\n// | {\n// type: 'gradient';\n// value: {\n// color: { type: 'color' };\n// position: { type: 'dimension' };\n// }[];\n// };\n\n/**\n * Definitions for composite tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionShadow = TokenDefinitionComposite<'shadow'>\n * ```\n */\nexport type TokenDefinitionComposite<\n TheTokenType extends TokenDefinitionCompositeRaw['type'] = TokenDefinitionCompositeRaw['type'],\n> = Extract<TokenDefinitionCompositeRaw, { type: TheTokenType }>;\n\n/**\n * Definitions for both singular and composite tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionDimension = TokenDefinition<'dimension'>\n * ```\n */\nexport type TokenDefinition<\n TheTokenType extends\n | TokenDefinitionComposite['type']\n | TokenDefinitionSingular['type'] =\n | TokenDefinitionComposite['type']\n | TokenDefinitionSingular['type'],\n> = Extract<\n TokenDefinitionComposite | TokenDefinitionSingular,\n { type: TheTokenType }\n>;\n\nexport type TokenReference = `{${string}}`;\n/** ensures there is no `{}` */\nexport type NotTokenReference<T> = T extends TokenReference ? never : T;\n\nexport function isTokenReference(val: unknown): val is TokenReference {\n if (typeof val !== 'string') return false;\n // total times `{` appears in `val`\n // Handle situation `{a.b} {c.d}`. Ensure count of `{` and `}` === 1. This\n // guarantees we ONLY support a single reference, ie `{a.b}`\n const totalOpenBrackets = val.split('{').length - 1;\n return totalOpenBrackets === 1 && val.startsWith('{') && val.endsWith('}');\n}\n\nexport function hasTokenReferences(val: unknown): boolean {\n return typeof val === 'string' && val.includes('{');\n}\n\nexport function isNotTokenReference<T>(\n value: T,\n): value is NotTokenReference<T> {\n return !isTokenReference(value);\n}\n\nexport const TokenReferenceStruct = s.define<TokenReference>(\n 'Token Reference',\n (value) => {\n if (typeof value !== 'string') return false;\n if (isNotTokenReference(value)) {\n return 'Must start and end with curly braces';\n }\n return true;\n },\n);\n\nexport type TokenType = TokenDefinition['type'];\nexport type TokenTypeComposite = TokenDefinitionComposite['type'];\nexport type TokenTypeSingular = TokenDefinitionSingular['type'];\nexport type TokenValueSingular = TokenDefinitionSingular['value'];\n\n// We make a Record to ensure we have *every* possible value\n// b/c TS will yell at us if a new one is added but isn't included here\n// then we make an array out of them, so we can be sure we have *every* possible value\nconst compositeTypesRecord: Record<TokenTypeComposite, TokenTypeComposite> = {\n border: 'border',\n shadow: 'shadow',\n transition: 'transition',\n};\nexport const tokenTypeComposites = Object.values(compositeTypesRecord);\nconst singularTypesRecord: Record<TokenTypeSingular, TokenTypeSingular> = {\n string: 'string',\n number: 'number',\n boolean: 'boolean',\n color: 'color',\n dimension: 'dimension',\n duration: 'duration',\n // fontFamily: 'fontFamily',\n fontWeight: 'fontWeight',\n strokeStyle: 'strokeStyle',\n cubicBezier: 'cubicBezier',\n};\nexport const tokenTypeSingulars = Object.values(singularTypesRecord);\n/**\n * @deprecated You probably want `isTokenDataComposite`\n * @see {isTokenDataComposite}\n */\nexport function isTokenTypeComposite(\n type: TokenType,\n): type is TokenTypeComposite {\n return tokenTypeComposites.includes(type as TokenTypeComposite);\n}\n\nexport function isTokenTypeSingular(\n type: TokenType,\n): type is TokenTypeSingular {\n return tokenTypeSingulars.includes(type as TokenTypeSingular);\n}\n","import { Simplify, expectType } from '@knapsack/utils';\nimport {\n TokenType,\n TokenDefinitionSingular,\n TokenDefinitionComposite,\n isTokenTypeComposite,\n isTokenTypeSingular,\n} from './token-definitions';\n\ntype CreateTokenSrcValueInfo<\n T extends {\n type: TokenType;\n value: unknown;\n },\n> =\n | {\n kind: 'ref';\n /** Has `{}` removed */\n referencedTokenId: string;\n isVarRef?: boolean;\n type: T['type'];\n }\n | {\n kind: 'static';\n type: T['type'];\n value: T['value'];\n };\n\ntype TokenSrcValueInfoSingularRaw = {\n // Ignore the key, pay attention to the value\n // The values become the items in the discriminated union\n [TheTokenType in TokenDefinitionSingular as TheTokenType['type']]: Simplify<\n CreateTokenSrcValueInfo<TheTokenType>\n >;\n}[TokenDefinitionSingular['type']];\n\n// This helper allows us to just pass the type string in to get that\n// item out of the discriminated union: `TokenSrcValueInfoSingular<'color'>`\ntype TokenSrcValueInfoSingular<\n TT extends TokenSrcValueInfoSingularRaw['type'] = TokenSrcValueInfoSingularRaw['type'],\n> = Extract<TokenSrcValueInfoSingularRaw, { type: TT }>;\n\nexpectType<TokenSrcValueInfoSingular<'dimension'>[]>([\n {\n type: 'dimension',\n kind: 'static',\n value: '1px',\n },\n {\n type: 'dimension',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n]);\n\ntype CreateSrcValueInfoForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]: Simplify<\n CreateTokenSrcValueInfo<{\n type: ValueObj[Key]['type'];\n value: TokenDefinitionSingular<ValueObj[Key]['type']>['value'];\n }>\n >;\n};\n\ntype TokenSrcValueInfoCompositeRaw = {\n [TheTokenType in TokenDefinitionComposite['type']]: Simplify<\n CreateTokenSrcValueInfo<{\n type: TheTokenType;\n value: Simplify<\n CreateSrcValueInfoForComposite<\n TokenDefinitionComposite<TheTokenType>['value']\n >\n >;\n }>\n >;\n}[TokenDefinitionComposite['type']];\n\ntype TokenSrcValueInfoComposite<\n TT extends TokenSrcValueInfoCompositeRaw['type'] = TokenSrcValueInfoCompositeRaw['type'],\n> = Extract<TokenSrcValueInfoCompositeRaw, { type: TT }>;\n\nexpectType<TokenSrcValueInfoComposite<'border'>[]>([\n {\n type: 'border',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'border',\n kind: 'static',\n value: {\n color: {\n kind: 'static',\n type: 'color',\n value: 'red',\n },\n style: {\n kind: 'ref',\n type: 'strokeStyle',\n referencedTokenId: '', // FIX\n },\n width: {\n kind: 'static',\n type: 'dimension',\n value: '2px',\n },\n },\n },\n]);\n\nexpectType<TokenSrcValueInfoComposite<'transition'>[]>([\n {\n type: 'transition',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n delay: {\n kind: 'static',\n type: 'duration',\n value: '1ms',\n },\n duration: {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n timingFunction: {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n },\n },\n]);\n\nexport type TokenSrcValueInfo<\n TT extends\n | TokenSrcValueInfoComposite['type']\n | TokenSrcValueInfoSingular['type'] =\n | TokenSrcValueInfoComposite['type']\n | TokenSrcValueInfoSingular['type'],\n TheKind extends\n | TokenSrcValueInfoComposite['kind']\n | TokenSrcValueInfoSingular['kind'] =\n | TokenSrcValueInfoComposite['kind']\n | TokenSrcValueInfoSingular['kind'],\n> = Extract<\n TokenSrcValueInfoComposite | TokenSrcValueInfoSingular,\n { type: TT; kind: TheKind }\n>;\n\nexport function isTokenSrcValueInfoSingular(\n tokenSrcValueInfo: TokenSrcValueInfo,\n): tokenSrcValueInfo is TokenSrcValueInfoSingular {\n return isTokenTypeSingular(tokenSrcValueInfo?.type);\n}\nexport function isTokenSrcValueInfoComposite(\n tokenSrcValueInfo: TokenSrcValueInfo,\n): tokenSrcValueInfo is TokenSrcValueInfoComposite {\n return isTokenTypeComposite(tokenSrcValueInfo?.type);\n}\n\nexpectType<TokenSrcValueInfo[]>([\n {\n type: 'dimension',\n kind: 'static',\n value: '1px',\n },\n {\n type: 'transition',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'transition',\n kind: 'ref',\n // @ts-expect-error - with `kind: 'ref'`, `value` is not allowed\n value: '1px',\n },\n {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n delay: {\n kind: 'static',\n type: 'duration',\n value: '1ms',\n },\n duration: {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n timingFunction: {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n },\n },\n]);\n\n/**\n * A common object that is used to represent a token in the app.\n * Used in functions for editing communication between UI forms, Xstate,\n * and `@knapsack/design-tokens-utils`.\n */\nexport type TokenInfo<\n TheTokenType extends TokenSrcValueInfo['type'] = TokenSrcValueInfo['type'],\n> = {\n tokenSrcValueInfo: TokenSrcValueInfo<TheTokenType>;\n tokenId: string;\n description?: string;\n};\n","import { Simplify, expectType, isObjKey, isObject } from '@knapsack/utils';\nimport {\n TokenDefinitionComposite,\n TokenDefinitionSingular,\n TokenReference,\n TokenType,\n TokenDefinition,\n} from './token-definitions';\nimport { TokenKsExtensions } from './token-misc';\n\nexport type TokenSrcCommon<TheType extends TokenType = TokenType> = {\n $type?: TokenDefinition<TheType>['type'];\n $description?: string;\n $extensions?: {\n 'cloud.knapsack'?: TokenKsExtensions;\n };\n};\n\nexport function isTokenSrcExtensions(\n extensionsObj: unknown,\n): extensionsObj is TokenSrcCommon['$extensions'] {\n return isObject(extensionsObj) && isObjKey('cloud.knapsack', extensionsObj);\n}\n\ntype CreateSrcValueForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]:\n | TokenReference\n | TokenDefinitionSingular<ValueObj[Key]['type']>['value'];\n};\n\ntype TokenSrcValueCompositeRaw = {\n [TheTokenType in TokenDefinitionComposite['type']]: Simplify<{\n type: TheTokenType;\n value: Simplify<\n CreateSrcValueForComposite<\n TokenDefinitionComposite<TheTokenType>['value']\n >\n >;\n }>;\n}[TokenDefinitionComposite['type']];\n\ntype TokenSrcValueComposite<\n TT extends TokenSrcValueCompositeRaw['type'] = TokenSrcValueCompositeRaw['type'],\n> = Extract<TokenSrcValueCompositeRaw, { type: TT }>;\n\ntype TokenSrcValueRaw = TokenDefinitionSingular | TokenSrcValueComposite;\n\nexport type TokenSrcValue<\n Type extends\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'] =\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'],\n> = Extract<TokenSrcValueRaw, { type: Type }>['value'] | TokenReference;\n\nexpectType<TokenSrcValue[]>([\n '#ddd',\n true,\n [83, 1, 1, 1],\n {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n {\n inset: true,\n color: '#000',\n offsetX: '0px',\n offsetY: '{spacing.medium}',\n spread: '0px',\n blur: '0px',\n },\n {\n timingFunction: '{timing.ease}',\n duration: '{timing.duration.medium}',\n delay: '7ms',\n color: '#000',\n },\n]);\n\nexport type TokenSrc<\n TheType extends\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'] =\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'],\n> = Simplify<\n {\n $value: TokenSrcValue<TheType>;\n } & TokenSrcCommon<TheType>\n>;\n\nexport function isTokenSrc(tokenObject: unknown): tokenObject is TokenSrc {\n if (isObject(tokenObject) && isObjKey('$value', tokenObject)) return true;\n return false;\n}\n\nexport type TokenSrcGroup = TokenSrcCommon & {\n [key: string]:\n | TokenSrcGroup\n | TokenSrc\n | TokenSrcCommon\n | TokenSrcCommon['$extensions'];\n};\n\nexport function isTokenGroup(\n tokenObject: unknown,\n): tokenObject is TokenSrcGroup {\n // @todo improve\n return (\n isObject(tokenObject) &&\n !isTokenSrcExtensions(tokenObject) &&\n !isObjKey('$value', tokenObject) &&\n // ensuring we are not in `$extensions` object\n !isObjKey('cloud.knapsack', tokenObject)\n );\n}\n\n// Token VAR references look like TokenSrcGroup\nexport function isTokenTypeVarRef(tokenObject: unknown) {\n // It's at least a TokenSrcGroup\n if (isTokenGroup(tokenObject)) {\n // The specific key within collectionInfo with the var reference\n const varRefCollectionInfo =\n tokenObject.$extensions['cloud.knapsack'].group.collectionInfo;\n if (\n isObjKey('type', varRefCollectionInfo) &&\n isObjKey('referenceId', varRefCollectionInfo)\n ) {\n return true;\n }\n }\n\n return false;\n}\n","import { parseNumberWithUnit } from '@knapsack/utils';\n\nexport function getPrimitiveValue(\n tokenValue: unknown,\n): 'string' | 'number' | 'boolean' {\n const type = typeof tokenValue;\n if (type === 'string' || type === 'number' || type === 'boolean') {\n return type;\n }\n throw new Error(\n `Invalid token value type: ${JSON.stringify(\n type,\n )}. Token value is: ${JSON.stringify(tokenValue)}`,\n );\n}\n\nexport type TokenDimensionUnit = 'px' | 'rem' | 'em' | '%';\n\n/**\n * Dimension strings require ending in 'px' or 'rem'\n * @see `libs/types/src/app-client-data/design-tokens-types/token-definitions.ts`\n */\nexport const isDimensionString = (\n value: string,\n): value is `${number}${'px' | 'rem' | 'em' | '%'}` =>\n value.includes('px') ||\n value.includes('rem') ||\n value.includes('em') ||\n value.includes('%');\n\n/**\n * Pass in values like `'12px'` to get detailed info\n * @throws if value is not a number or does not end in supported unit\n */\nexport function parseTokenDimensionValue(valueToParse: string | number): {\n value: number;\n unit?: TokenDimensionUnit;\n} {\n const { value, unit } = parseNumberWithUnit(valueToParse);\n if (!unit) {\n return { value };\n }\n if (unit !== 'px' && unit !== 'rem' && unit !== 'em' && unit !== '%') {\n throw new Error(`Invalid unit \"${unit}\" for value: ${value}`);\n }\n\n return { value, unit };\n}\n","import type { CSSProperties } from 'react';\nimport type { JsonSchemaObject } from '../json-schema';\nimport { RendererId } from '../renderers';\nimport { isObject } from '../type-utils';\nimport type { BlockConfig } from './blocks';\nimport type { Page, PageTab } from './page';\nimport { TokenSrcValueInfo } from './design-tokens-types/token-src-value-info';\n\nexport interface KsStatus {\n id: string;\n title: string;\n color?: string;\n}\n\nexport interface KsStatusSet {\n id: string;\n title: string;\n statuses: KsStatus[];\n}\n\n/**\n * Used by template renderers in addition to `path`\n * Twig: `@components/button.twig`\n * Web Components: `my-button` => `<my-button>`\n * React: a named export of the file if not `default`\n * @todo Replace this with `rendererOptions`\n */\ntype TemplateAlias = string;\n\nexport type SlottedTemplateDemo = {\n type: 'template-demo';\n /** @deprecated */\n patternId: string;\n /** @deprecated */\n templateId: string;\n /**\n * The demo referenced by `demoId` is inlined here before sending to server to\n * render, but is never stored in the json data. If this is present, it is\n * used instead of the demo referenced by `demoId`. This is done to ensure\n * server has all the latest data for a template demo by ensuring it includes\n * it's slotted children's data.\n * @see {inlineDemoData}\n */\n demo?: DataDemo;\n demoId: DemoBase['id'];\n};\n\n/**\n * i.e. Given a React Component, `Button`, this set to null/false would be\n * `<Button>` and set to true it would just be a reference to it: `Button`\n * @see {KsSlotInfo['isTemplateReference']}\n */\nexport type SlottedTemplateReference = {\n type: 'template-reference';\n patternId: string;\n templateId: string;\n};\n\nexport type SlottedText = {\n type: 'text';\n text: string;\n};\n\nexport type SlottedData =\n | SlottedText\n | SlottedTemplateDemo\n | SlottedTemplateReference;\n\n/** @deprecated - just check `type` */\nexport const isSlottedText = (\n slottedData: unknown,\n): slottedData is SlottedText =>\n isObject(slottedData) && slottedData.type === 'text';\n\n/** @deprecated - just check `type` */\nexport function isSlottedTemplateDemo(\n slottedData: unknown,\n): slottedData is SlottedTemplateDemo {\n return isObject(slottedData) && slottedData.type === 'template-demo';\n}\n\n/** @deprecated - just check `type` */\nexport function isSlottedTemplateReference(\n slottedData: unknown,\n): slottedData is SlottedTemplateReference {\n return isObject(slottedData) && slottedData.type === 'template-reference';\n}\n\n/**\n * Collection ID: Mode ID\n */\nexport type ThemeDefinition = {\n [collectionId: string]: string;\n};\n\nexport type SlotOptions = {\n /**\n * @default 'div'\n */\n wrappingElementName?: string;\n cssClasses?: string[];\n align?: {\n value:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'left'\n | 'center'\n | 'right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right';\n };\n layout?: {\n value: 'horizontal' | 'vertical' | 'wrap';\n };\n gap?: {\n value: TokenSrcValueInfo<'dimension'>;\n };\n paddingHorizontal?: {\n value: TokenSrcValueInfo<'dimension'>[];\n };\n paddingVertical?: {\n value: TokenSrcValueInfo<'dimension'>[];\n };\n /**\n * Collection ID: Mode ID\n */\n theme?: ThemeDefinition;\n};\n\n/**\n * These are created from {SlotOptions}\n * Only available in App Client for rendering - this is NOT saved in App Client Data\n */\nexport type SlotOptionsComputed = {\n styles: CSSProperties;\n cssClasses: string[];\n /**\n * @default 'div'\n */\n wrappingElementName: string;\n /**\n * can't be `style` or `class` or `className`\n */\n attributes: {\n [attributeName: string]: string;\n };\n};\n\nexport type KnapsackTemplateData = {\n /**\n * @todo Ideal would be `{ [key: string]: string | boolean | number }`\n */\n props: {\n [prop: string]: any;\n };\n slots?: {\n [slotName: string]: Array<SlottedData>;\n };\n /**\n * Settings from users are stored here and saved in App Client Data\n * This is used to dynamically create `slotsOptionsComputed`\n */\n slotsOptions?: {\n [slotName: string]: SlotOptions;\n };\n /**\n * Use `slotsOptions` to set & save styles on slotted children\n * Never set nor stored in App Client Data that gets saved\n * This is only inlined in the demo data for rendering so the App Client can\n * apply the styles to the slotted children\n * @see {inlineDemoData}\n */\n slotsOptionsComputed?: {\n [slotName: string]: SlotOptionsComputed;\n };\n};\n\ntype DemoType = 'data' | 'template';\n\ntype DemoBase = {\n id: string;\n title: string;\n description?: string;\n /**\n * Would override what was on the template\n */\n assetSetId?: string;\n width?: number;\n height?: number;\n type: DemoType;\n /** Collection ID: Mode ID */\n theme?: ThemeDefinition;\n};\n\n/**\n * Shows usage\n */\nexport type DataDemo = DemoBase & {\n type: 'data';\n patternId: string;\n templateId: string;\n data: KnapsackTemplateData;\n};\n\n/**\n * Shows source code\n */\nexport type TemplateDemo = DemoBase & {\n type: 'template';\n templateInfo: {\n alias?: TemplateAlias;\n path?: string;\n };\n};\n\nexport type Demo = TemplateDemo | DataDemo;\n\nexport type RenderDataDemo = Demo & {\n inlineStyles?: string;\n bodyAttributes?: Record<string, string>;\n};\n\n/** @deprecated */\nexport enum StageLayouts {\n portrait = 'portrait',\n landscape = 'landscape',\n}\n\nexport function isDataDemo(demo: TemplateDemo | DataDemo): demo is DataDemo {\n return demo?.type === 'data';\n}\n\nexport function isTemplateDemo(demo: Demo): demo is TemplateDemo {\n return demo?.type === 'template';\n}\n\nexport type KsSlotInfo = {\n title: string;\n description?: string;\n disallowText?: boolean;\n isRequired?: boolean;\n allowOnlyOne?: boolean;\n /**\n * i.e. Given a React Component, `Button`, this set to null/false would be\n * `<Button>` and set to true it would just be a reference to it: `Button`\n * @see {SlottedTemplateReference}\n */\n isTemplateReference?: boolean;\n allowedPatternIds?: string[];\n};\n\n/**\n * Supersedes `schema`\n */\nexport type KsTemplateSpec = {\n /**\n * Attempt to create the props & slots spec by reading the source file.\n * Prevents ability to use spec editor.\n *\n * If `true`, then uses the template `alias` & `path` to find the file.\n *\n * If a string, then that file path is used in place of the source file.\n *\n * Scenario: the `path` is used to point to a compiled file w types stripped\n * and this is used to point to either the source file w types or the compiled\n * `.d.ts` file. Currently only React is supported. The file extension\n * determines if TypeScript (ts/tsx) or PropTypes (js/jsx) is used for\n * inference.\n */\n isInferred?: boolean | string;\n /**\n * JSON Schema defining the serializable data passed in\n * The classic, formerly `schema`\n */\n props?: JsonSchemaObject;\n /**\n * Child component slots\n */\n slots?: {\n [name: string]: KsSlotInfo;\n };\n /**\n * @todo evaluate & refine\n */\n // cssProps?: {\n // [name: string]: {\n // title: string;\n // description: string;\n // };\n // };\n hidePropsTable?: boolean;\n hideSlotsTable?: boolean;\n /**\n * Extra Docs are each shown in their own table.\n * Useful for non-traditional spec docs that are more template language specific.\n * Examples: events, methods, etc\n */\n extraDocs?: {\n id: string;\n title: string;\n description?: string;\n tableRows?: {\n [columnTitle: string]: string;\n }[];\n }[];\n};\n\nexport interface KnapsackPatternTemplate {\n id: string;\n title?: string;\n /**\n * Relative file path to the template from the config file it is declared in\n */\n path: string;\n\n alias?: TemplateAlias;\n /**\n * Which template language? i.e. `twig`, `react` Replaces\n * KnapsackTemplateRenderer.test which ran a test on the file path (similar to\n * how WebPack loader `test` works)\n */\n templateLanguageId: RendererId;\n assetSetIds?: string[];\n spec?: KsTemplateSpec;\n /** Array of demo IDs, actual demo data is stored in `db.demos.demosById` */\n demoIds: Demo['id'][];\n /** Array of block IDs, actual block content is stored in db.blocks.blocksById */\n blockIds: BlockConfig['id'][];\n}\n\nexport type KnapsackPattern = Page & {\n $schema?: string;\n statuses?: {\n [statusSetId: string]: string;\n };\n templates?: KnapsackPatternTemplate[];\n subPages?: {\n id: string;\n title: string;\n blockIds: BlockConfig['id'][];\n }[];\n designSrcComponentsById?: Record<\n string,\n {\n id: string;\n title: string;\n componentId: string;\n fileId: string;\n }\n >;\n /** Controls order of `templates` & `subPages` on Pattern Page */\n tabs?: PageTab[];\n\n aliases?: string[];\n /**\n * Prevents pattern from appearing in System Overview and Status Table blocks\n */\n hideFromOverviewBlocks?: boolean;\n /**\n * Prevents pattern from appearing as an option in Component Embed and\n * Component Demo blocks\n */\n hideFromComponentBlocks?: boolean;\n};\n\nexport interface KnapsackPatternTemplateCode {\n html: string;\n data?: Record<string, any>;\n templateSrc: string;\n usage: string;\n language: string;\n}\n\nexport type KnapsackPatternsConfig = {\n $schema?: string;\n statusSets: KsStatusSet[];\n};\n\nexport interface TemplateRendererMeta {\n id: RendererId;\n title: string;\n version?: string;\n aliasTitle?: string;\n aliasDescription?: string;\n aliasUse: 'off' | 'optional' | 'required';\n aliasIsJsNamedExport?: boolean;\n syntaxHighlightingLanguage?: string;\n enableDataDemos: boolean;\n enableTemplateDemos: boolean;\n hasSlotsSupport: boolean;\n hasSlotOptionsSupport?: boolean;\n hasInferSpecSupport: boolean;\n hasTemplateSuggestionsSupport: boolean;\n prototypingTemplate?: {\n path: string;\n alias?: string;\n spec: Pick<KsTemplateSpec, 'props' | 'slots' | 'isInferred'>;\n };\n}\n\nexport type PatternsState = {\n patterns: {\n [id: string]: KnapsackPattern;\n };\n renderers: Partial<\n Record<\n RendererId,\n {\n meta: TemplateRendererMeta;\n }\n >\n >;\n} & KnapsackPatternsConfig;\n","import { ColorConfig } from '../color-config';\n\nexport enum PageHeaderSizes {\n auto = 'auto',\n small = 'small',\n medium = 'medium',\n large = 'large',\n full = 'full',\n}\n\nexport interface PageHeaderSettings {\n size?: `${PageHeaderSizes}`;\n backgroundImage?: string;\n backgroundColor?: ColorConfig;\n backgroundOverlay?: boolean;\n backgroundSize?: 'cover' | 'contain' | 'string';\n backgroundPosition?: 'left' | 'center' | 'right' | 'string';\n backgroundRepeat?: 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat';\n hideText?: boolean;\n textColorTitle?: ColorConfig;\n textColorDescription?: ColorConfig;\n}\n","import {\n // type structs validate that a value has a set of properties on it, but it does not assert anything about unspecified properties. This allows you to assert that a particular set of functionality exists without a strict equality check for properties.\n type,\n string,\n Describe,\n boolean,\n optional,\n array,\n number,\n define,\n} from 'superstruct';\nimport { isObjKey, isObject } from '../type-utils';\nimport type { KnapsackAssetSetsData } from './asset-sets';\nimport type { KsDesignTokensState } from './design-tokens';\nimport type { MetaState } from './meta';\nimport type { KnapsackNavsConfig } from './nav';\nimport type { KsFiles } from './files';\nimport type { KnapsackCustomPagesData } from './custom-pages';\nimport type { PatternsState } from './patterns';\nimport type { KnapsackSettings } from './settings';\n\nexport type {\n KsDesignToken,\n KsDesignTokenAttributes,\n KsDesignTokenData,\n KsDesignTokenDataGroup,\n KsDesignTokenSrc,\n KsDesignTokenSrcGroup,\n KsDesignTokensState,\n KsTokenType,\n KsTokenValue,\n KnapsackDesignToken,\n} from './design-tokens';\n\nexport interface KsAppClientDataV3 {\n settingsState: {\n settings: KnapsackSettings;\n };\n patternsState: PatternsState;\n customPagesState: KnapsackCustomPagesData;\n assetSetsState: KnapsackAssetSetsData;\n navsState: KnapsackNavsConfig;\n tokensState: KsDesignTokensState;\n metaState?: MetaState;\n filesState: KsFiles;\n}\n\nexport type KsAppClientDataNoMetaV3 = Omit<KsAppClientDataV3, 'metaState'>;\nexport type KsAppClientDataAndMetaV3 = Required<KsAppClientDataV3>;\n\nexport function isKsAppClientDataNoMetaV3(\n data: unknown,\n): data is KsAppClientDataNoMetaV3 {\n if (!isObject(data)) return false;\n const requiredKeys: Array<keyof KsAppClientDataNoMetaV3> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'settingsState',\n 'tokensState',\n ];\n if (!requiredKeys.every((key) => isObjKey(key, data))) return false;\n if (!isObjKey('metaState', data)) return true;\n return false;\n}\n\nexport const KsAppClientDataNoMetaStructV3 = define<KsAppClientDataNoMetaV3>(\n 'KsAppClientDataNoMeta',\n isKsAppClientDataNoMetaV3,\n);\n\nexport function isKsAppClientDataAndMetaV3(\n data: unknown,\n): data is KsAppClientDataAndMetaV3 {\n if (!isObject(data)) return false;\n const requiredKeys: Array<keyof KsAppClientDataAndMetaV3> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'settingsState',\n 'tokensState',\n 'metaState',\n ];\n return requiredKeys.every((key) => isObjKey(key, data));\n}\n\nexport const KsAppClientDataAndMetaStructV3 = define<KsAppClientDataAndMetaV3>(\n 'KsAppClientDataAndMeta',\n isKsAppClientDataAndMetaV3,\n);\n\nexport const KsMetaStateStructV3: Describe<KsAppClientDataV3['metaState']> =\n type({\n isLocalDev: boolean(),\n plugins: array(\n type({\n id: string(),\n hasContent: boolean(),\n clientPluginPath: optional(string()),\n cssPath: optional(string()),\n }),\n ),\n meta: optional(\n type({\n version: optional(string()),\n hasKnapsackCloud: boolean(),\n knapsackCloudSiteId: optional(string()),\n serverPort: optional(number()),\n websocketsPort: optional(number()),\n https: optional(boolean()),\n cacheDir: optional(string()),\n ksVersions: type({\n app: string(),\n }),\n }),\n ),\n });\n\nexport const isKsMetaStateV3 = KsMetaStateStructV3.is;\n","import { isDraft, type Draft } from 'immer';\nimport { Migration } from './migration.types';\nimport { KnapsackPattern, SlottedData } from '../app-client-data/patterns';\n\ntype Migration417DemosType = {\n version: string;\n checkIfNeeded: (appClientData: any) => boolean;\n migrate: (appClientData: Draft<any>) => void;\n};\n\nexport const migration417Demos: Migration417DemosType = {\n version: '4.1.7',\n checkIfNeeded: (appClientData) => {\n // this one will be tough to check for, so we'll just assume it's needed\n return true;\n },\n // note that `appClientData` is mutable since we're already in Immer\n migrate: (appClientData) => {\n if (!isDraft(appClientData)) {\n throw new Error(\n `Tried to run migrations on appClientData but it is not an Immer Draft`,\n );\n }\n Object.values(appClientData.patternsState.patterns).forEach(\n (\n pattern: Draft<\n KnapsackPattern & {\n demoSize?: string;\n }\n >,\n ) => {\n delete pattern.demoSize;\n },\n );\n\n Object.values(appClientData.db.demos.byId).forEach((demo) => {\n if (demo.type !== 'data') return;\n\n Object.entries(demo.data.slots ?? {}).forEach(([slotName, slotData]) => {\n demo.data.slots[slotName] = slotData.map(\n (slottedData: Draft<SlottedData | string>) => {\n // it used to be just a string\n if (typeof slottedData === 'string') {\n return {\n type: 'text',\n text: slottedData,\n };\n }\n if (\n // not doing anything with these\n slottedData.type === 'template-reference' ||\n // these already were migrated or made by the new editor\n slottedData.type === 'text'\n ) {\n return slottedData;\n }\n // these used to not have a type set\n slottedData.type = 'template-demo';\n return slottedData;\n },\n );\n });\n\n if (demo.patternId && demo.templateId) return;\n\n // using an IIFE so we can stop looping once we find it\n // would use `break` but it's a double loop\n (() => {\n for (const { id: pId, templates = [] } of Object.values(\n appClientData.patternsState.patterns,\n )) {\n for (const { id: tId, demoIds = [] } of templates) {\n if (demoIds.includes(demo.id)) {\n demo.patternId = pId;\n demo.templateId = tId;\n // found it - stop looking\n return;\n }\n }\n }\n })();\n });\n },\n} satisfies Migration;\n","import { migration417Demos } from './4.1.7-demos';\n\nexport const migrations = [migration417Demos];\n","// import { JSONSchema7 } from 'json-schema'; @todo consider using instead; though I'm not seeing it make it's way to the compiled JSON schema themselves via `convert-types-to-json-schmea.js`\n\ntype PropBase<Type = any> = {\n title?: string;\n description?: string;\n default?: Type;\n};\n\nexport enum PropTypeNames {\n 'string' = 'string',\n 'boolean' = 'boolean',\n 'number' = 'number',\n 'object' = 'object',\n 'options' = 'options',\n 'function' = 'function',\n 'customTypeScript' = 'customTypeScript',\n 'array' = 'array',\n 'arrayOfObjects' = 'arrayOfObjects',\n 'arrayOfStrings' = 'arrayOfStrings',\n 'unknown' = 'unknown',\n}\nexport type PropTypeNamesList = keyof typeof PropTypeNames;\n\nexport type StringProp = {\n type: 'string';\n} & PropBase<string>;\n\nexport type BooleanProp = {\n type: 'boolean';\n} & PropBase<boolean>;\n\nexport type NumberProp = {\n type: 'number';\n} & PropBase<number>;\n\nexport type OptionsProp = {\n type: 'string';\n enum: string[];\n enumNames?: string[];\n} & PropBase<string>;\n\nexport type CustomTypeScriptProp = {\n /**\n * TypeScript type\n * @example (name: string) => void\n */\n tsType: string;\n type?: never;\n default?: string;\n} & PropBase<string>;\n\nexport type FunctionProp = {\n typeof: 'function';\n /**\n * TypeScript type\n * @example (name: string) => void\n */\n tsType: string;\n default?: string;\n type?: 'string';\n} & PropBase<string>;\n\nexport type ObjectProp = {\n type: 'object';\n additionalProperties?: boolean;\n required?: string[];\n properties: {\n [prop: string]: any;\n };\n} & PropBase;\n\nexport type ArrayProp = {\n type: 'array';\n} & PropBase<unknown[]>;\n\nexport type ArrayOfStringsProp = {\n type: 'array';\n uniqueItems?: boolean;\n items: StringProp | OptionsProp;\n} & PropBase<unknown[]>;\n\nexport type ArrayOfObjectsProp = {\n type: 'array';\n items: ObjectProp;\n} & PropBase<Array<Record<string, unknown>>>;\n\nexport type PropertyTypes =\n | StringProp\n | BooleanProp\n | NumberProp\n | OptionsProp\n | FunctionProp\n | CustomTypeScriptProp\n | ObjectProp\n | ArrayOfObjectsProp\n | ArrayOfStringsProp\n | ArrayProp;\n\nexport const isStringProp = (prop: PropertyTypes): prop is StringProp =>\n 'type' in prop && prop.type === 'string' && !('enum' in prop);\nexport const isNumberProp = (prop: PropertyTypes): prop is NumberProp =>\n 'type' in prop && prop.type === 'number';\nexport const isBooleanProp = (prop: PropertyTypes): prop is BooleanProp =>\n 'type' in prop && prop.type === 'boolean';\nexport const isOptionsProp = (prop: PropertyTypes): prop is OptionsProp =>\n 'enum' in prop;\nexport const isFunctionProp = (prop: PropertyTypes): prop is FunctionProp =>\n 'typeof' in prop && prop?.typeof === 'function';\nexport const isCustomTypeScriptProp = (\n prop: PropertyTypes,\n): prop is CustomTypeScriptProp => !('typeof' in prop) && 'tsType' in prop;\nexport const isArrayOfObjectsProp = (\n prop: PropertyTypes,\n): prop is ArrayOfObjectsProp =>\n 'type' in prop &&\n prop.type === 'array' &&\n 'items' in prop &&\n prop.items.type === 'object';\nexport const isObjectProp = (prop: PropertyTypes): prop is ObjectProp =>\n 'type' in prop &&\n prop.type === 'object' &&\n 'properties' in prop &&\n Object.keys(prop.properties).length > 0;\nexport const isArrayOfStringsProp = (\n prop: PropertyTypes,\n): prop is ArrayOfStringsProp =>\n 'type' in prop &&\n prop.type === 'array' &&\n 'items' in prop &&\n prop.items.type === 'string';\n\nexport interface PropTypeDataBase {\n type: any;\n id: string;\n isRequired?: boolean;\n data: any;\n}\n\nexport interface StringPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.string;\n data: StringProp;\n}\n\nexport interface BooleanPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.boolean;\n data: BooleanProp;\n}\n\nexport interface NumberPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.number;\n data: NumberProp;\n}\n\nexport interface OptionsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.options;\n data: OptionsProp;\n}\n\nexport interface FunctionPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.function;\n data: FunctionProp;\n}\n\nexport interface CustomTypeScriptPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.customTypeScript;\n data: CustomTypeScriptProp;\n}\n\nexport interface ObjectPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.object;\n data: ObjectProp;\n}\n\nexport interface ArrayOfObjectsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.arrayOfObjects;\n data: ArrayOfObjectsProp;\n}\n\nexport interface ArrayOfStringsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.arrayOfStrings;\n data: ArrayOfStringsProp;\n}\n\nexport interface ArrayPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.array;\n data: ArrayProp;\n}\n\nexport type PropTypeData =\n | StringPropTypeData\n | BooleanPropTypeData\n | NumberPropTypeData\n | OptionsPropTypeData\n | FunctionPropTypeData\n | CustomTypeScriptPropTypeData\n | ObjectPropTypeData\n | ArrayOfObjectsPropTypeData\n | ArrayOfStringsPropTypeData;\n\nexport type JsonSchemaObject<PropNames extends string = string> = {\n $schema?: string;\n title?: string;\n description?: string;\n type: string;\n required?: string[];\n properties: Record<PropNames, PropertyTypes>;\n examples?: Record<string, unknown>[];\n};\n","import * as s from 'superstruct';\nimport type { Patch } from 'immer';\nimport type { SetOptional } from '@knapsack/utils';\nimport type { UUID, DateString } from './misc';\n\n/**\n * Patch\n */\n\nexport type { Patch };\n\nconst PatchStructRuntime = s.object({\n op: s.union([s.literal('replace'), s.literal('remove'), s.literal('add')]),\n path: s.array(s.union([s.string(), s.number()])),\n value: s.optional(s.any()),\n});\nconst PatchStruct: s.Describe<Patch> = PatchStructRuntime;\n\nexport const isPatch = (patch: unknown): patch is Patch =>\n PatchStruct.is(patch);\n\nconst PatchesStructRuntime = s.array(PatchStructRuntime);\nconst PatchesStruct: s.Describe<Patch[]> = PatchesStructRuntime;\n\nexport const isPatches = (patches: unknown): patches is Patch[] =>\n PatchesStruct.is(patches);\n\n/**\n * KsRemoteChange\n */\nexport type KsChange<Event extends { type: string } = { type: string }> = {\n patches: Patch[];\n inversePatches: Patch[];\n event: Event;\n id: UUID;\n date: DateString;\n};\nexport type KsRemoteChange = SetOptional<KsChange, 'inversePatches' | 'event'>;\n\nconst KsRemoteChangeRuntime = s.type({\n patches: PatchesStructRuntime,\n inversePatches: s.optional(PatchesStructRuntime),\n event: s.optional(s.object({ type: s.string() })),\n id: s.string(),\n date: s.string(),\n userId: s.optional(s.string()),\n});\nconst KsRemoteChangeStruct: s.Describe<KsRemoteChange> = KsRemoteChangeRuntime;\n\nexport const isKsRemoteChange = (change: unknown): change is KsRemoteChange =>\n KsRemoteChangeStruct.is(change);\n\nconst KsRemoteChangesStructRuntime = s.array(KsRemoteChangeRuntime);\nexport const KsRemoteChangesStruct: s.Describe<KsRemoteChange[]> =\n KsRemoteChangesStructRuntime;\n\nexport const isKsRemoteChanges = (\n changes: unknown,\n): changes is KsRemoteChange[] => KsRemoteChangesStruct.is(changes);\n","import { isObject } from './type-utils';\n\nexport const rendererIds = {\n react: 'react',\n vue: 'vue',\n 'web-components': 'web-components',\n twig: 'twig',\n hbs: 'hbs',\n angular: 'angular',\n html: 'html',\n} as const;\n\n/**\n * The ID of a renderer, e.g. 'react', 'vue', 'angular', etc.\n * On Pattern Templates, this will match up to `templateLanguageId` to identify which renderer to use.\n * @see {KnapsackPatternTemplate['templateLanguageId']}\n */\nexport type RendererId = keyof typeof rendererIds;\n\n/**\n * Information about JS imports that can describe how to import a module in these ways:\n * - `import { Foo, Bar } from './foo';`\n * - `import * as Foo from './foo';`\n * - `import Foo from './foo';`\n *\n * Used in Webpack-based renderers\n */\nexport type KsJsImportInfo =\n | {\n type: 'default';\n /** import name from 'path'; */\n name: string;\n path: string;\n }\n | {\n type: 'named';\n path: string;\n /** import { name } from 'path'; */\n name: string;\n }\n | {\n type: 'all';\n path: string;\n /** import * as name from 'path'; */\n name: string;\n };\n\n/** The result of `import`-ing a module */\ntype EsModuleObject<ExportedType = unknown> = {\n default?: ExportedType;\n [key: string]: ExportedType;\n};\n\nexport type KsJsImport =\n | {\n type: 'pattern-template';\n patternId: string;\n templateId: string;\n importInfo: KsJsImportInfo;\n }\n | {\n type: 'pattern-template-demo';\n patternId: string;\n templateId: string;\n demoId: string;\n importInfo: KsJsImportInfo;\n }\n | {\n type: 'extra';\n importInfo: KsJsImportInfo;\n };\n\ntype GetKsJsImportParam =\n | {\n type: 'pattern-template';\n patternId: string;\n templateId: string;\n }\n | {\n type: 'pattern-template-demo';\n patternId: string;\n templateId: string;\n demoId: string;\n }\n | {\n type: 'extra';\n name: string;\n };\n\ntype GetKsJsImportPatternParam = {\n patternId: string;\n templateId: string;\n demoId?: string;\n};\n\n/**\n * This is `window.knapsack` inside the renderer client: the iframe container for renderer components\n */\nexport interface KsRendererClientGlobal<ExportedComponentType = unknown> {\n typeName: 'KsRendererClientGlobal';\n importedModules: {\n [id: string]: () => Promise<EsModuleObject<ExportedComponentType>>;\n };\n allAvailableImports: KsJsImport[];\n getImport: (opt: GetKsJsImportParam) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getImports: (imports: GetKsJsImportParam[]) => Promise<{\n [importName: string]: ExportedComponentType;\n }>;\n getPatternImport: (opt: GetKsJsImportPatternParam) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getExtraImport: (opt: { name: string }) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getAllImports: (opt: {\n patterns: GetKsJsImportPatternParam[];\n extras?: { name: string }[];\n }) => Promise<{\n [importName: string]: ExportedComponentType;\n }>;\n}\n\nexport function isKsJsImports(imports: unknown): imports is KsJsImport[] {\n if (!Array.isArray(imports)) return false;\n if (imports.length === 0) return true;\n const [anImport] = imports;\n if (\n anImport.type === 'pattern-template' &&\n typeof anImport.patternId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.patternId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.templateId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.demoId !== 'string'\n )\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo !== 'object')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.type !== 'string')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.name !== 'string')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.path !== 'string')\n return false;\n if (\n anImport.type === 'extra' &&\n typeof anImport.importInfo.names !== 'undefined'\n ) {\n if (!Array.isArray(anImport.importInfo.names)) return false;\n if (\n anImport.importInfo.names.some((name: string) => typeof name !== 'string')\n )\n return false;\n }\n return true;\n}\n\nexport function isKsRendererClientGlobalImportedModules(\n mods: unknown,\n): mods is KsRendererClientGlobal['importedModules'] {\n if (!isObject(mods)) return false;\n for (const key in mods) {\n if (typeof mods[key] !== 'function') return false;\n }\n return true;\n}\n\nexport function isKsRendererClientGlobal<ExportedComponentType = unknown>(\n knapsack: unknown,\n): knapsack is KsRendererClientGlobal<ExportedComponentType> {\n if (!isObject(knapsack)) return false;\n if (knapsack.typeName !== 'KsRendererClientGlobal') return false;\n if (typeof knapsack.getImport !== 'function') return false;\n if (!Array.isArray(knapsack.allAvailableImports)) return false;\n if (!isKsRendererClientGlobalImportedModules(knapsack.importedModules)) {\n return false;\n }\n return isKsJsImports(knapsack.allAvailableImports);\n}\n\nconst isBrowser =\n typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nexport function getKsRendererClientGlobal<\n ExportedComponentType = unknown,\n>(): KsRendererClientGlobal<ExportedComponentType> {\n if (!isBrowser) {\n throw new Error(\n 'Cannot get KsRendererClientGlobal in a non-browser environment',\n );\n }\n const { knapsack } = window as any;\n if (!knapsack) {\n throw new Error(\n 'Cannot get KsRendererClientGlobal: \"knapsack\" is not defined on the window',\n );\n }\n if (!isKsRendererClientGlobal<ExportedComponentType>(knapsack)) {\n console.log(`Object found at \"window.knapsack\":`, knapsack);\n throw new Error(\n `Cannot get KsRendererClientGlobal: knapsack is not the correct type`,\n );\n }\n return knapsack;\n}\n\nexport type TemplateSuggestion = {\n path: string;\n alias?: string;\n};\n\nexport type TemplateSuggestionsGetFn = (opt: {\n rendererId: RendererId;\n newPath?: string;\n}) => Promise<{\n suggestions: TemplateSuggestion[];\n}>;\n","import type { FeedbackTypes } from './misc';\n\nexport enum KsRendererClientEvents {\n ready = 'ready',\n}\n\n/**\n * Message sent from the renderer client (in the iframe) to the App UI parent window\n * using `window.parent.postMessage()`.\n * Note that this likely will become a union type of all possible messages\n */\nexport type KsRendererClientMsg =\n | {\n /**\n * Sent when a `ResizeObserver` detects a change in the contents height or width.\n */\n type: 'ksRendererClient.contentResized';\n height: number;\n width: number;\n }\n | {\n type: 'ksRendererClient.showToast';\n msg: string;\n feedbackType?: FeedbackTypes;\n };\n\nexport interface KsRendererClientMeta {\n patternId: string;\n templateId: string;\n demoId: string;\n assetSetId: string;\n isInIframe: boolean;\n websocketsPort: number;\n}\n","export const WS_EVENTS = {\n PATTERN_TEMPLATE_CHANGED: 'PATTERN_TEMPLATE_CHANGED',\n PATTERN_ASSET_CHANGED: 'PATTERN_ASSET_CHANGED',\n DESIGN_TOKENS_CHANGED: 'DESIGN_TOKENS_CHANGED',\n RENDERER_CLIENT_RELOAD: 'RENDERER_CLIENT_RELOAD',\n APP_CLIENT_DATA_CHANGED: 'APP_CLIENT_DATA_CHANGED',\n};\n\nexport type WebSocketEvent = keyof typeof WS_EVENTS;\n\nexport interface WebSocketMessage {\n event: string;\n data: Record<string, unknown>;\n}\n\nexport interface DesignTokensChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.DESIGN_TOKENS_CHANGED;\n data: Record<string, unknown>;\n}\n\nexport interface PatternChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_TEMPLATE_CHANGED;\n data: {\n /**\n * Absolute path to template on server that was just edited\n */\n path: string;\n };\n}\n\nexport interface AssetChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_ASSET_CHANGED;\n data: {\n /**\n * Absolute path to asset file (CSS/JS) on server that was just edited\n */\n path: string;\n };\n}\n\nexport interface RendererClientReloadMessage extends WebSocketMessage {\n event: typeof WS_EVENTS.RENDERER_CLIENT_RELOAD;\n data: {\n // @todo add patternId etc for more details\n };\n}\n\nexport interface AppClientDataChanged extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_TEMPLATE_CHANGED;\n data: Record<string, unknown>;\n}\n\nexport type WebSocketMessages =\n | PatternChangedData\n | AssetChangedData\n | DesignTokensChangedData\n | RendererClientReloadMessage;\n","export enum GitProviderType {\n GitHub = 'GitHub',\n GitLab = 'GitLab',\n GitLabRest = 'GitLabRest',\n Bitbucket = 'Bitbucket',\n Azure = 'Azure',\n}\n\nexport type FileAddition = {\n /** base64 */\n contents: string;\n path: string;\n\n /** Action to perform: create, delete, move, update, or chmod. */\n action?: RestActions;\n /** Content of the file. */\n content?: string;\n /** Full path to the file. */\n filePath?: string;\n /** Encoding of the file. Default is text. */\n encoding?: TextEncoding;\n /** Last known file commit ID. */\n lastCommitId?: string;\n /** Original full path to the file being moved. */\n previousPath?: string;\n};\n\nexport type FileDeletion = {\n path: string;\n};\n\nexport enum MergeableState {\n Conflicting = 'CONFLICTING',\n Mergeable = 'MERGEABLE',\n Unknown = 'UNKNOWN',\n}\n\nexport enum RestActions {\n Create = 'CREATE',\n Move = 'MOVE',\n Update = 'UPDATE',\n Chmod = 'CHMOD',\n}\n\nexport enum TextEncoding {\n Base64 = 'BASE64',\n Text = 'TEXT',\n}\n\nexport type FileChanges = {\n /** File to add or change. */\n additions?: FileAddition[];\n\n /** Files to delete. */\n deletions?: FileDeletion[];\n\n /** Last known file commit ID. */\n lastCommitId?: string;\n};\n\nexport type CommitAction = Record<string, unknown>;\n\nexport interface RepoLabel {\n name: string;\n /** ID optional because bitbucket does not provide id. We might be able to generate one if its required, eg. reponame-labelname */\n id?: string;\n}\n\nexport interface RepoInfo {\n id: string;\n url: string;\n name: string;\n ownerName?: string;\n defaultBranch?: any;\n}\n\n// 'BranchInfo' name is currently taken by GitLab generated queries. Thus 'BranchInfoResult'\nexport interface BranchInfoResult {\n sha: string;\n shortSha?: string;\n associatedPullRequests?: Pr[];\n additions?: number;\n commitUrl?: string;\n deletions?: number;\n id?: string; // In GitLab, this is the branch name. Modelled this way to make deleteBranch work.\n default?: boolean;\n}\n\nexport interface PrInfo {\n url: string;\n number: number;\n id: string;\n}\n\nexport interface Pr {\n id: string;\n title: string;\n createdAt: string;\n headRef: {\n id?: string;\n name?: string;\n target: BranchInfoResult;\n };\n mergeable: MergeableState;\n merged: boolean;\n number: number;\n body: string;\n isDraft: boolean;\n url: string;\n author: {\n login: string;\n avatarUrl: string;\n };\n diffHeadSha?: string;\n targetBranch?: string;\n version?: string; // needed for bitbucket merge\n}\n\nexport interface GitProvider {\n type: GitProviderType;\n createBranch: (opt: { branch: string }) => Promise<BranchInfoResult>;\n commitOnBranch: (opt: {\n branch: string;\n message: string;\n fileChanges: FileChanges;\n }) => Promise<Record<string, unknown> | void>;\n getRepoLabels: () => Promise<RepoLabel[]>;\n getRepoInfo: () => Promise<RepoInfo>;\n getBranchInfo: ({ branch }: { branch: string }) => Promise<BranchInfoResult>;\n getPrs: () => Promise<Pr[]>;\n getPr: ({ prNumber }: { prNumber: number }) => Promise<Pr>;\n getTree?: (opt: { branch: string }) => Promise<{\n treeItems: {\n path: string;\n type: 'blob';\n /** SHA-1, use https://www.npmjs.com/package/git-hash-object */\n sha: string;\n url?: string;\n }[];\n }>;\n mergePr: ({ prNumber }: { prNumber: number }) => Promise<boolean>;\n createPr: ({\n siteId,\n branch,\n title,\n body,\n labelIds,\n }: {\n siteId: string;\n branch: string;\n title: string;\n body?: string;\n labelIds?: string[];\n }) => Promise<PrInfo>;\n deleteBranch: ({ id, branch }: { id: string; branch: string }) => Promise<{\n clientMutationId?: string;\n }>;\n getFileInfoOnBranchByPath: (opt: {\n filePath: string;\n branch: string;\n }) => Promise<{ exists: boolean; filePath: string }>;\n}\n","export const endpoint = `/plugins`;\n\nexport enum ACTIONS {\n getContent = 'getContent',\n}\n\nexport interface GetContentRequest {\n type: ACTIONS.getContent;\n pluginId: string;\n}\n\nexport interface GetContentResponse {\n type: ACTIONS.getContent;\n ok: boolean;\n message?: string;\n payload: Record<string, unknown>;\n}\n\nexport type ActionRequests = GetContentRequest;\n\nexport type ActionResponses = GetContentResponse;\n","export const endpoint = `/files`;\n\nexport enum ACTIONS {\n verify = 'verify',\n}\n\nexport interface VerifyData {\n type: ACTIONS.verify;\n payload: {\n path: string;\n };\n}\n\nexport interface VerifyDataResponse {\n type: ACTIONS.verify;\n payload: {\n exists: boolean;\n relativePath: string;\n absolutePath: string;\n type: 'absolute' | 'relative' | 'package' | 'unknown';\n };\n}\n\nexport type Actions = VerifyData;\n\nexport type ActionResponses = VerifyDataResponse;\n","/**\n * The roles here are duplicates of the roles in the database.\n * It needs to be here, in the types package, so it can be used in all packages.\n * If we pull it in from `@knapsack/hasura-gql-client`, which is the source, we get a dependency cycle. So we do it this way.\n * If the roles change in the database, we need to change them here too. We will get a build error if we don't (see code in `@knapsack/hasura-gql-client`).\n */\n\nexport const rolesById = {\n ADMIN: 'ADMIN',\n ANONYMOUS: 'ANONYMOUS',\n CONTRIBUTOR: 'CONTRIBUTOR',\n EDITOR: 'EDITOR',\n MANAGER: 'MANAGER',\n VIEWER: 'VIEWER',\n} as const;\nexport const roles = Object.values(rolesById);\nexport type Role = keyof typeof rolesById;\n","import { KsAppClientDataAndMeta } from '@knapsack/types';\n\nexport type SiteDeployedWebhookBody = {\n siteId: string;\n appClientData: KsAppClientDataAndMeta;\n};\n\nexport const siteDeployedWebhookEndpoint = '/site-deployed';\n\nexport const gitHubOauthInternalEndpoint = '/github-auth';\n","import { isUrl } from '@knapsack/utils';\n\nconst { KS_DB_URL } = process.env;\nif (KS_DB_URL && !isUrl(KS_DB_URL)) {\n throw new Error(`KS_DB_URL is not a valid URL: '${KS_DB_URL}'`);\n}\nconst dbUrl = KS_DB_URL || 'https://db.knapsack.cloud';\nconst dbGqlEndpoint = new URL('/v1/graphql', dbUrl).toString();\n\nexport const ksUrls = {\n /**\n * Base URL for Knapsack DB (Hasura)\n * @default 'https://db.knapsack.cloud'\n */\n dbUrl,\n /**\n * App DB GraphQL endpoint for connecting to Hasura GraphQL.\n * @default 'https://db.knapsack.cloud/v1/graphql'\n */\n dbGqlEndpoint,\n};\n","export const ksHttpHeaders = {\n siteId: 'X-KS-Site-ID',\n instanceId: 'X-KS-Instance-Id',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA,+EAAAA,UAAAC,SAAA;AAAA;AAAA;AAEA,IAAAA,QAAO,UAAU;AAAA,MAChB,aAAa,CAAC,KAAK,KAAK,GAAG;AAAA,MAC3B,gBAAgB,CAAC,KAAK,KAAK,GAAG;AAAA,MAC9B,QAAQ,CAAC,GAAG,KAAK,GAAG;AAAA,MACpB,cAAc,CAAC,KAAK,KAAK,GAAG;AAAA,MAC5B,SAAS,CAAC,KAAK,KAAK,GAAG;AAAA,MACvB,SAAS,CAAC,KAAK,KAAK,GAAG;AAAA,MACvB,UAAU,CAAC,KAAK,KAAK,GAAG;AAAA,MACxB,SAAS,CAAC,GAAG,GAAG,CAAC;AAAA,MACjB,kBAAkB,CAAC,KAAK,KAAK,GA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kBT,IAAM,2BAA2C;AAAA,EACtD,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,aAAa,CAAC;AAAA,EACd,aAAa,6BAAM,aAAN;AACf;AAOO,IAAM,cAAc,wBAAC,WAAoC;AAC9D,MAAI,CAAC,0BAA0B,GAAG,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AACA,QAAM,EAAE,aAAa,GAAG,SAAS,IAAI,OAAO,yBAAyB;AACrE,QAAM,cAAc,kBAAkB,WAAW;AACjD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,aAAa,wBAAC,WAAW;AACvB,UAAI,SAAS,aAAc,QAAO;AAClC,aAAO,YAAY,MAAM,KAAK;AAAA,IAChC,GAHa;AAAA,EAIf;AACF,GAd2B;;;A4BnN3B;AAOO,IAAM,8BAA8B;AAEpC,IAAM,8BAA8B;;;ACT3C;AAAA,IAAAC,gBAAsB;AAEtB,IAAM,EAAE,UAAU,IAAI,QAAQ;AAC9B,IAAI,aAAa,KAAC,qBAAM,SAAS,GAAG;AAClC,QAAM,IAAI,MAAM,kCAAkC,SAAS,GAAG;AAChE;AACA,IAAM,QAAQ,aAAa;AAC3B,IAAM,gBAAgB,IAAI,IAAI,eAAe,KAAK,EAAE,SAAS;AAEtD,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AACF;;;ACpBA;AAAO,IAAM,gBAAgB;AAAA,EAC3B,QAAQ;AAAA,EACR,YAAY;AACd;","names":["exports","module","exports","module","exports","module","swizzle","exports","module","string","s","import_superstruct","import_superstruct","import_utils","colorString","__name","union","string","type","literal","string","union","type","union","string","union","type","optional","object","literal","optional","boolean","type","array","__name","type","isObject","expectType","__name","isObject","isObjKey","type","__name","__name","__name","__name","define","type","boolean","array","string","optional","number","__name","__export","ACTIONS","endpoint","HasuraRoles","import_utils"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.1__@swc+core@1.3.57_@swc+helpers_ww5ypu3n2haukmlxcrky22ydmq/node_modules/tsup/assets/cjs_shims.js","../../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js","../../../node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js","../../../node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js","../../../node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js","../src/index.ts","../src/users.ts","../../types/src/ui-config.ts","../../types/src/color-config.ts","../../types/src/typography-config.ts","../../types/src/nav-customization-config.ts","../../types/src/app-client-data/index.ts","../../types/src/type-utils.ts","../../types/src/app-client-data/blocks.ts","../../types/src/app-client-data/design-tokens.ts","../../types/src/app-client-data/design-tokens-types/token-data.ts","../../types/src/app-client-data/design-tokens-types/token-definitions.ts","../../types/src/app-client-data/design-tokens-types/token-src-value-info.ts","../../types/src/app-client-data/design-tokens-types/token-src.ts","../../types/src/app-client-data/design-tokens-types/token-utils.ts","../../types/src/app-client-data/patterns.ts","../../types/src/app-client-data/page.header.ts","../../types/src/app-client-data-v3/index.ts","../../types/src/app-client-data-migrations/4.1.7-demos.ts","../../types/src/app-client-data-migrations/index.ts","../../types/src/json-schema.ts","../../types/src/changes.ts","../../types/src/renderers.ts","../../types/src/renderer-client-types.ts","../../types/src/web-sockets.ts","../../types/src/git-providers.ts","../../types/src/api/plugins.ts","../../types/src/api/files.ts","../../types/src/user-roles.ts","../src/webhooks.ts","../src/ks-urls.ts","../src/http-headers.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n","module.exports = function isArrayish(obj) {\n\tif (!obj || typeof obj === 'string') {\n\t\treturn false;\n\t}\n\n\treturn obj instanceof Array || Array.isArray(obj) ||\n\t\t(obj.length >= 0 && (obj.splice instanceof Function ||\n\t\t\t(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));\n};\n","'use strict';\n\nvar isArrayish = require('is-arrayish');\n\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\n\nvar swizzle = module.exports = function swizzle(args) {\n\tvar results = [];\n\n\tfor (var i = 0, len = args.length; i < len; i++) {\n\t\tvar arg = args[i];\n\n\t\tif (isArrayish(arg)) {\n\t\t\t// http://jsperf.com/javascript-array-concat-vs-push/98\n\t\t\tresults = concat.call(results, slice.call(arg));\n\t\t} else {\n\t\t\tresults.push(arg);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nswizzle.wrap = function (fn) {\n\treturn function () {\n\t\treturn fn(swizzle(arguments));\n\t};\n};\n","/* MIT license */\nvar colorNames = require('color-name');\nvar swizzle = require('simple-swizzle');\nvar hasOwnProperty = Object.hasOwnProperty;\n\nvar reverseNames = Object.create(null);\n\n// create a list of reverse color names\nfor (var name in colorNames) {\n\tif (hasOwnProperty.call(colorNames, name)) {\n\t\treverseNames[colorNames[name]] = name;\n\t}\n}\n\nvar cs = module.exports = {\n\tto: {},\n\tget: {}\n};\n\ncs.get = function (string) {\n\tvar prefix = string.substring(0, 3).toLowerCase();\n\tvar val;\n\tvar model;\n\tswitch (prefix) {\n\t\tcase 'hsl':\n\t\t\tval = cs.get.hsl(string);\n\t\t\tmodel = 'hsl';\n\t\t\tbreak;\n\t\tcase 'hwb':\n\t\t\tval = cs.get.hwb(string);\n\t\t\tmodel = 'hwb';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tval = cs.get.rgb(string);\n\t\t\tmodel = 'rgb';\n\t\t\tbreak;\n\t}\n\n\tif (!val) {\n\t\treturn null;\n\t}\n\n\treturn {model: model, value: val};\n};\n\ncs.get.rgb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar abbr = /^#([a-f0-9]{3,4})$/i;\n\tvar hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;\n\tvar rgba = /^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar per = /^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar keyword = /^(\\w+)$/;\n\n\tvar rgb = [0, 0, 0, 1];\n\tvar match;\n\tvar i;\n\tvar hexAlpha;\n\n\tif (match = string.match(hex)) {\n\t\thexAlpha = match[2];\n\t\tmatch = match[1];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\t// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19\n\t\t\tvar i2 = i * 2;\n\t\t\trgb[i] = parseInt(match.slice(i2, i2 + 2), 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(abbr)) {\n\t\tmatch = match[1];\n\t\thexAlpha = match[3];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i] + match[i], 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(rgba)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i + 1], 0);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(per)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(keyword)) {\n\t\tif (match[1] === 'transparent') {\n\t\t\treturn [0, 0, 0, 0];\n\t\t}\n\n\t\tif (!hasOwnProperty.call(colorNames, match[1])) {\n\t\t\treturn null;\n\t\t}\n\n\t\trgb = colorNames[match[1]];\n\t\trgb[3] = 1;\n\n\t\treturn rgb;\n\t} else {\n\t\treturn null;\n\t}\n\n\tfor (i = 0; i < 3; i++) {\n\t\trgb[i] = clamp(rgb[i], 0, 255);\n\t}\n\trgb[3] = clamp(rgb[3], 0, 1);\n\n\treturn rgb;\n};\n\ncs.get.hsl = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hsl = /^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hsl);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar s = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar l = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\n\t\treturn [h, s, l, a];\n\t}\n\n\treturn null;\n};\n\ncs.get.hwb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hwb = /^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hwb);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar w = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar b = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\t\treturn [h, w, b, a];\n\t}\n\n\treturn null;\n};\n\ncs.to.hex = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn (\n\t\t'#' +\n\t\thexDouble(rgba[0]) +\n\t\thexDouble(rgba[1]) +\n\t\thexDouble(rgba[2]) +\n\t\t(rgba[3] < 1\n\t\t\t? (hexDouble(Math.round(rgba[3] * 255)))\n\t\t\t: '')\n\t);\n};\n\ncs.to.rgb = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'\n\t\t: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';\n};\n\ncs.to.rgb.percent = function () {\n\tvar rgba = swizzle(arguments);\n\n\tvar r = Math.round(rgba[0] / 255 * 100);\n\tvar g = Math.round(rgba[1] / 255 * 100);\n\tvar b = Math.round(rgba[2] / 255 * 100);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'\n\t\t: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';\n};\n\ncs.to.hsl = function () {\n\tvar hsla = swizzle(arguments);\n\treturn hsla.length < 4 || hsla[3] === 1\n\t\t? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'\n\t\t: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';\n};\n\n// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax\n// (hwb have alpha optional & 1 is default value)\ncs.to.hwb = function () {\n\tvar hwba = swizzle(arguments);\n\n\tvar a = '';\n\tif (hwba.length >= 4 && hwba[3] !== 1) {\n\t\ta = ', ' + hwba[3];\n\t}\n\n\treturn 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';\n};\n\ncs.to.keyword = function (rgb) {\n\treturn reverseNames[rgb.slice(0, 3)];\n};\n\n// helpers\nfunction clamp(num, min, max) {\n\treturn Math.min(Math.max(min, num), max);\n}\n\nfunction hexDouble(num) {\n\tvar str = Math.round(num).toString(16).toUpperCase();\n\treturn (str.length < 2) ? '0' + str : str;\n}\n","export * from './users';\nexport * from './webhooks';\nexport * from './ks-urls';\nexport * from './http-headers';\n","/**\n * @file\n *\n * All things involving low-level user JWT parsing, claims, roles.\n */\n\nimport {\n array,\n boolean,\n Describe,\n enums,\n number,\n object,\n optional,\n string,\n type,\n union,\n record,\n assign,\n} from 'superstruct';\nimport { roles, type Role } from '@knapsack/types';\n\n// Superstruct runtime validation for Role\nexport const RolesEnums = enums(roles);\nexport const RolesEnumsStruct: Describe<Role> = RolesEnums;\n\nexport const canRoleAdmin = (role: Role): boolean => role === 'ADMIN';\n\nexport const rolesThatCanManageUsers: Role[] = ['ADMIN', 'MANAGER'];\n\nexport const canRoleManageUsers = (role: Role): boolean =>\n rolesThatCanManageUsers.includes(role);\n\nexport const rolesThatCanDelete: Role[] = [\n ...rolesThatCanManageUsers,\n 'EDITOR',\n];\n\nexport const canRoleDelete = (role: Role): boolean =>\n rolesThatCanDelete.includes(role);\n\nexport const rolesThatCanEdit: Role[] = [...rolesThatCanDelete, 'CONTRIBUTOR'];\n\nexport const canRoleEdit = (role: Role): boolean =>\n rolesThatCanEdit.includes(role);\n\nexport const rolesThatCanPublish: Role[] = ['ADMIN'];\n\nexport const canRolePublish = (role: Role): boolean =>\n rolesThatCanPublish.includes(role);\n\nexport const rolesThatCanView: Role[] = [...rolesThatCanEdit, 'VIEWER'];\n\nexport const canRoleView = (role: Role): boolean =>\n rolesThatCanView.includes(role);\n\nexport const isRoleValid = (role: string): role is Role =>\n RolesEnumsStruct.is(role);\n\n/**\n * Please note that these are not the same as the \"roles\" used on a per-site\n * basis, these are roles for the entire DB.\n */\nexport enum HasuraRoles {\n // yes, `admin` exists but no reason anyone should have it, yet\n user = 'user',\n anonymous = 'anonymous',\n}\nconst HasuraRolesStruct = enums(Object.values(HasuraRoles));\n\nexport type HasuraClaims = {\n 'x-hasura-allowed-roles': HasuraRoles[];\n 'x-hasura-default-role': HasuraRoles;\n 'x-hasura-user-id'?: string;\n};\n// Superstruct runtime validation for HasuraClaims\nexport const HasuraClaimsStruct: Describe<HasuraClaims> = object({\n 'x-hasura-allowed-roles': array(HasuraRolesStruct),\n 'x-hasura-default-role': HasuraRolesStruct,\n 'x-hasura-user-id': optional(string()),\n});\n\n/**\n * The specific Knapsack claims that live at 'https://knapsack.cloud' within JWT\n */\nexport type KnapsackClaims = {\n userId: string;\n /** For email address that end in `knapsack.cloud` */\n isSuperAdmin: boolean;\n /**\n * Keys are roleId, value are array of siteId strings\n * Purposely kept small for JWT payloads. Often expanded.\n * @see {SiteRoleMap}\n * @see {expandSitesByRole}\n * @example\n * {\n * sitesByRole: {\n * EDITOR: ['ks-demo-bootstrap', 'ks-demo-tailwind'],\n * VIEWER: ['site-id-1'],\n * },\n * }\n */\n sitesByRole: {\n [roleId in Role]?: string[];\n };\n};\n// Superstruct runtime validation for KnapsackClaims\nexport const KsClaimsStruct: Describe<KnapsackClaims> = object({\n userId: string(),\n isSuperAdmin: boolean(),\n sitesByRole: record(RolesEnums, array(string())),\n});\n\n/**\n * The easier to work with & expanded version of `sitesByRole` in KsClaims,\n * which is kept as small as possible for JWT payloads.\n * @see {KnapsackClaims}\n */\nexport type SiteRoleMap = {\n [siteId: string]: Role;\n};\n\n/**\n * Base JWT\n */\nexport type JwtBase = {\n /* Token expiration time; usually 1 hour after issued at time (`iat`), in seconds (not ms) */\n exp: number;\n /* Email exists on ID token, but not AUTH token */\n email?: string;\n /* WARNING: email_verified is not guaranteed to exst on SSO tokens, and is boolean or string! */\n email_verified?: string | boolean;\n /* Issued at Time, in seconds (not ms) */\n iat: number;\n /* Issuer */\n iss: string;\n /* Subject (userId) */\n sub: string;\n /* Audience */\n aud: string | string[];\n};\n// Superstruct runtime validation for JwtBase. Use type() to ignore extra keys\nexport const JwtBaseStruct: Describe<JwtBase> = type({\n exp: number(),\n email: optional(string()),\n email_verified: optional(union([string(), boolean()])),\n iat: number(),\n iss: string(),\n sub: string(),\n aud: union([string(), array(string())]),\n});\n\n/**\n * Bring it all together to make a full JWT\n */\nexport const HASURA_CLAIMS_NAMESPACE = 'https://hasura.io/jwt/claims';\nexport const KNAPSACK_CLAIMS_NAMESPACE = 'https://knapsack.cloud';\n\n// Just custom claims\nexport type JwtCustomClaims = {\n [HASURA_CLAIMS_NAMESPACE]: HasuraClaims;\n [KNAPSACK_CLAIMS_NAMESPACE]: KnapsackClaims;\n};\n// Superstruct runtime validation for JwtCustomClaims\nexport const JwtCustomClaimsStruct: Describe<JwtCustomClaims> = object({\n [HASURA_CLAIMS_NAMESPACE]: HasuraClaimsStruct,\n [KNAPSACK_CLAIMS_NAMESPACE]: KsClaimsStruct,\n});\n\n// The entire JWT, custom claims + base root keys\nexport type JwtWithCustomClaims = JwtBase & JwtCustomClaims;\n// Superstruct runtime validation for JwtWithCustomClaims\nexport const JwtWithCustomClaimsStruct: Describe<JwtWithCustomClaims> = assign(\n JwtBaseStruct,\n JwtCustomClaimsStruct,\n);\n\n/**\n * Convert sitesByRole to be a map of siteId to roleId. This is the format we\n * actually use within the app to determine what sites a user can access.\n */\nexport function expandSitesByRole(\n sitesByRole: KnapsackClaims['sitesByRole'],\n): SiteRoleMap {\n return Object.entries(sitesByRole).reduce((cur, [roleId, siteIds]) => {\n if (!isRoleValid(roleId)) return cur;\n siteIds.forEach((siteId) => {\n cur[siteId] = roleId;\n });\n return cur;\n }, {} as SiteRoleMap);\n}\n\nexport type KsClaimsHelper = Omit<KnapsackClaims, 'sitesByRole'> & {\n siteRoleMap: SiteRoleMap;\n /** Get the User's Role for particular site */\n getSiteRole: (siteId: string) => Role;\n};\n\nexport const defaultAnonymousKsClaims: KsClaimsHelper = {\n isSuperAdmin: false,\n userId: '',\n siteRoleMap: {},\n getSiteRole: () => 'ANONYMOUS',\n};\n\n/**\n * Picks off the KsClaims from the JWT (since it has a weird to use\n * `https://knapsack.cloud` namespace) and then also converts the size-conscious\n * `sitesByRole` into the more usable format of `siteRoleMap\n */\nexport const getKsClaims = (claims: unknown): KsClaimsHelper => {\n if (!JwtWithCustomClaimsStruct.is(claims)) {\n return defaultAnonymousKsClaims;\n }\n const { sitesByRole, ...ksClaims } = claims[KNAPSACK_CLAIMS_NAMESPACE];\n const siteRoleMap = expandSitesByRole(sitesByRole);\n return {\n ...ksClaims,\n siteRoleMap,\n getSiteRole: (siteId) => {\n if (ksClaims.isSuperAdmin) return 'ADMIN';\n return siteRoleMap[siteId] || 'ANONYMOUS';\n },\n };\n};\n","import {\n type,\n Describe,\n literal,\n optional,\n defaulted,\n boolean,\n array,\n object,\n} from 'superstruct';\n\nimport { ExpandRecursively } from '@knapsack/utils';\n\nimport {\n ColorConfig,\n ColorConfigStruct,\n ColorStringStruct,\n} from './color-config';\n\nimport {\n FontFaceConfigStruct,\n FontFaceConfig,\n TypographyConfigStruct,\n TypographyLinkConfigStruct,\n pageElements,\n pageElementsV2,\n} from './typography-config';\n\nimport {\n customizableNavElements,\n NavCustomizationConfigStruct,\n PrimaryNavCustomizationConfigStruct,\n SecondaryNavCustomizationConfigStruct,\n} from './nav-customization-config';\n\nexport type UiConfigV1 = {\n version: 1;\n oldSillySidebarBgColor: string;\n};\n\nexport const UiConfigV1Struct: Describe<UiConfigV1> = object({\n version: literal(1),\n oldSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV2 = {\n version: 2;\n anotherSillySidebarBgColor: string;\n};\n\nexport const UiConfigV2Struct: Describe<UiConfigV2> = object({\n version: literal(2),\n anotherSillySidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV3 = {\n version: 3;\n sidebarBgColor: string;\n};\n\nexport const UiConfigV3Struct: Describe<UiConfigV3> = object({\n version: literal(3),\n sidebarBgColor: ColorStringStruct,\n});\n\nexport type UiConfigV4 = {\n version: 4;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n enableSidebarIcons?: boolean;\n};\nexport const UiConfigV4Struct: Describe<UiConfigV4> = object({\n version: literal(4),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport type UiConfigV5 = {\n version: 5;\n primaryColor: ColorConfig;\n darkColor: ColorConfig;\n lightColor: ColorConfig;\n linkColor: ColorConfig;\n enableSidebarIcons: boolean;\n};\nexport const UiConfigV5Struct: Describe<UiConfigV5> = object({\n version: literal(5),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n});\n\nexport interface _UiConfigV6 extends Omit<UiConfigV5, 'version'> {\n version: 6;\n appearance: {\n customFonts?: FontFaceConfig[];\n pageElements: typeof pageElements;\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfigV6' is not assignable to type 'Record<string, unknown>'.\" error\nexport type UiConfigV6 = ExpandRecursively<_UiConfigV6>;\n\nexport const UiConfigV6Struct: Describe<UiConfigV6> = object({\n version: literal(6),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV7 extends Omit<UiConfigV6, 'version'> {\n version: 7;\n appearance: {\n navigation?: typeof customizableNavElements;\n customFonts?: UiConfigV6['appearance']['customFonts'];\n pageElements: UiConfigV6['appearance']['pageElements'];\n };\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig7' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\nexport type UiConfigV7 = ExpandRecursively<_UiConfigV7>;\n\nexport const UiConfigV7Struct: Describe<UiConfigV7> = object({\n version: literal(7),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n enableSidebarIcons: optional(defaulted(boolean(), true)),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV8\n extends Omit<UiConfigV7, 'version' | 'enableSidebarIcons'> {\n version: 8;\n}\n\n// ExpandRecursively needed to avoid \"Type 'UiConfig8' is not assignable to type 'Record<string, unknown>'.\" error in ui-config.xstate.ts\n// TODO: move this to @knapsack/types\nexport type UiConfigV8 = ExpandRecursively<_UiConfigV8>;\n\nexport const UiConfigV8Struct: Describe<UiConfigV8> = object({\n version: literal(8),\n primaryColor: ColorConfigStruct,\n darkColor: ColorConfigStruct,\n lightColor: ColorConfigStruct,\n linkColor: ColorConfigStruct,\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV9\n extends Omit<\n UiConfigV8,\n 'version' | 'primaryColor' | 'darkColor' | 'lightColor' | 'linkColor'\n > {\n version: 9;\n}\nexport type UiConfigV9 = ExpandRecursively<_UiConfigV9>;\n\nexport const UiConfigV9Struct: Describe<UiConfigV9> = object({\n version: literal(9),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport interface _UiConfigV10 extends Omit<UiConfigV9, 'version'> {\n version: 10;\n appearance: {\n navigation?: UiConfigV9['appearance']['navigation'];\n customFonts?: UiConfigV9['appearance']['customFonts'];\n pageElements: typeof pageElementsV2;\n };\n}\nexport type UiConfigV10 = ExpandRecursively<_UiConfigV10>;\n\nexport const UiConfigV10Struct: Describe<UiConfigV10> = object({\n version: literal(10),\n\n appearance: type({\n customFonts: optional(array(FontFaceConfigStruct)),\n navigation: optional(\n type({\n primaryNav: optional(PrimaryNavCustomizationConfigStruct),\n secondaryNav: optional(SecondaryNavCustomizationConfigStruct),\n tabs: optional(NavCustomizationConfigStruct),\n }),\n ),\n pageElements: type({\n pageTitle: optional(TypographyConfigStruct),\n pageDescription: optional(TypographyConfigStruct),\n headingXLarge: optional(TypographyConfigStruct),\n headingLarge: optional(TypographyConfigStruct),\n headingMedium: optional(TypographyConfigStruct),\n headingSmall: optional(TypographyConfigStruct),\n headingXSmall: optional(TypographyConfigStruct),\n bodyText: optional(TypographyConfigStruct),\n link: optional(TypographyLinkConfigStruct),\n }),\n }),\n});\n\nexport type UiConfigVersions =\n | typeof UiConfigV1Struct.TYPE\n | typeof UiConfigV2Struct.TYPE\n | typeof UiConfigV3Struct.TYPE\n | typeof UiConfigV4Struct.TYPE\n | typeof UiConfigV5Struct.TYPE\n | typeof UiConfigV6Struct.TYPE\n | typeof UiConfigV7Struct.TYPE\n | typeof UiConfigV8Struct.TYPE\n | typeof UiConfigV9Struct.TYPE\n | typeof UiConfigV10Struct.TYPE;\n\n// ALIASES FOR LATEST VERSIONS\nexport type UiConfig = UiConfigV10;\nexport const UiConfigStruct: typeof UiConfigV10Struct = UiConfigV10Struct;\n\nexport type NavElementNames = keyof UiConfig['appearance']['navigation'];\n","import colorString from 'color-string';\nimport { define, Describe, literal, string, type, union } from 'superstruct'; // https://docs.superstructjs.org\n\n/** Use `import { isColor } from '@knapsack/color-utils'` if you can, need to duplicate this logic due to dep cycle */\nfunction isColor(color: unknown): color is string {\n if (typeof color !== 'string') return false;\n try {\n return !!colorString.get(color);\n } catch (e) {\n return false;\n }\n}\n\nexport type ColorTokenConfig = {\n type: 'design-token';\n /** Will be **either** `-` (old) or `.` (new) separated */\n tokenName: string;\n};\nexport type ColorConfig =\n | { type: 'value'; colorValue: string }\n | ColorTokenConfig;\n\nexport const ColorStringStruct = define<string>(\n 'ColorStringStruct',\n (value) => typeof value === 'string' && isColor(value),\n);\n\nexport const ColorConfigStruct: Describe<ColorConfig> = union([\n type({\n type: literal('value'),\n colorValue: ColorStringStruct,\n }),\n type({\n type: literal('design-token'),\n tokenName: string(),\n }),\n]);\n\n// so we can check if an object is not just a ColorConfig but specifically a token\nexport const ColorTokenConfigStruct: Describe<ColorTokenConfig> = type({\n type: literal('design-token'),\n tokenName: string(),\n});\n","import {\n Describe,\n string,\n type,\n union,\n number,\n enums,\n optional,\n literal,\n array,\n size,\n boolean,\n object,\n} from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\n\nexport const HeadingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\nexport type HeadingLevel = (typeof HeadingLevels)[number];\n\nexport type FontSizeConfigVal = {\n unit: 'px' | 'rem';\n value: number;\n};\n\nexport const FontSizeConfigValStruct: Describe<FontSizeConfigVal> = object({\n unit: enums(['rem', 'px']),\n value: number(),\n});\n\nexport type FontFaceWeight = number | string;\n\nexport const FontFaceWeightStruct: Describe<FontFaceWeight> = union([\n string(),\n number(),\n]);\n\nexport enum FontFaceSourceFormats {\n woff2 = 'woff2',\n woff = 'woff',\n}\n\nexport type FontFaceSource = {\n /**\n * Note: if /when we eventually add 'local' type support, format isn't used!\n */\n format: keyof typeof FontFaceSourceFormats;\n type: 'url';\n path: string;\n};\n\nexport const FontFaceFormatsEnumStruct = enums(['woff2', 'woff']);\n\nexport const FontFaceSourceStruct: Describe<FontFaceSource> = type({\n format: FontFaceFormatsEnumStruct,\n type: literal('url'),\n path: string(),\n});\n\nexport type FontFaceConfig = {\n /**\n * registered name of the custom font\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family @font-face's font-family property}\n */\n family?: string;\n\n /**\n * number between 1 and 1000.\n *\n * note: since two weights are allowed (with variable fonts), this type is an\n * optional array for easy parsing down the road.\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight @font-face's font-weight property}.\n */\n weight?: FontFaceWeight | FontFaceWeight[];\n\n /**\n * the collection of urls / paths pointing to font files\n *\n * MDN Docs on {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src @font-face's src property}.\n */\n src?: FontFaceSource[];\n\n /**\n * the style of the custom font (ex. normal or italic)\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style See MDN docs on font-style}.\n */\n style?: string;\n\n // @todo: implement these later\n // display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n // variationSettings?: string;\n // unicodeRange?: string; // or ideally, URange; //\n // see https://drafts.csswg.org/css-syntax-3/#urange-syntax and\n // https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range\n};\n\nexport const FontFaceConfigStruct: Describe<FontFaceConfig> = type({\n family: optional(string()),\n weight: optional(\n union([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)]),\n ),\n src: optional(array(FontFaceSourceStruct)),\n style: optional(string()),\n display: optional(enums(['auto', 'block', 'swap', 'fallback', 'optional'])),\n variationSettings: optional(string()),\n unicodeRange: optional(string()),\n});\n\nexport type FontSizeConfig = {\n min: FontSizeConfigVal;\n max?: FontSizeConfigVal;\n};\n\nexport enum TextTransforms {\n inherit = 'As typed',\n capitalize = 'Capitalize',\n lowercase = 'Lowercase',\n uppercase = 'Uppercase',\n}\n\nexport enum FontStretches {\n 'ultra-condensed' = 'Ultra-condensed',\n 'extra-condensed' = 'Extra-condensed',\n condensed = 'Condensed',\n 'semi-condensed' = 'Semi-condensed',\n normal = 'Normal',\n 'semi-expanded' = 'Semi-expanded',\n expanded = 'Expanded',\n 'extra-expanded' = 'Extra-expanded',\n 'ultra-expanded' = 'Ultra-expanded',\n}\n\nexport type TypographyConfig = {\n /**\n * min / max height used to future-proof way of supporting responsive typography\n */\n fontSize?: FontSizeConfig;\n\n /**\n * reminder: line-heights can also be unitless!\n */\n lineHeight?: string | number;\n fontWeight?: FontFaceWeight;\n\n /**\n * note: letter-spacing can't be unitless, unit required!\n */\n letterSpacing?: string;\n\n /**\n * if not specified, Knapsack default font, otherwise should allow for a stack of font strings + fallbacks (including the names of custom registered fonts)\n */\n fontFamily?: string;\n\n textColor?: ColorConfig;\n\n textTransform?: keyof typeof TextTransforms;\n\n fontStretch?: keyof typeof FontStretches;\n};\n\nexport interface TypographyLinkConfig {\n fontWeight?: FontFaceWeight;\n textColor?: ColorConfig;\n hoverColor?: ColorConfig;\n underline?: boolean;\n textTransform?: keyof typeof TextTransforms;\n fontStretch?: keyof typeof FontStretches;\n}\n\nexport const TypographyLinkConfigStruct: Describe<TypographyLinkConfig> = type({\n fontWeight: optional(union([string(), number()])),\n textColor: optional(ColorConfigStruct),\n hoverColor: optional(ColorConfigStruct),\n underline: optional(boolean()),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nexport const FontSizeConfigStruct: Describe<FontSizeConfig> = type({\n min: FontSizeConfigValStruct,\n max: optional(FontSizeConfigValStruct),\n});\n\nexport const TypographyConfigStruct: Describe<TypographyConfig> = type({\n fontSize: optional(FontSizeConfigStruct),\n lineHeight: optional(union([string(), number()])),\n fontWeight: optional(union([string(), number()])),\n letterSpacing: optional(string()),\n fontFamily: optional(string()),\n textColor: optional(ColorConfigStruct),\n textTransform: optional(\n enums(['inherit', 'capitalize', 'lowercase', 'uppercase']),\n ),\n fontStretch: optional(\n enums([\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'normal',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n ]),\n ),\n});\n\nconst pageElementConfig: TypographyConfig = {};\nconst pageLinkElementConfig: TypographyLinkConfig = {};\n\nexport const pageElements = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport const pageElementsV2 = {\n pageTitle: pageElementConfig,\n pageDescription: pageElementConfig,\n headingXLarge: pageElementConfig,\n headingLarge: pageElementConfig,\n headingMedium: pageElementConfig,\n headingSmall: pageElementConfig,\n headingXSmall: pageElementConfig,\n bodyText: pageElementConfig,\n link: pageLinkElementConfig,\n} as const;\n\nexport type PageElementNames = keyof typeof pageElementsV2;\nexport type PageElementConfig = (typeof pageElementsV2)[PageElementNames];\n","import { Describe, type, union, optional } from 'superstruct'; // https://docs.superstructjs.org\nimport { ColorConfig, ColorConfigStruct } from './color-config';\nimport { TypographyConfig, TypographyConfigStruct } from './typography-config';\n\nexport interface NavCustomizationConfig extends TypographyConfig {\n accentColor?: ColorConfig;\n}\n\nexport interface PrimaryNavCustomizationConfig extends NavCustomizationConfig {\n hoverColor?: ColorConfig;\n backgroundColor?: ColorConfig;\n}\n\nexport type SecondaryNavCustomizationConfig = Omit<\n PrimaryNavCustomizationConfig,\n 'hoverColor'\n>;\n\nexport const NavCustomizationConfigStruct: Describe<NavCustomizationConfig> =\n union([\n TypographyConfigStruct,\n type({\n accentColor: optional(ColorConfigStruct),\n }),\n ]);\n\n// hoverColor: optional(ColorConfigStruct),\nexport const PrimaryNavCustomizationConfigStruct: Describe<PrimaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n hoverColor: optional(ColorConfigStruct),\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nexport const SecondaryNavCustomizationConfigStruct: Describe<SecondaryNavCustomizationConfig> =\n union([\n NavCustomizationConfigStruct,\n type({\n backgroundColor: optional(ColorConfigStruct),\n }),\n ]);\n\nconst navCustomizationConfig: NavCustomizationConfig = {};\nconst secondaryNavCustomizationConfig: SecondaryNavCustomizationConfig = {};\nconst primaryNavCustomizationConfig: PrimaryNavCustomizationConfig = {};\n\nexport const customizableNavElements = {\n primaryNav: primaryNavCustomizationConfig,\n secondaryNav: secondaryNavCustomizationConfig,\n tabs: navCustomizationConfig,\n} as const;\n\nexport type CustomizableNavElementNames = keyof typeof customizableNavElements;\nexport type CustomizableNavElementConfig =\n (typeof customizableNavElements)[CustomizableNavElementNames];\n","import {\n // type structs validate that a value has a set of properties on it, but it does not assert anything about unspecified properties. This allows you to assert that a particular set of functionality exists without a strict equality check for properties.\n type,\n string,\n Describe,\n boolean,\n optional,\n array,\n number,\n define,\n} from 'superstruct';\nimport { isObjKey, isObject } from '../type-utils';\nimport type { KnapsackAssetSetsData } from './asset-sets';\nimport type { TokenSrcGroup } from './design-tokens-types';\nimport type { MetaState } from './meta';\nimport type { KnapsackNavsConfig } from './nav';\nimport type { KsFiles } from './files';\nimport type { BlockConfig } from './blocks';\nimport type { KnapsackCustomPagesData } from './custom-pages';\nimport type { Demo, PatternsState } from './patterns';\nimport { UiConfig } from '../ui-config';\nimport { PagesSettings } from './page';\nimport { BlocksSettings } from './blocks.settings';\nimport { DesignSrcFile } from '../design-src.types';\n\nexport * from './asset-sets';\nexport * from './blocks';\nexport * from './custom-pages';\nexport * from './design-tokens';\nexport * from './design-tokens-types';\nexport * from './nav';\nexport * from './files';\nexport * from './meta';\nexport * from './patterns';\nexport { PageHeaderSizes } from './page.header';\nexport type { PageHeaderSettings } from './page.header';\nexport type { PageTab, PageType } from './page';\n\nexport interface KsAppClientData {\n patternsState: PatternsState;\n customPagesState: KnapsackCustomPagesData;\n assetSetsState: KnapsackAssetSetsData;\n navsState: KnapsackNavsConfig;\n tokensSrc: TokenSrcGroup;\n metaState?: MetaState;\n filesState: KsFiles;\n db: {\n blocks: {\n byId: Record<string, BlockConfig>;\n settings: BlocksSettings;\n };\n demos: {\n byId: Record<string, Demo>;\n // \"never\" for now until there are actual settings for demos\n settings: Record<string, never>;\n };\n settings: {\n title?: string;\n hideTitleInNavigation?: boolean;\n logoUrl?: string;\n favicon?: `https://${string}`;\n theme?: UiConfig;\n pages?: PagesSettings;\n designSrcs?: {\n files?: DesignSrcFile[];\n };\n tokens?: {\n theming?: {\n /** Which template languages theming controls will show up for next to the components preview stage. */\n enabledRendererIds?: string[];\n };\n };\n prototyping?: {\n patternId: string;\n };\n };\n };\n}\n\nexport type KsAppClientDataNoMeta = Omit<KsAppClientData, 'metaState'>;\nexport type KsAppClientDataAndMeta = Required<KsAppClientData>;\n\nexport function isKsAppClientDataNoMeta(\n data: unknown,\n): data is KsAppClientDataNoMeta {\n if (!isObject(data)) return false;\n // TODO: bring in exhaustive key checking here so all keys are caught\n const requiredKeys: Array<keyof KsAppClientDataNoMeta> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'tokensSrc',\n 'db',\n ];\n if (!requiredKeys.every((key) => isObjKey(key, data))) return false;\n if (!isObjKey('metaState', data)) return true;\n return false;\n}\n\nexport const KsAppClientDataNoMetaStruct = define<KsAppClientDataNoMeta>(\n 'KsAppClientDataNoMeta',\n isKsAppClientDataNoMeta,\n);\n\nexport function isKsAppClientDataAndMeta(\n data: unknown,\n): data is KsAppClientDataAndMeta {\n if (!isObject(data)) return false;\n // TODO: bring in exhaustive key checking here so all keys are caught\n const requiredKeys: Array<keyof KsAppClientDataAndMeta> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'tokensSrc',\n 'metaState',\n 'db',\n ];\n return requiredKeys.every((key) => isObjKey(key, data));\n}\n\nexport const KsAppClientDataAndMetaStruct = define<KsAppClientDataAndMeta>(\n 'KsAppClientDataAndMeta',\n isKsAppClientDataAndMeta,\n);\n\nexport const KsMetaStateStruct: Describe<KsAppClientData['metaState']> = type({\n isLocalDev: boolean(),\n plugins: array(\n type({\n id: string(),\n hasContent: boolean(),\n clientPluginPath: optional(string()),\n cssPath: optional(string()),\n }),\n ),\n meta: optional(\n type({\n version: optional(string()),\n hasKnapsackCloud: boolean(),\n knapsackCloudSiteId: optional(string()),\n serverPort: optional(number()),\n websocketsPort: optional(number()),\n https: optional(boolean()),\n cacheDir: optional(string()),\n ksVersions: type({\n app: string(),\n }),\n }),\n ),\n});\n\nexport const isKsMetaState = KsMetaStateStruct.is;\n","// backwards compatibile exports\n// this file used to have utilities for types, but those really belong\n// in `@knapsack/utils` so we're re-exporting them from there\n// look for `type-tools.ts` in `@knapsack/utils` for the source\nexport { isObjKey, isObject } from '@knapsack/utils';\nexport type {\n GetValueOrAsyncReturnValue,\n ValueOrGetValue,\n ValueOf,\n Except,\n Simplify,\n AsyncReturnType,\n PackageJson,\n TsConfigJson,\n} from '@knapsack/utils';\n","import type { JSONContent } from '@tiptap/core';\nimport { TokenType } from './design-tokens-types';\n\nexport const BlockSizes = ['large', 'medium', 'small'] as const;\ntype BlockSize = (typeof BlockSizes)[number];\n\nexport const BlockSpacings = ['large', 'medium', 'small'] as const;\ntype BlockSpacing = (typeof BlockSpacings)[number];\n\nexport type BlockHeader = {\n showHeader?: boolean;\n title?: string;\n description?: string;\n};\n\n/**\n * Data for blocks made using the `createEmbedBlock` function\n */\ntype IframeBlockData = {\n url?: string;\n clickToInteract: boolean;\n height?: number | string;\n};\n\ntype BlockConfigBase<\n BlockType extends string,\n Data extends Record<string, unknown> = never,\n> = {\n // Unique across all blocks, basically a UUID upon creation\n // e.g. `ut79D2X_H`\n id: string;\n // Match this to a Slices `id` to use it\n blockType: BlockType;\n data: Data;\n header?: BlockHeader;\n size?: BlockSize;\n /** Controls the amount of spacing AFTER a block */\n spacing?: BlockSpacing;\n};\n\ntype BlockConfigUnion =\n | BlockConfigBase<\n 'component-spec-block',\n {\n patternId?: string;\n templateId?: string;\n collapsible?: boolean;\n expanded?: boolean;\n }\n >\n | BlockConfigBase<\n 'pattern-template-block',\n {\n patternId?: string;\n templateId?: string;\n demoId?: string;\n demoSize?: string;\n showSchemaForm?: boolean;\n showCodeSnippet?: boolean;\n hideControls?: boolean;\n allowResizing?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-src-tiles',\n {\n columns?: '4' | '3' | '2' | '1';\n imageStyles?: {\n align?: 'left' | 'right' | 'center';\n background?: 'dark' | 'light';\n corners?: 'square' | 'rounded';\n fit?: 'contain' | 'fill';\n seamless?: boolean;\n size?: 'auto' | 'small' | 'medium' | 'large' | 'xsmall' | 'xlarge';\n };\n items: {\n description?: JSONContent;\n fileId: string;\n nodeId: string;\n title?: string;\n }[];\n layout?: 'grid' | 'list';\n hideComponentProps?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-src-component',\n {\n fileId: string;\n componentId: string;\n contents: Array<'variants' | 'spec' | 'usage'>;\n styles?: {\n columns?: '4' | '3' | '2' | '1';\n image?: {\n align?: 'left' | 'right' | 'center';\n background?: 'dark' | 'light';\n corners?: 'square' | 'rounded';\n size?: 'auto' | 'small' | 'medium' | 'large' | 'xsmall' | 'xlarge';\n };\n layout?: 'grid' | 'list';\n };\n hideComponentProps?: boolean;\n hideComponentTitles?: boolean;\n }\n >\n | BlockConfigBase<\n 'text-editor',\n {\n autoFocus?: boolean;\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'files-list',\n {\n files: string[];\n }\n >\n | BlockConfigBase<\n 'callout',\n {\n type: 'error' | 'info' | 'success' | 'warning';\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'code-snippet',\n {\n content: JSONContent;\n }\n >\n | BlockConfigBase<'divider-block', Record<string, never>>\n | BlockConfigBase<\n 'guidelines',\n {\n guidelines: {\n id: string;\n image?: {\n src: string;\n title?: string;\n alt?: string;\n };\n imageFit?: 'contain' | 'cover';\n type: 'caution' | 'do' | 'dont';\n content?: JSONContent;\n }[];\n gridStyles?: {\n centered?: boolean;\n columns?: '4' | '3' | '2' | '1';\n };\n tileStyles?: {\n headerBeforeImage?: boolean;\n imageOutlined?: boolean;\n imageRounded?: boolean;\n imageSize?:\n | 'none'\n | 'small'\n | 'medium'\n | 'large'\n | 'xsmall'\n | 'xlarge';\n };\n }\n >\n | BlockConfigBase<\n 'image-block',\n {\n imageSize?: 'xs' | 's' | 'm' | 'l' | 'full';\n images?: {\n caption?: string;\n src: string;\n }[];\n }\n >\n | BlockConfigBase<\n 'shortcut-tiles',\n {\n shortcuts: {\n description?: string;\n id: string;\n image?: string;\n link: {\n external?: boolean;\n name?: string;\n path: string;\n };\n title: string;\n }[];\n gridStyles?: {\n columns?: '4' | '3' | '2' | '1';\n centered?: boolean;\n gapSize?: number;\n };\n tileStyles?: {\n imageSize?: 'none' | 'xsmall' | 'small' | 'medium' | 'large';\n outlined?: boolean;\n rounded?: boolean;\n titleSize?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';\n };\n }\n >\n | BlockConfigBase<\n 'table',\n {\n content: JSONContent;\n }\n >\n | BlockConfigBase<\n 'pattern-variations',\n {\n patternId?: string;\n templateId?: string;\n demoId?: string;\n variationId?: string;\n assetSetId?: string;\n excludePropValue?: string;\n includePropValue?: string;\n size?: 's' | 'm' | 'l' | 'full';\n hideBlockTitle?: boolean;\n }\n >\n | BlockConfigBase<\n 'design-tokens',\n {\n tokenType: TokenType | '';\n demoId: string;\n groupIds: string[];\n exclude?: string;\n include?: string;\n }\n >\n | BlockConfigBase<\n 'design-token-collection',\n {\n collectionId: string;\n }\n >\n | BlockConfigBase<\n 'pattern-list-block',\n {\n itemSize?: 'small' | 'medium' | 'large' | 'full';\n showDescriptions?: boolean;\n excludePatterns?: string[];\n }\n >\n | BlockConfigBase<\n 'pattern-status-table-block',\n {\n excludeHiddenNavItems?: boolean;\n excludePatterns?: string[];\n }\n >\n | BlockConfigBase<\n 'video',\n {\n video: {\n format: string;\n name: string;\n size: string;\n url: string;\n };\n }\n >\n /** @deprecated */\n | BlockConfigBase<\n 'design-token-block',\n {\n tokens?: {\n type?: TokenType;\n category?: string;\n tags?: string[];\n name?: string;\n exclude?: string;\n };\n demo?: {\n id?: string;\n };\n }\n >\n | BlockConfigBase<'generic-iframe', IframeBlockData>\n | BlockConfigBase<'abstract-block', IframeBlockData>\n | BlockConfigBase<'adobe-xd-block', IframeBlockData>\n | BlockConfigBase<'airtable-block', IframeBlockData>\n | BlockConfigBase<'figma-block', IframeBlockData>\n | BlockConfigBase<'framer-cloud-block', IframeBlockData>\n | BlockConfigBase<'lucidchart-block', IframeBlockData>\n | BlockConfigBase<'vimeo-block', IframeBlockData>\n | BlockConfigBase<'youtube-block', IframeBlockData>\n | BlockConfigBase<'whimsical-block', IframeBlockData>\n | BlockConfigBase<\n 'markdown-block',\n {\n md?: string | string[];\n /** Automatically switches to edit mode + autofocuses on the editor */\n autoEdit?: boolean;\n columns?: number;\n }\n >;\n\n/**\n * This is the config for a block - which is what is stored in `block.ID.json` and available at `data.db.blocks.byId[blockId]`\n *\n * @example\n * // Use the first generic to filter down to a specific block type\n * type PatternListBlockConfig = BlockConfig<'pattern-list-block'>;\n * // Access the field `data` by doing this:\n * type Data= BlockConfig<'pattern-list-block'>['data'];\n */\nexport type BlockConfig<\n BlockType extends BlockConfigUnion['blockType'] = BlockConfigUnion['blockType'],\n> = Extract<BlockConfigUnion, { blockType: BlockType }>;\n\n/** Block Collections can be in several locations */\nexport type BlockCollectionLocation =\n | {\n type: 'page';\n pageId: string;\n }\n /** Tab on Pattern Page */\n | {\n type: 'patternSubPage';\n patternId: string;\n subPageId: string;\n }\n /** At bottom of Pattern Template page (under Spec table) - least used location */\n | {\n type: 'patternTemplate';\n patternId: string;\n templateId: string;\n };\n","export const tokenNameDisplayFormats = {\n default: 'Default',\n android: 'Android',\n cssVar: 'CSS Var',\n json: 'JSON',\n less: 'Less',\n scss: 'SCSS',\n swift: 'Swift',\n} as const;\n\nexport type TokenNameDisplayFormat = keyof typeof tokenNameDisplayFormats;\n","import { Simplify, expectType, isObjKey, isObject } from '@knapsack/utils';\nimport * as s from 'superstruct';\nimport {\n NotTokenReference,\n TokenDefinition,\n TokenDefinitionComposite,\n TokenDefinitionSingular,\n TokenReference,\n TokenReferenceStruct,\n TokenType,\n hasTokenReferences,\n isTokenTypeComposite,\n} from './token-definitions';\nimport { TokenKsExtensions, TokenOrder } from './token-misc';\nimport { TokenSrcValue } from './token-src';\n\n/** Used for tokens AND groups */\ntype TokenDataBothCommon = {\n id: string;\n description?: string;\n};\n\n// Shows what a fully de-referenced `value` of a composite token would be\ntype CreateDataValueForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]: TokenDefinitionSingular<\n ValueObj[Key]['type']\n >['value'];\n};\n\nexpectType<\n CreateDataValueForComposite<TokenDefinitionComposite<'shadow'>['value']>[]\n>([\n {\n inset: false,\n color: '#000',\n offsetX: '0px',\n offsetY: '0px',\n spread: '0px',\n blur: '0px',\n },\n {\n color: '#000',\n offsetX: '0px',\n offsetY: '0px',\n spread: '0px',\n blur: '0px',\n inset: true,\n },\n]);\n\ntype TokenDataCommon<\n Info extends {\n /** Basically the ID */\n type: TokenDefinition['type'];\n value: unknown;\n },\n> = TokenDataBothCommon & {\n type: Info['type'];\n value: Info['value'];\n /**\n * Extracted from `$extensions['cloud.knapsack'].token`\n */\n tokenConfig?: TokenKsExtensions['token'];\n /**\n * Tokens that are references by this token\n * @todo will need to change for shadow\n * @example\n * ```\n * [\n * ['color.primary', 'color.secondary'],\n * ['spacing.medium']\n * ]\n * ```\n */\n references?: Array<string[]>;\n /**\n * Tokens that use this as a reference token\n * @see {CreateTokenData.references}\n * @example\n * * ```\n * [\n * ['color.primary', 'color.secondary'],\n * ['spacing.medium']\n * ]\n * ```\n */\n // referencedBy?: Array<string[]>;\n};\n\ntype CreateTokenData<\n Info extends {\n type: TokenDefinition['type'];\n value: unknown;\n },\n> =\n | ({\n kind: 'ref';\n /** Has `{}` removed */\n referencedTokenId: string;\n originalValue: TokenReference;\n } & TokenDataCommon<Info>)\n | ({\n kind: 'static';\n originalValue: NotTokenReference<TokenSrcValue<Info['type']>>;\n } & TokenDataCommon<Info>);\n\nconst TokenDataBaseStruct: s.Describe<\n TokenDataBothCommon & {\n references?: Array<string[]>;\n tokenConfig?: TokenKsExtensions['token'];\n }\n> = s.type({\n id: s.string(),\n description: s.optional(s.string()),\n references: s.optional(s.array(s.array(s.string()))),\n tokenConfig: s.optional(\n s.type({\n purpose: s.optional(s.string()),\n }),\n ),\n});\n\ntype TokenDataSingularRaw = {\n // ignore the key, this makes a discriminated union out of the values\n [TokenDef in TokenDefinitionSingular as TokenDef['type']]: Simplify<\n CreateTokenData<TokenDef>\n >;\n}[TokenDefinitionSingular['type']];\n\nexport type TokenDataSingular<\n TT extends TokenDataSingularRaw['type'] = TokenDataSingularRaw['type'],\n> = Extract<TokenDataSingularRaw, { type: TT }>;\n\nexpectType<TokenDataSingular[]>([\n {\n type: 'duration',\n value: '1ms',\n originalValue: '1ms',\n id: '1',\n kind: 'static',\n },\n {\n type: 'duration',\n value: '1ms',\n kind: 'ref',\n id: '1',\n originalValue: '{a.b}',\n referencedTokenId: '1',\n },\n // @ts-expect-error - kind is wrong\n {\n type: 'duration',\n value: '1ms',\n originalValue: '1ms',\n id: '1',\n kind: 'ref',\n },\n // @ts-expect-error - kind is wrong\n {\n type: 'duration',\n value: '1ms',\n kind: 'static',\n id: '1',\n originalValue: '{a.b}',\n referencedTokenId: '1',\n },\n {\n type: 'color',\n value: '#000',\n kind: 'static',\n id: '1',\n originalValue: '#000',\n },\n {\n type: 'color',\n value: '#000',\n kind: 'ref',\n id: '1',\n originalValue: '{c.b}',\n referencedTokenId: 'c.b',\n },\n {\n type: 'cubicBezier',\n kind: 'static',\n value: [0, 0, 0, 1],\n originalValue: [0, 0, 0, 1],\n id: '1',\n },\n]);\n\ntype TokenDataCompositeRaw = {\n [TokenType in TokenDefinitionComposite['type']]: Simplify<\n CreateTokenData<{\n type: TokenType;\n value: Simplify<\n CreateDataValueForComposite<\n TokenDefinitionComposite<TokenType>['value']\n >\n >;\n }>\n >;\n}[TokenDefinitionComposite['type']];\n\nexport type TokenDataComposite<\n TheTokenType extends TokenDataCompositeRaw['type'] = TokenDataCompositeRaw['type'],\n> = Extract<TokenDataCompositeRaw, { type: TheTokenType }>;\n\nexport function isTokenDataComposite(\n tokenData: TokenData,\n): tokenData is TokenDataComposite {\n return isTokenTypeComposite(tokenData.type);\n}\n\nexpectType<TokenDataComposite[]>([\n {\n type: 'border',\n kind: 'static',\n id: '1',\n value: {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n originalValue: {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n },\n {\n type: 'border',\n kind: 'ref',\n referencedTokenId: 'a.b',\n id: '1',\n value: {\n color: 'red',\n style: 'dashed',\n width: '2px',\n },\n originalValue: '{a.b}',\n },\n {\n type: 'shadow',\n value: {\n color: '#000',\n offsetX: '1px',\n offsetY: '1px',\n blur: '1px',\n spread: '1px',\n inset: false,\n },\n originalValue: {\n color: '#000',\n offsetX: '{a.a}',\n offsetY: '1px',\n blur: '1px',\n spread: '1px',\n inset: false,\n },\n id: '1',\n kind: 'static',\n },\n {\n type: 'shadow',\n kind: 'ref',\n referencedTokenId: 'a.b',\n value: {\n inset: true,\n color: 'red',\n offsetX: '1px',\n blur: '2px',\n offsetY: '3px',\n spread: '4px',\n },\n originalValue: '{a.b}',\n id: '1',\n },\n {\n type: 'transition',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: '{a.b}',\n kind: 'ref',\n referencedTokenId: 'a.b',\n id: '1',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: {\n duration: '100ms',\n delay: '{a.c}',\n timingFunction: '{a.c}',\n },\n id: '1',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n originalValue: {\n duration: '100ms',\n delay: '200ms',\n timingFunction: [0, 0, 0, 0],\n },\n id: '1',\n },\n]);\n\nexport type TokenData<\n TheTokenType extends TokenDataSingular['type'] | TokenDataComposite['type'] =\n | TokenDataSingular['type']\n | TokenDataComposite['type'],\n> = Extract<TokenDataSingular | TokenDataComposite, { type: TheTokenType }>;\n\nexport type TokenGroupData = Simplify<\n {\n type?: TokenType;\n /**\n * Extracted from `$extensions['cloud.knapsack'].group`\n */\n groupConfig?: TokenKsExtensions['group'];\n children: TokenOrder;\n } & TokenDataBothCommon\n>;\n\n/**\n * @deprecated Use `TokenValueColorStruct` instead\n */\nexport function isTokenValueColor(\n value: unknown,\n): value is TokenDefinitionSingular<'color'>['value'] {\n return typeof value === 'string' && !hasTokenReferences(value);\n}\n\nexport const TokenValueColorStruct = s.define<TokenData<'color'>['value']>(\n 'Color Value',\n (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (value === '') {\n return 'Value must not be empty';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n return true;\n },\n);\n\nconst TokenDataColorNonRefStruct: s.Describe<\n Extract<TokenData<'color'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('color'),\n value: TokenValueColorStruct,\n kind: s.literal('static'),\n originalValue: TokenValueColorStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataColorRefStruct: s.Describe<\n Extract<TokenData<'color'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('color'),\n value: TokenValueColorStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueDimensionStruct` instead\n */\nexport function isTokenValueDimension(\n value: unknown,\n): value is TokenDefinitionSingular<'dimension'>['value'] {\n return (\n typeof value === 'string' &&\n (value.endsWith('px') || value.endsWith('rem')) &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueDimensionStruct = s.define<\n TokenData<'dimension'>['value']\n>('Dimension Value', (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n if (\n !value.endsWith('px') &&\n !value.endsWith('rem') &&\n !value.endsWith('em') &&\n !value.endsWith('%')\n ) {\n return 'Value must end with px, rem, em or %';\n }\n return true;\n});\n\nconst TokenDataDimensionNonRefStruct: s.Describe<\n Extract<TokenData<'dimension'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('dimension'),\n value: TokenValueDimensionStruct,\n kind: s.literal('static'),\n originalValue: TokenValueDimensionStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataDimensionRefStruct: s.Describe<\n Extract<TokenData<'dimension'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('dimension'),\n value: TokenValueDimensionStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueDurationStruct` instead\n */\nexport function isTokenValueDuration(\n value: unknown,\n): value is TokenDefinitionSingular<'duration'>['value'] {\n return (\n typeof value === 'string' &&\n value.endsWith('ms') &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueDurationStruct = s.define<\n TokenData<'duration'>['value']\n>('Duration Value', (value) => {\n if (typeof value !== 'string') {\n return 'Value must be a string';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n\n const durationRegex = /^\\d+ms$/;\n if (!durationRegex.test(value)) {\n return 'Value must be a number followed by \"ms\" (e.g., \"100ms\")';\n }\n\n return true;\n});\n\nconst TokenDataDurationNonRefStruct: s.Describe<\n Extract<TokenData<'duration'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('duration'),\n value: TokenValueDurationStruct,\n kind: s.literal('static'),\n originalValue: TokenValueDurationStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataDurationRefStruct: s.Describe<\n Extract<TokenData<'duration'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('duration'),\n value: TokenValueDurationStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * @deprecated Use `TokenValueFontWeightStruct` instead\n */\nexport function isTokenValueFontWeight(\n value: unknown,\n): value is TokenDefinitionSingular<'fontWeight'>['value'] {\n return (\n (typeof value === 'string' || typeof value === 'number') &&\n !hasTokenReferences(value)\n );\n}\n\nexport const TokenValueFontWeightStruct = s.define<\n TokenData<'fontWeight'>['value']\n>('Font Weight Value', (value) => {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return 'Value must be a string or number';\n }\n if (hasTokenReferences(value)) {\n return 'Value must not contain {} (token references)';\n }\n return true;\n});\n\nconst TokenDataFontWeightNonRefStruct: s.Describe<\n Extract<TokenData<'fontWeight'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('fontWeight'),\n value: TokenValueFontWeightStruct,\n kind: s.literal('static'),\n originalValue: TokenValueFontWeightStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataFontWeightRefStruct: s.Describe<\n Extract<TokenData<'fontWeight'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('fontWeight'),\n value: TokenValueFontWeightStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nexport const TokenValueCubicBezierStruct = s.define<\n TokenData<'cubicBezier'>['value']\n>('Cubic Bezier Value', (value) => {\n if (!Array.isArray(value)) {\n return 'Value must be an array';\n }\n if (value.length !== 4) {\n return 'Value must be an array of 4 numbers';\n }\n if (!value.every((v) => typeof v === 'number')) {\n return 'Value must be an array of 4 numbers';\n }\n // check if the first and third values are between 0 and 1\n // cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )\n if (value[0] < 0 || value[0] > 1 || value[2] < 0 || value[2] > 1) {\n return 'The first and third cubicBezier values must be between 0 and 1';\n }\n return true;\n});\n\nconst TokenDataCubicBezierNonRefStruct: s.Describe<\n Extract<TokenData<'cubicBezier'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('cubicBezier'),\n value: TokenValueCubicBezierStruct,\n kind: s.literal('static'),\n originalValue: TokenValueCubicBezierStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataCubicBezierRefStruct: s.Describe<\n Extract<TokenData<'cubicBezier'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('cubicBezier'),\n value: TokenValueCubicBezierStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * Determines if it's a \"shadow\" token value AND totally de-referenced\n */\nexport function isTokenValueShadow(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'shadow'>['value']>\n> {\n return (\n isObject(value) &&\n isTokenValueColor(value.color) &&\n isTokenValueDimension(value.offsetX) &&\n isTokenValueDimension(value.offsetY) &&\n isTokenValueDimension(value.blur) &&\n isTokenValueDimension(value.spread)\n );\n}\n\nconst TokenValueShadowStruct = s.define<TokenData<'shadow'>['value']>(\n 'Shadow Value',\n (value) => {\n if (isTokenValueShadow(value)) return true;\n return `Expected a shadow value, got ${JSON.stringify(value)}`;\n },\n);\n\nconst TokenDataShadowNonRefStruct: s.Describe<\n Extract<TokenData<'shadow'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('shadow'),\n value: TokenValueShadowStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n color: s.union([TokenValueColorStruct, TokenReferenceStruct]),\n offsetX: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n offsetY: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n blur: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n spread: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n inset: s.union([\n // marking this as optional b/c it could be `undefined` instead of `false`\n s.optional(s.boolean()),\n TokenReferenceStruct,\n ]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataShadowRefStruct: s.Describe<\n Extract<TokenData<'shadow'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('shadow'),\n value: TokenValueShadowStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nexport const TokenValueStrokeStyleStruct = s.union([\n s.literal('solid'),\n s.literal('dashed'),\n s.literal('dotted'),\n s.literal('double'),\n s.literal('groove'),\n s.literal('ridge'),\n s.literal('outset'),\n s.literal('inset'),\n]);\n\n/**\n * Determines if it's a \"border\" token value AND totally de-referenced\n */\nexport function isTokenValueBorder(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'border'>['value']>\n> {\n return (\n isObject(value) &&\n TokenValueColorStruct.is(value.color) &&\n TokenValueStrokeStyleStruct.is(value.style) &&\n TokenValueDimensionStruct.is(value.width)\n );\n}\n\nconst TokenValueBorderStruct = s.define<TokenData<'border'>['value']>(\n 'Border Value',\n isTokenValueBorder,\n);\n\nconst TokenDataBorderNonRefStruct: s.Describe<\n Extract<TokenData<'border'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('border'),\n value: TokenValueBorderStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n color: s.union([TokenValueColorStruct, TokenReferenceStruct]),\n style: s.union([TokenValueStrokeStyleStruct, TokenReferenceStruct]),\n width: s.union([TokenValueDimensionStruct, TokenReferenceStruct]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBorderRefStruct: s.Describe<\n Extract<TokenData<'border'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('border'),\n value: TokenValueBorderStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n/**\n * Determines if it's a \"transition\" token value AND totally de-referenced\n */\nexport function isTokenValueTransition(\n value: unknown,\n): value is Simplify<\n CreateDataValueForComposite<TokenDefinitionComposite<'transition'>['value']>\n> {\n return (\n isObject(value) &&\n TokenValueCubicBezierStruct.is(value.timingFunction) &&\n TokenValueDurationStruct.is(value.duration) &&\n TokenValueDurationStruct.is(value.delay)\n );\n}\nconst TokenValueTransitionStruct = s.define<TokenData<'transition'>['value']>(\n 'Transition Value',\n isTokenValueTransition,\n);\n\nconst TokenDataTransitionNonRefStruct: s.Describe<\n Extract<TokenData<'transition'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('transition'),\n value: TokenValueTransitionStruct,\n kind: s.literal('static'),\n originalValue: s.type({\n timingFunction: s.union([\n TokenValueCubicBezierStruct,\n TokenReferenceStruct,\n ]),\n duration: s.union([TokenValueDurationStruct, TokenReferenceStruct]),\n delay: s.union([TokenValueDurationStruct, TokenReferenceStruct]),\n }),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataTransitionRefStruct: s.Describe<\n Extract<TokenData<'transition'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('transition'),\n value: TokenValueTransitionStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStringNonRefStruct: s.Describe<\n Extract<TokenData<'string'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('string'),\n value: s.string(),\n kind: s.literal('static'),\n originalValue: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStringRefStruct: s.Describe<\n Extract<TokenData<'string'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('string'),\n value: s.string(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStrokeStyleNonRefStruct: s.Describe<\n Extract<TokenData<'strokeStyle'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('strokeStyle'),\n value: TokenValueStrokeStyleStruct,\n kind: s.literal('static'),\n originalValue: TokenValueStrokeStyleStruct,\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataStrokeStyleRefStruct: s.Describe<\n Extract<TokenData<'strokeStyle'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('strokeStyle'),\n value: TokenValueStrokeStyleStruct,\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: TokenValueStrokeStyleStruct,\n }),\n TokenDataBaseStruct,\n);\n// const TokenDataFontFamilyNonRefStruct: s.Describe<\n// Extract<TokenData<'fontFamily'>, { kind: 'static' }>\n// > = s.assign(\n// s.type({\n// type: s.literal('fontFamily'),\n// value: s.union([s.string(), s.array(s.string())]),\n// kind: s.literal('static'),\n// originalValue: s.union([s.string(), s.array(s.string())]),\n// }),\n// TokenDataBaseStruct,\n// );\n\n// const TokenDataFontFamilyRefStruct: s.Describe<\n// Extract<TokenData<'fontFamily'>, { kind: 'ref' }>\n// > = s.assign(\n// s.type({\n// type: s.literal('fontFamily'),\n// value: s.union([s.string(), s.array(s.string())]),\n// kind: s.literal('ref'),\n// originalValue: TokenReferenceStruct,\n// referencedTokenId: s.string(),\n// }),\n// TokenDataBaseStruct,\n// );\n\nconst TokenDataNumberNonRefStruct: s.Describe<\n Extract<TokenData<'number'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('number'),\n value: s.number(),\n kind: s.literal('static'),\n originalValue: s.number(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataNumberRefStruct: s.Describe<\n Extract<TokenData<'number'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('number'),\n value: s.number(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBooleanNonRefStruct: s.Describe<\n Extract<TokenData<'boolean'>, { kind: 'static' }>\n> = s.assign(\n s.type({\n type: s.literal('boolean'),\n value: s.boolean(),\n kind: s.literal('static'),\n originalValue: s.boolean(),\n }),\n TokenDataBaseStruct,\n);\n\nconst TokenDataBooleanRefStruct: s.Describe<\n Extract<TokenData<'boolean'>, { kind: 'ref' }>\n> = s.assign(\n s.type({\n type: s.literal('boolean'),\n value: s.boolean(),\n kind: s.literal('ref'),\n originalValue: TokenReferenceStruct,\n referencedTokenId: s.string(),\n }),\n TokenDataBaseStruct,\n);\n\n// Instead of using `s.union` to combine all the token data structs,\n// we first find out what \"type\" the token is\n// then we find out `kind` - which is our 2nd layer of discriminated union\n// and then use the specific struct\n// that way the errors are more specific to the actual declared token \"type\"\n// In a nutshell, `s.union` is not very good at discriminated unions errors\nexport const assertTokenData = (data: unknown): asserts data is TokenData => {\n if (!isObject(data)) {\n throw new Error(\n `Expected token data to be an object, got ${JSON.stringify(data)}`,\n );\n }\n if (!isObjKey('type', data)) {\n throw new Error(\n `Expected token data to have a \"type\" property, got ${JSON.stringify(\n data,\n )}`,\n );\n }\n if (typeof data.type !== 'string') {\n throw new Error(\n `Expected token data \"type\" property to be a string, got ${JSON.stringify(\n data,\n )}`,\n );\n }\n const type = data.type as TokenData['type'];\n const kind = data.kind as TokenData['kind'];\n try {\n switch (type) {\n case 'boolean':\n if (kind === 'ref') {\n TokenDataBooleanRefStruct.assert(data);\n } else {\n TokenDataBooleanNonRefStruct.assert(data);\n }\n return;\n case 'border':\n if (kind === 'ref') {\n TokenDataBorderRefStruct.assert(data);\n } else {\n TokenDataBorderNonRefStruct.assert(data);\n }\n return;\n case 'color':\n if (kind === 'ref') {\n TokenDataColorRefStruct.assert(data);\n } else {\n TokenDataColorNonRefStruct.assert(data);\n }\n return;\n case 'cubicBezier':\n if (kind === 'ref') {\n TokenDataCubicBezierRefStruct.assert(data);\n } else {\n TokenDataCubicBezierNonRefStruct.assert(data);\n }\n return;\n case 'dimension':\n if (kind === 'ref') {\n TokenDataDimensionRefStruct.assert(data);\n } else {\n TokenDataDimensionNonRefStruct.assert(data);\n }\n return;\n case 'duration':\n if (kind === 'ref') {\n TokenDataDurationRefStruct.assert(data);\n } else {\n TokenDataDurationNonRefStruct.assert(data);\n }\n return;\n case 'fontWeight':\n if (kind === 'ref') {\n TokenDataFontWeightRefStruct.assert(data);\n } else {\n TokenDataFontWeightNonRefStruct.assert(data);\n }\n return;\n case 'number':\n if (kind === 'ref') {\n TokenDataNumberRefStruct.assert(data);\n } else {\n TokenDataNumberNonRefStruct.assert(data);\n }\n return;\n case 'shadow':\n if (kind === 'ref') {\n TokenDataShadowRefStruct.assert(data);\n } else {\n TokenDataShadowNonRefStruct.assert(data);\n }\n return;\n case 'string':\n if (kind === 'ref') {\n TokenDataStringRefStruct.assert(data);\n } else {\n TokenDataStringNonRefStruct.assert(data);\n }\n return;\n case 'strokeStyle': // temp implementation\n if (kind === 'ref') {\n TokenDataStrokeStyleRefStruct.assert(data);\n } else {\n TokenDataStrokeStyleNonRefStruct.assert(data);\n }\n return;\n // case 'fontFamily':\n // if (kind === 'ref') {\n // TokenDataFontFamilyRefStruct.assert(data);\n // } else {\n // TokenDataFontFamilyNonRefStruct.assert(data);\n // }\n // return;\n case 'transition':\n if (kind === 'ref') {\n TokenDataTransitionRefStruct.assert(data);\n } else {\n TokenDataTransitionNonRefStruct.assert(data);\n }\n return;\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`Unknown token data type: ${type}`);\n }\n }\n } catch (error) {\n if (!(error instanceof s.StructError)) throw error;\n throw new Error(\n `Invalid token data for type \"${type}\": ${\n error.message\n }. Received this data: \"${JSON.stringify(data)}\"`,\n );\n }\n};\n","import * as s from 'superstruct';\n\nexport const strokeStyleValues = [\n 'solid',\n 'dashed',\n 'dotted',\n 'double',\n 'groove',\n 'ridge',\n 'outset',\n 'inset',\n] as const;\n\n/**\n * Don't use this one, use this instead:\n * @see {@link TokenDefinitionSingular}\n */\ntype TokenDefinitionSingularRaw =\n | { type: 'string'; value: string }\n | { type: 'number'; value: number }\n | { type: 'boolean'; value: boolean }\n | { type: 'color'; value: string }\n | {\n type: 'strokeStyle';\n value: (typeof strokeStyleValues)[number];\n }\n | { type: 'dimension'; value: `${number}${'px' | 'rem' | 'em' | '%'}` }\n | { type: 'duration'; value: `${number}ms` }\n // | { type: 'fontFamily'; value: string | string[] }\n | {\n type: 'fontWeight';\n // @TODO: Include union of possible strings https://tr.designtokens.org/format/#font-weight\n value: string | number;\n }\n | { type: 'cubicBezier'; value: [number, number, number, number] };\n\n/**\n * Definitions for both singular (non-composite) tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionDimension = TokenDefinitionSingular<'dimension'>\n * ```\n */\nexport type TokenDefinitionSingular<\n TheTokenType extends TokenDefinitionSingularRaw['type'] = TokenDefinitionSingularRaw['type'],\n> = Extract<TokenDefinitionSingularRaw, { type: TheTokenType }>;\n\n/**\n * Don't use this one, use this instead:\n * @see {@link TokenDefinitionComposite}\n */\ntype TokenDefinitionCompositeRaw =\n | {\n type: 'border';\n value: {\n color: { type: 'color' };\n style: { type: 'strokeStyle' };\n width: { type: 'dimension' };\n };\n }\n | {\n type: 'shadow';\n value: {\n color: { type: 'color' };\n offsetX: { type: 'dimension' };\n offsetY: { type: 'dimension' };\n spread: { type: 'dimension' };\n blur: { type: 'dimension' };\n inset: { type: 'boolean' };\n };\n }\n | {\n type: 'transition';\n value: {\n duration: { type: 'duration' };\n delay: { type: 'duration' };\n timingFunction: { type: 'cubicBezier' };\n };\n };\n// | {\n// type: 'gradient';\n// value: {\n// color: { type: 'color' };\n// position: { type: 'dimension' };\n// }[];\n// };\n\n/**\n * Definitions for composite tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionShadow = TokenDefinitionComposite<'shadow'>\n * ```\n */\nexport type TokenDefinitionComposite<\n TheTokenType extends TokenDefinitionCompositeRaw['type'] = TokenDefinitionCompositeRaw['type'],\n> = Extract<TokenDefinitionCompositeRaw, { type: TheTokenType }>;\n\n/**\n * Definitions for both singular and composite tokens.\n * Use first generic param to get just that type.\n * @example\n * ```ts\n * type TokenDefinitionDimension = TokenDefinition<'dimension'>\n * ```\n */\nexport type TokenDefinition<\n TheTokenType extends\n | TokenDefinitionComposite['type']\n | TokenDefinitionSingular['type'] =\n | TokenDefinitionComposite['type']\n | TokenDefinitionSingular['type'],\n> = Extract<\n TokenDefinitionComposite | TokenDefinitionSingular,\n { type: TheTokenType }\n>;\n\nexport type TokenReference = `{${string}}`;\n/** ensures there is no `{}` */\nexport type NotTokenReference<T> = T extends TokenReference ? never : T;\n\nexport function isTokenReference(val: unknown): val is TokenReference {\n if (typeof val !== 'string') return false;\n // total times `{` appears in `val`\n // Handle situation `{a.b} {c.d}`. Ensure count of `{` and `}` === 1. This\n // guarantees we ONLY support a single reference, ie `{a.b}`\n const totalOpenBrackets = val.split('{').length - 1;\n return totalOpenBrackets === 1 && val.startsWith('{') && val.endsWith('}');\n}\n\nexport function hasTokenReferences(val: unknown): boolean {\n return typeof val === 'string' && val.includes('{');\n}\n\nexport function isNotTokenReference<T>(\n value: T,\n): value is NotTokenReference<T> {\n return !isTokenReference(value);\n}\n\nexport const TokenReferenceStruct = s.define<TokenReference>(\n 'Token Reference',\n (value) => {\n if (typeof value !== 'string') return false;\n if (isNotTokenReference(value)) {\n return 'Must start and end with curly braces';\n }\n return true;\n },\n);\n\nexport type TokenType = TokenDefinition['type'];\nexport type TokenTypeComposite = TokenDefinitionComposite['type'];\nexport type TokenTypeSingular = TokenDefinitionSingular['type'];\nexport type TokenValueSingular = TokenDefinitionSingular['value'];\n\n// We make a Record to ensure we have *every* possible value\n// b/c TS will yell at us if a new one is added but isn't included here\n// then we make an array out of them, so we can be sure we have *every* possible value\nconst compositeTypesRecord: Record<TokenTypeComposite, TokenTypeComposite> = {\n border: 'border',\n shadow: 'shadow',\n transition: 'transition',\n};\nexport const tokenTypeComposites = Object.values(compositeTypesRecord);\nconst singularTypesRecord: Record<TokenTypeSingular, TokenTypeSingular> = {\n string: 'string',\n number: 'number',\n boolean: 'boolean',\n color: 'color',\n dimension: 'dimension',\n duration: 'duration',\n // fontFamily: 'fontFamily',\n fontWeight: 'fontWeight',\n strokeStyle: 'strokeStyle',\n cubicBezier: 'cubicBezier',\n};\nexport const tokenTypeSingulars = Object.values(singularTypesRecord);\n/**\n * @deprecated You probably want `isTokenDataComposite`\n * @see {isTokenDataComposite}\n */\nexport function isTokenTypeComposite(\n type: TokenType,\n): type is TokenTypeComposite {\n return tokenTypeComposites.includes(type as TokenTypeComposite);\n}\n\nexport function isTokenTypeSingular(\n type: TokenType,\n): type is TokenTypeSingular {\n return tokenTypeSingulars.includes(type as TokenTypeSingular);\n}\n","import { Simplify, expectType } from '@knapsack/utils';\nimport {\n TokenType,\n TokenDefinitionSingular,\n TokenDefinitionComposite,\n isTokenTypeComposite,\n isTokenTypeSingular,\n} from './token-definitions';\n\ntype CreateTokenSrcValueInfo<\n T extends {\n type: TokenType;\n value: unknown;\n },\n> =\n | {\n kind: 'ref';\n /** Has `{}` removed */\n referencedTokenId: string;\n isVarRef?: boolean;\n type: T['type'];\n }\n | {\n kind: 'static';\n type: T['type'];\n value: T['value'];\n };\n\ntype TokenSrcValueInfoSingularRaw = {\n // Ignore the key, pay attention to the value\n // The values become the items in the discriminated union\n [TheTokenType in TokenDefinitionSingular as TheTokenType['type']]: Simplify<\n CreateTokenSrcValueInfo<TheTokenType>\n >;\n}[TokenDefinitionSingular['type']];\n\n// This helper allows us to just pass the type string in to get that\n// item out of the discriminated union: `TokenSrcValueInfoSingular<'color'>`\ntype TokenSrcValueInfoSingular<\n TT extends TokenSrcValueInfoSingularRaw['type'] = TokenSrcValueInfoSingularRaw['type'],\n> = Extract<TokenSrcValueInfoSingularRaw, { type: TT }>;\n\nexpectType<TokenSrcValueInfoSingular<'dimension'>[]>([\n {\n type: 'dimension',\n kind: 'static',\n value: '1px',\n },\n {\n type: 'dimension',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n]);\n\ntype CreateSrcValueInfoForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]: Simplify<\n CreateTokenSrcValueInfo<{\n type: ValueObj[Key]['type'];\n value: TokenDefinitionSingular<ValueObj[Key]['type']>['value'];\n }>\n >;\n};\n\ntype TokenSrcValueInfoCompositeRaw = {\n [TheTokenType in TokenDefinitionComposite['type']]: Simplify<\n CreateTokenSrcValueInfo<{\n type: TheTokenType;\n value: Simplify<\n CreateSrcValueInfoForComposite<\n TokenDefinitionComposite<TheTokenType>['value']\n >\n >;\n }>\n >;\n}[TokenDefinitionComposite['type']];\n\ntype TokenSrcValueInfoComposite<\n TT extends TokenSrcValueInfoCompositeRaw['type'] = TokenSrcValueInfoCompositeRaw['type'],\n> = Extract<TokenSrcValueInfoCompositeRaw, { type: TT }>;\n\nexpectType<TokenSrcValueInfoComposite<'border'>[]>([\n {\n type: 'border',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'border',\n kind: 'static',\n value: {\n color: {\n kind: 'static',\n type: 'color',\n value: 'red',\n },\n style: {\n kind: 'ref',\n type: 'strokeStyle',\n referencedTokenId: '', // FIX\n },\n width: {\n kind: 'static',\n type: 'dimension',\n value: '2px',\n },\n },\n },\n]);\n\nexpectType<TokenSrcValueInfoComposite<'transition'>[]>([\n {\n type: 'transition',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n delay: {\n kind: 'static',\n type: 'duration',\n value: '1ms',\n },\n duration: {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n timingFunction: {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n },\n },\n]);\n\nexport type TokenSrcValueInfo<\n TT extends\n | TokenSrcValueInfoComposite['type']\n | TokenSrcValueInfoSingular['type'] =\n | TokenSrcValueInfoComposite['type']\n | TokenSrcValueInfoSingular['type'],\n TheKind extends\n | TokenSrcValueInfoComposite['kind']\n | TokenSrcValueInfoSingular['kind'] =\n | TokenSrcValueInfoComposite['kind']\n | TokenSrcValueInfoSingular['kind'],\n> = Extract<\n TokenSrcValueInfoComposite | TokenSrcValueInfoSingular,\n { type: TT; kind: TheKind }\n>;\n\nexport function isTokenSrcValueInfoSingular(\n tokenSrcValueInfo: TokenSrcValueInfo,\n): tokenSrcValueInfo is TokenSrcValueInfoSingular {\n return isTokenTypeSingular(tokenSrcValueInfo?.type);\n}\nexport function isTokenSrcValueInfoComposite(\n tokenSrcValueInfo: TokenSrcValueInfo,\n): tokenSrcValueInfo is TokenSrcValueInfoComposite {\n return isTokenTypeComposite(tokenSrcValueInfo?.type);\n}\n\nexpectType<TokenSrcValueInfo[]>([\n {\n type: 'dimension',\n kind: 'static',\n value: '1px',\n },\n {\n type: 'transition',\n kind: 'ref',\n referencedTokenId: 'a.b',\n },\n {\n type: 'transition',\n kind: 'ref',\n // @ts-expect-error - with `kind: 'ref'`, `value` is not allowed\n value: '1px',\n },\n {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n {\n type: 'transition',\n kind: 'static',\n value: {\n delay: {\n kind: 'static',\n type: 'duration',\n value: '1ms',\n },\n duration: {\n kind: 'ref',\n type: 'duration',\n referencedTokenId: 'animation.slow',\n },\n timingFunction: {\n kind: 'static',\n type: 'cubicBezier',\n value: [0.4, 0.0, 0.2, 1],\n },\n },\n },\n]);\n\n/**\n * A common object that is used to represent a token in the app.\n * Used in functions for editing communication between UI forms, Xstate,\n * and `@knapsack/design-tokens-utils`.\n */\nexport type TokenInfo<\n TheTokenType extends TokenSrcValueInfo['type'] = TokenSrcValueInfo['type'],\n> = {\n tokenSrcValueInfo: TokenSrcValueInfo<TheTokenType>;\n tokenId: string;\n description?: string;\n};\n","import { Simplify, expectType, isObjKey, isObject } from '@knapsack/utils';\nimport {\n TokenDefinitionComposite,\n TokenDefinitionSingular,\n TokenReference,\n TokenType,\n TokenDefinition,\n} from './token-definitions';\nimport { TokenKsExtensions } from './token-misc';\n\nexport type TokenSrcCommon<TheType extends TokenType = TokenType> = {\n $type?: TokenDefinition<TheType>['type'];\n $description?: string;\n $extensions?: {\n 'cloud.knapsack'?: TokenKsExtensions;\n };\n};\n\nexport function isTokenSrcExtensions(\n extensionsObj: unknown,\n): extensionsObj is TokenSrcCommon['$extensions'] {\n return isObject(extensionsObj) && isObjKey('cloud.knapsack', extensionsObj);\n}\n\ntype CreateSrcValueForComposite<\n ValueObj extends Record<string, { type: TokenDefinitionSingular['type'] }>,\n> = {\n [Key in keyof ValueObj]:\n | TokenReference\n | TokenDefinitionSingular<ValueObj[Key]['type']>['value'];\n};\n\ntype TokenSrcValueCompositeRaw = {\n [TheTokenType in TokenDefinitionComposite['type']]: Simplify<{\n type: TheTokenType;\n value: Simplify<\n CreateSrcValueForComposite<\n TokenDefinitionComposite<TheTokenType>['value']\n >\n >;\n }>;\n}[TokenDefinitionComposite['type']];\n\ntype TokenSrcValueComposite<\n TT extends TokenSrcValueCompositeRaw['type'] = TokenSrcValueCompositeRaw['type'],\n> = Extract<TokenSrcValueCompositeRaw, { type: TT }>;\n\ntype TokenSrcValueRaw = TokenDefinitionSingular | TokenSrcValueComposite;\n\nexport type TokenSrcValue<\n Type extends\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'] =\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'],\n> = Extract<TokenSrcValueRaw, { type: Type }>['value'] | TokenReference;\n\nexpectType<TokenSrcValue[]>([\n '#ddd',\n true,\n [83, 1, 1, 1],\n {\n color: '#000',\n style: 'solid',\n width: '1px',\n },\n {\n inset: true,\n color: '#000',\n offsetX: '0px',\n offsetY: '{spacing.medium}',\n spread: '0px',\n blur: '0px',\n },\n {\n timingFunction: '{timing.ease}',\n duration: '{timing.duration.medium}',\n delay: '7ms',\n color: '#000',\n },\n]);\n\nexport type TokenSrc<\n TheType extends\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'] =\n | TokenDefinitionSingular['type']\n | TokenSrcValueComposite['type'],\n> = Simplify<\n {\n $value: TokenSrcValue<TheType>;\n } & TokenSrcCommon<TheType>\n>;\n\nexport function isTokenSrc(tokenObject: unknown): tokenObject is TokenSrc {\n if (isObject(tokenObject) && isObjKey('$value', tokenObject)) return true;\n return false;\n}\n\nexport type TokenSrcGroup = TokenSrcCommon & {\n [key: string]:\n | TokenSrcGroup\n | TokenSrc\n | TokenSrcCommon\n | TokenSrcCommon['$extensions'];\n};\n\nexport function isTokenGroup(\n tokenObject: unknown,\n): tokenObject is TokenSrcGroup {\n // @todo improve\n return (\n isObject(tokenObject) &&\n !isTokenSrcExtensions(tokenObject) &&\n !isObjKey('$value', tokenObject) &&\n // ensuring we are not in `$extensions` object\n !isObjKey('cloud.knapsack', tokenObject)\n );\n}\n\n// Token VAR references look like TokenSrcGroup\nexport function isTokenTypeVarRef(tokenObject: unknown) {\n // It's at least a TokenSrcGroup\n if (isTokenGroup(tokenObject)) {\n // The specific key within collectionInfo with the var reference\n const varRefCollectionInfo =\n tokenObject.$extensions['cloud.knapsack'].group.collectionInfo;\n if (\n isObjKey('type', varRefCollectionInfo) &&\n isObjKey('referenceId', varRefCollectionInfo)\n ) {\n return true;\n }\n }\n\n return false;\n}\n","import { parseNumberWithUnit } from '@knapsack/utils';\n\nexport function getPrimitiveValue(\n tokenValue: unknown,\n): 'string' | 'number' | 'boolean' {\n const type = typeof tokenValue;\n if (type === 'string' || type === 'number' || type === 'boolean') {\n return type;\n }\n throw new Error(\n `Invalid token value type: ${JSON.stringify(\n type,\n )}. Token value is: ${JSON.stringify(tokenValue)}`,\n );\n}\n\nexport type TokenDimensionUnit = 'px' | 'rem' | 'em' | '%';\n\n/**\n * Dimension strings require ending in 'px' or 'rem'\n * @see `libs/types/src/app-client-data/design-tokens-types/token-definitions.ts`\n */\nexport const isDimensionString = (\n value: string,\n): value is `${number}${'px' | 'rem' | 'em' | '%'}` =>\n value.includes('px') ||\n value.includes('rem') ||\n value.includes('em') ||\n value.includes('%');\n\n/**\n * Pass in values like `'12px'` to get detailed info\n * @throws if value is not a number or does not end in supported unit\n */\nexport function parseTokenDimensionValue(valueToParse: string | number): {\n value: number;\n unit?: TokenDimensionUnit;\n} {\n const { value, unit } = parseNumberWithUnit(valueToParse);\n if (!unit) {\n return { value };\n }\n if (unit !== 'px' && unit !== 'rem' && unit !== 'em' && unit !== '%') {\n throw new Error(`Invalid unit \"${unit}\" for value: ${value}`);\n }\n\n return { value, unit };\n}\n","import type { CSSProperties } from 'react';\nimport type { JsonSchemaObject } from '../json-schema';\nimport { RendererId } from '../renderers';\nimport { isObject } from '../type-utils';\nimport type { BlockConfig } from './blocks';\nimport type { Page, PageTab } from './page';\nimport { TokenSrcValueInfo } from './design-tokens-types/token-src-value-info';\n\nexport interface KsStatus {\n id: string;\n title: string;\n color?: string;\n}\n\nexport interface KsStatusSet {\n id: string;\n title: string;\n statuses: KsStatus[];\n}\n\n/**\n * Used by template renderers in addition to `path`\n * Twig: `@components/button.twig`\n * Web Components: `my-button` => `<my-button>`\n * React: a named export of the file if not `default`\n * @todo Replace this with `rendererOptions`\n */\ntype TemplateAlias = string;\n\nexport type SlottedTemplateDemo = {\n type: 'template-demo';\n /** @deprecated */\n patternId: string;\n /** @deprecated */\n templateId: string;\n /**\n * The demo referenced by `demoId` is inlined here before sending to server to\n * render, but is never stored in the json data. If this is present, it is\n * used instead of the demo referenced by `demoId`. This is done to ensure\n * server has all the latest data for a template demo by ensuring it includes\n * it's slotted children's data.\n * @see {inlineDemoData}\n */\n demo?: DataDemo;\n demoId: DemoBase['id'];\n};\n\n/**\n * i.e. Given a React Component, `Button`, this set to null/false would be\n * `<Button>` and set to true it would just be a reference to it: `Button`\n * @see {KsSlotInfo['isTemplateReference']}\n */\nexport type SlottedTemplateReference = {\n type: 'template-reference';\n patternId: string;\n templateId: string;\n};\n\nexport type SlottedText = {\n type: 'text';\n text: string;\n};\n\nexport type SlottedData =\n | SlottedText\n | SlottedTemplateDemo\n | SlottedTemplateReference;\n\n/** @deprecated - just check `type` */\nexport const isSlottedText = (\n slottedData: unknown,\n): slottedData is SlottedText =>\n isObject(slottedData) && slottedData.type === 'text';\n\n/** @deprecated - just check `type` */\nexport function isSlottedTemplateDemo(\n slottedData: unknown,\n): slottedData is SlottedTemplateDemo {\n return isObject(slottedData) && slottedData.type === 'template-demo';\n}\n\n/** @deprecated - just check `type` */\nexport function isSlottedTemplateReference(\n slottedData: unknown,\n): slottedData is SlottedTemplateReference {\n return isObject(slottedData) && slottedData.type === 'template-reference';\n}\n\n/**\n * Collection ID: Mode ID\n */\nexport type ThemeDefinition = {\n [collectionId: string]: string;\n};\n\nexport type SlotOptions = {\n /**\n * @default 'div'\n */\n wrappingElementName?: string;\n cssClasses?: string[];\n align?: {\n value:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'left'\n | 'center'\n | 'right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right';\n };\n layout?: {\n value: 'horizontal' | 'vertical' | 'wrap';\n };\n gap?: {\n value: TokenSrcValueInfo<'dimension'>;\n };\n paddingHorizontal?: {\n value: TokenSrcValueInfo<'dimension'>[];\n };\n paddingVertical?: {\n value: TokenSrcValueInfo<'dimension'>[];\n };\n /**\n * Collection ID: Mode ID\n */\n theme?: ThemeDefinition;\n};\n\n/**\n * These are created from {SlotOptions}\n * Only available in App Client for rendering - this is NOT saved in App Client Data\n */\nexport type SlotOptionsComputed = {\n styles: CSSProperties;\n cssClasses: string[];\n /**\n * @default 'div'\n */\n wrappingElementName: string;\n /**\n * can't be `style` or `class` or `className`\n */\n attributes: {\n [attributeName: string]: string;\n };\n};\n\nexport type KnapsackTemplateData = {\n /**\n * @todo Ideal would be `{ [key: string]: string | boolean | number }`\n */\n props: {\n [prop: string]: any;\n };\n slots?: {\n [slotName: string]: Array<SlottedData>;\n };\n /**\n * Settings from users are stored here and saved in App Client Data\n * This is used to dynamically create `slotsOptionsComputed`\n */\n slotsOptions?: {\n [slotName: string]: SlotOptions;\n };\n /**\n * Use `slotsOptions` to set & save styles on slotted children\n * Never set nor stored in App Client Data that gets saved\n * This is only inlined in the demo data for rendering so the App Client can\n * apply the styles to the slotted children\n * @see {inlineDemoData}\n */\n slotsOptionsComputed?: {\n [slotName: string]: SlotOptionsComputed;\n };\n};\n\ntype DemoType = 'data' | 'template';\n\ntype DemoBase = {\n id: string;\n title: string;\n description?: string;\n /**\n * Would override what was on the template\n */\n assetSetId?: string;\n width?: number;\n height?: number;\n type: DemoType;\n /** Collection ID: Mode ID */\n theme?: ThemeDefinition;\n};\n\n/**\n * Shows usage\n */\nexport type DataDemo = DemoBase & {\n type: 'data';\n patternId: string;\n templateId: string;\n data: KnapsackTemplateData;\n};\n\n/**\n * Shows source code\n */\nexport type TemplateDemo = DemoBase & {\n type: 'template';\n templateInfo: {\n alias?: TemplateAlias;\n path?: string;\n };\n};\n\nexport type Demo = TemplateDemo | DataDemo;\n\nexport type RenderDataDemo = Demo & {\n inlineStyles?: string;\n bodyAttributes?: Record<string, string>;\n};\n\n/** @deprecated */\nexport enum StageLayouts {\n portrait = 'portrait',\n landscape = 'landscape',\n}\n\nexport function isDataDemo(demo: TemplateDemo | DataDemo): demo is DataDemo {\n return demo?.type === 'data';\n}\n\nexport function isTemplateDemo(demo: Demo): demo is TemplateDemo {\n return demo?.type === 'template';\n}\n\nexport type KsSlotInfo = {\n title: string;\n description?: string;\n disallowText?: boolean;\n isRequired?: boolean;\n allowOnlyOne?: boolean;\n /**\n * i.e. Given a React Component, `Button`, this set to null/false would be\n * `<Button>` and set to true it would just be a reference to it: `Button`\n * @see {SlottedTemplateReference}\n */\n isTemplateReference?: boolean;\n allowedPatternIds?: string[];\n};\n\n/**\n * Supersedes `schema`\n */\nexport type KsTemplateSpec = {\n /**\n * Attempt to create the props & slots spec by reading the source file.\n * Prevents ability to use spec editor.\n *\n * If `true`, then uses the template `alias` & `path` to find the file.\n *\n * If a string, then that file path is used in place of the source file.\n *\n * Scenario: the `path` is used to point to a compiled file w types stripped\n * and this is used to point to either the source file w types or the compiled\n * `.d.ts` file. Currently only React is supported. The file extension\n * determines if TypeScript (ts/tsx) or PropTypes (js/jsx) is used for\n * inference.\n */\n isInferred?: boolean | string;\n /**\n * JSON Schema defining the serializable data passed in\n * The classic, formerly `schema`\n */\n props?: JsonSchemaObject;\n /**\n * Child component slots\n */\n slots?: {\n [name: string]: KsSlotInfo;\n };\n /**\n * @todo evaluate & refine\n */\n // cssProps?: {\n // [name: string]: {\n // title: string;\n // description: string;\n // };\n // };\n hidePropsTable?: boolean;\n hideSlotsTable?: boolean;\n /**\n * Extra Docs are each shown in their own table.\n * Useful for non-traditional spec docs that are more template language specific.\n * Examples: events, methods, etc\n */\n extraDocs?: {\n id: string;\n title: string;\n description?: string;\n tableRows?: {\n [columnTitle: string]: string;\n }[];\n }[];\n};\n\nexport interface KnapsackPatternTemplate {\n id: string;\n title?: string;\n /**\n * Relative file path to the template from the config file it is declared in\n */\n path: string;\n\n alias?: TemplateAlias;\n /**\n * Which template language? i.e. `twig`, `react` Replaces\n * KnapsackTemplateRenderer.test which ran a test on the file path (similar to\n * how WebPack loader `test` works)\n */\n templateLanguageId: RendererId;\n assetSetIds?: string[];\n spec?: KsTemplateSpec;\n /** Array of demo IDs, actual demo data is stored in `db.demos.demosById` */\n demoIds: Demo['id'][];\n /** Array of block IDs, actual block content is stored in db.blocks.blocksById */\n blockIds: BlockConfig['id'][];\n}\n\nexport type KnapsackPattern = Page & {\n $schema?: string;\n statuses?: {\n [statusSetId: string]: string;\n };\n templates?: KnapsackPatternTemplate[];\n subPages?: {\n id: string;\n title: string;\n blockIds: BlockConfig['id'][];\n }[];\n designSrcComponentsById?: Record<\n string,\n {\n id: string;\n title: string;\n componentId: string;\n fileId: string;\n }\n >;\n /** Controls order of `templates` & `subPages` on Pattern Page */\n tabs?: PageTab[];\n\n aliases?: string[];\n /**\n * Prevents pattern from appearing in System Overview and Status Table blocks\n */\n hideFromOverviewBlocks?: boolean;\n /**\n * Prevents pattern from appearing as an option in Component Embed and\n * Component Demo blocks\n */\n hideFromComponentBlocks?: boolean;\n};\n\nexport interface KnapsackPatternTemplateCode {\n html: string;\n data?: Record<string, any>;\n templateSrc: string;\n usage: string;\n language: string;\n}\n\nexport type KnapsackPatternsConfig = {\n $schema?: string;\n statusSets: KsStatusSet[];\n};\n\nexport interface TemplateRendererMeta {\n id: RendererId;\n title: string;\n version?: string;\n aliasTitle?: string;\n aliasDescription?: string;\n aliasUse: 'off' | 'optional' | 'required';\n aliasIsJsNamedExport?: boolean;\n syntaxHighlightingLanguage?: string;\n enableDataDemos: boolean;\n enableTemplateDemos: boolean;\n hasSlotsSupport: boolean;\n hasSlotOptionsSupport?: boolean;\n hasInferSpecSupport: boolean;\n hasTemplateSuggestionsSupport: boolean;\n prototypingTemplate?: {\n path: string;\n alias?: string;\n spec: Pick<KsTemplateSpec, 'props' | 'slots' | 'isInferred'>;\n };\n}\n\nexport type PatternsState = {\n patterns: {\n [id: string]: KnapsackPattern;\n };\n renderers: Partial<\n Record<\n RendererId,\n {\n meta: TemplateRendererMeta;\n }\n >\n >;\n} & KnapsackPatternsConfig;\n","import { ColorConfig } from '../color-config';\n\nexport enum PageHeaderSizes {\n auto = 'auto',\n small = 'small',\n medium = 'medium',\n large = 'large',\n full = 'full',\n}\n\nexport interface PageHeaderSettings {\n size?: `${PageHeaderSizes}`;\n backgroundImage?: string;\n backgroundColor?: ColorConfig;\n backgroundOverlay?: boolean;\n backgroundSize?: 'cover' | 'contain' | 'string';\n backgroundPosition?: 'left' | 'center' | 'right' | 'string';\n backgroundRepeat?: 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat';\n hideText?: boolean;\n textColorTitle?: ColorConfig;\n textColorDescription?: ColorConfig;\n}\n","import {\n // type structs validate that a value has a set of properties on it, but it does not assert anything about unspecified properties. This allows you to assert that a particular set of functionality exists without a strict equality check for properties.\n type,\n string,\n Describe,\n boolean,\n optional,\n array,\n number,\n define,\n} from 'superstruct';\nimport { isObjKey, isObject } from '../type-utils';\nimport type { KnapsackAssetSetsData } from './asset-sets';\nimport type { KsDesignTokensState } from './design-tokens';\nimport type { MetaState } from './meta';\nimport type { KnapsackNavsConfig } from './nav';\nimport type { KsFiles } from './files';\nimport type { KnapsackCustomPagesData } from './custom-pages';\nimport type { PatternsState } from './patterns';\nimport type { KnapsackSettings } from './settings';\n\nexport type {\n KsDesignToken,\n KsDesignTokenAttributes,\n KsDesignTokenData,\n KsDesignTokenDataGroup,\n KsDesignTokenSrc,\n KsDesignTokenSrcGroup,\n KsDesignTokensState,\n KsTokenType,\n KsTokenValue,\n KnapsackDesignToken,\n} from './design-tokens';\n\nexport interface KsAppClientDataV3 {\n settingsState: {\n settings: KnapsackSettings;\n };\n patternsState: PatternsState;\n customPagesState: KnapsackCustomPagesData;\n assetSetsState: KnapsackAssetSetsData;\n navsState: KnapsackNavsConfig;\n tokensState: KsDesignTokensState;\n metaState?: MetaState;\n filesState: KsFiles;\n}\n\nexport type KsAppClientDataNoMetaV3 = Omit<KsAppClientDataV3, 'metaState'>;\nexport type KsAppClientDataAndMetaV3 = Required<KsAppClientDataV3>;\n\nexport function isKsAppClientDataNoMetaV3(\n data: unknown,\n): data is KsAppClientDataNoMetaV3 {\n if (!isObject(data)) return false;\n const requiredKeys: Array<keyof KsAppClientDataNoMetaV3> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'settingsState',\n 'tokensState',\n ];\n if (!requiredKeys.every((key) => isObjKey(key, data))) return false;\n if (!isObjKey('metaState', data)) return true;\n return false;\n}\n\nexport const KsAppClientDataNoMetaStructV3 = define<KsAppClientDataNoMetaV3>(\n 'KsAppClientDataNoMeta',\n isKsAppClientDataNoMetaV3,\n);\n\nexport function isKsAppClientDataAndMetaV3(\n data: unknown,\n): data is KsAppClientDataAndMetaV3 {\n if (!isObject(data)) return false;\n const requiredKeys: Array<keyof KsAppClientDataAndMetaV3> = [\n 'assetSetsState',\n 'customPagesState',\n 'navsState',\n 'patternsState',\n 'settingsState',\n 'tokensState',\n 'metaState',\n ];\n return requiredKeys.every((key) => isObjKey(key, data));\n}\n\nexport const KsAppClientDataAndMetaStructV3 = define<KsAppClientDataAndMetaV3>(\n 'KsAppClientDataAndMeta',\n isKsAppClientDataAndMetaV3,\n);\n\nexport const KsMetaStateStructV3: Describe<KsAppClientDataV3['metaState']> =\n type({\n isLocalDev: boolean(),\n plugins: array(\n type({\n id: string(),\n hasContent: boolean(),\n clientPluginPath: optional(string()),\n cssPath: optional(string()),\n }),\n ),\n meta: optional(\n type({\n version: optional(string()),\n hasKnapsackCloud: boolean(),\n knapsackCloudSiteId: optional(string()),\n serverPort: optional(number()),\n websocketsPort: optional(number()),\n https: optional(boolean()),\n cacheDir: optional(string()),\n ksVersions: type({\n app: string(),\n }),\n }),\n ),\n });\n\nexport const isKsMetaStateV3 = KsMetaStateStructV3.is;\n","import { isDraft, type Draft } from 'immer';\nimport { Migration } from './migration.types';\nimport { KnapsackPattern, SlottedData } from '../app-client-data/patterns';\n\ntype Migration417DemosType = {\n version: string;\n checkIfNeeded: (appClientData: any) => boolean;\n migrate: (appClientData: Draft<any>) => void;\n};\n\nexport const migration417Demos: Migration417DemosType = {\n version: '4.1.7',\n checkIfNeeded: (appClientData) => {\n // this one will be tough to check for, so we'll just assume it's needed\n return true;\n },\n // note that `appClientData` is mutable since we're already in Immer\n migrate: (appClientData) => {\n if (!isDraft(appClientData)) {\n throw new Error(\n `Tried to run migrations on appClientData but it is not an Immer Draft`,\n );\n }\n Object.values(appClientData.patternsState.patterns).forEach(\n (\n pattern: Draft<\n KnapsackPattern & {\n demoSize?: string;\n }\n >,\n ) => {\n delete pattern.demoSize;\n },\n );\n\n Object.values(appClientData.db.demos.byId).forEach((demo) => {\n if (demo.type !== 'data') return;\n\n Object.entries(demo.data.slots ?? {}).forEach(([slotName, slotData]) => {\n demo.data.slots[slotName] = slotData.map(\n (slottedData: Draft<SlottedData | string>) => {\n // it used to be just a string\n if (typeof slottedData === 'string') {\n return {\n type: 'text',\n text: slottedData,\n };\n }\n if (\n // not doing anything with these\n slottedData.type === 'template-reference' ||\n // these already were migrated or made by the new editor\n slottedData.type === 'text'\n ) {\n return slottedData;\n }\n // these used to not have a type set\n slottedData.type = 'template-demo';\n return slottedData;\n },\n );\n });\n\n if (demo.patternId && demo.templateId) return;\n\n // using an IIFE so we can stop looping once we find it\n // would use `break` but it's a double loop\n (() => {\n for (const { id: pId, templates = [] } of Object.values(\n appClientData.patternsState.patterns,\n )) {\n for (const { id: tId, demoIds = [] } of templates) {\n if (demoIds.includes(demo.id)) {\n demo.patternId = pId;\n demo.templateId = tId;\n // found it - stop looking\n return;\n }\n }\n }\n })();\n });\n },\n} satisfies Migration;\n","import { migration417Demos } from './4.1.7-demos';\n\nexport const migrations = [migration417Demos];\n","// import { JSONSchema7 } from 'json-schema'; @todo consider using instead; though I'm not seeing it make it's way to the compiled JSON schema themselves via `convert-types-to-json-schmea.js`\n\ntype PropBase<Type = any> = {\n title?: string;\n description?: string;\n default?: Type;\n};\n\nexport enum PropTypeNames {\n 'string' = 'string',\n 'boolean' = 'boolean',\n 'number' = 'number',\n 'object' = 'object',\n 'options' = 'options',\n 'function' = 'function',\n 'customTypeScript' = 'customTypeScript',\n 'array' = 'array',\n 'arrayOfObjects' = 'arrayOfObjects',\n 'arrayOfStrings' = 'arrayOfStrings',\n 'unknown' = 'unknown',\n}\nexport type PropTypeNamesList = keyof typeof PropTypeNames;\n\nexport type StringProp = {\n type: 'string';\n} & PropBase<string>;\n\nexport type BooleanProp = {\n type: 'boolean';\n} & PropBase<boolean>;\n\nexport type NumberProp = {\n type: 'number';\n} & PropBase<number>;\n\nexport type OptionsProp = {\n type: 'string';\n enum: string[];\n enumNames?: string[];\n} & PropBase<string>;\n\nexport type CustomTypeScriptProp = {\n /**\n * TypeScript type\n * @example (name: string) => void\n */\n tsType: string;\n type?: never;\n default?: string;\n} & PropBase<string>;\n\nexport type FunctionProp = {\n typeof: 'function';\n /**\n * TypeScript type\n * @example (name: string) => void\n */\n tsType: string;\n default?: string;\n type?: 'string';\n} & PropBase<string>;\n\nexport type ObjectProp = {\n type: 'object';\n additionalProperties?: boolean;\n required?: string[];\n properties: {\n [prop: string]: any;\n };\n} & PropBase;\n\nexport type ArrayProp = {\n type: 'array';\n} & PropBase<unknown[]>;\n\nexport type ArrayOfStringsProp = {\n type: 'array';\n uniqueItems?: boolean;\n items: StringProp | OptionsProp;\n} & PropBase<unknown[]>;\n\nexport type ArrayOfObjectsProp = {\n type: 'array';\n items: ObjectProp;\n} & PropBase<Array<Record<string, unknown>>>;\n\nexport type PropertyTypes =\n | StringProp\n | BooleanProp\n | NumberProp\n | OptionsProp\n | FunctionProp\n | CustomTypeScriptProp\n | ObjectProp\n | ArrayOfObjectsProp\n | ArrayOfStringsProp\n | ArrayProp;\n\nexport const isStringProp = (prop: PropertyTypes): prop is StringProp =>\n 'type' in prop && prop.type === 'string' && !('enum' in prop);\nexport const isNumberProp = (prop: PropertyTypes): prop is NumberProp =>\n 'type' in prop && prop.type === 'number';\nexport const isBooleanProp = (prop: PropertyTypes): prop is BooleanProp =>\n 'type' in prop && prop.type === 'boolean';\nexport const isOptionsProp = (prop: PropertyTypes): prop is OptionsProp =>\n 'enum' in prop;\nexport const isFunctionProp = (prop: PropertyTypes): prop is FunctionProp =>\n 'typeof' in prop && prop?.typeof === 'function';\nexport const isCustomTypeScriptProp = (\n prop: PropertyTypes,\n): prop is CustomTypeScriptProp => !('typeof' in prop) && 'tsType' in prop;\nexport const isArrayOfObjectsProp = (\n prop: PropertyTypes,\n): prop is ArrayOfObjectsProp =>\n 'type' in prop &&\n prop.type === 'array' &&\n 'items' in prop &&\n prop.items.type === 'object';\nexport const isObjectProp = (prop: PropertyTypes): prop is ObjectProp =>\n 'type' in prop &&\n prop.type === 'object' &&\n 'properties' in prop &&\n Object.keys(prop.properties).length > 0;\nexport const isArrayOfStringsProp = (\n prop: PropertyTypes,\n): prop is ArrayOfStringsProp =>\n 'type' in prop &&\n prop.type === 'array' &&\n 'items' in prop &&\n prop.items.type === 'string';\n\nexport interface PropTypeDataBase {\n type: any;\n id: string;\n isRequired?: boolean;\n data: any;\n}\n\nexport interface StringPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.string;\n data: StringProp;\n}\n\nexport interface BooleanPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.boolean;\n data: BooleanProp;\n}\n\nexport interface NumberPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.number;\n data: NumberProp;\n}\n\nexport interface OptionsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.options;\n data: OptionsProp;\n}\n\nexport interface FunctionPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.function;\n data: FunctionProp;\n}\n\nexport interface CustomTypeScriptPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.customTypeScript;\n data: CustomTypeScriptProp;\n}\n\nexport interface ObjectPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.object;\n data: ObjectProp;\n}\n\nexport interface ArrayOfObjectsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.arrayOfObjects;\n data: ArrayOfObjectsProp;\n}\n\nexport interface ArrayOfStringsPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.arrayOfStrings;\n data: ArrayOfStringsProp;\n}\n\nexport interface ArrayPropTypeData extends PropTypeDataBase {\n type: typeof PropTypeNames.array;\n data: ArrayProp;\n}\n\nexport type PropTypeData =\n | StringPropTypeData\n | BooleanPropTypeData\n | NumberPropTypeData\n | OptionsPropTypeData\n | FunctionPropTypeData\n | CustomTypeScriptPropTypeData\n | ObjectPropTypeData\n | ArrayOfObjectsPropTypeData\n | ArrayOfStringsPropTypeData;\n\nexport type JsonSchemaObject<PropNames extends string = string> = {\n $schema?: string;\n title?: string;\n description?: string;\n type: string;\n required?: string[];\n properties: Record<PropNames, PropertyTypes>;\n examples?: Record<string, unknown>[];\n};\n","import * as s from 'superstruct';\nimport type { Patch } from 'immer';\nimport type { SetOptional } from '@knapsack/utils';\nimport type { UUID, DateString } from './misc';\n\n/**\n * Patch\n */\n\nexport type { Patch };\n\nconst PatchStructRuntime = s.object({\n op: s.union([s.literal('replace'), s.literal('remove'), s.literal('add')]),\n path: s.array(s.union([s.string(), s.number()])),\n value: s.optional(s.any()),\n});\nconst PatchStruct: s.Describe<Patch> = PatchStructRuntime;\n\nexport const isPatch = (patch: unknown): patch is Patch =>\n PatchStruct.is(patch);\n\nconst PatchesStructRuntime = s.array(PatchStructRuntime);\nconst PatchesStruct: s.Describe<Patch[]> = PatchesStructRuntime;\n\nexport const isPatches = (patches: unknown): patches is Patch[] =>\n PatchesStruct.is(patches);\n\n/**\n * KsRemoteChange\n */\nexport type KsChange<Event extends { type: string } = { type: string }> = {\n patches: Patch[];\n inversePatches: Patch[];\n event: Event;\n id: UUID;\n date: DateString;\n};\nexport type KsRemoteChange = SetOptional<KsChange, 'inversePatches' | 'event'>;\n\nconst KsRemoteChangeRuntime = s.type({\n patches: PatchesStructRuntime,\n inversePatches: s.optional(PatchesStructRuntime),\n event: s.optional(s.object({ type: s.string() })),\n id: s.string(),\n date: s.string(),\n userId: s.optional(s.string()),\n});\nconst KsRemoteChangeStruct: s.Describe<KsRemoteChange> = KsRemoteChangeRuntime;\n\nexport const isKsRemoteChange = (change: unknown): change is KsRemoteChange =>\n KsRemoteChangeStruct.is(change);\n\nconst KsRemoteChangesStructRuntime = s.array(KsRemoteChangeRuntime);\nexport const KsRemoteChangesStruct: s.Describe<KsRemoteChange[]> =\n KsRemoteChangesStructRuntime;\n\nexport const isKsRemoteChanges = (\n changes: unknown,\n): changes is KsRemoteChange[] => KsRemoteChangesStruct.is(changes);\n","import { isObject } from './type-utils';\n\nexport const rendererIds = {\n react: 'react',\n vue: 'vue',\n 'web-components': 'web-components',\n twig: 'twig',\n hbs: 'hbs',\n angular: 'angular',\n html: 'html',\n} as const;\n\n/**\n * The ID of a renderer, e.g. 'react', 'vue', 'angular', etc.\n * On Pattern Templates, this will match up to `templateLanguageId` to identify which renderer to use.\n * @see {KnapsackPatternTemplate['templateLanguageId']}\n */\nexport type RendererId = keyof typeof rendererIds;\n\n/**\n * Information about JS imports that can describe how to import a module in these ways:\n * - `import { Foo, Bar } from './foo';`\n * - `import * as Foo from './foo';`\n * - `import Foo from './foo';`\n *\n * Used in Webpack-based renderers\n */\nexport type KsJsImportInfo =\n | {\n type: 'default';\n /** import name from 'path'; */\n name: string;\n path: string;\n }\n | {\n type: 'named';\n path: string;\n /** import { name } from 'path'; */\n name: string;\n }\n | {\n type: 'all';\n path: string;\n /** import * as name from 'path'; */\n name: string;\n };\n\n/** The result of `import`-ing a module */\ntype EsModuleObject<ExportedType = unknown> = {\n default?: ExportedType;\n [key: string]: ExportedType;\n};\n\nexport type KsJsImport =\n | {\n type: 'pattern-template';\n patternId: string;\n templateId: string;\n importInfo: KsJsImportInfo;\n }\n | {\n type: 'pattern-template-demo';\n patternId: string;\n templateId: string;\n demoId: string;\n importInfo: KsJsImportInfo;\n }\n | {\n type: 'extra';\n importInfo: KsJsImportInfo;\n };\n\ntype GetKsJsImportParam =\n | {\n type: 'pattern-template';\n patternId: string;\n templateId: string;\n }\n | {\n type: 'pattern-template-demo';\n patternId: string;\n templateId: string;\n demoId: string;\n }\n | {\n type: 'extra';\n name: string;\n };\n\ntype GetKsJsImportPatternParam = {\n patternId: string;\n templateId: string;\n demoId?: string;\n};\n\n/**\n * This is `window.knapsack` inside the renderer client: the iframe container for renderer components\n */\nexport interface KsRendererClientGlobal<ExportedComponentType = unknown> {\n typeName: 'KsRendererClientGlobal';\n importedModules: {\n [id: string]: () => Promise<EsModuleObject<ExportedComponentType>>;\n };\n allAvailableImports: KsJsImport[];\n getImport: (opt: GetKsJsImportParam) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getImports: (imports: GetKsJsImportParam[]) => Promise<{\n [importName: string]: ExportedComponentType;\n }>;\n getPatternImport: (opt: GetKsJsImportPatternParam) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getExtraImport: (opt: { name: string }) => Promise<{\n name: string;\n /** Most likely a component */\n value: ExportedComponentType;\n }>;\n getAllImports: (opt: {\n patterns: GetKsJsImportPatternParam[];\n extras?: { name: string }[];\n }) => Promise<{\n [importName: string]: ExportedComponentType;\n }>;\n}\n\nexport function isKsJsImports(imports: unknown): imports is KsJsImport[] {\n if (!Array.isArray(imports)) return false;\n if (imports.length === 0) return true;\n const [anImport] = imports;\n if (\n anImport.type === 'pattern-template' &&\n typeof anImport.patternId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.patternId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.templateId !== 'string'\n )\n return false;\n if (\n anImport.type === 'pattern-template-demo' &&\n typeof anImport.demoId !== 'string'\n )\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo !== 'object')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.type !== 'string')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.name !== 'string')\n return false;\n if (anImport.type === 'extra' && typeof anImport.importInfo.path !== 'string')\n return false;\n if (\n anImport.type === 'extra' &&\n typeof anImport.importInfo.names !== 'undefined'\n ) {\n if (!Array.isArray(anImport.importInfo.names)) return false;\n if (\n anImport.importInfo.names.some((name: string) => typeof name !== 'string')\n )\n return false;\n }\n return true;\n}\n\nexport function isKsRendererClientGlobalImportedModules(\n mods: unknown,\n): mods is KsRendererClientGlobal['importedModules'] {\n if (!isObject(mods)) return false;\n for (const key in mods) {\n if (typeof mods[key] !== 'function') return false;\n }\n return true;\n}\n\nexport function isKsRendererClientGlobal<ExportedComponentType = unknown>(\n knapsack: unknown,\n): knapsack is KsRendererClientGlobal<ExportedComponentType> {\n if (!isObject(knapsack)) return false;\n if (knapsack.typeName !== 'KsRendererClientGlobal') return false;\n if (typeof knapsack.getImport !== 'function') return false;\n if (!Array.isArray(knapsack.allAvailableImports)) return false;\n if (!isKsRendererClientGlobalImportedModules(knapsack.importedModules)) {\n return false;\n }\n return isKsJsImports(knapsack.allAvailableImports);\n}\n\nconst isBrowser =\n typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nexport function getKsRendererClientGlobal<\n ExportedComponentType = unknown,\n>(): KsRendererClientGlobal<ExportedComponentType> {\n if (!isBrowser) {\n throw new Error(\n 'Cannot get KsRendererClientGlobal in a non-browser environment',\n );\n }\n const { knapsack } = window as any;\n if (!knapsack) {\n throw new Error(\n 'Cannot get KsRendererClientGlobal: \"knapsack\" is not defined on the window',\n );\n }\n if (!isKsRendererClientGlobal<ExportedComponentType>(knapsack)) {\n console.log(`Object found at \"window.knapsack\":`, knapsack);\n throw new Error(\n `Cannot get KsRendererClientGlobal: knapsack is not the correct type`,\n );\n }\n return knapsack;\n}\n\nexport type TemplateSuggestion = {\n path: string;\n alias?: string;\n};\n\nexport type TemplateSuggestionsGetFn = (opt: {\n rendererId: RendererId;\n newPath?: string;\n}) => Promise<{\n suggestions: TemplateSuggestion[];\n}>;\n","import type { FeedbackTypes } from './misc';\n\nexport enum KsRendererClientEvents {\n ready = 'ready',\n}\n\n/**\n * Message sent from the renderer client (in the iframe) to the App UI parent window\n * using `window.parent.postMessage()`.\n * Note that this likely will become a union type of all possible messages\n */\nexport type KsRendererClientMsg =\n | {\n /**\n * Sent when a `ResizeObserver` detects a change in the contents height or width.\n */\n type: 'ksRendererClient.contentResized';\n height: number;\n width: number;\n }\n | {\n type: 'ksRendererClient.showToast';\n msg: string;\n feedbackType?: FeedbackTypes;\n };\n\nexport interface KsRendererClientMeta {\n patternId: string;\n templateId: string;\n demoId: string;\n assetSetId: string;\n isInIframe: boolean;\n websocketsPort: number;\n}\n","export const WS_EVENTS = {\n PATTERN_TEMPLATE_CHANGED: 'PATTERN_TEMPLATE_CHANGED',\n PATTERN_ASSET_CHANGED: 'PATTERN_ASSET_CHANGED',\n DESIGN_TOKENS_CHANGED: 'DESIGN_TOKENS_CHANGED',\n RENDERER_CLIENT_RELOAD: 'RENDERER_CLIENT_RELOAD',\n APP_CLIENT_DATA_CHANGED: 'APP_CLIENT_DATA_CHANGED',\n};\n\nexport type WebSocketEvent = keyof typeof WS_EVENTS;\n\nexport interface WebSocketMessage {\n event: string;\n data: Record<string, unknown>;\n}\n\nexport interface DesignTokensChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.DESIGN_TOKENS_CHANGED;\n data: Record<string, unknown>;\n}\n\nexport interface PatternChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_TEMPLATE_CHANGED;\n data: {\n /**\n * Absolute path to template on server that was just edited\n */\n path: string;\n };\n}\n\nexport interface AssetChangedData extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_ASSET_CHANGED;\n data: {\n /**\n * Absolute path to asset file (CSS/JS) on server that was just edited\n */\n path: string;\n };\n}\n\nexport interface RendererClientReloadMessage extends WebSocketMessage {\n event: typeof WS_EVENTS.RENDERER_CLIENT_RELOAD;\n data: {\n // @todo add patternId etc for more details\n };\n}\n\nexport interface AppClientDataChanged extends WebSocketMessage {\n event: typeof WS_EVENTS.PATTERN_TEMPLATE_CHANGED;\n data: Record<string, unknown>;\n}\n\nexport type WebSocketMessages =\n | PatternChangedData\n | AssetChangedData\n | DesignTokensChangedData\n | RendererClientReloadMessage;\n","export enum GitProviderType {\n GitHub = 'GitHub',\n GitLab = 'GitLab',\n GitLabRest = 'GitLabRest',\n Bitbucket = 'Bitbucket',\n Azure = 'Azure',\n}\n\nexport type FileAddition = {\n /** base64 */\n contents: string;\n path: string;\n\n /** Action to perform: create, delete, move, update, or chmod. */\n action?: RestActions;\n /** Content of the file. */\n content?: string;\n /** Full path to the file. */\n filePath?: string;\n /** Encoding of the file. Default is text. */\n encoding?: TextEncoding;\n /** Last known file commit ID. */\n lastCommitId?: string;\n /** Original full path to the file being moved. */\n previousPath?: string;\n};\n\nexport type FileDeletion = {\n path: string;\n};\n\nexport enum MergeableState {\n Conflicting = 'CONFLICTING',\n Mergeable = 'MERGEABLE',\n Unknown = 'UNKNOWN',\n}\n\nexport enum RestActions {\n Create = 'CREATE',\n Move = 'MOVE',\n Update = 'UPDATE',\n Chmod = 'CHMOD',\n}\n\nexport enum TextEncoding {\n Base64 = 'BASE64',\n Text = 'TEXT',\n}\n\nexport type FileChanges = {\n /** File to add or change. */\n additions?: FileAddition[];\n\n /** Files to delete. */\n deletions?: FileDeletion[];\n\n /** Last known file commit ID. */\n lastCommitId?: string;\n};\n\nexport type CommitAction = Record<string, unknown>;\n\nexport interface RepoLabel {\n name: string;\n /** ID optional because bitbucket does not provide id. We might be able to generate one if its required, eg. reponame-labelname */\n id?: string;\n}\n\nexport interface RepoInfo {\n id: string;\n url: string;\n name: string;\n ownerName?: string;\n defaultBranch?: any;\n}\n\n// 'BranchInfo' name is currently taken by GitLab generated queries. Thus 'BranchInfoResult'\nexport interface BranchInfoResult {\n sha: string;\n shortSha?: string;\n associatedPullRequests?: Pr[];\n additions?: number;\n commitUrl?: string;\n deletions?: number;\n id?: string; // In GitLab, this is the branch name. Modelled this way to make deleteBranch work.\n default?: boolean;\n}\n\nexport interface PrInfo {\n url: string;\n number: number;\n id: string;\n}\n\nexport interface Pr {\n id: string;\n title: string;\n createdAt: string;\n headRef: {\n id?: string;\n name?: string;\n target: BranchInfoResult;\n };\n mergeable: MergeableState;\n merged: boolean;\n number: number;\n body: string;\n isDraft: boolean;\n url: string;\n author: {\n login: string;\n avatarUrl: string;\n };\n diffHeadSha?: string;\n targetBranch?: string;\n version?: string; // needed for bitbucket merge\n}\n\nexport interface GitProvider {\n type: GitProviderType;\n createBranch: (opt: { branch: string }) => Promise<BranchInfoResult>;\n commitOnBranch: (opt: {\n branch: string;\n message: string;\n fileChanges: FileChanges;\n }) => Promise<Record<string, unknown> | void>;\n getRepoLabels: () => Promise<RepoLabel[]>;\n getRepoInfo: () => Promise<RepoInfo>;\n getBranchInfo: ({ branch }: { branch: string }) => Promise<BranchInfoResult>;\n getPrs: () => Promise<Pr[]>;\n getPr: ({ prNumber }: { prNumber: number }) => Promise<Pr>;\n getTree?: (opt: { branch: string }) => Promise<{\n treeItems: {\n path: string;\n type: 'blob';\n /** SHA-1, use https://www.npmjs.com/package/git-hash-object */\n sha: string;\n url?: string;\n }[];\n }>;\n mergePr: ({ prNumber }: { prNumber: number }) => Promise<boolean>;\n createPr: ({\n siteId,\n branch,\n title,\n body,\n labelIds,\n }: {\n siteId: string;\n branch: string;\n title: string;\n body?: string;\n labelIds?: string[];\n }) => Promise<PrInfo>;\n deleteBranch: ({ id, branch }: { id: string; branch: string }) => Promise<{\n clientMutationId?: string;\n }>;\n getFileInfoOnBranchByPath: (opt: {\n filePath: string;\n branch: string;\n }) => Promise<{ exists: boolean; filePath: string }>;\n}\n","export const endpoint = `/plugins`;\n\nexport enum ACTIONS {\n getContent = 'getContent',\n}\n\nexport interface GetContentRequest {\n type: ACTIONS.getContent;\n pluginId: string;\n}\n\nexport interface GetContentResponse {\n type: ACTIONS.getContent;\n ok: boolean;\n message?: string;\n payload: Record<string, unknown>;\n}\n\nexport type ActionRequests = GetContentRequest;\n\nexport type ActionResponses = GetContentResponse;\n","import type { RendererId } from '../renderers';\n\nexport const endpoint = `/files`;\n\nexport enum ACTIONS {\n verify = 'verify',\n}\n\nexport interface VerifyData {\n type: ACTIONS.verify;\n payload: {\n path: string;\n rendererId: RendererId;\n };\n}\n\nexport interface VerifyDataResponse {\n type: ACTIONS.verify;\n payload: {\n exists: boolean;\n relativePath: string;\n absolutePath: string;\n type: 'absolute' | 'relative' | 'package' | 'unknown';\n };\n}\n\nexport type Actions = VerifyData;\n\nexport type ActionResponses = VerifyDataResponse;\n","/**\n * The roles here are duplicates of the roles in the database.\n * It needs to be here, in the types package, so it can be used in all packages.\n * If we pull it in from `@knapsack/hasura-gql-client`, which is the source, we get a dependency cycle. So we do it this way.\n * If the roles change in the database, we need to change them here too. We will get a build error if we don't (see code in `@knapsack/hasura-gql-client`).\n */\n\nexport const rolesById = {\n ADMIN: 'ADMIN',\n ANONYMOUS: 'ANONYMOUS',\n CONTRIBUTOR: 'CONTRIBUTOR',\n EDITOR: 'EDITOR',\n MANAGER: 'MANAGER',\n VIEWER: 'VIEWER',\n} as const;\nexport const roles = Object.values(rolesById);\nexport type Role = keyof typeof rolesById;\n","import { KsAppClientDataAndMeta } from '@knapsack/types';\n\nexport type SiteDeployedWebhookBody = {\n siteId: string;\n appClientData: KsAppClientDataAndMeta;\n};\n\nexport const siteDeployedWebhookEndpoint = '/site-deployed';\n\nexport const gitHubOauthInternalEndpoint = '/github-auth';\n","import { isUrl } from '@knapsack/utils';\n\nconst { KS_DB_URL } = process.env;\nif (KS_DB_URL && !isUrl(KS_DB_URL)) {\n throw new Error(`KS_DB_URL is not a valid URL: '${KS_DB_URL}'`);\n}\nconst dbUrl = KS_DB_URL || 'https://db.knapsack.cloud';\nconst dbGqlEndpoint = new URL('/v1/graphql', dbUrl).toString();\n\nexport const ksUrls = {\n /**\n * Base URL for Knapsack DB (Hasura)\n * @default 'https://db.knapsack.cloud'\n */\n dbUrl,\n /**\n * App DB GraphQL endpoint for connecting to Hasura GraphQL.\n * @default 'https://db.knapsack.cloud/v1/graphql'\n */\n dbGqlEndpoint,\n};\n","export const ksHttpHeaders = {\n siteId: 'X-KS-Site-ID',\n instanceId: 'X-KS-Instance-Id',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA,+EAAAA,UAAAC,SAAA;AAAA;AAAA;AAEA,IAAAA,QAAO,UAAU;AAAA,MAChB,aAAa,CAAC,KAAK,KAAK,GAAG;AAAA,MAC3B,gBAAgB,CAAC,KAAK,KAAK,GAAG;AAAA,MAC9B,QAAQ,CAAC,GAAG,KAAK,GAAG;AAAA,MACpB,cAAc,CAAC,KAAK,KAAK,GAAG;AAAA,MAC5B,SAAS,CAAC,KAAK,KAAK,GAAG;AAAA,MACvB,SAAS,CAAC,KAAK,KAAK,GAAG;AAAA,MACvB,UAAU,CAAC,KAAK,KAAK,GAAG;AAAA,MACxB,SAAS,CAAC,GAAG,GAAG,CAAC;AAAA,MACjB,kBAAkB,CAAC,KAAK,KAAK,GAAG;AAAA,MAChC,QAAQ,CAAC,GAAG,GAAG,GAAG;AAAA,MAClB,cAAc,CAAC,KAAK,IAAI,GAAG;AAAA,MAC3B,SAAS,CAAC,KAAK,IAAI,EAAE;AAAA,MACrB,aAAa,CAAC,KAA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AAC,0BAA0B,GAAG,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AACA,QAAM,EAAE,aAAa,GAAG,SAAS,IAAI,OAAO,yBAAyB;AACrE,QAAM,cAAc,kBAAkB,WAAW;AACjD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,aAAa,wBAAC,WAAW;AACvB,UAAI,SAAS,aAAc,QAAO;AAClC,aAAO,YAAY,MAAM,KAAK;AAAA,IAChC,GAHa;AAAA,EAIf;AACF,GAd2B;;;A4BnN3B;AAOO,IAAM,8BAA8B;AAEpC,IAAM,8BAA8B;;;ACT3C;AAAA,IAAAC,gBAAsB;AAEtB,IAAM,EAAE,UAAU,IAAI,QAAQ;AAC9B,IAAI,aAAa,KAAC,qBAAM,SAAS,GAAG;AAClC,QAAM,IAAI,MAAM,kCAAkC,SAAS,GAAG;AAChE;AACA,IAAM,QAAQ,aAAa;AAC3B,IAAM,gBAAgB,IAAI,IAAI,eAAe,KAAK,EAAE,SAAS;AAEtD,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AACF;;;ACpBA;AAAO,IAAM,gBAAgB;AAAA,EAC3B,QAAQ;AAAA,EACR,YAAY;AACd;","names":["exports","module","exports","module","exports","module","swizzle","exports","module","string","s","import_superstruct","import_superstruct","import_utils","colorString","__name","union","string","type","literal","string","union","type","union","string","union","type","optional","object","literal","optional","boolean","type","array","__name","type","isObject","expectType","__name","isObject","isObjKey","type","__name","__name","__name","__name","define","type","boolean","array","string","optional","number","__name","__export","ACTIONS","endpoint","HasuraRoles","import_utils"]}