@knapsack/core 4.69.15--canary.4532.e420d28.0 → 4.69.15--canary.4771.9877e61.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1,1945 +1,9 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
- mod
29
- ));
1
+ import * as r from 'superstruct';
2
+ import { define, union, type, literal, string, object, enums, number, optional, size, array, boolean, defaulted, record, assign } from 'superstruct';
3
+ import { expectType, isObject, isObjKey, isUrl, parseNumberWithUnit } from '@knapsack/utils';
30
4
 
31
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/node_modules/tsup/assets/esm_shims.js
32
- var init_esm_shims = __esm({
33
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/node_modules/tsup/assets/esm_shims.js"() {
34
- }
35
- });
5
+ var Lt=Object.create;var be=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Ht=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var s=(e,t)=>be(e,"name",{value:t,configurable:!0});var ne=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var jt=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $t(t))!Gt.call(e,o)&&o!==n&&be(e,o,{get:()=>t[o],enumerable:!(a=Wt(t,o))||a.enumerable});return e};var Jt=(e,t,n)=>(n=e!=null?Lt(Ht(e)):{},jt(be(n,"default",{value:e,enumerable:!0}),e));var Me=ne((Wn,Oe)=>{Oe.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};});var ze=ne(($n,Fe)=>{Fe.exports=s(function(t){return !t||typeof t=="string"?!1:t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&t.constructor.name!=="String")},"isArrayish");});var Ue=ne((Gn,Be)=>{var qt=ze(),Xt=Array.prototype.concat,Yt=Array.prototype.slice,Ke=Be.exports=s(function(t){for(var n=[],a=0,o=t.length;a<o;a++){var d=t[a];qt(d)?n=Xt.call(n,Yt.call(d)):n.push(d);}return n},"swizzle");Ke.wrap=function(e){return function(){return e(Ke(arguments))}};});var He=ne((Jn,$e)=>{var j=Me(),J=Ue(),Le=Object.hasOwnProperty,We=Object.create(null);for(ae in j)Le.call(j,ae)&&(We[j[ae]]=ae);var ae,_=$e.exports={to:{},get:{}};_.get=function(e){var t=e.substring(0,3).toLowerCase(),n,a;switch(t){case"hsl":n=_.get.hsl(e),a="hsl";break;case"hwb":n=_.get.hwb(e),a="hwb";break;default:n=_.get.rgb(e),a="rgb";break}return n?{model:a,value:n}:null};_.get.rgb=function(e){if(!e)return null;var t=/^#([a-f0-9]{3,4})$/i,n=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,a=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,o=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,d=/^(\w+)$/,c=[0,0,0,1],l,p,E;if(l=e.match(n)){for(E=l[2],l=l[1],p=0;p<3;p++){var re=p*2;c[p]=parseInt(l.slice(re,re+2),16);}E&&(c[3]=parseInt(E,16)/255);}else if(l=e.match(t)){for(l=l[1],E=l[3],p=0;p<3;p++)c[p]=parseInt(l[p]+l[p],16);E&&(c[3]=parseInt(E+E,16)/255);}else if(l=e.match(a)){for(p=0;p<3;p++)c[p]=parseInt(l[p+1],0);l[4]&&(l[5]?c[3]=parseFloat(l[4])*.01:c[3]=parseFloat(l[4]));}else if(l=e.match(o)){for(p=0;p<3;p++)c[p]=Math.round(parseFloat(l[p+1])*2.55);l[4]&&(l[5]?c[3]=parseFloat(l[4])*.01:c[3]=parseFloat(l[4]));}else return (l=e.match(d))?l[1]==="transparent"?[0,0,0,0]:Le.call(j,l[1])?(c=j[l[1]],c[3]=1,c):null:null;for(p=0;p<3;p++)c[p]=O(c[p],0,255);return c[3]=O(c[3],0,1),c};_.get.hsl=function(e){if(!e)return null;var t=/^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=e.match(t);if(n){var a=parseFloat(n[4]),o=(parseFloat(n[1])%360+360)%360,d=O(parseFloat(n[2]),0,100),c=O(parseFloat(n[3]),0,100),l=O(isNaN(a)?1:a,0,1);return [o,d,c,l]}return null};_.get.hwb=function(e){if(!e)return null;var t=/^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=e.match(t);if(n){var a=parseFloat(n[4]),o=(parseFloat(n[1])%360+360)%360,d=O(parseFloat(n[2]),0,100),c=O(parseFloat(n[3]),0,100),l=O(isNaN(a)?1:a,0,1);return [o,d,c,l]}return null};_.to.hex=function(){var e=J(arguments);return "#"+ie(e[0])+ie(e[1])+ie(e[2])+(e[3]<1?ie(Math.round(e[3]*255)):"")};_.to.rgb=function(){var e=J(arguments);return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};_.to.rgb.percent=function(){var e=J(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),a=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+n+"%, "+a+"%)":"rgba("+t+"%, "+n+"%, "+a+"%, "+e[3]+")"};_.to.hsl=function(){var e=J(arguments);return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};_.to.hwb=function(){var e=J(arguments),t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};_.to.keyword=function(e){return We[e.slice(0,3)]};function O(e,t,n){return Math.min(Math.max(t,e),n)}s(O,"clamp");function ie(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}s(ie,"hexDouble");});var it=Jt(He());var Ye=Symbol.for("immer-nothing"),Ge=Symbol.for("immer-draftable"),C=Symbol.for("immer-state"),Qt=process.env.NODE_ENV!=="production"?[function(e){return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return `'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return `'original' expects a draft, got: ${e}`}]:[];function v(e,...t){if(process.env.NODE_ENV!=="production"){let n=Qt[e],a=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${a}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}s(v,"die");var W=Object.getPrototypeOf;function M(e){return !!e&&!!e[C]}s(M,"isDraft");function K(e){return e?Qe(e)||Array.isArray(e)||!!e[Ge]||!!e.constructor?.[Ge]||ce(e)||de(e):!1}s(K,"isDraftable");var Zt=Object.prototype.constructor.toString();function Qe(e){if(!e||typeof e!="object")return !1;let t=W(e);if(t===null)return !0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Zt}s(Qe,"isPlainObject");function se(e,t){ue(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e);}):e.forEach((n,a)=>t(a,n,e));}s(se,"each");function ue(e){let t=e[C];return t?t.type_:Array.isArray(e)?1:ce(e)?2:de(e)?3:0}s(ue,"getArchtype");function ke(e,t){return ue(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}s(ke,"has");function Ze(e,t,n){let a=ue(e);a===2?e.set(t,n):a===3?e.add(n):e[t]=n;}s(Ze,"set");function er(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}s(er,"is");function ce(e){return e instanceof Map}s(ce,"isMap");function de(e){return e instanceof Set}s(de,"isSet");function z(e){return e.copy_||e.base_}s(z,"latest");function _e(e,t){if(ce(e))return new Map(e);if(de(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Qe(e);if(t===!0||t==="class_only"&&!n){let a=Object.getOwnPropertyDescriptors(e);delete a[C];let o=Reflect.ownKeys(a);for(let d=0;d<o.length;d++){let c=o[d],l=a[c];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(a[c]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[c]});}return Object.create(W(e),a)}else {let a=W(e);if(a!==null&&n)return {...e};let o=Object.create(a);return Object.assign(o,e)}}s(_e,"shallowCopy");function Ae(e,t=!1){return pe(e)||M(e)||!K(e)||(ue(e)>1&&(e.set=e.add=e.clear=e.delete=tr),Object.freeze(e),t&&Object.entries(e).forEach(([n,a])=>Ae(a,!0))),e}s(Ae,"freeze");function tr(){v(2);}s(tr,"dontMutateFrozenCollections");function pe(e){return Object.isFrozen(e)}s(pe,"isFrozen");var rr={};function B(e){let t=rr[e];return t||v(0,e),t}s(B,"getPlugin");var q;function et(){return q}s(et,"getCurrentScope");function nr(e,t){return {drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}s(nr,"createScope");function je(e,t){t&&(B("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t);}s(je,"usePatchesInScope");function Ce(e){Te(e),e.drafts_.forEach(ar),e.drafts_=null;}s(Ce,"revokeScope");function Te(e){e===q&&(q=e.parent_);}s(Te,"leaveScope");function Je(e){return q=nr(q,e)}s(Je,"enterScope");function ar(e){let t=e[C];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0;}s(ar,"revokeDraft");function qe(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[C].modified_&&(Ce(t),v(4)),K(e)&&(e=oe(t,e),t.parent_||le(t,e)),t.patches_&&B("Patches").generateReplacementPatches_(n[C].base_,e,t.patches_,t.inversePatches_)):e=oe(t,n,[]),Ce(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ye?e:void 0}s(qe,"processResult");function oe(e,t,n){if(pe(t))return t;let a=t[C];if(!a)return se(t,(o,d)=>Xe(e,a,t,o,d,n)),t;if(a.scope_!==e)return t;if(!a.modified_)return le(e,a.base_,!0),a.base_;if(!a.finalized_){a.finalized_=!0,a.scope_.unfinalizedDrafts_--;let o=a.copy_,d=o,c=!1;a.type_===3&&(d=new Set(o),o.clear(),c=!0),se(d,(l,p)=>Xe(e,a,o,l,p,n,c)),le(e,o,!1),n&&e.patches_&&B("Patches").generatePatches_(a,n,e.patches_,e.inversePatches_);}return a.copy_}s(oe,"finalize");function Xe(e,t,n,a,o,d,c){if(process.env.NODE_ENV!=="production"&&o===n&&v(5),M(o)){let l=d&&t&&t.type_!==3&&!ke(t.assigned_,a)?d.concat(a):void 0,p=oe(e,o,l);if(Ze(n,a,p),M(p))e.canAutoFreeze_=!1;else return}else c&&n.add(o);if(K(o)&&!pe(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;oe(e,o),(!t||!t.scope_.parent_)&&typeof a!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,a)&&le(e,o);}}s(Xe,"finalizeProperty");function le(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ae(t,n);}s(le,"maybeFreeze");function ir(e,t){let n=Array.isArray(e),a={type_:n?1:0,scope_:t?t.scope_:et(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=a,d=Ee;n&&(o=[a],d=X);let{revoke:c,proxy:l}=Proxy.revocable(o,d);return a.draft_=l,a.revoke_=c,l}s(ir,"createProxyProxy");var Ee={get(e,t){if(t===C)return e;let n=z(e);if(!ke(n,t))return sr(e,n,t);let a=n[t];return e.finalized_||!K(a)?a:a===ve(e.base_,t)?(Se(e),e.copy_[t]=xe(a,e)):a},has(e,t){return t in z(e)},ownKeys(e){return Reflect.ownKeys(z(e))},set(e,t,n){let a=tt(z(e),t);if(a?.set)return a.set.call(e.draft_,n),!0;if(!e.modified_){let o=ve(z(e),t),d=o?.[C];if(d&&d.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(er(n,o)&&(n!==void 0||ke(e.base_,t)))return !0;Se(e),we(e);}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return ve(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Se(e),we(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=z(e),a=Reflect.getOwnPropertyDescriptor(n,t);return a&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:a.enumerable,value:n[t]}},defineProperty(){v(11);},getPrototypeOf(e){return W(e.base_)},setPrototypeOf(){v(12);}},X={};se(Ee,(e,t)=>{X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};});X.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&v(13),X.set.call(this,e,t,void 0)};X.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&v(14),Ee.set.call(this,e[0],t,n,e[0])};function ve(e,t){let n=e[C];return (n?z(n):e)[t]}s(ve,"peek");function sr(e,t,n){let a=tt(t,n);return a?"value"in a?a.value:a.get?.call(e.draft_):void 0}s(sr,"readPropFromProto");function tt(e,t){if(!(t in e))return;let n=W(e);for(;n;){let a=Object.getOwnPropertyDescriptor(n,t);if(a)return a;n=W(n);}}s(tt,"getDescriptorFromProto");function we(e){e.modified_||(e.modified_=!0,e.parent_&&we(e.parent_));}s(we,"markChanged");function Se(e){e.copy_||(e.copy_=_e(e.base_,e.scope_.immer_.useStrictShallowCopy_));}s(Se,"prepareCopy");var or=class{static{s(this,"Immer2");}constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,a)=>{if(typeof t=="function"&&typeof n!="function"){let d=n;n=t;let c=this;return s(function(p=d,...E){return c.produce(p,re=>n.call(this,re,...E))},"curriedProduce")}typeof n!="function"&&v(6),a!==void 0&&typeof a!="function"&&v(7);let o;if(K(t)){let d=Je(this),c=xe(t,void 0),l=!0;try{o=n(c),l=!1;}finally{l?Ce(d):Te(d);}return je(d,a),qe(o,d)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===Ye&&(o=void 0),this.autoFreeze_&&Ae(o,!0),a){let d=[],c=[];B("Patches").generateReplacementPatches_(t,o,d,c),a(d,c);}return o}else v(1,t);},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return (c,...l)=>this.produceWithPatches(c,p=>t(p,...l));let a,o;return [this.produce(t,n,(c,l)=>{a=c,o=l;}),a,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy);}createDraft(e){K(e)||v(8),M(e)&&(e=lr(e));let t=Je(this),n=xe(e,void 0);return n[C].isManual_=!0,Te(t),n}finishDraft(e,t){let n=e&&e[C];(!n||!n.isManual_)&&v(9);let{scope_:a}=n;return je(a,t),qe(void 0,a)}setAutoFreeze(e){this.autoFreeze_=e;}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e;}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));let a=B("Patches").applyPatches_;return M(e)?a(e,t):this.produce(e,o=>a(o,t))}};function xe(e,t){let n=ce(e)?B("MapSet").proxyMap_(e,t):de(e)?B("MapSet").proxySet_(e,t):ir(e,t);return (t?t.scope_:et()).drafts_.push(n),n}s(xe,"createProxy");function lr(e){return M(e)||v(10,e),rt(e)}s(lr,"current");function rt(e){if(!K(e)||pe(e))return e;let t=e[C],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=_e(e,t.scope_.immer_.useStrictShallowCopy_);}else n=_e(e,!0);return se(n,(a,o)=>{Ze(n,a,rt(o));}),t&&(t.finalized_=!1),n}s(rt,"currentImpl");var T=new or;T.produceWithPatches.bind(T);T.setAutoFreeze.bind(T);T.setUseStrictShallowCopy.bind(T);T.applyPatches.bind(T);T.createDraft.bind(T);T.finishDraft.bind(T);var st=Object.defineProperty,u=s((e,t)=>st(e,"name",{value:t,configurable:!0}),"o"),ot=s((e,t)=>{for(var n in t)st(e,n,{get:t[n],enumerable:!0});},"ge");function lt(e){if(typeof e!="string")return !1;try{return !!it.default.get(e)}catch{return !1}}s(lt,"Fe");u(lt,"isColor");var ge=define("ColorStringStruct",e=>typeof e=="string"&&lt(e)),m=union([type({type:literal("value"),colorValue:ge}),type({type:literal("design-token"),tokenName:string()})]);type({type:literal("design-token"),tokenName:string()});var nt=object({unit:enums(["rem","px"]),value:number()}),at=union([string(),number()]),dr=(e=>(e.woff2="woff2",e.woff="woff",e))(dr||{}),pr=enums(["woff2","woff"]),fr=type({format:pr,type:literal("url"),path:string()}),ee=type({family:optional(string()),weight:optional(union([at,size(array(at),2)])),src:optional(array(fr)),style:optional(string()),display:optional(enums(["auto","block","swap","fallback","optional"])),variationSettings:optional(string()),unicodeRange:optional(string())}),gr=(e=>(e.inherit="As typed",e.capitalize="Capitalize",e.lowercase="Lowercase",e.uppercase="Uppercase",e))(gr||{}),yr=(e=>(e["ultra-condensed"]="Ultra-condensed",e["extra-condensed"]="Extra-condensed",e.condensed="Condensed",e["semi-condensed"]="Semi-condensed",e.normal="Normal",e["semi-expanded"]="Semi-expanded",e.expanded="Expanded",e["extra-expanded"]="Extra-expanded",e["ultra-expanded"]="Ultra-expanded",e))(yr||{}),te=type({fontWeight:optional(union([string(),number()])),textColor:optional(m),hoverColor:optional(m),underline:optional(boolean()),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),mr=type({min:nt,max:optional(nt)}),f=type({fontSize:optional(mr),lineHeight:optional(union([string(),number()])),fontWeight:optional(union([string(),number()])),letterSpacing:optional(string()),fontFamily:optional(string()),textColor:optional(m),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))});var G=union([f,type({accentColor:optional(m)})]),ye=union([G,type({hoverColor:optional(m),backgroundColor:optional(m)})]),me=union([G,type({backgroundColor:optional(m)})]);object({version:literal(1),oldSillySidebarBgColor:ge});object({version:literal(2),anotherSillySidebarBgColor:ge});object({version:literal(3),sidebarBgColor:ge});object({version:literal(4),primaryColor:m,darkColor:m,lightColor:m,enableSidebarIcons:optional(defaulted(boolean(),!0))});object({version:literal(5),primaryColor:m,darkColor:m,lightColor:m,linkColor:m,enableSidebarIcons:optional(defaulted(boolean(),!0))});object({version:literal(6),primaryColor:m,darkColor:m,lightColor:m,linkColor:m,enableSidebarIcons:optional(defaulted(boolean(),!0)),appearance:type({customFonts:optional(array(ee)),pageElements:type({pageTitle:optional(f),pageDescription:optional(f),headingLarge:optional(f),headingMedium:optional(f),headingSmall:optional(f),bodyText:optional(f),link:optional(te)})})});object({version:literal(7),primaryColor:m,darkColor:m,lightColor:m,linkColor:m,enableSidebarIcons:optional(defaulted(boolean(),!0)),appearance:type({customFonts:optional(array(ee)),navigation:optional(type({primaryNav:optional(ye),secondaryNav:optional(me),tabs:optional(G)})),pageElements:type({pageTitle:optional(f),pageDescription:optional(f),headingLarge:optional(f),headingMedium:optional(f),headingSmall:optional(f),bodyText:optional(f),link:optional(te)})})});object({version:literal(8),primaryColor:m,darkColor:m,lightColor:m,linkColor:m,appearance:type({customFonts:optional(array(ee)),navigation:optional(type({primaryNav:optional(ye),secondaryNav:optional(me),tabs:optional(G)})),pageElements:type({pageTitle:optional(f),pageDescription:optional(f),headingLarge:optional(f),headingMedium:optional(f),headingSmall:optional(f),bodyText:optional(f),link:optional(te)})})});object({version:literal(9),appearance:type({customFonts:optional(array(ee)),navigation:optional(type({primaryNav:optional(ye),secondaryNav:optional(me),tabs:optional(G)})),pageElements:type({pageTitle:optional(f),pageDescription:optional(f),headingLarge:optional(f),headingMedium:optional(f),headingSmall:optional(f),bodyText:optional(f),link:optional(te)})})});object({version:literal(10),appearance:type({customFonts:optional(array(ee)),navigation:optional(type({primaryNav:optional(ye),secondaryNav:optional(me),tabs:optional(G)})),pageElements:type({pageTitle:optional(f),pageDescription:optional(f),headingXLarge:optional(f),headingLarge:optional(f),headingMedium:optional(f),headingSmall:optional(f),headingXSmall:optional(f),bodyText:optional(f),link:optional(te)})})});function ut(e){return typeof e!="string"?!1:e.split("{").length-1===1&&e.startsWith("{")&&e.endsWith("}")}s(ut,"Qe");u(ut,"isTokenReference");function P(e){return typeof e=="string"&&e.includes("{")}s(P,"b");u(P,"hasTokenReferences");function ct(e){return !ut(e)}s(ct,"Ze");u(ct,"isNotTokenReference");var h=r.define("Token Reference",e=>typeof e!="string"?!1:ct(e)?"Must start and end with curly braces":!0),hr={border:"border",shadow:"shadow",transition:"transition"},br=Object.values(hr),vr={string:"string",number:"number",boolean:"boolean",color:"color",dimension:"dimension",duration:"duration",fontWeight:"fontWeight",strokeStyle:"strokeStyle",cubicBezier:"cubicBezier"},Sr=Object.values(vr);function Ve(e){return br.includes(e)}s(Ve,"q");u(Ve,"isTokenTypeComposite");function dt(e){return Sr.includes(e)}s(dt,"Te");u(dt,"isTokenTypeSingular");expectType([{inset:!1,color:"#000",offsetX:"0px",offsetY:"0px",spread:"0px",blur:"0px"},{color:"#000",offsetX:"0px",offsetY:"0px",spread:"0px",blur:"0px",inset:!0}]);var b=r.type({id:r.string(),description:r.optional(r.string()),references:r.optional(r.array(r.array(r.string()))),tokenConfig:r.optional(r.type({purpose:r.optional(r.string())}))});expectType([{type:"duration",value:"1ms",originalValue:"1ms",id:"1",kind:"static"},{type:"duration",value:"1ms",kind:"ref",id:"1",originalValue:"{a.b}",referencedTokenId:"1"},{type:"duration",value:"1ms",originalValue:"1ms",id:"1",kind:"ref"},{type:"duration",value:"1ms",kind:"static",id:"1",originalValue:"{a.b}",referencedTokenId:"1"},{type:"color",value:"#000",kind:"static",id:"1",originalValue:"#000"},{type:"color",value:"#000",kind:"ref",id:"1",originalValue:"{c.b}",referencedTokenId:"c.b"},{type:"cubicBezier",kind:"static",value:[0,0,0,1],originalValue:[0,0,0,1],id:"1"}]);function kr(e){return Ve(e.type)}s(kr,"To");u(kr,"isTokenDataComposite");expectType([{type:"border",kind:"static",id:"1",value:{color:"#000",style:"solid",width:"1px"},originalValue:{color:"#000",style:"solid",width:"1px"}},{type:"border",kind:"ref",referencedTokenId:"a.b",id:"1",value:{color:"red",style:"dashed",width:"2px"},originalValue:"{a.b}"},{type:"shadow",value:{color:"#000",offsetX:"1px",offsetY:"1px",blur:"1px",spread:"1px",inset:!1},originalValue:{color:"#000",offsetX:"{a.a}",offsetY:"1px",blur:"1px",spread:"1px",inset:!1},id:"1",kind:"static"},{type:"shadow",kind:"ref",referencedTokenId:"a.b",value:{inset:!0,color:"red",offsetX:"1px",blur:"2px",offsetY:"3px",spread:"4px"},originalValue:"{a.b}",id:"1"},{type:"transition",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:"{a.b}",kind:"ref",referencedTokenId:"a.b",id:"1"},{type:"transition",kind:"static",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:{duration:"100ms",delay:"{a.c}",timingFunction:"{a.c}"},id:"1"},{type:"transition",kind:"static",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},id:"1"}]);function pt(e){return typeof e=="string"&&!P(e)}s(pt,"it");u(pt,"isTokenValueColor");var $=r.define("Color Value",e=>typeof e!="string"?"Value must be a string":e===""?"Value must not be empty":P(e)?"Value must not contain {} (token references)":!0),_r=r.assign(r.type({type:r.literal("color"),value:$,kind:r.literal("static"),originalValue:$}),b),Cr=r.assign(r.type({type:r.literal("color"),value:$,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);function Y(e){return typeof e=="string"&&(e.endsWith("px")||e.endsWith("rem"))&&!P(e)}s(Y,"J");u(Y,"isTokenValueDimension");var D=r.define("Dimension Value",e=>typeof e!="string"?"Value must be a string":P(e)?"Value must not contain {} (token references)":!e.endsWith("px")&&!e.endsWith("rem")&&!e.endsWith("em")&&!e.endsWith("%")?"Value must end with px, rem, em or %":!0),Tr=r.assign(r.type({type:r.literal("dimension"),value:D,kind:r.literal("static"),originalValue:D}),b),wr=r.assign(r.type({type:r.literal("dimension"),value:D,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);function xr(e){return typeof e=="string"&&e.endsWith("ms")&&!P(e)}s(xr,"So");u(xr,"isTokenValueDuration");var L=r.define("Duration Value",e=>typeof e!="string"?"Value must be a string":P(e)?"Value must not contain {} (token references)":/^\d+ms$/.test(e)?!0:'Value must be a number followed by "ms" (e.g., "100ms")'),Ar=r.assign(r.type({type:r.literal("duration"),value:L,kind:r.literal("static"),originalValue:L}),b),Er=r.assign(r.type({type:r.literal("duration"),value:L,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);function Dr(e){return (typeof e=="string"||typeof e=="number")&&!P(e)}s(Dr,"Co");u(Dr,"isTokenValueFontWeight");var De=r.define("Font Weight Value",e=>typeof e!="string"&&typeof e!="number"?"Value must be a string or number":P(e)?"Value must not contain {} (token references)":!0),Nr=r.assign(r.type({type:r.literal("fontWeight"),value:De,kind:r.literal("static"),originalValue:De}),b),Vr=r.assign(r.type({type:r.literal("fontWeight"),value:De,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b),Q=r.define("Cubic Bezier Value",e=>Array.isArray(e)?e.length!==4||!e.every(t=>typeof t=="number")?"Value must be an array of 4 numbers":e[0]<0||e[0]>1||e[2]<0||e[2]>1?"The first and third cubicBezier values must be between 0 and 1":!0:"Value must be an array"),Ir=r.assign(r.type({type:r.literal("cubicBezier"),value:Q,kind:r.literal("static"),originalValue:Q}),b),Pr=r.assign(r.type({type:r.literal("cubicBezier"),value:Q,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);function ft(e){return isObject(e)&&pt(e.color)&&Y(e.offsetX)&&Y(e.offsetY)&&Y(e.blur)&&Y(e.spread)}s(ft,"yt");u(ft,"isTokenValueShadow");var gt=r.define("Shadow Value",e=>ft(e)?!0:`Expected a shadow value, got ${JSON.stringify(e)}`),Rr=r.assign(r.type({type:r.literal("shadow"),value:gt,kind:r.literal("static"),originalValue:r.type({color:r.union([$,h]),offsetX:r.union([D,h]),offsetY:r.union([D,h]),blur:r.union([D,h]),spread:r.union([D,h]),inset:r.union([r.optional(r.boolean()),h])})}),b),Or=r.assign(r.type({type:r.literal("shadow"),value:gt,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b),H=r.union([r.literal("solid"),r.literal("dashed"),r.literal("dotted"),r.literal("double"),r.literal("groove"),r.literal("ridge"),r.literal("outset"),r.literal("inset")]);function yt(e){return isObject(e)&&$.is(e.color)&&H.is(e.style)&&D.is(e.width)}s(yt,"St");u(yt,"isTokenValueBorder");var mt=r.define("Border Value",yt),Mr=r.assign(r.type({type:r.literal("border"),value:mt,kind:r.literal("static"),originalValue:r.type({color:r.union([$,h]),style:r.union([H,h]),width:r.union([D,h])})}),b),Fr=r.assign(r.type({type:r.literal("border"),value:mt,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);function ht(e){return isObject(e)&&Q.is(e.timingFunction)&&L.is(e.duration)&&L.is(e.delay)}s(ht,"bt");u(ht,"isTokenValueTransition");var bt=r.define("Transition Value",ht),zr=r.assign(r.type({type:r.literal("transition"),value:bt,kind:r.literal("static"),originalValue:r.type({timingFunction:r.union([Q,h]),duration:r.union([L,h]),delay:r.union([L,h])})}),b),Kr=r.assign(r.type({type:r.literal("transition"),value:bt,kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b),Br=r.assign(r.type({type:r.literal("string"),value:r.string(),kind:r.literal("static"),originalValue:r.string()}),b),Ur=r.assign(r.type({type:r.literal("string"),value:r.string(),kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b),Lr=r.assign(r.type({type:r.literal("strokeStyle"),value:H,kind:r.literal("static"),originalValue:H}),b),Wr=r.assign(r.type({type:r.literal("strokeStyle"),value:H,kind:r.literal("ref"),originalValue:h,referencedTokenId:H}),b),$r=r.assign(r.type({type:r.literal("number"),value:r.number(),kind:r.literal("static"),originalValue:r.number()}),b),Hr=r.assign(r.type({type:r.literal("number"),value:r.number(),kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b),Gr=r.assign(r.type({type:r.literal("boolean"),value:r.boolean(),kind:r.literal("static"),originalValue:r.boolean()}),b),jr=r.assign(r.type({type:r.literal("boolean"),value:r.boolean(),kind:r.literal("ref"),originalValue:h,referencedTokenId:r.string()}),b);u(e=>{if(!isObject(e))throw new Error(`Expected token data to be an object, got ${JSON.stringify(e)}`);if(!isObjKey("type",e))throw new Error(`Expected token data to have a "type" property, got ${JSON.stringify(e)}`);if(typeof e.type!="string")throw new Error(`Expected token data "type" property to be a string, got ${JSON.stringify(e)}`);let t=e.type,n=e.kind;try{switch(t){case"boolean":n==="ref"?jr.assert(e):Gr.assert(e);return;case"border":n==="ref"?Fr.assert(e):Mr.assert(e);return;case"color":n==="ref"?Cr.assert(e):_r.assert(e);return;case"cubicBezier":n==="ref"?Pr.assert(e):Ir.assert(e);return;case"dimension":n==="ref"?wr.assert(e):Tr.assert(e);return;case"duration":n==="ref"?Er.assert(e):Ar.assert(e);return;case"fontWeight":n==="ref"?Vr.assert(e):Nr.assert(e);return;case"number":n==="ref"?Hr.assert(e):$r.assert(e);return;case"shadow":n==="ref"?Or.assert(e):Rr.assert(e);return;case"string":n==="ref"?Ur.assert(e):Br.assert(e);return;case"strokeStyle":n==="ref"?Wr.assert(e):Lr.assert(e);return;case"transition":n==="ref"?Kr.assert(e):zr.assert(e);return;default:throw new Error(`Unknown token data type: ${t}`)}}catch(a){throw a instanceof r.StructError?new Error(`Invalid token data for type "${t}": ${a.message}. Received this data: "${JSON.stringify(e)}"`):a}},"assertTokenData");expectType([{type:"dimension",kind:"static",value:"1px"},{type:"dimension",kind:"ref",referencedTokenId:"a.b"}]);expectType([{type:"border",kind:"ref",referencedTokenId:"a.b"},{type:"border",kind:"static",value:{color:{kind:"static",type:"color",value:"red"},style:{kind:"ref",type:"strokeStyle",referencedTokenId:""},width:{kind:"static",type:"dimension",value:"2px"}}}]);expectType([{type:"transition",kind:"ref",referencedTokenId:"a.b"},{type:"transition",kind:"static",value:{delay:{kind:"static",type:"duration",value:"1ms"},duration:{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},timingFunction:{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]}}}]);function Jr(e){return dt(e?.type)}s(Jr,"Bo");u(Jr,"isTokenSrcValueInfoSingular");function qr(e){return Ve(e?.type)}s(qr,"Eo");u(qr,"isTokenSrcValueInfoComposite");expectType([{type:"dimension",kind:"static",value:"1px"},{type:"transition",kind:"ref",referencedTokenId:"a.b"},{type:"transition",kind:"ref",value:"1px"},{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]},{type:"transition",kind:"static",value:{delay:{kind:"static",type:"duration",value:"1ms"},duration:{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},timingFunction:{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]}}}]);function vt(e){return isObject(e)&&isObjKey("cloud.knapsack",e)}s(vt,"At");u(vt,"isTokenSrcExtensions");expectType(["#ddd",!0,[83,1,1,1],{color:"#000",style:"solid",width:"1px"},{inset:!0,color:"#000",offsetX:"0px",offsetY:"{spacing.medium}",spread:"0px",blur:"0px"},{timingFunction:"{timing.ease}",duration:"{timing.duration.medium}",delay:"7ms",color:"#000"}]);function Xr(e){return !!(isObject(e)&&isObjKey("$value",e))}s(Xr,"Oo");u(Xr,"isTokenSrc");function St(e){return isObject(e)&&!vt(e)&&!isObjKey("$value",e)&&!isObjKey("cloud.knapsack",e)}s(St,"Kt");u(St,"isTokenGroup");function Yr(e){if(St(e)){let t=e.$extensions["cloud.knapsack"].group.collectionInfo;if(isObjKey("type",t)&&isObjKey("referenceId",t))return !0}return !1}s(Yr,"Fo");u(Yr,"isTokenTypeVarRef");function Qr(e){let t=typeof e;if(t==="string"||t==="number"||t==="boolean")return t;throw new Error(`Invalid token value type: ${JSON.stringify(t)}. Token value is: ${JSON.stringify(e)}`)}s(Qr,"jo");u(Qr,"getPrimitiveValue");u(e=>e.includes("px")||e.includes("rem")||e.includes("em")||e.includes("%"),"isDimensionString");function Zr(e){let{value:t,unit:n}=parseNumberWithUnit(e);if(!n)return {value:t};if(n!=="px"&&n!=="rem"&&n!=="em"&&n!=="%")throw new Error(`Invalid unit "${n}" for value: ${t}`);return {value:t,unit:n}}s(Zr,"_o");u(Zr,"parseTokenDimensionValue");u(e=>isObject(e)&&e.type==="text","isSlottedText");function en(e){return isObject(e)&&e.type==="template-demo"}s(en,"qo");u(en,"isSlottedTemplateDemo");function tn(e){return isObject(e)&&e.type==="template-reference"}s(tn,"Jo");u(tn,"isSlottedTemplateReference");var rn=(e=>(e.portrait="portrait",e.landscape="landscape",e))(rn||{});function nn(e){return e?.type==="data"}s(nn,"Yo");u(nn,"isDataDemo");function an(e){return e?.type==="template"}s(an,"Xo");u(an,"isTemplateDemo");var sn=(e=>(e.auto="auto",e.small="small",e.medium="medium",e.large="large",e.full="full",e))(sn||{});function kt(e){return !isObject(e)||!["assetSetsState","customPagesState","navsState","patternsState","tokensSrc","db"].every(t=>isObjKey(t,e))?!1:!isObjKey("metaState",e)}s(kt,"zt");u(kt,"isKsAppClientDataNoMeta");define("KsAppClientDataNoMeta",kt);function _t(e){return isObject(e)?["assetSetsState","customPagesState","navsState","patternsState","tokensSrc","metaState","db"].every(t=>isObjKey(t,e)):!1}s(_t,"Mt");u(_t,"isKsAppClientDataAndMeta");define("KsAppClientDataAndMeta",_t);type({isLocalDev:boolean(),plugins:array(type({id:string(),hasContent:boolean(),clientPluginPath:optional(string()),cssPath:optional(string())})),meta:optional(type({version:optional(string()),hasKnapsackCloud:boolean(),knapsackCloudSiteId:optional(string()),serverPort:optional(number()),websocketsPort:optional(number()),https:optional(boolean()),cacheDir:optional(string()),ksVersions:type({app:string()})}))});function Ct(e){return !isObject(e)||!["assetSetsState","customPagesState","navsState","patternsState","settingsState","tokensState"].every(t=>isObjKey(t,e))?!1:!isObjKey("metaState",e)}s(Ct,"_t");u(Ct,"isKsAppClientDataNoMetaV3");define("KsAppClientDataNoMeta",Ct);function Tt(e){return isObject(e)?["assetSetsState","customPagesState","navsState","patternsState","settingsState","tokensState","metaState"].every(t=>isObjKey(t,e)):!1}s(Tt,"Lt");u(Tt,"isKsAppClientDataAndMetaV3");define("KsAppClientDataAndMeta",Tt);type({isLocalDev:boolean(),plugins:array(type({id:string(),hasContent:boolean(),clientPluginPath:optional(string()),cssPath:optional(string())})),meta:optional(type({version:optional(string()),hasKnapsackCloud:boolean(),knapsackCloudSiteId:optional(string()),serverPort:optional(number()),websocketsPort:optional(number()),https:optional(boolean()),cacheDir:optional(string()),ksVersions:type({app:string()})}))});({version:"4.1.7",checkIfNeeded:u(e=>!0,"checkIfNeeded"),migrate:u(e=>{if(!M(e))throw new Error("Tried to run migrations on appClientData but it is not an Immer Draft");Object.values(e.patternsState.patterns).forEach(t=>{delete t.demoSize;}),Object.values(e.db.demos.byId).forEach(t=>{t.type==="data"&&(Object.entries(t.data.slots??{}).forEach(([n,a])=>{t.data.slots[n]=a.map(o=>typeof o=="string"?{type:"text",text:o}:(o.type==="template-reference"||o.type==="text"||(o.type="template-demo"),o));}),!(t.patternId&&t.templateId)&&(()=>{for(let{id:n,templates:a=[]}of Object.values(e.patternsState.patterns))for(let{id:o,demoIds:d=[]}of a)if(d.includes(t.id)){t.patternId=n,t.templateId=o;return}})());});},"migrate")});var un=(e=>(e.string="string",e.boolean="boolean",e.number="number",e.object="object",e.options="options",e.function="function",e.customTypeScript="customTypeScript",e.array="array",e.arrayOfObjects="arrayOfObjects",e.arrayOfStrings="arrayOfStrings",e.unknown="unknown",e))(un||{});u(e=>"type"in e&&e.type==="string"&&!("enum"in e),"isStringProp");u(e=>"type"in e&&e.type==="number","isNumberProp");u(e=>"type"in e&&e.type==="boolean","isBooleanProp");u(e=>"enum"in e,"isOptionsProp");u(e=>"typeof"in e&&e?.typeof==="function","isFunctionProp");u(e=>!("typeof"in e)&&"tsType"in e,"isCustomTypeScriptProp");u(e=>"type"in e&&e.type==="array"&&"items"in e&&e.items.type==="object","isArrayOfObjectsProp");u(e=>"type"in e&&e.type==="object"&&"properties"in e&&Object.keys(e.properties).length>0,"isObjectProp");u(e=>"type"in e&&e.type==="array"&&"items"in e&&e.items.type==="string","isArrayOfStringsProp");var wt=r.object({op:r.union([r.literal("replace"),r.literal("remove"),r.literal("add")]),path:r.array(r.union([r.string(),r.number()])),value:r.optional(r.any())}),cn=wt;u(e=>cn.is(e),"isPatch");var Ne=r.array(wt),dn=Ne;u(e=>dn.is(e),"isPatches");var xt=r.type({patches:Ne,inversePatches:r.optional(Ne),event:r.optional(r.object({type:r.string()})),id:r.string(),date:r.string(),userId:r.optional(r.string())}),pn=xt;u(e=>pn.is(e),"isKsRemoteChange");var fn=r.array(xt),gn=fn;u(e=>gn.is(e),"isKsRemoteChanges");var yn=(e=>(e.ready="ready",e))(yn||{});var mn=(e=>(e.GitHub="GitHub",e.GitLab="GitLab",e.GitLabRest="GitLabRest",e.Bitbucket="Bitbucket",e.Azure="Azure",e))(mn||{}),hn=(e=>(e.Conflicting="CONFLICTING",e.Mergeable="MERGEABLE",e.Unknown="UNKNOWN",e))(hn||{}),bn=(e=>(e.Create="CREATE",e.Move="MOVE",e.Update="UPDATE",e.Chmod="CHMOD",e))(bn||{}),vn=(e=>(e.Base64="BASE64",e.Text="TEXT",e))(vn||{}),Sn={};ot(Sn,{ACTIONS:s(()=>At,"ACTIONS"),endpoint:s(()=>kn,"endpoint")});var kn="/plugins",At=(e=>(e.getContent="getContent",e))(At||{}),_n={};ot(_n,{ACTIONS:s(()=>Et,"ACTIONS"),endpoint:s(()=>Cn,"endpoint")});var Cn="/files",Et=(e=>(e.verify="verify",e))(Et||{}),Tn={ADMIN:"ADMIN",ANONYMOUS:"ANONYMOUS",CONTRIBUTOR:"CONTRIBUTOR",EDITOR:"EDITOR",MANAGER:"MANAGER",VIEWER:"VIEWER"},Dt=Object.values(Tn);var Ot=enums(Dt),En=Ot,Ya=s(e=>e==="ADMIN","canRoleAdmin"),Mt=["ADMIN","MANAGER"],Qa=s(e=>Mt.includes(e),"canRoleManageUsers"),Ft=[...Mt,"EDITOR"],Za=s(e=>Ft.includes(e),"canRoleDelete"),zt=[...Ft,"CONTRIBUTOR"],ei=s(e=>zt.includes(e),"canRoleEdit"),Dn=["ADMIN"],ti=s(e=>Dn.includes(e),"canRolePublish"),Nn=[...zt,"VIEWER"],ri=s(e=>Nn.includes(e),"canRoleView"),Vn=s(e=>En.is(e),"isRoleValid"),Kt=(n=>(n.user="user",n.anonymous="anonymous",n))(Kt||{}),It=enums(Object.values(Kt)),In=object({"x-hasura-allowed-roles":array(It),"x-hasura-default-role":It,"x-hasura-user-id":optional(string())}),Pn=object({userId:string(),isSuperAdmin:boolean(),sitesByRole:record(Ot,array(string()))}),Rn=type({exp:number(),email:optional(string()),email_verified:optional(union([string(),boolean()])),iat:number(),iss:string(),sub:string(),aud:union([string(),array(string())])}),On="https://hasura.io/jwt/claims",Bt="https://knapsack.cloud",Mn=object({[On]:In,[Bt]:Pn}),Fn=assign(Rn,Mn);function zn(e){return Object.entries(e).reduce((t,[n,a])=>(Vn(n)&&a.forEach(o=>{t[o]=n;}),t),{})}s(zn,"expandSitesByRole");var Kn={isSuperAdmin:!1,userId:"",siteRoleMap:{},getSiteRole:s(()=>"ANONYMOUS","getSiteRole")},ni=s(e=>{if(!Fn.is(e))return Kn;let{sitesByRole:t,...n}=e[Bt],a=zn(t);return {...n,siteRoleMap:a,getSiteRole:s(o=>n.isSuperAdmin?"ADMIN":a[o]||"ANONYMOUS","getSiteRole")}},"getKsClaims");var si="/site-deployed",oi="/github-auth";var{KS_DB_URL:he}=process.env;if(he&&!isUrl(he))throw new Error(`KS_DB_URL is not a valid URL: '${he}'`);var Ut=he||"https://db.knapsack.cloud",Un=new URL("/v1/graphql",Ut).toString(),ci={dbUrl:Ut,dbGqlEndpoint:Un};var pi={siteId:"X-KS-Site-ID",instanceId:"X-KS-Instance-Id"};
36
6
 
37
- // ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
38
- var require_color_name = __commonJS({
39
- "../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js"(exports, module) {
40
- "use strict";
41
- init_esm_shims();
42
- module.exports = {
43
- "aliceblue": [240, 248, 255],
44
- "antiquewhite": [250, 235, 215],
45
- "aqua": [0, 255, 255],
46
- "aquamarine": [127, 255, 212],
47
- "azure": [240, 255, 255],
48
- "beige": [245, 245, 220],
49
- "bisque": [255, 228, 196],
50
- "black": [0, 0, 0],
51
- "blanchedalmond": [255, 235, 205],
52
- "blue": [0, 0, 255],
53
- "blueviolet": [138, 43, 226],
54
- "brown": [165, 42, 42],
55
- "burlywood": [222, 184, 135],
56
- "cadetblue": [95, 158, 160],
57
- "chartreuse": [127, 255, 0],
58
- "chocolate": [210, 105, 30],
59
- "coral": [255, 127, 80],
60
- "cornflowerblue": [100, 149, 237],
61
- "cornsilk": [255, 248, 220],
62
- "crimson": [220, 20, 60],
63
- "cyan": [0, 255, 255],
64
- "darkblue": [0, 0, 139],
65
- "darkcyan": [0, 139, 139],
66
- "darkgoldenrod": [184, 134, 11],
67
- "darkgray": [169, 169, 169],
68
- "darkgreen": [0, 100, 0],
69
- "darkgrey": [169, 169, 169],
70
- "darkkhaki": [189, 183, 107],
71
- "darkmagenta": [139, 0, 139],
72
- "darkolivegreen": [85, 107, 47],
73
- "darkorange": [255, 140, 0],
74
- "darkorchid": [153, 50, 204],
75
- "darkred": [139, 0, 0],
76
- "darksalmon": [233, 150, 122],
77
- "darkseagreen": [143, 188, 143],
78
- "darkslateblue": [72, 61, 139],
79
- "darkslategray": [47, 79, 79],
80
- "darkslategrey": [47, 79, 79],
81
- "darkturquoise": [0, 206, 209],
82
- "darkviolet": [148, 0, 211],
83
- "deeppink": [255, 20, 147],
84
- "deepskyblue": [0, 191, 255],
85
- "dimgray": [105, 105, 105],
86
- "dimgrey": [105, 105, 105],
87
- "dodgerblue": [30, 144, 255],
88
- "firebrick": [178, 34, 34],
89
- "floralwhite": [255, 250, 240],
90
- "forestgreen": [34, 139, 34],
91
- "fuchsia": [255, 0, 255],
92
- "gainsboro": [220, 220, 220],
93
- "ghostwhite": [248, 248, 255],
94
- "gold": [255, 215, 0],
95
- "goldenrod": [218, 165, 32],
96
- "gray": [128, 128, 128],
97
- "green": [0, 128, 0],
98
- "greenyellow": [173, 255, 47],
99
- "grey": [128, 128, 128],
100
- "honeydew": [240, 255, 240],
101
- "hotpink": [255, 105, 180],
102
- "indianred": [205, 92, 92],
103
- "indigo": [75, 0, 130],
104
- "ivory": [255, 255, 240],
105
- "khaki": [240, 230, 140],
106
- "lavender": [230, 230, 250],
107
- "lavenderblush": [255, 240, 245],
108
- "lawngreen": [124, 252, 0],
109
- "lemonchiffon": [255, 250, 205],
110
- "lightblue": [173, 216, 230],
111
- "lightcoral": [240, 128, 128],
112
- "lightcyan": [224, 255, 255],
113
- "lightgoldenrodyellow": [250, 250, 210],
114
- "lightgray": [211, 211, 211],
115
- "lightgreen": [144, 238, 144],
116
- "lightgrey": [211, 211, 211],
117
- "lightpink": [255, 182, 193],
118
- "lightsalmon": [255, 160, 122],
119
- "lightseagreen": [32, 178, 170],
120
- "lightskyblue": [135, 206, 250],
121
- "lightslategray": [119, 136, 153],
122
- "lightslategrey": [119, 136, 153],
123
- "lightsteelblue": [176, 196, 222],
124
- "lightyellow": [255, 255, 224],
125
- "lime": [0, 255, 0],
126
- "limegreen": [50, 205, 50],
127
- "linen": [250, 240, 230],
128
- "magenta": [255, 0, 255],
129
- "maroon": [128, 0, 0],
130
- "mediumaquamarine": [102, 205, 170],
131
- "mediumblue": [0, 0, 205],
132
- "mediumorchid": [186, 85, 211],
133
- "mediumpurple": [147, 112, 219],
134
- "mediumseagreen": [60, 179, 113],
135
- "mediumslateblue": [123, 104, 238],
136
- "mediumspringgreen": [0, 250, 154],
137
- "mediumturquoise": [72, 209, 204],
138
- "mediumvioletred": [199, 21, 133],
139
- "midnightblue": [25, 25, 112],
140
- "mintcream": [245, 255, 250],
141
- "mistyrose": [255, 228, 225],
142
- "moccasin": [255, 228, 181],
143
- "navajowhite": [255, 222, 173],
144
- "navy": [0, 0, 128],
145
- "oldlace": [253, 245, 230],
146
- "olive": [128, 128, 0],
147
- "olivedrab": [107, 142, 35],
148
- "orange": [255, 165, 0],
149
- "orangered": [255, 69, 0],
150
- "orchid": [218, 112, 214],
151
- "palegoldenrod": [238, 232, 170],
152
- "palegreen": [152, 251, 152],
153
- "paleturquoise": [175, 238, 238],
154
- "palevioletred": [219, 112, 147],
155
- "papayawhip": [255, 239, 213],
156
- "peachpuff": [255, 218, 185],
157
- "peru": [205, 133, 63],
158
- "pink": [255, 192, 203],
159
- "plum": [221, 160, 221],
160
- "powderblue": [176, 224, 230],
161
- "purple": [128, 0, 128],
162
- "rebeccapurple": [102, 51, 153],
163
- "red": [255, 0, 0],
164
- "rosybrown": [188, 143, 143],
165
- "royalblue": [65, 105, 225],
166
- "saddlebrown": [139, 69, 19],
167
- "salmon": [250, 128, 114],
168
- "sandybrown": [244, 164, 96],
169
- "seagreen": [46, 139, 87],
170
- "seashell": [255, 245, 238],
171
- "sienna": [160, 82, 45],
172
- "silver": [192, 192, 192],
173
- "skyblue": [135, 206, 235],
174
- "slateblue": [106, 90, 205],
175
- "slategray": [112, 128, 144],
176
- "slategrey": [112, 128, 144],
177
- "snow": [255, 250, 250],
178
- "springgreen": [0, 255, 127],
179
- "steelblue": [70, 130, 180],
180
- "tan": [210, 180, 140],
181
- "teal": [0, 128, 128],
182
- "thistle": [216, 191, 216],
183
- "tomato": [255, 99, 71],
184
- "turquoise": [64, 224, 208],
185
- "violet": [238, 130, 238],
186
- "wheat": [245, 222, 179],
187
- "white": [255, 255, 255],
188
- "whitesmoke": [245, 245, 245],
189
- "yellow": [255, 255, 0],
190
- "yellowgreen": [154, 205, 50]
191
- };
192
- }
193
- });
194
-
195
- // ../../node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js
196
- var require_is_arrayish = __commonJS({
197
- "../../node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js"(exports, module) {
198
- init_esm_shims();
199
- module.exports = /* @__PURE__ */ __name(function isArrayish(obj) {
200
- if (!obj || typeof obj === "string") {
201
- return false;
202
- }
203
- return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && (obj.splice instanceof Function || Object.getOwnPropertyDescriptor(obj, obj.length - 1) && obj.constructor.name !== "String");
204
- }, "isArrayish");
205
- }
206
- });
207
-
208
- // ../../node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js
209
- var require_simple_swizzle = __commonJS({
210
- "../../node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js"(exports, module) {
211
- "use strict";
212
- init_esm_shims();
213
- var isArrayish = require_is_arrayish();
214
- var concat = Array.prototype.concat;
215
- var slice = Array.prototype.slice;
216
- var swizzle = module.exports = /* @__PURE__ */ __name(function swizzle2(args) {
217
- var results = [];
218
- for (var i = 0, len = args.length; i < len; i++) {
219
- var arg = args[i];
220
- if (isArrayish(arg)) {
221
- results = concat.call(results, slice.call(arg));
222
- } else {
223
- results.push(arg);
224
- }
225
- }
226
- return results;
227
- }, "swizzle");
228
- swizzle.wrap = function(fn) {
229
- return function() {
230
- return fn(swizzle(arguments));
231
- };
232
- };
233
- }
234
- });
235
-
236
- // ../../node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js
237
- var require_color_string = __commonJS({
238
- "../../node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js"(exports, module) {
239
- init_esm_shims();
240
- var colorNames = require_color_name();
241
- var swizzle = require_simple_swizzle();
242
- var hasOwnProperty = Object.hasOwnProperty;
243
- var reverseNames = /* @__PURE__ */ Object.create(null);
244
- for (name in colorNames) {
245
- if (hasOwnProperty.call(colorNames, name)) {
246
- reverseNames[colorNames[name]] = name;
247
- }
248
- }
249
- var name;
250
- var cs = module.exports = {
251
- to: {},
252
- get: {}
253
- };
254
- cs.get = function(string8) {
255
- var prefix = string8.substring(0, 3).toLowerCase();
256
- var val;
257
- var model;
258
- switch (prefix) {
259
- case "hsl":
260
- val = cs.get.hsl(string8);
261
- model = "hsl";
262
- break;
263
- case "hwb":
264
- val = cs.get.hwb(string8);
265
- model = "hwb";
266
- break;
267
- default:
268
- val = cs.get.rgb(string8);
269
- model = "rgb";
270
- break;
271
- }
272
- if (!val) {
273
- return null;
274
- }
275
- return { model, value: val };
276
- };
277
- cs.get.rgb = function(string8) {
278
- if (!string8) {
279
- return null;
280
- }
281
- var abbr = /^#([a-f0-9]{3,4})$/i;
282
- var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
283
- var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
284
- var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
285
- var keyword = /^(\w+)$/;
286
- var rgb = [0, 0, 0, 1];
287
- var match;
288
- var i;
289
- var hexAlpha;
290
- if (match = string8.match(hex)) {
291
- hexAlpha = match[2];
292
- match = match[1];
293
- for (i = 0; i < 3; i++) {
294
- var i2 = i * 2;
295
- rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
296
- }
297
- if (hexAlpha) {
298
- rgb[3] = parseInt(hexAlpha, 16) / 255;
299
- }
300
- } else if (match = string8.match(abbr)) {
301
- match = match[1];
302
- hexAlpha = match[3];
303
- for (i = 0; i < 3; i++) {
304
- rgb[i] = parseInt(match[i] + match[i], 16);
305
- }
306
- if (hexAlpha) {
307
- rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
308
- }
309
- } else if (match = string8.match(rgba)) {
310
- for (i = 0; i < 3; i++) {
311
- rgb[i] = parseInt(match[i + 1], 0);
312
- }
313
- if (match[4]) {
314
- if (match[5]) {
315
- rgb[3] = parseFloat(match[4]) * 0.01;
316
- } else {
317
- rgb[3] = parseFloat(match[4]);
318
- }
319
- }
320
- } else if (match = string8.match(per)) {
321
- for (i = 0; i < 3; i++) {
322
- rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
323
- }
324
- if (match[4]) {
325
- if (match[5]) {
326
- rgb[3] = parseFloat(match[4]) * 0.01;
327
- } else {
328
- rgb[3] = parseFloat(match[4]);
329
- }
330
- }
331
- } else if (match = string8.match(keyword)) {
332
- if (match[1] === "transparent") {
333
- return [0, 0, 0, 0];
334
- }
335
- if (!hasOwnProperty.call(colorNames, match[1])) {
336
- return null;
337
- }
338
- rgb = colorNames[match[1]];
339
- rgb[3] = 1;
340
- return rgb;
341
- } else {
342
- return null;
343
- }
344
- for (i = 0; i < 3; i++) {
345
- rgb[i] = clamp(rgb[i], 0, 255);
346
- }
347
- rgb[3] = clamp(rgb[3], 0, 1);
348
- return rgb;
349
- };
350
- cs.get.hsl = function(string8) {
351
- if (!string8) {
352
- return null;
353
- }
354
- var 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*)?\)$/;
355
- var match = string8.match(hsl);
356
- if (match) {
357
- var alpha = parseFloat(match[4]);
358
- var h = (parseFloat(match[1]) % 360 + 360) % 360;
359
- var s4 = clamp(parseFloat(match[2]), 0, 100);
360
- var l = clamp(parseFloat(match[3]), 0, 100);
361
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
362
- return [h, s4, l, a];
363
- }
364
- return null;
365
- };
366
- cs.get.hwb = function(string8) {
367
- if (!string8) {
368
- return null;
369
- }
370
- var 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*)?\)$/;
371
- var match = string8.match(hwb);
372
- if (match) {
373
- var alpha = parseFloat(match[4]);
374
- var h = (parseFloat(match[1]) % 360 + 360) % 360;
375
- var w = clamp(parseFloat(match[2]), 0, 100);
376
- var b = clamp(parseFloat(match[3]), 0, 100);
377
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
378
- return [h, w, b, a];
379
- }
380
- return null;
381
- };
382
- cs.to.hex = function() {
383
- var rgba = swizzle(arguments);
384
- return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
385
- };
386
- cs.to.rgb = function() {
387
- var rgba = swizzle(arguments);
388
- return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
389
- };
390
- cs.to.rgb.percent = function() {
391
- var rgba = swizzle(arguments);
392
- var r = Math.round(rgba[0] / 255 * 100);
393
- var g = Math.round(rgba[1] / 255 * 100);
394
- var b = Math.round(rgba[2] / 255 * 100);
395
- return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
396
- };
397
- cs.to.hsl = function() {
398
- var hsla = swizzle(arguments);
399
- return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
400
- };
401
- cs.to.hwb = function() {
402
- var hwba = swizzle(arguments);
403
- var a = "";
404
- if (hwba.length >= 4 && hwba[3] !== 1) {
405
- a = ", " + hwba[3];
406
- }
407
- return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
408
- };
409
- cs.to.keyword = function(rgb) {
410
- return reverseNames[rgb.slice(0, 3)];
411
- };
412
- function clamp(num, min, max) {
413
- return Math.min(Math.max(min, num), max);
414
- }
415
- __name(clamp, "clamp");
416
- function hexDouble(num) {
417
- var str = Math.round(num).toString(16).toUpperCase();
418
- return str.length < 2 ? "0" + str : str;
419
- }
420
- __name(hexDouble, "hexDouble");
421
- }
422
- });
423
-
424
- // src/index.ts
425
- init_esm_shims();
426
-
427
- // src/users.ts
428
- init_esm_shims();
429
- import {
430
- array as array7,
431
- boolean as boolean6,
432
- enums as enums2,
433
- number as number6,
434
- object as object4,
435
- optional as optional8,
436
- string as string7,
437
- type as type9,
438
- union as union6,
439
- record,
440
- assign as assign2
441
- } from "superstruct";
442
-
443
- // ../types/dist/index.mjs
444
- init_esm_shims();
445
- var import_color_string = __toESM(require_color_string(), 1);
446
- import {
447
- type as type4,
448
- literal as literal3,
449
- optional as optional3,
450
- defaulted,
451
- boolean as boolean2,
452
- array as array2,
453
- object as object2
454
- } from "superstruct";
455
- import { define, literal, string, type, union } from "superstruct";
456
- import {
457
- string as string2,
458
- type as type2,
459
- union as union2,
460
- number,
461
- enums,
462
- optional,
463
- literal as literal2,
464
- array,
465
- size,
466
- boolean,
467
- object
468
- } from "superstruct";
469
- import { type as type3, union as union3, optional as optional2 } from "superstruct";
470
- import {
471
- type as type6,
472
- string as string4,
473
- boolean as boolean4,
474
- optional as optional5,
475
- array as array4,
476
- number as number3,
477
- define as define4
478
- } from "superstruct";
479
- import { isObjKey, isObject } from "@knapsack/utils";
480
- import { expectType, isObjKey as isObjKey2, isObject as isObject2 } from "@knapsack/utils";
481
- import * as s2 from "superstruct";
482
- import * as s from "superstruct";
483
- import { expectType as expectType2 } from "@knapsack/utils";
484
- import { expectType as expectType3, isObjKey as isObjKey3, isObject as isObject3 } from "@knapsack/utils";
485
- import { parseNumberWithUnit } from "@knapsack/utils";
486
- import {
487
- type as type7,
488
- string as string5,
489
- boolean as boolean5,
490
- optional as optional6,
491
- array as array5,
492
- number as number4,
493
- define as define5
494
- } from "superstruct";
495
- import * as s3 from "superstruct";
496
- var __defProp2 = Object.defineProperty;
497
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
498
- var __export = /* @__PURE__ */ __name((target, all) => {
499
- for (var name in all)
500
- __defProp2(target, name, { get: all[name], enumerable: true });
501
- }, "__export");
502
- function isColor(color) {
503
- if (typeof color !== "string") return false;
504
- try {
505
- return !!import_color_string.default.get(color);
506
- } catch (e) {
507
- return false;
508
- }
509
- }
510
- __name(isColor, "isColor");
511
- __name2(isColor, "isColor");
512
- var ColorStringStruct = define(
513
- "ColorStringStruct",
514
- (value) => typeof value === "string" && isColor(value)
515
- );
516
- var ColorConfigStruct = union([
517
- type({
518
- type: literal("value"),
519
- colorValue: ColorStringStruct
520
- }),
521
- type({
522
- type: literal("design-token"),
523
- tokenName: string()
524
- })
525
- ]);
526
- var ColorTokenConfigStruct = type({
527
- type: literal("design-token"),
528
- tokenName: string()
529
- });
530
- var FontSizeConfigValStruct = object({
531
- unit: enums(["rem", "px"]),
532
- value: number()
533
- });
534
- var FontFaceWeightStruct = union2([
535
- string2(),
536
- number()
537
- ]);
538
- var FontFaceFormatsEnumStruct = enums(["woff2", "woff"]);
539
- var FontFaceSourceStruct = type2({
540
- format: FontFaceFormatsEnumStruct,
541
- type: literal2("url"),
542
- path: string2()
543
- });
544
- var FontFaceConfigStruct = type2({
545
- family: optional(string2()),
546
- weight: optional(
547
- union2([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)])
548
- ),
549
- src: optional(array(FontFaceSourceStruct)),
550
- style: optional(string2()),
551
- display: optional(enums(["auto", "block", "swap", "fallback", "optional"])),
552
- variationSettings: optional(string2()),
553
- unicodeRange: optional(string2())
554
- });
555
- var TypographyLinkConfigStruct = type2({
556
- fontWeight: optional(union2([string2(), number()])),
557
- textColor: optional(ColorConfigStruct),
558
- hoverColor: optional(ColorConfigStruct),
559
- underline: optional(boolean()),
560
- textTransform: optional(
561
- enums(["inherit", "capitalize", "lowercase", "uppercase"])
562
- ),
563
- fontStretch: optional(
564
- enums([
565
- "ultra-condensed",
566
- "extra-condensed",
567
- "condensed",
568
- "semi-condensed",
569
- "normal",
570
- "semi-expanded",
571
- "expanded",
572
- "extra-expanded",
573
- "ultra-expanded"
574
- ])
575
- )
576
- });
577
- var FontSizeConfigStruct = type2({
578
- min: FontSizeConfigValStruct,
579
- max: optional(FontSizeConfigValStruct)
580
- });
581
- var TypographyConfigStruct = type2({
582
- fontSize: optional(FontSizeConfigStruct),
583
- lineHeight: optional(union2([string2(), number()])),
584
- fontWeight: optional(union2([string2(), number()])),
585
- letterSpacing: optional(string2()),
586
- fontFamily: optional(string2()),
587
- textColor: optional(ColorConfigStruct),
588
- textTransform: optional(
589
- enums(["inherit", "capitalize", "lowercase", "uppercase"])
590
- ),
591
- fontStretch: optional(
592
- enums([
593
- "ultra-condensed",
594
- "extra-condensed",
595
- "condensed",
596
- "semi-condensed",
597
- "normal",
598
- "semi-expanded",
599
- "expanded",
600
- "extra-expanded",
601
- "ultra-expanded"
602
- ])
603
- )
604
- });
605
- var NavCustomizationConfigStruct = union3([
606
- TypographyConfigStruct,
607
- type3({
608
- accentColor: optional2(ColorConfigStruct)
609
- })
610
- ]);
611
- var PrimaryNavCustomizationConfigStruct = union3([
612
- NavCustomizationConfigStruct,
613
- type3({
614
- hoverColor: optional2(ColorConfigStruct),
615
- backgroundColor: optional2(ColorConfigStruct)
616
- })
617
- ]);
618
- var SecondaryNavCustomizationConfigStruct = union3([
619
- NavCustomizationConfigStruct,
620
- type3({
621
- backgroundColor: optional2(ColorConfigStruct)
622
- })
623
- ]);
624
- var UiConfigV1Struct = object2({
625
- version: literal3(1),
626
- oldSillySidebarBgColor: ColorStringStruct
627
- });
628
- var UiConfigV2Struct = object2({
629
- version: literal3(2),
630
- anotherSillySidebarBgColor: ColorStringStruct
631
- });
632
- var UiConfigV3Struct = object2({
633
- version: literal3(3),
634
- sidebarBgColor: ColorStringStruct
635
- });
636
- var UiConfigV4Struct = object2({
637
- version: literal3(4),
638
- primaryColor: ColorConfigStruct,
639
- darkColor: ColorConfigStruct,
640
- lightColor: ColorConfigStruct,
641
- enableSidebarIcons: optional3(defaulted(boolean2(), true))
642
- });
643
- var UiConfigV5Struct = object2({
644
- version: literal3(5),
645
- primaryColor: ColorConfigStruct,
646
- darkColor: ColorConfigStruct,
647
- lightColor: ColorConfigStruct,
648
- linkColor: ColorConfigStruct,
649
- enableSidebarIcons: optional3(defaulted(boolean2(), true))
650
- });
651
- var UiConfigV6Struct = object2({
652
- version: literal3(6),
653
- primaryColor: ColorConfigStruct,
654
- darkColor: ColorConfigStruct,
655
- lightColor: ColorConfigStruct,
656
- linkColor: ColorConfigStruct,
657
- enableSidebarIcons: optional3(defaulted(boolean2(), true)),
658
- appearance: type4({
659
- customFonts: optional3(array2(FontFaceConfigStruct)),
660
- pageElements: type4({
661
- pageTitle: optional3(TypographyConfigStruct),
662
- pageDescription: optional3(TypographyConfigStruct),
663
- headingLarge: optional3(TypographyConfigStruct),
664
- headingMedium: optional3(TypographyConfigStruct),
665
- headingSmall: optional3(TypographyConfigStruct),
666
- bodyText: optional3(TypographyConfigStruct),
667
- link: optional3(TypographyLinkConfigStruct)
668
- })
669
- })
670
- });
671
- var UiConfigV7Struct = object2({
672
- version: literal3(7),
673
- primaryColor: ColorConfigStruct,
674
- darkColor: ColorConfigStruct,
675
- lightColor: ColorConfigStruct,
676
- linkColor: ColorConfigStruct,
677
- enableSidebarIcons: optional3(defaulted(boolean2(), true)),
678
- appearance: type4({
679
- customFonts: optional3(array2(FontFaceConfigStruct)),
680
- navigation: optional3(
681
- type4({
682
- primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
683
- secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
684
- tabs: optional3(NavCustomizationConfigStruct)
685
- })
686
- ),
687
- pageElements: type4({
688
- pageTitle: optional3(TypographyConfigStruct),
689
- pageDescription: optional3(TypographyConfigStruct),
690
- headingLarge: optional3(TypographyConfigStruct),
691
- headingMedium: optional3(TypographyConfigStruct),
692
- headingSmall: optional3(TypographyConfigStruct),
693
- bodyText: optional3(TypographyConfigStruct),
694
- link: optional3(TypographyLinkConfigStruct)
695
- })
696
- })
697
- });
698
- var UiConfigV8Struct = object2({
699
- version: literal3(8),
700
- primaryColor: ColorConfigStruct,
701
- darkColor: ColorConfigStruct,
702
- lightColor: ColorConfigStruct,
703
- linkColor: ColorConfigStruct,
704
- appearance: type4({
705
- customFonts: optional3(array2(FontFaceConfigStruct)),
706
- navigation: optional3(
707
- type4({
708
- primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
709
- secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
710
- tabs: optional3(NavCustomizationConfigStruct)
711
- })
712
- ),
713
- pageElements: type4({
714
- pageTitle: optional3(TypographyConfigStruct),
715
- pageDescription: optional3(TypographyConfigStruct),
716
- headingLarge: optional3(TypographyConfigStruct),
717
- headingMedium: optional3(TypographyConfigStruct),
718
- headingSmall: optional3(TypographyConfigStruct),
719
- bodyText: optional3(TypographyConfigStruct),
720
- link: optional3(TypographyLinkConfigStruct)
721
- })
722
- })
723
- });
724
- var UiConfigV9Struct = object2({
725
- version: literal3(9),
726
- appearance: type4({
727
- customFonts: optional3(array2(FontFaceConfigStruct)),
728
- navigation: optional3(
729
- type4({
730
- primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
731
- secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
732
- tabs: optional3(NavCustomizationConfigStruct)
733
- })
734
- ),
735
- pageElements: type4({
736
- pageTitle: optional3(TypographyConfigStruct),
737
- pageDescription: optional3(TypographyConfigStruct),
738
- headingLarge: optional3(TypographyConfigStruct),
739
- headingMedium: optional3(TypographyConfigStruct),
740
- headingSmall: optional3(TypographyConfigStruct),
741
- bodyText: optional3(TypographyConfigStruct),
742
- link: optional3(TypographyLinkConfigStruct)
743
- })
744
- })
745
- });
746
- var UiConfigV10Struct = object2({
747
- version: literal3(10),
748
- appearance: type4({
749
- customFonts: optional3(array2(FontFaceConfigStruct)),
750
- navigation: optional3(
751
- type4({
752
- primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
753
- secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
754
- tabs: optional3(NavCustomizationConfigStruct)
755
- })
756
- ),
757
- pageElements: type4({
758
- pageTitle: optional3(TypographyConfigStruct),
759
- pageDescription: optional3(TypographyConfigStruct),
760
- headingXLarge: optional3(TypographyConfigStruct),
761
- headingLarge: optional3(TypographyConfigStruct),
762
- headingMedium: optional3(TypographyConfigStruct),
763
- headingSmall: optional3(TypographyConfigStruct),
764
- headingXSmall: optional3(TypographyConfigStruct),
765
- bodyText: optional3(TypographyConfigStruct),
766
- link: optional3(TypographyLinkConfigStruct)
767
- })
768
- })
769
- });
770
- function isTokenReference(val) {
771
- if (typeof val !== "string") return false;
772
- const totalOpenBrackets = val.split("{").length - 1;
773
- return totalOpenBrackets === 1 && val.startsWith("{") && val.endsWith("}");
774
- }
775
- __name(isTokenReference, "isTokenReference");
776
- __name2(isTokenReference, "isTokenReference");
777
- function hasTokenReferences(val) {
778
- return typeof val === "string" && val.includes("{");
779
- }
780
- __name(hasTokenReferences, "hasTokenReferences");
781
- __name2(hasTokenReferences, "hasTokenReferences");
782
- function isNotTokenReference(value) {
783
- return !isTokenReference(value);
784
- }
785
- __name(isNotTokenReference, "isNotTokenReference");
786
- __name2(isNotTokenReference, "isNotTokenReference");
787
- var TokenReferenceStruct = s.define(
788
- "Token Reference",
789
- (value) => {
790
- if (typeof value !== "string") return false;
791
- if (isNotTokenReference(value)) {
792
- return "Must start and end with curly braces";
793
- }
794
- return true;
795
- }
796
- );
797
- var compositeTypesRecord = {
798
- border: "border",
799
- shadow: "shadow",
800
- transition: "transition"
801
- };
802
- var tokenTypeComposites = Object.values(compositeTypesRecord);
803
- var singularTypesRecord = {
804
- string: "string",
805
- number: "number",
806
- boolean: "boolean",
807
- color: "color",
808
- dimension: "dimension",
809
- duration: "duration",
810
- // fontFamily: 'fontFamily',
811
- fontWeight: "fontWeight",
812
- strokeStyle: "strokeStyle",
813
- cubicBezier: "cubicBezier"
814
- };
815
- var tokenTypeSingulars = Object.values(singularTypesRecord);
816
- function isTokenTypeComposite(type92) {
817
- return tokenTypeComposites.includes(type92);
818
- }
819
- __name(isTokenTypeComposite, "isTokenTypeComposite");
820
- __name2(isTokenTypeComposite, "isTokenTypeComposite");
821
- function isTokenTypeSingular(type92) {
822
- return tokenTypeSingulars.includes(type92);
823
- }
824
- __name(isTokenTypeSingular, "isTokenTypeSingular");
825
- __name2(isTokenTypeSingular, "isTokenTypeSingular");
826
- expectType([
827
- {
828
- inset: false,
829
- color: "#000",
830
- offsetX: "0px",
831
- offsetY: "0px",
832
- spread: "0px",
833
- blur: "0px"
834
- },
835
- {
836
- color: "#000",
837
- offsetX: "0px",
838
- offsetY: "0px",
839
- spread: "0px",
840
- blur: "0px",
841
- inset: true
842
- }
843
- ]);
844
- var TokenDataBaseStruct = s2.type({
845
- id: s2.string(),
846
- description: s2.optional(s2.string()),
847
- references: s2.optional(s2.array(s2.array(s2.string()))),
848
- tokenConfig: s2.optional(
849
- s2.type({
850
- purpose: s2.optional(s2.string())
851
- })
852
- )
853
- });
854
- expectType([
855
- {
856
- type: "duration",
857
- value: "1ms",
858
- originalValue: "1ms",
859
- id: "1",
860
- kind: "static"
861
- },
862
- {
863
- type: "duration",
864
- value: "1ms",
865
- kind: "ref",
866
- id: "1",
867
- originalValue: "{a.b}",
868
- referencedTokenId: "1"
869
- },
870
- // @ts-expect-error - kind is wrong
871
- {
872
- type: "duration",
873
- value: "1ms",
874
- originalValue: "1ms",
875
- id: "1",
876
- kind: "ref"
877
- },
878
- // @ts-expect-error - kind is wrong
879
- {
880
- type: "duration",
881
- value: "1ms",
882
- kind: "static",
883
- id: "1",
884
- originalValue: "{a.b}",
885
- referencedTokenId: "1"
886
- },
887
- {
888
- type: "color",
889
- value: "#000",
890
- kind: "static",
891
- id: "1",
892
- originalValue: "#000"
893
- },
894
- {
895
- type: "color",
896
- value: "#000",
897
- kind: "ref",
898
- id: "1",
899
- originalValue: "{c.b}",
900
- referencedTokenId: "c.b"
901
- },
902
- {
903
- type: "cubicBezier",
904
- kind: "static",
905
- value: [0, 0, 0, 1],
906
- originalValue: [0, 0, 0, 1],
907
- id: "1"
908
- }
909
- ]);
910
- function isTokenDataComposite(tokenData) {
911
- return isTokenTypeComposite(tokenData.type);
912
- }
913
- __name(isTokenDataComposite, "isTokenDataComposite");
914
- __name2(isTokenDataComposite, "isTokenDataComposite");
915
- expectType([
916
- {
917
- type: "border",
918
- kind: "static",
919
- id: "1",
920
- value: {
921
- color: "#000",
922
- style: "solid",
923
- width: "1px"
924
- },
925
- originalValue: {
926
- color: "#000",
927
- style: "solid",
928
- width: "1px"
929
- }
930
- },
931
- {
932
- type: "border",
933
- kind: "ref",
934
- referencedTokenId: "a.b",
935
- id: "1",
936
- value: {
937
- color: "red",
938
- style: "dashed",
939
- width: "2px"
940
- },
941
- originalValue: "{a.b}"
942
- },
943
- {
944
- type: "shadow",
945
- value: {
946
- color: "#000",
947
- offsetX: "1px",
948
- offsetY: "1px",
949
- blur: "1px",
950
- spread: "1px",
951
- inset: false
952
- },
953
- originalValue: {
954
- color: "#000",
955
- offsetX: "{a.a}",
956
- offsetY: "1px",
957
- blur: "1px",
958
- spread: "1px",
959
- inset: false
960
- },
961
- id: "1",
962
- kind: "static"
963
- },
964
- {
965
- type: "shadow",
966
- kind: "ref",
967
- referencedTokenId: "a.b",
968
- value: {
969
- inset: true,
970
- color: "red",
971
- offsetX: "1px",
972
- blur: "2px",
973
- offsetY: "3px",
974
- spread: "4px"
975
- },
976
- originalValue: "{a.b}",
977
- id: "1"
978
- },
979
- {
980
- type: "transition",
981
- value: {
982
- duration: "100ms",
983
- delay: "200ms",
984
- timingFunction: [0, 0, 0, 0]
985
- },
986
- originalValue: "{a.b}",
987
- kind: "ref",
988
- referencedTokenId: "a.b",
989
- id: "1"
990
- },
991
- {
992
- type: "transition",
993
- kind: "static",
994
- value: {
995
- duration: "100ms",
996
- delay: "200ms",
997
- timingFunction: [0, 0, 0, 0]
998
- },
999
- originalValue: {
1000
- duration: "100ms",
1001
- delay: "{a.c}",
1002
- timingFunction: "{a.c}"
1003
- },
1004
- id: "1"
1005
- },
1006
- {
1007
- type: "transition",
1008
- kind: "static",
1009
- value: {
1010
- duration: "100ms",
1011
- delay: "200ms",
1012
- timingFunction: [0, 0, 0, 0]
1013
- },
1014
- originalValue: {
1015
- duration: "100ms",
1016
- delay: "200ms",
1017
- timingFunction: [0, 0, 0, 0]
1018
- },
1019
- id: "1"
1020
- }
1021
- ]);
1022
- function isTokenValueColor(value) {
1023
- return typeof value === "string" && !hasTokenReferences(value);
1024
- }
1025
- __name(isTokenValueColor, "isTokenValueColor");
1026
- __name2(isTokenValueColor, "isTokenValueColor");
1027
- var TokenValueColorStruct = s2.define(
1028
- "Color Value",
1029
- (value) => {
1030
- if (typeof value !== "string") {
1031
- return "Value must be a string";
1032
- }
1033
- if (value === "") {
1034
- return "Value must not be empty";
1035
- }
1036
- if (hasTokenReferences(value)) {
1037
- return "Value must not contain {} (token references)";
1038
- }
1039
- return true;
1040
- }
1041
- );
1042
- var TokenDataColorNonRefStruct = s2.assign(
1043
- s2.type({
1044
- type: s2.literal("color"),
1045
- value: TokenValueColorStruct,
1046
- kind: s2.literal("static"),
1047
- originalValue: TokenValueColorStruct
1048
- }),
1049
- TokenDataBaseStruct
1050
- );
1051
- var TokenDataColorRefStruct = s2.assign(
1052
- s2.type({
1053
- type: s2.literal("color"),
1054
- value: TokenValueColorStruct,
1055
- kind: s2.literal("ref"),
1056
- originalValue: TokenReferenceStruct,
1057
- referencedTokenId: s2.string()
1058
- }),
1059
- TokenDataBaseStruct
1060
- );
1061
- function isTokenValueDimension(value) {
1062
- return typeof value === "string" && (value.endsWith("px") || value.endsWith("rem")) && !hasTokenReferences(value);
1063
- }
1064
- __name(isTokenValueDimension, "isTokenValueDimension");
1065
- __name2(isTokenValueDimension, "isTokenValueDimension");
1066
- var TokenValueDimensionStruct = s2.define("Dimension Value", (value) => {
1067
- if (typeof value !== "string") {
1068
- return "Value must be a string";
1069
- }
1070
- if (hasTokenReferences(value)) {
1071
- return "Value must not contain {} (token references)";
1072
- }
1073
- if (!value.endsWith("px") && !value.endsWith("rem") && !value.endsWith("em") && !value.endsWith("%")) {
1074
- return "Value must end with px, rem, em or %";
1075
- }
1076
- return true;
1077
- });
1078
- var TokenDataDimensionNonRefStruct = s2.assign(
1079
- s2.type({
1080
- type: s2.literal("dimension"),
1081
- value: TokenValueDimensionStruct,
1082
- kind: s2.literal("static"),
1083
- originalValue: TokenValueDimensionStruct
1084
- }),
1085
- TokenDataBaseStruct
1086
- );
1087
- var TokenDataDimensionRefStruct = s2.assign(
1088
- s2.type({
1089
- type: s2.literal("dimension"),
1090
- value: TokenValueDimensionStruct,
1091
- kind: s2.literal("ref"),
1092
- originalValue: TokenReferenceStruct,
1093
- referencedTokenId: s2.string()
1094
- }),
1095
- TokenDataBaseStruct
1096
- );
1097
- function isTokenValueDuration(value) {
1098
- return typeof value === "string" && value.endsWith("ms") && !hasTokenReferences(value);
1099
- }
1100
- __name(isTokenValueDuration, "isTokenValueDuration");
1101
- __name2(isTokenValueDuration, "isTokenValueDuration");
1102
- var TokenValueDurationStruct = s2.define("Duration Value", (value) => {
1103
- if (typeof value !== "string") {
1104
- return "Value must be a string";
1105
- }
1106
- if (hasTokenReferences(value)) {
1107
- return "Value must not contain {} (token references)";
1108
- }
1109
- const durationRegex = /^\d+ms$/;
1110
- if (!durationRegex.test(value)) {
1111
- return 'Value must be a number followed by "ms" (e.g., "100ms")';
1112
- }
1113
- return true;
1114
- });
1115
- var TokenDataDurationNonRefStruct = s2.assign(
1116
- s2.type({
1117
- type: s2.literal("duration"),
1118
- value: TokenValueDurationStruct,
1119
- kind: s2.literal("static"),
1120
- originalValue: TokenValueDurationStruct
1121
- }),
1122
- TokenDataBaseStruct
1123
- );
1124
- var TokenDataDurationRefStruct = s2.assign(
1125
- s2.type({
1126
- type: s2.literal("duration"),
1127
- value: TokenValueDurationStruct,
1128
- kind: s2.literal("ref"),
1129
- originalValue: TokenReferenceStruct,
1130
- referencedTokenId: s2.string()
1131
- }),
1132
- TokenDataBaseStruct
1133
- );
1134
- function isTokenValueFontWeight(value) {
1135
- return (typeof value === "string" || typeof value === "number") && !hasTokenReferences(value);
1136
- }
1137
- __name(isTokenValueFontWeight, "isTokenValueFontWeight");
1138
- __name2(isTokenValueFontWeight, "isTokenValueFontWeight");
1139
- var TokenValueFontWeightStruct = s2.define("Font Weight Value", (value) => {
1140
- if (typeof value !== "string" && typeof value !== "number") {
1141
- return "Value must be a string or number";
1142
- }
1143
- if (hasTokenReferences(value)) {
1144
- return "Value must not contain {} (token references)";
1145
- }
1146
- return true;
1147
- });
1148
- var TokenDataFontWeightNonRefStruct = s2.assign(
1149
- s2.type({
1150
- type: s2.literal("fontWeight"),
1151
- value: TokenValueFontWeightStruct,
1152
- kind: s2.literal("static"),
1153
- originalValue: TokenValueFontWeightStruct
1154
- }),
1155
- TokenDataBaseStruct
1156
- );
1157
- var TokenDataFontWeightRefStruct = s2.assign(
1158
- s2.type({
1159
- type: s2.literal("fontWeight"),
1160
- value: TokenValueFontWeightStruct,
1161
- kind: s2.literal("ref"),
1162
- originalValue: TokenReferenceStruct,
1163
- referencedTokenId: s2.string()
1164
- }),
1165
- TokenDataBaseStruct
1166
- );
1167
- var TokenValueCubicBezierStruct = s2.define("Cubic Bezier Value", (value) => {
1168
- if (!Array.isArray(value)) {
1169
- return "Value must be an array";
1170
- }
1171
- if (value.length !== 4) {
1172
- return "Value must be an array of 4 numbers";
1173
- }
1174
- if (!value.every((v) => typeof v === "number")) {
1175
- return "Value must be an array of 4 numbers";
1176
- }
1177
- if (value[0] < 0 || value[0] > 1 || value[2] < 0 || value[2] > 1) {
1178
- return "The first and third cubicBezier values must be between 0 and 1";
1179
- }
1180
- return true;
1181
- });
1182
- var TokenDataCubicBezierNonRefStruct = s2.assign(
1183
- s2.type({
1184
- type: s2.literal("cubicBezier"),
1185
- value: TokenValueCubicBezierStruct,
1186
- kind: s2.literal("static"),
1187
- originalValue: TokenValueCubicBezierStruct
1188
- }),
1189
- TokenDataBaseStruct
1190
- );
1191
- var TokenDataCubicBezierRefStruct = s2.assign(
1192
- s2.type({
1193
- type: s2.literal("cubicBezier"),
1194
- value: TokenValueCubicBezierStruct,
1195
- kind: s2.literal("ref"),
1196
- originalValue: TokenReferenceStruct,
1197
- referencedTokenId: s2.string()
1198
- }),
1199
- TokenDataBaseStruct
1200
- );
1201
- function isTokenValueShadow(value) {
1202
- return isObject2(value) && isTokenValueColor(value.color) && isTokenValueDimension(value.offsetX) && isTokenValueDimension(value.offsetY) && isTokenValueDimension(value.blur) && isTokenValueDimension(value.spread);
1203
- }
1204
- __name(isTokenValueShadow, "isTokenValueShadow");
1205
- __name2(isTokenValueShadow, "isTokenValueShadow");
1206
- var TokenValueShadowStruct = s2.define(
1207
- "Shadow Value",
1208
- (value) => {
1209
- if (isTokenValueShadow(value)) return true;
1210
- return `Expected a shadow value, got ${JSON.stringify(value)}`;
1211
- }
1212
- );
1213
- var TokenDataShadowNonRefStruct = s2.assign(
1214
- s2.type({
1215
- type: s2.literal("shadow"),
1216
- value: TokenValueShadowStruct,
1217
- kind: s2.literal("static"),
1218
- originalValue: s2.type({
1219
- color: s2.union([TokenValueColorStruct, TokenReferenceStruct]),
1220
- offsetX: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
1221
- offsetY: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
1222
- blur: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
1223
- spread: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
1224
- inset: s2.union([
1225
- // marking this as optional b/c it could be `undefined` instead of `false`
1226
- s2.optional(s2.boolean()),
1227
- TokenReferenceStruct
1228
- ])
1229
- })
1230
- }),
1231
- TokenDataBaseStruct
1232
- );
1233
- var TokenDataShadowRefStruct = s2.assign(
1234
- s2.type({
1235
- type: s2.literal("shadow"),
1236
- value: TokenValueShadowStruct,
1237
- kind: s2.literal("ref"),
1238
- originalValue: TokenReferenceStruct,
1239
- referencedTokenId: s2.string()
1240
- }),
1241
- TokenDataBaseStruct
1242
- );
1243
- var TokenValueStrokeStyleStruct = s2.union([
1244
- s2.literal("solid"),
1245
- s2.literal("dashed"),
1246
- s2.literal("dotted"),
1247
- s2.literal("double"),
1248
- s2.literal("groove"),
1249
- s2.literal("ridge"),
1250
- s2.literal("outset"),
1251
- s2.literal("inset")
1252
- ]);
1253
- function isTokenValueBorder(value) {
1254
- return isObject2(value) && TokenValueColorStruct.is(value.color) && TokenValueStrokeStyleStruct.is(value.style) && TokenValueDimensionStruct.is(value.width);
1255
- }
1256
- __name(isTokenValueBorder, "isTokenValueBorder");
1257
- __name2(isTokenValueBorder, "isTokenValueBorder");
1258
- var TokenValueBorderStruct = s2.define(
1259
- "Border Value",
1260
- isTokenValueBorder
1261
- );
1262
- var TokenDataBorderNonRefStruct = s2.assign(
1263
- s2.type({
1264
- type: s2.literal("border"),
1265
- value: TokenValueBorderStruct,
1266
- kind: s2.literal("static"),
1267
- originalValue: s2.type({
1268
- color: s2.union([TokenValueColorStruct, TokenReferenceStruct]),
1269
- style: s2.union([TokenValueStrokeStyleStruct, TokenReferenceStruct]),
1270
- width: s2.union([TokenValueDimensionStruct, TokenReferenceStruct])
1271
- })
1272
- }),
1273
- TokenDataBaseStruct
1274
- );
1275
- var TokenDataBorderRefStruct = s2.assign(
1276
- s2.type({
1277
- type: s2.literal("border"),
1278
- value: TokenValueBorderStruct,
1279
- kind: s2.literal("ref"),
1280
- originalValue: TokenReferenceStruct,
1281
- referencedTokenId: s2.string()
1282
- }),
1283
- TokenDataBaseStruct
1284
- );
1285
- function isTokenValueTransition(value) {
1286
- return isObject2(value) && TokenValueCubicBezierStruct.is(value.timingFunction) && TokenValueDurationStruct.is(value.duration) && TokenValueDurationStruct.is(value.delay);
1287
- }
1288
- __name(isTokenValueTransition, "isTokenValueTransition");
1289
- __name2(isTokenValueTransition, "isTokenValueTransition");
1290
- var TokenValueTransitionStruct = s2.define(
1291
- "Transition Value",
1292
- isTokenValueTransition
1293
- );
1294
- var TokenDataTransitionNonRefStruct = s2.assign(
1295
- s2.type({
1296
- type: s2.literal("transition"),
1297
- value: TokenValueTransitionStruct,
1298
- kind: s2.literal("static"),
1299
- originalValue: s2.type({
1300
- timingFunction: s2.union([
1301
- TokenValueCubicBezierStruct,
1302
- TokenReferenceStruct
1303
- ]),
1304
- duration: s2.union([TokenValueDurationStruct, TokenReferenceStruct]),
1305
- delay: s2.union([TokenValueDurationStruct, TokenReferenceStruct])
1306
- })
1307
- }),
1308
- TokenDataBaseStruct
1309
- );
1310
- var TokenDataTransitionRefStruct = s2.assign(
1311
- s2.type({
1312
- type: s2.literal("transition"),
1313
- value: TokenValueTransitionStruct,
1314
- kind: s2.literal("ref"),
1315
- originalValue: TokenReferenceStruct,
1316
- referencedTokenId: s2.string()
1317
- }),
1318
- TokenDataBaseStruct
1319
- );
1320
- var TokenDataStringNonRefStruct = s2.assign(
1321
- s2.type({
1322
- type: s2.literal("string"),
1323
- value: s2.string(),
1324
- kind: s2.literal("static"),
1325
- originalValue: s2.string()
1326
- }),
1327
- TokenDataBaseStruct
1328
- );
1329
- var TokenDataStringRefStruct = s2.assign(
1330
- s2.type({
1331
- type: s2.literal("string"),
1332
- value: s2.string(),
1333
- kind: s2.literal("ref"),
1334
- originalValue: TokenReferenceStruct,
1335
- referencedTokenId: s2.string()
1336
- }),
1337
- TokenDataBaseStruct
1338
- );
1339
- var TokenDataStrokeStyleNonRefStruct = s2.assign(
1340
- s2.type({
1341
- type: s2.literal("strokeStyle"),
1342
- value: TokenValueStrokeStyleStruct,
1343
- kind: s2.literal("static"),
1344
- originalValue: TokenValueStrokeStyleStruct
1345
- }),
1346
- TokenDataBaseStruct
1347
- );
1348
- var TokenDataStrokeStyleRefStruct = s2.assign(
1349
- s2.type({
1350
- type: s2.literal("strokeStyle"),
1351
- value: TokenValueStrokeStyleStruct,
1352
- kind: s2.literal("ref"),
1353
- originalValue: TokenReferenceStruct,
1354
- referencedTokenId: TokenValueStrokeStyleStruct
1355
- }),
1356
- TokenDataBaseStruct
1357
- );
1358
- var TokenDataNumberNonRefStruct = s2.assign(
1359
- s2.type({
1360
- type: s2.literal("number"),
1361
- value: s2.number(),
1362
- kind: s2.literal("static"),
1363
- originalValue: s2.number()
1364
- }),
1365
- TokenDataBaseStruct
1366
- );
1367
- var TokenDataNumberRefStruct = s2.assign(
1368
- s2.type({
1369
- type: s2.literal("number"),
1370
- value: s2.number(),
1371
- kind: s2.literal("ref"),
1372
- originalValue: TokenReferenceStruct,
1373
- referencedTokenId: s2.string()
1374
- }),
1375
- TokenDataBaseStruct
1376
- );
1377
- var TokenDataBooleanNonRefStruct = s2.assign(
1378
- s2.type({
1379
- type: s2.literal("boolean"),
1380
- value: s2.boolean(),
1381
- kind: s2.literal("static"),
1382
- originalValue: s2.boolean()
1383
- }),
1384
- TokenDataBaseStruct
1385
- );
1386
- var TokenDataBooleanRefStruct = s2.assign(
1387
- s2.type({
1388
- type: s2.literal("boolean"),
1389
- value: s2.boolean(),
1390
- kind: s2.literal("ref"),
1391
- originalValue: TokenReferenceStruct,
1392
- referencedTokenId: s2.string()
1393
- }),
1394
- TokenDataBaseStruct
1395
- );
1396
- expectType2([
1397
- {
1398
- type: "dimension",
1399
- kind: "static",
1400
- value: "1px"
1401
- },
1402
- {
1403
- type: "dimension",
1404
- kind: "ref",
1405
- referencedTokenId: "a.b"
1406
- }
1407
- ]);
1408
- expectType2([
1409
- {
1410
- type: "border",
1411
- kind: "ref",
1412
- referencedTokenId: "a.b"
1413
- },
1414
- {
1415
- type: "border",
1416
- kind: "static",
1417
- value: {
1418
- color: {
1419
- kind: "static",
1420
- type: "color",
1421
- value: "red"
1422
- },
1423
- style: {
1424
- kind: "ref",
1425
- type: "strokeStyle",
1426
- referencedTokenId: ""
1427
- // FIX
1428
- },
1429
- width: {
1430
- kind: "static",
1431
- type: "dimension",
1432
- value: "2px"
1433
- }
1434
- }
1435
- }
1436
- ]);
1437
- expectType2([
1438
- {
1439
- type: "transition",
1440
- kind: "ref",
1441
- referencedTokenId: "a.b"
1442
- },
1443
- {
1444
- type: "transition",
1445
- kind: "static",
1446
- value: {
1447
- delay: {
1448
- kind: "static",
1449
- type: "duration",
1450
- value: "1ms"
1451
- },
1452
- duration: {
1453
- kind: "ref",
1454
- type: "duration",
1455
- referencedTokenId: "animation.slow"
1456
- },
1457
- timingFunction: {
1458
- kind: "static",
1459
- type: "cubicBezier",
1460
- value: [0.4, 0, 0.2, 1]
1461
- }
1462
- }
1463
- }
1464
- ]);
1465
- function isTokenSrcValueInfoSingular(tokenSrcValueInfo) {
1466
- return isTokenTypeSingular(tokenSrcValueInfo?.type);
1467
- }
1468
- __name(isTokenSrcValueInfoSingular, "isTokenSrcValueInfoSingular");
1469
- __name2(isTokenSrcValueInfoSingular, "isTokenSrcValueInfoSingular");
1470
- function isTokenSrcValueInfoComposite(tokenSrcValueInfo) {
1471
- return isTokenTypeComposite(tokenSrcValueInfo?.type);
1472
- }
1473
- __name(isTokenSrcValueInfoComposite, "isTokenSrcValueInfoComposite");
1474
- __name2(isTokenSrcValueInfoComposite, "isTokenSrcValueInfoComposite");
1475
- expectType2([
1476
- {
1477
- type: "dimension",
1478
- kind: "static",
1479
- value: "1px"
1480
- },
1481
- {
1482
- type: "transition",
1483
- kind: "ref",
1484
- referencedTokenId: "a.b"
1485
- },
1486
- {
1487
- type: "transition",
1488
- kind: "ref",
1489
- // @ts-expect-error - with `kind: 'ref'`, `value` is not allowed
1490
- value: "1px"
1491
- },
1492
- {
1493
- kind: "ref",
1494
- type: "duration",
1495
- referencedTokenId: "animation.slow"
1496
- },
1497
- {
1498
- kind: "static",
1499
- type: "cubicBezier",
1500
- value: [0.4, 0, 0.2, 1]
1501
- },
1502
- {
1503
- type: "transition",
1504
- kind: "static",
1505
- value: {
1506
- delay: {
1507
- kind: "static",
1508
- type: "duration",
1509
- value: "1ms"
1510
- },
1511
- duration: {
1512
- kind: "ref",
1513
- type: "duration",
1514
- referencedTokenId: "animation.slow"
1515
- },
1516
- timingFunction: {
1517
- kind: "static",
1518
- type: "cubicBezier",
1519
- value: [0.4, 0, 0.2, 1]
1520
- }
1521
- }
1522
- }
1523
- ]);
1524
- function isTokenSrcExtensions(extensionsObj) {
1525
- return isObject3(extensionsObj) && isObjKey3("cloud.knapsack", extensionsObj);
1526
- }
1527
- __name(isTokenSrcExtensions, "isTokenSrcExtensions");
1528
- __name2(isTokenSrcExtensions, "isTokenSrcExtensions");
1529
- expectType3([
1530
- "#ddd",
1531
- true,
1532
- [83, 1, 1, 1],
1533
- {
1534
- color: "#000",
1535
- style: "solid",
1536
- width: "1px"
1537
- },
1538
- {
1539
- inset: true,
1540
- color: "#000",
1541
- offsetX: "0px",
1542
- offsetY: "{spacing.medium}",
1543
- spread: "0px",
1544
- blur: "0px"
1545
- },
1546
- {
1547
- timingFunction: "{timing.ease}",
1548
- duration: "{timing.duration.medium}",
1549
- delay: "7ms",
1550
- color: "#000"
1551
- }
1552
- ]);
1553
- function isTokenSrc(tokenObject) {
1554
- if (isObject3(tokenObject) && isObjKey3("$value", tokenObject)) return true;
1555
- return false;
1556
- }
1557
- __name(isTokenSrc, "isTokenSrc");
1558
- __name2(isTokenSrc, "isTokenSrc");
1559
- function isTokenGroup(tokenObject) {
1560
- return isObject3(tokenObject) && !isTokenSrcExtensions(tokenObject) && !isObjKey3("$value", tokenObject) && // ensuring we are not in `$extensions` object
1561
- !isObjKey3("cloud.knapsack", tokenObject);
1562
- }
1563
- __name(isTokenGroup, "isTokenGroup");
1564
- __name2(isTokenGroup, "isTokenGroup");
1565
- function isTokenTypeVarRef(tokenObject) {
1566
- if (isTokenGroup(tokenObject)) {
1567
- const varRefCollectionInfo = tokenObject.$extensions["cloud.knapsack"].group.collectionInfo;
1568
- if (isObjKey3("type", varRefCollectionInfo) && isObjKey3("referenceId", varRefCollectionInfo)) {
1569
- return true;
1570
- }
1571
- }
1572
- return false;
1573
- }
1574
- __name(isTokenTypeVarRef, "isTokenTypeVarRef");
1575
- __name2(isTokenTypeVarRef, "isTokenTypeVarRef");
1576
- function getPrimitiveValue(tokenValue) {
1577
- const type92 = typeof tokenValue;
1578
- if (type92 === "string" || type92 === "number" || type92 === "boolean") {
1579
- return type92;
1580
- }
1581
- throw new Error(
1582
- `Invalid token value type: ${JSON.stringify(
1583
- type92
1584
- )}. Token value is: ${JSON.stringify(tokenValue)}`
1585
- );
1586
- }
1587
- __name(getPrimitiveValue, "getPrimitiveValue");
1588
- __name2(getPrimitiveValue, "getPrimitiveValue");
1589
- function parseTokenDimensionValue(valueToParse) {
1590
- const { value, unit } = parseNumberWithUnit(valueToParse);
1591
- if (!unit) {
1592
- return { value };
1593
- }
1594
- if (unit !== "px" && unit !== "rem" && unit !== "em" && unit !== "%") {
1595
- throw new Error(`Invalid unit "${unit}" for value: ${value}`);
1596
- }
1597
- return { value, unit };
1598
- }
1599
- __name(parseTokenDimensionValue, "parseTokenDimensionValue");
1600
- __name2(parseTokenDimensionValue, "parseTokenDimensionValue");
1601
- function isSlottedTemplateDemo(slottedData) {
1602
- return isObject(slottedData) && slottedData.type === "template-demo";
1603
- }
1604
- __name(isSlottedTemplateDemo, "isSlottedTemplateDemo");
1605
- __name2(isSlottedTemplateDemo, "isSlottedTemplateDemo");
1606
- function isSlottedTemplateReference(slottedData) {
1607
- return isObject(slottedData) && slottedData.type === "template-reference";
1608
- }
1609
- __name(isSlottedTemplateReference, "isSlottedTemplateReference");
1610
- __name2(isSlottedTemplateReference, "isSlottedTemplateReference");
1611
- function isDataDemo(demo) {
1612
- return demo?.type === "data";
1613
- }
1614
- __name(isDataDemo, "isDataDemo");
1615
- __name2(isDataDemo, "isDataDemo");
1616
- function isTemplateDemo(demo) {
1617
- return demo?.type === "template";
1618
- }
1619
- __name(isTemplateDemo, "isTemplateDemo");
1620
- __name2(isTemplateDemo, "isTemplateDemo");
1621
- function isKsAppClientDataNoMeta(data) {
1622
- if (!isObject(data)) return false;
1623
- const requiredKeys = [
1624
- "assetSetsState",
1625
- "customPagesState",
1626
- "navsState",
1627
- "patternsState",
1628
- "tokensSrc",
1629
- "db"
1630
- ];
1631
- if (!requiredKeys.every((key) => isObjKey(key, data))) return false;
1632
- if (!isObjKey("metaState", data)) return true;
1633
- return false;
1634
- }
1635
- __name(isKsAppClientDataNoMeta, "isKsAppClientDataNoMeta");
1636
- __name2(isKsAppClientDataNoMeta, "isKsAppClientDataNoMeta");
1637
- var KsAppClientDataNoMetaStruct = define4(
1638
- "KsAppClientDataNoMeta",
1639
- isKsAppClientDataNoMeta
1640
- );
1641
- function isKsAppClientDataAndMeta(data) {
1642
- if (!isObject(data)) return false;
1643
- const requiredKeys = [
1644
- "assetSetsState",
1645
- "customPagesState",
1646
- "navsState",
1647
- "patternsState",
1648
- "tokensSrc",
1649
- "metaState",
1650
- "db"
1651
- ];
1652
- return requiredKeys.every((key) => isObjKey(key, data));
1653
- }
1654
- __name(isKsAppClientDataAndMeta, "isKsAppClientDataAndMeta");
1655
- __name2(isKsAppClientDataAndMeta, "isKsAppClientDataAndMeta");
1656
- var KsAppClientDataAndMetaStruct = define4(
1657
- "KsAppClientDataAndMeta",
1658
- isKsAppClientDataAndMeta
1659
- );
1660
- var KsMetaStateStruct = type6({
1661
- isLocalDev: boolean4(),
1662
- plugins: array4(
1663
- type6({
1664
- id: string4(),
1665
- hasContent: boolean4(),
1666
- clientPluginPath: optional5(string4()),
1667
- cssPath: optional5(string4())
1668
- })
1669
- ),
1670
- meta: optional5(
1671
- type6({
1672
- version: optional5(string4()),
1673
- hasKnapsackCloud: boolean4(),
1674
- knapsackCloudSiteId: optional5(string4()),
1675
- serverPort: optional5(number3()),
1676
- websocketsPort: optional5(number3()),
1677
- https: optional5(boolean4()),
1678
- cacheDir: optional5(string4()),
1679
- ksVersions: type6({
1680
- app: string4()
1681
- })
1682
- })
1683
- )
1684
- });
1685
- var isKsMetaState = KsMetaStateStruct.is;
1686
- function isKsAppClientDataNoMetaV3(data) {
1687
- if (!isObject(data)) return false;
1688
- const requiredKeys = [
1689
- "assetSetsState",
1690
- "customPagesState",
1691
- "navsState",
1692
- "patternsState",
1693
- "settingsState",
1694
- "tokensState"
1695
- ];
1696
- if (!requiredKeys.every((key) => isObjKey(key, data))) return false;
1697
- if (!isObjKey("metaState", data)) return true;
1698
- return false;
1699
- }
1700
- __name(isKsAppClientDataNoMetaV3, "isKsAppClientDataNoMetaV3");
1701
- __name2(isKsAppClientDataNoMetaV3, "isKsAppClientDataNoMetaV3");
1702
- var KsAppClientDataNoMetaStructV3 = define5(
1703
- "KsAppClientDataNoMeta",
1704
- isKsAppClientDataNoMetaV3
1705
- );
1706
- function isKsAppClientDataAndMetaV3(data) {
1707
- if (!isObject(data)) return false;
1708
- const requiredKeys = [
1709
- "assetSetsState",
1710
- "customPagesState",
1711
- "navsState",
1712
- "patternsState",
1713
- "settingsState",
1714
- "tokensState",
1715
- "metaState"
1716
- ];
1717
- return requiredKeys.every((key) => isObjKey(key, data));
1718
- }
1719
- __name(isKsAppClientDataAndMetaV3, "isKsAppClientDataAndMetaV3");
1720
- __name2(isKsAppClientDataAndMetaV3, "isKsAppClientDataAndMetaV3");
1721
- var KsAppClientDataAndMetaStructV3 = define5(
1722
- "KsAppClientDataAndMeta",
1723
- isKsAppClientDataAndMetaV3
1724
- );
1725
- var KsMetaStateStructV3 = type7({
1726
- isLocalDev: boolean5(),
1727
- plugins: array5(
1728
- type7({
1729
- id: string5(),
1730
- hasContent: boolean5(),
1731
- clientPluginPath: optional6(string5()),
1732
- cssPath: optional6(string5())
1733
- })
1734
- ),
1735
- meta: optional6(
1736
- type7({
1737
- version: optional6(string5()),
1738
- hasKnapsackCloud: boolean5(),
1739
- knapsackCloudSiteId: optional6(string5()),
1740
- serverPort: optional6(number4()),
1741
- websocketsPort: optional6(number4()),
1742
- https: optional6(boolean5()),
1743
- cacheDir: optional6(string5()),
1744
- ksVersions: type7({
1745
- app: string5()
1746
- })
1747
- })
1748
- )
1749
- });
1750
- var isKsMetaStateV3 = KsMetaStateStructV3.is;
1751
- var PatchStructRuntime = s3.object({
1752
- op: s3.union([s3.literal("replace"), s3.literal("remove"), s3.literal("add")]),
1753
- path: s3.array(s3.union([s3.string(), s3.number()])),
1754
- value: s3.optional(s3.any())
1755
- });
1756
- var PatchesStructRuntime = s3.array(PatchStructRuntime);
1757
- var KsRemoteChangeRuntime = s3.type({
1758
- patches: PatchesStructRuntime,
1759
- inversePatches: s3.optional(PatchesStructRuntime),
1760
- event: s3.optional(s3.object({ type: s3.string() })),
1761
- id: s3.string(),
1762
- date: s3.string(),
1763
- userId: s3.optional(s3.string())
1764
- });
1765
- var KsRemoteChangesStructRuntime = s3.array(KsRemoteChangeRuntime);
1766
- var plugins_exports = {};
1767
- __export(plugins_exports, {
1768
- ACTIONS: /* @__PURE__ */ __name(() => ACTIONS, "ACTIONS"),
1769
- endpoint: /* @__PURE__ */ __name(() => endpoint, "endpoint")
1770
- });
1771
- var endpoint = `/plugins`;
1772
- var ACTIONS = /* @__PURE__ */ ((ACTIONS3) => {
1773
- ACTIONS3["getContent"] = "getContent";
1774
- return ACTIONS3;
1775
- })(ACTIONS || {});
1776
- var files_exports = {};
1777
- __export(files_exports, {
1778
- ACTIONS: /* @__PURE__ */ __name(() => ACTIONS2, "ACTIONS"),
1779
- endpoint: /* @__PURE__ */ __name(() => endpoint2, "endpoint")
1780
- });
1781
- var endpoint2 = `/files`;
1782
- var ACTIONS2 = /* @__PURE__ */ ((ACTIONS3) => {
1783
- ACTIONS3["verify"] = "verify";
1784
- return ACTIONS3;
1785
- })(ACTIONS2 || {});
1786
- var rolesById = {
1787
- ADMIN: "ADMIN",
1788
- ANONYMOUS: "ANONYMOUS",
1789
- CONTRIBUTOR: "CONTRIBUTOR",
1790
- EDITOR: "EDITOR",
1791
- MANAGER: "MANAGER",
1792
- VIEWER: "VIEWER"
1793
- };
1794
- var roles = Object.values(rolesById);
1795
-
1796
- // src/users.ts
1797
- var RolesEnums = enums2(roles);
1798
- var RolesEnumsStruct = RolesEnums;
1799
- var canRoleAdmin = /* @__PURE__ */ __name((role) => role === "ADMIN", "canRoleAdmin");
1800
- var rolesThatCanManageUsers = ["ADMIN", "MANAGER"];
1801
- var canRoleManageUsers = /* @__PURE__ */ __name((role) => rolesThatCanManageUsers.includes(role), "canRoleManageUsers");
1802
- var rolesThatCanDelete = [
1803
- ...rolesThatCanManageUsers,
1804
- "EDITOR"
1805
- ];
1806
- var canRoleDelete = /* @__PURE__ */ __name((role) => rolesThatCanDelete.includes(role), "canRoleDelete");
1807
- var rolesThatCanEdit = [...rolesThatCanDelete, "CONTRIBUTOR"];
1808
- var canRoleEdit = /* @__PURE__ */ __name((role) => rolesThatCanEdit.includes(role), "canRoleEdit");
1809
- var rolesThatCanPublish = ["ADMIN"];
1810
- var canRolePublish = /* @__PURE__ */ __name((role) => rolesThatCanPublish.includes(role), "canRolePublish");
1811
- var rolesThatCanView = [...rolesThatCanEdit, "VIEWER"];
1812
- var canRoleView = /* @__PURE__ */ __name((role) => rolesThatCanView.includes(role), "canRoleView");
1813
- var isRoleValid = /* @__PURE__ */ __name((role) => RolesEnumsStruct.is(role), "isRoleValid");
1814
- var HasuraRoles = /* @__PURE__ */ ((HasuraRoles2) => {
1815
- HasuraRoles2["user"] = "user";
1816
- HasuraRoles2["anonymous"] = "anonymous";
1817
- return HasuraRoles2;
1818
- })(HasuraRoles || {});
1819
- var HasuraRolesStruct = enums2(Object.values(HasuraRoles));
1820
- var HasuraClaimsStruct = object4({
1821
- "x-hasura-allowed-roles": array7(HasuraRolesStruct),
1822
- "x-hasura-default-role": HasuraRolesStruct,
1823
- "x-hasura-user-id": optional8(string7())
1824
- });
1825
- var KsClaimsStruct = object4({
1826
- userId: string7(),
1827
- isSuperAdmin: boolean6(),
1828
- sitesByRole: record(RolesEnums, array7(string7()))
1829
- });
1830
- var JwtBaseStruct = type9({
1831
- exp: number6(),
1832
- email: optional8(string7()),
1833
- email_verified: optional8(union6([string7(), boolean6()])),
1834
- iat: number6(),
1835
- iss: string7(),
1836
- sub: string7(),
1837
- aud: union6([string7(), array7(string7())])
1838
- });
1839
- var HASURA_CLAIMS_NAMESPACE = "https://hasura.io/jwt/claims";
1840
- var KNAPSACK_CLAIMS_NAMESPACE = "https://knapsack.cloud";
1841
- var JwtCustomClaimsStruct = object4({
1842
- [HASURA_CLAIMS_NAMESPACE]: HasuraClaimsStruct,
1843
- [KNAPSACK_CLAIMS_NAMESPACE]: KsClaimsStruct
1844
- });
1845
- var JwtWithCustomClaimsStruct = assign2(
1846
- JwtBaseStruct,
1847
- JwtCustomClaimsStruct
1848
- );
1849
- function expandSitesByRole(sitesByRole) {
1850
- return Object.entries(sitesByRole).reduce((cur, [roleId, siteIds]) => {
1851
- if (!isRoleValid(roleId)) return cur;
1852
- siteIds.forEach((siteId) => {
1853
- cur[siteId] = roleId;
1854
- });
1855
- return cur;
1856
- }, {});
1857
- }
1858
- __name(expandSitesByRole, "expandSitesByRole");
1859
- var defaultAnonymousKsClaims = {
1860
- isSuperAdmin: false,
1861
- userId: "",
1862
- siteRoleMap: {},
1863
- getSiteRole: /* @__PURE__ */ __name(() => "ANONYMOUS", "getSiteRole")
1864
- };
1865
- var getKsClaims = /* @__PURE__ */ __name((claims) => {
1866
- if (!JwtWithCustomClaimsStruct.is(claims)) {
1867
- return defaultAnonymousKsClaims;
1868
- }
1869
- const { sitesByRole, ...ksClaims } = claims[KNAPSACK_CLAIMS_NAMESPACE];
1870
- const siteRoleMap = expandSitesByRole(sitesByRole);
1871
- return {
1872
- ...ksClaims,
1873
- siteRoleMap,
1874
- getSiteRole: /* @__PURE__ */ __name((siteId) => {
1875
- if (ksClaims.isSuperAdmin) return "ADMIN";
1876
- return siteRoleMap[siteId] || "ANONYMOUS";
1877
- }, "getSiteRole")
1878
- };
1879
- }, "getKsClaims");
1880
-
1881
- // src/webhooks.ts
1882
- init_esm_shims();
1883
- var siteDeployedWebhookEndpoint = "/site-deployed";
1884
- var gitHubOauthInternalEndpoint = "/github-auth";
1885
-
1886
- // src/ks-urls.ts
1887
- init_esm_shims();
1888
- import { isUrl } from "@knapsack/utils";
1889
- var { KS_DB_URL } = process.env;
1890
- if (KS_DB_URL && !isUrl(KS_DB_URL)) {
1891
- throw new Error(`KS_DB_URL is not a valid URL: '${KS_DB_URL}'`);
1892
- }
1893
- var dbUrl = KS_DB_URL || "https://db.knapsack.cloud";
1894
- var dbGqlEndpoint = new URL("/v1/graphql", dbUrl).toString();
1895
- var ksUrls = {
1896
- /**
1897
- * Base URL for Knapsack DB (Hasura)
1898
- * @default 'https://db.knapsack.cloud'
1899
- */
1900
- dbUrl,
1901
- /**
1902
- * App DB GraphQL endpoint for connecting to Hasura GraphQL.
1903
- * @default 'https://db.knapsack.cloud/v1/graphql'
1904
- */
1905
- dbGqlEndpoint
1906
- };
1907
-
1908
- // src/http-headers.ts
1909
- init_esm_shims();
1910
- var ksHttpHeaders = {
1911
- siteId: "X-KS-Site-ID",
1912
- instanceId: "X-KS-Instance-Id"
1913
- };
1914
- export {
1915
- HASURA_CLAIMS_NAMESPACE,
1916
- HasuraClaimsStruct,
1917
- HasuraRoles,
1918
- JwtBaseStruct,
1919
- JwtCustomClaimsStruct,
1920
- JwtWithCustomClaimsStruct,
1921
- KNAPSACK_CLAIMS_NAMESPACE,
1922
- KsClaimsStruct,
1923
- RolesEnums,
1924
- RolesEnumsStruct,
1925
- canRoleAdmin,
1926
- canRoleDelete,
1927
- canRoleEdit,
1928
- canRoleManageUsers,
1929
- canRolePublish,
1930
- canRoleView,
1931
- defaultAnonymousKsClaims,
1932
- expandSitesByRole,
1933
- getKsClaims,
1934
- gitHubOauthInternalEndpoint,
1935
- isRoleValid,
1936
- ksHttpHeaders,
1937
- ksUrls,
1938
- rolesThatCanDelete,
1939
- rolesThatCanEdit,
1940
- rolesThatCanManageUsers,
1941
- rolesThatCanPublish,
1942
- rolesThatCanView,
1943
- siteDeployedWebhookEndpoint
1944
- };
7
+ export { On as HASURA_CLAIMS_NAMESPACE, In as HasuraClaimsStruct, Kt as HasuraRoles, Rn as JwtBaseStruct, Mn as JwtCustomClaimsStruct, Fn as JwtWithCustomClaimsStruct, Bt as KNAPSACK_CLAIMS_NAMESPACE, Pn as KsClaimsStruct, Ot as RolesEnums, En as RolesEnumsStruct, Ya as canRoleAdmin, Za as canRoleDelete, ei as canRoleEdit, Qa as canRoleManageUsers, ti as canRolePublish, ri as canRoleView, Kn as defaultAnonymousKsClaims, zn as expandSitesByRole, ni as getKsClaims, oi as gitHubOauthInternalEndpoint, Vn as isRoleValid, pi as ksHttpHeaders, ci as ksUrls, Ft as rolesThatCanDelete, zt as rolesThatCanEdit, Mt as rolesThatCanManageUsers, Dn as rolesThatCanPublish, Nn as rolesThatCanView, si as siteDeployedWebhookEndpoint };
8
+ //# sourceMappingURL=index.mjs.map
1945
9
  //# sourceMappingURL=index.mjs.map