@briklab/lib 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,19 +4,46 @@
4
4
  * Runtime JS Type Checker
5
5
  * @module JSTC
6
6
  */
7
+ /**
8
+ * # Primitive Type
9
+ */
7
10
  type PrimitiveType = "string" | "number" | "boolean" | "object" | "function" | "undefined" | "symbol" | "bigint";
11
+ /**
12
+ * JS constructor type
13
+ */
8
14
  type ConstructorType = Function;
15
+ /**
16
+ * # JSType
17
+ * A Valid Javascript Type
18
+ */
9
19
  export type JSType = PrimitiveType | ConstructorType | string;
20
+ /**
21
+ * # JSType
22
+ * A Valid JavaScript Type or a Valid JavaScript Type Array
23
+ */
10
24
  export type JSTypeOrArray = JSType | JSType[];
25
+ /**
26
+ * # JSTypeChecker
27
+ * A JS Type Checker. Add type checking to your javascript files as well
28
+ */
11
29
  export declare class JSTypeChecker {
12
30
  #private;
13
31
  /**
32
+ * ### JSTypeChecker.for
14
33
  * check if specific arguments are of a specific type, class, etc.
15
34
  * @param {unknown[]} args
16
35
  */
17
36
  for(args: unknown[]): {
37
+ /**
38
+ * ### JSTypeChecker.for().check
39
+ * Check the given arguments with corresponding given types
40
+ */
18
41
  check: (types: JSTypeOrArray[]) => boolean;
19
42
  };
43
+ /**
44
+ * ### JSTypeChecker.addCustomHandler
45
+ * Create a custom handler for checking types.
46
+ */
20
47
  addCustomHandler(name: string, handler: (value: unknown) => boolean): void;
21
48
  }
22
49
  declare const JSTC: JSTypeChecker;
@@ -1,8 +1,6 @@
1
- var c=function(n,t,r,e){if(r==="a"&&!e)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!e:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?e:r==="a"?e.call(n):e?e.value:t.get(n)},s,u=class{constructor(){s.set(this,{Array:t=>Array.isArray(t),"string[]":t=>Array.isArray(t)&&t.every(r=>typeof r=="string")})}for(t){return Array.isArray(t)||(console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!
1
+ var c=function(n,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(n):r?r.value:t.get(n)},i,u=class{constructor(){i.set(this,{Array:t=>Array.isArray(t),"string[]":t=>Array.isArray(t)&&t.every(e=>typeof e=="string")})}for(t){return Array.isArray(t)||(console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!
2
2
  Hint: The first argument must be a array.
3
- Using [givenValue] as fallback`),t=[t]),{check:r=>{if(Array.isArray(r)||(console.warn(`[JSTC.for().check] @briklab/lib/jstc: Invalid first argument!
4
- Hint: The first argument must be a valid array!
5
- Using [givenValue] as fallback`),r=[r]),t.length<r.length)return!1;for(let e=0;e<r.length;e++){let o=t[e],f=r[e],b=Array.isArray(f)?f:[f],i=!1;for(let l of b){let d=typeof l=="string"?l.split("|"):[l];for(let a of d)if(typeof a=="function"){if(o instanceof a){i=!0;break}}else if(typeof a=="string"&&c(this,s,"f")[a]){if(c(this,s,"f")[a](o)){i=!0;break}}else if(typeof o===a){i=!0;break}if(i)break}if(!i)return!1}return!0}}}addCustomHandler(t,r){typeof t=="string"&&typeof r=="function"||(console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!
3
+ Using [givenValue] as fallback`),t=[t]),{check:e=>{if(t.length<e.length)return!1;for(let r=0;r<e.length;r++){let o=t[r],f=e[r],y=Array.isArray(f)?f:[f],s=!1;for(let l of y){let d=typeof l=="string"?l.split("|"):[l];for(let a of d)if(typeof a=="function"){if(o instanceof a){s=!0;break}}else if(typeof a=="string"&&c(this,i,"f")[a]){if(c(this,i,"f")[a](o)){s=!0;break}}else if(typeof o===a){s=!0;break}if(s)break}if(!s)return!1}return!0}}}addCustomHandler(t,e){typeof t=="string"&&typeof e=="function"||(console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!
6
4
  Hint: The first argument must be a string, and the second argument must be a function
7
- Using String(argument1) and ()=>false as fallbacks`),t=String(t),r=()=>!1),c(this,s,"f")[t]=r}};s=new WeakMap;var g=new u,y=g;export{u as JSTypeChecker,y as default};
5
+ Using String(argument1) and ()=>false as fallbacks`),t=String(t),e=()=>!1),c(this,i,"f")[t]=e}};i=new WeakMap;var g=new u,b=g;export{u as JSTypeChecker,b as default};
8
6
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js"],
4
- "sourcesContent": ["/**\n * # JSTC\n * @packageDocumentation\n * Runtime JS Type Checker\n * @module JSTC\n */\nvar __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar _JSTypeChecker___CustomHandler;\nexport class JSTypeChecker {\n constructor() {\n _JSTypeChecker___CustomHandler.set(this, {\n Array: (value) => Array.isArray(value),\n \"string[]\": (value) => Array.isArray(value) && value.every((v) => typeof v === \"string\"),\n });\n }\n /**\n * check if specific arguments are of a specific type, class, etc.\n * @param {unknown[]} args\n */\n for(args) {\n if (!Array.isArray(args)) {\n console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!\r\n Hint: The first argument must be a array.\r\n Using [givenValue] as fallback`);\n args = [args];\n }\n return {\n check: (types) => {\n if (!Array.isArray(types)) {\n console.warn(`[JSTC.for().check] @briklab/lib/jstc: Invalid first argument!\r\n Hint: The first argument must be a valid array!\r\n Using [givenValue] as fallback`);\n types = [types];\n }\n if (args.length < types.length)\n return false;\n for (let i = 0; i < types.length; i++) {\n const value = args[i];\n const expected = types[i];\n const expectedTypes = Array.isArray(expected) ? expected : [expected];\n let matched = false;\n for (const tRaw of expectedTypes) {\n const unionTypes = typeof tRaw === \"string\" ? tRaw.split(\"|\") : [tRaw];\n for (const t of unionTypes) {\n if (typeof t === \"function\") {\n if (value instanceof t) {\n matched = true;\n break;\n }\n }\n else if (typeof t === \"string\" && __classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[t]) {\n if (__classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[t](value)) {\n matched = true;\n break;\n }\n }\n else if (typeof value === t) {\n matched = true;\n break;\n }\n }\n if (matched)\n break;\n }\n if (!matched)\n return false;\n }\n return true;\n },\n };\n }\n addCustomHandler(name, handler) {\n if (!(typeof name === \"string\" && typeof handler === \"function\")) {\n console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!\r\n Hint: The first argument must be a string, and the second argument must be a function\r\n Using String(argument1) and ()=>false as fallbacks`);\n name = String(name);\n handler = () => false;\n }\n __classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[name] = handler;\n }\n}\n_JSTypeChecker___CustomHandler = new WeakMap();\nconst JSTC = new JSTypeChecker();\nexport default JSTC;\n"],
5
- "mappings": "AAMA,IAAIA,EAAkE,SAAUC,EAAUC,EAAOC,EAAMC,EAAG,CACtG,GAAID,IAAS,KAAO,CAACC,EAAG,MAAM,IAAI,UAAU,+CAA+C,EAC3F,GAAI,OAAOF,GAAU,WAAaD,IAAaC,GAAS,CAACE,EAAI,CAACF,EAAM,IAAID,CAAQ,EAAG,MAAM,IAAI,UAAU,0EAA0E,EACjL,OAAOE,IAAS,IAAMC,EAAID,IAAS,IAAMC,EAAE,KAAKH,CAAQ,EAAIG,EAAIA,EAAE,MAAQF,EAAM,IAAID,CAAQ,CAChG,EACII,EACSC,EAAN,KAAoB,CACvB,aAAc,CACVD,EAA+B,IAAI,KAAM,CACrC,MAAQE,GAAU,MAAM,QAAQA,CAAK,EACrC,WAAaA,GAAU,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAOC,GAAM,OAAOA,GAAM,QAAQ,CAC3F,CAAC,CACL,CAKA,IAAIC,EAAM,CACN,OAAK,MAAM,QAAQA,CAAI,IACnB,QAAQ,KAAK;AAAA;AAAA,uCAEc,EAC3BA,EAAO,CAACA,CAAI,GAET,CACH,MAAQC,GAAU,CAOd,GANK,MAAM,QAAQA,CAAK,IACpB,QAAQ,KAAK;AAAA;AAAA,2CAEU,EACvBA,EAAQ,CAACA,CAAK,GAEdD,EAAK,OAASC,EAAM,OACpB,MAAO,GACX,QAASC,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAAK,CACnC,IAAMJ,EAAQE,EAAKE,CAAC,EACdC,EAAWF,EAAMC,CAAC,EAClBE,EAAgB,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,EAChEE,EAAU,GACd,QAAWC,KAAQF,EAAe,CAC9B,IAAMG,EAAa,OAAOD,GAAS,SAAWA,EAAK,MAAM,GAAG,EAAI,CAACA,CAAI,EACrE,QAAWE,KAAKD,EACZ,GAAI,OAAOC,GAAM,YACb,GAAIV,aAAiBU,EAAG,CACpBH,EAAU,GACV,KACJ,UAEK,OAAOG,GAAM,UAAYjB,EAAuB,KAAMK,EAAgC,GAAG,EAAEY,CAAC,GACjG,GAAIjB,EAAuB,KAAMK,EAAgC,GAAG,EAAEY,CAAC,EAAEV,CAAK,EAAG,CAC7EO,EAAU,GACV,KACJ,UAEK,OAAOP,IAAUU,EAAG,CACzBH,EAAU,GACV,KACJ,CAEJ,GAAIA,EACA,KACR,CACA,GAAI,CAACA,EACD,MAAO,EACf,CACA,MAAO,EACX,CACJ,CACJ,CACA,iBAAiBI,EAAMC,EAAS,CACtB,OAAOD,GAAS,UAAY,OAAOC,GAAY,aACjD,QAAQ,KAAK;AAAA;AAAA,2DAEkC,EAC/CD,EAAO,OAAOA,CAAI,EAClBC,EAAU,IAAM,IAEpBnB,EAAuB,KAAMK,EAAgC,GAAG,EAAEa,CAAI,EAAIC,CAC9E,CACJ,EACAd,EAAiC,IAAI,QACrC,IAAMe,EAAO,IAAId,EACVe,EAAQD",
4
+ "sourcesContent": ["/**\n * # JSTC\n * @packageDocumentation\n * Runtime JS Type Checker\n * @module JSTC\n */\nvar __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar _JSTypeChecker___CustomHandler;\n/**\n * # JSTypeChecker\n * A JS Type Checker. Add type checking to your javascript files as well\n */\nexport class JSTypeChecker {\n constructor() {\n _JSTypeChecker___CustomHandler.set(this, {\n Array: (value) => Array.isArray(value),\n \"string[]\": (value) => Array.isArray(value) && value.every((v) => typeof v === \"string\"),\n });\n }\n /**\n * ### JSTypeChecker.for\n * check if specific arguments are of a specific type, class, etc.\n * @param {unknown[]} args\n */\n for(args) {\n if (!Array.isArray(args)) {\n console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!\r\n Hint: The first argument must be a array.\r\n Using [givenValue] as fallback`);\n args = [args];\n }\n return {\n /**\n * ### JSTypeChecker.for().check\n * Check the given arguments with corresponding given types\n */\n check: (types) => {\n if (args.length < types.length)\n return false;\n for (let i = 0; i < types.length; i++) {\n const value = args[i];\n const expected = types[i];\n const expectedTypes = Array.isArray(expected) ? expected : [expected];\n let matched = false;\n for (const tRaw of expectedTypes) {\n const unionTypes = typeof tRaw === \"string\" ? tRaw.split(\"|\") : [tRaw];\n for (const t of unionTypes) {\n if (typeof t === \"function\") {\n if (value instanceof t) {\n matched = true;\n break;\n }\n }\n else if (typeof t === \"string\" && __classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[t]) {\n if (__classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[t](value)) {\n matched = true;\n break;\n }\n }\n else if (typeof value === t) {\n matched = true;\n break;\n }\n }\n if (matched)\n break;\n }\n if (!matched)\n return false;\n }\n return true;\n },\n };\n }\n /**\n * ### JSTypeChecker.addCustomHandler\n * Create a custom handler for checking types.\n */\n addCustomHandler(name, handler) {\n if (!(typeof name === \"string\" && typeof handler === \"function\")) {\n console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!\r\n Hint: The first argument must be a string, and the second argument must be a function\r\n Using String(argument1) and ()=>false as fallbacks`);\n name = String(name);\n handler = () => false;\n }\n __classPrivateFieldGet(this, _JSTypeChecker___CustomHandler, \"f\")[name] = handler;\n }\n}\n_JSTypeChecker___CustomHandler = new WeakMap();\nconst JSTC = new JSTypeChecker();\nexport default JSTC;\n"],
5
+ "mappings": "AAMA,IAAIA,EAAkE,SAAUC,EAAUC,EAAOC,EAAMC,EAAG,CACtG,GAAID,IAAS,KAAO,CAACC,EAAG,MAAM,IAAI,UAAU,+CAA+C,EAC3F,GAAI,OAAOF,GAAU,WAAaD,IAAaC,GAAS,CAACE,EAAI,CAACF,EAAM,IAAID,CAAQ,EAAG,MAAM,IAAI,UAAU,0EAA0E,EACjL,OAAOE,IAAS,IAAMC,EAAID,IAAS,IAAMC,EAAE,KAAKH,CAAQ,EAAIG,EAAIA,EAAE,MAAQF,EAAM,IAAID,CAAQ,CAChG,EACII,EAKSC,EAAN,KAAoB,CACvB,aAAc,CACVD,EAA+B,IAAI,KAAM,CACrC,MAAQE,GAAU,MAAM,QAAQA,CAAK,EACrC,WAAaA,GAAU,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAOC,GAAM,OAAOA,GAAM,QAAQ,CAC3F,CAAC,CACL,CAMA,IAAIC,EAAM,CACN,OAAK,MAAM,QAAQA,CAAI,IACnB,QAAQ,KAAK;AAAA;AAAA,uCAEc,EAC3BA,EAAO,CAACA,CAAI,GAET,CAKH,MAAQC,GAAU,CACd,GAAID,EAAK,OAASC,EAAM,OACpB,MAAO,GACX,QAASC,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAAK,CACnC,IAAMJ,EAAQE,EAAKE,CAAC,EACdC,EAAWF,EAAMC,CAAC,EAClBE,EAAgB,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,EAChEE,EAAU,GACd,QAAWC,KAAQF,EAAe,CAC9B,IAAMG,EAAa,OAAOD,GAAS,SAAWA,EAAK,MAAM,GAAG,EAAI,CAACA,CAAI,EACrE,QAAWE,KAAKD,EACZ,GAAI,OAAOC,GAAM,YACb,GAAIV,aAAiBU,EAAG,CACpBH,EAAU,GACV,KACJ,UAEK,OAAOG,GAAM,UAAYjB,EAAuB,KAAMK,EAAgC,GAAG,EAAEY,CAAC,GACjG,GAAIjB,EAAuB,KAAMK,EAAgC,GAAG,EAAEY,CAAC,EAAEV,CAAK,EAAG,CAC7EO,EAAU,GACV,KACJ,UAEK,OAAOP,IAAUU,EAAG,CACzBH,EAAU,GACV,KACJ,CAEJ,GAAIA,EACA,KACR,CACA,GAAI,CAACA,EACD,MAAO,EACf,CACA,MAAO,EACX,CACJ,CACJ,CAKA,iBAAiBI,EAAMC,EAAS,CACtB,OAAOD,GAAS,UAAY,OAAOC,GAAY,aACjD,QAAQ,KAAK;AAAA;AAAA,2DAEkC,EAC/CD,EAAO,OAAOA,CAAI,EAClBC,EAAU,IAAM,IAEpBnB,EAAuB,KAAMK,EAAgC,GAAG,EAAEa,CAAI,EAAIC,CAC9E,CACJ,EACAd,EAAiC,IAAI,QACrC,IAAMe,EAAO,IAAId,EACVe,EAAQD",
6
6
  "names": ["__classPrivateFieldGet", "receiver", "state", "kind", "f", "_JSTypeChecker___CustomHandler", "JSTypeChecker", "value", "v", "args", "types", "i", "expected", "expectedTypes", "matched", "tRaw", "unionTypes", "t", "name", "handler", "JSTC", "index_default"]
7
7
  }
@@ -11,9 +11,7 @@ var gt=Object.create;var Ke=Object.defineProperty;var mt=Object.getOwnPropertyDe
11
11
  `),Ve=He.length,Ue=He.pop().length+1,ne=new Error(dt+" (line "+Ve+", char "+Ue+")");throw ne.line=Ve,ne.char=Ue,ne.styleSheet=S,ne},y;y=e.charAt(t);t++)switch(y){case" ":case" ":case"\r":case`
12
12
  `:case"\f":o[r]&&(s+=y);break;case'"':n=t+1;do n=e.indexOf('"',n)+1,n||X('Unmatched "');while(e[n-2]==="\\");switch(s+=e.slice(t,n),t=n-1,r){case"before-value":r="value";break;case"importRule-begin":r="importRule";break}break;case"'":n=t+1;do n=e.indexOf("'",n)+1,n||X("Unmatched '");while(e[n-2]==="\\");switch(s+=e.slice(t,n),t=n-1,r){case"before-value":r="value";break;case"importRule-begin":r="importRule";break}break;case"/":e.charAt(t+1)==="*"?(t+=2,n=e.indexOf("*/",t),n===-1?X("Missing */"):t=n+1):s+=y,r==="importRule-begin"&&(s+=" ",r="importRule");break;case"@":if(e.indexOf("@-moz-document",t)===t){r="documentRule-begin",K=new c.CSSDocumentRule,K.__starts=t,t+=13,s="";break}else if(e.indexOf("@media",t)===t){r="atBlock",B=new c.CSSMediaRule,B.__starts=t,t+=5,s="";break}else if(e.indexOf("@supports",t)===t){r="conditionBlock",J=new c.CSSSupportsRule,J.__starts=t,t+=8,s="";break}else if(e.indexOf("@host",t)===t){r="hostRule-begin",t+=4,re=new c.CSSHostRule,re.__starts=t,s="";break}else if(e.indexOf("@import",t)===t){r="importRule-begin",t+=6,s+="@import";break}else if(e.indexOf("@font-face",t)===t){r="fontFaceRule-begin",t+=9,Z=new c.CSSFontFaceRule,Z.__starts=t,s="";break}else{Fe.lastIndex=t;var ie=Fe.exec(e);if(ie&&ie.index===t){r="keyframesRule-begin",H=new c.CSSKeyframesRule,H.__starts=t,H._vendorPrefix=ie[1],t+=ie[0].length-1,s="";break}else r==="selector"&&(r="atRule")}s+=y;break;case"{":r==="selector"||r==="atRule"?(R.selectorText=s.trim(),R.style.__starts=t,s="",r="before-name"):r==="atBlock"?(B.media.mediaText=s.trim(),a&&x.push(a),u=a=B,B.parentStyleSheet=S,s="",r="before-selector"):r==="conditionBlock"?(J.conditionText=s.trim(),a&&x.push(a),u=a=J,J.parentStyleSheet=S,s="",r="before-selector"):r==="hostRule-begin"?(a&&x.push(a),u=a=re,re.parentStyleSheet=S,s="",r="before-selector"):r==="fontFaceRule-begin"?(a&&(Z.parentRule=a),Z.parentStyleSheet=S,R=Z,s="",r="before-name"):r==="keyframesRule-begin"?(H.name=s.trim(),a&&(x.push(a),H.parentRule=a),H.parentStyleSheet=S,u=a=H,s="",r="keyframeRule-begin"):r==="keyframeRule-begin"?(R=new c.CSSKeyframeRule,R.keyText=s.trim(),R.__starts=t,s="",r="before-name"):r==="documentRule-begin"&&(K.matcher.matcherText=s.trim(),a&&(x.push(a),K.parentRule=a),u=a=K,K.parentStyleSheet=S,s="",r="before-selector");break;case":":r==="name"?(ve=s.trim(),s="",r="before-value"):s+=y;break;case"(":if(r==="value")if(s.trim()==="expression"){var se=new c.CSSValueExpression(e,t).parse();se.error?X(se.error):(s+=se.expression,t=se.idx)}else r="value-parenthesis",l=1,s+=y;else r==="value-parenthesis"&&l++,s+=y;break;case")":r==="value-parenthesis"&&(l--,l===0&&(r="value")),s+=y;break;case"!":r==="value"&&e.indexOf("!important",t)===t?(W="important",t+=9):s+=y;break;case";":switch(r){case"value":R.style.setProperty(ve,s.trim(),W),W="",s="",r="before-name";break;case"atRule":s="",r="before-selector";break;case"importRule":Y=new c.CSSImportRule,Y.parentStyleSheet=Y.styleSheet.parentStyleSheet=S,Y.cssText=s+y,S.cssRules.push(Y),s="",r="before-selector";break;default:s+=y;break}break;case"}":switch(r){case"value":R.style.setProperty(ve,s.trim(),W),W="";case"before-name":case"name":R.__ends=t+1,a&&(R.parentRule=a),R.parentStyleSheet=S,u.cssRules.push(R),s="",u.constructor===c.CSSKeyframesRule?r="keyframeRule-begin":r="before-selector";break;case"keyframeRule-begin":case"before-selector":case"selector":for(a||X("Unexpected }"),D=x.length>0;x.length>0;){if(a=x.pop(),a.constructor.name==="CSSMediaRule"||a.constructor.name==="CSSSupportsRule"){Ae=u,u=a,u.cssRules.push(Ae);break}x.length===0&&(D=!1)}D||(u.__ends=t+1,S.cssRules.push(u),u=S,a=null),s="",r="before-selector";break}break;default:switch(r){case"before-selector":r="selector",R=new c.CSSStyleRule,R.__starts=t;break;case"before-name":r="name";break;case"before-value":r="value";break;case"importRule-begin":r="importRule";break}s+=y;break}return S};at.parse=c.parse;c.CSSStyleSheet=ee().CSSStyleSheet;c.CSSStyleRule=Q().CSSStyleRule;c.CSSImportRule=ke().CSSImportRule;c.CSSGroupingRule=U().CSSGroupingRule;c.CSSMediaRule=Se().CSSMediaRule;c.CSSConditionRule=N().CSSConditionRule;c.CSSSupportsRule=ue().CSSSupportsRule;c.CSSFontFaceRule=Te().CSSFontFaceRule;c.CSSHostRule=Me().CSSHostRule;c.CSSStyleDeclaration=V().CSSStyleDeclaration;c.CSSKeyframeRule=ce().CSSKeyframeRule;c.CSSKeyframesRule=he().CSSKeyframesRule;c.CSSValueExpression=Ie().CSSValueExpression;c.CSSDocumentRule=$e().CSSDocumentRule});var V=h(St=>{var G={};G.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}};G.CSSStyleDeclaration.prototype={constructor:G.CSSStyleDeclaration,getPropertyValue:function(i){return this[i]||""},setProperty:function(i,e,t){if(this[i]){var r=Array.prototype.indexOf.call(this,i);r<0&&(this[this.length]=i,this.length++)}else this[this.length]=i,this.length++;this[i]=e+"",this._importants[i]=t},removeProperty:function(i){if(!(i in this))return"";var e=Array.prototype.indexOf.call(this,i);if(e<0)return"";var t=this[i];return this[i]="",Array.prototype.splice.call(this,e,1),t},getPropertyCSSValue:function(){},getPropertyPriority:function(i){return this._importants[i]||""},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var i=[],e=0,t=this.length;e<t;++e){var r=this[e],n=this.getPropertyValue(r),s=this.getPropertyPriority(r);s&&(s=" !"+s),i[e]=r+": "+n+s+";"}return i.join(" ")},set cssText(i){var e,t;for(e=this.length;e--;)t=this[e],this[t]="";Array.prototype.splice.call(this,0,this.length),this._importants={};var r=G.parse("#bogus{"+i+"}").cssRules[0].style,n=r.length;for(e=0;e<n;++e)t=r[e],this.setProperty(r[e],r.getPropertyValue(t),r.getPropertyPriority(t))}};St.CSSStyleDeclaration=G.CSSStyleDeclaration;G.parse=le().parse});var ct=h(ut=>{var Ce={CSSStyleSheet:ee().CSSStyleSheet,CSSRule:d().CSSRule,CSSStyleRule:Q().CSSStyleRule,CSSGroupingRule:U().CSSGroupingRule,CSSConditionRule:N().CSSConditionRule,CSSMediaRule:Se().CSSMediaRule,CSSSupportsRule:ue().CSSSupportsRule,CSSStyleDeclaration:V().CSSStyleDeclaration,CSSKeyframeRule:ce().CSSKeyframeRule,CSSKeyframesRule:he().CSSKeyframesRule};Ce.clone=function i(e){var t=new Ce.CSSStyleSheet,r=e.cssRules;if(!r)return t;for(var n=0,s=r.length;n<s;n++){var l=r[n],o=t.cssRules[n]=new l.constructor,S=l.style;if(S){for(var u=o.style=new Ce.CSSStyleDeclaration,a=0,x=S.length;a<x;a++){var D=u[a]=S[a];u[D]=S[D],u._importants[D]=S.getPropertyPriority(D)}u.length=S.length}l.hasOwnProperty("keyText")&&(o.keyText=l.keyText),l.hasOwnProperty("selectorText")&&(o.selectorText=l.selectorText),l.hasOwnProperty("mediaText")&&(o.mediaText=l.mediaText),l.hasOwnProperty("conditionText")&&(o.conditionText=l.conditionText),l.hasOwnProperty("cssRules")&&(o.cssRules=i(l).cssRules)}return t};ut.clone=Ce.clone});var ht=h(p=>{"use strict";p.CSSStyleDeclaration=V().CSSStyleDeclaration;p.CSSRule=d().CSSRule;p.CSSGroupingRule=U().CSSGroupingRule;p.CSSConditionRule=N().CSSConditionRule;p.CSSStyleRule=Q().CSSStyleRule;p.MediaList=ae().MediaList;p.CSSMediaRule=Se().CSSMediaRule;p.CSSSupportsRule=ue().CSSSupportsRule;p.CSSImportRule=ke().CSSImportRule;p.CSSFontFaceRule=Te().CSSFontFaceRule;p.CSSHostRule=Me().CSSHostRule;p.StyleSheet=_e().StyleSheet;p.CSSStyleSheet=ee().CSSStyleSheet;p.CSSKeyframesRule=he().CSSKeyframesRule;p.CSSKeyframeRule=ce().CSSKeyframeRule;p.MatcherList=Oe().MatcherList;p.CSSDocumentRule=$e().CSSDocumentRule;p.CSSValue=Ee().CSSValue;p.CSSValueExpression=Ie().CSSValueExpression;p.parse=le().parse;p.clone=ct().clone});var xe=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},z,we=class{constructor(){z.set(this,{Array:e=>Array.isArray(e),"string[]":e=>Array.isArray(e)&&e.every(t=>typeof t=="string")})}for(e){return Array.isArray(e)||(console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!
13
13
  Hint: The first argument must be a array.
14
- Using [givenValue] as fallback`),e=[e]),{check:t=>{if(Array.isArray(t)||(console.warn(`[JSTC.for().check] @briklab/lib/jstc: Invalid first argument!
15
- Hint: The first argument must be a valid array!
16
- Using [givenValue] as fallback`),t=[t]),e.length<t.length)return!1;for(let r=0;r<t.length;r++){let n=e[r],s=t[r],l=Array.isArray(s)?s:[s],o=!1;for(let S of l){let u=typeof S=="string"?S.split("|"):[S];for(let a of u)if(typeof a=="function"){if(n instanceof a){o=!0;break}}else if(typeof a=="string"&&xe(this,z,"f")[a]){if(xe(this,z,"f")[a](n)){o=!0;break}}else if(typeof n===a){o=!0;break}if(o)break}if(!o)return!1}return!0}}}addCustomHandler(e,t){typeof e=="string"&&typeof t=="function"||(console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!
14
+ Using [givenValue] as fallback`),e=[e]),{check:t=>{if(e.length<t.length)return!1;for(let r=0;r<t.length;r++){let n=e[r],s=t[r],l=Array.isArray(s)?s:[s],o=!1;for(let S of l){let u=typeof S=="string"?S.split("|"):[S];for(let a of u)if(typeof a=="function"){if(n instanceof a){o=!0;break}}else if(typeof a=="string"&&xe(this,z,"f")[a]){if(xe(this,z,"f")[a](n)){o=!0;break}}else if(typeof n===a){o=!0;break}if(o)break}if(!o)return!1}return!0}}}addCustomHandler(e,t){typeof e=="string"&&typeof t=="function"||(console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!
17
15
  Hint: The first argument must be a string, and the second argument must be a function
18
16
  Using String(argument1) and ()=>false as fallbacks`),e=String(e),t=()=>!1),xe(this,z,"f")[e]=t}};z=new WeakMap;var kt=new we,O=kt;var De=_t(ht(),1);var m=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},C,qe,Re,ye,ft,Pe,Le,pt={red:"#ff0000",blue:"#0000ff",green:"#00ff00",yellow:"#ffff00",orange:"#ffa500",black:"#000000",white:"#ffffff",gray:"#808080"},j=class i{constructor(e){if(C.add(this),this.r=0,this.g=0,this.b=0,this.a=1,typeof e=="string")m(this,C,"m",ft).call(this,e);else if("r"in e&&"g"in e&&"b"in e)this.r=m(this,C,"m",Re).call(this,e.r),this.g=m(this,C,"m",Re).call(this,e.g),this.b=m(this,C,"m",Re).call(this,e.b),this.a=e.a??1;else if("h"in e&&"s"in e&&"l"in e){let{r:t,g:r,b:n}=m(this,C,"m",Pe).call(this,e.h,e.s,e.l);this.r=t,this.g=r,this.b=n,this.a=e.a??1}else console.warn(`[Color.constructor] Invalid first argument!
19
17
  Hint: The first argument must be a valid color array