commit a65d4877ad7d309627808a169818f1add8c278ae Author: StableStudio Date: Fri May 12 10:36:19 2023 -0500 Initial commit diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..0bdfd1d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,67 @@ +{ + "root": true, + + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "ecmaFeatures": { "jsx": true }, + "sourceType": "module", + "project": "./tsconfig.json", + "extraFileExtensions": [".md"] + }, + + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:prettier/recommended", + "plugin:markdown/recommended" + ], + + "plugins": ["react", "react-hooks", "import"], + "settings": { "react": { "version": "detect" } }, + + "rules": { + "prettier/prettier": ["error", {}, { "usePrettierrc": true }], + + "react/react-in-jsx-scope": "off", + "react/jsx-no-undef": "off", + "react/prop-types": "off", + "react-hooks/rules-of-hooks": "off", + "react/no-unknown-property": ["error", { "ignore": ["css"] }], + "react/display-name": "off", + + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" } + ], + + "no-unused-vars": [ + "error", + { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" } + ], + + "import/order": [ + "error", + { + "newlines-between": "always-and-inside-groups", + "alphabetize": { "order": "asc", "caseInsensitive": true }, + + "groups": ["builtin", "external", "parent", "index", "sibling"], + "pathGroups": [ + { "pattern": "~/**", "group": "external" }, + { "pattern": ".", "group": "sibling" } + ] + } + ], + + "sort-imports": [ + "error", + { + "ignoreCase": true, + "ignoreDeclarationSort": true + } + ] + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6abb642 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.DS_Store +.idea +*.iml + +node_modules + +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/.husky/common.sh b/.husky/common.sh new file mode 100644 index 0000000..1487014 --- /dev/null +++ b/.husky/common.sh @@ -0,0 +1,8 @@ +command_exists () { + command -v "$1" >/dev/null 2>&1 +} + +# Windows 10, Git Bash and Yarn workaround +if command_exists winpty && test -t 1; then + exec < /dev/tty +fi \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000..1c2b953 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,12 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" +. "$(dirname "$0")/common.sh" + +# Ensure the entire project still compiles +blue=$(tput setaf 4) +normal=$(tput sgr0) +printf "%b" "${blue}Type checking... ${normal}" +yarn stablestudio-ui build:types + +# Run the lint-staged job in the root package.json +yarn lint-staged diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..168d9d2 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "endOfLine": "auto" +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e93e507 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch UI in Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Launch UI in Edge", + "type": "msedge", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}" + }, + { + "name": "Attach to Chrome", + "port": 9222, + "request": "attach", + "type": "pwa-chrome", + "urlFilter": "http://localhost:3000/*", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..fae8e3d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true +} diff --git a/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs b/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs new file mode 100644 index 0000000..fc27b01 --- /dev/null +++ b/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs @@ -0,0 +1,28 @@ +/* eslint-disable */ +//prettier-ignore +module.exports = { +name: "@yarnpkg/plugin-workspace-tools", +factory: function (require) { +var plugin=(()=>{var _r=Object.create;var we=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var xr=Object.getPrototypeOf,Cr=Object.prototype.hasOwnProperty;var W=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var q=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),wr=(e,r)=>{for(var t in r)we(e,t,{get:r[t],enumerable:!0})},Je=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of br(r))!Cr.call(e,s)&&s!==t&&we(e,s,{get:()=>r[s],enumerable:!(n=Er(r,s))||n.enumerable});return e};var Be=(e,r,t)=>(t=e!=null?_r(xr(e)):{},Je(r||!e||!e.__esModule?we(t,"default",{value:e,enumerable:!0}):t,e)),Sr=e=>Je(we({},"__esModule",{value:!0}),e);var ve=q(ee=>{"use strict";ee.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;ee.find=(e,r)=>e.nodes.find(t=>t.type===r);ee.exceedsLimit=(e,r,t=1,n)=>n===!1||!ee.isInteger(e)||!ee.isInteger(r)?!1:(Number(r)-Number(e))/Number(t)>=n;ee.escapeNode=(e,r=0,t)=>{let n=e.nodes[r];!n||(t&&n.type===t||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};ee.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;ee.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;ee.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;ee.reduce=e=>e.reduce((r,t)=>(t.type==="text"&&r.push(t.value),t.type==="range"&&(t.type="text"),r),[]);ee.flatten=(...e)=>{let r=[],t=n=>{for(let s=0;s{"use strict";var tt=ve();rt.exports=(e,r={})=>{let t=(n,s={})=>{let i=r.escapeInvalid&&tt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c="";if(n.value)return(i||a)&&tt.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let p of n.nodes)c+=t(p);return c};return t(e)}});var st=q((Jn,nt)=>{"use strict";nt.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var ht=q((es,pt)=>{"use strict";var at=st(),le=(e,r,t)=>{if(at(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(r===void 0||e===r)return String(e);if(at(r)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...t};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let s=String(n.relaxZeros),i=String(n.shorthand),a=String(n.capture),c=String(n.wrap),p=e+":"+r+"="+s+i+a+c;if(le.cache.hasOwnProperty(p))return le.cache[p].result;let m=Math.min(e,r),h=Math.max(e,r);if(Math.abs(m-h)===1){let y=e+"|"+r;return n.capture?`(${y})`:n.wrap===!1?y:`(?:${y})`}let R=ft(e)||ft(r),f={min:e,max:r,a:m,b:h},$=[],_=[];if(R&&(f.isPadded=R,f.maxLen=String(f.max).length),m<0){let y=h<0?Math.abs(h):1;_=it(y,Math.abs(m),f,n),m=f.a=0}return h>=0&&($=it(m,h,f,n)),f.negatives=_,f.positives=$,f.result=vr(_,$,n),n.capture===!0?f.result=`(${f.result})`:n.wrap!==!1&&$.length+_.length>1&&(f.result=`(?:${f.result})`),le.cache[p]=f,f.result};function vr(e,r,t){let n=Me(e,r,"-",!1,t)||[],s=Me(r,e,"",!1,t)||[],i=Me(e,r,"-?",!0,t)||[];return n.concat(i).concat(s).join("|")}function Hr(e,r){let t=1,n=1,s=ut(e,t),i=new Set([r]);for(;e<=s&&s<=r;)i.add(s),t+=1,s=ut(e,t);for(s=ct(r+1,n)-1;e1&&c.count.pop(),c.count.push(h.count[0]),c.string=c.pattern+lt(c.count),a=m+1;continue}t.isPadded&&(R=Or(m,t,n)),h.string=R+h.pattern+lt(h.count),i.push(h),a=m+1,c=h}return i}function Me(e,r,t,n,s){let i=[];for(let a of e){let{string:c}=a;!n&&!ot(r,"string",c)&&i.push(t+c),n&&ot(r,"string",c)&&i.push(t+c)}return i}function Tr(e,r){let t=[];for(let n=0;nr?1:r>e?-1:0}function ot(e,r,t){return e.some(n=>n[r]===t)}function ut(e,r){return Number(String(e).slice(0,-r)+"9".repeat(r))}function ct(e,r){return e-e%Math.pow(10,r)}function lt(e){let[r=0,t=""]=e;return t||r>1?`{${r+(t?","+t:"")}}`:""}function Lr(e,r,t){return`[${e}${r-e===1?"":"-"}${r}]`}function ft(e){return/^-?(0+)\d/.test(e)}function Or(e,r,t){if(!r.isPadded)return e;let n=Math.abs(r.maxLen-String(e).length),s=t.relaxZeros!==!1;switch(n){case 0:return"";case 1:return s?"0?":"0";case 2:return s?"0{0,2}":"00";default:return s?`0{0,${n}}`:`0{${n}}`}}le.cache={};le.clearCache=()=>le.cache={};pt.exports=le});var Ue=q((ts,Et)=>{"use strict";var Nr=W("util"),At=ht(),dt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ir=e=>r=>e===!0?Number(r):String(r),Pe=e=>typeof e=="number"||typeof e=="string"&&e!=="",Ae=e=>Number.isInteger(+e),De=e=>{let r=`${e}`,t=-1;if(r[0]==="-"&&(r=r.slice(1)),r==="0")return!1;for(;r[++t]==="0";);return t>0},Br=(e,r,t)=>typeof e=="string"||typeof r=="string"?!0:t.stringify===!0,Mr=(e,r,t)=>{if(r>0){let n=e[0]==="-"?"-":"";n&&(e=e.slice(1)),e=n+e.padStart(n?r-1:r,"0")}return t===!1?String(e):e},gt=(e,r)=>{let t=e[0]==="-"?"-":"";for(t&&(e=e.slice(1),r--);e.length{e.negatives.sort((a,c)=>ac?1:0),e.positives.sort((a,c)=>ac?1:0);let t=r.capture?"":"?:",n="",s="",i;return e.positives.length&&(n=e.positives.join("|")),e.negatives.length&&(s=`-(${t}${e.negatives.join("|")})`),n&&s?i=`${n}|${s}`:i=n||s,r.wrap?`(${t}${i})`:i},mt=(e,r,t,n)=>{if(t)return At(e,r,{wrap:!1,...n});let s=String.fromCharCode(e);if(e===r)return s;let i=String.fromCharCode(r);return`[${s}-${i}]`},Rt=(e,r,t)=>{if(Array.isArray(e)){let n=t.wrap===!0,s=t.capture?"":"?:";return n?`(${s}${e.join("|")})`:e.join("|")}return At(e,r,t)},yt=(...e)=>new RangeError("Invalid range arguments: "+Nr.inspect(...e)),_t=(e,r,t)=>{if(t.strictRanges===!0)throw yt([e,r]);return[]},Dr=(e,r)=>{if(r.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},Ur=(e,r,t=1,n={})=>{let s=Number(e),i=Number(r);if(!Number.isInteger(s)||!Number.isInteger(i)){if(n.strictRanges===!0)throw yt([e,r]);return[]}s===0&&(s=0),i===0&&(i=0);let a=s>i,c=String(e),p=String(r),m=String(t);t=Math.max(Math.abs(t),1);let h=De(c)||De(p)||De(m),R=h?Math.max(c.length,p.length,m.length):0,f=h===!1&&Br(e,r,n)===!1,$=n.transform||Ir(f);if(n.toRegex&&t===1)return mt(gt(e,R),gt(r,R),!0,n);let _={negatives:[],positives:[]},y=T=>_[T<0?"negatives":"positives"].push(Math.abs(T)),E=[],S=0;for(;a?s>=i:s<=i;)n.toRegex===!0&&t>1?y(s):E.push(Mr($(s,S),R,f)),s=a?s-t:s+t,S++;return n.toRegex===!0?t>1?Pr(_,n):Rt(E,null,{wrap:!1,...n}):E},Gr=(e,r,t=1,n={})=>{if(!Ae(e)&&e.length>1||!Ae(r)&&r.length>1)return _t(e,r,n);let s=n.transform||(f=>String.fromCharCode(f)),i=`${e}`.charCodeAt(0),a=`${r}`.charCodeAt(0),c=i>a,p=Math.min(i,a),m=Math.max(i,a);if(n.toRegex&&t===1)return mt(p,m,!1,n);let h=[],R=0;for(;c?i>=a:i<=a;)h.push(s(i,R)),i=c?i-t:i+t,R++;return n.toRegex===!0?Rt(h,null,{wrap:!1,options:n}):h},$e=(e,r,t,n={})=>{if(r==null&&Pe(e))return[e];if(!Pe(e)||!Pe(r))return _t(e,r,n);if(typeof t=="function")return $e(e,r,1,{transform:t});if(dt(t))return $e(e,r,0,t);let s={...n};return s.capture===!0&&(s.wrap=!0),t=t||s.step||1,Ae(t)?Ae(e)&&Ae(r)?Ur(e,r,t,s):Gr(e,r,Math.max(Math.abs(t),1),s):t!=null&&!dt(t)?Dr(t,s):$e(e,r,1,t)};Et.exports=$e});var Ct=q((rs,xt)=>{"use strict";var qr=Ue(),bt=ve(),Kr=(e,r={})=>{let t=(n,s={})=>{let i=bt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c=i===!0||a===!0,p=r.escapeInvalid===!0?"\\":"",m="";if(n.isOpen===!0||n.isClose===!0)return p+n.value;if(n.type==="open")return c?p+n.value:"(";if(n.type==="close")return c?p+n.value:")";if(n.type==="comma")return n.prev.type==="comma"?"":c?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let h=bt.reduce(n.nodes),R=qr(...h,{...r,wrap:!1,toRegex:!0});if(R.length!==0)return h.length>1&&R.length>1?`(${R})`:R}if(n.nodes)for(let h of n.nodes)m+=t(h,n);return m};return t(e)};xt.exports=Kr});var vt=q((ns,St)=>{"use strict";var Wr=Ue(),wt=He(),he=ve(),fe=(e="",r="",t=!1)=>{let n=[];if(e=[].concat(e),r=[].concat(r),!r.length)return e;if(!e.length)return t?he.flatten(r).map(s=>`{${s}}`):r;for(let s of e)if(Array.isArray(s))for(let i of s)n.push(fe(i,r,t));else for(let i of r)t===!0&&typeof i=="string"&&(i=`{${i}}`),n.push(Array.isArray(i)?fe(s,i,t):s+i);return he.flatten(n)},jr=(e,r={})=>{let t=r.rangeLimit===void 0?1e3:r.rangeLimit,n=(s,i={})=>{s.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(s.invalid||s.dollar){c.push(fe(c.pop(),wt(s,r)));return}if(s.type==="brace"&&s.invalid!==!0&&s.nodes.length===2){c.push(fe(c.pop(),["{}"]));return}if(s.nodes&&s.ranges>0){let R=he.reduce(s.nodes);if(he.exceedsLimit(...R,r.step,t))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=Wr(...R,r);f.length===0&&(f=wt(s,r)),c.push(fe(c.pop(),f)),s.nodes=[];return}let p=he.encloseBrace(s),m=s.queue,h=s;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,m=h.queue;for(let R=0;R{"use strict";Ht.exports={MAX_LENGTH:1024*64,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:` +`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Nt=q((as,Ot)=>{"use strict";var Fr=He(),{MAX_LENGTH:Tt,CHAR_BACKSLASH:Ge,CHAR_BACKTICK:Qr,CHAR_COMMA:Xr,CHAR_DOT:Zr,CHAR_LEFT_PARENTHESES:Yr,CHAR_RIGHT_PARENTHESES:zr,CHAR_LEFT_CURLY_BRACE:Vr,CHAR_RIGHT_CURLY_BRACE:Jr,CHAR_LEFT_SQUARE_BRACKET:kt,CHAR_RIGHT_SQUARE_BRACKET:Lt,CHAR_DOUBLE_QUOTE:en,CHAR_SINGLE_QUOTE:tn,CHAR_NO_BREAK_SPACE:rn,CHAR_ZERO_WIDTH_NOBREAK_SPACE:nn}=$t(),sn=(e,r={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let t=r||{},n=typeof t.maxLength=="number"?Math.min(Tt,t.maxLength):Tt;if(e.length>n)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${n})`);let s={type:"root",input:e,nodes:[]},i=[s],a=s,c=s,p=0,m=e.length,h=0,R=0,f,$={},_=()=>e[h++],y=E=>{if(E.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&E.type==="text"){c.value+=E.value;return}return a.nodes.push(E),E.parent=a,E.prev=c,c=E,E};for(y({type:"bos"});h0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:Fr(a)}]}y({type:"comma",value:f}),a.commas++;continue}if(f===Zr&&R>0&&a.commas===0){let E=a.nodes;if(R===0||E.length===0){y({type:"text",value:f});continue}if(c.type==="dot"){if(a.range=[],c.value+=f,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){E.pop();let S=E[E.length-1];S.value+=c.value+f,c=S,a.ranges--;continue}y({type:"dot",value:f});continue}y({type:"text",value:f})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(T=>{T.nodes||(T.type==="open"&&(T.isOpen=!0),T.type==="close"&&(T.isClose=!0),T.nodes||(T.type="text"),T.invalid=!0)});let E=i[i.length-1],S=E.nodes.indexOf(a);E.nodes.splice(S,1,...a.nodes)}while(i.length>0);return y({type:"eos"}),s};Ot.exports=sn});var Mt=q((is,Bt)=>{"use strict";var It=He(),an=Ct(),on=vt(),un=Nt(),X=(e,r={})=>{let t=[];if(Array.isArray(e))for(let n of e){let s=X.create(n,r);Array.isArray(s)?t.push(...s):t.push(s)}else t=[].concat(X.create(e,r));return r&&r.expand===!0&&r.nodupes===!0&&(t=[...new Set(t)]),t};X.parse=(e,r={})=>un(e,r);X.stringify=(e,r={})=>It(typeof e=="string"?X.parse(e,r):e,r);X.compile=(e,r={})=>(typeof e=="string"&&(e=X.parse(e,r)),an(e,r));X.expand=(e,r={})=>{typeof e=="string"&&(e=X.parse(e,r));let t=on(e,r);return r.noempty===!0&&(t=t.filter(Boolean)),r.nodupes===!0&&(t=[...new Set(t)]),t};X.create=(e,r={})=>e===""||e.length<3?[e]:r.expand!==!0?X.compile(e,r):X.expand(e,r);Bt.exports=X});var me=q((os,qt)=>{"use strict";var cn=W("path"),se="\\\\/",Pt=`[^${se}]`,ie="\\.",ln="\\+",fn="\\?",Te="\\/",pn="(?=.)",Dt="[^/]",qe=`(?:${Te}|$)`,Ut=`(?:^|${Te})`,Ke=`${ie}{1,2}${qe}`,hn=`(?!${ie})`,dn=`(?!${Ut}${Ke})`,gn=`(?!${ie}{0,1}${qe})`,An=`(?!${Ke})`,mn=`[^.${Te}]`,Rn=`${Dt}*?`,Gt={DOT_LITERAL:ie,PLUS_LITERAL:ln,QMARK_LITERAL:fn,SLASH_LITERAL:Te,ONE_CHAR:pn,QMARK:Dt,END_ANCHOR:qe,DOTS_SLASH:Ke,NO_DOT:hn,NO_DOTS:dn,NO_DOT_SLASH:gn,NO_DOTS_SLASH:An,QMARK_NO_DOT:mn,STAR:Rn,START_ANCHOR:Ut},yn={...Gt,SLASH_LITERAL:`[${se}]`,QMARK:Pt,STAR:`${Pt}*?`,DOTS_SLASH:`${ie}{1,2}(?:[${se}]|$)`,NO_DOT:`(?!${ie})`,NO_DOTS:`(?!(?:^|[${se}])${ie}{1,2}(?:[${se}]|$))`,NO_DOT_SLASH:`(?!${ie}{0,1}(?:[${se}]|$))`,NO_DOTS_SLASH:`(?!${ie}{1,2}(?:[${se}]|$))`,QMARK_NO_DOT:`[^.${se}]`,START_ANCHOR:`(?:^|[${se}])`,END_ANCHOR:`(?:[${se}]|$)`},_n={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};qt.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:_n,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:cn.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?yn:Gt}}});var Re=q(F=>{"use strict";var En=W("path"),bn=process.platform==="win32",{REGEX_BACKSLASH:xn,REGEX_REMOVE_BACKSLASH:Cn,REGEX_SPECIAL_CHARS:wn,REGEX_SPECIAL_CHARS_GLOBAL:Sn}=me();F.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);F.hasRegexChars=e=>wn.test(e);F.isRegexChar=e=>e.length===1&&F.hasRegexChars(e);F.escapeRegex=e=>e.replace(Sn,"\\$1");F.toPosixSlashes=e=>e.replace(xn,"/");F.removeBackslashes=e=>e.replace(Cn,r=>r==="\\"?"":r);F.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};F.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:bn===!0||En.sep==="\\";F.escapeLast=(e,r,t)=>{let n=e.lastIndexOf(r,t);return n===-1?e:e[n-1]==="\\"?F.escapeLast(e,r,n-1):`${e.slice(0,n)}\\${e.slice(n)}`};F.removePrefix=(e,r={})=>{let t=e;return t.startsWith("./")&&(t=t.slice(2),r.prefix="./"),t};F.wrapOutput=(e,r={},t={})=>{let n=t.contains?"":"^",s=t.contains?"":"$",i=`${n}(?:${e})${s}`;return r.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Yt=q((cs,Zt)=>{"use strict";var Kt=Re(),{CHAR_ASTERISK:We,CHAR_AT:vn,CHAR_BACKWARD_SLASH:ye,CHAR_COMMA:Hn,CHAR_DOT:je,CHAR_EXCLAMATION_MARK:Fe,CHAR_FORWARD_SLASH:Xt,CHAR_LEFT_CURLY_BRACE:Qe,CHAR_LEFT_PARENTHESES:Xe,CHAR_LEFT_SQUARE_BRACKET:$n,CHAR_PLUS:Tn,CHAR_QUESTION_MARK:Wt,CHAR_RIGHT_CURLY_BRACE:kn,CHAR_RIGHT_PARENTHESES:jt,CHAR_RIGHT_SQUARE_BRACKET:Ln}=me(),Ft=e=>e===Xt||e===ye,Qt=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},On=(e,r)=>{let t=r||{},n=e.length-1,s=t.parts===!0||t.scanToEnd===!0,i=[],a=[],c=[],p=e,m=-1,h=0,R=0,f=!1,$=!1,_=!1,y=!1,E=!1,S=!1,T=!1,L=!1,z=!1,I=!1,re=0,K,g,v={value:"",depth:0,isGlob:!1},k=()=>m>=n,l=()=>p.charCodeAt(m+1),H=()=>(K=g,p.charCodeAt(++m));for(;m0&&(B=p.slice(0,h),p=p.slice(h),R-=h),w&&_===!0&&R>0?(w=p.slice(0,R),o=p.slice(R)):_===!0?(w="",o=p):w=p,w&&w!==""&&w!=="/"&&w!==p&&Ft(w.charCodeAt(w.length-1))&&(w=w.slice(0,-1)),t.unescape===!0&&(o&&(o=Kt.removeBackslashes(o)),w&&T===!0&&(w=Kt.removeBackslashes(w)));let u={prefix:B,input:e,start:h,base:w,glob:o,isBrace:f,isBracket:$,isGlob:_,isExtglob:y,isGlobstar:E,negated:L,negatedExtglob:z};if(t.tokens===!0&&(u.maxDepth=0,Ft(g)||a.push(v),u.tokens=a),t.parts===!0||t.tokens===!0){let M;for(let b=0;b{"use strict";var ke=me(),Z=Re(),{MAX_LENGTH:Le,POSIX_REGEX_SOURCE:Nn,REGEX_NON_SPECIAL_CHARS:In,REGEX_SPECIAL_CHARS_BACKREF:Bn,REPLACEMENTS:zt}=ke,Mn=(e,r)=>{if(typeof r.expandRange=="function")return r.expandRange(...e,r);e.sort();let t=`[${e.join("-")}]`;try{new RegExp(t)}catch{return e.map(s=>Z.escapeRegex(s)).join("..")}return t},de=(e,r)=>`Missing ${e}: "${r}" - use "\\\\${r}" to match literal characters`,Vt=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=zt[e]||e;let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);let i={type:"bos",value:"",output:t.prepend||""},a=[i],c=t.capture?"":"?:",p=Z.isWindows(r),m=ke.globChars(p),h=ke.extglobChars(m),{DOT_LITERAL:R,PLUS_LITERAL:f,SLASH_LITERAL:$,ONE_CHAR:_,DOTS_SLASH:y,NO_DOT:E,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:L,QMARK_NO_DOT:z,STAR:I,START_ANCHOR:re}=m,K=A=>`(${c}(?:(?!${re}${A.dot?y:R}).)*?)`,g=t.dot?"":E,v=t.dot?L:z,k=t.bash===!0?K(t):I;t.capture&&(k=`(${k})`),typeof t.noext=="boolean"&&(t.noextglob=t.noext);let l={input:e,index:-1,start:0,dot:t.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=Z.removePrefix(e,l),s=e.length;let H=[],w=[],B=[],o=i,u,M=()=>l.index===s-1,b=l.peek=(A=1)=>e[l.index+A],V=l.advance=()=>e[++l.index]||"",J=()=>e.slice(l.index+1),Q=(A="",O=0)=>{l.consumed+=A,l.index+=O},Ee=A=>{l.output+=A.output!=null?A.output:A.value,Q(A.value)},Rr=()=>{let A=1;for(;b()==="!"&&(b(2)!=="("||b(3)==="?");)V(),l.start++,A++;return A%2===0?!1:(l.negated=!0,l.start++,!0)},be=A=>{l[A]++,B.push(A)},oe=A=>{l[A]--,B.pop()},C=A=>{if(o.type==="globstar"){let O=l.braces>0&&(A.type==="comma"||A.type==="brace"),d=A.extglob===!0||H.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!O&&!d&&(l.output=l.output.slice(0,-o.output.length),o.type="star",o.value="*",o.output=k,l.output+=o.output)}if(H.length&&A.type!=="paren"&&(H[H.length-1].inner+=A.value),(A.value||A.output)&&Ee(A),o&&o.type==="text"&&A.type==="text"){o.value+=A.value,o.output=(o.output||"")+A.value;return}A.prev=o,a.push(A),o=A},xe=(A,O)=>{let d={...h[O],conditions:1,inner:""};d.prev=o,d.parens=l.parens,d.output=l.output;let x=(t.capture?"(":"")+d.open;be("parens"),C({type:A,value:O,output:l.output?"":_}),C({type:"paren",extglob:!0,value:V(),output:x}),H.push(d)},yr=A=>{let O=A.close+(t.capture?")":""),d;if(A.type==="negate"){let x=k;A.inner&&A.inner.length>1&&A.inner.includes("/")&&(x=K(t)),(x!==k||M()||/^\)+$/.test(J()))&&(O=A.close=`)$))${x}`),A.inner.includes("*")&&(d=J())&&/^\.[^\\/.]+$/.test(d)&&(O=A.close=`)${d})${x})`),A.prev.type==="bos"&&(l.negatedExtglob=!0)}C({type:"paren",extglob:!0,value:u,output:O}),oe("parens")};if(t.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,O=e.replace(Bn,(d,x,P,j,G,Ie)=>j==="\\"?(A=!0,d):j==="?"?x?x+j+(G?L.repeat(G.length):""):Ie===0?v+(G?L.repeat(G.length):""):L.repeat(P.length):j==="."?R.repeat(P.length):j==="*"?x?x+j+(G?k:""):k:x?d:`\\${d}`);return A===!0&&(t.unescape===!0?O=O.replace(/\\/g,""):O=O.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),O===e&&t.contains===!0?(l.output=e,l):(l.output=Z.wrapOutput(O,l,r),l)}for(;!M();){if(u=V(),u==="\0")continue;if(u==="\\"){let d=b();if(d==="/"&&t.bash!==!0||d==="."||d===";")continue;if(!d){u+="\\",C({type:"text",value:u});continue}let x=/^\\+/.exec(J()),P=0;if(x&&x[0].length>2&&(P=x[0].length,l.index+=P,P%2!==0&&(u+="\\")),t.unescape===!0?u=V():u+=V(),l.brackets===0){C({type:"text",value:u});continue}}if(l.brackets>0&&(u!=="]"||o.value==="["||o.value==="[^")){if(t.posix!==!1&&u===":"){let d=o.value.slice(1);if(d.includes("[")&&(o.posix=!0,d.includes(":"))){let x=o.value.lastIndexOf("["),P=o.value.slice(0,x),j=o.value.slice(x+2),G=Nn[j];if(G){o.value=P+G,l.backtrack=!0,V(),!i.output&&a.indexOf(o)===1&&(i.output=_);continue}}}(u==="["&&b()!==":"||u==="-"&&b()==="]")&&(u=`\\${u}`),u==="]"&&(o.value==="["||o.value==="[^")&&(u=`\\${u}`),t.posix===!0&&u==="!"&&o.value==="["&&(u="^"),o.value+=u,Ee({value:u});continue}if(l.quotes===1&&u!=='"'){u=Z.escapeRegex(u),o.value+=u,Ee({value:u});continue}if(u==='"'){l.quotes=l.quotes===1?0:1,t.keepQuotes===!0&&C({type:"text",value:u});continue}if(u==="("){be("parens"),C({type:"paren",value:u});continue}if(u===")"){if(l.parens===0&&t.strictBrackets===!0)throw new SyntaxError(de("opening","("));let d=H[H.length-1];if(d&&l.parens===d.parens+1){yr(H.pop());continue}C({type:"paren",value:u,output:l.parens?")":"\\)"}),oe("parens");continue}if(u==="["){if(t.nobracket===!0||!J().includes("]")){if(t.nobracket!==!0&&t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));u=`\\${u}`}else be("brackets");C({type:"bracket",value:u});continue}if(u==="]"){if(t.nobracket===!0||o&&o.type==="bracket"&&o.value.length===1){C({type:"text",value:u,output:`\\${u}`});continue}if(l.brackets===0){if(t.strictBrackets===!0)throw new SyntaxError(de("opening","["));C({type:"text",value:u,output:`\\${u}`});continue}oe("brackets");let d=o.value.slice(1);if(o.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(u=`/${u}`),o.value+=u,Ee({value:u}),t.literalBrackets===!1||Z.hasRegexChars(d))continue;let x=Z.escapeRegex(o.value);if(l.output=l.output.slice(0,-o.value.length),t.literalBrackets===!0){l.output+=x,o.value=x;continue}o.value=`(${c}${x}|${o.value})`,l.output+=o.value;continue}if(u==="{"&&t.nobrace!==!0){be("braces");let d={type:"brace",value:u,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};w.push(d),C(d);continue}if(u==="}"){let d=w[w.length-1];if(t.nobrace===!0||!d){C({type:"text",value:u,output:u});continue}let x=")";if(d.dots===!0){let P=a.slice(),j=[];for(let G=P.length-1;G>=0&&(a.pop(),P[G].type!=="brace");G--)P[G].type!=="dots"&&j.unshift(P[G].value);x=Mn(j,t),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let P=l.output.slice(0,d.outputIndex),j=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",u=x="\\}",l.output=P;for(let G of j)l.output+=G.output||G.value}C({type:"brace",value:u,output:x}),oe("braces"),w.pop();continue}if(u==="|"){H.length>0&&H[H.length-1].conditions++,C({type:"text",value:u});continue}if(u===","){let d=u,x=w[w.length-1];x&&B[B.length-1]==="braces"&&(x.comma=!0,d="|"),C({type:"comma",value:u,output:d});continue}if(u==="/"){if(o.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",a.pop(),o=i;continue}C({type:"slash",value:u,output:$});continue}if(u==="."){if(l.braces>0&&o.type==="dot"){o.value==="."&&(o.output=R);let d=w[w.length-1];o.type="dots",o.output+=u,o.value+=u,d.dots=!0;continue}if(l.braces+l.parens===0&&o.type!=="bos"&&o.type!=="slash"){C({type:"text",value:u,output:R});continue}C({type:"dot",value:u,output:R});continue}if(u==="?"){if(!(o&&o.value==="(")&&t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("qmark",u);continue}if(o&&o.type==="paren"){let x=b(),P=u;if(x==="<"&&!Z.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(o.value==="("&&!/[!=<:]/.test(x)||x==="<"&&!/<([!=]|\w+>)/.test(J()))&&(P=`\\${u}`),C({type:"text",value:u,output:P});continue}if(t.dot!==!0&&(o.type==="slash"||o.type==="bos")){C({type:"qmark",value:u,output:z});continue}C({type:"qmark",value:u,output:L});continue}if(u==="!"){if(t.noextglob!==!0&&b()==="("&&(b(2)!=="?"||!/[!=<:]/.test(b(3)))){xe("negate",u);continue}if(t.nonegate!==!0&&l.index===0){Rr();continue}}if(u==="+"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("plus",u);continue}if(o&&o.value==="("||t.regex===!1){C({type:"plus",value:u,output:f});continue}if(o&&(o.type==="bracket"||o.type==="paren"||o.type==="brace")||l.parens>0){C({type:"plus",value:u});continue}C({type:"plus",value:f});continue}if(u==="@"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){C({type:"at",extglob:!0,value:u,output:""});continue}C({type:"text",value:u});continue}if(u!=="*"){(u==="$"||u==="^")&&(u=`\\${u}`);let d=In.exec(J());d&&(u+=d[0],l.index+=d[0].length),C({type:"text",value:u});continue}if(o&&(o.type==="globstar"||o.star===!0)){o.type="star",o.star=!0,o.value+=u,o.output=k,l.backtrack=!0,l.globstar=!0,Q(u);continue}let A=J();if(t.noextglob!==!0&&/^\([^?]/.test(A)){xe("star",u);continue}if(o.type==="star"){if(t.noglobstar===!0){Q(u);continue}let d=o.prev,x=d.prev,P=d.type==="slash"||d.type==="bos",j=x&&(x.type==="star"||x.type==="globstar");if(t.bash===!0&&(!P||A[0]&&A[0]!=="/")){C({type:"star",value:u,output:""});continue}let G=l.braces>0&&(d.type==="comma"||d.type==="brace"),Ie=H.length&&(d.type==="pipe"||d.type==="paren");if(!P&&d.type!=="paren"&&!G&&!Ie){C({type:"star",value:u,output:""});continue}for(;A.slice(0,3)==="/**";){let Ce=e[l.index+4];if(Ce&&Ce!=="/")break;A=A.slice(3),Q("/**",3)}if(d.type==="bos"&&M()){o.type="globstar",o.value+=u,o.output=K(t),l.output=o.output,l.globstar=!0,Q(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!j&&M()){l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=K(t)+(t.strictSlashes?")":"|$)"),o.value+=u,l.globstar=!0,l.output+=d.output+o.output,Q(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&A[0]==="/"){let Ce=A[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=`${K(t)}${$}|${$}${Ce})`,o.value+=u,l.output+=d.output+o.output,l.globstar=!0,Q(u+V()),C({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&A[0]==="/"){o.type="globstar",o.value+=u,o.output=`(?:^|${$}|${K(t)}${$})`,l.output=o.output,l.globstar=!0,Q(u+V()),C({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-o.output.length),o.type="globstar",o.output=K(t),o.value+=u,l.output+=o.output,l.globstar=!0,Q(u);continue}let O={type:"star",value:u,output:k};if(t.bash===!0){O.output=".*?",(o.type==="bos"||o.type==="slash")&&(O.output=g+O.output),C(O);continue}if(o&&(o.type==="bracket"||o.type==="paren")&&t.regex===!0){O.output=u,C(O);continue}(l.index===l.start||o.type==="slash"||o.type==="dot")&&(o.type==="dot"?(l.output+=S,o.output+=S):t.dot===!0?(l.output+=T,o.output+=T):(l.output+=g,o.output+=g),b()!=="*"&&(l.output+=_,o.output+=_)),C(O)}for(;l.brackets>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));l.output=Z.escapeLast(l.output,"["),oe("brackets")}for(;l.parens>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing",")"));l.output=Z.escapeLast(l.output,"("),oe("parens")}for(;l.braces>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","}"));l.output=Z.escapeLast(l.output,"{"),oe("braces")}if(t.strictSlashes!==!0&&(o.type==="star"||o.type==="bracket")&&C({type:"maybe_slash",value:"",output:`${$}?`}),l.backtrack===!0){l.output="";for(let A of l.tokens)l.output+=A.output!=null?A.output:A.value,A.suffix&&(l.output+=A.suffix)}return l};Vt.fastpaths=(e,r)=>{let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);e=zt[e]||e;let i=Z.isWindows(r),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:p,DOTS_SLASH:m,NO_DOT:h,NO_DOTS:R,NO_DOTS_SLASH:f,STAR:$,START_ANCHOR:_}=ke.globChars(i),y=t.dot?R:h,E=t.dot?f:h,S=t.capture?"":"?:",T={negated:!1,prefix:""},L=t.bash===!0?".*?":$;t.capture&&(L=`(${L})`);let z=g=>g.noglobstar===!0?L:`(${S}(?:(?!${_}${g.dot?m:a}).)*?)`,I=g=>{switch(g){case"*":return`${y}${p}${L}`;case".*":return`${a}${p}${L}`;case"*.*":return`${y}${L}${a}${p}${L}`;case"*/*":return`${y}${L}${c}${p}${E}${L}`;case"**":return y+z(t);case"**/*":return`(?:${y}${z(t)}${c})?${E}${p}${L}`;case"**/*.*":return`(?:${y}${z(t)}${c})?${E}${L}${a}${p}${L}`;case"**/.*":return`(?:${y}${z(t)}${c})?${a}${p}${L}`;default:{let v=/^(.*?)\.(\w+)$/.exec(g);if(!v)return;let k=I(v[1]);return k?k+a+v[2]:void 0}}},re=Z.removePrefix(e,T),K=I(re);return K&&t.strictSlashes!==!0&&(K+=`${c}?`),K};Jt.exports=Vt});var rr=q((fs,tr)=>{"use strict";var Pn=W("path"),Dn=Yt(),Ze=er(),Ye=Re(),Un=me(),Gn=e=>e&&typeof e=="object"&&!Array.isArray(e),D=(e,r,t=!1)=>{if(Array.isArray(e)){let h=e.map(f=>D(f,r,t));return f=>{for(let $ of h){let _=$(f);if(_)return _}return!1}}let n=Gn(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!n)throw new TypeError("Expected pattern to be a non-empty string");let s=r||{},i=Ye.isWindows(r),a=n?D.compileRe(e,r):D.makeRe(e,r,!1,!0),c=a.state;delete a.state;let p=()=>!1;if(s.ignore){let h={...r,ignore:null,onMatch:null,onResult:null};p=D(s.ignore,h,t)}let m=(h,R=!1)=>{let{isMatch:f,match:$,output:_}=D.test(h,a,r,{glob:e,posix:i}),y={glob:e,state:c,regex:a,posix:i,input:h,output:_,match:$,isMatch:f};return typeof s.onResult=="function"&&s.onResult(y),f===!1?(y.isMatch=!1,R?y:!1):p(h)?(typeof s.onIgnore=="function"&&s.onIgnore(y),y.isMatch=!1,R?y:!1):(typeof s.onMatch=="function"&&s.onMatch(y),R?y:!0)};return t&&(m.state=c),m};D.test=(e,r,t,{glob:n,posix:s}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=t||{},a=i.format||(s?Ye.toPosixSlashes:null),c=e===n,p=c&&a?a(e):e;return c===!1&&(p=a?a(e):e,c=p===n),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=D.matchBase(e,r,t,s):c=r.exec(p)),{isMatch:Boolean(c),match:c,output:p}};D.matchBase=(e,r,t,n=Ye.isWindows(t))=>(r instanceof RegExp?r:D.makeRe(r,t)).test(Pn.basename(e));D.isMatch=(e,r,t)=>D(r,t)(e);D.parse=(e,r)=>Array.isArray(e)?e.map(t=>D.parse(t,r)):Ze(e,{...r,fastpaths:!1});D.scan=(e,r)=>Dn(e,r);D.compileRe=(e,r,t=!1,n=!1)=>{if(t===!0)return e.output;let s=r||{},i=s.contains?"":"^",a=s.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let p=D.toRegex(c,r);return n===!0&&(p.state=e),p};D.makeRe=(e,r={},t=!1,n=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let s={negated:!1,fastpaths:!0};return r.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(s.output=Ze.fastpaths(e,r)),s.output||(s=Ze(e,r)),D.compileRe(s,r,t,n)};D.toRegex=(e,r)=>{try{let t=r||{};return new RegExp(e,t.flags||(t.nocase?"i":""))}catch(t){if(r&&r.debug===!0)throw t;return/$^/}};D.constants=Un;tr.exports=D});var sr=q((ps,nr)=>{"use strict";nr.exports=rr()});var cr=q((hs,ur)=>{"use strict";var ir=W("util"),or=Mt(),ae=sr(),ze=Re(),ar=e=>e===""||e==="./",N=(e,r,t)=>{r=[].concat(r),e=[].concat(e);let n=new Set,s=new Set,i=new Set,a=0,c=h=>{i.add(h.output),t&&t.onResult&&t.onResult(h)};for(let h=0;h!n.has(h));if(t&&m.length===0){if(t.failglob===!0)throw new Error(`No matches found for "${r.join(", ")}"`);if(t.nonull===!0||t.nullglob===!0)return t.unescape?r.map(h=>h.replace(/\\/g,"")):r}return m};N.match=N;N.matcher=(e,r)=>ae(e,r);N.isMatch=(e,r,t)=>ae(r,t)(e);N.any=N.isMatch;N.not=(e,r,t={})=>{r=[].concat(r).map(String);let n=new Set,s=[],a=N(e,r,{...t,onResult:c=>{t.onResult&&t.onResult(c),s.push(c.output)}});for(let c of s)a.includes(c)||n.add(c);return[...n]};N.contains=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);if(Array.isArray(r))return r.some(n=>N.contains(e,n,t));if(typeof r=="string"){if(ar(e)||ar(r))return!1;if(e.includes(r)||e.startsWith("./")&&e.slice(2).includes(r))return!0}return N.isMatch(e,r,{...t,contains:!0})};N.matchKeys=(e,r,t)=>{if(!ze.isObject(e))throw new TypeError("Expected the first argument to be an object");let n=N(Object.keys(e),r,t),s={};for(let i of n)s[i]=e[i];return s};N.some=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(n.some(a=>i(a)))return!0}return!1};N.every=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(!n.every(a=>i(a)))return!1}return!0};N.all=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);return[].concat(r).every(n=>ae(n,t)(e))};N.capture=(e,r,t)=>{let n=ze.isWindows(t),i=ae.makeRe(String(e),{...t,capture:!0}).exec(n?ze.toPosixSlashes(r):r);if(i)return i.slice(1).map(a=>a===void 0?"":a)};N.makeRe=(...e)=>ae.makeRe(...e);N.scan=(...e)=>ae.scan(...e);N.parse=(e,r)=>{let t=[];for(let n of[].concat(e||[]))for(let s of or(String(n),r))t.push(ae.parse(s,r));return t};N.braces=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return r&&r.nobrace===!0||!/\{.*\}/.test(e)?[e]:or(e,r)};N.braceExpand=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return N.braces(e,{...r,expand:!0})};ur.exports=N});var fr=q((ds,lr)=>{"use strict";lr.exports=(e,...r)=>new Promise(t=>{t(e(...r))})});var hr=q((gs,Ve)=>{"use strict";var qn=fr(),pr=e=>{if(e<1)throw new TypeError("Expected `concurrency` to be a number from 1 and up");let r=[],t=0,n=()=>{t--,r.length>0&&r.shift()()},s=(c,p,...m)=>{t++;let h=qn(c,...m);p(h),h.then(n,n)},i=(c,p,...m)=>{tnew Promise(m=>i(c,m,...p));return Object.defineProperties(a,{activeCount:{get:()=>t},pendingCount:{get:()=>r.length}}),a};Ve.exports=pr;Ve.exports.default=pr});var Fn={};wr(Fn,{default:()=>jn});var Se=W("@yarnpkg/cli"),ne=W("@yarnpkg/core"),et=W("@yarnpkg/core"),ue=W("clipanion"),ce=class extends Se.BaseCommand{constructor(){super(...arguments);this.json=ue.Option.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.production=ue.Option.Boolean("--production",!1,{description:"Only install regular dependencies by omitting dev dependencies"});this.all=ue.Option.Boolean("-A,--all",!1,{description:"Install the entire project"});this.workspaces=ue.Option.Rest()}async execute(){let t=await ne.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ne.Project.find(t,this.context.cwd),i=await ne.Cache.find(t);await n.restoreInstallState({restoreResolutions:!1});let a;if(this.all)a=new Set(n.workspaces);else if(this.workspaces.length===0){if(!s)throw new Se.WorkspaceRequiredError(n.cwd,this.context.cwd);a=new Set([s])}else a=new Set(this.workspaces.map(p=>n.getWorkspaceByIdent(et.structUtils.parseIdent(p))));for(let p of a)for(let m of this.production?["dependencies"]:ne.Manifest.hardDependencies)for(let h of p.manifest.getForScope(m).values()){let R=n.tryWorkspaceByDescriptor(h);R!==null&&a.add(R)}for(let p of n.workspaces)a.has(p)?this.production&&p.manifest.devDependencies.clear():(p.manifest.installConfig=p.manifest.installConfig||{},p.manifest.installConfig.selfReferences=!1,p.manifest.dependencies.clear(),p.manifest.devDependencies.clear(),p.manifest.peerDependencies.clear(),p.manifest.scripts.clear());return(await ne.StreamReport.start({configuration:t,json:this.json,stdout:this.context.stdout,includeLogs:!0},async p=>{await n.install({cache:i,report:p,persistProject:!1})})).exitCode()}};ce.paths=[["workspaces","focus"]],ce.usage=ue.Command.Usage({category:"Workspace-related commands",description:"install a single workspace and its dependencies",details:"\n This command will run an install as if the specified workspaces (and all other workspaces they depend on) were the only ones in the project. If no workspaces are explicitly listed, the active one will be assumed.\n\n Note that this command is only very moderately useful when using zero-installs, since the cache will contain all the packages anyway - meaning that the only difference between a full install and a focused install would just be a few extra lines in the `.pnp.cjs` file, at the cost of introducing an extra complexity.\n\n If the `-A,--all` flag is set, the entire project will be installed. Combine with `--production` to replicate the old `yarn install --production`.\n "});var Ne=W("@yarnpkg/cli"),ge=W("@yarnpkg/core"),_e=W("@yarnpkg/core"),Y=W("@yarnpkg/core"),gr=W("@yarnpkg/plugin-git"),U=W("clipanion"),Oe=Be(cr()),Ar=W("os"),mr=Be(hr()),te=Be(W("typanion")),pe=class extends Ne.BaseCommand{constructor(){super(...arguments);this.recursive=U.Option.Boolean("-R,--recursive",!1,{description:"Find packages via dependencies/devDependencies instead of using the workspaces field"});this.from=U.Option.Array("--from",[],{description:"An array of glob pattern idents from which to base any recursion"});this.all=U.Option.Boolean("-A,--all",!1,{description:"Run the command on all workspaces of a project"});this.verbose=U.Option.Boolean("-v,--verbose",!1,{description:"Prefix each output line with the name of the originating workspace"});this.parallel=U.Option.Boolean("-p,--parallel",!1,{description:"Run the commands in parallel"});this.interlaced=U.Option.Boolean("-i,--interlaced",!1,{description:"Print the output of commands in real-time instead of buffering it"});this.jobs=U.Option.String("-j,--jobs",{description:"The maximum number of parallel tasks that the execution will be limited to; or `unlimited`",validator:te.isOneOf([te.isEnum(["unlimited"]),te.applyCascade(te.isNumber(),[te.isInteger(),te.isAtLeast(1)])])});this.topological=U.Option.Boolean("-t,--topological",!1,{description:"Run the command after all workspaces it depends on (regular) have finished"});this.topologicalDev=U.Option.Boolean("--topological-dev",!1,{description:"Run the command after all workspaces it depends on (regular + dev) have finished"});this.include=U.Option.Array("--include",[],{description:"An array of glob pattern idents; only matching workspaces will be traversed"});this.exclude=U.Option.Array("--exclude",[],{description:"An array of glob pattern idents; matching workspaces won't be traversed"});this.publicOnly=U.Option.Boolean("--no-private",{description:"Avoid running the command on private workspaces"});this.since=U.Option.String("--since",{description:"Only include workspaces that have been changed since the specified ref.",tolerateBoolean:!0});this.commandName=U.Option.String();this.args=U.Option.Proxy()}async execute(){let t=await ge.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ge.Project.find(t,this.context.cwd);if(!this.all&&!s)throw new Ne.WorkspaceRequiredError(n.cwd,this.context.cwd);await n.restoreInstallState();let i=this.cli.process([this.commandName,...this.args]),a=i.path.length===1&&i.path[0]==="run"&&typeof i.scriptName<"u"?i.scriptName:null;if(i.path.length===0)throw new U.UsageError("Invalid subcommand name for iteration - use the 'run' keyword if you wish to execute a script");let c=this.all?n.topLevelWorkspace:s,p=this.since?Array.from(await gr.gitUtils.fetchChangedWorkspaces({ref:this.since,project:n})):[c,...this.from.length>0?c.getRecursiveWorkspaceChildren():[]],m=g=>Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.from),h=this.from.length>0?p.filter(m):p,R=new Set([...h,...h.map(g=>[...this.recursive?this.since?g.getRecursiveWorkspaceDependents():g.getRecursiveWorkspaceDependencies():g.getRecursiveWorkspaceChildren()]).flat()]),f=[],$=!1;if(a!=null&&a.includes(":")){for(let g of n.workspaces)if(g.manifest.scripts.has(a)&&($=!$,$===!1))break}for(let g of R)a&&!g.manifest.scripts.has(a)&&!$&&!(await ge.scriptUtils.getWorkspaceAccessibleBinaries(g)).has(a)||a===process.env.npm_lifecycle_event&&g.cwd===s.cwd||this.include.length>0&&!Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.include)||this.exclude.length>0&&Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.exclude)||this.publicOnly&&g.manifest.private===!0||f.push(g);let _=this.parallel?this.jobs==="unlimited"?1/0:Number(this.jobs)||Math.max(1,(0,Ar.cpus)().length/2):1,y=_===1?!1:this.parallel,E=y?this.interlaced:!0,S=(0,mr.default)(_),T=new Map,L=new Set,z=0,I=null,re=!1,K=await _e.StreamReport.start({configuration:t,stdout:this.context.stdout},async g=>{let v=async(k,{commandIndex:l})=>{if(re)return-1;!y&&this.verbose&&l>1&&g.reportSeparator();let H=Kn(k,{configuration:t,verbose:this.verbose,commandIndex:l}),[w,B]=dr(g,{prefix:H,interlaced:E}),[o,u]=dr(g,{prefix:H,interlaced:E});try{this.verbose&&g.reportInfo(null,`${H} Process started`);let M=Date.now(),b=await this.cli.run([this.commandName,...this.args],{cwd:k.cwd,stdout:w,stderr:o})||0;w.end(),o.end(),await B,await u;let V=Date.now();if(this.verbose){let J=t.get("enableTimers")?`, completed in ${Y.formatUtils.pretty(t,V-M,Y.formatUtils.Type.DURATION)}`:"";g.reportInfo(null,`${H} Process exited (exit code ${b})${J}`)}return b===130&&(re=!0,I=b),b}catch(M){throw w.end(),o.end(),await B,await u,M}};for(let k of f)T.set(k.anchoredLocator.locatorHash,k);for(;T.size>0&&!g.hasErrors();){let k=[];for(let[w,B]of T){if(L.has(B.anchoredDescriptor.descriptorHash))continue;let o=!0;if(this.topological||this.topologicalDev){let u=this.topologicalDev?new Map([...B.manifest.dependencies,...B.manifest.devDependencies]):B.manifest.dependencies;for(let M of u.values()){let b=n.tryWorkspaceByDescriptor(M);if(o=b===null||!T.has(b.anchoredLocator.locatorHash),!o)break}}if(!!o&&(L.add(B.anchoredDescriptor.descriptorHash),k.push(S(async()=>{let u=await v(B,{commandIndex:++z});return T.delete(w),L.delete(B.anchoredDescriptor.descriptorHash),u})),!y))break}if(k.length===0){let w=Array.from(T.values()).map(B=>Y.structUtils.prettyLocator(t,B.anchoredLocator)).join(", ");g.reportError(_e.MessageName.CYCLIC_DEPENDENCIES,`Dependency cycle detected (${w})`);return}let H=(await Promise.all(k)).find(w=>w!==0);I===null&&(I=typeof H<"u"?1:I),(this.topological||this.topologicalDev)&&typeof H<"u"&&g.reportError(_e.MessageName.UNNAMED,"The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph")}});return I!==null?I:K.exitCode()}};pe.paths=[["workspaces","foreach"]],pe.usage=U.Command.Usage({category:"Workspace-related commands",description:"run a command on all workspaces",details:"\n This command will run a given sub-command on current and all its descendant workspaces. Various flags can alter the exact behavior of the command:\n\n - If `-p,--parallel` is set, the commands will be ran in parallel; they'll by default be limited to a number of parallel tasks roughly equal to half your core number, but that can be overridden via `-j,--jobs`, or disabled by setting `-j unlimited`.\n\n - If `-p,--parallel` and `-i,--interlaced` are both set, Yarn will print the lines from the output as it receives them. If `-i,--interlaced` wasn't set, it would instead buffer the output from each process and print the resulting buffers only after their source processes have exited.\n\n - If `-t,--topological` is set, Yarn will only run the command after all workspaces that it depends on through the `dependencies` field have successfully finished executing. If `--topological-dev` is set, both the `dependencies` and `devDependencies` fields will be considered when figuring out the wait points.\n\n - If `-A,--all` is set, Yarn will run the command on all the workspaces of a project. By default yarn runs the command only on current and all its descendant workspaces.\n\n - If `-R,--recursive` is set, Yarn will find workspaces to run the command on by recursively evaluating `dependencies` and `devDependencies` fields, instead of looking at the `workspaces` fields.\n\n - If `--from` is set, Yarn will use the packages matching the 'from' glob as the starting point for any recursive search.\n\n - If `--since` is set, Yarn will only run the command on workspaces that have been modified since the specified ref. By default Yarn will use the refs specified by the `changesetBaseRefs` configuration option.\n\n - The command may apply to only some workspaces through the use of `--include` which acts as a whitelist. The `--exclude` flag will do the opposite and will be a list of packages that mustn't execute the script. Both flags accept glob patterns (if valid Idents and supported by [micromatch](https://github.com/micromatch/micromatch)). Make sure to escape the patterns, to prevent your own shell from trying to expand them.\n\n Adding the `-v,--verbose` flag will cause Yarn to print more information; in particular the name of the workspace that generated the output will be printed at the front of each line.\n\n If the command is `run` and the script being run does not exist the child workspace will be skipped without error.\n ",examples:[["Publish current and all descendant packages","yarn workspaces foreach npm publish --tolerate-republish"],["Run build script on current and all descendant packages","yarn workspaces foreach run build"],["Run build script on current and all descendant packages in parallel, building package dependencies first","yarn workspaces foreach -pt run build"],["Run build script on several packages and all their dependencies, building dependencies first","yarn workspaces foreach -ptR --from '{workspace-a,workspace-b}' run build"]]});function dr(e,{prefix:r,interlaced:t}){let n=e.createStreamReporter(r),s=new Y.miscUtils.DefaultStream;s.pipe(n,{end:!1}),s.on("finish",()=>{n.end()});let i=new Promise(c=>{n.on("finish",()=>{c(s.active)})});if(t)return[s,i];let a=new Y.miscUtils.BufferStream;return a.pipe(s,{end:!1}),a.on("finish",()=>{s.end()}),[a,i]}function Kn(e,{configuration:r,commandIndex:t,verbose:n}){if(!n)return null;let i=`[${Y.structUtils.stringifyIdent(e.locator)}]:`,a=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],c=a[t%a.length];return Y.formatUtils.pretty(r,i,c)}var Wn={commands:[ce,pe]},jn=Wn;return Sr(Fn);})(); +/*! + * fill-range + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Licensed under the MIT License. + */ +/*! + * is-number + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Released under the MIT License. + */ +/*! + * to-regex-range + * + * Copyright (c) 2015-present, Jon Schlinkert. + * Released under the MIT License. + */ +return plugin; +} +}; diff --git a/.yarn/releases/yarn-3.3.0.cjs b/.yarn/releases/yarn-3.3.0.cjs new file mode 100755 index 0000000..47f24f6 --- /dev/null +++ b/.yarn/releases/yarn-3.3.0.cjs @@ -0,0 +1,807 @@ +#!/usr/bin/env node +/* eslint-disable */ +//prettier-ignore +(()=>{var lfe=Object.create;var GS=Object.defineProperty;var cfe=Object.getOwnPropertyDescriptor;var ufe=Object.getOwnPropertyNames;var gfe=Object.getPrototypeOf,ffe=Object.prototype.hasOwnProperty;var J=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var y=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ht=(r,e)=>{for(var t in e)GS(r,t,{get:e[t],enumerable:!0})},hfe=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ufe(e))!ffe.call(r,n)&&n!==t&&GS(r,n,{get:()=>e[n],enumerable:!(i=cfe(e,n))||i.enumerable});return r};var ne=(r,e,t)=>(t=r!=null?lfe(gfe(r)):{},hfe(e||!r||!r.__esModule?GS(t,"default",{value:r,enumerable:!0}):t,r));var iU=y((iZe,rU)=>{rU.exports=tU;tU.sync=Lfe;var $1=J("fs");function Nfe(r,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var i=0;i{aU.exports=sU;sU.sync=Tfe;var nU=J("fs");function sU(r,e,t){nU.stat(r,function(i,n){t(i,i?!1:oU(n,e))})}function Tfe(r,e){return oU(nU.statSync(r),e)}function oU(r,e){return r.isFile()&&Ofe(r,e)}function Ofe(r,e){var t=r.mode,i=r.uid,n=r.gid,s=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8),c=parseInt("001",8),u=a|l,g=t&c||t&l&&n===o||t&a&&i===s||t&u&&s===0;return g}});var cU=y((oZe,lU)=>{var sZe=J("fs"),LI;process.platform==="win32"||global.TESTING_WINDOWS?LI=iU():LI=AU();lU.exports=sv;sv.sync=Mfe;function sv(r,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){sv(r,e||{},function(s,o){s?n(s):i(o)})})}LI(r,e||{},function(i,n){i&&(i.code==="EACCES"||e&&e.ignoreErrors)&&(i=null,n=!1),t(i,n)})}function Mfe(r,e){try{return LI.sync(r,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var CU=y((aZe,dU)=>{var Xg=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",uU=J("path"),Kfe=Xg?";":":",gU=cU(),fU=r=>Object.assign(new Error(`not found: ${r}`),{code:"ENOENT"}),hU=(r,e)=>{let t=e.colon||Kfe,i=r.match(/\//)||Xg&&r.match(/\\/)?[""]:[...Xg?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],n=Xg?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Xg?n.split(t):[""];return Xg&&r.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:i,pathExt:s,pathExtExe:n}},pU=(r,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:i,pathExt:n,pathExtExe:s}=hU(r,e),o=[],a=c=>new Promise((u,g)=>{if(c===i.length)return e.all&&o.length?u(o):g(fU(r));let f=i[c],h=/^".*"$/.test(f)?f.slice(1,-1):f,p=uU.join(h,r),C=!h&&/^\.[\\\/]/.test(r)?r.slice(0,2)+p:p;u(l(C,c,0))}),l=(c,u,g)=>new Promise((f,h)=>{if(g===n.length)return f(a(u+1));let p=n[g];gU(c+p,{pathExt:s},(C,w)=>{if(!C&&w)if(e.all)o.push(c+p);else return f(c+p);return f(l(c,u,g+1))})});return t?a(0).then(c=>t(null,c),t):a(0)},Ufe=(r,e)=>{e=e||{};let{pathEnv:t,pathExt:i,pathExtExe:n}=hU(r,e),s=[];for(let o=0;o{"use strict";var mU=(r={})=>{let e=r.env||process.env;return(r.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};ov.exports=mU;ov.exports.default=mU});var BU=y((lZe,wU)=>{"use strict";var IU=J("path"),Hfe=CU(),Gfe=EU();function yU(r,e){let t=r.options.env||process.env,i=process.cwd(),n=r.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(r.options.cwd)}catch{}let o;try{o=Hfe.sync(r.command,{path:t[Gfe({env:t})],pathExt:e?IU.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=IU.resolve(n?r.options.cwd:"",o)),o}function Yfe(r){return yU(r)||yU(r,!0)}wU.exports=Yfe});var QU=y((cZe,Av)=>{"use strict";var av=/([()\][%!^"`<>&|;, *?])/g;function jfe(r){return r=r.replace(av,"^$1"),r}function qfe(r,e){return r=`${r}`,r=r.replace(/(\\*)"/g,'$1$1\\"'),r=r.replace(/(\\*)$/,"$1$1"),r=`"${r}"`,r=r.replace(av,"^$1"),e&&(r=r.replace(av,"^$1")),r}Av.exports.command=jfe;Av.exports.argument=qfe});var SU=y((uZe,bU)=>{"use strict";bU.exports=/^#!(.*)/});var xU=y((gZe,vU)=>{"use strict";var Jfe=SU();vU.exports=(r="")=>{let e=r.match(Jfe);if(!e)return null;let[t,i]=e[0].replace(/#! ?/,"").split(" "),n=t.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var DU=y((fZe,PU)=>{"use strict";var lv=J("fs"),Wfe=xU();function zfe(r){let t=Buffer.alloc(150),i;try{i=lv.openSync(r,"r"),lv.readSync(i,t,0,150,0),lv.closeSync(i)}catch{}return Wfe(t.toString())}PU.exports=zfe});var NU=y((hZe,FU)=>{"use strict";var Vfe=J("path"),kU=BU(),RU=QU(),Xfe=DU(),_fe=process.platform==="win32",Zfe=/\.(?:com|exe)$/i,$fe=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ehe(r){r.file=kU(r);let e=r.file&&Xfe(r.file);return e?(r.args.unshift(r.file),r.command=e,kU(r)):r.file}function the(r){if(!_fe)return r;let e=ehe(r),t=!Zfe.test(e);if(r.options.forceShell||t){let i=$fe.test(e);r.command=Vfe.normalize(r.command),r.command=RU.command(r.command),r.args=r.args.map(s=>RU.argument(s,i));let n=[r.command].concat(r.args).join(" ");r.args=["/d","/s","/c",`"${n}"`],r.command=process.env.comspec||"cmd.exe",r.options.windowsVerbatimArguments=!0}return r}function rhe(r,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let i={command:r,args:e,options:t,file:void 0,original:{command:r,args:e}};return t.shell?i:the(i)}FU.exports=rhe});var OU=y((pZe,TU)=>{"use strict";var cv=process.platform==="win32";function uv(r,e){return Object.assign(new Error(`${e} ${r.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${r.command}`,path:r.command,spawnargs:r.args})}function ihe(r,e){if(!cv)return;let t=r.emit;r.emit=function(i,n){if(i==="exit"){let s=LU(n,e,"spawn");if(s)return t.call(r,"error",s)}return t.apply(r,arguments)}}function LU(r,e){return cv&&r===1&&!e.file?uv(e.original,"spawn"):null}function nhe(r,e){return cv&&r===1&&!e.file?uv(e.original,"spawnSync"):null}TU.exports={hookChildProcess:ihe,verifyENOENT:LU,verifyENOENTSync:nhe,notFoundError:uv}});var hv=y((dZe,_g)=>{"use strict";var MU=J("child_process"),gv=NU(),fv=OU();function KU(r,e,t){let i=gv(r,e,t),n=MU.spawn(i.command,i.args,i.options);return fv.hookChildProcess(n,i),n}function she(r,e,t){let i=gv(r,e,t),n=MU.spawnSync(i.command,i.args,i.options);return n.error=n.error||fv.verifyENOENTSync(n.status,i),n}_g.exports=KU;_g.exports.spawn=KU;_g.exports.sync=she;_g.exports._parse=gv;_g.exports._enoent=fv});var HU=y((CZe,UU)=>{"use strict";function ohe(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function cc(r,e,t,i){this.message=r,this.expected=e,this.found=t,this.location=i,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,cc)}ohe(cc,Error);cc.buildMessage=function(r,e){var t={literal:function(c){return'"'+n(c.text)+'"'},class:function(c){var u="",g;for(g=0;g0){for(g=1,f=1;g>",re=de(">>",!1),me=">&",tt=de(">&",!1),Rt=">",It=de(">",!1),Kr="<<<",oi=de("<<<",!1),pi="<&",pr=de("<&",!1),di="<",ai=de("<",!1),Os=function(m){return{type:"argument",segments:[].concat(...m)}},dr=function(m){return m},Bi="$'",_n=de("$'",!1),ha="'",mA=de("'",!1),Dg=function(m){return[{type:"text",text:m}]},Zn='""',EA=de('""',!1),pa=function(){return{type:"text",text:""}},jp='"',IA=de('"',!1),yA=function(m){return m},Br=function(m){return{type:"arithmetic",arithmetic:m,quoted:!0}},zl=function(m){return{type:"shell",shell:m,quoted:!0}},kg=function(m){return{type:"variable",...m,quoted:!0}},Eo=function(m){return{type:"text",text:m}},Rg=function(m){return{type:"arithmetic",arithmetic:m,quoted:!1}},qp=function(m){return{type:"shell",shell:m,quoted:!1}},Jp=function(m){return{type:"variable",...m,quoted:!1}},xr=function(m){return{type:"glob",pattern:m}},oe=/^[^']/,Io=Ye(["'"],!0,!1),kn=function(m){return m.join("")},Fg=/^[^$"]/,Qt=Ye(["$",'"'],!0,!1),Vl=`\\ +`,Rn=de(`\\ +`,!1),$n=function(){return""},es="\\",ut=de("\\",!1),yo=/^[\\$"`]/,at=Ye(["\\","$",'"',"`"],!1,!1),ln=function(m){return m},S="\\a",Tt=de("\\a",!1),Ng=function(){return"a"},Xl="\\b",Wp=de("\\b",!1),zp=function(){return"\b"},Vp=/^[Ee]/,Xp=Ye(["E","e"],!1,!1),_p=function(){return"\x1B"},G="\\f",yt=de("\\f",!1),wA=function(){return"\f"},Wi="\\n",_l=de("\\n",!1),We=function(){return` +`},da="\\r",Lg=de("\\r",!1),lI=function(){return"\r"},Zp="\\t",cI=de("\\t",!1),ar=function(){return" "},Fn="\\v",Zl=de("\\v",!1),$p=function(){return"\v"},Ms=/^[\\'"?]/,Ca=Ye(["\\","'",'"',"?"],!1,!1),cn=function(m){return String.fromCharCode(parseInt(m,16))},De="\\x",Tg=de("\\x",!1),$l="\\u",Ks=de("\\u",!1),ec="\\U",BA=de("\\U",!1),Og=function(m){return String.fromCodePoint(parseInt(m,16))},Mg=/^[0-7]/,ma=Ye([["0","7"]],!1,!1),Ea=/^[0-9a-fA-f]/,$e=Ye([["0","9"],["a","f"],["A","f"]],!1,!1),wo=rt(),QA="-",tc=de("-",!1),Us="+",rc=de("+",!1),uI=".",ed=de(".",!1),Kg=function(m,b,F){return{type:"number",value:(m==="-"?-1:1)*parseFloat(b.join("")+"."+F.join(""))}},td=function(m,b){return{type:"number",value:(m==="-"?-1:1)*parseInt(b.join(""))}},gI=function(m){return{type:"variable",...m}},ic=function(m){return{type:"variable",name:m}},fI=function(m){return m},Ug="*",bA=de("*",!1),Fr="/",hI=de("/",!1),Hs=function(m,b,F){return{type:b==="*"?"multiplication":"division",right:F}},Gs=function(m,b){return b.reduce((F,U)=>({left:F,...U}),m)},Hg=function(m,b,F){return{type:b==="+"?"addition":"subtraction",right:F}},SA="$((",R=de("$((",!1),q="))",pe=de("))",!1),Ne=function(m){return m},xe="$(",qe=de("$(",!1),dt=function(m){return m},Ft="${",Nn=de("${",!1),bS=":-",s1=de(":-",!1),o1=function(m,b){return{name:m,defaultValue:b}},SS=":-}",a1=de(":-}",!1),A1=function(m){return{name:m,defaultValue:[]}},vS=":+",l1=de(":+",!1),c1=function(m,b){return{name:m,alternativeValue:b}},xS=":+}",u1=de(":+}",!1),g1=function(m){return{name:m,alternativeValue:[]}},PS=function(m){return{name:m}},f1="$",h1=de("$",!1),p1=function(m){return e.isGlobPattern(m)},d1=function(m){return m},DS=/^[a-zA-Z0-9_]/,kS=Ye([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),RS=function(){return O()},FS=/^[$@*?#a-zA-Z0-9_\-]/,NS=Ye(["$","@","*","?","#",["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),C1=/^[(){}<>$|&; \t"']/,Gg=Ye(["(",")","{","}","<",">","$","|","&",";"," "," ",'"',"'"],!1,!1),LS=/^[<>&; \t"']/,TS=Ye(["<",">","&",";"," "," ",'"',"'"],!1,!1),pI=/^[ \t]/,dI=Ye([" "," "],!1,!1),Q=0,Re=0,vA=[{line:1,column:1}],d=0,E=[],I=0,k;if("startRule"in e){if(!(e.startRule in i))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');n=i[e.startRule]}function O(){return r.substring(Re,Q)}function X(){return Et(Re,Q)}function te(m,b){throw b=b!==void 0?b:Et(Re,Q),Fi([At(m)],r.substring(Re,Q),b)}function ye(m,b){throw b=b!==void 0?b:Et(Re,Q),Ln(m,b)}function de(m,b){return{type:"literal",text:m,ignoreCase:b}}function Ye(m,b,F){return{type:"class",parts:m,inverted:b,ignoreCase:F}}function rt(){return{type:"any"}}function wt(){return{type:"end"}}function At(m){return{type:"other",description:m}}function et(m){var b=vA[m],F;if(b)return b;for(F=m-1;!vA[F];)F--;for(b=vA[F],b={line:b.line,column:b.column};Fd&&(d=Q,E=[]),E.push(m))}function Ln(m,b){return new cc(m,null,null,b)}function Fi(m,b,F){return new cc(cc.buildMessage(m,b),m,b,F)}function xA(){var m,b;return m=Q,b=Ur(),b===t&&(b=null),b!==t&&(Re=m,b=s(b)),m=b,m}function Ur(){var m,b,F,U,ce;if(m=Q,b=Hr(),b!==t){for(F=[],U=Me();U!==t;)F.push(U),U=Me();F!==t?(U=Ia(),U!==t?(ce=ts(),ce===t&&(ce=null),ce!==t?(Re=m,b=o(b,U,ce),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)}else Q=m,m=t;if(m===t)if(m=Q,b=Hr(),b!==t){for(F=[],U=Me();U!==t;)F.push(U),U=Me();F!==t?(U=Ia(),U===t&&(U=null),U!==t?(Re=m,b=a(b,U),m=b):(Q=m,m=t)):(Q=m,m=t)}else Q=m,m=t;return m}function ts(){var m,b,F,U,ce;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t)if(F=Ur(),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();U!==t?(Re=m,b=l(F),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t;return m}function Ia(){var m;return r.charCodeAt(Q)===59?(m=c,Q++):(m=t,I===0&&Be(u)),m===t&&(r.charCodeAt(Q)===38?(m=g,Q++):(m=t,I===0&&Be(f))),m}function Hr(){var m,b,F;return m=Q,b=m1(),b!==t?(F=Jge(),F===t&&(F=null),F!==t?(Re=m,b=h(b,F),m=b):(Q=m,m=t)):(Q=m,m=t),m}function Jge(){var m,b,F,U,ce,be,ft;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t)if(F=Wge(),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();if(U!==t)if(ce=Hr(),ce!==t){for(be=[],ft=Me();ft!==t;)be.push(ft),ft=Me();be!==t?(Re=m,b=p(F,ce),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t;return m}function Wge(){var m;return r.substr(Q,2)===C?(m=C,Q+=2):(m=t,I===0&&Be(w)),m===t&&(r.substr(Q,2)===B?(m=B,Q+=2):(m=t,I===0&&Be(v))),m}function m1(){var m,b,F;return m=Q,b=Xge(),b!==t?(F=zge(),F===t&&(F=null),F!==t?(Re=m,b=D(b,F),m=b):(Q=m,m=t)):(Q=m,m=t),m}function zge(){var m,b,F,U,ce,be,ft;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t)if(F=Vge(),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();if(U!==t)if(ce=m1(),ce!==t){for(be=[],ft=Me();ft!==t;)be.push(ft),ft=Me();be!==t?(Re=m,b=L(F,ce),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t;return m}function Vge(){var m;return r.substr(Q,2)===H?(m=H,Q+=2):(m=t,I===0&&Be(j)),m===t&&(r.charCodeAt(Q)===124?(m=$,Q++):(m=t,I===0&&Be(V))),m}function CI(){var m,b,F,U,ce,be;if(m=Q,b=D1(),b!==t)if(r.charCodeAt(Q)===61?(F=W,Q++):(F=t,I===0&&Be(Z)),F!==t)if(U=y1(),U!==t){for(ce=[],be=Me();be!==t;)ce.push(be),be=Me();ce!==t?(Re=m,b=A(b,U),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t;else Q=m,m=t;if(m===t)if(m=Q,b=D1(),b!==t)if(r.charCodeAt(Q)===61?(F=W,Q++):(F=t,I===0&&Be(Z)),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();U!==t?(Re=m,b=ae(b),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t;return m}function Xge(){var m,b,F,U,ce,be,ft,Bt,Vr,Ci,rs;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t)if(r.charCodeAt(Q)===40?(F=ge,Q++):(F=t,I===0&&Be(_)),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();if(U!==t)if(ce=Ur(),ce!==t){for(be=[],ft=Me();ft!==t;)be.push(ft),ft=Me();if(be!==t)if(r.charCodeAt(Q)===41?(ft=T,Q++):(ft=t,I===0&&Be(N)),ft!==t){for(Bt=[],Vr=Me();Vr!==t;)Bt.push(Vr),Vr=Me();if(Bt!==t){for(Vr=[],Ci=rd();Ci!==t;)Vr.push(Ci),Ci=rd();if(Vr!==t){for(Ci=[],rs=Me();rs!==t;)Ci.push(rs),rs=Me();Ci!==t?(Re=m,b=ue(ce,Vr),m=b):(Q=m,m=t)}else Q=m,m=t}else Q=m,m=t}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t;if(m===t){for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t)if(r.charCodeAt(Q)===123?(F=we,Q++):(F=t,I===0&&Be(Le)),F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();if(U!==t)if(ce=Ur(),ce!==t){for(be=[],ft=Me();ft!==t;)be.push(ft),ft=Me();if(be!==t)if(r.charCodeAt(Q)===125?(ft=Pe,Q++):(ft=t,I===0&&Be(Te)),ft!==t){for(Bt=[],Vr=Me();Vr!==t;)Bt.push(Vr),Vr=Me();if(Bt!==t){for(Vr=[],Ci=rd();Ci!==t;)Vr.push(Ci),Ci=rd();if(Vr!==t){for(Ci=[],rs=Me();rs!==t;)Ci.push(rs),rs=Me();Ci!==t?(Re=m,b=se(ce,Vr),m=b):(Q=m,m=t)}else Q=m,m=t}else Q=m,m=t}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;else Q=m,m=t;if(m===t){for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t){for(F=[],U=CI();U!==t;)F.push(U),U=CI();if(F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();if(U!==t){if(ce=[],be=I1(),be!==t)for(;be!==t;)ce.push(be),be=I1();else ce=t;if(ce!==t){for(be=[],ft=Me();ft!==t;)be.push(ft),ft=Me();be!==t?(Re=m,b=Ae(F,ce),m=b):(Q=m,m=t)}else Q=m,m=t}else Q=m,m=t}else Q=m,m=t}else Q=m,m=t;if(m===t){for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t){if(F=[],U=CI(),U!==t)for(;U!==t;)F.push(U),U=CI();else F=t;if(F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();U!==t?(Re=m,b=Qe(F),m=b):(Q=m,m=t)}else Q=m,m=t}else Q=m,m=t}}}return m}function E1(){var m,b,F,U,ce;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t){if(F=[],U=mI(),U!==t)for(;U!==t;)F.push(U),U=mI();else F=t;if(F!==t){for(U=[],ce=Me();ce!==t;)U.push(ce),ce=Me();U!==t?(Re=m,b=fe(F),m=b):(Q=m,m=t)}else Q=m,m=t}else Q=m,m=t;return m}function I1(){var m,b,F;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();if(b!==t?(F=rd(),F!==t?(Re=m,b=le(F),m=b):(Q=m,m=t)):(Q=m,m=t),m===t){for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();b!==t?(F=mI(),F!==t?(Re=m,b=le(F),m=b):(Q=m,m=t)):(Q=m,m=t)}return m}function rd(){var m,b,F,U,ce;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();return b!==t?(Ge.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(ie)),F===t&&(F=null),F!==t?(U=_ge(),U!==t?(ce=mI(),ce!==t?(Re=m,b=Y(F,U,ce),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m}function _ge(){var m;return r.substr(Q,2)===he?(m=he,Q+=2):(m=t,I===0&&Be(re)),m===t&&(r.substr(Q,2)===me?(m=me,Q+=2):(m=t,I===0&&Be(tt)),m===t&&(r.charCodeAt(Q)===62?(m=Rt,Q++):(m=t,I===0&&Be(It)),m===t&&(r.substr(Q,3)===Kr?(m=Kr,Q+=3):(m=t,I===0&&Be(oi)),m===t&&(r.substr(Q,2)===pi?(m=pi,Q+=2):(m=t,I===0&&Be(pr)),m===t&&(r.charCodeAt(Q)===60?(m=di,Q++):(m=t,I===0&&Be(ai))))))),m}function mI(){var m,b,F;for(m=Q,b=[],F=Me();F!==t;)b.push(F),F=Me();return b!==t?(F=y1(),F!==t?(Re=m,b=le(F),m=b):(Q=m,m=t)):(Q=m,m=t),m}function y1(){var m,b,F;if(m=Q,b=[],F=w1(),F!==t)for(;F!==t;)b.push(F),F=w1();else b=t;return b!==t&&(Re=m,b=Os(b)),m=b,m}function w1(){var m,b;return m=Q,b=Zge(),b!==t&&(Re=m,b=dr(b)),m=b,m===t&&(m=Q,b=$ge(),b!==t&&(Re=m,b=dr(b)),m=b,m===t&&(m=Q,b=efe(),b!==t&&(Re=m,b=dr(b)),m=b,m===t&&(m=Q,b=tfe(),b!==t&&(Re=m,b=dr(b)),m=b))),m}function Zge(){var m,b,F,U;return m=Q,r.substr(Q,2)===Bi?(b=Bi,Q+=2):(b=t,I===0&&Be(_n)),b!==t?(F=nfe(),F!==t?(r.charCodeAt(Q)===39?(U=ha,Q++):(U=t,I===0&&Be(mA)),U!==t?(Re=m,b=Dg(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m}function $ge(){var m,b,F,U;return m=Q,r.charCodeAt(Q)===39?(b=ha,Q++):(b=t,I===0&&Be(mA)),b!==t?(F=rfe(),F!==t?(r.charCodeAt(Q)===39?(U=ha,Q++):(U=t,I===0&&Be(mA)),U!==t?(Re=m,b=Dg(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m}function efe(){var m,b,F,U;if(m=Q,r.substr(Q,2)===Zn?(b=Zn,Q+=2):(b=t,I===0&&Be(EA)),b!==t&&(Re=m,b=pa()),m=b,m===t)if(m=Q,r.charCodeAt(Q)===34?(b=jp,Q++):(b=t,I===0&&Be(IA)),b!==t){for(F=[],U=B1();U!==t;)F.push(U),U=B1();F!==t?(r.charCodeAt(Q)===34?(U=jp,Q++):(U=t,I===0&&Be(IA)),U!==t?(Re=m,b=yA(F),m=b):(Q=m,m=t)):(Q=m,m=t)}else Q=m,m=t;return m}function tfe(){var m,b,F;if(m=Q,b=[],F=Q1(),F!==t)for(;F!==t;)b.push(F),F=Q1();else b=t;return b!==t&&(Re=m,b=yA(b)),m=b,m}function B1(){var m,b;return m=Q,b=x1(),b!==t&&(Re=m,b=Br(b)),m=b,m===t&&(m=Q,b=P1(),b!==t&&(Re=m,b=zl(b)),m=b,m===t&&(m=Q,b=US(),b!==t&&(Re=m,b=kg(b)),m=b,m===t&&(m=Q,b=ife(),b!==t&&(Re=m,b=Eo(b)),m=b))),m}function Q1(){var m,b;return m=Q,b=x1(),b!==t&&(Re=m,b=Rg(b)),m=b,m===t&&(m=Q,b=P1(),b!==t&&(Re=m,b=qp(b)),m=b,m===t&&(m=Q,b=US(),b!==t&&(Re=m,b=Jp(b)),m=b,m===t&&(m=Q,b=afe(),b!==t&&(Re=m,b=xr(b)),m=b,m===t&&(m=Q,b=ofe(),b!==t&&(Re=m,b=Eo(b)),m=b)))),m}function rfe(){var m,b,F;for(m=Q,b=[],oe.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Io));F!==t;)b.push(F),oe.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Io));return b!==t&&(Re=m,b=kn(b)),m=b,m}function ife(){var m,b,F;if(m=Q,b=[],F=b1(),F===t&&(Fg.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Qt))),F!==t)for(;F!==t;)b.push(F),F=b1(),F===t&&(Fg.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Qt)));else b=t;return b!==t&&(Re=m,b=kn(b)),m=b,m}function b1(){var m,b,F;return m=Q,r.substr(Q,2)===Vl?(b=Vl,Q+=2):(b=t,I===0&&Be(Rn)),b!==t&&(Re=m,b=$n()),m=b,m===t&&(m=Q,r.charCodeAt(Q)===92?(b=es,Q++):(b=t,I===0&&Be(ut)),b!==t?(yo.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(at)),F!==t?(Re=m,b=ln(F),m=b):(Q=m,m=t)):(Q=m,m=t)),m}function nfe(){var m,b,F;for(m=Q,b=[],F=S1(),F===t&&(oe.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Io)));F!==t;)b.push(F),F=S1(),F===t&&(oe.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Io)));return b!==t&&(Re=m,b=kn(b)),m=b,m}function S1(){var m,b,F;return m=Q,r.substr(Q,2)===S?(b=S,Q+=2):(b=t,I===0&&Be(Tt)),b!==t&&(Re=m,b=Ng()),m=b,m===t&&(m=Q,r.substr(Q,2)===Xl?(b=Xl,Q+=2):(b=t,I===0&&Be(Wp)),b!==t&&(Re=m,b=zp()),m=b,m===t&&(m=Q,r.charCodeAt(Q)===92?(b=es,Q++):(b=t,I===0&&Be(ut)),b!==t?(Vp.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Xp)),F!==t?(Re=m,b=_p(),m=b):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===G?(b=G,Q+=2):(b=t,I===0&&Be(yt)),b!==t&&(Re=m,b=wA()),m=b,m===t&&(m=Q,r.substr(Q,2)===Wi?(b=Wi,Q+=2):(b=t,I===0&&Be(_l)),b!==t&&(Re=m,b=We()),m=b,m===t&&(m=Q,r.substr(Q,2)===da?(b=da,Q+=2):(b=t,I===0&&Be(Lg)),b!==t&&(Re=m,b=lI()),m=b,m===t&&(m=Q,r.substr(Q,2)===Zp?(b=Zp,Q+=2):(b=t,I===0&&Be(cI)),b!==t&&(Re=m,b=ar()),m=b,m===t&&(m=Q,r.substr(Q,2)===Fn?(b=Fn,Q+=2):(b=t,I===0&&Be(Zl)),b!==t&&(Re=m,b=$p()),m=b,m===t&&(m=Q,r.charCodeAt(Q)===92?(b=es,Q++):(b=t,I===0&&Be(ut)),b!==t?(Ms.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(Ca)),F!==t?(Re=m,b=ln(F),m=b):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=sfe()))))))))),m}function sfe(){var m,b,F,U,ce,be,ft,Bt,Vr,Ci,rs,HS;return m=Q,r.charCodeAt(Q)===92?(b=es,Q++):(b=t,I===0&&Be(ut)),b!==t?(F=OS(),F!==t?(Re=m,b=cn(F),m=b):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===De?(b=De,Q+=2):(b=t,I===0&&Be(Tg)),b!==t?(F=Q,U=Q,ce=OS(),ce!==t?(be=Tn(),be!==t?(ce=[ce,be],U=ce):(Q=U,U=t)):(Q=U,U=t),U===t&&(U=OS()),U!==t?F=r.substring(F,Q):F=U,F!==t?(Re=m,b=cn(F),m=b):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===$l?(b=$l,Q+=2):(b=t,I===0&&Be(Ks)),b!==t?(F=Q,U=Q,ce=Tn(),ce!==t?(be=Tn(),be!==t?(ft=Tn(),ft!==t?(Bt=Tn(),Bt!==t?(ce=[ce,be,ft,Bt],U=ce):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t),U!==t?F=r.substring(F,Q):F=U,F!==t?(Re=m,b=cn(F),m=b):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===ec?(b=ec,Q+=2):(b=t,I===0&&Be(BA)),b!==t?(F=Q,U=Q,ce=Tn(),ce!==t?(be=Tn(),be!==t?(ft=Tn(),ft!==t?(Bt=Tn(),Bt!==t?(Vr=Tn(),Vr!==t?(Ci=Tn(),Ci!==t?(rs=Tn(),rs!==t?(HS=Tn(),HS!==t?(ce=[ce,be,ft,Bt,Vr,Ci,rs,HS],U=ce):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t)):(Q=U,U=t),U!==t?F=r.substring(F,Q):F=U,F!==t?(Re=m,b=Og(F),m=b):(Q=m,m=t)):(Q=m,m=t)))),m}function OS(){var m;return Mg.test(r.charAt(Q))?(m=r.charAt(Q),Q++):(m=t,I===0&&Be(ma)),m}function Tn(){var m;return Ea.test(r.charAt(Q))?(m=r.charAt(Q),Q++):(m=t,I===0&&Be($e)),m}function ofe(){var m,b,F,U,ce;if(m=Q,b=[],F=Q,r.charCodeAt(Q)===92?(U=es,Q++):(U=t,I===0&&Be(ut)),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t),F===t&&(F=Q,U=Q,I++,ce=k1(),I--,ce===t?U=void 0:(Q=U,U=t),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t)),F!==t)for(;F!==t;)b.push(F),F=Q,r.charCodeAt(Q)===92?(U=es,Q++):(U=t,I===0&&Be(ut)),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t),F===t&&(F=Q,U=Q,I++,ce=k1(),I--,ce===t?U=void 0:(Q=U,U=t),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t));else b=t;return b!==t&&(Re=m,b=kn(b)),m=b,m}function MS(){var m,b,F,U,ce,be;if(m=Q,r.charCodeAt(Q)===45?(b=QA,Q++):(b=t,I===0&&Be(tc)),b===t&&(r.charCodeAt(Q)===43?(b=Us,Q++):(b=t,I===0&&Be(rc))),b===t&&(b=null),b!==t){if(F=[],Ge.test(r.charAt(Q))?(U=r.charAt(Q),Q++):(U=t,I===0&&Be(ie)),U!==t)for(;U!==t;)F.push(U),Ge.test(r.charAt(Q))?(U=r.charAt(Q),Q++):(U=t,I===0&&Be(ie));else F=t;if(F!==t)if(r.charCodeAt(Q)===46?(U=uI,Q++):(U=t,I===0&&Be(ed)),U!==t){if(ce=[],Ge.test(r.charAt(Q))?(be=r.charAt(Q),Q++):(be=t,I===0&&Be(ie)),be!==t)for(;be!==t;)ce.push(be),Ge.test(r.charAt(Q))?(be=r.charAt(Q),Q++):(be=t,I===0&&Be(ie));else ce=t;ce!==t?(Re=m,b=Kg(b,F,ce),m=b):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;if(m===t){if(m=Q,r.charCodeAt(Q)===45?(b=QA,Q++):(b=t,I===0&&Be(tc)),b===t&&(r.charCodeAt(Q)===43?(b=Us,Q++):(b=t,I===0&&Be(rc))),b===t&&(b=null),b!==t){if(F=[],Ge.test(r.charAt(Q))?(U=r.charAt(Q),Q++):(U=t,I===0&&Be(ie)),U!==t)for(;U!==t;)F.push(U),Ge.test(r.charAt(Q))?(U=r.charAt(Q),Q++):(U=t,I===0&&Be(ie));else F=t;F!==t?(Re=m,b=td(b,F),m=b):(Q=m,m=t)}else Q=m,m=t;if(m===t&&(m=Q,b=US(),b!==t&&(Re=m,b=gI(b)),m=b,m===t&&(m=Q,b=nc(),b!==t&&(Re=m,b=ic(b)),m=b,m===t)))if(m=Q,r.charCodeAt(Q)===40?(b=ge,Q++):(b=t,I===0&&Be(_)),b!==t){for(F=[],U=Me();U!==t;)F.push(U),U=Me();if(F!==t)if(U=v1(),U!==t){for(ce=[],be=Me();be!==t;)ce.push(be),be=Me();ce!==t?(r.charCodeAt(Q)===41?(be=T,Q++):(be=t,I===0&&Be(N)),be!==t?(Re=m,b=fI(U),m=b):(Q=m,m=t)):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t}return m}function KS(){var m,b,F,U,ce,be,ft,Bt;if(m=Q,b=MS(),b!==t){for(F=[],U=Q,ce=[],be=Me();be!==t;)ce.push(be),be=Me();if(ce!==t)if(r.charCodeAt(Q)===42?(be=Ug,Q++):(be=t,I===0&&Be(bA)),be===t&&(r.charCodeAt(Q)===47?(be=Fr,Q++):(be=t,I===0&&Be(hI))),be!==t){for(ft=[],Bt=Me();Bt!==t;)ft.push(Bt),Bt=Me();ft!==t?(Bt=MS(),Bt!==t?(Re=U,ce=Hs(b,be,Bt),U=ce):(Q=U,U=t)):(Q=U,U=t)}else Q=U,U=t;else Q=U,U=t;for(;U!==t;){for(F.push(U),U=Q,ce=[],be=Me();be!==t;)ce.push(be),be=Me();if(ce!==t)if(r.charCodeAt(Q)===42?(be=Ug,Q++):(be=t,I===0&&Be(bA)),be===t&&(r.charCodeAt(Q)===47?(be=Fr,Q++):(be=t,I===0&&Be(hI))),be!==t){for(ft=[],Bt=Me();Bt!==t;)ft.push(Bt),Bt=Me();ft!==t?(Bt=MS(),Bt!==t?(Re=U,ce=Hs(b,be,Bt),U=ce):(Q=U,U=t)):(Q=U,U=t)}else Q=U,U=t;else Q=U,U=t}F!==t?(Re=m,b=Gs(b,F),m=b):(Q=m,m=t)}else Q=m,m=t;return m}function v1(){var m,b,F,U,ce,be,ft,Bt;if(m=Q,b=KS(),b!==t){for(F=[],U=Q,ce=[],be=Me();be!==t;)ce.push(be),be=Me();if(ce!==t)if(r.charCodeAt(Q)===43?(be=Us,Q++):(be=t,I===0&&Be(rc)),be===t&&(r.charCodeAt(Q)===45?(be=QA,Q++):(be=t,I===0&&Be(tc))),be!==t){for(ft=[],Bt=Me();Bt!==t;)ft.push(Bt),Bt=Me();ft!==t?(Bt=KS(),Bt!==t?(Re=U,ce=Hg(b,be,Bt),U=ce):(Q=U,U=t)):(Q=U,U=t)}else Q=U,U=t;else Q=U,U=t;for(;U!==t;){for(F.push(U),U=Q,ce=[],be=Me();be!==t;)ce.push(be),be=Me();if(ce!==t)if(r.charCodeAt(Q)===43?(be=Us,Q++):(be=t,I===0&&Be(rc)),be===t&&(r.charCodeAt(Q)===45?(be=QA,Q++):(be=t,I===0&&Be(tc))),be!==t){for(ft=[],Bt=Me();Bt!==t;)ft.push(Bt),Bt=Me();ft!==t?(Bt=KS(),Bt!==t?(Re=U,ce=Hg(b,be,Bt),U=ce):(Q=U,U=t)):(Q=U,U=t)}else Q=U,U=t;else Q=U,U=t}F!==t?(Re=m,b=Gs(b,F),m=b):(Q=m,m=t)}else Q=m,m=t;return m}function x1(){var m,b,F,U,ce,be;if(m=Q,r.substr(Q,3)===SA?(b=SA,Q+=3):(b=t,I===0&&Be(R)),b!==t){for(F=[],U=Me();U!==t;)F.push(U),U=Me();if(F!==t)if(U=v1(),U!==t){for(ce=[],be=Me();be!==t;)ce.push(be),be=Me();ce!==t?(r.substr(Q,2)===q?(be=q,Q+=2):(be=t,I===0&&Be(pe)),be!==t?(Re=m,b=Ne(U),m=b):(Q=m,m=t)):(Q=m,m=t)}else Q=m,m=t;else Q=m,m=t}else Q=m,m=t;return m}function P1(){var m,b,F,U;return m=Q,r.substr(Q,2)===xe?(b=xe,Q+=2):(b=t,I===0&&Be(qe)),b!==t?(F=Ur(),F!==t?(r.charCodeAt(Q)===41?(U=T,Q++):(U=t,I===0&&Be(N)),U!==t?(Re=m,b=dt(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m}function US(){var m,b,F,U,ce,be;return m=Q,r.substr(Q,2)===Ft?(b=Ft,Q+=2):(b=t,I===0&&Be(Nn)),b!==t?(F=nc(),F!==t?(r.substr(Q,2)===bS?(U=bS,Q+=2):(U=t,I===0&&Be(s1)),U!==t?(ce=E1(),ce!==t?(r.charCodeAt(Q)===125?(be=Pe,Q++):(be=t,I===0&&Be(Te)),be!==t?(Re=m,b=o1(F,ce),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===Ft?(b=Ft,Q+=2):(b=t,I===0&&Be(Nn)),b!==t?(F=nc(),F!==t?(r.substr(Q,3)===SS?(U=SS,Q+=3):(U=t,I===0&&Be(a1)),U!==t?(Re=m,b=A1(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===Ft?(b=Ft,Q+=2):(b=t,I===0&&Be(Nn)),b!==t?(F=nc(),F!==t?(r.substr(Q,2)===vS?(U=vS,Q+=2):(U=t,I===0&&Be(l1)),U!==t?(ce=E1(),ce!==t?(r.charCodeAt(Q)===125?(be=Pe,Q++):(be=t,I===0&&Be(Te)),be!==t?(Re=m,b=c1(F,ce),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===Ft?(b=Ft,Q+=2):(b=t,I===0&&Be(Nn)),b!==t?(F=nc(),F!==t?(r.substr(Q,3)===xS?(U=xS,Q+=3):(U=t,I===0&&Be(u1)),U!==t?(Re=m,b=g1(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.substr(Q,2)===Ft?(b=Ft,Q+=2):(b=t,I===0&&Be(Nn)),b!==t?(F=nc(),F!==t?(r.charCodeAt(Q)===125?(U=Pe,Q++):(U=t,I===0&&Be(Te)),U!==t?(Re=m,b=PS(F),m=b):(Q=m,m=t)):(Q=m,m=t)):(Q=m,m=t),m===t&&(m=Q,r.charCodeAt(Q)===36?(b=f1,Q++):(b=t,I===0&&Be(h1)),b!==t?(F=nc(),F!==t?(Re=m,b=PS(F),m=b):(Q=m,m=t)):(Q=m,m=t)))))),m}function afe(){var m,b,F;return m=Q,b=Afe(),b!==t?(Re=Q,F=p1(b),F?F=void 0:F=t,F!==t?(Re=m,b=d1(b),m=b):(Q=m,m=t)):(Q=m,m=t),m}function Afe(){var m,b,F,U,ce;if(m=Q,b=[],F=Q,U=Q,I++,ce=R1(),I--,ce===t?U=void 0:(Q=U,U=t),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t),F!==t)for(;F!==t;)b.push(F),F=Q,U=Q,I++,ce=R1(),I--,ce===t?U=void 0:(Q=U,U=t),U!==t?(r.length>Q?(ce=r.charAt(Q),Q++):(ce=t,I===0&&Be(wo)),ce!==t?(Re=F,U=ln(ce),F=U):(Q=F,F=t)):(Q=F,F=t);else b=t;return b!==t&&(Re=m,b=kn(b)),m=b,m}function D1(){var m,b,F;if(m=Q,b=[],DS.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(kS)),F!==t)for(;F!==t;)b.push(F),DS.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(kS));else b=t;return b!==t&&(Re=m,b=RS()),m=b,m}function nc(){var m,b,F;if(m=Q,b=[],FS.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(NS)),F!==t)for(;F!==t;)b.push(F),FS.test(r.charAt(Q))?(F=r.charAt(Q),Q++):(F=t,I===0&&Be(NS));else b=t;return b!==t&&(Re=m,b=RS()),m=b,m}function k1(){var m;return C1.test(r.charAt(Q))?(m=r.charAt(Q),Q++):(m=t,I===0&&Be(Gg)),m}function R1(){var m;return LS.test(r.charAt(Q))?(m=r.charAt(Q),Q++):(m=t,I===0&&Be(TS)),m}function Me(){var m,b;if(m=[],pI.test(r.charAt(Q))?(b=r.charAt(Q),Q++):(b=t,I===0&&Be(dI)),b!==t)for(;b!==t;)m.push(b),pI.test(r.charAt(Q))?(b=r.charAt(Q),Q++):(b=t,I===0&&Be(dI));else m=t;return m}if(k=n(),k!==t&&Q===r.length)return k;throw k!==t&&Q{"use strict";function Ahe(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function gc(r,e,t,i){this.message=r,this.expected=e,this.found=t,this.location=i,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,gc)}Ahe(gc,Error);gc.buildMessage=function(r,e){var t={literal:function(c){return'"'+n(c.text)+'"'},class:function(c){var u="",g;for(g=0;g0){for(g=1,f=1;gH&&(H=v,j=[]),j.push(ie))}function Te(ie,Y){return new gc(ie,null,null,Y)}function se(ie,Y,he){return new gc(gc.buildMessage(ie,Y),ie,Y,he)}function Ae(){var ie,Y,he,re;return ie=v,Y=Qe(),Y!==t?(r.charCodeAt(v)===47?(he=s,v++):(he=t,$===0&&Pe(o)),he!==t?(re=Qe(),re!==t?(D=ie,Y=a(Y,re),ie=Y):(v=ie,ie=t)):(v=ie,ie=t)):(v=ie,ie=t),ie===t&&(ie=v,Y=Qe(),Y!==t&&(D=ie,Y=l(Y)),ie=Y),ie}function Qe(){var ie,Y,he,re;return ie=v,Y=fe(),Y!==t?(r.charCodeAt(v)===64?(he=c,v++):(he=t,$===0&&Pe(u)),he!==t?(re=Ge(),re!==t?(D=ie,Y=g(Y,re),ie=Y):(v=ie,ie=t)):(v=ie,ie=t)):(v=ie,ie=t),ie===t&&(ie=v,Y=fe(),Y!==t&&(D=ie,Y=f(Y)),ie=Y),ie}function fe(){var ie,Y,he,re,me;return ie=v,r.charCodeAt(v)===64?(Y=c,v++):(Y=t,$===0&&Pe(u)),Y!==t?(he=le(),he!==t?(r.charCodeAt(v)===47?(re=s,v++):(re=t,$===0&&Pe(o)),re!==t?(me=le(),me!==t?(D=ie,Y=h(),ie=Y):(v=ie,ie=t)):(v=ie,ie=t)):(v=ie,ie=t)):(v=ie,ie=t),ie===t&&(ie=v,Y=le(),Y!==t&&(D=ie,Y=h()),ie=Y),ie}function le(){var ie,Y,he;if(ie=v,Y=[],p.test(r.charAt(v))?(he=r.charAt(v),v++):(he=t,$===0&&Pe(C)),he!==t)for(;he!==t;)Y.push(he),p.test(r.charAt(v))?(he=r.charAt(v),v++):(he=t,$===0&&Pe(C));else Y=t;return Y!==t&&(D=ie,Y=h()),ie=Y,ie}function Ge(){var ie,Y,he;if(ie=v,Y=[],w.test(r.charAt(v))?(he=r.charAt(v),v++):(he=t,$===0&&Pe(B)),he!==t)for(;he!==t;)Y.push(he),w.test(r.charAt(v))?(he=r.charAt(v),v++):(he=t,$===0&&Pe(B));else Y=t;return Y!==t&&(D=ie,Y=h()),ie=Y,ie}if(V=n(),V!==t&&v===r.length)return V;throw V!==t&&v{"use strict";function JU(r){return typeof r>"u"||r===null}function che(r){return typeof r=="object"&&r!==null}function uhe(r){return Array.isArray(r)?r:JU(r)?[]:[r]}function ghe(r,e){var t,i,n,s;if(e)for(s=Object.keys(e),t=0,i=s.length;t{"use strict";function dd(r,e){Error.call(this),this.name="YAMLException",this.reason=r,this.mark=e,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}dd.prototype=Object.create(Error.prototype);dd.prototype.constructor=dd;dd.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t};WU.exports=dd});var XU=y((LZe,VU)=>{"use strict";var zU=hc();function Iv(r,e,t,i,n){this.name=r,this.buffer=e,this.position=t,this.line=i,this.column=n}Iv.prototype.getSnippet=function(e,t){var i,n,s,o,a;if(!this.buffer)return null;for(e=e||4,t=t||75,i="",n=this.position;n>0&&`\0\r +\x85\u2028\u2029`.indexOf(this.buffer.charAt(n-1))===-1;)if(n-=1,this.position-n>t/2-1){i=" ... ",n+=5;break}for(s="",o=this.position;ot/2-1){s=" ... ",o-=5;break}return a=this.buffer.slice(n,o),zU.repeat(" ",e)+i+a+s+` +`+zU.repeat(" ",e+this.position-n+i.length)+"^"};Iv.prototype.toString=function(e){var t,i="";return this.name&&(i+='in "'+this.name+'" '),i+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet(),t&&(i+=`: +`+t)),i};VU.exports=Iv});var Ai=y((TZe,ZU)=>{"use strict";var _U=ef(),phe=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],dhe=["scalar","sequence","mapping"];function Che(r){var e={};return r!==null&&Object.keys(r).forEach(function(t){r[t].forEach(function(i){e[String(i)]=t})}),e}function mhe(r,e){if(e=e||{},Object.keys(e).forEach(function(t){if(phe.indexOf(t)===-1)throw new _U('Unknown option "'+t+'" is met in definition of "'+r+'" YAML type.')}),this.tag=r,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.defaultStyle=e.defaultStyle||null,this.styleAliases=Che(e.styleAliases||null),dhe.indexOf(this.kind)===-1)throw new _U('Unknown kind "'+this.kind+'" is specified for "'+r+'" YAML type.')}ZU.exports=mhe});var pc=y((OZe,e2)=>{"use strict";var $U=hc(),GI=ef(),Ehe=Ai();function yv(r,e,t){var i=[];return r.include.forEach(function(n){t=yv(n,e,t)}),r[e].forEach(function(n){t.forEach(function(s,o){s.tag===n.tag&&s.kind===n.kind&&i.push(o)}),t.push(n)}),t.filter(function(n,s){return i.indexOf(s)===-1})}function Ihe(){var r={scalar:{},sequence:{},mapping:{},fallback:{}},e,t;function i(n){r[n.kind][n.tag]=r.fallback[n.tag]=n}for(e=0,t=arguments.length;e{"use strict";var yhe=Ai();t2.exports=new yhe("tag:yaml.org,2002:str",{kind:"scalar",construct:function(r){return r!==null?r:""}})});var n2=y((KZe,i2)=>{"use strict";var whe=Ai();i2.exports=new whe("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(r){return r!==null?r:[]}})});var o2=y((UZe,s2)=>{"use strict";var Bhe=Ai();s2.exports=new Bhe("tag:yaml.org,2002:map",{kind:"mapping",construct:function(r){return r!==null?r:{}}})});var YI=y((HZe,a2)=>{"use strict";var Qhe=pc();a2.exports=new Qhe({explicit:[r2(),n2(),o2()]})});var l2=y((GZe,A2)=>{"use strict";var bhe=Ai();function She(r){if(r===null)return!0;var e=r.length;return e===1&&r==="~"||e===4&&(r==="null"||r==="Null"||r==="NULL")}function vhe(){return null}function xhe(r){return r===null}A2.exports=new bhe("tag:yaml.org,2002:null",{kind:"scalar",resolve:She,construct:vhe,predicate:xhe,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var u2=y((YZe,c2)=>{"use strict";var Phe=Ai();function Dhe(r){if(r===null)return!1;var e=r.length;return e===4&&(r==="true"||r==="True"||r==="TRUE")||e===5&&(r==="false"||r==="False"||r==="FALSE")}function khe(r){return r==="true"||r==="True"||r==="TRUE"}function Rhe(r){return Object.prototype.toString.call(r)==="[object Boolean]"}c2.exports=new Phe("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Dhe,construct:khe,predicate:Rhe,represent:{lowercase:function(r){return r?"true":"false"},uppercase:function(r){return r?"TRUE":"FALSE"},camelcase:function(r){return r?"True":"False"}},defaultStyle:"lowercase"})});var f2=y((jZe,g2)=>{"use strict";var Fhe=hc(),Nhe=Ai();function Lhe(r){return 48<=r&&r<=57||65<=r&&r<=70||97<=r&&r<=102}function The(r){return 48<=r&&r<=55}function Ohe(r){return 48<=r&&r<=57}function Mhe(r){if(r===null)return!1;var e=r.length,t=0,i=!1,n;if(!e)return!1;if(n=r[t],(n==="-"||n==="+")&&(n=r[++t]),n==="0"){if(t+1===e)return!0;if(n=r[++t],n==="b"){for(t++;t=0?"0b"+r.toString(2):"-0b"+r.toString(2).slice(1)},octal:function(r){return r>=0?"0"+r.toString(8):"-0"+r.toString(8).slice(1)},decimal:function(r){return r.toString(10)},hexadecimal:function(r){return r>=0?"0x"+r.toString(16).toUpperCase():"-0x"+r.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var d2=y((qZe,p2)=>{"use strict";var h2=hc(),Hhe=Ai(),Ghe=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Yhe(r){return!(r===null||!Ghe.test(r)||r[r.length-1]==="_")}function jhe(r){var e,t,i,n;return e=r.replace(/_/g,"").toLowerCase(),t=e[0]==="-"?-1:1,n=[],"+-".indexOf(e[0])>=0&&(e=e.slice(1)),e===".inf"?t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:e===".nan"?NaN:e.indexOf(":")>=0?(e.split(":").forEach(function(s){n.unshift(parseFloat(s,10))}),e=0,i=1,n.forEach(function(s){e+=s*i,i*=60}),t*e):t*parseFloat(e,10)}var qhe=/^[-+]?[0-9]+e/;function Jhe(r,e){var t;if(isNaN(r))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===r)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===r)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(h2.isNegativeZero(r))return"-0.0";return t=r.toString(10),qhe.test(t)?t.replace("e",".e"):t}function Whe(r){return Object.prototype.toString.call(r)==="[object Number]"&&(r%1!==0||h2.isNegativeZero(r))}p2.exports=new Hhe("tag:yaml.org,2002:float",{kind:"scalar",resolve:Yhe,construct:jhe,predicate:Whe,represent:Jhe,defaultStyle:"lowercase"})});var wv=y((JZe,C2)=>{"use strict";var zhe=pc();C2.exports=new zhe({include:[YI()],implicit:[l2(),u2(),f2(),d2()]})});var Bv=y((WZe,m2)=>{"use strict";var Vhe=pc();m2.exports=new Vhe({include:[wv()]})});var w2=y((zZe,y2)=>{"use strict";var Xhe=Ai(),E2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),I2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function _he(r){return r===null?!1:E2.exec(r)!==null||I2.exec(r)!==null}function Zhe(r){var e,t,i,n,s,o,a,l=0,c=null,u,g,f;if(e=E2.exec(r),e===null&&(e=I2.exec(r)),e===null)throw new Error("Date resolve error");if(t=+e[1],i=+e[2]-1,n=+e[3],!e[4])return new Date(Date.UTC(t,i,n));if(s=+e[4],o=+e[5],a=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=+e[10],g=+(e[11]||0),c=(u*60+g)*6e4,e[9]==="-"&&(c=-c)),f=new Date(Date.UTC(t,i,n,s,o,a,l)),c&&f.setTime(f.getTime()-c),f}function $he(r){return r.toISOString()}y2.exports=new Xhe("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:_he,construct:Zhe,instanceOf:Date,represent:$he})});var Q2=y((VZe,B2)=>{"use strict";var epe=Ai();function tpe(r){return r==="<<"||r===null}B2.exports=new epe("tag:yaml.org,2002:merge",{kind:"scalar",resolve:tpe})});var v2=y((XZe,S2)=>{"use strict";var dc;try{b2=J,dc=b2("buffer").Buffer}catch{}var b2,rpe=Ai(),Qv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function ipe(r){if(r===null)return!1;var e,t,i=0,n=r.length,s=Qv;for(t=0;t64)){if(e<0)return!1;i+=6}return i%8===0}function npe(r){var e,t,i=r.replace(/[\r\n=]/g,""),n=i.length,s=Qv,o=0,a=[];for(e=0;e>16&255),a.push(o>>8&255),a.push(o&255)),o=o<<6|s.indexOf(i.charAt(e));return t=n%4*6,t===0?(a.push(o>>16&255),a.push(o>>8&255),a.push(o&255)):t===18?(a.push(o>>10&255),a.push(o>>2&255)):t===12&&a.push(o>>4&255),dc?dc.from?dc.from(a):new dc(a):a}function spe(r){var e="",t=0,i,n,s=r.length,o=Qv;for(i=0;i>18&63],e+=o[t>>12&63],e+=o[t>>6&63],e+=o[t&63]),t=(t<<8)+r[i];return n=s%3,n===0?(e+=o[t>>18&63],e+=o[t>>12&63],e+=o[t>>6&63],e+=o[t&63]):n===2?(e+=o[t>>10&63],e+=o[t>>4&63],e+=o[t<<2&63],e+=o[64]):n===1&&(e+=o[t>>2&63],e+=o[t<<4&63],e+=o[64],e+=o[64]),e}function ope(r){return dc&&dc.isBuffer(r)}S2.exports=new rpe("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ipe,construct:npe,predicate:ope,represent:spe})});var P2=y((_Ze,x2)=>{"use strict";var ape=Ai(),Ape=Object.prototype.hasOwnProperty,lpe=Object.prototype.toString;function cpe(r){if(r===null)return!0;var e=[],t,i,n,s,o,a=r;for(t=0,i=a.length;t{"use strict";var gpe=Ai(),fpe=Object.prototype.toString;function hpe(r){if(r===null)return!0;var e,t,i,n,s,o=r;for(s=new Array(o.length),e=0,t=o.length;e{"use strict";var dpe=Ai(),Cpe=Object.prototype.hasOwnProperty;function mpe(r){if(r===null)return!0;var e,t=r;for(e in t)if(Cpe.call(t,e)&&t[e]!==null)return!1;return!0}function Epe(r){return r!==null?r:{}}R2.exports=new dpe("tag:yaml.org,2002:set",{kind:"mapping",resolve:mpe,construct:Epe})});var rf=y((e$e,N2)=>{"use strict";var Ipe=pc();N2.exports=new Ipe({include:[Bv()],implicit:[w2(),Q2()],explicit:[v2(),P2(),k2(),F2()]})});var T2=y((t$e,L2)=>{"use strict";var ype=Ai();function wpe(){return!0}function Bpe(){}function Qpe(){return""}function bpe(r){return typeof r>"u"}L2.exports=new ype("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:wpe,construct:Bpe,predicate:bpe,represent:Qpe})});var M2=y((r$e,O2)=>{"use strict";var Spe=Ai();function vpe(r){if(r===null||r.length===0)return!1;var e=r,t=/\/([gim]*)$/.exec(r),i="";return!(e[0]==="/"&&(t&&(i=t[1]),i.length>3||e[e.length-i.length-1]!=="/"))}function xpe(r){var e=r,t=/\/([gim]*)$/.exec(r),i="";return e[0]==="/"&&(t&&(i=t[1]),e=e.slice(1,e.length-i.length-1)),new RegExp(e,i)}function Ppe(r){var e="/"+r.source+"/";return r.global&&(e+="g"),r.multiline&&(e+="m"),r.ignoreCase&&(e+="i"),e}function Dpe(r){return Object.prototype.toString.call(r)==="[object RegExp]"}O2.exports=new Spe("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:vpe,construct:xpe,predicate:Dpe,represent:Ppe})});var H2=y((i$e,U2)=>{"use strict";var jI;try{K2=J,jI=K2("esprima")}catch{typeof window<"u"&&(jI=window.esprima)}var K2,kpe=Ai();function Rpe(r){if(r===null)return!1;try{var e="("+r+")",t=jI.parse(e,{range:!0});return!(t.type!=="Program"||t.body.length!==1||t.body[0].type!=="ExpressionStatement"||t.body[0].expression.type!=="ArrowFunctionExpression"&&t.body[0].expression.type!=="FunctionExpression")}catch{return!1}}function Fpe(r){var e="("+r+")",t=jI.parse(e,{range:!0}),i=[],n;if(t.type!=="Program"||t.body.length!==1||t.body[0].type!=="ExpressionStatement"||t.body[0].expression.type!=="ArrowFunctionExpression"&&t.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return t.body[0].expression.params.forEach(function(s){i.push(s.name)}),n=t.body[0].expression.body.range,t.body[0].expression.body.type==="BlockStatement"?new Function(i,e.slice(n[0]+1,n[1]-1)):new Function(i,"return "+e.slice(n[0],n[1]))}function Npe(r){return r.toString()}function Lpe(r){return Object.prototype.toString.call(r)==="[object Function]"}U2.exports=new kpe("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Rpe,construct:Fpe,predicate:Lpe,represent:Npe})});var Cd=y((n$e,Y2)=>{"use strict";var G2=pc();Y2.exports=G2.DEFAULT=new G2({include:[rf()],explicit:[T2(),M2(),H2()]})});var AH=y((s$e,md)=>{"use strict";var Qa=hc(),X2=ef(),Tpe=XU(),_2=rf(),Ope=Cd(),FA=Object.prototype.hasOwnProperty,qI=1,Z2=2,$2=3,JI=4,bv=1,Mpe=2,j2=3,Kpe=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Upe=/[\x85\u2028\u2029]/,Hpe=/[,\[\]\{\}]/,eH=/^(?:!|!!|![a-z\-]+!)$/i,tH=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function q2(r){return Object.prototype.toString.call(r)}function So(r){return r===10||r===13}function mc(r){return r===9||r===32}function fn(r){return r===9||r===32||r===10||r===13}function nf(r){return r===44||r===91||r===93||r===123||r===125}function Gpe(r){var e;return 48<=r&&r<=57?r-48:(e=r|32,97<=e&&e<=102?e-97+10:-1)}function Ype(r){return r===120?2:r===117?4:r===85?8:0}function jpe(r){return 48<=r&&r<=57?r-48:-1}function J2(r){return r===48?"\0":r===97?"\x07":r===98?"\b":r===116||r===9?" ":r===110?` +`:r===118?"\v":r===102?"\f":r===114?"\r":r===101?"\x1B":r===32?" ":r===34?'"':r===47?"/":r===92?"\\":r===78?"\x85":r===95?"\xA0":r===76?"\u2028":r===80?"\u2029":""}function qpe(r){return r<=65535?String.fromCharCode(r):String.fromCharCode((r-65536>>10)+55296,(r-65536&1023)+56320)}var rH=new Array(256),iH=new Array(256);for(Cc=0;Cc<256;Cc++)rH[Cc]=J2(Cc)?1:0,iH[Cc]=J2(Cc);var Cc;function Jpe(r,e){this.input=r,this.filename=e.filename||null,this.schema=e.schema||Ope,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=r.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function nH(r,e){return new X2(e,new Tpe(r.filename,r.input,r.position,r.line,r.position-r.lineStart))}function gt(r,e){throw nH(r,e)}function WI(r,e){r.onWarning&&r.onWarning.call(null,nH(r,e))}var W2={YAML:function(e,t,i){var n,s,o;e.version!==null&>(e,"duplication of %YAML directive"),i.length!==1&>(e,"YAML directive accepts exactly one argument"),n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),n===null&>(e,"ill-formed argument of the YAML directive"),s=parseInt(n[1],10),o=parseInt(n[2],10),s!==1&>(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=o<2,o!==1&&o!==2&&WI(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var n,s;i.length!==2&>(e,"TAG directive accepts exactly two arguments"),n=i[0],s=i[1],eH.test(n)||gt(e,"ill-formed tag handle (first argument) of the TAG directive"),FA.call(e.tagMap,n)&>(e,'there is a previously declared suffix for "'+n+'" tag handle'),tH.test(s)||gt(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[n]=s}};function RA(r,e,t,i){var n,s,o,a;if(e1&&(r.result+=Qa.repeat(` +`,e-1))}function Wpe(r,e,t){var i,n,s,o,a,l,c,u,g=r.kind,f=r.result,h;if(h=r.input.charCodeAt(r.position),fn(h)||nf(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(n=r.input.charCodeAt(r.position+1),fn(n)||t&&nf(n)))return!1;for(r.kind="scalar",r.result="",s=o=r.position,a=!1;h!==0;){if(h===58){if(n=r.input.charCodeAt(r.position+1),fn(n)||t&&nf(n))break}else if(h===35){if(i=r.input.charCodeAt(r.position-1),fn(i))break}else{if(r.position===r.lineStart&&zI(r)||t&&nf(h))break;if(So(h))if(l=r.line,c=r.lineStart,u=r.lineIndent,_r(r,!1,-1),r.lineIndent>=e){a=!0,h=r.input.charCodeAt(r.position);continue}else{r.position=o,r.line=l,r.lineStart=c,r.lineIndent=u;break}}a&&(RA(r,s,o,!1),vv(r,r.line-l),s=o=r.position,a=!1),mc(h)||(o=r.position+1),h=r.input.charCodeAt(++r.position)}return RA(r,s,o,!1),r.result?!0:(r.kind=g,r.result=f,!1)}function zpe(r,e){var t,i,n;if(t=r.input.charCodeAt(r.position),t!==39)return!1;for(r.kind="scalar",r.result="",r.position++,i=n=r.position;(t=r.input.charCodeAt(r.position))!==0;)if(t===39)if(RA(r,i,r.position,!0),t=r.input.charCodeAt(++r.position),t===39)i=r.position,r.position++,n=r.position;else return!0;else So(t)?(RA(r,i,n,!0),vv(r,_r(r,!1,e)),i=n=r.position):r.position===r.lineStart&&zI(r)?gt(r,"unexpected end of the document within a single quoted scalar"):(r.position++,n=r.position);gt(r,"unexpected end of the stream within a single quoted scalar")}function Vpe(r,e){var t,i,n,s,o,a;if(a=r.input.charCodeAt(r.position),a!==34)return!1;for(r.kind="scalar",r.result="",r.position++,t=i=r.position;(a=r.input.charCodeAt(r.position))!==0;){if(a===34)return RA(r,t,r.position,!0),r.position++,!0;if(a===92){if(RA(r,t,r.position,!0),a=r.input.charCodeAt(++r.position),So(a))_r(r,!1,e);else if(a<256&&rH[a])r.result+=iH[a],r.position++;else if((o=Ype(a))>0){for(n=o,s=0;n>0;n--)a=r.input.charCodeAt(++r.position),(o=Gpe(a))>=0?s=(s<<4)+o:gt(r,"expected hexadecimal character");r.result+=qpe(s),r.position++}else gt(r,"unknown escape sequence");t=i=r.position}else So(a)?(RA(r,t,i,!0),vv(r,_r(r,!1,e)),t=i=r.position):r.position===r.lineStart&&zI(r)?gt(r,"unexpected end of the document within a double quoted scalar"):(r.position++,i=r.position)}gt(r,"unexpected end of the stream within a double quoted scalar")}function Xpe(r,e){var t=!0,i,n=r.tag,s,o=r.anchor,a,l,c,u,g,f={},h,p,C,w;if(w=r.input.charCodeAt(r.position),w===91)l=93,g=!1,s=[];else if(w===123)l=125,g=!0,s={};else return!1;for(r.anchor!==null&&(r.anchorMap[r.anchor]=s),w=r.input.charCodeAt(++r.position);w!==0;){if(_r(r,!0,e),w=r.input.charCodeAt(r.position),w===l)return r.position++,r.tag=n,r.anchor=o,r.kind=g?"mapping":"sequence",r.result=s,!0;t||gt(r,"missed comma between flow collection entries"),p=h=C=null,c=u=!1,w===63&&(a=r.input.charCodeAt(r.position+1),fn(a)&&(c=u=!0,r.position++,_r(r,!0,e))),i=r.line,of(r,e,qI,!1,!0),p=r.tag,h=r.result,_r(r,!0,e),w=r.input.charCodeAt(r.position),(u||r.line===i)&&w===58&&(c=!0,w=r.input.charCodeAt(++r.position),_r(r,!0,e),of(r,e,qI,!1,!0),C=r.result),g?sf(r,s,f,p,h,C):c?s.push(sf(r,null,f,p,h,C)):s.push(h),_r(r,!0,e),w=r.input.charCodeAt(r.position),w===44?(t=!0,w=r.input.charCodeAt(++r.position)):t=!1}gt(r,"unexpected end of the stream within a flow collection")}function _pe(r,e){var t,i,n=bv,s=!1,o=!1,a=e,l=0,c=!1,u,g;if(g=r.input.charCodeAt(r.position),g===124)i=!1;else if(g===62)i=!0;else return!1;for(r.kind="scalar",r.result="";g!==0;)if(g=r.input.charCodeAt(++r.position),g===43||g===45)bv===n?n=g===43?j2:Mpe:gt(r,"repeat of a chomping mode identifier");else if((u=jpe(g))>=0)u===0?gt(r,"bad explicit indentation width of a block scalar; it cannot be less than one"):o?gt(r,"repeat of an indentation width identifier"):(a=e+u-1,o=!0);else break;if(mc(g)){do g=r.input.charCodeAt(++r.position);while(mc(g));if(g===35)do g=r.input.charCodeAt(++r.position);while(!So(g)&&g!==0)}for(;g!==0;){for(Sv(r),r.lineIndent=0,g=r.input.charCodeAt(r.position);(!o||r.lineIndenta&&(a=r.lineIndent),So(g)){l++;continue}if(r.lineIndente)&&l!==0)gt(r,"bad indentation of a sequence entry");else if(r.lineIndente)&&(of(r,e,JI,!0,n)&&(p?f=r.result:h=r.result),p||(sf(r,c,u,g,f,h,s,o),g=f=h=null),_r(r,!0,-1),w=r.input.charCodeAt(r.position)),r.lineIndent>e&&w!==0)gt(r,"bad indentation of a mapping entry");else if(r.lineIndente?l=1:r.lineIndent===e?l=0:r.lineIndente?l=1:r.lineIndent===e?l=0:r.lineIndent tag; it should be "scalar", not "'+r.kind+'"'),g=0,f=r.implicitTypes.length;g tag; it should be "'+h.kind+'", not "'+r.kind+'"'),h.resolve(r.result)?(r.result=h.construct(r.result),r.anchor!==null&&(r.anchorMap[r.anchor]=r.result)):gt(r,"cannot resolve a node with !<"+r.tag+"> explicit tag")):gt(r,"unknown tag !<"+r.tag+">");return r.listener!==null&&r.listener("close",r),r.tag!==null||r.anchor!==null||u}function rde(r){var e=r.position,t,i,n,s=!1,o;for(r.version=null,r.checkLineBreaks=r.legacy,r.tagMap={},r.anchorMap={};(o=r.input.charCodeAt(r.position))!==0&&(_r(r,!0,-1),o=r.input.charCodeAt(r.position),!(r.lineIndent>0||o!==37));){for(s=!0,o=r.input.charCodeAt(++r.position),t=r.position;o!==0&&!fn(o);)o=r.input.charCodeAt(++r.position);for(i=r.input.slice(t,r.position),n=[],i.length<1&>(r,"directive name must not be less than one character in length");o!==0;){for(;mc(o);)o=r.input.charCodeAt(++r.position);if(o===35){do o=r.input.charCodeAt(++r.position);while(o!==0&&!So(o));break}if(So(o))break;for(t=r.position;o!==0&&!fn(o);)o=r.input.charCodeAt(++r.position);n.push(r.input.slice(t,r.position))}o!==0&&Sv(r),FA.call(W2,i)?W2[i](r,i,n):WI(r,'unknown document directive "'+i+'"')}if(_r(r,!0,-1),r.lineIndent===0&&r.input.charCodeAt(r.position)===45&&r.input.charCodeAt(r.position+1)===45&&r.input.charCodeAt(r.position+2)===45?(r.position+=3,_r(r,!0,-1)):s&>(r,"directives end mark is expected"),of(r,r.lineIndent-1,JI,!1,!0),_r(r,!0,-1),r.checkLineBreaks&&Upe.test(r.input.slice(e,r.position))&&WI(r,"non-ASCII line breaks are interpreted as content"),r.documents.push(r.result),r.position===r.lineStart&&zI(r)){r.input.charCodeAt(r.position)===46&&(r.position+=3,_r(r,!0,-1));return}if(r.position"u"&&(t=e,e=null);var i=sH(r,t);if(typeof e!="function")return i;for(var n=0,s=i.length;n"u"&&(t=e,e=null),oH(r,e,Qa.extend({schema:_2},t))}function nde(r,e){return aH(r,Qa.extend({schema:_2},e))}md.exports.loadAll=oH;md.exports.load=aH;md.exports.safeLoadAll=ide;md.exports.safeLoad=nde});var kH=y((o$e,kv)=>{"use strict";var Id=hc(),yd=ef(),sde=Cd(),ode=rf(),dH=Object.prototype.toString,CH=Object.prototype.hasOwnProperty,ade=9,Ed=10,Ade=13,lde=32,cde=33,ude=34,mH=35,gde=37,fde=38,hde=39,pde=42,EH=44,dde=45,IH=58,Cde=61,mde=62,Ede=63,Ide=64,yH=91,wH=93,yde=96,BH=123,wde=124,QH=125,Li={};Li[0]="\\0";Li[7]="\\a";Li[8]="\\b";Li[9]="\\t";Li[10]="\\n";Li[11]="\\v";Li[12]="\\f";Li[13]="\\r";Li[27]="\\e";Li[34]='\\"';Li[92]="\\\\";Li[133]="\\N";Li[160]="\\_";Li[8232]="\\L";Li[8233]="\\P";var Bde=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function Qde(r,e){var t,i,n,s,o,a,l;if(e===null)return{};for(t={},i=Object.keys(e),n=0,s=i.length;n0?r.charCodeAt(s-1):null,f=f&&uH(o,a)}else{for(s=0;si&&r[g+1]!==" ",g=s);else if(!af(o))return VI;a=s>0?r.charCodeAt(s-1):null,f=f&&uH(o,a)}c=c||u&&s-g-1>i&&r[g+1]!==" "}return!l&&!c?f&&!n(r)?SH:vH:t>9&&bH(r)?VI:c?PH:xH}function Dde(r,e,t,i){r.dump=function(){if(e.length===0)return"''";if(!r.noCompatMode&&Bde.indexOf(e)!==-1)return"'"+e+"'";var n=r.indent*Math.max(1,t),s=r.lineWidth===-1?-1:Math.max(Math.min(r.lineWidth,40),r.lineWidth-n),o=i||r.flowLevel>-1&&t>=r.flowLevel;function a(l){return Sde(r,l)}switch(Pde(e,o,r.indent,s,a)){case SH:return e;case vH:return"'"+e.replace(/'/g,"''")+"'";case xH:return"|"+gH(e,r.indent)+fH(cH(e,n));case PH:return">"+gH(e,r.indent)+fH(cH(kde(e,s),n));case VI:return'"'+Rde(e,s)+'"';default:throw new yd("impossible error: invalid scalar style")}}()}function gH(r,e){var t=bH(r)?String(e):"",i=r[r.length-1]===` +`,n=i&&(r[r.length-2]===` +`||r===` +`),s=n?"+":i?"":"-";return t+s+` +`}function fH(r){return r[r.length-1]===` +`?r.slice(0,-1):r}function kde(r,e){for(var t=/(\n+)([^\n]*)/g,i=function(){var c=r.indexOf(` +`);return c=c!==-1?c:r.length,t.lastIndex=c,hH(r.slice(0,c),e)}(),n=r[0]===` +`||r[0]===" ",s,o;o=t.exec(r);){var a=o[1],l=o[2];s=l[0]===" ",i+=a+(!n&&!s&&l!==""?` +`:"")+hH(l,e),n=s}return i}function hH(r,e){if(r===""||r[0]===" ")return r;for(var t=/ [^ ]/g,i,n=0,s,o=0,a=0,l="";i=t.exec(r);)a=i.index,a-n>e&&(s=o>n?o:a,l+=` +`+r.slice(n,s),n=s+1),o=a;return l+=` +`,r.length-n>e&&o>n?l+=r.slice(n,o)+` +`+r.slice(o+1):l+=r.slice(n),l.slice(1)}function Rde(r){for(var e="",t,i,n,s=0;s=55296&&t<=56319&&(i=r.charCodeAt(s+1),i>=56320&&i<=57343)){e+=lH((t-55296)*1024+i-56320+65536),s++;continue}n=Li[t],e+=!n&&af(t)?r[s]:n||lH(t)}return e}function Fde(r,e,t){var i="",n=r.tag,s,o;for(s=0,o=t.length;s1024&&(u+="? "),u+=r.dump+(r.condenseFlow?'"':"")+":"+(r.condenseFlow?"":" "),Ec(r,e,c,!1,!1)&&(u+=r.dump,i+=u));r.tag=n,r.dump="{"+i+"}"}function Tde(r,e,t,i){var n="",s=r.tag,o=Object.keys(t),a,l,c,u,g,f;if(r.sortKeys===!0)o.sort();else if(typeof r.sortKeys=="function")o.sort(r.sortKeys);else if(r.sortKeys)throw new yd("sortKeys must be a boolean or a function");for(a=0,l=o.length;a1024,g&&(r.dump&&Ed===r.dump.charCodeAt(0)?f+="?":f+="? "),f+=r.dump,g&&(f+=xv(r,e)),Ec(r,e+1,u,!0,g)&&(r.dump&&Ed===r.dump.charCodeAt(0)?f+=":":f+=": ",f+=r.dump,n+=f));r.tag=s,r.dump=n||"{}"}function pH(r,e,t){var i,n,s,o,a,l;for(n=t?r.explicitTypes:r.implicitTypes,s=0,o=n.length;s tag resolver accepts not "'+l+'" style');r.dump=i}return!0}return!1}function Ec(r,e,t,i,n,s){r.tag=null,r.dump=t,pH(r,t,!1)||pH(r,t,!0);var o=dH.call(r.dump);i&&(i=r.flowLevel<0||r.flowLevel>e);var a=o==="[object Object]"||o==="[object Array]",l,c;if(a&&(l=r.duplicates.indexOf(t),c=l!==-1),(r.tag!==null&&r.tag!=="?"||c||r.indent!==2&&e>0)&&(n=!1),c&&r.usedDuplicates[l])r.dump="*ref_"+l;else{if(a&&c&&!r.usedDuplicates[l]&&(r.usedDuplicates[l]=!0),o==="[object Object]")i&&Object.keys(r.dump).length!==0?(Tde(r,e,r.dump,n),c&&(r.dump="&ref_"+l+r.dump)):(Lde(r,e,r.dump),c&&(r.dump="&ref_"+l+" "+r.dump));else if(o==="[object Array]"){var u=r.noArrayIndent&&e>0?e-1:e;i&&r.dump.length!==0?(Nde(r,u,r.dump,n),c&&(r.dump="&ref_"+l+r.dump)):(Fde(r,u,r.dump),c&&(r.dump="&ref_"+l+" "+r.dump))}else if(o==="[object String]")r.tag!=="?"&&Dde(r,r.dump,e,s);else{if(r.skipInvalid)return!1;throw new yd("unacceptable kind of an object to dump "+o)}r.tag!==null&&r.tag!=="?"&&(r.dump="!<"+r.tag+"> "+r.dump)}return!0}function Ode(r,e){var t=[],i=[],n,s;for(Pv(r,t,i),n=0,s=i.length;n{"use strict";var XI=AH(),RH=kH();function _I(r){return function(){throw new Error("Function "+r+" is deprecated and cannot be used.")}}Lr.exports.Type=Ai();Lr.exports.Schema=pc();Lr.exports.FAILSAFE_SCHEMA=YI();Lr.exports.JSON_SCHEMA=wv();Lr.exports.CORE_SCHEMA=Bv();Lr.exports.DEFAULT_SAFE_SCHEMA=rf();Lr.exports.DEFAULT_FULL_SCHEMA=Cd();Lr.exports.load=XI.load;Lr.exports.loadAll=XI.loadAll;Lr.exports.safeLoad=XI.safeLoad;Lr.exports.safeLoadAll=XI.safeLoadAll;Lr.exports.dump=RH.dump;Lr.exports.safeDump=RH.safeDump;Lr.exports.YAMLException=ef();Lr.exports.MINIMAL_SCHEMA=YI();Lr.exports.SAFE_SCHEMA=rf();Lr.exports.DEFAULT_SCHEMA=Cd();Lr.exports.scan=_I("scan");Lr.exports.parse=_I("parse");Lr.exports.compose=_I("compose");Lr.exports.addConstructor=_I("addConstructor")});var LH=y((A$e,NH)=>{"use strict";var Kde=FH();NH.exports=Kde});var OH=y((l$e,TH)=>{"use strict";function Ude(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function Ic(r,e,t,i){this.message=r,this.expected=e,this.found=t,this.location=i,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ic)}Ude(Ic,Error);Ic.buildMessage=function(r,e){var t={literal:function(c){return'"'+n(c.text)+'"'},class:function(c){var u="",g;for(g=0;g0){for(g=1,f=1;g({[Ne]:pe})))},H=function(R){return R},j=function(R){return R},$=Ms("correct indentation"),V=" ",W=ar(" ",!1),Z=function(R){return R.length===SA*Hg},A=function(R){return R.length===(SA+1)*Hg},ae=function(){return SA++,!0},ge=function(){return SA--,!0},_=function(){return Lg()},T=Ms("pseudostring"),N=/^[^\r\n\t ?:,\][{}#&*!|>'"%@`\-]/,ue=Fn(["\r",` +`," "," ","?",":",",","]","[","{","}","#","&","*","!","|",">","'",'"',"%","@","`","-"],!0,!1),we=/^[^\r\n\t ,\][{}:#"']/,Le=Fn(["\r",` +`," "," ",",","]","[","{","}",":","#",'"',"'"],!0,!1),Pe=function(){return Lg().replace(/^ *| *$/g,"")},Te="--",se=ar("--",!1),Ae=/^[a-zA-Z\/0-9]/,Qe=Fn([["a","z"],["A","Z"],"/",["0","9"]],!1,!1),fe=/^[^\r\n\t :,]/,le=Fn(["\r",` +`," "," ",":",","],!0,!1),Ge="null",ie=ar("null",!1),Y=function(){return null},he="true",re=ar("true",!1),me=function(){return!0},tt="false",Rt=ar("false",!1),It=function(){return!1},Kr=Ms("string"),oi='"',pi=ar('"',!1),pr=function(){return""},di=function(R){return R},ai=function(R){return R.join("")},Os=/^[^"\\\0-\x1F\x7F]/,dr=Fn(['"',"\\",["\0",""],"\x7F"],!0,!1),Bi='\\"',_n=ar('\\"',!1),ha=function(){return'"'},mA="\\\\",Dg=ar("\\\\",!1),Zn=function(){return"\\"},EA="\\/",pa=ar("\\/",!1),jp=function(){return"/"},IA="\\b",yA=ar("\\b",!1),Br=function(){return"\b"},zl="\\f",kg=ar("\\f",!1),Eo=function(){return"\f"},Rg="\\n",qp=ar("\\n",!1),Jp=function(){return` +`},xr="\\r",oe=ar("\\r",!1),Io=function(){return"\r"},kn="\\t",Fg=ar("\\t",!1),Qt=function(){return" "},Vl="\\u",Rn=ar("\\u",!1),$n=function(R,q,pe,Ne){return String.fromCharCode(parseInt(`0x${R}${q}${pe}${Ne}`))},es=/^[0-9a-fA-F]/,ut=Fn([["0","9"],["a","f"],["A","F"]],!1,!1),yo=Ms("blank space"),at=/^[ \t]/,ln=Fn([" "," "],!1,!1),S=Ms("white space"),Tt=/^[ \t\n\r]/,Ng=Fn([" "," ",` +`,"\r"],!1,!1),Xl=`\r +`,Wp=ar(`\r +`,!1),zp=` +`,Vp=ar(` +`,!1),Xp="\r",_p=ar("\r",!1),G=0,yt=0,wA=[{line:1,column:1}],Wi=0,_l=[],We=0,da;if("startRule"in e){if(!(e.startRule in i))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');n=i[e.startRule]}function Lg(){return r.substring(yt,G)}function lI(){return cn(yt,G)}function Zp(R,q){throw q=q!==void 0?q:cn(yt,G),$l([Ms(R)],r.substring(yt,G),q)}function cI(R,q){throw q=q!==void 0?q:cn(yt,G),Tg(R,q)}function ar(R,q){return{type:"literal",text:R,ignoreCase:q}}function Fn(R,q,pe){return{type:"class",parts:R,inverted:q,ignoreCase:pe}}function Zl(){return{type:"any"}}function $p(){return{type:"end"}}function Ms(R){return{type:"other",description:R}}function Ca(R){var q=wA[R],pe;if(q)return q;for(pe=R-1;!wA[pe];)pe--;for(q=wA[pe],q={line:q.line,column:q.column};peWi&&(Wi=G,_l=[]),_l.push(R))}function Tg(R,q){return new Ic(R,null,null,q)}function $l(R,q,pe){return new Ic(Ic.buildMessage(R,q),R,q,pe)}function Ks(){var R;return R=Og(),R}function ec(){var R,q,pe;for(R=G,q=[],pe=BA();pe!==t;)q.push(pe),pe=BA();return q!==t&&(yt=R,q=s(q)),R=q,R}function BA(){var R,q,pe,Ne,xe;return R=G,q=Ea(),q!==t?(r.charCodeAt(G)===45?(pe=o,G++):(pe=t,We===0&&De(a)),pe!==t?(Ne=Fr(),Ne!==t?(xe=ma(),xe!==t?(yt=R,q=l(xe),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R}function Og(){var R,q,pe;for(R=G,q=[],pe=Mg();pe!==t;)q.push(pe),pe=Mg();return q!==t&&(yt=R,q=c(q)),R=q,R}function Mg(){var R,q,pe,Ne,xe,qe,dt,Ft,Nn;if(R=G,q=Fr(),q===t&&(q=null),q!==t){if(pe=G,r.charCodeAt(G)===35?(Ne=u,G++):(Ne=t,We===0&&De(g)),Ne!==t){if(xe=[],qe=G,dt=G,We++,Ft=Gs(),We--,Ft===t?dt=void 0:(G=dt,dt=t),dt!==t?(r.length>G?(Ft=r.charAt(G),G++):(Ft=t,We===0&&De(f)),Ft!==t?(dt=[dt,Ft],qe=dt):(G=qe,qe=t)):(G=qe,qe=t),qe!==t)for(;qe!==t;)xe.push(qe),qe=G,dt=G,We++,Ft=Gs(),We--,Ft===t?dt=void 0:(G=dt,dt=t),dt!==t?(r.length>G?(Ft=r.charAt(G),G++):(Ft=t,We===0&&De(f)),Ft!==t?(dt=[dt,Ft],qe=dt):(G=qe,qe=t)):(G=qe,qe=t);else xe=t;xe!==t?(Ne=[Ne,xe],pe=Ne):(G=pe,pe=t)}else G=pe,pe=t;if(pe===t&&(pe=null),pe!==t){if(Ne=[],xe=Hs(),xe!==t)for(;xe!==t;)Ne.push(xe),xe=Hs();else Ne=t;Ne!==t?(yt=R,q=h(),R=q):(G=R,R=t)}else G=R,R=t}else G=R,R=t;if(R===t&&(R=G,q=Ea(),q!==t?(pe=tc(),pe!==t?(Ne=Fr(),Ne===t&&(Ne=null),Ne!==t?(r.charCodeAt(G)===58?(xe=p,G++):(xe=t,We===0&&De(C)),xe!==t?(qe=Fr(),qe===t&&(qe=null),qe!==t?(dt=ma(),dt!==t?(yt=R,q=w(pe,dt),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t&&(R=G,q=Ea(),q!==t?(pe=Us(),pe!==t?(Ne=Fr(),Ne===t&&(Ne=null),Ne!==t?(r.charCodeAt(G)===58?(xe=p,G++):(xe=t,We===0&&De(C)),xe!==t?(qe=Fr(),qe===t&&(qe=null),qe!==t?(dt=ma(),dt!==t?(yt=R,q=w(pe,dt),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t))){if(R=G,q=Ea(),q!==t)if(pe=Us(),pe!==t)if(Ne=Fr(),Ne!==t)if(xe=uI(),xe!==t){if(qe=[],dt=Hs(),dt!==t)for(;dt!==t;)qe.push(dt),dt=Hs();else qe=t;qe!==t?(yt=R,q=w(pe,xe),R=q):(G=R,R=t)}else G=R,R=t;else G=R,R=t;else G=R,R=t;else G=R,R=t;if(R===t)if(R=G,q=Ea(),q!==t)if(pe=Us(),pe!==t){if(Ne=[],xe=G,qe=Fr(),qe===t&&(qe=null),qe!==t?(r.charCodeAt(G)===44?(dt=B,G++):(dt=t,We===0&&De(v)),dt!==t?(Ft=Fr(),Ft===t&&(Ft=null),Ft!==t?(Nn=Us(),Nn!==t?(yt=xe,qe=D(pe,Nn),xe=qe):(G=xe,xe=t)):(G=xe,xe=t)):(G=xe,xe=t)):(G=xe,xe=t),xe!==t)for(;xe!==t;)Ne.push(xe),xe=G,qe=Fr(),qe===t&&(qe=null),qe!==t?(r.charCodeAt(G)===44?(dt=B,G++):(dt=t,We===0&&De(v)),dt!==t?(Ft=Fr(),Ft===t&&(Ft=null),Ft!==t?(Nn=Us(),Nn!==t?(yt=xe,qe=D(pe,Nn),xe=qe):(G=xe,xe=t)):(G=xe,xe=t)):(G=xe,xe=t)):(G=xe,xe=t);else Ne=t;Ne!==t?(xe=Fr(),xe===t&&(xe=null),xe!==t?(r.charCodeAt(G)===58?(qe=p,G++):(qe=t,We===0&&De(C)),qe!==t?(dt=Fr(),dt===t&&(dt=null),dt!==t?(Ft=ma(),Ft!==t?(yt=R,q=L(pe,Ne,Ft),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)}else G=R,R=t;else G=R,R=t}return R}function ma(){var R,q,pe,Ne,xe,qe,dt;if(R=G,q=G,We++,pe=G,Ne=Gs(),Ne!==t?(xe=$e(),xe!==t?(r.charCodeAt(G)===45?(qe=o,G++):(qe=t,We===0&&De(a)),qe!==t?(dt=Fr(),dt!==t?(Ne=[Ne,xe,qe,dt],pe=Ne):(G=pe,pe=t)):(G=pe,pe=t)):(G=pe,pe=t)):(G=pe,pe=t),We--,pe!==t?(G=q,q=void 0):q=t,q!==t?(pe=Hs(),pe!==t?(Ne=wo(),Ne!==t?(xe=ec(),xe!==t?(qe=QA(),qe!==t?(yt=R,q=H(xe),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t&&(R=G,q=Gs(),q!==t?(pe=wo(),pe!==t?(Ne=Og(),Ne!==t?(xe=QA(),xe!==t?(yt=R,q=H(Ne),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t),R===t))if(R=G,q=rc(),q!==t){if(pe=[],Ne=Hs(),Ne!==t)for(;Ne!==t;)pe.push(Ne),Ne=Hs();else pe=t;pe!==t?(yt=R,q=j(q),R=q):(G=R,R=t)}else G=R,R=t;return R}function Ea(){var R,q,pe;for(We++,R=G,q=[],r.charCodeAt(G)===32?(pe=V,G++):(pe=t,We===0&&De(W));pe!==t;)q.push(pe),r.charCodeAt(G)===32?(pe=V,G++):(pe=t,We===0&&De(W));return q!==t?(yt=G,pe=Z(q),pe?pe=void 0:pe=t,pe!==t?(q=[q,pe],R=q):(G=R,R=t)):(G=R,R=t),We--,R===t&&(q=t,We===0&&De($)),R}function $e(){var R,q,pe;for(R=G,q=[],r.charCodeAt(G)===32?(pe=V,G++):(pe=t,We===0&&De(W));pe!==t;)q.push(pe),r.charCodeAt(G)===32?(pe=V,G++):(pe=t,We===0&&De(W));return q!==t?(yt=G,pe=A(q),pe?pe=void 0:pe=t,pe!==t?(q=[q,pe],R=q):(G=R,R=t)):(G=R,R=t),R}function wo(){var R;return yt=G,R=ae(),R?R=void 0:R=t,R}function QA(){var R;return yt=G,R=ge(),R?R=void 0:R=t,R}function tc(){var R;return R=ic(),R===t&&(R=ed()),R}function Us(){var R,q,pe;if(R=ic(),R===t){if(R=G,q=[],pe=Kg(),pe!==t)for(;pe!==t;)q.push(pe),pe=Kg();else q=t;q!==t&&(yt=R,q=_()),R=q}return R}function rc(){var R;return R=td(),R===t&&(R=gI(),R===t&&(R=ic(),R===t&&(R=ed()))),R}function uI(){var R;return R=td(),R===t&&(R=ic(),R===t&&(R=Kg())),R}function ed(){var R,q,pe,Ne,xe,qe;if(We++,R=G,N.test(r.charAt(G))?(q=r.charAt(G),G++):(q=t,We===0&&De(ue)),q!==t){for(pe=[],Ne=G,xe=Fr(),xe===t&&(xe=null),xe!==t?(we.test(r.charAt(G))?(qe=r.charAt(G),G++):(qe=t,We===0&&De(Le)),qe!==t?(xe=[xe,qe],Ne=xe):(G=Ne,Ne=t)):(G=Ne,Ne=t);Ne!==t;)pe.push(Ne),Ne=G,xe=Fr(),xe===t&&(xe=null),xe!==t?(we.test(r.charAt(G))?(qe=r.charAt(G),G++):(qe=t,We===0&&De(Le)),qe!==t?(xe=[xe,qe],Ne=xe):(G=Ne,Ne=t)):(G=Ne,Ne=t);pe!==t?(yt=R,q=Pe(),R=q):(G=R,R=t)}else G=R,R=t;return We--,R===t&&(q=t,We===0&&De(T)),R}function Kg(){var R,q,pe,Ne,xe;if(R=G,r.substr(G,2)===Te?(q=Te,G+=2):(q=t,We===0&&De(se)),q===t&&(q=null),q!==t)if(Ae.test(r.charAt(G))?(pe=r.charAt(G),G++):(pe=t,We===0&&De(Qe)),pe!==t){for(Ne=[],fe.test(r.charAt(G))?(xe=r.charAt(G),G++):(xe=t,We===0&&De(le));xe!==t;)Ne.push(xe),fe.test(r.charAt(G))?(xe=r.charAt(G),G++):(xe=t,We===0&&De(le));Ne!==t?(yt=R,q=Pe(),R=q):(G=R,R=t)}else G=R,R=t;else G=R,R=t;return R}function td(){var R,q;return R=G,r.substr(G,4)===Ge?(q=Ge,G+=4):(q=t,We===0&&De(ie)),q!==t&&(yt=R,q=Y()),R=q,R}function gI(){var R,q;return R=G,r.substr(G,4)===he?(q=he,G+=4):(q=t,We===0&&De(re)),q!==t&&(yt=R,q=me()),R=q,R===t&&(R=G,r.substr(G,5)===tt?(q=tt,G+=5):(q=t,We===0&&De(Rt)),q!==t&&(yt=R,q=It()),R=q),R}function ic(){var R,q,pe,Ne;return We++,R=G,r.charCodeAt(G)===34?(q=oi,G++):(q=t,We===0&&De(pi)),q!==t?(r.charCodeAt(G)===34?(pe=oi,G++):(pe=t,We===0&&De(pi)),pe!==t?(yt=R,q=pr(),R=q):(G=R,R=t)):(G=R,R=t),R===t&&(R=G,r.charCodeAt(G)===34?(q=oi,G++):(q=t,We===0&&De(pi)),q!==t?(pe=fI(),pe!==t?(r.charCodeAt(G)===34?(Ne=oi,G++):(Ne=t,We===0&&De(pi)),Ne!==t?(yt=R,q=di(pe),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)),We--,R===t&&(q=t,We===0&&De(Kr)),R}function fI(){var R,q,pe;if(R=G,q=[],pe=Ug(),pe!==t)for(;pe!==t;)q.push(pe),pe=Ug();else q=t;return q!==t&&(yt=R,q=ai(q)),R=q,R}function Ug(){var R,q,pe,Ne,xe,qe;return Os.test(r.charAt(G))?(R=r.charAt(G),G++):(R=t,We===0&&De(dr)),R===t&&(R=G,r.substr(G,2)===Bi?(q=Bi,G+=2):(q=t,We===0&&De(_n)),q!==t&&(yt=R,q=ha()),R=q,R===t&&(R=G,r.substr(G,2)===mA?(q=mA,G+=2):(q=t,We===0&&De(Dg)),q!==t&&(yt=R,q=Zn()),R=q,R===t&&(R=G,r.substr(G,2)===EA?(q=EA,G+=2):(q=t,We===0&&De(pa)),q!==t&&(yt=R,q=jp()),R=q,R===t&&(R=G,r.substr(G,2)===IA?(q=IA,G+=2):(q=t,We===0&&De(yA)),q!==t&&(yt=R,q=Br()),R=q,R===t&&(R=G,r.substr(G,2)===zl?(q=zl,G+=2):(q=t,We===0&&De(kg)),q!==t&&(yt=R,q=Eo()),R=q,R===t&&(R=G,r.substr(G,2)===Rg?(q=Rg,G+=2):(q=t,We===0&&De(qp)),q!==t&&(yt=R,q=Jp()),R=q,R===t&&(R=G,r.substr(G,2)===xr?(q=xr,G+=2):(q=t,We===0&&De(oe)),q!==t&&(yt=R,q=Io()),R=q,R===t&&(R=G,r.substr(G,2)===kn?(q=kn,G+=2):(q=t,We===0&&De(Fg)),q!==t&&(yt=R,q=Qt()),R=q,R===t&&(R=G,r.substr(G,2)===Vl?(q=Vl,G+=2):(q=t,We===0&&De(Rn)),q!==t?(pe=bA(),pe!==t?(Ne=bA(),Ne!==t?(xe=bA(),xe!==t?(qe=bA(),qe!==t?(yt=R,q=$n(pe,Ne,xe,qe),R=q):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)):(G=R,R=t)))))))))),R}function bA(){var R;return es.test(r.charAt(G))?(R=r.charAt(G),G++):(R=t,We===0&&De(ut)),R}function Fr(){var R,q;if(We++,R=[],at.test(r.charAt(G))?(q=r.charAt(G),G++):(q=t,We===0&&De(ln)),q!==t)for(;q!==t;)R.push(q),at.test(r.charAt(G))?(q=r.charAt(G),G++):(q=t,We===0&&De(ln));else R=t;return We--,R===t&&(q=t,We===0&&De(yo)),R}function hI(){var R,q;if(We++,R=[],Tt.test(r.charAt(G))?(q=r.charAt(G),G++):(q=t,We===0&&De(Ng)),q!==t)for(;q!==t;)R.push(q),Tt.test(r.charAt(G))?(q=r.charAt(G),G++):(q=t,We===0&&De(Ng));else R=t;return We--,R===t&&(q=t,We===0&&De(S)),R}function Hs(){var R,q,pe,Ne,xe,qe;if(R=G,q=Gs(),q!==t){for(pe=[],Ne=G,xe=Fr(),xe===t&&(xe=null),xe!==t?(qe=Gs(),qe!==t?(xe=[xe,qe],Ne=xe):(G=Ne,Ne=t)):(G=Ne,Ne=t);Ne!==t;)pe.push(Ne),Ne=G,xe=Fr(),xe===t&&(xe=null),xe!==t?(qe=Gs(),qe!==t?(xe=[xe,qe],Ne=xe):(G=Ne,Ne=t)):(G=Ne,Ne=t);pe!==t?(q=[q,pe],R=q):(G=R,R=t)}else G=R,R=t;return R}function Gs(){var R;return r.substr(G,2)===Xl?(R=Xl,G+=2):(R=t,We===0&&De(Wp)),R===t&&(r.charCodeAt(G)===10?(R=zp,G++):(R=t,We===0&&De(Vp)),R===t&&(r.charCodeAt(G)===13?(R=Xp,G++):(R=t,We===0&&De(_p)))),R}let Hg=2,SA=0;if(da=n(),da!==t&&G===r.length)return da;throw da!==t&&G{"use strict";var Jde=r=>{let e=!1,t=!1,i=!1;for(let n=0;n{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");e=Object.assign({pascalCase:!1},e);let t=n=>e.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(r)?r=r.map(n=>n.trim()).filter(n=>n.length).join("-"):r=r.trim(),r.length===0?"":r.length===1?e.pascalCase?r.toUpperCase():r.toLowerCase():(r!==r.toLowerCase()&&(r=Jde(r)),r=r.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,s)=>s.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),t(r))};Fv.exports=GH;Fv.exports.default=GH});var jH=y((p$e,Wde)=>{Wde.exports=[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI",pr:"SYSTEM_PULLREQUEST_PULLREQUESTID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE"},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Shippable",constant:"SHIPPABLE",env:"SHIPPABLE",pr:{IS_PULL_REQUEST:"true"}},{name:"Solano CI",constant:"SOLANO",env:"TDDIUM",pr:"TDDIUM_PR_ID"},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vercel",constant:"VERCEL",env:"NOW_BUILDER"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"}]});var yc=y(Mn=>{"use strict";var JH=jH(),vo=process.env;Object.defineProperty(Mn,"_vendors",{value:JH.map(function(r){return r.constant})});Mn.name=null;Mn.isPR=null;JH.forEach(function(r){let t=(Array.isArray(r.env)?r.env:[r.env]).every(function(i){return qH(i)});if(Mn[r.constant]=t,t)switch(Mn.name=r.name,typeof r.pr){case"string":Mn.isPR=!!vo[r.pr];break;case"object":"env"in r.pr?Mn.isPR=r.pr.env in vo&&vo[r.pr.env]!==r.pr.ne:"any"in r.pr?Mn.isPR=r.pr.any.some(function(i){return!!vo[i]}):Mn.isPR=qH(r.pr);break;default:Mn.isPR=null}});Mn.isCI=!!(vo.CI||vo.CONTINUOUS_INTEGRATION||vo.BUILD_NUMBER||vo.RUN_ID||Mn.name);function qH(r){return typeof r=="string"?!!vo[r]:Object.keys(r).every(function(e){return vo[e]===r[e]})}});var ey=y(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var zde=0,Vde=1,Xde=2,_de="",Zde="\0",$de=-1,eCe=/^(-h|--help)(?:=([0-9]+))?$/,tCe=/^(--[a-z]+(?:-[a-z]+)*|-[a-zA-Z]+)$/,rCe=/^-[a-zA-Z]{2,}$/,iCe=/^([^=]+)=([\s\S]*)$/,nCe=process.env.DEBUG_CLI==="1";Kn.BATCH_REGEX=rCe;Kn.BINDING_REGEX=iCe;Kn.DEBUG=nCe;Kn.END_OF_INPUT=Zde;Kn.HELP_COMMAND_INDEX=$de;Kn.HELP_REGEX=eCe;Kn.NODE_ERRORED=Xde;Kn.NODE_INITIAL=zde;Kn.NODE_SUCCESS=Vde;Kn.OPTION_REGEX=tCe;Kn.START_OF_INPUT=_de});var ty=y(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});var sCe=ey(),Nv=class extends Error{constructor(e){super(e),this.clipanion={type:"usage"},this.name="UsageError"}},Lv=class extends Error{constructor(e,t){if(super(),this.input=e,this.candidates=t,this.clipanion={type:"none"},this.name="UnknownSyntaxError",this.candidates.length===0)this.message="Command not found, but we're not sure what's the alternative.";else if(this.candidates.every(i=>i.reason!==null&&i.reason===t[0].reason)){let[{reason:i}]=this.candidates;this.message=`${i} + +${this.candidates.map(({usage:n})=>`$ ${n}`).join(` +`)}`}else if(this.candidates.length===1){let[{usage:i}]=this.candidates;this.message=`Command not found; did you mean: + +$ ${i} +${Ov(e)}`}else this.message=`Command not found; did you mean one of: + +${this.candidates.map(({usage:i},n)=>`${`${n}.`.padStart(4)} ${i}`).join(` +`)} + +${Ov(e)}`}},Tv=class extends Error{constructor(e,t){super(),this.input=e,this.usages=t,this.clipanion={type:"none"},this.name="AmbiguousSyntaxError",this.message=`Cannot find which to pick amongst the following alternatives: + +${this.usages.map((i,n)=>`${`${n}.`.padStart(4)} ${i}`).join(` +`)} + +${Ov(e)}`}},Ov=r=>`While running ${r.filter(e=>e!==sCe.END_OF_INPUT).map(e=>{let t=JSON.stringify(e);return e.match(/\s/)||e.length===0||t!==`"${e}"`?t:e}).join(" ")}`;Bd.AmbiguousSyntaxError=Tv;Bd.UnknownSyntaxError=Lv;Bd.UsageError=Nv});var Sa=y(NA=>{"use strict";Object.defineProperty(NA,"__esModule",{value:!0});var WH=ty(),zH=Symbol("clipanion/isOption");function oCe(r){return{...r,[zH]:!0}}function aCe(r,e){return typeof r>"u"?[r,e]:typeof r=="object"&&r!==null&&!Array.isArray(r)?[void 0,r]:[r,e]}function Mv(r,e=!1){let t=r.replace(/^\.: /,"");return e&&(t=t[0].toLowerCase()+t.slice(1)),t}function VH(r,e){return e.length===1?new WH.UsageError(`${r}: ${Mv(e[0],!0)}`):new WH.UsageError(`${r}: +${e.map(t=>` +- ${Mv(t)}`).join("")}`)}function ACe(r,e,t){if(typeof t>"u")return e;let i=[],n=[],s=a=>{let l=e;return e=a,s.bind(null,l)};if(!t(e,{errors:i,coercions:n,coercion:s}))throw VH(`Invalid value for ${r}`,i);for(let[,a]of n)a();return e}NA.applyValidator=ACe;NA.cleanValidationError=Mv;NA.formatError=VH;NA.isOptionSymbol=zH;NA.makeCommandOption=oCe;NA.rerouteArguments=aCe});var ns=y(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});var XH=/^[a-zA-Z_][a-zA-Z0-9_]*$/,_H=/^#[0-9a-f]{6}$/i,ZH=/^#[0-9a-f]{6}([0-9a-f]{2})?$/i,$H=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,eG=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$/i,Kv=/^(?:[1-9]\d{3}(-?)(?:(?:0[1-9]|1[0-2])\1(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])\1(?:29|30)|(?:0[13578]|1[02])(?:\1)31|00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[0-5]))|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)(?:(-?)02(?:\2)29|-?366))T(?:[01]\d|2[0-3])(:?)[0-5]\d(?:\3[0-5]\d)?(?:Z|[+-][01]\d(?:\3[0-5]\d)?)$/,tG=r=>()=>r;function bt({test:r}){return tG(r)()}function Zr(r){return r===null?"null":r===void 0?"undefined":r===""?"an empty string":JSON.stringify(r)}function LA(r,e){var t,i,n;return typeof e=="number"?`${(t=r==null?void 0:r.p)!==null&&t!==void 0?t:"."}[${e}]`:XH.test(e)?`${(i=r==null?void 0:r.p)!==null&&i!==void 0?i:""}.${e}`:`${(n=r==null?void 0:r.p)!==null&&n!==void 0?n:"."}[${JSON.stringify(e)}]`}function wc(r,e){return t=>{let i=r[e];return r[e]=t,wc(r,e).bind(null,i)}}function rG(r,e){return t=>{r[e]=t}}function ry(r,e,t){return r===1?e:t}function pt({errors:r,p:e}={},t){return r==null||r.push(`${e!=null?e:"."}: ${t}`),!1}var iG=()=>bt({test:(r,e)=>!0});function lCe(r){return bt({test:(e,t)=>e!==r?pt(t,`Expected a literal (got ${Zr(r)})`):!0})}var cCe=()=>bt({test:(r,e)=>typeof r!="string"?pt(e,`Expected a string (got ${Zr(r)})`):!0});function uCe(r){let e=Array.isArray(r)?r:Object.values(r),t=new Set(e);return bt({test:(i,n)=>t.has(i)?!0:pt(n,`Expected a valid enumeration value (got ${Zr(i)})`)})}var gCe=new Map([["true",!0],["True",!0],["1",!0],[1,!0],["false",!1],["False",!1],["0",!1],[0,!1]]),fCe=()=>bt({test:(r,e)=>{var t;if(typeof r!="boolean"){if(typeof(e==null?void 0:e.coercions)<"u"){if(typeof(e==null?void 0:e.coercion)>"u")return pt(e,"Unbound coercion result");let i=gCe.get(r);if(typeof i<"u")return e.coercions.push([(t=e.p)!==null&&t!==void 0?t:".",e.coercion.bind(null,i)]),!0}return pt(e,`Expected a boolean (got ${Zr(r)})`)}return!0}}),hCe=()=>bt({test:(r,e)=>{var t;if(typeof r!="number"){if(typeof(e==null?void 0:e.coercions)<"u"){if(typeof(e==null?void 0:e.coercion)>"u")return pt(e,"Unbound coercion result");let i;if(typeof r=="string"){let n;try{n=JSON.parse(r)}catch{}if(typeof n=="number")if(JSON.stringify(n)===r)i=n;else return pt(e,`Received a number that can't be safely represented by the runtime (${r})`)}if(typeof i<"u")return e.coercions.push([(t=e.p)!==null&&t!==void 0?t:".",e.coercion.bind(null,i)]),!0}return pt(e,`Expected a number (got ${Zr(r)})`)}return!0}}),pCe=()=>bt({test:(r,e)=>{var t;if(!(r instanceof Date)){if(typeof(e==null?void 0:e.coercions)<"u"){if(typeof(e==null?void 0:e.coercion)>"u")return pt(e,"Unbound coercion result");let i;if(typeof r=="string"&&Kv.test(r))i=new Date(r);else{let n;if(typeof r=="string"){let s;try{s=JSON.parse(r)}catch{}typeof s=="number"&&(n=s)}else typeof r=="number"&&(n=r);if(typeof n<"u")if(Number.isSafeInteger(n)||!Number.isSafeInteger(n*1e3))i=new Date(n*1e3);else return pt(e,`Received a timestamp that can't be safely represented by the runtime (${r})`)}if(typeof i<"u")return e.coercions.push([(t=e.p)!==null&&t!==void 0?t:".",e.coercion.bind(null,i)]),!0}return pt(e,`Expected a date (got ${Zr(r)})`)}return!0}}),dCe=(r,{delimiter:e}={})=>bt({test:(t,i)=>{var n;if(typeof t=="string"&&typeof e<"u"&&typeof(i==null?void 0:i.coercions)<"u"){if(typeof(i==null?void 0:i.coercion)>"u")return pt(i,"Unbound coercion result");t=t.split(e),i.coercions.push([(n=i.p)!==null&&n!==void 0?n:".",i.coercion.bind(null,t)])}if(!Array.isArray(t))return pt(i,`Expected an array (got ${Zr(t)})`);let s=!0;for(let o=0,a=t.length;o{let t=nG(r.length);return bt({test:(i,n)=>{var s;if(typeof i=="string"&&typeof e<"u"&&typeof(n==null?void 0:n.coercions)<"u"){if(typeof(n==null?void 0:n.coercion)>"u")return pt(n,"Unbound coercion result");i=i.split(e),n.coercions.push([(s=n.p)!==null&&s!==void 0?s:".",n.coercion.bind(null,i)])}if(!Array.isArray(i))return pt(n,`Expected a tuple (got ${Zr(i)})`);let o=t(i,Object.assign({},n));for(let a=0,l=i.length;abt({test:(t,i)=>{if(typeof t!="object"||t===null)return pt(i,`Expected an object (got ${Zr(t)})`);let n=Object.keys(t),s=!0;for(let o=0,a=n.length;o{let t=Object.keys(r);return bt({test:(i,n)=>{if(typeof i!="object"||i===null)return pt(n,`Expected an object (got ${Zr(i)})`);let s=new Set([...t,...Object.keys(i)]),o={},a=!0;for(let l of s){if(l==="constructor"||l==="__proto__")a=pt(Object.assign(Object.assign({},n),{p:LA(n,l)}),"Unsafe property name");else{let c=Object.prototype.hasOwnProperty.call(r,l)?r[l]:void 0,u=Object.prototype.hasOwnProperty.call(i,l)?i[l]:void 0;typeof c<"u"?a=c(u,Object.assign(Object.assign({},n),{p:LA(n,l),coercion:wc(i,l)}))&&a:e===null?a=pt(Object.assign(Object.assign({},n),{p:LA(n,l)}),`Extraneous property (got ${Zr(u)})`):Object.defineProperty(o,l,{enumerable:!0,get:()=>u,set:rG(i,l)})}if(!a&&(n==null?void 0:n.errors)==null)break}return e!==null&&(a||(n==null?void 0:n.errors)!=null)&&(a=e(o,n)&&a),a}})},ICe=r=>bt({test:(e,t)=>e instanceof r?!0:pt(t,`Expected an instance of ${r.name} (got ${Zr(e)})`)}),yCe=(r,{exclusive:e=!1}={})=>bt({test:(t,i)=>{var n,s,o;let a=[],l=typeof(i==null?void 0:i.errors)<"u"?[]:void 0;for(let c=0,u=r.length;c1?pt(i,`Expected to match exactly a single predicate (matched ${a.join(", ")})`):(o=i==null?void 0:i.errors)===null||o===void 0||o.push(...l),!1}}),wCe=(r,e)=>bt({test:(t,i)=>{var n,s;let o={value:t},a=typeof(i==null?void 0:i.coercions)<"u"?wc(o,"value"):void 0,l=typeof(i==null?void 0:i.coercions)<"u"?[]:void 0;if(!r(t,Object.assign(Object.assign({},i),{coercion:a,coercions:l})))return!1;let c=[];if(typeof l<"u")for(let[,u]of l)c.push(u());try{if(typeof(i==null?void 0:i.coercions)<"u"){if(o.value!==t){if(typeof(i==null?void 0:i.coercion)>"u")return pt(i,"Unbound coercion result");i.coercions.push([(n=i.p)!==null&&n!==void 0?n:".",i.coercion.bind(null,o.value)])}(s=i==null?void 0:i.coercions)===null||s===void 0||s.push(...l)}return e.every(u=>u(o.value,i))}finally{for(let u of c)u()}}}),BCe=r=>bt({test:(e,t)=>typeof e>"u"?!0:r(e,t)}),QCe=r=>bt({test:(e,t)=>e===null?!0:r(e,t)}),bCe=r=>bt({test:(e,t)=>e.length>=r?!0:pt(t,`Expected to have a length of at least ${r} elements (got ${e.length})`)}),SCe=r=>bt({test:(e,t)=>e.length<=r?!0:pt(t,`Expected to have a length of at most ${r} elements (got ${e.length})`)}),nG=r=>bt({test:(e,t)=>e.length!==r?pt(t,`Expected to have a length of exactly ${r} elements (got ${e.length})`):!0}),vCe=({map:r}={})=>bt({test:(e,t)=>{let i=new Set,n=new Set;for(let s=0,o=e.length;sbt({test:(r,e)=>r<=0?!0:pt(e,`Expected to be negative (got ${r})`)}),PCe=()=>bt({test:(r,e)=>r>=0?!0:pt(e,`Expected to be positive (got ${r})`)}),DCe=r=>bt({test:(e,t)=>e>=r?!0:pt(t,`Expected to be at least ${r} (got ${e})`)}),kCe=r=>bt({test:(e,t)=>e<=r?!0:pt(t,`Expected to be at most ${r} (got ${e})`)}),RCe=(r,e)=>bt({test:(t,i)=>t>=r&&t<=e?!0:pt(i,`Expected to be in the [${r}; ${e}] range (got ${t})`)}),FCe=(r,e)=>bt({test:(t,i)=>t>=r&&tbt({test:(e,t)=>e!==Math.round(e)?pt(t,`Expected to be an integer (got ${e})`):Number.isSafeInteger(e)?!0:pt(t,`Expected to be a safe integer (got ${e})`)}),LCe=r=>bt({test:(e,t)=>r.test(e)?!0:pt(t,`Expected to match the pattern ${r.toString()} (got ${Zr(e)})`)}),TCe=()=>bt({test:(r,e)=>r!==r.toLowerCase()?pt(e,`Expected to be all-lowercase (got ${r})`):!0}),OCe=()=>bt({test:(r,e)=>r!==r.toUpperCase()?pt(e,`Expected to be all-uppercase (got ${r})`):!0}),MCe=()=>bt({test:(r,e)=>eG.test(r)?!0:pt(e,`Expected to be a valid UUID v4 (got ${Zr(r)})`)}),KCe=()=>bt({test:(r,e)=>Kv.test(r)?!1:pt(e,`Expected to be a valid ISO 8601 date string (got ${Zr(r)})`)}),UCe=({alpha:r=!1})=>bt({test:(e,t)=>(r?_H.test(e):ZH.test(e))?!0:pt(t,`Expected to be a valid hexadecimal color string (got ${Zr(e)})`)}),HCe=()=>bt({test:(r,e)=>$H.test(r)?!0:pt(e,`Expected to be a valid base 64 string (got ${Zr(r)})`)}),GCe=(r=iG())=>bt({test:(e,t)=>{let i;try{i=JSON.parse(e)}catch{return pt(t,`Expected to be a valid JSON string (got ${Zr(e)})`)}return r(i,t)}}),YCe=r=>{let e=new Set(r);return bt({test:(t,i)=>{let n=new Set(Object.keys(t)),s=[];for(let o of e)n.has(o)||s.push(o);return s.length>0?pt(i,`Missing required ${ry(s.length,"property","properties")} ${s.map(o=>`"${o}"`).join(", ")}`):!0}})},jCe=r=>{let e=new Set(r);return bt({test:(t,i)=>{let n=new Set(Object.keys(t)),s=[];for(let o of e)n.has(o)&&s.push(o);return s.length>0?pt(i,`Forbidden ${ry(s.length,"property","properties")} ${s.map(o=>`"${o}"`).join(", ")}`):!0}})},qCe=r=>{let e=new Set(r);return bt({test:(t,i)=>{let n=new Set(Object.keys(t)),s=[];for(let o of e)n.has(o)&&s.push(o);return s.length>1?pt(i,`Mutually exclusive properties ${s.map(o=>`"${o}"`).join(", ")}`):!0}})};(function(r){r.Forbids="Forbids",r.Requires="Requires"})(st.KeyRelationship||(st.KeyRelationship={}));var JCe={[st.KeyRelationship.Forbids]:{expect:!1,message:"forbids using"},[st.KeyRelationship.Requires]:{expect:!0,message:"requires using"}},WCe=(r,e,t,{ignore:i=[]}={})=>{let n=new Set(i),s=new Set(t),o=JCe[e];return bt({test:(a,l)=>{let c=new Set(Object.keys(a));if(!c.has(r)||n.has(a[r]))return!0;let u=[];for(let g of s)(c.has(g)&&!n.has(a[g]))!==o.expect&&u.push(g);return u.length>=1?pt(l,`Property "${r}" ${o.message} ${ry(u.length,"property","properties")} ${u.map(g=>`"${g}"`).join(", ")}`):!0}})};st.applyCascade=wCe;st.base64RegExp=$H;st.colorStringAlphaRegExp=ZH;st.colorStringRegExp=_H;st.computeKey=LA;st.getPrintable=Zr;st.hasExactLength=nG;st.hasForbiddenKeys=jCe;st.hasKeyRelationship=WCe;st.hasMaxLength=SCe;st.hasMinLength=bCe;st.hasMutuallyExclusiveKeys=qCe;st.hasRequiredKeys=YCe;st.hasUniqueItems=vCe;st.isArray=dCe;st.isAtLeast=DCe;st.isAtMost=kCe;st.isBase64=HCe;st.isBoolean=fCe;st.isDate=pCe;st.isDict=mCe;st.isEnum=uCe;st.isHexColor=UCe;st.isISO8601=KCe;st.isInExclusiveRange=FCe;st.isInInclusiveRange=RCe;st.isInstanceOf=ICe;st.isInteger=NCe;st.isJSON=GCe;st.isLiteral=lCe;st.isLowerCase=TCe;st.isNegative=xCe;st.isNullable=QCe;st.isNumber=hCe;st.isObject=ECe;st.isOneOf=yCe;st.isOptional=BCe;st.isPositive=PCe;st.isString=cCe;st.isTuple=CCe;st.isUUID4=MCe;st.isUnknown=iG;st.isUpperCase=OCe;st.iso8601RegExp=Kv;st.makeCoercionFn=wc;st.makeSetter=rG;st.makeTrait=tG;st.makeValidator=bt;st.matchesRegExp=LCe;st.plural=ry;st.pushError=pt;st.simpleKeyRegExp=XH;st.uuid4RegExp=eG});var Bc=y(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});var sG=Sa();function zCe(r){if(r&&r.__esModule)return r;var e=Object.create(null);return r&&Object.keys(r).forEach(function(t){if(t!=="default"){var i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:function(){return r[t]}})}}),e.default=r,Object.freeze(e)}var Qd=class{constructor(){this.help=!1}static Usage(e){return e}async catch(e){throw e}async validateAndExecute(){let t=this.constructor.schema;if(Array.isArray(t)){let{isDict:n,isUnknown:s,applyCascade:o}=await Promise.resolve().then(function(){return zCe(ns())}),a=o(n(s()),t),l=[],c=[];if(!a(this,{errors:l,coercions:c}))throw sG.formatError("Invalid option schema",l);for(let[,g]of c)g()}else if(t!=null)throw new Error("Invalid command schema");let i=await this.execute();return typeof i<"u"?i:0}};Qd.isOption=sG.isOptionSymbol;Qd.Default=[];Uv.Command=Qd});var Gv=y(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:!0});var oG=80,Hv=Array(oG).fill("\u2501");for(let r=0;r<=24;++r)Hv[Hv.length-r]=`\x1B[38;5;${232+r}m\u2501`;var VCe={header:r=>`\x1B[1m\u2501\u2501\u2501 ${r}${r.length`\x1B[1m${r}\x1B[22m`,error:r=>`\x1B[31m\x1B[1m${r}\x1B[22m\x1B[39m`,code:r=>`\x1B[36m${r}\x1B[39m`},XCe={header:r=>r,bold:r=>r,error:r=>r,code:r=>r};function _Ce(r){let e=r.split(` +`),t=e.filter(n=>n.match(/\S/)),i=t.length>0?t.reduce((n,s)=>Math.min(n,s.length-s.trimStart().length),Number.MAX_VALUE):0;return e.map(n=>n.slice(i).trimRight()).join(` +`)}function ZCe(r,{format:e,paragraphs:t}){return r=r.replace(/\r\n?/g,` +`),r=_Ce(r),r=r.replace(/^\n+|\n+$/g,""),r=r.replace(/^(\s*)-([^\n]*?)\n+/gm,`$1-$2 + +`),r=r.replace(/\n(\n)?\n*/g,"$1"),t&&(r=r.split(/\n/).map(i=>{let n=i.match(/^\s*[*-][\t ]+(.*)/);if(!n)return i.match(/(.{1,80})(?: |$)/g).join(` +`);let s=i.length-i.trimStart().length;return n[1].match(new RegExp(`(.{1,${78-s}})(?: |$)`,"g")).map((o,a)=>" ".repeat(s)+(a===0?"- ":" ")+o).join(` +`)}).join(` + +`)),r=r.replace(/(`+)((?:.|[\n])*?)\1/g,(i,n,s)=>e.code(n+s+n)),r=r.replace(/(\*\*)((?:.|[\n])*?)\1/g,(i,n,s)=>e.bold(n+s+n)),r?`${r} +`:""}bd.formatMarkdownish=ZCe;bd.richFormat=VCe;bd.textFormat=XCe});var ay=y(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});var lt=ey(),sy=ty();function Vi(r){lt.DEBUG&&console.log(r)}var aG={candidateUsage:null,requiredOptions:[],errorMessage:null,ignoreOptions:!1,path:[],positionals:[],options:[],remainder:null,selectedIndex:lt.HELP_COMMAND_INDEX};function Yv(){return{nodes:[Ti(),Ti(),Ti()]}}function AG(r){let e=Yv(),t=[],i=e.nodes.length;for(let n of r){t.push(i);for(let s=0;s{if(e.has(i))return;e.add(i);let n=r.nodes[i];for(let o of Object.values(n.statics))for(let{to:a}of o)t(a);for(let[,{to:o}]of n.dynamics)t(o);for(let{to:o}of n.shortcuts)t(o);let s=new Set(n.shortcuts.map(({to:o})=>o));for(;n.shortcuts.length>0;){let{to:o}=n.shortcuts.shift(),a=r.nodes[o];for(let[l,c]of Object.entries(a.statics)){let u=Object.prototype.hasOwnProperty.call(n.statics,l)?n.statics[l]:n.statics[l]=[];for(let g of c)u.some(({to:f})=>g.to===f)||u.push(g)}for(let[l,c]of a.dynamics)n.dynamics.some(([u,{to:g}])=>l===u&&c.to===g)||n.dynamics.push([l,c]);for(let l of a.shortcuts)s.has(l.to)||(n.shortcuts.push(l),s.add(l.to))}};t(lt.NODE_INITIAL)}function cG(r,{prefix:e=""}={}){if(lt.DEBUG){Vi(`${e}Nodes are:`);for(let t=0;tl!==lt.NODE_ERRORED).map(({state:l})=>({usage:l.candidateUsage,reason:null})));if(a.every(({node:l})=>l===lt.NODE_ERRORED))throw new sy.UnknownSyntaxError(e,a.map(({state:l})=>({usage:l.candidateUsage,reason:l.errorMessage})));i=uG(a)}if(i.length>0){Vi(" Results:");for(let s of i)Vi(` - ${s.node} -> ${JSON.stringify(s.state)}`)}else Vi(" No results");return i}function $Ce(r,e){if(e.selectedIndex!==null)return!0;if(Object.prototype.hasOwnProperty.call(r.statics,lt.END_OF_INPUT)){for(let{to:t}of r.statics[lt.END_OF_INPUT])if(t===lt.NODE_SUCCESS)return!0}return!1}function eme(r,e,t){let i=t&&e.length>0?[""]:[],n=jv(r,e,t),s=[],o=new Set,a=(l,c,u=!0)=>{let g=[c];for(;g.length>0;){let h=g;g=[];for(let p of h){let C=r.nodes[p],w=Object.keys(C.statics);for(let B of Object.keys(C.statics)){let v=w[0];for(let{to:D,reducer:L}of C.statics[v])L==="pushPath"&&(u||l.push(v),g.push(D))}}u=!1}let f=JSON.stringify(l);o.has(f)||(s.push(l),o.add(f))};for(let{node:l,state:c}of n){if(c.remainder!==null){a([c.remainder],l);continue}let u=r.nodes[l],g=$Ce(u,c);for(let[f,h]of Object.entries(u.statics))(g&&f!==lt.END_OF_INPUT||!f.startsWith("-")&&h.some(({reducer:p})=>p==="pushPath"))&&a([...i,f],l);if(!!g)for(let[f,{to:h}]of u.dynamics){if(h===lt.NODE_ERRORED)continue;let p=dG(f,c);if(p!==null)for(let C of p)a([...i,C],l)}}return[...s].sort()}function tme(r,e){let t=jv(r,[...e,lt.END_OF_INPUT]);return gG(e,t.map(({state:i})=>i))}function uG(r){let e=0;for(let{state:t}of r)t.path.length>e&&(e=t.path.length);return r.filter(({state:t})=>t.path.length===e)}function gG(r,e){let t=e.filter(g=>g.selectedIndex!==null);if(t.length===0)throw new Error;let i=t.filter(g=>g.requiredOptions.every(f=>f.some(h=>g.options.find(p=>p.name===h))));if(i.length===0)throw new sy.UnknownSyntaxError(r,t.map(g=>({usage:g.candidateUsage,reason:null})));let n=0;for(let g of i)g.path.length>n&&(n=g.path.length);let s=i.filter(g=>g.path.length===n),o=g=>g.positionals.filter(({extra:f})=>!f).length+g.options.length,a=s.map(g=>({state:g,positionalCount:o(g)})),l=0;for(let{positionalCount:g}of a)g>l&&(l=g);let c=a.filter(({positionalCount:g})=>g===l).map(({state:g})=>g),u=fG(c);if(u.length>1)throw new sy.AmbiguousSyntaxError(r,u.map(g=>g.candidateUsage));return u[0]}function fG(r){let e=[],t=[];for(let i of r)i.selectedIndex===lt.HELP_COMMAND_INDEX?t.push(i):e.push(i);return t.length>0&&e.push({...aG,path:hG(...t.map(i=>i.path)),options:t.reduce((i,n)=>i.concat(n.options),[])}),e}function hG(r,e,...t){return e===void 0?Array.from(r):hG(r.filter((i,n)=>i===e[n]),...t)}function Ti(){return{dynamics:[],shortcuts:[],statics:{}}}function qv(r){return r===lt.NODE_SUCCESS||r===lt.NODE_ERRORED}function iy(r,e=0){return{to:qv(r.to)?r.to:r.to>2?r.to+e-2:r.to+e,reducer:r.reducer}}function pG(r,e=0){let t=Ti();for(let[i,n]of r.dynamics)t.dynamics.push([i,iy(n,e)]);for(let i of r.shortcuts)t.shortcuts.push(iy(i,e));for(let[i,n]of Object.entries(r.statics))t.statics[i]=n.map(s=>iy(s,e));return t}function Ei(r,e,t,i,n){r.nodes[e].dynamics.push([t,{to:i,reducer:n}])}function Qc(r,e,t,i){r.nodes[e].shortcuts.push({to:t,reducer:i})}function xo(r,e,t,i,n){(Object.prototype.hasOwnProperty.call(r.nodes[e].statics,t)?r.nodes[e].statics[t]:r.nodes[e].statics[t]=[]).push({to:i,reducer:n})}function Sd(r,e,t,i){if(Array.isArray(e)){let[n,...s]=e;return r[n](t,i,...s)}else return r[e](t,i)}function dG(r,e){let t=Array.isArray(r)?vd[r[0]]:vd[r];if(typeof t.suggest>"u")return null;let i=Array.isArray(r)?r.slice(1):[];return t.suggest(e,...i)}var vd={always:()=>!0,isOptionLike:(r,e)=>!r.ignoreOptions&&e!=="-"&&e.startsWith("-"),isNotOptionLike:(r,e)=>r.ignoreOptions||e==="-"||!e.startsWith("-"),isOption:(r,e,t,i)=>!r.ignoreOptions&&e===t,isBatchOption:(r,e,t)=>!r.ignoreOptions&<.BATCH_REGEX.test(e)&&[...e.slice(1)].every(i=>t.includes(`-${i}`)),isBoundOption:(r,e,t,i)=>{let n=e.match(lt.BINDING_REGEX);return!r.ignoreOptions&&!!n&<.OPTION_REGEX.test(n[1])&&t.includes(n[1])&&i.filter(s=>s.names.includes(n[1])).every(s=>s.allowBinding)},isNegatedOption:(r,e,t)=>!r.ignoreOptions&&e===`--no-${t.slice(2)}`,isHelp:(r,e)=>!r.ignoreOptions&<.HELP_REGEX.test(e),isUnsupportedOption:(r,e,t)=>!r.ignoreOptions&&e.startsWith("-")&<.OPTION_REGEX.test(e)&&!t.includes(e),isInvalidOption:(r,e)=>!r.ignoreOptions&&e.startsWith("-")&&!lt.OPTION_REGEX.test(e)};vd.isOption.suggest=(r,e,t=!0)=>t?null:[e];var ny={setCandidateState:(r,e,t)=>({...r,...t}),setSelectedIndex:(r,e,t)=>({...r,selectedIndex:t}),pushBatch:(r,e)=>({...r,options:r.options.concat([...e.slice(1)].map(t=>({name:`-${t}`,value:!0})))}),pushBound:(r,e)=>{let[,t,i]=e.match(lt.BINDING_REGEX);return{...r,options:r.options.concat({name:t,value:i})}},pushPath:(r,e)=>({...r,path:r.path.concat(e)}),pushPositional:(r,e)=>({...r,positionals:r.positionals.concat({value:e,extra:!1})}),pushExtra:(r,e)=>({...r,positionals:r.positionals.concat({value:e,extra:!0})}),pushExtraNoLimits:(r,e)=>({...r,positionals:r.positionals.concat({value:e,extra:Po})}),pushTrue:(r,e,t=e)=>({...r,options:r.options.concat({name:e,value:!0})}),pushFalse:(r,e,t=e)=>({...r,options:r.options.concat({name:t,value:!1})}),pushUndefined:(r,e)=>({...r,options:r.options.concat({name:e,value:void 0})}),pushStringValue:(r,e)=>{var t;let i={...r,options:[...r.options]},n=r.options[r.options.length-1];return n.value=((t=n.value)!==null&&t!==void 0?t:[]).concat([e]),i},setStringValue:(r,e)=>{let t={...r,options:[...r.options]},i=r.options[r.options.length-1];return i.value=e,t},inhibateOptions:r=>({...r,ignoreOptions:!0}),useHelp:(r,e,t)=>{let[,,i]=e.match(lt.HELP_REGEX);return typeof i<"u"?{...r,options:[{name:"-c",value:String(t)},{name:"-i",value:i}]}:{...r,options:[{name:"-c",value:String(t)}]}},setError:(r,e,t)=>e===lt.END_OF_INPUT?{...r,errorMessage:`${t}.`}:{...r,errorMessage:`${t} ("${e}").`},setOptionArityError:(r,e)=>{let t=r.options[r.options.length-1];return{...r,errorMessage:`Not enough arguments to option ${t.name}.`}}},Po=Symbol(),oy=class{constructor(e,t){this.allOptionNames=[],this.arity={leading:[],trailing:[],extra:[],proxy:!1},this.options=[],this.paths=[],this.cliIndex=e,this.cliOpts=t}addPath(e){this.paths.push(e)}setArity({leading:e=this.arity.leading,trailing:t=this.arity.trailing,extra:i=this.arity.extra,proxy:n=this.arity.proxy}){Object.assign(this.arity,{leading:e,trailing:t,extra:i,proxy:n})}addPositional({name:e="arg",required:t=!0}={}){if(!t&&this.arity.extra===Po)throw new Error("Optional parameters cannot be declared when using .rest() or .proxy()");if(!t&&this.arity.trailing.length>0)throw new Error("Optional parameters cannot be declared after the required trailing positional arguments");!t&&this.arity.extra!==Po?this.arity.extra.push(e):this.arity.extra!==Po&&this.arity.extra.length===0?this.arity.leading.push(e):this.arity.trailing.push(e)}addRest({name:e="arg",required:t=0}={}){if(this.arity.extra===Po)throw new Error("Infinite lists cannot be declared multiple times in the same command");if(this.arity.trailing.length>0)throw new Error("Infinite lists cannot be declared after the required trailing positional arguments");for(let i=0;i1)throw new Error("The arity cannot be higher than 1 when the option only supports the --arg=value syntax");if(!Number.isInteger(i))throw new Error(`The arity must be an integer, got ${i}`);if(i<0)throw new Error(`The arity must be positive, got ${i}`);this.allOptionNames.push(...e),this.options.push({names:e,description:t,arity:i,hidden:n,required:s,allowBinding:o})}setContext(e){this.context=e}usage({detailed:e=!0,inlineOptions:t=!0}={}){let i=[this.cliOpts.binaryName],n=[];if(this.paths.length>0&&i.push(...this.paths[0]),e){for(let{names:o,arity:a,hidden:l,description:c,required:u}of this.options){if(l)continue;let g=[];for(let h=0;h`:`[${f}]`)}i.push(...this.arity.leading.map(o=>`<${o}>`)),this.arity.extra===Po?i.push("..."):i.push(...this.arity.extra.map(o=>`[${o}]`)),i.push(...this.arity.trailing.map(o=>`<${o}>`))}return{usage:i.join(" "),options:n}}compile(){if(typeof this.context>"u")throw new Error("Assertion failed: No context attached");let e=Yv(),t=lt.NODE_INITIAL,i=this.usage().usage,n=this.options.filter(a=>a.required).map(a=>a.names);t=ss(e,Ti()),xo(e,lt.NODE_INITIAL,lt.START_OF_INPUT,t,["setCandidateState",{candidateUsage:i,requiredOptions:n}]);let s=this.arity.proxy?"always":"isNotOptionLike",o=this.paths.length>0?this.paths:[[]];for(let a of o){let l=t;if(a.length>0){let f=ss(e,Ti());Qc(e,l,f),this.registerOptions(e,f),l=f}for(let f=0;f0||!this.arity.proxy){let f=ss(e,Ti());Ei(e,l,"isHelp",f,["useHelp",this.cliIndex]),xo(e,f,lt.END_OF_INPUT,lt.NODE_SUCCESS,["setSelectedIndex",lt.HELP_COMMAND_INDEX]),this.registerOptions(e,l)}this.arity.leading.length>0&&xo(e,l,lt.END_OF_INPUT,lt.NODE_ERRORED,["setError","Not enough positional arguments"]);let c=l;for(let f=0;f0||f+1!==this.arity.leading.length)&&xo(e,h,lt.END_OF_INPUT,lt.NODE_ERRORED,["setError","Not enough positional arguments"]),Ei(e,c,"isNotOptionLike",h,"pushPositional"),c=h}let u=c;if(this.arity.extra===Po||this.arity.extra.length>0){let f=ss(e,Ti());if(Qc(e,c,f),this.arity.extra===Po){let h=ss(e,Ti());this.arity.proxy||this.registerOptions(e,h),Ei(e,c,s,h,"pushExtraNoLimits"),Ei(e,h,s,h,"pushExtraNoLimits"),Qc(e,h,f)}else for(let h=0;h0&&xo(e,u,lt.END_OF_INPUT,lt.NODE_ERRORED,["setError","Not enough positional arguments"]);let g=u;for(let f=0;fo.length>s.length?o:s,"");if(i.arity===0)for(let s of i.names)Ei(e,t,["isOption",s,i.hidden||s!==n],t,"pushTrue"),s.startsWith("--")&&!s.startsWith("--no-")&&Ei(e,t,["isNegatedOption",s],t,["pushFalse",s]);else{let s=ss(e,Ti());for(let o of i.names)Ei(e,t,["isOption",o,i.hidden||o!==n],s,"pushUndefined");for(let o=0;o=0&&etme(i,n),suggest:(n,s)=>eme(i,n,s)}}};Ar.CliBuilder=xd;Ar.CommandBuilder=oy;Ar.NoLimits=Po;Ar.aggregateHelpStates=fG;Ar.cloneNode=pG;Ar.cloneTransition=iy;Ar.debug=Vi;Ar.debugMachine=cG;Ar.execute=Sd;Ar.injectNode=ss;Ar.isTerminalNode=qv;Ar.makeAnyOfMachine=AG;Ar.makeNode=Ti;Ar.makeStateMachine=Yv;Ar.reducers=ny;Ar.registerDynamic=Ei;Ar.registerShortcut=Qc;Ar.registerStatic=xo;Ar.runMachineInternal=jv;Ar.selectBestState=gG;Ar.simplifyMachine=lG;Ar.suggest=dG;Ar.tests=vd;Ar.trimSmallerBranches=uG});var CG=y(Jv=>{"use strict";Object.defineProperty(Jv,"__esModule",{value:!0});var rme=Bc(),Pd=class extends rme.Command{constructor(e){super(),this.contexts=e,this.commands=[]}static from(e,t){let i=new Pd(t);i.path=e.path;for(let n of e.options)switch(n.name){case"-c":i.commands.push(Number(n.value));break;case"-i":i.index=Number(n.value);break}return i}async execute(){let e=this.commands;if(typeof this.index<"u"&&this.index>=0&&this.index1){this.context.stdout.write(`Multiple commands match your selection: +`),this.context.stdout.write(` +`);let t=0;for(let i of this.commands)this.context.stdout.write(this.cli.usage(this.contexts[i].commandClass,{prefix:`${t++}. `.padStart(5)}));this.context.stdout.write(` +`),this.context.stdout.write(`Run again with -h= to see the longer details of any of those commands. +`)}}};Jv.HelpCommand=Pd});var BG=y(Wv=>{"use strict";Object.defineProperty(Wv,"__esModule",{value:!0});var ime=ey(),mG=Bc(),nme=J("tty"),sme=ay(),hn=Gv(),ome=CG();function ame(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var EG=ame(nme),IG=Symbol("clipanion/errorCommand");function Ame(){return process.env.FORCE_COLOR==="0"?1:process.env.FORCE_COLOR==="1"||typeof process.stdout<"u"&&process.stdout.isTTY?8:1}var TA=class{constructor({binaryLabel:e,binaryName:t="...",binaryVersion:i,enableCapture:n=!1,enableColors:s}={}){this.registrations=new Map,this.builder=new sme.CliBuilder({binaryName:t}),this.binaryLabel=e,this.binaryName=t,this.binaryVersion=i,this.enableCapture=n,this.enableColors=s}static from(e,t={}){let i=new TA(t);for(let n of e)i.register(n);return i}register(e){var t;let i=new Map,n=new e;for(let l in n){let c=n[l];typeof c=="object"&&c!==null&&c[mG.Command.isOption]&&i.set(l,c)}let s=this.builder.command(),o=s.cliIndex,a=(t=e.paths)!==null&&t!==void 0?t:n.paths;if(typeof a<"u")for(let l of a)s.addPath(l);this.registrations.set(e,{specs:i,builder:s,index:o});for(let[l,{definition:c}]of i.entries())c(s,l);s.setContext({commandClass:e})}process(e){let{contexts:t,process:i}=this.builder.compile(),n=i(e);switch(n.selectedIndex){case ime.HELP_COMMAND_INDEX:return ome.HelpCommand.from(n,t);default:{let{commandClass:s}=t[n.selectedIndex],o=this.registrations.get(s);if(typeof o>"u")throw new Error("Assertion failed: Expected the command class to have been registered.");let a=new s;a.path=n.path;try{for(let[l,{transformer:c}]of o.specs.entries())a[l]=c(o.builder,l,n);return a}catch(l){throw l[IG]=a,l}}break}}async run(e,t){var i;let n,s={...TA.defaultContext,...t},o=(i=this.enableColors)!==null&&i!==void 0?i:s.colorDepth>1;if(!Array.isArray(e))n=e;else try{n=this.process(e)}catch(c){return s.stdout.write(this.error(c,{colored:o})),1}if(n.help)return s.stdout.write(this.usage(n,{colored:o,detailed:!0})),0;n.context=s,n.cli={binaryLabel:this.binaryLabel,binaryName:this.binaryName,binaryVersion:this.binaryVersion,enableCapture:this.enableCapture,enableColors:this.enableColors,definitions:()=>this.definitions(),error:(c,u)=>this.error(c,u),format:c=>this.format(c),process:c=>this.process(c),run:(c,u)=>this.run(c,{...s,...u}),usage:(c,u)=>this.usage(c,u)};let a=this.enableCapture?lme(s):wG,l;try{l=await a(()=>n.validateAndExecute().catch(c=>n.catch(c).then(()=>0)))}catch(c){return s.stdout.write(this.error(c,{colored:o,command:n})),1}return l}async runExit(e,t){process.exitCode=await this.run(e,t)}suggest(e,t){let{suggest:i}=this.builder.compile();return i(e,t)}definitions({colored:e=!1}={}){let t=[];for(let[i,{index:n}]of this.registrations){if(typeof i.usage>"u")continue;let{usage:s}=this.getUsageByIndex(n,{detailed:!1}),{usage:o,options:a}=this.getUsageByIndex(n,{detailed:!0,inlineOptions:!1}),l=typeof i.usage.category<"u"?hn.formatMarkdownish(i.usage.category,{format:this.format(e),paragraphs:!1}):void 0,c=typeof i.usage.description<"u"?hn.formatMarkdownish(i.usage.description,{format:this.format(e),paragraphs:!1}):void 0,u=typeof i.usage.details<"u"?hn.formatMarkdownish(i.usage.details,{format:this.format(e),paragraphs:!0}):void 0,g=typeof i.usage.examples<"u"?i.usage.examples.map(([f,h])=>[hn.formatMarkdownish(f,{format:this.format(e),paragraphs:!1}),h.replace(/\$0/g,this.binaryName)]):void 0;t.push({path:s,usage:o,category:l,description:c,details:u,examples:g,options:a})}return t}usage(e=null,{colored:t,detailed:i=!1,prefix:n="$ "}={}){var s;if(e===null){for(let l of this.registrations.keys()){let c=l.paths,u=typeof l.usage<"u";if(!c||c.length===0||c.length===1&&c[0].length===0||((s=c==null?void 0:c.some(h=>h.length===0))!==null&&s!==void 0?s:!1))if(e){e=null;break}else e=l;else if(u){e=null;continue}}e&&(i=!0)}let o=e!==null&&e instanceof mG.Command?e.constructor:e,a="";if(o)if(i){let{description:l="",details:c="",examples:u=[]}=o.usage||{};l!==""&&(a+=hn.formatMarkdownish(l,{format:this.format(t),paragraphs:!1}).replace(/^./,h=>h.toUpperCase()),a+=` +`),(c!==""||u.length>0)&&(a+=`${this.format(t).header("Usage")} +`,a+=` +`);let{usage:g,options:f}=this.getUsageByRegistration(o,{inlineOptions:!1});if(a+=`${this.format(t).bold(n)}${g} +`,f.length>0){a+=` +`,a+=`${hn.richFormat.header("Options")} +`;let h=f.reduce((p,C)=>Math.max(p,C.definition.length),0);a+=` +`;for(let{definition:p,description:C}of f)a+=` ${this.format(t).bold(p.padEnd(h))} ${hn.formatMarkdownish(C,{format:this.format(t),paragraphs:!1})}`}if(c!==""&&(a+=` +`,a+=`${this.format(t).header("Details")} +`,a+=` +`,a+=hn.formatMarkdownish(c,{format:this.format(t),paragraphs:!0})),u.length>0){a+=` +`,a+=`${this.format(t).header("Examples")} +`;for(let[h,p]of u)a+=` +`,a+=hn.formatMarkdownish(h,{format:this.format(t),paragraphs:!1}),a+=`${p.replace(/^/m,` ${this.format(t).bold(n)}`).replace(/\$0/g,this.binaryName)} +`}}else{let{usage:l}=this.getUsageByRegistration(o);a+=`${this.format(t).bold(n)}${l} +`}else{let l=new Map;for(let[f,{index:h}]of this.registrations.entries()){if(typeof f.usage>"u")continue;let p=typeof f.usage.category<"u"?hn.formatMarkdownish(f.usage.category,{format:this.format(t),paragraphs:!1}):null,C=l.get(p);typeof C>"u"&&l.set(p,C=[]);let{usage:w}=this.getUsageByIndex(h);C.push({commandClass:f,usage:w})}let c=Array.from(l.keys()).sort((f,h)=>f===null?-1:h===null?1:f.localeCompare(h,"en",{usage:"sort",caseFirst:"upper"})),u=typeof this.binaryLabel<"u",g=typeof this.binaryVersion<"u";u||g?(u&&g?a+=`${this.format(t).header(`${this.binaryLabel} - ${this.binaryVersion}`)} + +`:u?a+=`${this.format(t).header(`${this.binaryLabel}`)} +`:a+=`${this.format(t).header(`${this.binaryVersion}`)} +`,a+=` ${this.format(t).bold(n)}${this.binaryName} +`):a+=`${this.format(t).bold(n)}${this.binaryName} +`;for(let f of c){let h=l.get(f).slice().sort((C,w)=>C.usage.localeCompare(w.usage,"en",{usage:"sort",caseFirst:"upper"})),p=f!==null?f.trim():"General commands";a+=` +`,a+=`${this.format(t).header(`${p}`)} +`;for(let{commandClass:C,usage:w}of h){let B=C.usage.description||"undocumented";a+=` +`,a+=` ${this.format(t).bold(w)} +`,a+=` ${hn.formatMarkdownish(B,{format:this.format(t),paragraphs:!1})}`}}a+=` +`,a+=hn.formatMarkdownish("You can also print more details about any of these commands by calling them with the `-h,--help` flag right after the command name.",{format:this.format(t),paragraphs:!0})}return a}error(e,t){var i,{colored:n,command:s=(i=e[IG])!==null&&i!==void 0?i:null}=t===void 0?{}:t;e instanceof Error||(e=new Error(`Execution failed with a non-error rejection (rejected value: ${JSON.stringify(e)})`));let o="",a=e.name.replace(/([a-z])([A-Z])/g,"$1 $2");a==="Error"&&(a="Internal Error"),o+=`${this.format(n).error(a)}: ${e.message} +`;let l=e.clipanion;return typeof l<"u"?l.type==="usage"&&(o+=` +`,o+=this.usage(s)):e.stack&&(o+=`${e.stack.replace(/^.*\n/,"")} +`),o}format(e){var t;return((t=e!=null?e:this.enableColors)!==null&&t!==void 0?t:TA.defaultContext.colorDepth>1)?hn.richFormat:hn.textFormat}getUsageByRegistration(e,t){let i=this.registrations.get(e);if(typeof i>"u")throw new Error("Assertion failed: Unregistered command");return this.getUsageByIndex(i.index,t)}getUsageByIndex(e,t){return this.builder.getBuilderByIndex(e).usage(t)}};TA.defaultContext={stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,colorDepth:"getColorDepth"in EG.default.WriteStream.prototype?EG.default.WriteStream.prototype.getColorDepth():Ame()};var yG;function lme(r){let e=yG;if(typeof e>"u"){if(r.stdout===process.stdout&&r.stderr===process.stderr)return wG;let{AsyncLocalStorage:t}=J("async_hooks");e=yG=new t;let i=process.stdout._write;process.stdout._write=function(s,o,a){let l=e.getStore();return typeof l>"u"?i.call(this,s,o,a):l.stdout.write(s,o,a)};let n=process.stderr._write;process.stderr._write=function(s,o,a){let l=e.getStore();return typeof l>"u"?n.call(this,s,o,a):l.stderr.write(s,o,a)}}return t=>e.run(r,t)}function wG(r){return r()}Wv.Cli=TA});var QG=y(zv=>{"use strict";Object.defineProperty(zv,"__esModule",{value:!0});var cme=Bc(),Ay=class extends cme.Command{async execute(){this.context.stdout.write(`${JSON.stringify(this.cli.definitions(),null,2)} +`)}};Ay.paths=[["--clipanion=definitions"]];zv.DefinitionsCommand=Ay});var bG=y(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});var ume=Bc(),ly=class extends ume.Command{async execute(){this.context.stdout.write(this.cli.usage())}};ly.paths=[["-h"],["--help"]];Vv.HelpCommand=ly});var SG=y(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var gme=Bc(),cy=class extends gme.Command{async execute(){var e;this.context.stdout.write(`${(e=this.cli.binaryVersion)!==null&&e!==void 0?e:""} +`)}};cy.paths=[["-v"],["--version"]];Xv.VersionCommand=cy});var vG=y(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var fme=QG(),hme=bG(),pme=SG();Dd.DefinitionsCommand=fme.DefinitionsCommand;Dd.HelpCommand=hme.HelpCommand;Dd.VersionCommand=pme.VersionCommand});var PG=y(_v=>{"use strict";Object.defineProperty(_v,"__esModule",{value:!0});var xG=Sa();function dme(r,e,t){let[i,n]=xG.rerouteArguments(e,t!=null?t:{}),{arity:s=1}=n,o=r.split(","),a=new Set(o);return xG.makeCommandOption({definition(l){l.addOption({names:o,arity:s,hidden:n==null?void 0:n.hidden,description:n==null?void 0:n.description,required:n.required})},transformer(l,c,u){let g=typeof i<"u"?[...i]:void 0;for(let{name:f,value:h}of u.options)!a.has(f)||(g=g!=null?g:[],g.push(h));return g}})}_v.Array=dme});var kG=y(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});var DG=Sa();function Cme(r,e,t){let[i,n]=DG.rerouteArguments(e,t!=null?t:{}),s=r.split(","),o=new Set(s);return DG.makeCommandOption({definition(a){a.addOption({names:s,allowBinding:!1,arity:0,hidden:n.hidden,description:n.description,required:n.required})},transformer(a,l,c){let u=i;for(let{name:g,value:f}of c.options)!o.has(g)||(u=f);return u}})}Zv.Boolean=Cme});var FG=y($v=>{"use strict";Object.defineProperty($v,"__esModule",{value:!0});var RG=Sa();function mme(r,e,t){let[i,n]=RG.rerouteArguments(e,t!=null?t:{}),s=r.split(","),o=new Set(s);return RG.makeCommandOption({definition(a){a.addOption({names:s,allowBinding:!1,arity:0,hidden:n.hidden,description:n.description,required:n.required})},transformer(a,l,c){let u=i;for(let{name:g,value:f}of c.options)!o.has(g)||(u!=null||(u=0),f?u+=1:u=0);return u}})}$v.Counter=mme});var NG=y(ex=>{"use strict";Object.defineProperty(ex,"__esModule",{value:!0});var Eme=Sa();function Ime(r={}){return Eme.makeCommandOption({definition(e,t){var i;e.addProxy({name:(i=r.name)!==null&&i!==void 0?i:t,required:r.required})},transformer(e,t,i){return i.positionals.map(({value:n})=>n)}})}ex.Proxy=Ime});var LG=y(tx=>{"use strict";Object.defineProperty(tx,"__esModule",{value:!0});var yme=Sa(),wme=ay();function Bme(r={}){return yme.makeCommandOption({definition(e,t){var i;e.addRest({name:(i=r.name)!==null&&i!==void 0?i:t,required:r.required})},transformer(e,t,i){let n=o=>{let a=i.positionals[o];return a.extra===wme.NoLimits||a.extra===!1&&oo)}})}tx.Rest=Bme});var TG=y(rx=>{"use strict";Object.defineProperty(rx,"__esModule",{value:!0});var kd=Sa(),Qme=ay();function bme(r,e,t){let[i,n]=kd.rerouteArguments(e,t!=null?t:{}),{arity:s=1}=n,o=r.split(","),a=new Set(o);return kd.makeCommandOption({definition(l){l.addOption({names:o,arity:n.tolerateBoolean?0:s,hidden:n.hidden,description:n.description,required:n.required})},transformer(l,c,u){let g,f=i;for(let{name:h,value:p}of u.options)!a.has(h)||(g=h,f=p);return typeof f=="string"?kd.applyValidator(g!=null?g:c,f,n.validator):f}})}function Sme(r={}){let{required:e=!0}=r;return kd.makeCommandOption({definition(t,i){var n;t.addPositional({name:(n=r.name)!==null&&n!==void 0?n:i,required:r.required})},transformer(t,i,n){var s;for(let o=0;o{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});var Af=Sa(),xme=PG(),Pme=kG(),Dme=FG(),kme=NG(),Rme=LG(),Fme=TG();pn.applyValidator=Af.applyValidator;pn.cleanValidationError=Af.cleanValidationError;pn.formatError=Af.formatError;pn.isOptionSymbol=Af.isOptionSymbol;pn.makeCommandOption=Af.makeCommandOption;pn.rerouteArguments=Af.rerouteArguments;pn.Array=xme.Array;pn.Boolean=Pme.Boolean;pn.Counter=Dme.Counter;pn.Proxy=kme.Proxy;pn.Rest=Rme.Rest;pn.String=Fme.String});var Xe=y(OA=>{"use strict";Object.defineProperty(OA,"__esModule",{value:!0});var Nme=ty(),Lme=Bc(),Tme=Gv(),Ome=BG(),Mme=vG(),Kme=OG();OA.UsageError=Nme.UsageError;OA.Command=Lme.Command;OA.formatMarkdownish=Tme.formatMarkdownish;OA.Cli=Ome.Cli;OA.Builtins=Mme;OA.Option=Kme});var KG=y((M$e,MG)=>{"use strict";MG.exports=(r,...e)=>new Promise(t=>{t(r(...e))})});var lf=y((K$e,ix)=>{"use strict";var Ume=KG(),UG=r=>{if(r<1)throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=[],t=0,i=()=>{t--,e.length>0&&e.shift()()},n=(a,l,...c)=>{t++;let u=Ume(a,...c);l(u),u.then(i,i)},s=(a,l,...c)=>{tnew Promise(c=>s(a,c,...l));return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.length}}),o};ix.exports=UG;ix.exports.default=UG});var Rd=y((H$e,HG)=>{var Hme="2.0.0",Gme=Number.MAX_SAFE_INTEGER||9007199254740991,Yme=16;HG.exports={SEMVER_SPEC_VERSION:Hme,MAX_LENGTH:256,MAX_SAFE_INTEGER:Gme,MAX_SAFE_COMPONENT_LENGTH:Yme}});var Fd=y((G$e,GG)=>{var jme=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{};GG.exports=jme});var bc=y((KA,YG)=>{var{MAX_SAFE_COMPONENT_LENGTH:nx}=Rd(),qme=Fd();KA=YG.exports={};var Jme=KA.re=[],_e=KA.src=[],Ze=KA.t={},Wme=0,St=(r,e,t)=>{let i=Wme++;qme(i,e),Ze[r]=i,_e[i]=e,Jme[i]=new RegExp(e,t?"g":void 0)};St("NUMERICIDENTIFIER","0|[1-9]\\d*");St("NUMERICIDENTIFIERLOOSE","[0-9]+");St("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*");St("MAINVERSION",`(${_e[Ze.NUMERICIDENTIFIER]})\\.(${_e[Ze.NUMERICIDENTIFIER]})\\.(${_e[Ze.NUMERICIDENTIFIER]})`);St("MAINVERSIONLOOSE",`(${_e[Ze.NUMERICIDENTIFIERLOOSE]})\\.(${_e[Ze.NUMERICIDENTIFIERLOOSE]})\\.(${_e[Ze.NUMERICIDENTIFIERLOOSE]})`);St("PRERELEASEIDENTIFIER",`(?:${_e[Ze.NUMERICIDENTIFIER]}|${_e[Ze.NONNUMERICIDENTIFIER]})`);St("PRERELEASEIDENTIFIERLOOSE",`(?:${_e[Ze.NUMERICIDENTIFIERLOOSE]}|${_e[Ze.NONNUMERICIDENTIFIER]})`);St("PRERELEASE",`(?:-(${_e[Ze.PRERELEASEIDENTIFIER]}(?:\\.${_e[Ze.PRERELEASEIDENTIFIER]})*))`);St("PRERELEASELOOSE",`(?:-?(${_e[Ze.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${_e[Ze.PRERELEASEIDENTIFIERLOOSE]})*))`);St("BUILDIDENTIFIER","[0-9A-Za-z-]+");St("BUILD",`(?:\\+(${_e[Ze.BUILDIDENTIFIER]}(?:\\.${_e[Ze.BUILDIDENTIFIER]})*))`);St("FULLPLAIN",`v?${_e[Ze.MAINVERSION]}${_e[Ze.PRERELEASE]}?${_e[Ze.BUILD]}?`);St("FULL",`^${_e[Ze.FULLPLAIN]}$`);St("LOOSEPLAIN",`[v=\\s]*${_e[Ze.MAINVERSIONLOOSE]}${_e[Ze.PRERELEASELOOSE]}?${_e[Ze.BUILD]}?`);St("LOOSE",`^${_e[Ze.LOOSEPLAIN]}$`);St("GTLT","((?:<|>)?=?)");St("XRANGEIDENTIFIERLOOSE",`${_e[Ze.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);St("XRANGEIDENTIFIER",`${_e[Ze.NUMERICIDENTIFIER]}|x|X|\\*`);St("XRANGEPLAIN",`[v=\\s]*(${_e[Ze.XRANGEIDENTIFIER]})(?:\\.(${_e[Ze.XRANGEIDENTIFIER]})(?:\\.(${_e[Ze.XRANGEIDENTIFIER]})(?:${_e[Ze.PRERELEASE]})?${_e[Ze.BUILD]}?)?)?`);St("XRANGEPLAINLOOSE",`[v=\\s]*(${_e[Ze.XRANGEIDENTIFIERLOOSE]})(?:\\.(${_e[Ze.XRANGEIDENTIFIERLOOSE]})(?:\\.(${_e[Ze.XRANGEIDENTIFIERLOOSE]})(?:${_e[Ze.PRERELEASELOOSE]})?${_e[Ze.BUILD]}?)?)?`);St("XRANGE",`^${_e[Ze.GTLT]}\\s*${_e[Ze.XRANGEPLAIN]}$`);St("XRANGELOOSE",`^${_e[Ze.GTLT]}\\s*${_e[Ze.XRANGEPLAINLOOSE]}$`);St("COERCE",`(^|[^\\d])(\\d{1,${nx}})(?:\\.(\\d{1,${nx}}))?(?:\\.(\\d{1,${nx}}))?(?:$|[^\\d])`);St("COERCERTL",_e[Ze.COERCE],!0);St("LONETILDE","(?:~>?)");St("TILDETRIM",`(\\s*)${_e[Ze.LONETILDE]}\\s+`,!0);KA.tildeTrimReplace="$1~";St("TILDE",`^${_e[Ze.LONETILDE]}${_e[Ze.XRANGEPLAIN]}$`);St("TILDELOOSE",`^${_e[Ze.LONETILDE]}${_e[Ze.XRANGEPLAINLOOSE]}$`);St("LONECARET","(?:\\^)");St("CARETTRIM",`(\\s*)${_e[Ze.LONECARET]}\\s+`,!0);KA.caretTrimReplace="$1^";St("CARET",`^${_e[Ze.LONECARET]}${_e[Ze.XRANGEPLAIN]}$`);St("CARETLOOSE",`^${_e[Ze.LONECARET]}${_e[Ze.XRANGEPLAINLOOSE]}$`);St("COMPARATORLOOSE",`^${_e[Ze.GTLT]}\\s*(${_e[Ze.LOOSEPLAIN]})$|^$`);St("COMPARATOR",`^${_e[Ze.GTLT]}\\s*(${_e[Ze.FULLPLAIN]})$|^$`);St("COMPARATORTRIM",`(\\s*)${_e[Ze.GTLT]}\\s*(${_e[Ze.LOOSEPLAIN]}|${_e[Ze.XRANGEPLAIN]})`,!0);KA.comparatorTrimReplace="$1$2$3";St("HYPHENRANGE",`^\\s*(${_e[Ze.XRANGEPLAIN]})\\s+-\\s+(${_e[Ze.XRANGEPLAIN]})\\s*$`);St("HYPHENRANGELOOSE",`^\\s*(${_e[Ze.XRANGEPLAINLOOSE]})\\s+-\\s+(${_e[Ze.XRANGEPLAINLOOSE]})\\s*$`);St("STAR","(<|>)?=?\\s*\\*");St("GTE0","^\\s*>=\\s*0.0.0\\s*$");St("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")});var Nd=y((Y$e,jG)=>{var zme=["includePrerelease","loose","rtl"],Vme=r=>r?typeof r!="object"?{loose:!0}:zme.filter(e=>r[e]).reduce((e,t)=>(e[t]=!0,e),{}):{};jG.exports=Vme});var gy=y((j$e,WG)=>{var qG=/^[0-9]+$/,JG=(r,e)=>{let t=qG.test(r),i=qG.test(e);return t&&i&&(r=+r,e=+e),r===e?0:t&&!i?-1:i&&!t?1:rJG(e,r);WG.exports={compareIdentifiers:JG,rcompareIdentifiers:Xme}});var Oi=y((q$e,_G)=>{var fy=Fd(),{MAX_LENGTH:zG,MAX_SAFE_INTEGER:hy}=Rd(),{re:VG,t:XG}=bc(),_me=Nd(),{compareIdentifiers:Ld}=gy(),Un=class{constructor(e,t){if(t=_me(t),e instanceof Un){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>zG)throw new TypeError(`version is longer than ${zG} characters`);fy("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let i=e.trim().match(t.loose?VG[XG.LOOSE]:VG[XG.FULL]);if(!i)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>hy||this.major<0)throw new TypeError("Invalid major version");if(this.minor>hy||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>hy||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let s=+n;if(s>=0&&s=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);i===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}};_G.exports=Un});var Sc=y((J$e,tY)=>{var{MAX_LENGTH:Zme}=Rd(),{re:ZG,t:$G}=bc(),eY=Oi(),$me=Nd(),eEe=(r,e)=>{if(e=$me(e),r instanceof eY)return r;if(typeof r!="string"||r.length>Zme||!(e.loose?ZG[$G.LOOSE]:ZG[$G.FULL]).test(r))return null;try{return new eY(r,e)}catch{return null}};tY.exports=eEe});var iY=y((W$e,rY)=>{var tEe=Sc(),rEe=(r,e)=>{let t=tEe(r,e);return t?t.version:null};rY.exports=rEe});var sY=y((z$e,nY)=>{var iEe=Sc(),nEe=(r,e)=>{let t=iEe(r.trim().replace(/^[=v]+/,""),e);return t?t.version:null};nY.exports=nEe});var aY=y((V$e,oY)=>{var sEe=Oi(),oEe=(r,e,t,i)=>{typeof t=="string"&&(i=t,t=void 0);try{return new sEe(r,t).inc(e,i).version}catch{return null}};oY.exports=oEe});var os=y((X$e,lY)=>{var AY=Oi(),aEe=(r,e,t)=>new AY(r,t).compare(new AY(e,t));lY.exports=aEe});var py=y((_$e,cY)=>{var AEe=os(),lEe=(r,e,t)=>AEe(r,e,t)===0;cY.exports=lEe});var fY=y((Z$e,gY)=>{var uY=Sc(),cEe=py(),uEe=(r,e)=>{if(cEe(r,e))return null;{let t=uY(r),i=uY(e),n=t.prerelease.length||i.prerelease.length,s=n?"pre":"",o=n?"prerelease":"";for(let a in t)if((a==="major"||a==="minor"||a==="patch")&&t[a]!==i[a])return s+a;return o}};gY.exports=uEe});var pY=y(($$e,hY)=>{var gEe=Oi(),fEe=(r,e)=>new gEe(r,e).major;hY.exports=fEe});var CY=y((eet,dY)=>{var hEe=Oi(),pEe=(r,e)=>new hEe(r,e).minor;dY.exports=pEe});var EY=y((tet,mY)=>{var dEe=Oi(),CEe=(r,e)=>new dEe(r,e).patch;mY.exports=CEe});var yY=y((ret,IY)=>{var mEe=Sc(),EEe=(r,e)=>{let t=mEe(r,e);return t&&t.prerelease.length?t.prerelease:null};IY.exports=EEe});var BY=y((iet,wY)=>{var IEe=os(),yEe=(r,e,t)=>IEe(e,r,t);wY.exports=yEe});var bY=y((net,QY)=>{var wEe=os(),BEe=(r,e)=>wEe(r,e,!0);QY.exports=BEe});var dy=y((set,vY)=>{var SY=Oi(),QEe=(r,e,t)=>{let i=new SY(r,t),n=new SY(e,t);return i.compare(n)||i.compareBuild(n)};vY.exports=QEe});var PY=y((oet,xY)=>{var bEe=dy(),SEe=(r,e)=>r.sort((t,i)=>bEe(t,i,e));xY.exports=SEe});var kY=y((aet,DY)=>{var vEe=dy(),xEe=(r,e)=>r.sort((t,i)=>vEe(i,t,e));DY.exports=xEe});var Td=y((Aet,RY)=>{var PEe=os(),DEe=(r,e,t)=>PEe(r,e,t)>0;RY.exports=DEe});var Cy=y((cet,FY)=>{var kEe=os(),REe=(r,e,t)=>kEe(r,e,t)<0;FY.exports=REe});var sx=y((uet,NY)=>{var FEe=os(),NEe=(r,e,t)=>FEe(r,e,t)!==0;NY.exports=NEe});var my=y((get,LY)=>{var LEe=os(),TEe=(r,e,t)=>LEe(r,e,t)>=0;LY.exports=TEe});var Ey=y((fet,TY)=>{var OEe=os(),MEe=(r,e,t)=>OEe(r,e,t)<=0;TY.exports=MEe});var ox=y((het,OY)=>{var KEe=py(),UEe=sx(),HEe=Td(),GEe=my(),YEe=Cy(),jEe=Ey(),qEe=(r,e,t,i)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return KEe(r,t,i);case"!=":return UEe(r,t,i);case">":return HEe(r,t,i);case">=":return GEe(r,t,i);case"<":return YEe(r,t,i);case"<=":return jEe(r,t,i);default:throw new TypeError(`Invalid operator: ${e}`)}};OY.exports=qEe});var KY=y((pet,MY)=>{var JEe=Oi(),WEe=Sc(),{re:Iy,t:yy}=bc(),zEe=(r,e)=>{if(r instanceof JEe)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;e=e||{};let t=null;if(!e.rtl)t=r.match(Iy[yy.COERCE]);else{let i;for(;(i=Iy[yy.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)(!t||i.index+i[0].length!==t.index+t[0].length)&&(t=i),Iy[yy.COERCERTL].lastIndex=i.index+i[1].length+i[2].length;Iy[yy.COERCERTL].lastIndex=-1}return t===null?null:WEe(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};MY.exports=zEe});var HY=y((det,UY)=>{"use strict";UY.exports=function(r){r.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var Od=y((Cet,GY)=>{"use strict";GY.exports=Ht;Ht.Node=vc;Ht.create=Ht;function Ht(r){var e=this;if(e instanceof Ht||(e=new Ht),e.tail=null,e.head=null,e.length=0,r&&typeof r.forEach=="function")r.forEach(function(n){e.push(n)});else if(arguments.length>0)for(var t=0,i=arguments.length;t1)t=e;else if(this.head)i=this.head.next,t=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=0;i!==null;n++)t=r(t,i.value,n),i=i.next;return t};Ht.prototype.reduceReverse=function(r,e){var t,i=this.tail;if(arguments.length>1)t=e;else if(this.tail)i=this.tail.prev,t=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=this.length-1;i!==null;n--)t=r(t,i.value,n),i=i.prev;return t};Ht.prototype.toArray=function(){for(var r=new Array(this.length),e=0,t=this.head;t!==null;e++)r[e]=t.value,t=t.next;return r};Ht.prototype.toArrayReverse=function(){for(var r=new Array(this.length),e=0,t=this.tail;t!==null;e++)r[e]=t.value,t=t.prev;return r};Ht.prototype.slice=function(r,e){e=e||this.length,e<0&&(e+=this.length),r=r||0,r<0&&(r+=this.length);var t=new Ht;if(ethis.length&&(e=this.length);for(var i=0,n=this.head;n!==null&&ithis.length&&(e=this.length);for(var i=this.length,n=this.tail;n!==null&&i>e;i--)n=n.prev;for(;n!==null&&i>r;i--,n=n.prev)t.push(n.value);return t};Ht.prototype.splice=function(r,e,...t){r>this.length&&(r=this.length-1),r<0&&(r=this.length+r);for(var i=0,n=this.head;n!==null&&i{"use strict";var ZEe=Od(),xc=Symbol("max"),xa=Symbol("length"),cf=Symbol("lengthCalculator"),Kd=Symbol("allowStale"),Pc=Symbol("maxAge"),va=Symbol("dispose"),YY=Symbol("noDisposeOnSet"),Ii=Symbol("lruList"),zs=Symbol("cache"),qY=Symbol("updateAgeOnGet"),ax=()=>1,lx=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let t=this[xc]=e.max||1/0,i=e.length||ax;if(this[cf]=typeof i!="function"?ax:i,this[Kd]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[Pc]=e.maxAge||0,this[va]=e.dispose,this[YY]=e.noDisposeOnSet||!1,this[qY]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[xc]=e||1/0,Md(this)}get max(){return this[xc]}set allowStale(e){this[Kd]=!!e}get allowStale(){return this[Kd]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[Pc]=e,Md(this)}get maxAge(){return this[Pc]}set lengthCalculator(e){typeof e!="function"&&(e=ax),e!==this[cf]&&(this[cf]=e,this[xa]=0,this[Ii].forEach(t=>{t.length=this[cf](t.value,t.key),this[xa]+=t.length})),Md(this)}get lengthCalculator(){return this[cf]}get length(){return this[xa]}get itemCount(){return this[Ii].length}rforEach(e,t){t=t||this;for(let i=this[Ii].tail;i!==null;){let n=i.prev;jY(this,e,i,t),i=n}}forEach(e,t){t=t||this;for(let i=this[Ii].head;i!==null;){let n=i.next;jY(this,e,i,t),i=n}}keys(){return this[Ii].toArray().map(e=>e.key)}values(){return this[Ii].toArray().map(e=>e.value)}reset(){this[va]&&this[Ii]&&this[Ii].length&&this[Ii].forEach(e=>this[va](e.key,e.value)),this[zs]=new Map,this[Ii]=new ZEe,this[xa]=0}dump(){return this[Ii].map(e=>wy(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[Ii]}set(e,t,i){if(i=i||this[Pc],i&&typeof i!="number")throw new TypeError("maxAge must be a number");let n=i?Date.now():0,s=this[cf](t,e);if(this[zs].has(e)){if(s>this[xc])return uf(this,this[zs].get(e)),!1;let l=this[zs].get(e).value;return this[va]&&(this[YY]||this[va](e,l.value)),l.now=n,l.maxAge=i,l.value=t,this[xa]+=s-l.length,l.length=s,this.get(e),Md(this),!0}let o=new cx(e,t,s,n,i);return o.length>this[xc]?(this[va]&&this[va](e,t),!1):(this[xa]+=o.length,this[Ii].unshift(o),this[zs].set(e,this[Ii].head),Md(this),!0)}has(e){if(!this[zs].has(e))return!1;let t=this[zs].get(e).value;return!wy(this,t)}get(e){return Ax(this,e,!0)}peek(e){return Ax(this,e,!1)}pop(){let e=this[Ii].tail;return e?(uf(this,e),e.value):null}del(e){uf(this,this[zs].get(e))}load(e){this.reset();let t=Date.now();for(let i=e.length-1;i>=0;i--){let n=e[i],s=n.e||0;if(s===0)this.set(n.k,n.v);else{let o=s-t;o>0&&this.set(n.k,n.v,o)}}}prune(){this[zs].forEach((e,t)=>Ax(this,t,!1))}},Ax=(r,e,t)=>{let i=r[zs].get(e);if(i){let n=i.value;if(wy(r,n)){if(uf(r,i),!r[Kd])return}else t&&(r[qY]&&(i.value.now=Date.now()),r[Ii].unshiftNode(i));return n.value}},wy=(r,e)=>{if(!e||!e.maxAge&&!r[Pc])return!1;let t=Date.now()-e.now;return e.maxAge?t>e.maxAge:r[Pc]&&t>r[Pc]},Md=r=>{if(r[xa]>r[xc])for(let e=r[Ii].tail;r[xa]>r[xc]&&e!==null;){let t=e.prev;uf(r,e),e=t}},uf=(r,e)=>{if(e){let t=e.value;r[va]&&r[va](t.key,t.value),r[xa]-=t.length,r[zs].delete(t.key),r[Ii].removeNode(e)}},cx=class{constructor(e,t,i,n,s){this.key=e,this.value=t,this.length=i,this.now=n,this.maxAge=s||0}},jY=(r,e,t,i)=>{let n=t.value;wy(r,n)&&(uf(r,t),r[Kd]||(n=void 0)),n&&e.call(i,n.value,n.key,r)};JY.exports=lx});var as=y((Eet,_Y)=>{var Dc=class{constructor(e,t){if(t=eIe(t),e instanceof Dc)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new Dc(e.raw,t);if(e instanceof ux)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);if(this.set.length>1){let i=this.set[0];if(this.set=this.set.filter(n=>!VY(n[0])),this.set.length===0)this.set=[i];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&sIe(n[0])){this.set=[n];break}}}this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){e=e.trim();let i=`parseRange:${Object.keys(this.options).join(",")}:${e}`,n=zY.get(i);if(n)return n;let s=this.options.loose,o=s?Mi[bi.HYPHENRANGELOOSE]:Mi[bi.HYPHENRANGE];e=e.replace(o,pIe(this.options.includePrerelease)),jr("hyphen replace",e),e=e.replace(Mi[bi.COMPARATORTRIM],rIe),jr("comparator trim",e,Mi[bi.COMPARATORTRIM]),e=e.replace(Mi[bi.TILDETRIM],iIe),e=e.replace(Mi[bi.CARETTRIM],nIe),e=e.split(/\s+/).join(" ");let a=s?Mi[bi.COMPARATORLOOSE]:Mi[bi.COMPARATOR],l=e.split(" ").map(f=>oIe(f,this.options)).join(" ").split(/\s+/).map(f=>hIe(f,this.options)).filter(this.options.loose?f=>!!f.match(a):()=>!0).map(f=>new ux(f,this.options)),c=l.length,u=new Map;for(let f of l){if(VY(f))return[f];u.set(f.value,f)}u.size>1&&u.has("")&&u.delete("");let g=[...u.values()];return zY.set(i,g),g}intersects(e,t){if(!(e instanceof Dc))throw new TypeError("a Range is required");return this.set.some(i=>XY(i,t)&&e.set.some(n=>XY(n,t)&&i.every(s=>n.every(o=>s.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new tIe(e,this.options)}catch{return!1}for(let t=0;tr.value==="<0.0.0-0",sIe=r=>r.value==="",XY=(r,e)=>{let t=!0,i=r.slice(),n=i.pop();for(;t&&i.length;)t=i.every(s=>n.intersects(s,e)),n=i.pop();return t},oIe=(r,e)=>(jr("comp",r,e),r=lIe(r,e),jr("caret",r),r=aIe(r,e),jr("tildes",r),r=uIe(r,e),jr("xrange",r),r=fIe(r,e),jr("stars",r),r),Xi=r=>!r||r.toLowerCase()==="x"||r==="*",aIe=(r,e)=>r.trim().split(/\s+/).map(t=>AIe(t,e)).join(" "),AIe=(r,e)=>{let t=e.loose?Mi[bi.TILDELOOSE]:Mi[bi.TILDE];return r.replace(t,(i,n,s,o,a)=>{jr("tilde",r,i,n,s,o,a);let l;return Xi(n)?l="":Xi(s)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:Xi(o)?l=`>=${n}.${s}.0 <${n}.${+s+1}.0-0`:a?(jr("replaceTilde pr",a),l=`>=${n}.${s}.${o}-${a} <${n}.${+s+1}.0-0`):l=`>=${n}.${s}.${o} <${n}.${+s+1}.0-0`,jr("tilde return",l),l})},lIe=(r,e)=>r.trim().split(/\s+/).map(t=>cIe(t,e)).join(" "),cIe=(r,e)=>{jr("caret",r,e);let t=e.loose?Mi[bi.CARETLOOSE]:Mi[bi.CARET],i=e.includePrerelease?"-0":"";return r.replace(t,(n,s,o,a,l)=>{jr("caret",r,n,s,o,a,l);let c;return Xi(s)?c="":Xi(o)?c=`>=${s}.0.0${i} <${+s+1}.0.0-0`:Xi(a)?s==="0"?c=`>=${s}.${o}.0${i} <${s}.${+o+1}.0-0`:c=`>=${s}.${o}.0${i} <${+s+1}.0.0-0`:l?(jr("replaceCaret pr",l),s==="0"?o==="0"?c=`>=${s}.${o}.${a}-${l} <${s}.${o}.${+a+1}-0`:c=`>=${s}.${o}.${a}-${l} <${s}.${+o+1}.0-0`:c=`>=${s}.${o}.${a}-${l} <${+s+1}.0.0-0`):(jr("no pr"),s==="0"?o==="0"?c=`>=${s}.${o}.${a}${i} <${s}.${o}.${+a+1}-0`:c=`>=${s}.${o}.${a}${i} <${s}.${+o+1}.0-0`:c=`>=${s}.${o}.${a} <${+s+1}.0.0-0`),jr("caret return",c),c})},uIe=(r,e)=>(jr("replaceXRanges",r,e),r.split(/\s+/).map(t=>gIe(t,e)).join(" ")),gIe=(r,e)=>{r=r.trim();let t=e.loose?Mi[bi.XRANGELOOSE]:Mi[bi.XRANGE];return r.replace(t,(i,n,s,o,a,l)=>{jr("xRange",r,i,n,s,o,a,l);let c=Xi(s),u=c||Xi(o),g=u||Xi(a),f=g;return n==="="&&f&&(n=""),l=e.includePrerelease?"-0":"",c?n===">"||n==="<"?i="<0.0.0-0":i="*":n&&f?(u&&(o=0),a=0,n===">"?(n=">=",u?(s=+s+1,o=0,a=0):(o=+o+1,a=0)):n==="<="&&(n="<",u?s=+s+1:o=+o+1),n==="<"&&(l="-0"),i=`${n+s}.${o}.${a}${l}`):u?i=`>=${s}.0.0${l} <${+s+1}.0.0-0`:g&&(i=`>=${s}.${o}.0${l} <${s}.${+o+1}.0-0`),jr("xRange return",i),i})},fIe=(r,e)=>(jr("replaceStars",r,e),r.trim().replace(Mi[bi.STAR],"")),hIe=(r,e)=>(jr("replaceGTE0",r,e),r.trim().replace(Mi[e.includePrerelease?bi.GTE0PRE:bi.GTE0],"")),pIe=r=>(e,t,i,n,s,o,a,l,c,u,g,f,h)=>(Xi(i)?t="":Xi(n)?t=`>=${i}.0.0${r?"-0":""}`:Xi(s)?t=`>=${i}.${n}.0${r?"-0":""}`:o?t=`>=${t}`:t=`>=${t}${r?"-0":""}`,Xi(c)?l="":Xi(u)?l=`<${+c+1}.0.0-0`:Xi(g)?l=`<${c}.${+u+1}.0-0`:f?l=`<=${c}.${u}.${g}-${f}`:r?l=`<${c}.${u}.${+g+1}-0`:l=`<=${l}`,`${t} ${l}`.trim()),dIe=(r,e,t)=>{for(let i=0;i0){let n=r[i].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var Ud=y((Iet,rj)=>{var Hd=Symbol("SemVer ANY"),gf=class{static get ANY(){return Hd}constructor(e,t){if(t=CIe(t),e instanceof gf){if(e.loose===!!t.loose)return e;e=e.value}fx("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Hd?this.value="":this.value=this.operator+this.semver.version,fx("comp",this)}parse(e){let t=this.options.loose?ZY[$Y.COMPARATORLOOSE]:ZY[$Y.COMPARATOR],i=e.match(t);if(!i)throw new TypeError(`Invalid comparator: ${e}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new ej(i[2],this.options.loose):this.semver=Hd}toString(){return this.value}test(e){if(fx("Comparator.test",e,this.options.loose),this.semver===Hd||e===Hd)return!0;if(typeof e=="string")try{e=new ej(e,this.options)}catch{return!1}return gx(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof gf))throw new TypeError("a Comparator is required");if((!t||typeof t!="object")&&(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""?!0:new tj(e.value,t).test(this.value);if(e.operator==="")return e.value===""?!0:new tj(this.value,t).test(e.semver);let i=(this.operator===">="||this.operator===">")&&(e.operator===">="||e.operator===">"),n=(this.operator==="<="||this.operator==="<")&&(e.operator==="<="||e.operator==="<"),s=this.semver.version===e.semver.version,o=(this.operator===">="||this.operator==="<=")&&(e.operator===">="||e.operator==="<="),a=gx(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),l=gx(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return i||n||s&&o||a||l}};rj.exports=gf;var CIe=Nd(),{re:ZY,t:$Y}=bc(),gx=ox(),fx=Fd(),ej=Oi(),tj=as()});var Gd=y((yet,ij)=>{var mIe=as(),EIe=(r,e,t)=>{try{e=new mIe(e,t)}catch{return!1}return e.test(r)};ij.exports=EIe});var sj=y((wet,nj)=>{var IIe=as(),yIe=(r,e)=>new IIe(r,e).set.map(t=>t.map(i=>i.value).join(" ").trim().split(" "));nj.exports=yIe});var aj=y((Bet,oj)=>{var wIe=Oi(),BIe=as(),QIe=(r,e,t)=>{let i=null,n=null,s=null;try{s=new BIe(e,t)}catch{return null}return r.forEach(o=>{s.test(o)&&(!i||n.compare(o)===-1)&&(i=o,n=new wIe(i,t))}),i};oj.exports=QIe});var lj=y((Qet,Aj)=>{var bIe=Oi(),SIe=as(),vIe=(r,e,t)=>{let i=null,n=null,s=null;try{s=new SIe(e,t)}catch{return null}return r.forEach(o=>{s.test(o)&&(!i||n.compare(o)===1)&&(i=o,n=new bIe(i,t))}),i};Aj.exports=vIe});var gj=y((bet,uj)=>{var hx=Oi(),xIe=as(),cj=Td(),PIe=(r,e)=>{r=new xIe(r,e);let t=new hx("0.0.0");if(r.test(t)||(t=new hx("0.0.0-0"),r.test(t)))return t;t=null;for(let i=0;i{let a=new hx(o.semver.version);switch(o.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!s||cj(a,s))&&(s=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),s&&(!t||cj(t,s))&&(t=s)}return t&&r.test(t)?t:null};uj.exports=PIe});var hj=y((vet,fj)=>{var DIe=as(),kIe=(r,e)=>{try{return new DIe(r,e).range||"*"}catch{return null}};fj.exports=kIe});var By=y((xet,mj)=>{var RIe=Oi(),Cj=Ud(),{ANY:FIe}=Cj,NIe=as(),LIe=Gd(),pj=Td(),dj=Cy(),TIe=Ey(),OIe=my(),MIe=(r,e,t,i)=>{r=new RIe(r,i),e=new NIe(e,i);let n,s,o,a,l;switch(t){case">":n=pj,s=TIe,o=dj,a=">",l=">=";break;case"<":n=dj,s=OIe,o=pj,a="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(LIe(r,e,i))return!1;for(let c=0;c{h.semver===FIe&&(h=new Cj(">=0.0.0")),g=g||h,f=f||h,n(h.semver,g.semver,i)?g=h:o(h.semver,f.semver,i)&&(f=h)}),g.operator===a||g.operator===l||(!f.operator||f.operator===a)&&s(r,f.semver))return!1;if(f.operator===l&&o(r,f.semver))return!1}return!0};mj.exports=MIe});var Ij=y((Pet,Ej)=>{var KIe=By(),UIe=(r,e,t)=>KIe(r,e,">",t);Ej.exports=UIe});var wj=y((Det,yj)=>{var HIe=By(),GIe=(r,e,t)=>HIe(r,e,"<",t);yj.exports=GIe});var bj=y((ket,Qj)=>{var Bj=as(),YIe=(r,e,t)=>(r=new Bj(r,t),e=new Bj(e,t),r.intersects(e));Qj.exports=YIe});var vj=y((Ret,Sj)=>{var jIe=Gd(),qIe=os();Sj.exports=(r,e,t)=>{let i=[],n=null,s=null,o=r.sort((u,g)=>qIe(u,g,t));for(let u of o)jIe(u,e,t)?(s=u,n||(n=u)):(s&&i.push([n,s]),s=null,n=null);n&&i.push([n,null]);let a=[];for(let[u,g]of i)u===g?a.push(u):!g&&u===o[0]?a.push("*"):g?u===o[0]?a.push(`<=${g}`):a.push(`${u} - ${g}`):a.push(`>=${u}`);let l=a.join(" || "),c=typeof e.raw=="string"?e.raw:String(e);return l.length{var xj=as(),Qy=Ud(),{ANY:px}=Qy,Yd=Gd(),dx=os(),JIe=(r,e,t={})=>{if(r===e)return!0;r=new xj(r,t),e=new xj(e,t);let i=!1;e:for(let n of r.set){for(let s of e.set){let o=WIe(n,s,t);if(i=i||o!==null,o)continue e}if(i)return!1}return!0},WIe=(r,e,t)=>{if(r===e)return!0;if(r.length===1&&r[0].semver===px){if(e.length===1&&e[0].semver===px)return!0;t.includePrerelease?r=[new Qy(">=0.0.0-0")]:r=[new Qy(">=0.0.0")]}if(e.length===1&&e[0].semver===px){if(t.includePrerelease)return!0;e=[new Qy(">=0.0.0")]}let i=new Set,n,s;for(let h of r)h.operator===">"||h.operator===">="?n=Pj(n,h,t):h.operator==="<"||h.operator==="<="?s=Dj(s,h,t):i.add(h.semver);if(i.size>1)return null;let o;if(n&&s){if(o=dx(n.semver,s.semver,t),o>0)return null;if(o===0&&(n.operator!==">="||s.operator!=="<="))return null}for(let h of i){if(n&&!Yd(h,String(n),t)||s&&!Yd(h,String(s),t))return null;for(let p of e)if(!Yd(h,String(p),t))return!1;return!0}let a,l,c,u,g=s&&!t.includePrerelease&&s.semver.prerelease.length?s.semver:!1,f=n&&!t.includePrerelease&&n.semver.prerelease.length?n.semver:!1;g&&g.prerelease.length===1&&s.operator==="<"&&g.prerelease[0]===0&&(g=!1);for(let h of e){if(u=u||h.operator===">"||h.operator===">=",c=c||h.operator==="<"||h.operator==="<=",n){if(f&&h.semver.prerelease&&h.semver.prerelease.length&&h.semver.major===f.major&&h.semver.minor===f.minor&&h.semver.patch===f.patch&&(f=!1),h.operator===">"||h.operator===">="){if(a=Pj(n,h,t),a===h&&a!==n)return!1}else if(n.operator===">="&&!Yd(n.semver,String(h),t))return!1}if(s){if(g&&h.semver.prerelease&&h.semver.prerelease.length&&h.semver.major===g.major&&h.semver.minor===g.minor&&h.semver.patch===g.patch&&(g=!1),h.operator==="<"||h.operator==="<="){if(l=Dj(s,h,t),l===h&&l!==s)return!1}else if(s.operator==="<="&&!Yd(s.semver,String(h),t))return!1}if(!h.operator&&(s||n)&&o!==0)return!1}return!(n&&c&&!s&&o!==0||s&&u&&!n&&o!==0||f||g)},Pj=(r,e,t)=>{if(!r)return e;let i=dx(r.semver,e.semver,t);return i>0?r:i<0||e.operator===">"&&r.operator===">="?e:r},Dj=(r,e,t)=>{if(!r)return e;let i=dx(r.semver,e.semver,t);return i<0?r:i>0||e.operator==="<"&&r.operator==="<="?e:r};kj.exports=JIe});var $r=y((Net,Fj)=>{var Cx=bc();Fj.exports={re:Cx.re,src:Cx.src,tokens:Cx.t,SEMVER_SPEC_VERSION:Rd().SEMVER_SPEC_VERSION,SemVer:Oi(),compareIdentifiers:gy().compareIdentifiers,rcompareIdentifiers:gy().rcompareIdentifiers,parse:Sc(),valid:iY(),clean:sY(),inc:aY(),diff:fY(),major:pY(),minor:CY(),patch:EY(),prerelease:yY(),compare:os(),rcompare:BY(),compareLoose:bY(),compareBuild:dy(),sort:PY(),rsort:kY(),gt:Td(),lt:Cy(),eq:py(),neq:sx(),gte:my(),lte:Ey(),cmp:ox(),coerce:KY(),Comparator:Ud(),Range:as(),satisfies:Gd(),toComparators:sj(),maxSatisfying:aj(),minSatisfying:lj(),minVersion:gj(),validRange:hj(),outside:By(),gtr:Ij(),ltr:wj(),intersects:bj(),simplifyRange:vj(),subset:Rj()}});var mx=y(by=>{"use strict";Object.defineProperty(by,"__esModule",{value:!0});by.VERSION=void 0;by.VERSION="9.1.0"});var Gt=y((exports,module)=>{"use strict";var __spreadArray=exports&&exports.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,s;i{(function(r,e){typeof define=="function"&&define.amd?define([],e):typeof Sy=="object"&&Sy.exports?Sy.exports=e():r.regexpToAst=e()})(typeof self<"u"?self:Nj,function(){function r(){}r.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},r.prototype.restoreState=function(p){this.idx=p.idx,this.input=p.input,this.groupIdx=p.groupIdx},r.prototype.pattern=function(p){this.idx=0,this.input=p,this.groupIdx=0,this.consumeChar("/");var C=this.disjunction();this.consumeChar("/");for(var w={type:"Flags",loc:{begin:this.idx,end:p.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":o(w,"global");break;case"i":o(w,"ignoreCase");break;case"m":o(w,"multiLine");break;case"u":o(w,"unicode");break;case"y":o(w,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:w,value:C,loc:this.loc(0)}},r.prototype.disjunction=function(){var p=[],C=this.idx;for(p.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),p.push(this.alternative());return{type:"Disjunction",value:p,loc:this.loc(C)}},r.prototype.alternative=function(){for(var p=[],C=this.idx;this.isTerm();)p.push(this.term());return{type:"Alternative",value:p,loc:this.loc(C)}},r.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},r.prototype.assertion=function(){var p=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(p)};case"$":return{type:"EndAnchor",loc:this.loc(p)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(p)};case"B":return{type:"NonWordBoundary",loc:this.loc(p)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var C;switch(this.popChar()){case"=":C="Lookahead";break;case"!":C="NegativeLookahead";break}a(C);var w=this.disjunction();return this.consumeChar(")"),{type:C,value:w,loc:this.loc(p)}}l()},r.prototype.quantifier=function(p){var C,w=this.idx;switch(this.popChar()){case"*":C={atLeast:0,atMost:1/0};break;case"+":C={atLeast:1,atMost:1/0};break;case"?":C={atLeast:0,atMost:1};break;case"{":var B=this.integerIncludingZero();switch(this.popChar()){case"}":C={atLeast:B,atMost:B};break;case",":var v;this.isDigit()?(v=this.integerIncludingZero(),C={atLeast:B,atMost:v}):C={atLeast:B,atMost:1/0},this.consumeChar("}");break}if(p===!0&&C===void 0)return;a(C);break}if(!(p===!0&&C===void 0))return a(C),this.peekChar(0)==="?"?(this.consumeChar("?"),C.greedy=!1):C.greedy=!0,C.type="Quantifier",C.loc=this.loc(w),C},r.prototype.atom=function(){var p,C=this.idx;switch(this.peekChar()){case".":p=this.dotAll();break;case"\\":p=this.atomEscape();break;case"[":p=this.characterClass();break;case"(":p=this.group();break}return p===void 0&&this.isPatternCharacter()&&(p=this.patternCharacter()),a(p),p.loc=this.loc(C),this.isQuantifier()&&(p.quantifier=this.quantifier()),p},r.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[n(` +`),n("\r"),n("\u2028"),n("\u2029")]}},r.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},r.prototype.decimalEscapeAtom=function(){var p=this.positiveInteger();return{type:"GroupBackReference",value:p}},r.prototype.characterClassEscape=function(){var p,C=!1;switch(this.popChar()){case"d":p=u;break;case"D":p=u,C=!0;break;case"s":p=f;break;case"S":p=f,C=!0;break;case"w":p=g;break;case"W":p=g,C=!0;break}return a(p),{type:"Set",value:p,complement:C}},r.prototype.controlEscapeAtom=function(){var p;switch(this.popChar()){case"f":p=n("\f");break;case"n":p=n(` +`);break;case"r":p=n("\r");break;case"t":p=n(" ");break;case"v":p=n("\v");break}return a(p),{type:"Character",value:p}},r.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var p=this.popChar();if(/[a-zA-Z]/.test(p)===!1)throw Error("Invalid ");var C=p.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:C}},r.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:n("\0")}},r.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},r.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},r.prototype.identityEscapeAtom=function(){var p=this.popChar();return{type:"Character",value:n(p)}},r.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case` +`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var p=this.popChar();return{type:"Character",value:n(p)}}},r.prototype.characterClass=function(){var p=[],C=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),C=!0);this.isClassAtom();){var w=this.classAtom(),B=w.type==="Character";if(B&&this.isRangeDash()){this.consumeChar("-");var v=this.classAtom(),D=v.type==="Character";if(D){if(v.value=this.input.length)throw Error("Unexpected end of input");this.idx++},r.prototype.loc=function(p){return{begin:p,end:this.idx}};var e=/[0-9a-fA-F]/,t=/[0-9]/,i=/[1-9]/;function n(p){return p.charCodeAt(0)}function s(p,C){p.length!==void 0?p.forEach(function(w){C.push(w)}):C.push(p)}function o(p,C){if(p[C]===!0)throw"duplicate flag "+C;p[C]=!0}function a(p){if(p===void 0)throw Error("Internal Error - Should never get here!")}function l(){throw Error("Internal Error - Should never get here!")}var c,u=[];for(c=n("0");c<=n("9");c++)u.push(c);var g=[n("_")].concat(u);for(c=n("a");c<=n("z");c++)g.push(c);for(c=n("A");c<=n("Z");c++)g.push(c);var f=[n(" "),n("\f"),n(` +`),n("\r"),n(" "),n("\v"),n(" "),n("\xA0"),n("\u1680"),n("\u2000"),n("\u2001"),n("\u2002"),n("\u2003"),n("\u2004"),n("\u2005"),n("\u2006"),n("\u2007"),n("\u2008"),n("\u2009"),n("\u200A"),n("\u2028"),n("\u2029"),n("\u202F"),n("\u205F"),n("\u3000"),n("\uFEFF")];function h(){}return h.prototype.visitChildren=function(p){for(var C in p){var w=p[C];p.hasOwnProperty(C)&&(w.type!==void 0?this.visit(w):Array.isArray(w)&&w.forEach(function(B){this.visit(B)},this))}},h.prototype.visit=function(p){switch(p.type){case"Pattern":this.visitPattern(p);break;case"Flags":this.visitFlags(p);break;case"Disjunction":this.visitDisjunction(p);break;case"Alternative":this.visitAlternative(p);break;case"StartAnchor":this.visitStartAnchor(p);break;case"EndAnchor":this.visitEndAnchor(p);break;case"WordBoundary":this.visitWordBoundary(p);break;case"NonWordBoundary":this.visitNonWordBoundary(p);break;case"Lookahead":this.visitLookahead(p);break;case"NegativeLookahead":this.visitNegativeLookahead(p);break;case"Character":this.visitCharacter(p);break;case"Set":this.visitSet(p);break;case"Group":this.visitGroup(p);break;case"GroupBackReference":this.visitGroupBackReference(p);break;case"Quantifier":this.visitQuantifier(p);break}this.visitChildren(p)},h.prototype.visitPattern=function(p){},h.prototype.visitFlags=function(p){},h.prototype.visitDisjunction=function(p){},h.prototype.visitAlternative=function(p){},h.prototype.visitStartAnchor=function(p){},h.prototype.visitEndAnchor=function(p){},h.prototype.visitWordBoundary=function(p){},h.prototype.visitNonWordBoundary=function(p){},h.prototype.visitLookahead=function(p){},h.prototype.visitNegativeLookahead=function(p){},h.prototype.visitCharacter=function(p){},h.prototype.visitSet=function(p){},h.prototype.visitGroup=function(p){},h.prototype.visitGroupBackReference=function(p){},h.prototype.visitQuantifier=function(p){},{RegExpParser:r,BaseRegExpVisitor:h,VERSION:"0.5.0"}})});var Py=y(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.clearRegExpParserCache=ff.getRegExpAst=void 0;var zIe=vy(),xy={},VIe=new zIe.RegExpParser;function XIe(r){var e=r.toString();if(xy.hasOwnProperty(e))return xy[e];var t=VIe.pattern(e);return xy[e]=t,t}ff.getRegExpAst=XIe;function _Ie(){xy={}}ff.clearRegExpParserCache=_Ie});var Kj=y(dn=>{"use strict";var ZIe=dn&&dn.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(dn,"__esModule",{value:!0});dn.canMatchCharCode=dn.firstCharOptimizedIndices=dn.getOptimizedStartCodesIndices=dn.failedOptimizationPrefixMsg=void 0;var Tj=vy(),As=Gt(),Oj=Py(),Pa=Ix(),Mj="Complement Sets are not supported for first char optimization";dn.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations: +`;function $Ie(r,e){e===void 0&&(e=!1);try{var t=(0,Oj.getRegExpAst)(r),i=ky(t.value,{},t.flags.ignoreCase);return i}catch(s){if(s.message===Mj)e&&(0,As.PRINT_WARNING)(""+dn.failedOptimizationPrefixMsg+(" Unable to optimize: < "+r.toString()+` > +`)+` Complement Sets cannot be automatically optimized. + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var n="";e&&(n=` + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),(0,As.PRINT_ERROR)(dn.failedOptimizationPrefixMsg+` +`+(" Failed parsing: < "+r.toString()+` > +`)+(" Using the regexp-to-ast library version: "+Tj.VERSION+` +`)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+n)}}return[]}dn.getOptimizedStartCodesIndices=$Ie;function ky(r,e,t){switch(r.type){case"Disjunction":for(var i=0;i=Pa.minOptimizationVal)for(var f=u.from>=Pa.minOptimizationVal?u.from:Pa.minOptimizationVal,h=u.to,p=(0,Pa.charCodeToOptimizedIndex)(f),C=(0,Pa.charCodeToOptimizedIndex)(h),w=p;w<=C;w++)e[w]=w}}});break;case"Group":ky(o.value,e,t);break;default:throw Error("Non Exhaustive Match")}var a=o.quantifier!==void 0&&o.quantifier.atLeast===0;if(o.type==="Group"&&Ex(o)===!1||o.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return(0,As.values)(e)}dn.firstCharOptimizedIndices=ky;function Dy(r,e,t){var i=(0,Pa.charCodeToOptimizedIndex)(r);e[i]=i,t===!0&&eye(r,e)}function eye(r,e){var t=String.fromCharCode(r),i=t.toUpperCase();if(i!==t){var n=(0,Pa.charCodeToOptimizedIndex)(i.charCodeAt(0));e[n]=n}else{var s=t.toLowerCase();if(s!==t){var n=(0,Pa.charCodeToOptimizedIndex)(s.charCodeAt(0));e[n]=n}}}function Lj(r,e){return(0,As.find)(r.value,function(t){if(typeof t=="number")return(0,As.contains)(e,t);var i=t;return(0,As.find)(e,function(n){return i.from<=n&&n<=i.to})!==void 0})}function Ex(r){return r.quantifier&&r.quantifier.atLeast===0?!0:r.value?(0,As.isArray)(r.value)?(0,As.every)(r.value,Ex):Ex(r.value):!1}var tye=function(r){ZIe(e,r);function e(t){var i=r.call(this)||this;return i.targetCharCodes=t,i.found=!1,i}return e.prototype.visitChildren=function(t){if(this.found!==!0){switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return}r.prototype.visitChildren.call(this,t)}},e.prototype.visitCharacter=function(t){(0,As.contains)(this.targetCharCodes,t.value)&&(this.found=!0)},e.prototype.visitSet=function(t){t.complement?Lj(t,this.targetCharCodes)===void 0&&(this.found=!0):Lj(t,this.targetCharCodes)!==void 0&&(this.found=!0)},e}(Tj.BaseRegExpVisitor);function rye(r,e){if(e instanceof RegExp){var t=(0,Oj.getRegExpAst)(e),i=new tye(r);return i.visit(t),i.found}else return(0,As.find)(e,function(n){return(0,As.contains)(r,n.charCodeAt(0))})!==void 0}dn.canMatchCharCode=rye});var Ix=y(Je=>{"use strict";var Uj=Je&&Je.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(Je,"__esModule",{value:!0});Je.charCodeToOptimizedIndex=Je.minOptimizationVal=Je.buildLineBreakIssueMessage=Je.LineTerminatorOptimizedTester=Je.isShortPattern=Je.isCustomPattern=Je.cloneEmptyGroups=Je.performWarningRuntimeChecks=Je.performRuntimeChecks=Je.addStickyFlag=Je.addStartOfInput=Je.findUnreachablePatterns=Je.findModesThatDoNotExist=Je.findInvalidGroupType=Je.findDuplicatePatterns=Je.findUnsupportedFlags=Je.findStartOfInputAnchor=Je.findEmptyMatchRegExps=Je.findEndOfInputAnchor=Je.findInvalidPatterns=Je.findMissingPatterns=Je.validatePatterns=Je.analyzeTokenTypes=Je.enableSticky=Je.disableSticky=Je.SUPPORT_STICKY=Je.MODES=Je.DEFAULT_MODE=void 0;var Hj=vy(),ir=jd(),Se=Gt(),hf=Kj(),Gj=Py(),Do="PATTERN";Je.DEFAULT_MODE="defaultMode";Je.MODES="modes";Je.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function iye(){Je.SUPPORT_STICKY=!1}Je.disableSticky=iye;function nye(){Je.SUPPORT_STICKY=!0}Je.enableSticky=nye;function sye(r,e){e=(0,Se.defaults)(e,{useSticky:Je.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` +`],tracer:function(v,D){return D()}});var t=e.tracer;t("initCharCodeToOptimizedIndexMap",function(){pye()});var i;t("Reject Lexer.NA",function(){i=(0,Se.reject)(r,function(v){return v[Do]===ir.Lexer.NA})});var n=!1,s;t("Transform Patterns",function(){n=!1,s=(0,Se.map)(i,function(v){var D=v[Do];if((0,Se.isRegExp)(D)){var L=D.source;return L.length===1&&L!=="^"&&L!=="$"&&L!=="."&&!D.ignoreCase?L:L.length===2&&L[0]==="\\"&&!(0,Se.contains)(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],L[1])?L[1]:e.useSticky?Bx(D):wx(D)}else{if((0,Se.isFunction)(D))return n=!0,{exec:D};if((0,Se.has)(D,"exec"))return n=!0,D;if(typeof D=="string"){if(D.length===1)return D;var H=D.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),j=new RegExp(H);return e.useSticky?Bx(j):wx(j)}else throw Error("non exhaustive match")}})});var o,a,l,c,u;t("misc mapping",function(){o=(0,Se.map)(i,function(v){return v.tokenTypeIdx}),a=(0,Se.map)(i,function(v){var D=v.GROUP;if(D!==ir.Lexer.SKIPPED){if((0,Se.isString)(D))return D;if((0,Se.isUndefined)(D))return!1;throw Error("non exhaustive match")}}),l=(0,Se.map)(i,function(v){var D=v.LONGER_ALT;if(D){var L=(0,Se.isArray)(D)?(0,Se.map)(D,function(H){return(0,Se.indexOf)(i,H)}):[(0,Se.indexOf)(i,D)];return L}}),c=(0,Se.map)(i,function(v){return v.PUSH_MODE}),u=(0,Se.map)(i,function(v){return(0,Se.has)(v,"POP_MODE")})});var g;t("Line Terminator Handling",function(){var v=rq(e.lineTerminatorCharacters);g=(0,Se.map)(i,function(D){return!1}),e.positionTracking!=="onlyOffset"&&(g=(0,Se.map)(i,function(D){if((0,Se.has)(D,"LINE_BREAKS"))return D.LINE_BREAKS;if(eq(D,v)===!1)return(0,hf.canMatchCharCode)(v,D.PATTERN)}))});var f,h,p,C;t("Misc Mapping #2",function(){f=(0,Se.map)(i,bx),h=(0,Se.map)(s,$j),p=(0,Se.reduce)(i,function(v,D){var L=D.GROUP;return(0,Se.isString)(L)&&L!==ir.Lexer.SKIPPED&&(v[L]=[]),v},{}),C=(0,Se.map)(s,function(v,D){return{pattern:s[D],longerAlt:l[D],canLineTerminator:g[D],isCustom:f[D],short:h[D],group:a[D],push:c[D],pop:u[D],tokenTypeIdx:o[D],tokenType:i[D]}})});var w=!0,B=[];return e.safeMode||t("First Char Optimization",function(){B=(0,Se.reduce)(i,function(v,D,L){if(typeof D.PATTERN=="string"){var H=D.PATTERN.charCodeAt(0),j=Qx(H);yx(v,j,C[L])}else if((0,Se.isArray)(D.START_CHARS_HINT)){var $;(0,Se.forEach)(D.START_CHARS_HINT,function(W){var Z=typeof W=="string"?W.charCodeAt(0):W,A=Qx(Z);$!==A&&($=A,yx(v,A,C[L]))})}else if((0,Se.isRegExp)(D.PATTERN))if(D.PATTERN.unicode)w=!1,e.ensureOptimizations&&(0,Se.PRINT_ERROR)(""+hf.failedOptimizationPrefixMsg+(" Unable to analyze < "+D.PATTERN.toString()+` > pattern. +`)+` The regexp unicode flag is not currently supported by the regexp-to-ast library. + This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var V=(0,hf.getOptimizedStartCodesIndices)(D.PATTERN,e.ensureOptimizations);(0,Se.isEmpty)(V)&&(w=!1),(0,Se.forEach)(V,function(W){yx(v,W,C[L])})}else e.ensureOptimizations&&(0,Se.PRINT_ERROR)(""+hf.failedOptimizationPrefixMsg+(" TokenType: <"+D.name+`> is using a custom token pattern without providing parameter. +`)+` This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),w=!1;return v},[])}),t("ArrayPacking",function(){B=(0,Se.packArray)(B)}),{emptyGroups:p,patternIdxToConfig:C,charCodeToPatternIdxToConfig:B,hasCustom:n,canBeOptimized:w}}Je.analyzeTokenTypes=sye;function oye(r,e){var t=[],i=Yj(r);t=t.concat(i.errors);var n=jj(i.valid),s=n.valid;return t=t.concat(n.errors),t=t.concat(aye(s)),t=t.concat(Xj(s)),t=t.concat(_j(s,e)),t=t.concat(Zj(s)),t}Je.validatePatterns=oye;function aye(r){var e=[],t=(0,Se.filter)(r,function(i){return(0,Se.isRegExp)(i[Do])});return e=e.concat(qj(t)),e=e.concat(Wj(t)),e=e.concat(zj(t)),e=e.concat(Vj(t)),e=e.concat(Jj(t)),e}function Yj(r){var e=(0,Se.filter)(r,function(n){return!(0,Se.has)(n,Do)}),t=(0,Se.map)(e,function(n){return{message:"Token Type: ->"+n.name+"<- missing static 'PATTERN' property",type:ir.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[n]}}),i=(0,Se.difference)(r,e);return{errors:t,valid:i}}Je.findMissingPatterns=Yj;function jj(r){var e=(0,Se.filter)(r,function(n){var s=n[Do];return!(0,Se.isRegExp)(s)&&!(0,Se.isFunction)(s)&&!(0,Se.has)(s,"exec")&&!(0,Se.isString)(s)}),t=(0,Se.map)(e,function(n){return{message:"Token Type: ->"+n.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:ir.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[n]}}),i=(0,Se.difference)(r,e);return{errors:t,valid:i}}Je.findInvalidPatterns=jj;var Aye=/[^\\][\$]/;function qj(r){var e=function(n){Uj(s,n);function s(){var o=n!==null&&n.apply(this,arguments)||this;return o.found=!1,o}return s.prototype.visitEndAnchor=function(o){this.found=!0},s}(Hj.BaseRegExpVisitor),t=(0,Se.filter)(r,function(n){var s=n[Do];try{var o=(0,Gj.getRegExpAst)(s),a=new e;return a.visit(o),a.found}catch{return Aye.test(s.source)}}),i=(0,Se.map)(t,function(n){return{message:`Unexpected RegExp Anchor Error: + Token Type: ->`+n.name+`<- static 'PATTERN' cannot contain end of input anchor '$' + See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ir.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[n]}});return i}Je.findEndOfInputAnchor=qj;function Jj(r){var e=(0,Se.filter)(r,function(i){var n=i[Do];return n.test("")}),t=(0,Se.map)(e,function(i){return{message:"Token Type: ->"+i.name+"<- static 'PATTERN' must not match an empty string",type:ir.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[i]}});return t}Je.findEmptyMatchRegExps=Jj;var lye=/[^\\[][\^]|^\^/;function Wj(r){var e=function(n){Uj(s,n);function s(){var o=n!==null&&n.apply(this,arguments)||this;return o.found=!1,o}return s.prototype.visitStartAnchor=function(o){this.found=!0},s}(Hj.BaseRegExpVisitor),t=(0,Se.filter)(r,function(n){var s=n[Do];try{var o=(0,Gj.getRegExpAst)(s),a=new e;return a.visit(o),a.found}catch{return lye.test(s.source)}}),i=(0,Se.map)(t,function(n){return{message:`Unexpected RegExp Anchor Error: + Token Type: ->`+n.name+`<- static 'PATTERN' cannot contain start of input anchor '^' + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ir.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[n]}});return i}Je.findStartOfInputAnchor=Wj;function zj(r){var e=(0,Se.filter)(r,function(i){var n=i[Do];return n instanceof RegExp&&(n.multiline||n.global)}),t=(0,Se.map)(e,function(i){return{message:"Token Type: ->"+i.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:ir.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[i]}});return t}Je.findUnsupportedFlags=zj;function Vj(r){var e=[],t=(0,Se.map)(r,function(s){return(0,Se.reduce)(r,function(o,a){return s.PATTERN.source===a.PATTERN.source&&!(0,Se.contains)(e,a)&&a.PATTERN!==ir.Lexer.NA&&(e.push(a),o.push(a)),o},[])});t=(0,Se.compact)(t);var i=(0,Se.filter)(t,function(s){return s.length>1}),n=(0,Se.map)(i,function(s){var o=(0,Se.map)(s,function(l){return l.name}),a=(0,Se.first)(s).PATTERN;return{message:"The same RegExp pattern ->"+a+"<-"+("has been used in all of the following Token Types: "+o.join(", ")+" <-"),type:ir.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}});return n}Je.findDuplicatePatterns=Vj;function Xj(r){var e=(0,Se.filter)(r,function(i){if(!(0,Se.has)(i,"GROUP"))return!1;var n=i.GROUP;return n!==ir.Lexer.SKIPPED&&n!==ir.Lexer.NA&&!(0,Se.isString)(n)}),t=(0,Se.map)(e,function(i){return{message:"Token Type: ->"+i.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:ir.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[i]}});return t}Je.findInvalidGroupType=Xj;function _j(r,e){var t=(0,Se.filter)(r,function(n){return n.PUSH_MODE!==void 0&&!(0,Se.contains)(e,n.PUSH_MODE)}),i=(0,Se.map)(t,function(n){var s="Token Type: ->"+n.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+n.PUSH_MODE+"<-which does not exist";return{message:s,type:ir.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[n]}});return i}Je.findModesThatDoNotExist=_j;function Zj(r){var e=[],t=(0,Se.reduce)(r,function(i,n,s){var o=n.PATTERN;return o===ir.Lexer.NA||((0,Se.isString)(o)?i.push({str:o,idx:s,tokenType:n}):(0,Se.isRegExp)(o)&&uye(o)&&i.push({str:o.source,idx:s,tokenType:n})),i},[]);return(0,Se.forEach)(r,function(i,n){(0,Se.forEach)(t,function(s){var o=s.str,a=s.idx,l=s.tokenType;if(n"+i.name+"<-")+`in the lexer's definition. +See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:c,type:ir.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[i,l]})}})}),e}Je.findUnreachablePatterns=Zj;function cye(r,e){if((0,Se.isRegExp)(e)){var t=e.exec(r);return t!==null&&t.index===0}else{if((0,Se.isFunction)(e))return e(r,0,[],{});if((0,Se.has)(e,"exec"))return e.exec(r,0,[],{});if(typeof e=="string")return e===r;throw Error("non exhaustive match")}}function uye(r){var e=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return(0,Se.find)(e,function(t){return r.source.indexOf(t)!==-1})===void 0}function wx(r){var e=r.ignoreCase?"i":"";return new RegExp("^(?:"+r.source+")",e)}Je.addStartOfInput=wx;function Bx(r){var e=r.ignoreCase?"iy":"y";return new RegExp(""+r.source,e)}Je.addStickyFlag=Bx;function gye(r,e,t){var i=[];return(0,Se.has)(r,Je.DEFAULT_MODE)||i.push({message:"A MultiMode Lexer cannot be initialized without a <"+Je.DEFAULT_MODE+`> property in its definition +`,type:ir.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),(0,Se.has)(r,Je.MODES)||i.push({message:"A MultiMode Lexer cannot be initialized without a <"+Je.MODES+`> property in its definition +`,type:ir.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),(0,Se.has)(r,Je.MODES)&&(0,Se.has)(r,Je.DEFAULT_MODE)&&!(0,Se.has)(r.modes,r.defaultMode)&&i.push({message:"A MultiMode Lexer cannot be initialized with a "+Je.DEFAULT_MODE+": <"+r.defaultMode+`>which does not exist +`,type:ir.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),(0,Se.has)(r,Je.MODES)&&(0,Se.forEach)(r.modes,function(n,s){(0,Se.forEach)(n,function(o,a){(0,Se.isUndefined)(o)&&i.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+s+"> at index: <"+a+`> +`),type:ir.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),i}Je.performRuntimeChecks=gye;function fye(r,e,t){var i=[],n=!1,s=(0,Se.compact)((0,Se.flatten)((0,Se.mapValues)(r.modes,function(l){return l}))),o=(0,Se.reject)(s,function(l){return l[Do]===ir.Lexer.NA}),a=rq(t);return e&&(0,Se.forEach)(o,function(l){var c=eq(l,a);if(c!==!1){var u=tq(l,c),g={message:u,type:c.issue,tokenType:l};i.push(g)}else(0,Se.has)(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(n=!0):(0,hf.canMatchCharCode)(a,l.PATTERN)&&(n=!0)}),e&&!n&&i.push({message:`Warning: No LINE_BREAKS Found. + This Lexer has been defined to track line and column information, + But none of the Token Types can be identified as matching a line terminator. + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS + for details.`,type:ir.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),i}Je.performWarningRuntimeChecks=fye;function hye(r){var e={},t=(0,Se.keys)(r);return(0,Se.forEach)(t,function(i){var n=r[i];if((0,Se.isArray)(n))e[i]=[];else throw Error("non exhaustive match")}),e}Je.cloneEmptyGroups=hye;function bx(r){var e=r.PATTERN;if((0,Se.isRegExp)(e))return!1;if((0,Se.isFunction)(e))return!0;if((0,Se.has)(e,"exec"))return!0;if((0,Se.isString)(e))return!1;throw Error("non exhaustive match")}Je.isCustomPattern=bx;function $j(r){return(0,Se.isString)(r)&&r.length===1?r.charCodeAt(0):!1}Je.isShortPattern=$j;Je.LineTerminatorOptimizedTester={test:function(r){for(var e=r.length,t=this.lastIndex;t Token Type +`)+(" Root cause: "+e.errMsg+`. +`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===ir.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. +`+(" The problem is in the <"+r.name+`> Token Type +`)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}Je.buildLineBreakIssueMessage=tq;function rq(r){var e=(0,Se.map)(r,function(t){return(0,Se.isString)(t)&&t.length>0?t.charCodeAt(0):t});return e}function yx(r,e,t){r[e]===void 0?r[e]=[t]:r[e].push(t)}Je.minOptimizationVal=256;var Ry=[];function Qx(r){return r255?255+~~(r/255):r}}});var pf=y(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.isTokenType=Nt.hasExtendingTokensTypesMapProperty=Nt.hasExtendingTokensTypesProperty=Nt.hasCategoriesProperty=Nt.hasShortKeyProperty=Nt.singleAssignCategoriesToksMap=Nt.assignCategoriesMapProp=Nt.assignCategoriesTokensProp=Nt.assignTokenDefaultProps=Nt.expandCategories=Nt.augmentTokenTypes=Nt.tokenIdxToClass=Nt.tokenShortNameIdx=Nt.tokenStructuredMatcherNoCategories=Nt.tokenStructuredMatcher=void 0;var ei=Gt();function dye(r,e){var t=r.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}Nt.tokenStructuredMatcher=dye;function Cye(r,e){return r.tokenTypeIdx===e.tokenTypeIdx}Nt.tokenStructuredMatcherNoCategories=Cye;Nt.tokenShortNameIdx=1;Nt.tokenIdxToClass={};function mye(r){var e=iq(r);nq(e),oq(e),sq(e),(0,ei.forEach)(e,function(t){t.isParent=t.categoryMatches.length>0})}Nt.augmentTokenTypes=mye;function iq(r){for(var e=(0,ei.cloneArr)(r),t=r,i=!0;i;){t=(0,ei.compact)((0,ei.flatten)((0,ei.map)(t,function(s){return s.CATEGORIES})));var n=(0,ei.difference)(t,e);e=e.concat(n),(0,ei.isEmpty)(n)?i=!1:t=n}return e}Nt.expandCategories=iq;function nq(r){(0,ei.forEach)(r,function(e){aq(e)||(Nt.tokenIdxToClass[Nt.tokenShortNameIdx]=e,e.tokenTypeIdx=Nt.tokenShortNameIdx++),Sx(e)&&!(0,ei.isArray)(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Sx(e)||(e.CATEGORIES=[]),Aq(e)||(e.categoryMatches=[]),lq(e)||(e.categoryMatchesMap={})})}Nt.assignTokenDefaultProps=nq;function sq(r){(0,ei.forEach)(r,function(e){e.categoryMatches=[],(0,ei.forEach)(e.categoryMatchesMap,function(t,i){e.categoryMatches.push(Nt.tokenIdxToClass[i].tokenTypeIdx)})})}Nt.assignCategoriesTokensProp=sq;function oq(r){(0,ei.forEach)(r,function(e){vx([],e)})}Nt.assignCategoriesMapProp=oq;function vx(r,e){(0,ei.forEach)(r,function(t){e.categoryMatchesMap[t.tokenTypeIdx]=!0}),(0,ei.forEach)(e.CATEGORIES,function(t){var i=r.concat(e);(0,ei.contains)(i,t)||vx(i,t)})}Nt.singleAssignCategoriesToksMap=vx;function aq(r){return(0,ei.has)(r,"tokenTypeIdx")}Nt.hasShortKeyProperty=aq;function Sx(r){return(0,ei.has)(r,"CATEGORIES")}Nt.hasCategoriesProperty=Sx;function Aq(r){return(0,ei.has)(r,"categoryMatches")}Nt.hasExtendingTokensTypesProperty=Aq;function lq(r){return(0,ei.has)(r,"categoryMatchesMap")}Nt.hasExtendingTokensTypesMapProperty=lq;function Eye(r){return(0,ei.has)(r,"tokenTypeIdx")}Nt.isTokenType=Eye});var xx=y(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.defaultLexerErrorProvider=void 0;Fy.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(r){return"Unable to pop Lexer Mode after encountering Token ->"+r.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(r,e,t,i,n){return"unexpected character: ->"+r.charAt(e)+"<- at offset: "+e+","+(" skipped "+t+" characters.")}}});var jd=y(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.Lexer=kc.LexerDefinitionErrorType=void 0;var Vs=Ix(),nr=Gt(),Iye=pf(),yye=xx(),wye=Py(),Bye;(function(r){r[r.MISSING_PATTERN=0]="MISSING_PATTERN",r[r.INVALID_PATTERN=1]="INVALID_PATTERN",r[r.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",r[r.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",r[r.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",r[r.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",r[r.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",r[r.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",r[r.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",r[r.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",r[r.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",r[r.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",r[r.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",r[r.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",r[r.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",r[r.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",r[r.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(Bye=kc.LexerDefinitionErrorType||(kc.LexerDefinitionErrorType={}));var qd={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` +`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:yye.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(qd);var Qye=function(){function r(e,t){var i=this;if(t===void 0&&(t=qd),this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. +a boolean 2nd argument is no longer supported`);this.config=(0,nr.merge)(qd,t);var n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var s,o=!0;i.TRACE_INIT("Lexer Config handling",function(){if(i.config.lineTerminatorsPattern===qd.lineTerminatorsPattern)i.config.lineTerminatorsPattern=Vs.LineTerminatorOptimizedTester;else if(i.config.lineTerminatorCharacters===qd.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');i.trackStartLines=/full|onlyStart/i.test(i.config.positionTracking),i.trackEndLines=/full/i.test(i.config.positionTracking),(0,nr.isArray)(e)?(s={modes:{}},s.modes[Vs.DEFAULT_MODE]=(0,nr.cloneArr)(e),s[Vs.DEFAULT_MODE]=Vs.DEFAULT_MODE):(o=!1,s=(0,nr.cloneObj)(e))}),i.config.skipValidations===!1&&(i.TRACE_INIT("performRuntimeChecks",function(){i.lexerDefinitionErrors=i.lexerDefinitionErrors.concat((0,Vs.performRuntimeChecks)(s,i.trackStartLines,i.config.lineTerminatorCharacters))}),i.TRACE_INIT("performWarningRuntimeChecks",function(){i.lexerDefinitionWarning=i.lexerDefinitionWarning.concat((0,Vs.performWarningRuntimeChecks)(s,i.trackStartLines,i.config.lineTerminatorCharacters))})),s.modes=s.modes?s.modes:{},(0,nr.forEach)(s.modes,function(u,g){s.modes[g]=(0,nr.reject)(u,function(f){return(0,nr.isUndefined)(f)})});var a=(0,nr.keys)(s.modes);if((0,nr.forEach)(s.modes,function(u,g){i.TRACE_INIT("Mode: <"+g+"> processing",function(){if(i.modes.push(g),i.config.skipValidations===!1&&i.TRACE_INIT("validatePatterns",function(){i.lexerDefinitionErrors=i.lexerDefinitionErrors.concat((0,Vs.validatePatterns)(u,a))}),(0,nr.isEmpty)(i.lexerDefinitionErrors)){(0,Iye.augmentTokenTypes)(u);var f;i.TRACE_INIT("analyzeTokenTypes",function(){f=(0,Vs.analyzeTokenTypes)(u,{lineTerminatorCharacters:i.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:i.TRACE_INIT.bind(i)})}),i.patternIdxToConfig[g]=f.patternIdxToConfig,i.charCodeToPatternIdxToConfig[g]=f.charCodeToPatternIdxToConfig,i.emptyGroups=(0,nr.merge)(i.emptyGroups,f.emptyGroups),i.hasCustom=f.hasCustom||i.hasCustom,i.canModeBeOptimized[g]=f.canBeOptimized}})}),i.defaultMode=s.defaultMode,!(0,nr.isEmpty)(i.lexerDefinitionErrors)&&!i.config.deferDefinitionErrorsHandling){var l=(0,nr.map)(i.lexerDefinitionErrors,function(u){return u.message}),c=l.join(`----------------------- +`);throw new Error(`Errors detected in definition of Lexer: +`+c)}(0,nr.forEach)(i.lexerDefinitionWarning,function(u){(0,nr.PRINT_WARNING)(u.message)}),i.TRACE_INIT("Choosing sub-methods implementations",function(){if(Vs.SUPPORT_STICKY?(i.chopInput=nr.IDENTITY,i.match=i.matchWithTest):(i.updateLastIndex=nr.NOOP,i.match=i.matchWithExec),o&&(i.handleModes=nr.NOOP),i.trackStartLines===!1&&(i.computeNewColumn=nr.IDENTITY),i.trackEndLines===!1&&(i.updateTokenEndLineColumnLocation=nr.NOOP),/full/i.test(i.config.positionTracking))i.createTokenInstance=i.createFullToken;else if(/onlyStart/i.test(i.config.positionTracking))i.createTokenInstance=i.createStartOnlyToken;else if(/onlyOffset/i.test(i.config.positionTracking))i.createTokenInstance=i.createOffsetOnlyToken;else throw Error('Invalid config option: "'+i.config.positionTracking+'"');i.hasCustom?(i.addToken=i.addTokenUsingPush,i.handlePayload=i.handlePayloadWithCustom):(i.addToken=i.addTokenUsingMemberAccess,i.handlePayload=i.handlePayloadNoCustom)}),i.TRACE_INIT("Failed Optimization Warnings",function(){var u=(0,nr.reduce)(i.canModeBeOptimized,function(g,f,h){return f===!1&&g.push(h),g},[]);if(t.ensureOptimizations&&!(0,nr.isEmpty)(u))throw Error("Lexer Modes: < "+u.join(", ")+` > cannot be optimized. + Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode. + Or inspect the console log for details on how to resolve these issues.`)}),i.TRACE_INIT("clearRegExpParserCache",function(){(0,wye.clearRegExpParserCache)()}),i.TRACE_INIT("toFastProperties",function(){(0,nr.toFastProperties)(i)})})}return r.prototype.tokenize=function(e,t){if(t===void 0&&(t=this.defaultMode),!(0,nr.isEmpty)(this.lexerDefinitionErrors)){var i=(0,nr.map)(this.lexerDefinitionErrors,function(o){return o.message}),n=i.join(`----------------------- +`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer: +`+n)}var s=this.tokenizeInternal(e,t);return s},r.prototype.tokenizeInternal=function(e,t){var i=this,n,s,o,a,l,c,u,g,f,h,p,C,w,B,v,D,L=e,H=L.length,j=0,$=0,V=this.hasCustom?0:Math.floor(e.length/10),W=new Array(V),Z=[],A=this.trackStartLines?1:void 0,ae=this.trackStartLines?1:void 0,ge=(0,Vs.cloneEmptyGroups)(this.emptyGroups),_=this.trackStartLines,T=this.config.lineTerminatorsPattern,N=0,ue=[],we=[],Le=[],Pe=[];Object.freeze(Pe);var Te=void 0;function se(){return ue}function Ae(dr){var Bi=(0,Vs.charCodeToOptimizedIndex)(dr),_n=we[Bi];return _n===void 0?Pe:_n}var Qe=function(dr){if(Le.length===1&&dr.tokenType.PUSH_MODE===void 0){var Bi=i.config.errorMessageProvider.buildUnableToPopLexerModeMessage(dr);Z.push({offset:dr.startOffset,line:dr.startLine!==void 0?dr.startLine:void 0,column:dr.startColumn!==void 0?dr.startColumn:void 0,length:dr.image.length,message:Bi})}else{Le.pop();var _n=(0,nr.last)(Le);ue=i.patternIdxToConfig[_n],we=i.charCodeToPatternIdxToConfig[_n],N=ue.length;var ha=i.canModeBeOptimized[_n]&&i.config.safeMode===!1;we&&ha?Te=Ae:Te=se}};function fe(dr){Le.push(dr),we=this.charCodeToPatternIdxToConfig[dr],ue=this.patternIdxToConfig[dr],N=ue.length,N=ue.length;var Bi=this.canModeBeOptimized[dr]&&this.config.safeMode===!1;we&&Bi?Te=Ae:Te=se}fe.call(this,t);for(var le;jc.length){c=a,u=g,le=tt;break}}}break}}if(c!==null){if(f=c.length,h=le.group,h!==void 0&&(p=le.tokenTypeIdx,C=this.createTokenInstance(c,j,p,le.tokenType,A,ae,f),this.handlePayload(C,u),h===!1?$=this.addToken(W,$,C):ge[h].push(C)),e=this.chopInput(e,f),j=j+f,ae=this.computeNewColumn(ae,f),_===!0&&le.canLineTerminator===!0){var It=0,Kr=void 0,oi=void 0;T.lastIndex=0;do Kr=T.test(c),Kr===!0&&(oi=T.lastIndex-1,It++);while(Kr===!0);It!==0&&(A=A+It,ae=f-oi,this.updateTokenEndLineColumnLocation(C,h,oi,It,A,ae,f))}this.handleModes(le,Qe,fe,C)}else{for(var pi=j,pr=A,di=ae,ai=!1;!ai&&j <"+e+">");var n=(0,nr.timer)(t),s=n.time,o=n.value,a=s>10?console.warn:console.log;return this.traceInitIndent time: "+s+"ms"),this.traceInitIndent--,o}else return t()},r.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",r.NA=/NOT_APPLICABLE/,r}();kc.Lexer=Qye});var UA=y(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.tokenMatcher=Si.createTokenInstance=Si.EOF=Si.createToken=Si.hasTokenLabel=Si.tokenName=Si.tokenLabel=void 0;var Xs=Gt(),bye=jd(),Px=pf();function Sye(r){return mq(r)?r.LABEL:r.name}Si.tokenLabel=Sye;function vye(r){return r.name}Si.tokenName=vye;function mq(r){return(0,Xs.isString)(r.LABEL)&&r.LABEL!==""}Si.hasTokenLabel=mq;var xye="parent",cq="categories",uq="label",gq="group",fq="push_mode",hq="pop_mode",pq="longer_alt",dq="line_breaks",Cq="start_chars_hint";function Eq(r){return Pye(r)}Si.createToken=Eq;function Pye(r){var e=r.pattern,t={};if(t.name=r.name,(0,Xs.isUndefined)(e)||(t.PATTERN=e),(0,Xs.has)(r,xye))throw`The parent property is no longer supported. +See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return(0,Xs.has)(r,cq)&&(t.CATEGORIES=r[cq]),(0,Px.augmentTokenTypes)([t]),(0,Xs.has)(r,uq)&&(t.LABEL=r[uq]),(0,Xs.has)(r,gq)&&(t.GROUP=r[gq]),(0,Xs.has)(r,hq)&&(t.POP_MODE=r[hq]),(0,Xs.has)(r,fq)&&(t.PUSH_MODE=r[fq]),(0,Xs.has)(r,pq)&&(t.LONGER_ALT=r[pq]),(0,Xs.has)(r,dq)&&(t.LINE_BREAKS=r[dq]),(0,Xs.has)(r,Cq)&&(t.START_CHARS_HINT=r[Cq]),t}Si.EOF=Eq({name:"EOF",pattern:bye.Lexer.NA});(0,Px.augmentTokenTypes)([Si.EOF]);function Dye(r,e,t,i,n,s,o,a){return{image:e,startOffset:t,endOffset:i,startLine:n,endLine:s,startColumn:o,endColumn:a,tokenTypeIdx:r.tokenTypeIdx,tokenType:r}}Si.createTokenInstance=Dye;function kye(r,e){return(0,Px.tokenStructuredMatcher)(r,e)}Si.tokenMatcher=kye});var Cn=y(Wt=>{"use strict";var Da=Wt&&Wt.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(Wt,"__esModule",{value:!0});Wt.serializeProduction=Wt.serializeGrammar=Wt.Terminal=Wt.Alternation=Wt.RepetitionWithSeparator=Wt.Repetition=Wt.RepetitionMandatoryWithSeparator=Wt.RepetitionMandatory=Wt.Option=Wt.Alternative=Wt.Rule=Wt.NonTerminal=Wt.AbstractProduction=void 0;var lr=Gt(),Rye=UA(),ko=function(){function r(e){this._definition=e}return Object.defineProperty(r.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),r.prototype.accept=function(e){e.visit(this),(0,lr.forEach)(this.definition,function(t){t.accept(e)})},r}();Wt.AbstractProduction=ko;var Iq=function(r){Da(e,r);function e(t){var i=r.call(this,[])||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return Object.defineProperty(e.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(t){},enumerable:!1,configurable:!0}),e.prototype.accept=function(t){t.visit(this)},e}(ko);Wt.NonTerminal=Iq;var yq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.orgText="",(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.Rule=yq;var wq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.ignoreAmbiguities=!1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.Alternative=wq;var Bq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.Option=Bq;var Qq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.RepetitionMandatory=Qq;var bq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.RepetitionMandatoryWithSeparator=bq;var Sq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.Repetition=Sq;var vq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return e}(ko);Wt.RepetitionWithSeparator=vq;var xq=function(r){Da(e,r);function e(t){var i=r.call(this,t.definition)||this;return i.idx=1,i.ignoreAmbiguities=!1,i.hasPredicates=!1,(0,lr.assign)(i,(0,lr.pick)(t,function(n){return n!==void 0})),i}return Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(t){this._definition=t},enumerable:!1,configurable:!0}),e}(ko);Wt.Alternation=xq;var Ny=function(){function r(e){this.idx=1,(0,lr.assign)(this,(0,lr.pick)(e,function(t){return t!==void 0}))}return r.prototype.accept=function(e){e.visit(this)},r}();Wt.Terminal=Ny;function Fye(r){return(0,lr.map)(r,Jd)}Wt.serializeGrammar=Fye;function Jd(r){function e(s){return(0,lr.map)(s,Jd)}if(r instanceof Iq){var t={type:"NonTerminal",name:r.nonTerminalName,idx:r.idx};return(0,lr.isString)(r.label)&&(t.label=r.label),t}else{if(r instanceof wq)return{type:"Alternative",definition:e(r.definition)};if(r instanceof Bq)return{type:"Option",idx:r.idx,definition:e(r.definition)};if(r instanceof Qq)return{type:"RepetitionMandatory",idx:r.idx,definition:e(r.definition)};if(r instanceof bq)return{type:"RepetitionMandatoryWithSeparator",idx:r.idx,separator:Jd(new Ny({terminalType:r.separator})),definition:e(r.definition)};if(r instanceof vq)return{type:"RepetitionWithSeparator",idx:r.idx,separator:Jd(new Ny({terminalType:r.separator})),definition:e(r.definition)};if(r instanceof Sq)return{type:"Repetition",idx:r.idx,definition:e(r.definition)};if(r instanceof xq)return{type:"Alternation",idx:r.idx,definition:e(r.definition)};if(r instanceof Ny){var i={type:"Terminal",name:r.terminalType.name,label:(0,Rye.tokenLabel)(r.terminalType),idx:r.idx};(0,lr.isString)(r.label)&&(i.terminalLabel=r.label);var n=r.terminalType.PATTERN;return r.terminalType.PATTERN&&(i.pattern=(0,lr.isRegExp)(n)?n.source:n),i}else{if(r instanceof yq)return{type:"Rule",name:r.name,orgText:r.orgText,definition:e(r.definition)};throw Error("non exhaustive match")}}}Wt.serializeProduction=Jd});var Ty=y(Ly=>{"use strict";Object.defineProperty(Ly,"__esModule",{value:!0});Ly.RestWalker=void 0;var Dx=Gt(),mn=Cn(),Nye=function(){function r(){}return r.prototype.walk=function(e,t){var i=this;t===void 0&&(t=[]),(0,Dx.forEach)(e.definition,function(n,s){var o=(0,Dx.drop)(e.definition,s+1);if(n instanceof mn.NonTerminal)i.walkProdRef(n,o,t);else if(n instanceof mn.Terminal)i.walkTerminal(n,o,t);else if(n instanceof mn.Alternative)i.walkFlat(n,o,t);else if(n instanceof mn.Option)i.walkOption(n,o,t);else if(n instanceof mn.RepetitionMandatory)i.walkAtLeastOne(n,o,t);else if(n instanceof mn.RepetitionMandatoryWithSeparator)i.walkAtLeastOneSep(n,o,t);else if(n instanceof mn.RepetitionWithSeparator)i.walkManySep(n,o,t);else if(n instanceof mn.Repetition)i.walkMany(n,o,t);else if(n instanceof mn.Alternation)i.walkOr(n,o,t);else throw Error("non exhaustive match")})},r.prototype.walkTerminal=function(e,t,i){},r.prototype.walkProdRef=function(e,t,i){},r.prototype.walkFlat=function(e,t,i){var n=t.concat(i);this.walk(e,n)},r.prototype.walkOption=function(e,t,i){var n=t.concat(i);this.walk(e,n)},r.prototype.walkAtLeastOne=function(e,t,i){var n=[new mn.Option({definition:e.definition})].concat(t,i);this.walk(e,n)},r.prototype.walkAtLeastOneSep=function(e,t,i){var n=Pq(e,t,i);this.walk(e,n)},r.prototype.walkMany=function(e,t,i){var n=[new mn.Option({definition:e.definition})].concat(t,i);this.walk(e,n)},r.prototype.walkManySep=function(e,t,i){var n=Pq(e,t,i);this.walk(e,n)},r.prototype.walkOr=function(e,t,i){var n=this,s=t.concat(i);(0,Dx.forEach)(e.definition,function(o){var a=new mn.Alternative({definition:[o]});n.walk(a,s)})},r}();Ly.RestWalker=Nye;function Pq(r,e,t){var i=[new mn.Option({definition:[new mn.Terminal({terminalType:r.separator})].concat(r.definition)})],n=i.concat(e,t);return n}});var df=y(Oy=>{"use strict";Object.defineProperty(Oy,"__esModule",{value:!0});Oy.GAstVisitor=void 0;var Ro=Cn(),Lye=function(){function r(){}return r.prototype.visit=function(e){var t=e;switch(t.constructor){case Ro.NonTerminal:return this.visitNonTerminal(t);case Ro.Alternative:return this.visitAlternative(t);case Ro.Option:return this.visitOption(t);case Ro.RepetitionMandatory:return this.visitRepetitionMandatory(t);case Ro.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(t);case Ro.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(t);case Ro.Repetition:return this.visitRepetition(t);case Ro.Alternation:return this.visitAlternation(t);case Ro.Terminal:return this.visitTerminal(t);case Ro.Rule:return this.visitRule(t);default:throw Error("non exhaustive match")}},r.prototype.visitNonTerminal=function(e){},r.prototype.visitAlternative=function(e){},r.prototype.visitOption=function(e){},r.prototype.visitRepetition=function(e){},r.prototype.visitRepetitionMandatory=function(e){},r.prototype.visitRepetitionMandatoryWithSeparator=function(e){},r.prototype.visitRepetitionWithSeparator=function(e){},r.prototype.visitAlternation=function(e){},r.prototype.visitTerminal=function(e){},r.prototype.visitRule=function(e){},r}();Oy.GAstVisitor=Lye});var zd=y(Ki=>{"use strict";var Tye=Ki&&Ki.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(Ki,"__esModule",{value:!0});Ki.collectMethods=Ki.DslMethodsCollectorVisitor=Ki.getProductionDslName=Ki.isBranchingProd=Ki.isOptionalProd=Ki.isSequenceProd=void 0;var Wd=Gt(),Qr=Cn(),Oye=df();function Mye(r){return r instanceof Qr.Alternative||r instanceof Qr.Option||r instanceof Qr.Repetition||r instanceof Qr.RepetitionMandatory||r instanceof Qr.RepetitionMandatoryWithSeparator||r instanceof Qr.RepetitionWithSeparator||r instanceof Qr.Terminal||r instanceof Qr.Rule}Ki.isSequenceProd=Mye;function kx(r,e){e===void 0&&(e=[]);var t=r instanceof Qr.Option||r instanceof Qr.Repetition||r instanceof Qr.RepetitionWithSeparator;return t?!0:r instanceof Qr.Alternation?(0,Wd.some)(r.definition,function(i){return kx(i,e)}):r instanceof Qr.NonTerminal&&(0,Wd.contains)(e,r)?!1:r instanceof Qr.AbstractProduction?(r instanceof Qr.NonTerminal&&e.push(r),(0,Wd.every)(r.definition,function(i){return kx(i,e)})):!1}Ki.isOptionalProd=kx;function Kye(r){return r instanceof Qr.Alternation}Ki.isBranchingProd=Kye;function Uye(r){if(r instanceof Qr.NonTerminal)return"SUBRULE";if(r instanceof Qr.Option)return"OPTION";if(r instanceof Qr.Alternation)return"OR";if(r instanceof Qr.RepetitionMandatory)return"AT_LEAST_ONE";if(r instanceof Qr.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(r instanceof Qr.RepetitionWithSeparator)return"MANY_SEP";if(r instanceof Qr.Repetition)return"MANY";if(r instanceof Qr.Terminal)return"CONSUME";throw Error("non exhaustive match")}Ki.getProductionDslName=Uye;var Dq=function(r){Tye(e,r);function e(){var t=r!==null&&r.apply(this,arguments)||this;return t.separator="-",t.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},t}return e.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},e.prototype.visitTerminal=function(t){var i=t.terminalType.name+this.separator+"Terminal";(0,Wd.has)(this.dslMethods,i)||(this.dslMethods[i]=[]),this.dslMethods[i].push(t)},e.prototype.visitNonTerminal=function(t){var i=t.nonTerminalName+this.separator+"Terminal";(0,Wd.has)(this.dslMethods,i)||(this.dslMethods[i]=[]),this.dslMethods[i].push(t)},e.prototype.visitOption=function(t){this.dslMethods.option.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.dslMethods.repetitionWithSeparator.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.dslMethods.repetitionMandatory.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)},e.prototype.visitRepetition=function(t){this.dslMethods.repetition.push(t)},e.prototype.visitAlternation=function(t){this.dslMethods.alternation.push(t)},e}(Oye.GAstVisitor);Ki.DslMethodsCollectorVisitor=Dq;var My=new Dq;function Hye(r){My.reset(),r.accept(My);var e=My.dslMethods;return My.reset(),e}Ki.collectMethods=Hye});var Fx=y(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.firstForTerminal=Fo.firstForBranching=Fo.firstForSequence=Fo.first=void 0;var Ky=Gt(),kq=Cn(),Rx=zd();function Uy(r){if(r instanceof kq.NonTerminal)return Uy(r.referencedRule);if(r instanceof kq.Terminal)return Nq(r);if((0,Rx.isSequenceProd)(r))return Rq(r);if((0,Rx.isBranchingProd)(r))return Fq(r);throw Error("non exhaustive match")}Fo.first=Uy;function Rq(r){for(var e=[],t=r.definition,i=0,n=t.length>i,s,o=!0;n&&o;)s=t[i],o=(0,Rx.isOptionalProd)(s),e=e.concat(Uy(s)),i=i+1,n=t.length>i;return(0,Ky.uniq)(e)}Fo.firstForSequence=Rq;function Fq(r){var e=(0,Ky.map)(r.definition,function(t){return Uy(t)});return(0,Ky.uniq)((0,Ky.flatten)(e))}Fo.firstForBranching=Fq;function Nq(r){return[r.terminalType]}Fo.firstForTerminal=Nq});var Nx=y(Hy=>{"use strict";Object.defineProperty(Hy,"__esModule",{value:!0});Hy.IN=void 0;Hy.IN="_~IN~_"});var Kq=y(ls=>{"use strict";var Gye=ls&&ls.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(ls,"__esModule",{value:!0});ls.buildInProdFollowPrefix=ls.buildBetweenProdsFollowPrefix=ls.computeAllProdsFollows=ls.ResyncFollowsWalker=void 0;var Yye=Ty(),jye=Fx(),Lq=Gt(),Tq=Nx(),qye=Cn(),Oq=function(r){Gye(e,r);function e(t){var i=r.call(this)||this;return i.topProd=t,i.follows={},i}return e.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},e.prototype.walkTerminal=function(t,i,n){},e.prototype.walkProdRef=function(t,i,n){var s=Mq(t.referencedRule,t.idx)+this.topProd.name,o=i.concat(n),a=new qye.Alternative({definition:o}),l=(0,jye.first)(a);this.follows[s]=l},e}(Yye.RestWalker);ls.ResyncFollowsWalker=Oq;function Jye(r){var e={};return(0,Lq.forEach)(r,function(t){var i=new Oq(t).startWalking();(0,Lq.assign)(e,i)}),e}ls.computeAllProdsFollows=Jye;function Mq(r,e){return r.name+e+Tq.IN}ls.buildBetweenProdsFollowPrefix=Mq;function Wye(r){var e=r.terminalType.name;return e+r.idx+Tq.IN}ls.buildInProdFollowPrefix=Wye});var Vd=y(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.defaultGrammarValidatorErrorProvider=ka.defaultGrammarResolverErrorProvider=ka.defaultParserErrorProvider=void 0;var Cf=UA(),zye=Gt(),_s=Gt(),Lx=Cn(),Uq=zd();ka.defaultParserErrorProvider={buildMismatchTokenMessage:function(r){var e=r.expected,t=r.actual,i=r.previous,n=r.ruleName,s=(0,Cf.hasTokenLabel)(e),o=s?"--> "+(0,Cf.tokenLabel)(e)+" <--":"token of type --> "+e.name+" <--",a="Expecting "+o+" but found --> '"+t.image+"' <--";return a},buildNotAllInputParsedMessage:function(r){var e=r.firstRedundant,t=r.ruleName;return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(r){var e=r.expectedPathsPerAlt,t=r.actual,i=r.previous,n=r.customUserDescription,s=r.ruleName,o="Expecting: ",a=(0,_s.first)(t).image,l=` +but found: '`+a+"'";if(n)return o+n+l;var c=(0,_s.reduce)(e,function(h,p){return h.concat(p)},[]),u=(0,_s.map)(c,function(h){return"["+(0,_s.map)(h,function(p){return(0,Cf.tokenLabel)(p)}).join(", ")+"]"}),g=(0,_s.map)(u,function(h,p){return" "+(p+1)+". "+h}),f=`one of these possible Token sequences: +`+g.join(` +`);return o+f+l},buildEarlyExitMessage:function(r){var e=r.expectedIterationPaths,t=r.actual,i=r.customUserDescription,n=r.ruleName,s="Expecting: ",o=(0,_s.first)(t).image,a=` +but found: '`+o+"'";if(i)return s+i+a;var l=(0,_s.map)(e,function(u){return"["+(0,_s.map)(u,function(g){return(0,Cf.tokenLabel)(g)}).join(",")+"]"}),c=`expecting at least one iteration which starts with one of these possible Token sequences:: + `+("<"+l.join(" ,")+">");return s+c+a}};Object.freeze(ka.defaultParserErrorProvider);ka.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(r,e){var t="Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<- +inside top level rule: ->`+r.name+"<-";return t}};ka.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(r,e){function t(u){return u instanceof Lx.Terminal?u.terminalType.name:u instanceof Lx.NonTerminal?u.nonTerminalName:""}var i=r.name,n=(0,_s.first)(e),s=n.idx,o=(0,Uq.getProductionDslName)(n),a=t(n),l=s>0,c="->"+o+(l?s:"")+"<- "+(a?"with argument: ->"+a+"<-":"")+` + appears more than once (`+e.length+" times) in the top level rule: ->"+i+`<-. + For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES + `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,` +`),c},buildNamespaceConflictError:function(r){var e=`Namespace conflict found in grammar. +`+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+r.name+`>. +`)+`To resolve this make sure each Terminal and Non-Terminal names are unique +This is easy to accomplish by using the convention that Terminal names start with an uppercase letter +and Non-Terminal names start with a lower case letter.`;return e},buildAlternationPrefixAmbiguityError:function(r){var e=(0,_s.map)(r.prefixPath,function(n){return(0,Cf.tokenLabel)(n)}).join(", "),t=r.alternation.idx===0?"":r.alternation.idx,i="Ambiguous alternatives: <"+r.ambiguityIndices.join(" ,")+`> due to common lookahead prefix +`+("in inside <"+r.topLevelRule.name+`> Rule, +`)+("<"+e+`> may appears as a prefix path in all these alternatives. +`)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX +For Further details.`;return i},buildAlternationAmbiguityError:function(r){var e=(0,_s.map)(r.prefixPath,function(n){return(0,Cf.tokenLabel)(n)}).join(", "),t=r.alternation.idx===0?"":r.alternation.idx,i="Ambiguous Alternatives Detected: <"+r.ambiguityIndices.join(" ,")+"> in "+(" inside <"+r.topLevelRule.name+`> Rule, +`)+("<"+e+`> may appears as a prefix path in all these alternatives. +`);return i=i+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES +For Further details.`,i},buildEmptyRepetitionError:function(r){var e=(0,Uq.getProductionDslName)(r.repetition);r.repetition.idx!==0&&(e+=r.repetition.idx);var t="The repetition <"+e+"> within Rule <"+r.topLevelRule.name+`> can never consume any tokens. +This could lead to an infinite loop.`;return t},buildTokenNameError:function(r){return"deprecated"},buildEmptyAlternationError:function(r){var e="Ambiguous empty alternative: <"+(r.emptyChoiceIdx+1)+">"+(" in inside <"+r.topLevelRule.name+`> Rule. +`)+"Only the last alternative may be an empty alternative.";return e},buildTooManyAlternativesError:function(r){var e=`An Alternation cannot have more than 256 alternatives: +`+(" inside <"+r.topLevelRule.name+`> Rule. + has `+(r.alternation.definition.length+1)+" alternatives.");return e},buildLeftRecursionError:function(r){var e=r.topLevelRule.name,t=zye.map(r.leftRecursionPath,function(s){return s.name}),i=e+" --> "+t.concat([e]).join(" --> "),n=`Left Recursion found in grammar. +`+("rule: <"+e+`> can be invoked from itself (directly or indirectly) +`)+(`without consuming any Tokens. The grammar path that causes this is: + `+i+` +`)+` To fix this refactor your grammar to remove the left recursion. +see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return n},buildInvalidRuleNameError:function(r){return"deprecated"},buildDuplicateRuleNameError:function(r){var e;r.topLevelRule instanceof Lx.Rule?e=r.topLevelRule.name:e=r.topLevelRule;var t="Duplicate definition, rule: ->"+e+"<- is already defined in the grammar: ->"+r.grammarName+"<-";return t}}});var Yq=y(HA=>{"use strict";var Vye=HA&&HA.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(HA,"__esModule",{value:!0});HA.GastRefResolverVisitor=HA.resolveGrammar=void 0;var Xye=Hn(),Hq=Gt(),_ye=df();function Zye(r,e){var t=new Gq(r,e);return t.resolveRefs(),t.errors}HA.resolveGrammar=Zye;var Gq=function(r){Vye(e,r);function e(t,i){var n=r.call(this)||this;return n.nameToTopRule=t,n.errMsgProvider=i,n.errors=[],n}return e.prototype.resolveRefs=function(){var t=this;(0,Hq.forEach)((0,Hq.values)(this.nameToTopRule),function(i){t.currTopLevel=i,i.accept(t)})},e.prototype.visitNonTerminal=function(t){var i=this.nameToTopRule[t.nonTerminalName];if(i)t.referencedRule=i;else{var n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:Xye.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}},e}(_ye.GAstVisitor);HA.GastRefResolverVisitor=Gq});var _d=y(Tr=>{"use strict";var Rc=Tr&&Tr.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(Tr,"__esModule",{value:!0});Tr.nextPossibleTokensAfter=Tr.possiblePathsFrom=Tr.NextTerminalAfterAtLeastOneSepWalker=Tr.NextTerminalAfterAtLeastOneWalker=Tr.NextTerminalAfterManySepWalker=Tr.NextTerminalAfterManyWalker=Tr.AbstractNextTerminalAfterProductionWalker=Tr.NextAfterTokenWalker=Tr.AbstractNextPossibleTokensWalker=void 0;var jq=Ty(),Kt=Gt(),$ye=Fx(),Dt=Cn(),qq=function(r){Rc(e,r);function e(t,i){var n=r.call(this)||this;return n.topProd=t,n.path=i,n.possibleTokTypes=[],n.nextProductionName="",n.nextProductionOccurrence=0,n.found=!1,n.isAtEndOfPath=!1,n}return e.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=(0,Kt.cloneArr)(this.path.ruleStack).reverse(),this.occurrenceStack=(0,Kt.cloneArr)(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},e.prototype.walk=function(t,i){i===void 0&&(i=[]),this.found||r.prototype.walk.call(this,t,i)},e.prototype.walkProdRef=function(t,i,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){var s=i.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,s)}},e.prototype.updateExpectedNext=function(){(0,Kt.isEmpty)(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e}(jq.RestWalker);Tr.AbstractNextPossibleTokensWalker=qq;var ewe=function(r){Rc(e,r);function e(t,i){var n=r.call(this,t,i)||this;return n.path=i,n.nextTerminalName="",n.nextTerminalOccurrence=0,n.nextTerminalName=n.path.lastTok.name,n.nextTerminalOccurrence=n.path.lastTokOccurrence,n}return e.prototype.walkTerminal=function(t,i,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){var s=i.concat(n),o=new Dt.Alternative({definition:s});this.possibleTokTypes=(0,$ye.first)(o),this.found=!0}},e}(qq);Tr.NextAfterTokenWalker=ewe;var Xd=function(r){Rc(e,r);function e(t,i){var n=r.call(this)||this;return n.topRule=t,n.occurrence=i,n.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},n}return e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e}(jq.RestWalker);Tr.AbstractNextTerminalAfterProductionWalker=Xd;var twe=function(r){Rc(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.walkMany=function(t,i,n){if(t.idx===this.occurrence){var s=(0,Kt.first)(i.concat(n));this.result.isEndOfRule=s===void 0,s instanceof Dt.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else r.prototype.walkMany.call(this,t,i,n)},e}(Xd);Tr.NextTerminalAfterManyWalker=twe;var rwe=function(r){Rc(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.walkManySep=function(t,i,n){if(t.idx===this.occurrence){var s=(0,Kt.first)(i.concat(n));this.result.isEndOfRule=s===void 0,s instanceof Dt.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else r.prototype.walkManySep.call(this,t,i,n)},e}(Xd);Tr.NextTerminalAfterManySepWalker=rwe;var iwe=function(r){Rc(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.walkAtLeastOne=function(t,i,n){if(t.idx===this.occurrence){var s=(0,Kt.first)(i.concat(n));this.result.isEndOfRule=s===void 0,s instanceof Dt.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else r.prototype.walkAtLeastOne.call(this,t,i,n)},e}(Xd);Tr.NextTerminalAfterAtLeastOneWalker=iwe;var nwe=function(r){Rc(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.walkAtLeastOneSep=function(t,i,n){if(t.idx===this.occurrence){var s=(0,Kt.first)(i.concat(n));this.result.isEndOfRule=s===void 0,s instanceof Dt.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else r.prototype.walkAtLeastOneSep.call(this,t,i,n)},e}(Xd);Tr.NextTerminalAfterAtLeastOneSepWalker=nwe;function Jq(r,e,t){t===void 0&&(t=[]),t=(0,Kt.cloneArr)(t);var i=[],n=0;function s(c){return c.concat((0,Kt.drop)(r,n+1))}function o(c){var u=Jq(s(c),e,t);return i.concat(u)}for(;t.length=0;ge--){var _=B.definition[ge],T={idx:p,def:_.definition.concat((0,Kt.drop)(h)),ruleStack:C,occurrenceStack:w};g.push(T),g.push(o)}else if(B instanceof Dt.Alternative)g.push({idx:p,def:B.definition.concat((0,Kt.drop)(h)),ruleStack:C,occurrenceStack:w});else if(B instanceof Dt.Rule)g.push(owe(B,p,C,w));else throw Error("non exhaustive match")}}return u}Tr.nextPossibleTokensAfter=swe;function owe(r,e,t,i){var n=(0,Kt.cloneArr)(t);n.push(r.name);var s=(0,Kt.cloneArr)(i);return s.push(1),{idx:e,def:r.definition,ruleStack:n,occurrenceStack:s}}});var Zd=y(_t=>{"use strict";var Vq=_t&&_t.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(_t,"__esModule",{value:!0});_t.areTokenCategoriesNotUsed=_t.isStrictPrefixOfPath=_t.containsPath=_t.getLookaheadPathsForOptionalProd=_t.getLookaheadPathsForOr=_t.lookAheadSequenceFromAlternatives=_t.buildSingleAlternativeLookaheadFunction=_t.buildAlternativesLookAheadFunc=_t.buildLookaheadFuncForOptionalProd=_t.buildLookaheadFuncForOr=_t.getProdType=_t.PROD_TYPE=void 0;var sr=Gt(),Wq=_d(),awe=Ty(),Gy=pf(),GA=Cn(),Awe=df(),li;(function(r){r[r.OPTION=0]="OPTION",r[r.REPETITION=1]="REPETITION",r[r.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",r[r.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",r[r.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",r[r.ALTERNATION=5]="ALTERNATION"})(li=_t.PROD_TYPE||(_t.PROD_TYPE={}));function lwe(r){if(r instanceof GA.Option)return li.OPTION;if(r instanceof GA.Repetition)return li.REPETITION;if(r instanceof GA.RepetitionMandatory)return li.REPETITION_MANDATORY;if(r instanceof GA.RepetitionMandatoryWithSeparator)return li.REPETITION_MANDATORY_WITH_SEPARATOR;if(r instanceof GA.RepetitionWithSeparator)return li.REPETITION_WITH_SEPARATOR;if(r instanceof GA.Alternation)return li.ALTERNATION;throw Error("non exhaustive match")}_t.getProdType=lwe;function cwe(r,e,t,i,n,s){var o=_q(r,e,t),a=Mx(o)?Gy.tokenStructuredMatcherNoCategories:Gy.tokenStructuredMatcher;return s(o,i,a,n)}_t.buildLookaheadFuncForOr=cwe;function uwe(r,e,t,i,n,s){var o=Zq(r,e,n,t),a=Mx(o)?Gy.tokenStructuredMatcherNoCategories:Gy.tokenStructuredMatcher;return s(o[0],a,i)}_t.buildLookaheadFuncForOptionalProd=uwe;function gwe(r,e,t,i){var n=r.length,s=(0,sr.every)(r,function(l){return(0,sr.every)(l,function(c){return c.length===1})});if(e)return function(l){for(var c=(0,sr.map)(l,function(D){return D.GATE}),u=0;u{"use strict";var Kx=zt&&zt.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(zt,"__esModule",{value:!0});zt.checkPrefixAlternativesAmbiguities=zt.validateSomeNonEmptyLookaheadPath=zt.validateTooManyAlts=zt.RepetionCollector=zt.validateAmbiguousAlternationAlternatives=zt.validateEmptyOrAlternative=zt.getFirstNoneTerminal=zt.validateNoLeftRecursion=zt.validateRuleIsOverridden=zt.validateRuleDoesNotAlreadyExist=zt.OccurrenceValidationCollector=zt.identifyProductionForDuplicates=zt.validateGrammar=void 0;var er=Gt(),br=Gt(),No=Hn(),Ux=zd(),mf=Zd(),Cwe=_d(),Zs=Cn(),Hx=df();function mwe(r,e,t,i,n){var s=er.map(r,function(h){return Ewe(h,i)}),o=er.map(r,function(h){return Gx(h,h,i)}),a=[],l=[],c=[];(0,br.every)(o,br.isEmpty)&&(a=(0,br.map)(r,function(h){return nJ(h,i)}),l=(0,br.map)(r,function(h){return sJ(h,e,i)}),c=AJ(r,e,i));var u=wwe(r,t,i),g=(0,br.map)(r,function(h){return aJ(h,i)}),f=(0,br.map)(r,function(h){return iJ(h,r,n,i)});return er.flatten(s.concat(c,o,a,l,u,g,f))}zt.validateGrammar=mwe;function Ewe(r,e){var t=new rJ;r.accept(t);var i=t.allProductions,n=er.groupBy(i,eJ),s=er.pick(n,function(a){return a.length>1}),o=er.map(er.values(s),function(a){var l=er.first(a),c=e.buildDuplicateFoundError(r,a),u=(0,Ux.getProductionDslName)(l),g={message:c,type:No.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:r.name,dslName:u,occurrence:l.idx},f=tJ(l);return f&&(g.parameter=f),g});return o}function eJ(r){return(0,Ux.getProductionDslName)(r)+"_#_"+r.idx+"_#_"+tJ(r)}zt.identifyProductionForDuplicates=eJ;function tJ(r){return r instanceof Zs.Terminal?r.terminalType.name:r instanceof Zs.NonTerminal?r.nonTerminalName:""}var rJ=function(r){Kx(e,r);function e(){var t=r!==null&&r.apply(this,arguments)||this;return t.allProductions=[],t}return e.prototype.visitNonTerminal=function(t){this.allProductions.push(t)},e.prototype.visitOption=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e.prototype.visitAlternation=function(t){this.allProductions.push(t)},e.prototype.visitTerminal=function(t){this.allProductions.push(t)},e}(Hx.GAstVisitor);zt.OccurrenceValidationCollector=rJ;function iJ(r,e,t,i){var n=[],s=(0,br.reduce)(e,function(a,l){return l.name===r.name?a+1:a},0);if(s>1){var o=i.buildDuplicateRuleNameError({topLevelRule:r,grammarName:t});n.push({message:o,type:No.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:r.name})}return n}zt.validateRuleDoesNotAlreadyExist=iJ;function Iwe(r,e,t){var i=[],n;return er.contains(e,r)||(n="Invalid rule override, rule: ->"+r+"<- cannot be overridden in the grammar: ->"+t+"<-as it is not defined in any of the super grammars ",i.push({message:n,type:No.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:r})),i}zt.validateRuleIsOverridden=Iwe;function Gx(r,e,t,i){i===void 0&&(i=[]);var n=[],s=$d(e.definition);if(er.isEmpty(s))return[];var o=r.name,a=er.contains(s,r);a&&n.push({message:t.buildLeftRecursionError({topLevelRule:r,leftRecursionPath:i}),type:No.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:o});var l=er.difference(s,i.concat([r])),c=er.map(l,function(u){var g=er.cloneArr(i);return g.push(u),Gx(r,u,t,g)});return n.concat(er.flatten(c))}zt.validateNoLeftRecursion=Gx;function $d(r){var e=[];if(er.isEmpty(r))return e;var t=er.first(r);if(t instanceof Zs.NonTerminal)e.push(t.referencedRule);else if(t instanceof Zs.Alternative||t instanceof Zs.Option||t instanceof Zs.RepetitionMandatory||t instanceof Zs.RepetitionMandatoryWithSeparator||t instanceof Zs.RepetitionWithSeparator||t instanceof Zs.Repetition)e=e.concat($d(t.definition));else if(t instanceof Zs.Alternation)e=er.flatten(er.map(t.definition,function(o){return $d(o.definition)}));else if(!(t instanceof Zs.Terminal))throw Error("non exhaustive match");var i=(0,Ux.isOptionalProd)(t),n=r.length>1;if(i&&n){var s=er.drop(r);return e.concat($d(s))}else return e}zt.getFirstNoneTerminal=$d;var Yx=function(r){Kx(e,r);function e(){var t=r!==null&&r.apply(this,arguments)||this;return t.alternations=[],t}return e.prototype.visitAlternation=function(t){this.alternations.push(t)},e}(Hx.GAstVisitor);function nJ(r,e){var t=new Yx;r.accept(t);var i=t.alternations,n=er.reduce(i,function(s,o){var a=er.dropRight(o.definition),l=er.map(a,function(c,u){var g=(0,Cwe.nextPossibleTokensAfter)([c],[],null,1);return er.isEmpty(g)?{message:e.buildEmptyAlternationError({topLevelRule:r,alternation:o,emptyChoiceIdx:u}),type:No.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:r.name,occurrence:o.idx,alternative:u+1}:null});return s.concat(er.compact(l))},[]);return n}zt.validateEmptyOrAlternative=nJ;function sJ(r,e,t){var i=new Yx;r.accept(i);var n=i.alternations;n=(0,br.reject)(n,function(o){return o.ignoreAmbiguities===!0});var s=er.reduce(n,function(o,a){var l=a.idx,c=a.maxLookahead||e,u=(0,mf.getLookaheadPathsForOr)(l,r,c,a),g=ywe(u,a,r,t),f=lJ(u,a,r,t);return o.concat(g,f)},[]);return s}zt.validateAmbiguousAlternationAlternatives=sJ;var oJ=function(r){Kx(e,r);function e(){var t=r!==null&&r.apply(this,arguments)||this;return t.allProductions=[],t}return e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e}(Hx.GAstVisitor);zt.RepetionCollector=oJ;function aJ(r,e){var t=new Yx;r.accept(t);var i=t.alternations,n=er.reduce(i,function(s,o){return o.definition.length>255&&s.push({message:e.buildTooManyAlternativesError({topLevelRule:r,alternation:o}),type:No.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:r.name,occurrence:o.idx}),s},[]);return n}zt.validateTooManyAlts=aJ;function AJ(r,e,t){var i=[];return(0,br.forEach)(r,function(n){var s=new oJ;n.accept(s);var o=s.allProductions;(0,br.forEach)(o,function(a){var l=(0,mf.getProdType)(a),c=a.maxLookahead||e,u=a.idx,g=(0,mf.getLookaheadPathsForOptionalProd)(u,n,l,c),f=g[0];if((0,br.isEmpty)((0,br.flatten)(f))){var h=t.buildEmptyRepetitionError({topLevelRule:n,repetition:a});i.push({message:h,type:No.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:n.name})}})}),i}zt.validateSomeNonEmptyLookaheadPath=AJ;function ywe(r,e,t,i){var n=[],s=(0,br.reduce)(r,function(a,l,c){return e.definition[c].ignoreAmbiguities===!0||(0,br.forEach)(l,function(u){var g=[c];(0,br.forEach)(r,function(f,h){c!==h&&(0,mf.containsPath)(f,u)&&e.definition[h].ignoreAmbiguities!==!0&&g.push(h)}),g.length>1&&!(0,mf.containsPath)(n,u)&&(n.push(u),a.push({alts:g,path:u}))}),a},[]),o=er.map(s,function(a){var l=(0,br.map)(a.alts,function(u){return u+1}),c=i.buildAlternationAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:l,prefixPath:a.path});return{message:c,type:No.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:t.name,occurrence:e.idx,alternatives:[a.alts]}});return o}function lJ(r,e,t,i){var n=[],s=(0,br.reduce)(r,function(o,a,l){var c=(0,br.map)(a,function(u){return{idx:l,path:u}});return o.concat(c)},[]);return(0,br.forEach)(s,function(o){var a=e.definition[o.idx];if(a.ignoreAmbiguities!==!0){var l=o.idx,c=o.path,u=(0,br.findAll)(s,function(f){return e.definition[f.idx].ignoreAmbiguities!==!0&&f.idx{"use strict";Object.defineProperty(Ef,"__esModule",{value:!0});Ef.validateGrammar=Ef.resolveGrammar=void 0;var qx=Gt(),Bwe=Yq(),Qwe=jx(),cJ=Vd();function bwe(r){r=(0,qx.defaults)(r,{errMsgProvider:cJ.defaultGrammarResolverErrorProvider});var e={};return(0,qx.forEach)(r.rules,function(t){e[t.name]=t}),(0,Bwe.resolveGrammar)(e,r.errMsgProvider)}Ef.resolveGrammar=bwe;function Swe(r){return r=(0,qx.defaults)(r,{errMsgProvider:cJ.defaultGrammarValidatorErrorProvider}),(0,Qwe.validateGrammar)(r.rules,r.maxLookahead,r.tokenTypes,r.errMsgProvider,r.grammarName)}Ef.validateGrammar=Swe});var If=y(En=>{"use strict";var eC=En&&En.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(En,"__esModule",{value:!0});En.EarlyExitException=En.NotAllInputParsedException=En.NoViableAltException=En.MismatchedTokenException=En.isRecognitionException=void 0;var vwe=Gt(),gJ="MismatchedTokenException",fJ="NoViableAltException",hJ="EarlyExitException",pJ="NotAllInputParsedException",dJ=[gJ,fJ,hJ,pJ];Object.freeze(dJ);function xwe(r){return(0,vwe.contains)(dJ,r.name)}En.isRecognitionException=xwe;var Yy=function(r){eC(e,r);function e(t,i){var n=this.constructor,s=r.call(this,t)||this;return s.token=i,s.resyncedTokens=[],Object.setPrototypeOf(s,n.prototype),Error.captureStackTrace&&Error.captureStackTrace(s,s.constructor),s}return e}(Error),Pwe=function(r){eC(e,r);function e(t,i,n){var s=r.call(this,t,i)||this;return s.previousToken=n,s.name=gJ,s}return e}(Yy);En.MismatchedTokenException=Pwe;var Dwe=function(r){eC(e,r);function e(t,i,n){var s=r.call(this,t,i)||this;return s.previousToken=n,s.name=fJ,s}return e}(Yy);En.NoViableAltException=Dwe;var kwe=function(r){eC(e,r);function e(t,i){var n=r.call(this,t,i)||this;return n.name=pJ,n}return e}(Yy);En.NotAllInputParsedException=kwe;var Rwe=function(r){eC(e,r);function e(t,i,n){var s=r.call(this,t,i)||this;return s.previousToken=n,s.name=hJ,s}return e}(Yy);En.EarlyExitException=Rwe});var Wx=y(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.attemptInRepetitionRecovery=Ui.Recoverable=Ui.InRuleRecoveryException=Ui.IN_RULE_RECOVERY_EXCEPTION=Ui.EOF_FOLLOW_KEY=void 0;var jy=UA(),cs=Gt(),Fwe=If(),Nwe=Nx(),Lwe=Hn();Ui.EOF_FOLLOW_KEY={};Ui.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function Jx(r){this.name=Ui.IN_RULE_RECOVERY_EXCEPTION,this.message=r}Ui.InRuleRecoveryException=Jx;Jx.prototype=Error.prototype;var Twe=function(){function r(){}return r.prototype.initRecoverable=function(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=(0,cs.has)(e,"recoveryEnabled")?e.recoveryEnabled:Lwe.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=CJ)},r.prototype.getTokenToInsert=function(e){var t=(0,jy.createTokenInstance)(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t},r.prototype.canTokenTypeBeInsertedInRecovery=function(e){return!0},r.prototype.tryInRepetitionRecovery=function(e,t,i,n){for(var s=this,o=this.findReSyncTokenType(),a=this.exportLexerState(),l=[],c=!1,u=this.LA(1),g=this.LA(1),f=function(){var h=s.LA(0),p=s.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:u,previous:h,ruleName:s.getCurrRuleFullName()}),C=new Fwe.MismatchedTokenException(p,u,s.LA(0));C.resyncedTokens=(0,cs.dropRight)(l),s.SAVE_ERROR(C)};!c;)if(this.tokenMatcher(g,n)){f();return}else if(i.call(this)){f(),e.apply(this,t);return}else this.tokenMatcher(g,o)?c=!0:(g=this.SKIP_TOKEN(),this.addToResyncTokens(g,l));this.importLexerState(a)},r.prototype.shouldInRepetitionRecoveryBeTried=function(e,t,i){return!(i===!1||e===void 0||t===void 0||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))},r.prototype.getFollowsForInRuleRecovery=function(e,t){var i=this.getCurrentGrammarPath(e,t),n=this.getNextPossibleTokenTypes(i);return n},r.prototype.tryInRuleRecovery=function(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t)){var i=this.getTokenToInsert(e);return i}if(this.canRecoverWithSingleTokenDeletion(e)){var n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Jx("sad sad panda")},r.prototype.canPerformInRuleRecovery=function(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)},r.prototype.canRecoverWithSingleTokenInsertion=function(e,t){var i=this;if(!this.canTokenTypeBeInsertedInRecovery(e)||(0,cs.isEmpty)(t))return!1;var n=this.LA(1),s=(0,cs.find)(t,function(o){return i.tokenMatcher(n,o)})!==void 0;return s},r.prototype.canRecoverWithSingleTokenDeletion=function(e){var t=this.tokenMatcher(this.LA(2),e);return t},r.prototype.isInCurrentRuleReSyncSet=function(e){var t=this.getCurrFollowKey(),i=this.getFollowSetFromFollowKey(t);return(0,cs.contains)(i,e)},r.prototype.findReSyncTokenType=function(){for(var e=this.flattenFollowSet(),t=this.LA(1),i=2;;){var n=t.tokenType;if((0,cs.contains)(e,n))return n;t=this.LA(i),i++}},r.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return Ui.EOF_FOLLOW_KEY;var e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(i)}},r.prototype.buildFullFollowKeyStack=function(){var e=this,t=this.RULE_STACK,i=this.RULE_OCCURRENCE_STACK;return(0,cs.map)(t,function(n,s){return s===0?Ui.EOF_FOLLOW_KEY:{ruleName:e.shortRuleNameToFullName(n),idxInCallingRule:i[s],inRule:e.shortRuleNameToFullName(t[s-1])}})},r.prototype.flattenFollowSet=function(){var e=this,t=(0,cs.map)(this.buildFullFollowKeyStack(),function(i){return e.getFollowSetFromFollowKey(i)});return(0,cs.flatten)(t)},r.prototype.getFollowSetFromFollowKey=function(e){if(e===Ui.EOF_FOLLOW_KEY)return[jy.EOF];var t=e.ruleName+e.idxInCallingRule+Nwe.IN+e.inRule;return this.resyncFollows[t]},r.prototype.addToResyncTokens=function(e,t){return this.tokenMatcher(e,jy.EOF)||t.push(e),t},r.prototype.reSyncTo=function(e){for(var t=[],i=this.LA(1);this.tokenMatcher(i,e)===!1;)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,t);return(0,cs.dropRight)(t)},r.prototype.attemptInRepetitionRecovery=function(e,t,i,n,s,o,a){},r.prototype.getCurrentGrammarPath=function(e,t){var i=this.getHumanReadableRuleStack(),n=(0,cs.cloneArr)(this.RULE_OCCURRENCE_STACK),s={ruleStack:i,occurrenceStack:n,lastTok:e,lastTokOccurrence:t};return s},r.prototype.getHumanReadableRuleStack=function(){var e=this;return(0,cs.map)(this.RULE_STACK,function(t){return e.shortRuleNameToFullName(t)})},r}();Ui.Recoverable=Twe;function CJ(r,e,t,i,n,s,o){var a=this.getKeyForAutomaticLookahead(i,n),l=this.firstAfterRepMap[a];if(l===void 0){var c=this.getCurrRuleFullName(),u=this.getGAstProductions()[c],g=new s(u,n);l=g.startWalking(),this.firstAfterRepMap[a]=l}var f=l.token,h=l.occurrence,p=l.isEndOfRule;this.RULE_STACK.length===1&&p&&f===void 0&&(f=jy.EOF,h=1),this.shouldInRepetitionRecoveryBeTried(f,h,o)&&this.tryInRepetitionRecovery(r,e,t,f)}Ui.attemptInRepetitionRecovery=CJ});var qy=y(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.getKeyForAutomaticLookahead=qt.AT_LEAST_ONE_SEP_IDX=qt.MANY_SEP_IDX=qt.AT_LEAST_ONE_IDX=qt.MANY_IDX=qt.OPTION_IDX=qt.OR_IDX=qt.BITS_FOR_ALT_IDX=qt.BITS_FOR_RULE_IDX=qt.BITS_FOR_OCCURRENCE_IDX=qt.BITS_FOR_METHOD_TYPE=void 0;qt.BITS_FOR_METHOD_TYPE=4;qt.BITS_FOR_OCCURRENCE_IDX=8;qt.BITS_FOR_RULE_IDX=12;qt.BITS_FOR_ALT_IDX=8;qt.OR_IDX=1<{"use strict";Object.defineProperty(Jy,"__esModule",{value:!0});Jy.LooksAhead=void 0;var Ra=Zd(),$s=Gt(),mJ=Hn(),Fa=qy(),Fc=zd(),Mwe=function(){function r(){}return r.prototype.initLooksAhead=function(e){this.dynamicTokensEnabled=(0,$s.has)(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:mJ.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=(0,$s.has)(e,"maxLookahead")?e.maxLookahead:mJ.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=(0,$s.isES2015MapSupported)()?new Map:[],(0,$s.isES2015MapSupported)()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},r.prototype.preComputeLookaheadFunctions=function(e){var t=this;(0,$s.forEach)(e,function(i){t.TRACE_INIT(i.name+" Rule Lookahead",function(){var n=(0,Fc.collectMethods)(i),s=n.alternation,o=n.repetition,a=n.option,l=n.repetitionMandatory,c=n.repetitionMandatoryWithSeparator,u=n.repetitionWithSeparator;(0,$s.forEach)(s,function(g){var f=g.idx===0?"":g.idx;t.TRACE_INIT(""+(0,Fc.getProductionDslName)(g)+f,function(){var h=(0,Ra.buildLookaheadFuncForOr)(g.idx,i,g.maxLookahead||t.maxLookahead,g.hasPredicates,t.dynamicTokensEnabled,t.lookAheadBuilderForAlternatives),p=(0,Fa.getKeyForAutomaticLookahead)(t.fullRuleNameToShort[i.name],Fa.OR_IDX,g.idx);t.setLaFuncCache(p,h)})}),(0,$s.forEach)(o,function(g){t.computeLookaheadFunc(i,g.idx,Fa.MANY_IDX,Ra.PROD_TYPE.REPETITION,g.maxLookahead,(0,Fc.getProductionDslName)(g))}),(0,$s.forEach)(a,function(g){t.computeLookaheadFunc(i,g.idx,Fa.OPTION_IDX,Ra.PROD_TYPE.OPTION,g.maxLookahead,(0,Fc.getProductionDslName)(g))}),(0,$s.forEach)(l,function(g){t.computeLookaheadFunc(i,g.idx,Fa.AT_LEAST_ONE_IDX,Ra.PROD_TYPE.REPETITION_MANDATORY,g.maxLookahead,(0,Fc.getProductionDslName)(g))}),(0,$s.forEach)(c,function(g){t.computeLookaheadFunc(i,g.idx,Fa.AT_LEAST_ONE_SEP_IDX,Ra.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.maxLookahead,(0,Fc.getProductionDslName)(g))}),(0,$s.forEach)(u,function(g){t.computeLookaheadFunc(i,g.idx,Fa.MANY_SEP_IDX,Ra.PROD_TYPE.REPETITION_WITH_SEPARATOR,g.maxLookahead,(0,Fc.getProductionDslName)(g))})})})},r.prototype.computeLookaheadFunc=function(e,t,i,n,s,o){var a=this;this.TRACE_INIT(""+o+(t===0?"":t),function(){var l=(0,Ra.buildLookaheadFuncForOptionalProd)(t,e,s||a.maxLookahead,a.dynamicTokensEnabled,n,a.lookAheadBuilderForOptional),c=(0,Fa.getKeyForAutomaticLookahead)(a.fullRuleNameToShort[e.name],i,t);a.setLaFuncCache(c,l)})},r.prototype.lookAheadBuilderForOptional=function(e,t,i){return(0,Ra.buildSingleAlternativeLookaheadFunction)(e,t,i)},r.prototype.lookAheadBuilderForAlternatives=function(e,t,i,n){return(0,Ra.buildAlternativesLookAheadFunc)(e,t,i,n)},r.prototype.getKeyForAutomaticLookahead=function(e,t){var i=this.getLastExplicitRuleShortName();return(0,Fa.getKeyForAutomaticLookahead)(i,e,t)},r.prototype.getLaFuncFromCache=function(e){},r.prototype.getLaFuncFromMap=function(e){return this.lookAheadFuncsCache.get(e)},r.prototype.getLaFuncFromObj=function(e){return this.lookAheadFuncsCache[e]},r.prototype.setLaFuncCache=function(e,t){},r.prototype.setLaFuncCacheUsingMap=function(e,t){this.lookAheadFuncsCache.set(e,t)},r.prototype.setLaFuncUsingObj=function(e,t){this.lookAheadFuncsCache[e]=t},r}();Jy.LooksAhead=Mwe});var IJ=y(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.addNoneTerminalToCst=Lo.addTerminalToCst=Lo.setNodeLocationFull=Lo.setNodeLocationOnlyOffset=void 0;function Kwe(r,e){isNaN(r.startOffset)===!0?(r.startOffset=e.startOffset,r.endOffset=e.endOffset):r.endOffset{"use strict";Object.defineProperty(YA,"__esModule",{value:!0});YA.defineNameProp=YA.functionName=YA.classNameFromInstance=void 0;var Ywe=Gt();function jwe(r){return wJ(r.constructor)}YA.classNameFromInstance=jwe;var yJ="name";function wJ(r){var e=r.name;return e||"anonymous"}YA.functionName=wJ;function qwe(r,e){var t=Object.getOwnPropertyDescriptor(r,yJ);return(0,Ywe.isUndefined)(t)||t.configurable?(Object.defineProperty(r,yJ,{enumerable:!1,configurable:!0,writable:!1,value:e}),!0):!1}YA.defineNameProp=qwe});var vJ=y(vi=>{"use strict";Object.defineProperty(vi,"__esModule",{value:!0});vi.validateRedundantMethods=vi.validateMissingCstMethods=vi.validateVisitor=vi.CstVisitorDefinitionError=vi.createBaseVisitorConstructorWithDefaults=vi.createBaseSemanticVisitorConstructor=vi.defaultVisit=void 0;var us=Gt(),tC=zx();function BJ(r,e){for(var t=(0,us.keys)(r),i=t.length,n=0;n: + `+(""+s.join(` + +`).replace(/\n/g,` + `)))}}};return t.prototype=i,t.prototype.constructor=t,t._RULE_NAMES=e,t}vi.createBaseSemanticVisitorConstructor=Jwe;function Wwe(r,e,t){var i=function(){};(0,tC.defineNameProp)(i,r+"BaseSemanticsWithDefaults");var n=Object.create(t.prototype);return(0,us.forEach)(e,function(s){n[s]=BJ}),i.prototype=n,i.prototype.constructor=i,i}vi.createBaseVisitorConstructorWithDefaults=Wwe;var Vx;(function(r){r[r.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",r[r.MISSING_METHOD=1]="MISSING_METHOD"})(Vx=vi.CstVisitorDefinitionError||(vi.CstVisitorDefinitionError={}));function QJ(r,e){var t=bJ(r,e),i=SJ(r,e);return t.concat(i)}vi.validateVisitor=QJ;function bJ(r,e){var t=(0,us.map)(e,function(i){if(!(0,us.isFunction)(r[i]))return{msg:"Missing visitor method: <"+i+"> on "+(0,tC.functionName)(r.constructor)+" CST Visitor.",type:Vx.MISSING_METHOD,methodName:i}});return(0,us.compact)(t)}vi.validateMissingCstMethods=bJ;var zwe=["constructor","visit","validateVisitor"];function SJ(r,e){var t=[];for(var i in r)(0,us.isFunction)(r[i])&&!(0,us.contains)(zwe,i)&&!(0,us.contains)(e,i)&&t.push({msg:"Redundant visitor method: <"+i+"> on "+(0,tC.functionName)(r.constructor)+` CST Visitor +There is no Grammar Rule corresponding to this method's name. +`,type:Vx.REDUNDANT_METHOD,methodName:i});return t}vi.validateRedundantMethods=SJ});var PJ=y(Wy=>{"use strict";Object.defineProperty(Wy,"__esModule",{value:!0});Wy.TreeBuilder=void 0;var yf=IJ(),ti=Gt(),xJ=vJ(),Vwe=Hn(),Xwe=function(){function r(){}return r.prototype.initTreeBuilder=function(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=(0,ti.has)(e,"nodeLocationTracking")?e.nodeLocationTracking:Vwe.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=ti.NOOP,this.cstFinallyStateUpdate=ti.NOOP,this.cstPostTerminal=ti.NOOP,this.cstPostNonTerminal=ti.NOOP,this.cstPostRule=ti.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=yf.setNodeLocationFull,this.setNodeLocationFromNode=yf.setNodeLocationFull,this.cstPostRule=ti.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ti.NOOP,this.setNodeLocationFromNode=ti.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=yf.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=yf.setNodeLocationOnlyOffset,this.cstPostRule=ti.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ti.NOOP,this.setNodeLocationFromNode=ti.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=ti.NOOP,this.setNodeLocationFromNode=ti.NOOP,this.cstPostRule=ti.NOOP,this.setInitialNodeLocation=ti.NOOP;else throw Error('Invalid config option: "'+e.nodeLocationTracking+'"')},r.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(e){e.location={startOffset:NaN,endOffset:NaN}},r.prototype.setInitialNodeLocationOnlyOffsetRegular=function(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},r.prototype.setInitialNodeLocationFullRecovery=function(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},r.prototype.setInitialNodeLocationFullRegular=function(e){var t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},r.prototype.cstInvocationStateUpdate=function(e,t){var i={name:e,children:{}};this.setInitialNodeLocation(i),this.CST_STACK.push(i)},r.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},r.prototype.cstPostRuleFull=function(e){var t=this.LA(0),i=e.location;i.startOffset<=t.startOffset?(i.endOffset=t.endOffset,i.endLine=t.endLine,i.endColumn=t.endColumn):(i.startOffset=NaN,i.startLine=NaN,i.startColumn=NaN)},r.prototype.cstPostRuleOnlyOffset=function(e){var t=this.LA(0),i=e.location;i.startOffset<=t.startOffset?i.endOffset=t.endOffset:i.startOffset=NaN},r.prototype.cstPostTerminal=function(e,t){var i=this.CST_STACK[this.CST_STACK.length-1];(0,yf.addTerminalToCst)(i,t,e),this.setNodeLocationFromToken(i.location,t)},r.prototype.cstPostNonTerminal=function(e,t){var i=this.CST_STACK[this.CST_STACK.length-1];(0,yf.addNoneTerminalToCst)(i,t,e),this.setNodeLocationFromNode(i.location,e.location)},r.prototype.getBaseCstVisitorConstructor=function(){if((0,ti.isUndefined)(this.baseCstVisitorConstructor)){var e=(0,xJ.createBaseSemanticVisitorConstructor)(this.className,(0,ti.keys)(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor},r.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if((0,ti.isUndefined)(this.baseCstVisitorWithDefaultsConstructor)){var e=(0,xJ.createBaseVisitorConstructorWithDefaults)(this.className,(0,ti.keys)(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor},r.prototype.getLastExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-1]},r.prototype.getPreviousExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-2]},r.prototype.getLastExplicitRuleOccurrenceIndex=function(){var e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]},r}();Wy.TreeBuilder=Xwe});var kJ=y(zy=>{"use strict";Object.defineProperty(zy,"__esModule",{value:!0});zy.LexerAdapter=void 0;var DJ=Hn(),_we=function(){function r(){}return r.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(r.prototype,"input",{get:function(){return this.tokVector},set:function(e){if(this.selfAnalysisDone!==!0)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length},enumerable:!1,configurable:!0}),r.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):DJ.END_OF_FILE},r.prototype.LA=function(e){var t=this.currIdx+e;return t<0||this.tokVectorLength<=t?DJ.END_OF_FILE:this.tokVector[t]},r.prototype.consumeToken=function(){this.currIdx++},r.prototype.exportLexerState=function(){return this.currIdx},r.prototype.importLexerState=function(e){this.currIdx=e},r.prototype.resetLexerState=function(){this.currIdx=-1},r.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},r.prototype.getLexerPosition=function(){return this.exportLexerState()},r}();zy.LexerAdapter=_we});var FJ=y(Vy=>{"use strict";Object.defineProperty(Vy,"__esModule",{value:!0});Vy.RecognizerApi=void 0;var RJ=Gt(),Zwe=If(),Xx=Hn(),$we=Vd(),eBe=jx(),tBe=Cn(),rBe=function(){function r(){}return r.prototype.ACTION=function(e){return e.call(this)},r.prototype.consume=function(e,t,i){return this.consumeInternal(t,e,i)},r.prototype.subrule=function(e,t,i){return this.subruleInternal(t,e,i)},r.prototype.option=function(e,t){return this.optionInternal(t,e)},r.prototype.or=function(e,t){return this.orInternal(t,e)},r.prototype.many=function(e,t){return this.manyInternal(e,t)},r.prototype.atLeastOne=function(e,t){return this.atLeastOneInternal(e,t)},r.prototype.CONSUME=function(e,t){return this.consumeInternal(e,0,t)},r.prototype.CONSUME1=function(e,t){return this.consumeInternal(e,1,t)},r.prototype.CONSUME2=function(e,t){return this.consumeInternal(e,2,t)},r.prototype.CONSUME3=function(e,t){return this.consumeInternal(e,3,t)},r.prototype.CONSUME4=function(e,t){return this.consumeInternal(e,4,t)},r.prototype.CONSUME5=function(e,t){return this.consumeInternal(e,5,t)},r.prototype.CONSUME6=function(e,t){return this.consumeInternal(e,6,t)},r.prototype.CONSUME7=function(e,t){return this.consumeInternal(e,7,t)},r.prototype.CONSUME8=function(e,t){return this.consumeInternal(e,8,t)},r.prototype.CONSUME9=function(e,t){return this.consumeInternal(e,9,t)},r.prototype.SUBRULE=function(e,t){return this.subruleInternal(e,0,t)},r.prototype.SUBRULE1=function(e,t){return this.subruleInternal(e,1,t)},r.prototype.SUBRULE2=function(e,t){return this.subruleInternal(e,2,t)},r.prototype.SUBRULE3=function(e,t){return this.subruleInternal(e,3,t)},r.prototype.SUBRULE4=function(e,t){return this.subruleInternal(e,4,t)},r.prototype.SUBRULE5=function(e,t){return this.subruleInternal(e,5,t)},r.prototype.SUBRULE6=function(e,t){return this.subruleInternal(e,6,t)},r.prototype.SUBRULE7=function(e,t){return this.subruleInternal(e,7,t)},r.prototype.SUBRULE8=function(e,t){return this.subruleInternal(e,8,t)},r.prototype.SUBRULE9=function(e,t){return this.subruleInternal(e,9,t)},r.prototype.OPTION=function(e){return this.optionInternal(e,0)},r.prototype.OPTION1=function(e){return this.optionInternal(e,1)},r.prototype.OPTION2=function(e){return this.optionInternal(e,2)},r.prototype.OPTION3=function(e){return this.optionInternal(e,3)},r.prototype.OPTION4=function(e){return this.optionInternal(e,4)},r.prototype.OPTION5=function(e){return this.optionInternal(e,5)},r.prototype.OPTION6=function(e){return this.optionInternal(e,6)},r.prototype.OPTION7=function(e){return this.optionInternal(e,7)},r.prototype.OPTION8=function(e){return this.optionInternal(e,8)},r.prototype.OPTION9=function(e){return this.optionInternal(e,9)},r.prototype.OR=function(e){return this.orInternal(e,0)},r.prototype.OR1=function(e){return this.orInternal(e,1)},r.prototype.OR2=function(e){return this.orInternal(e,2)},r.prototype.OR3=function(e){return this.orInternal(e,3)},r.prototype.OR4=function(e){return this.orInternal(e,4)},r.prototype.OR5=function(e){return this.orInternal(e,5)},r.prototype.OR6=function(e){return this.orInternal(e,6)},r.prototype.OR7=function(e){return this.orInternal(e,7)},r.prototype.OR8=function(e){return this.orInternal(e,8)},r.prototype.OR9=function(e){return this.orInternal(e,9)},r.prototype.MANY=function(e){this.manyInternal(0,e)},r.prototype.MANY1=function(e){this.manyInternal(1,e)},r.prototype.MANY2=function(e){this.manyInternal(2,e)},r.prototype.MANY3=function(e){this.manyInternal(3,e)},r.prototype.MANY4=function(e){this.manyInternal(4,e)},r.prototype.MANY5=function(e){this.manyInternal(5,e)},r.prototype.MANY6=function(e){this.manyInternal(6,e)},r.prototype.MANY7=function(e){this.manyInternal(7,e)},r.prototype.MANY8=function(e){this.manyInternal(8,e)},r.prototype.MANY9=function(e){this.manyInternal(9,e)},r.prototype.MANY_SEP=function(e){this.manySepFirstInternal(0,e)},r.prototype.MANY_SEP1=function(e){this.manySepFirstInternal(1,e)},r.prototype.MANY_SEP2=function(e){this.manySepFirstInternal(2,e)},r.prototype.MANY_SEP3=function(e){this.manySepFirstInternal(3,e)},r.prototype.MANY_SEP4=function(e){this.manySepFirstInternal(4,e)},r.prototype.MANY_SEP5=function(e){this.manySepFirstInternal(5,e)},r.prototype.MANY_SEP6=function(e){this.manySepFirstInternal(6,e)},r.prototype.MANY_SEP7=function(e){this.manySepFirstInternal(7,e)},r.prototype.MANY_SEP8=function(e){this.manySepFirstInternal(8,e)},r.prototype.MANY_SEP9=function(e){this.manySepFirstInternal(9,e)},r.prototype.AT_LEAST_ONE=function(e){this.atLeastOneInternal(0,e)},r.prototype.AT_LEAST_ONE1=function(e){return this.atLeastOneInternal(1,e)},r.prototype.AT_LEAST_ONE2=function(e){this.atLeastOneInternal(2,e)},r.prototype.AT_LEAST_ONE3=function(e){this.atLeastOneInternal(3,e)},r.prototype.AT_LEAST_ONE4=function(e){this.atLeastOneInternal(4,e)},r.prototype.AT_LEAST_ONE5=function(e){this.atLeastOneInternal(5,e)},r.prototype.AT_LEAST_ONE6=function(e){this.atLeastOneInternal(6,e)},r.prototype.AT_LEAST_ONE7=function(e){this.atLeastOneInternal(7,e)},r.prototype.AT_LEAST_ONE8=function(e){this.atLeastOneInternal(8,e)},r.prototype.AT_LEAST_ONE9=function(e){this.atLeastOneInternal(9,e)},r.prototype.AT_LEAST_ONE_SEP=function(e){this.atLeastOneSepFirstInternal(0,e)},r.prototype.AT_LEAST_ONE_SEP1=function(e){this.atLeastOneSepFirstInternal(1,e)},r.prototype.AT_LEAST_ONE_SEP2=function(e){this.atLeastOneSepFirstInternal(2,e)},r.prototype.AT_LEAST_ONE_SEP3=function(e){this.atLeastOneSepFirstInternal(3,e)},r.prototype.AT_LEAST_ONE_SEP4=function(e){this.atLeastOneSepFirstInternal(4,e)},r.prototype.AT_LEAST_ONE_SEP5=function(e){this.atLeastOneSepFirstInternal(5,e)},r.prototype.AT_LEAST_ONE_SEP6=function(e){this.atLeastOneSepFirstInternal(6,e)},r.prototype.AT_LEAST_ONE_SEP7=function(e){this.atLeastOneSepFirstInternal(7,e)},r.prototype.AT_LEAST_ONE_SEP8=function(e){this.atLeastOneSepFirstInternal(8,e)},r.prototype.AT_LEAST_ONE_SEP9=function(e){this.atLeastOneSepFirstInternal(9,e)},r.prototype.RULE=function(e,t,i){if(i===void 0&&(i=Xx.DEFAULT_RULE_CONFIG),(0,RJ.contains)(this.definedRulesNames,e)){var n=$we.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),s={message:n,type:Xx.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);var o=this.defineRule(e,t,i);return this[e]=o,o},r.prototype.OVERRIDE_RULE=function(e,t,i){i===void 0&&(i=Xx.DEFAULT_RULE_CONFIG);var n=[];n=n.concat((0,eBe.validateRuleIsOverridden)(e,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(n);var s=this.defineRule(e,t,i);return this[e]=s,s},r.prototype.BACKTRACK=function(e,t){return function(){this.isBackTrackingStack.push(1);var i=this.saveRecogState();try{return e.apply(this,t),!0}catch(n){if((0,Zwe.isRecognitionException)(n))return!1;throw n}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}},r.prototype.getGAstProductions=function(){return this.gastProductionsCache},r.prototype.getSerializedGastProductions=function(){return(0,tBe.serializeGrammar)((0,RJ.values)(this.gastProductionsCache))},r}();Vy.RecognizerApi=rBe});var OJ=y(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.RecognizerEngine=void 0;var Dr=Gt(),Gn=qy(),Xy=If(),NJ=Zd(),wf=_d(),LJ=Hn(),iBe=Wx(),TJ=UA(),rC=pf(),nBe=zx(),sBe=function(){function r(){}return r.prototype.initRecognizerEngine=function(e,t){if(this.className=(0,nBe.classNameFromInstance)(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=rC.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},(0,Dr.has)(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0 + For Further details.`);if((0,Dr.isArray)(e)){if((0,Dr.isEmpty)(e))throw Error(`A Token Vocabulary cannot be empty. + Note that the first argument for the parser constructor + is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0 + For Further details.`)}if((0,Dr.isArray)(e))this.tokensMap=(0,Dr.reduce)(e,function(o,a){return o[a.name]=a,o},{});else if((0,Dr.has)(e,"modes")&&(0,Dr.every)((0,Dr.flatten)((0,Dr.values)(e.modes)),rC.isTokenType)){var i=(0,Dr.flatten)((0,Dr.values)(e.modes)),n=(0,Dr.uniq)(i);this.tokensMap=(0,Dr.reduce)(n,function(o,a){return o[a.name]=a,o},{})}else if((0,Dr.isObject)(e))this.tokensMap=(0,Dr.cloneObj)(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=TJ.EOF;var s=(0,Dr.every)((0,Dr.values)(e),function(o){return(0,Dr.isEmpty)(o.categoryMatches)});this.tokenMatcher=s?rC.tokenStructuredMatcherNoCategories:rC.tokenStructuredMatcher,(0,rC.augmentTokenTypes)((0,Dr.values)(this.tokensMap))},r.prototype.defineRule=function(e,t,i){if(this.selfAnalysisDone)throw Error("Grammar rule <"+e+`> may not be defined after the 'performSelfAnalysis' method has been called' +Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var n=(0,Dr.has)(i,"resyncEnabled")?i.resyncEnabled:LJ.DEFAULT_RULE_CONFIG.resyncEnabled,s=(0,Dr.has)(i,"recoveryValueFunc")?i.recoveryValueFunc:LJ.DEFAULT_RULE_CONFIG.recoveryValueFunc,o=this.ruleShortNameIdx<t},r.prototype.orInternal=function(e,t){var i=this.getKeyForAutomaticLookahead(Gn.OR_IDX,t),n=(0,Dr.isArray)(e)?e:e.DEF,s=this.getLaFuncFromCache(i),o=s.call(this,n);if(o!==void 0){var a=n[o];return a.ALT.call(this)}this.raiseNoAltException(t,e.ERR_MSG)},r.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Xy.NotAllInputParsedException(t,e))}},r.prototype.subruleInternal=function(e,t,i){var n;try{var s=i!==void 0?i.ARGS:void 0;return n=e.call(this,t,s),this.cstPostNonTerminal(n,i!==void 0&&i.LABEL!==void 0?i.LABEL:e.ruleName),n}catch(o){this.subruleInternalError(o,i,e.ruleName)}},r.prototype.subruleInternalError=function(e,t,i){throw(0,Xy.isRecognitionException)(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:i),delete e.partialCstResult),e},r.prototype.consumeInternal=function(e,t,i){var n;try{var s=this.LA(1);this.tokenMatcher(s,e)===!0?(this.consumeToken(),n=s):this.consumeInternalError(e,s,i)}catch(o){n=this.consumeInternalRecovery(e,t,o)}return this.cstPostTerminal(i!==void 0&&i.LABEL!==void 0?i.LABEL:e.name,n),n},r.prototype.consumeInternalError=function(e,t,i){var n,s=this.LA(0);throw i!==void 0&&i.ERR_MSG?n=i.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:s,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Xy.MismatchedTokenException(n,t,s))},r.prototype.consumeInternalRecovery=function(e,t,i){if(this.recoveryEnabled&&i.name==="MismatchedTokenException"&&!this.isBackTracking()){var n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(s){throw s.name===iBe.IN_RULE_RECOVERY_EXCEPTION?i:s}}else throw i},r.prototype.saveRecogState=function(){var e=this.errors,t=(0,Dr.cloneArr)(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}},r.prototype.reloadRecogState=function(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK},r.prototype.ruleInvocationStateUpdate=function(e,t,i){this.RULE_OCCURRENCE_STACK.push(i),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t,e)},r.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},r.prototype.getCurrRuleFullName=function(){var e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]},r.prototype.shortRuleNameToFullName=function(e){return this.shortRuleNameToFull[e]},r.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),TJ.EOF)},r.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},r}();_y.RecognizerEngine=sBe});var KJ=y(Zy=>{"use strict";Object.defineProperty(Zy,"__esModule",{value:!0});Zy.ErrorHandler=void 0;var _x=If(),Zx=Gt(),MJ=Zd(),oBe=Hn(),aBe=function(){function r(){}return r.prototype.initErrorHandler=function(e){this._errors=[],this.errorMessageProvider=(0,Zx.has)(e,"errorMessageProvider")?e.errorMessageProvider:oBe.DEFAULT_PARSER_CONFIG.errorMessageProvider},r.prototype.SAVE_ERROR=function(e){if((0,_x.isRecognitionException)(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:(0,Zx.cloneArr)(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(r.prototype,"errors",{get:function(){return(0,Zx.cloneArr)(this._errors)},set:function(e){this._errors=e},enumerable:!1,configurable:!0}),r.prototype.raiseEarlyExitException=function(e,t,i){for(var n=this.getCurrRuleFullName(),s=this.getGAstProductions()[n],o=(0,MJ.getLookaheadPathsForOptionalProd)(e,s,t,this.maxLookahead),a=o[0],l=[],c=1;c<=this.maxLookahead;c++)l.push(this.LA(c));var u=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:l,previous:this.LA(0),customUserDescription:i,ruleName:n});throw this.SAVE_ERROR(new _x.EarlyExitException(u,this.LA(1),this.LA(0)))},r.prototype.raiseNoAltException=function(e,t){for(var i=this.getCurrRuleFullName(),n=this.getGAstProductions()[i],s=(0,MJ.getLookaheadPathsForOr)(e,n,this.maxLookahead),o=[],a=1;a<=this.maxLookahead;a++)o.push(this.LA(a));var l=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:o,previous:l,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new _x.NoViableAltException(c,this.LA(1),l))},r}();Zy.ErrorHandler=aBe});var GJ=y($y=>{"use strict";Object.defineProperty($y,"__esModule",{value:!0});$y.ContentAssist=void 0;var UJ=_d(),HJ=Gt(),ABe=function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(e,t){var i=this.gastProductionsCache[e];if((0,HJ.isUndefined)(i))throw Error("Rule ->"+e+"<- does not exist in this grammar.");return(0,UJ.nextPossibleTokensAfter)([i],t,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(e){var t=(0,HJ.first)(e.ruleStack),i=this.getGAstProductions(),n=i[t],s=new UJ.NextAfterTokenWalker(n,e).startWalking();return s},r}();$y.ContentAssist=ABe});var XJ=y(rw=>{"use strict";Object.defineProperty(rw,"__esModule",{value:!0});rw.GastRecorder=void 0;var In=Gt(),To=Cn(),lBe=jd(),JJ=pf(),WJ=UA(),cBe=Hn(),uBe=qy(),tw={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(tw);var YJ=!0,jJ=Math.pow(2,uBe.BITS_FOR_OCCURRENCE_IDX)-1,zJ=(0,WJ.createToken)({name:"RECORDING_PHASE_TOKEN",pattern:lBe.Lexer.NA});(0,JJ.augmentTokenTypes)([zJ]);var VJ=(0,WJ.createTokenInstance)(zJ,`This IToken indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(VJ);var gBe={name:`This CSTNode indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},fBe=function(){function r(){}return r.prototype.initGastRecorder=function(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1},r.prototype.enableRecording=function(){var e=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var t=function(n){var s=n>0?n:"";e["CONSUME"+s]=function(o,a){return this.consumeInternalRecord(o,n,a)},e["SUBRULE"+s]=function(o,a){return this.subruleInternalRecord(o,n,a)},e["OPTION"+s]=function(o){return this.optionInternalRecord(o,n)},e["OR"+s]=function(o){return this.orInternalRecord(o,n)},e["MANY"+s]=function(o){this.manyInternalRecord(n,o)},e["MANY_SEP"+s]=function(o){this.manySepFirstInternalRecord(n,o)},e["AT_LEAST_ONE"+s]=function(o){this.atLeastOneInternalRecord(n,o)},e["AT_LEAST_ONE_SEP"+s]=function(o){this.atLeastOneSepFirstInternalRecord(n,o)}},i=0;i<10;i++)t(i);e.consume=function(n,s,o){return this.consumeInternalRecord(s,n,o)},e.subrule=function(n,s,o){return this.subruleInternalRecord(s,n,o)},e.option=function(n,s){return this.optionInternalRecord(s,n)},e.or=function(n,s){return this.orInternalRecord(s,n)},e.many=function(n,s){this.manyInternalRecord(n,s)},e.atLeastOne=function(n,s){this.atLeastOneInternalRecord(n,s)},e.ACTION=e.ACTION_RECORD,e.BACKTRACK=e.BACKTRACK_RECORD,e.LA=e.LA_RECORD})},r.prototype.disableRecording=function(){var e=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var t=0;t<10;t++){var i=t>0?t:"";delete e["CONSUME"+i],delete e["SUBRULE"+i],delete e["OPTION"+i],delete e["OR"+i],delete e["MANY"+i],delete e["MANY_SEP"+i],delete e["AT_LEAST_ONE"+i],delete e["AT_LEAST_ONE_SEP"+i]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})},r.prototype.ACTION_RECORD=function(e){},r.prototype.BACKTRACK_RECORD=function(e,t){return function(){return!0}},r.prototype.LA_RECORD=function(e){return cBe.END_OF_FILE},r.prototype.topLevelRuleRecord=function(e,t){try{var i=new To.Rule({definition:[],name:e});return i.name=e,this.recordingProdStack.push(i),t.call(this),this.recordingProdStack.pop(),i}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+` + This error was thrown during the "grammar recording phase" For more info see: + https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}},r.prototype.optionInternalRecord=function(e,t){return iC.call(this,To.Option,e,t)},r.prototype.atLeastOneInternalRecord=function(e,t){iC.call(this,To.RepetitionMandatory,t,e)},r.prototype.atLeastOneSepFirstInternalRecord=function(e,t){iC.call(this,To.RepetitionMandatoryWithSeparator,t,e,YJ)},r.prototype.manyInternalRecord=function(e,t){iC.call(this,To.Repetition,t,e)},r.prototype.manySepFirstInternalRecord=function(e,t){iC.call(this,To.RepetitionWithSeparator,t,e,YJ)},r.prototype.orInternalRecord=function(e,t){return hBe.call(this,e,t)},r.prototype.subruleInternalRecord=function(e,t,i){if(ew(t),!e||(0,In.has)(e,"ruleName")===!1){var n=new Error(" argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(e)+">")+(` + inside top level rule: <`+this.recordingProdStack[0].name+">"));throw n.KNOWN_RECORDER_ERROR=!0,n}var s=(0,In.peek)(this.recordingProdStack),o=e.ruleName,a=new To.NonTerminal({idx:t,nonTerminalName:o,label:i==null?void 0:i.LABEL,referencedRule:void 0});return s.definition.push(a),this.outputCst?gBe:tw},r.prototype.consumeInternalRecord=function(e,t,i){if(ew(t),!(0,JJ.hasShortKeyProperty)(e)){var n=new Error(" argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(e)+">")+(` + inside top level rule: <`+this.recordingProdStack[0].name+">"));throw n.KNOWN_RECORDER_ERROR=!0,n}var s=(0,In.peek)(this.recordingProdStack),o=new To.Terminal({idx:t,terminalType:e,label:i==null?void 0:i.LABEL});return s.definition.push(o),VJ},r}();rw.GastRecorder=fBe;function iC(r,e,t,i){i===void 0&&(i=!1),ew(t);var n=(0,In.peek)(this.recordingProdStack),s=(0,In.isFunction)(e)?e:e.DEF,o=new r({definition:[],idx:t});return i&&(o.separator=e.SEP),(0,In.has)(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(o),s.call(this),n.definition.push(o),this.recordingProdStack.pop(),tw}function hBe(r,e){var t=this;ew(e);var i=(0,In.peek)(this.recordingProdStack),n=(0,In.isArray)(r)===!1,s=n===!1?r:r.DEF,o=new To.Alternation({definition:[],idx:e,ignoreAmbiguities:n&&r.IGNORE_AMBIGUITIES===!0});(0,In.has)(r,"MAX_LOOKAHEAD")&&(o.maxLookahead=r.MAX_LOOKAHEAD);var a=(0,In.some)(s,function(l){return(0,In.isFunction)(l.GATE)});return o.hasPredicates=a,i.definition.push(o),(0,In.forEach)(s,function(l){var c=new To.Alternative({definition:[]});o.definition.push(c),(0,In.has)(l,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=l.IGNORE_AMBIGUITIES:(0,In.has)(l,"GATE")&&(c.ignoreAmbiguities=!0),t.recordingProdStack.push(c),l.ALT.call(t),t.recordingProdStack.pop()}),tw}function qJ(r){return r===0?"":""+r}function ew(r){if(r<0||r>jJ){var e=new Error("Invalid DSL Method idx value: <"+r+`> + `+("Idx value must be a none negative value smaller than "+(jJ+1)));throw e.KNOWN_RECORDER_ERROR=!0,e}}});var ZJ=y(iw=>{"use strict";Object.defineProperty(iw,"__esModule",{value:!0});iw.PerformanceTracer=void 0;var _J=Gt(),pBe=Hn(),dBe=function(){function r(){}return r.prototype.initPerformanceTracer=function(e){if((0,_J.has)(e,"traceInitPerf")){var t=e.traceInitPerf,i=typeof t=="number";this.traceInitMaxIdent=i?t:1/0,this.traceInitPerf=i?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=pBe.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},r.prototype.TRACE_INIT=function(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;var i=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <"+e+">");var n=(0,_J.timer)(t),s=n.time,o=n.value,a=s>10?console.warn:console.log;return this.traceInitIndent time: "+s+"ms"),this.traceInitIndent--,o}else return t()},r}();iw.PerformanceTracer=dBe});var $J=y(nw=>{"use strict";Object.defineProperty(nw,"__esModule",{value:!0});nw.applyMixins=void 0;function CBe(r,e){e.forEach(function(t){var i=t.prototype;Object.getOwnPropertyNames(i).forEach(function(n){if(n!=="constructor"){var s=Object.getOwnPropertyDescriptor(i,n);s&&(s.get||s.set)?Object.defineProperty(r.prototype,n,s):r.prototype[n]=t.prototype[n]}})})}nw.applyMixins=CBe});var Hn=y(Cr=>{"use strict";var rW=Cr&&Cr.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}();Object.defineProperty(Cr,"__esModule",{value:!0});Cr.EmbeddedActionsParser=Cr.CstParser=Cr.Parser=Cr.EMPTY_ALT=Cr.ParserDefinitionErrorType=Cr.DEFAULT_RULE_CONFIG=Cr.DEFAULT_PARSER_CONFIG=Cr.END_OF_FILE=void 0;var _i=Gt(),mBe=Kq(),eW=UA(),iW=Vd(),tW=uJ(),EBe=Wx(),IBe=EJ(),yBe=PJ(),wBe=kJ(),BBe=FJ(),QBe=OJ(),bBe=KJ(),SBe=GJ(),vBe=XJ(),xBe=ZJ(),PBe=$J();Cr.END_OF_FILE=(0,eW.createTokenInstance)(eW.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Cr.END_OF_FILE);Cr.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:iW.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1});Cr.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var DBe;(function(r){r[r.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",r[r.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",r[r.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",r[r.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",r[r.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",r[r.LEFT_RECURSION=5]="LEFT_RECURSION",r[r.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",r[r.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",r[r.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",r[r.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",r[r.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",r[r.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",r[r.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(DBe=Cr.ParserDefinitionErrorType||(Cr.ParserDefinitionErrorType={}));function kBe(r){return r===void 0&&(r=void 0),function(){return r}}Cr.EMPTY_ALT=kBe;var sw=function(){function r(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;var i=this;if(i.initErrorHandler(t),i.initLexerAdapter(),i.initLooksAhead(t),i.initRecognizerEngine(e,t),i.initRecoverable(t),i.initTreeBuilder(t),i.initContentAssist(),i.initGastRecorder(t),i.initPerformanceTracer(t),(0,_i.has)(t,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. + Please use the flag on the relevant DSL method instead. + See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES + For further details.`);this.skipValidations=(0,_i.has)(t,"skipValidations")?t.skipValidations:Cr.DEFAULT_PARSER_CONFIG.skipValidations}return r.performSelfAnalysis=function(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},r.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",function(){var t;e.selfAnalysisDone=!0;var i=e.className;e.TRACE_INIT("toFastProps",function(){(0,_i.toFastProperties)(e)}),e.TRACE_INIT("Grammar Recording",function(){try{e.enableRecording(),(0,_i.forEach)(e.definedRulesNames,function(s){var o=e[s],a=o.originalGrammarAction,l=void 0;e.TRACE_INIT(s+" Rule",function(){l=e.topLevelRuleRecord(s,a)}),e.gastProductionsCache[s]=l})}finally{e.disableRecording()}});var n=[];if(e.TRACE_INIT("Grammar Resolving",function(){n=(0,tW.resolveGrammar)({rules:(0,_i.values)(e.gastProductionsCache)}),e.definitionErrors=e.definitionErrors.concat(n)}),e.TRACE_INIT("Grammar Validations",function(){if((0,_i.isEmpty)(n)&&e.skipValidations===!1){var s=(0,tW.validateGrammar)({rules:(0,_i.values)(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:(0,_i.values)(e.tokensMap),errMsgProvider:iW.defaultGrammarValidatorErrorProvider,grammarName:i});e.definitionErrors=e.definitionErrors.concat(s)}}),(0,_i.isEmpty)(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",function(){var s=(0,mBe.computeAllProdsFollows)((0,_i.values)(e.gastProductionsCache));e.resyncFollows=s}),e.TRACE_INIT("ComputeLookaheadFunctions",function(){e.preComputeLookaheadFunctions((0,_i.values)(e.gastProductionsCache))})),!r.DEFER_DEFINITION_ERRORS_HANDLING&&!(0,_i.isEmpty)(e.definitionErrors))throw t=(0,_i.map)(e.definitionErrors,function(s){return s.message}),new Error(`Parser Definition Errors detected: + `+t.join(` +------------------------------- +`))})},r.DEFER_DEFINITION_ERRORS_HANDLING=!1,r}();Cr.Parser=sw;(0,PBe.applyMixins)(sw,[EBe.Recoverable,IBe.LooksAhead,yBe.TreeBuilder,wBe.LexerAdapter,QBe.RecognizerEngine,BBe.RecognizerApi,bBe.ErrorHandler,SBe.ContentAssist,vBe.GastRecorder,xBe.PerformanceTracer]);var RBe=function(r){rW(e,r);function e(t,i){i===void 0&&(i=Cr.DEFAULT_PARSER_CONFIG);var n=this,s=(0,_i.cloneObj)(i);return s.outputCst=!0,n=r.call(this,t,s)||this,n}return e}(sw);Cr.CstParser=RBe;var FBe=function(r){rW(e,r);function e(t,i){i===void 0&&(i=Cr.DEFAULT_PARSER_CONFIG);var n=this,s=(0,_i.cloneObj)(i);return s.outputCst=!1,n=r.call(this,t,s)||this,n}return e}(sw);Cr.EmbeddedActionsParser=FBe});var sW=y(ow=>{"use strict";Object.defineProperty(ow,"__esModule",{value:!0});ow.createSyntaxDiagramsCode=void 0;var nW=mx();function NBe(r,e){var t=e===void 0?{}:e,i=t.resourceBase,n=i===void 0?"https://unpkg.com/chevrotain@"+nW.VERSION+"/diagrams/":i,s=t.css,o=s===void 0?"https://unpkg.com/chevrotain@"+nW.VERSION+"/diagrams/diagrams.css":s,a=` + + + + + +`,l=` + +`,c=` + + + diff --git a/packages/stablestudio-ui/package.json b/packages/stablestudio-ui/package.json new file mode 100644 index 0000000..62774ce --- /dev/null +++ b/packages/stablestudio-ui/package.json @@ -0,0 +1,97 @@ +{ + "name": "@stability/stablestudio-ui", + "version": "1.0.0", + "license": "MIT", + "type": "module", + "scripts": { + "clean": "rimraf dist && rimraf node_modules", + "lint": "eslint \"./src/**/*.{ts,tsx}\"", + "lint:fix": "yarn lint --fix", + "build:types": "tsc --noEmit", + "build": "yarn build:preview", + "build:preview": "yarn build:types && vite build --mode preview", + "build:production": "yarn build:types && vite build --mode production", + "dev:types": "tsc --noEmit --watch", + "dev": "vite" + }, + "dependencies": { + "@emotion/css": "^11.10.5", + "@emotion/react": "^11.10.5", + "@emotion/styled": "^11.10.5", + "@react-hook/resize-observer": "^1.2.6", + "@reecelucas/react-use-hotkeys": "^2.0.0", + "@stability/stablestudio-plugin": "workspace:^", + "@stability/stablestudio-plugin-example": "workspace:^", + "@stability/stablestudio-plugin-stability": "workspace:^", + "@tanstack/react-query": "^4.22.0", + "@tanstack/react-query-devtools": "^4.22.0", + "@tanstack/react-virtual": "beta", + "buffer": "^6.0.3", + "date-fns": "^2.29.3", + "file-saver": "^2.0.5", + "flexsearch": "^0.7.31", + "framer-motion": "^8.5.0", + "idb-keyval": "^6.2.0", + "immer": "^9.0.18", + "jszip": "^3.10.1", + "konva": "^8.4.2", + "lodash.throttle": "^4.1.1", + "lucide-react": "^0.105.0", + "minisearch": "^6.0.0", + "notistack": "^3.0.0-alpha.11", + "query-string": "^8.1.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-konva": "^18.2.3", + "react-konva-utils": "^0.3.1", + "react-markdown": "^8.0.7", + "react-router-dom": "^6.7.0", + "react-slider": "^2.0.4", + "react-syntax-highlighter": "^15.5.0", + "react-use": "^17.4.0", + "react-virtualized-auto-sizer": "^1.0.7", + "react-window": "^1.8.8", + "remark-custom-heading-id": "^1.0.0", + "remark-gfm": "^3.0.1", + "tailwind-merge": "^1.8.1", + "throttled-queue": "^2.1.4", + "tiny-invariant": "^1.3.1", + "ts-custom-error": "^3.3.1", + "unified": "^10.1.2", + "zundo": "beta", + "zustand": "^4.3.2" + }, + "devDependencies": { + "@tailwindcss/typography": "^0.5.9", + "@types/file-saver": "^2.0.5", + "@types/lodash.throttle": "^4.1.7", + "@types/react": "^18.0.27", + "@types/react-dom": "^18.0.10", + "@types/react-slider": "^1.3.1", + "@types/react-syntax-highlighter": "^15.5.6", + "@types/react-virtualized-auto-sizer": "^1.0.1", + "@types/react-window": "^1.8.5", + "@typescript-eslint/eslint-plugin": "^5.48.2", + "@typescript-eslint/parser": "^5.48.2", + "@vitejs/plugin-react": "^3.0.1", + "autoprefixer": "^10.4.13", + "eslint": "8.32.0", + "eslint-config-prettier": "^8.6.0", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-markdown": "^3.0.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-react": "^7.32.1", + "eslint-plugin-react-hooks": "^4.6.0", + "postcss": "^8.4.21", + "prettier": "^2.8.3", + "prettier-plugin-tailwindcss": "^0.2.1", + "rimraf": "^4.1.1", + "rollup-plugin-visualizer": "^5.9.0", + "tailwindcss": "^3.2.4", + "tsx": "^3.12.2", + "typescript": "4.9.4", + "typescript-styled-plugin": "^0.18.2", + "vite": "^4.0.4", + "vite-tsconfig-paths": "^4.0.5" + } +} diff --git a/packages/stablestudio-ui/postcss.config.cjs b/packages/stablestudio-ui/postcss.config.cjs new file mode 100644 index 0000000..ccb4ee5 --- /dev/null +++ b/packages/stablestudio-ui/postcss.config.cjs @@ -0,0 +1,9 @@ +// This project includes code from `caniuse-lite` by Ben Briggs, available under a CC BY 4.0 license. +// The original work can be found at the repository: https://github.com/browserslist/caniuse-lite. + +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/packages/stablestudio-ui/public/Checkers.png b/packages/stablestudio-ui/public/Checkers.png new file mode 100644 index 0000000..d761fa5 Binary files /dev/null and b/packages/stablestudio-ui/public/Checkers.png differ diff --git a/packages/stablestudio-ui/public/DummyImage.png b/packages/stablestudio-ui/public/DummyImage.png new file mode 100644 index 0000000..cbeea0a Binary files /dev/null and b/packages/stablestudio-ui/public/DummyImage.png differ diff --git a/packages/stablestudio-ui/public/Inter.ttf b/packages/stablestudio-ui/public/Inter.ttf new file mode 100644 index 0000000..ec3164e Binary files /dev/null and b/packages/stablestudio-ui/public/Inter.ttf differ diff --git a/packages/stablestudio-ui/public/PluginWithManifest.js b/packages/stablestudio-ui/public/PluginWithManifest.js new file mode 100644 index 0000000..ee74f4e --- /dev/null +++ b/packages/stablestudio-ui/public/PluginWithManifest.js @@ -0,0 +1,52 @@ +var l = (t) => { + let e, + i = new Set(), + r = (o, u) => { + let s = typeof o == "function" ? o(e) : o; + if (!Object.is(s, e)) { + let g = e; + (e = u ?? typeof s != "object" ? s : Object.assign({}, e, s)), + i.forEach((p) => p(e, g)); + } + }, + a = () => e, + n = { + setState: r, + getState: a, + subscribe: (o) => (i.add(o), () => i.delete(o)), + destroy: () => { + (import.meta.env && import.meta.env.MODE) !== "production" && + console.warn( + "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected." + ), + i.clear(); + }, + }; + return (e = t(r, a, n)), n; + }, + d = (t) => (t ? l(t) : l), + c = (t) => (e) => d((i, r) => t({ set: i, get: r, context: e })); +var m = c(() => ({ + manifest: { + name: "Example Plugin", + description: "An example plugin for StableStudio", + version: "1.2.3", + author: "Bobby Joe", + license: "MIT", + link: "https://github.com", + icon: "https://place.dog/100/100", + }, + getStatus: () => ({ + indicator: "success", + message: "This plugin is working", + }), + settings: { + exampleSetting: { + type: "string", + default: "Hello, World!", + placeholder: "Example setting", + }, + }, +})); +export { m as createPlugin }; +//# sourceMappingURL=index.js.map diff --git a/packages/stablestudio-ui/public/PluginWithoutManifest.js b/packages/stablestudio-ui/public/PluginWithoutManifest.js new file mode 100644 index 0000000..a6db124 --- /dev/null +++ b/packages/stablestudio-ui/public/PluginWithoutManifest.js @@ -0,0 +1,52 @@ +var l = (t) => { + let e, + i = new Set(), + r = (o, u) => { + let s = typeof o == "function" ? o(e) : o; + if (!Object.is(s, e)) { + let g = e; + (e = u ?? typeof s != "object" ? s : Object.assign({}, e, s)), + i.forEach((p) => p(e, g)); + } + }, + a = () => e, + n = { + setState: r, + getState: a, + subscribe: (o) => (i.add(o), () => i.delete(o)), + destroy: () => { + (import.meta.env && import.meta.env.MODE) !== "production" && + console.warn( + "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected." + ), + i.clear(); + }, + }; + return (e = t(r, a, n)), n; + }, + d = (t) => (t ? l(t) : l), + c = (t) => (e) => d((i, r) => t({ set: i, get: r, context: e })); +var m = c(() => ({ + // manifest: { + // name: "Example Plugin", + // description: "An example plugin for StableStudio", + // version: "1.2.3", + // author: "Bobby Joe", + // license: "MIT", + // link: "https://github.com", + // icon: "place.dog/100/100", + // }, + getStatus: () => ({ + indicator: "success", + message: "This plugin is working", + }), + settings: { + exampleSetting: { + type: "string", + default: "Hello, World!", + placeholder: "Example setting", + }, + }, +})); +export { m as createPlugin }; +//# sourceMappingURL=index.js.map diff --git a/packages/stablestudio-ui/public/examples/aurora.png b/packages/stablestudio-ui/public/examples/aurora.png new file mode 100644 index 0000000..26d9fc3 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/aurora.png differ diff --git a/packages/stablestudio-ui/public/examples/cake.png b/packages/stablestudio-ui/public/examples/cake.png new file mode 100644 index 0000000..56ac966 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/cake.png differ diff --git a/packages/stablestudio-ui/public/examples/center.png b/packages/stablestudio-ui/public/examples/center.png new file mode 100644 index 0000000..19a7684 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/center.png differ diff --git a/packages/stablestudio-ui/public/examples/chili.png b/packages/stablestudio-ui/public/examples/chili.png new file mode 100644 index 0000000..e9e57c0 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/chili.png differ diff --git a/packages/stablestudio-ui/public/examples/dragon.png b/packages/stablestudio-ui/public/examples/dragon.png new file mode 100644 index 0000000..0bffe6a Binary files /dev/null and b/packages/stablestudio-ui/public/examples/dragon.png differ diff --git a/packages/stablestudio-ui/public/examples/flowers.png b/packages/stablestudio-ui/public/examples/flowers.png new file mode 100644 index 0000000..2a91a89 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/flowers.png differ diff --git a/packages/stablestudio-ui/public/examples/forest.png b/packages/stablestudio-ui/public/examples/forest.png new file mode 100644 index 0000000..3bd0ff6 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/forest.png differ diff --git a/packages/stablestudio-ui/public/examples/king.png b/packages/stablestudio-ui/public/examples/king.png new file mode 100644 index 0000000..1846dd7 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/king.png differ diff --git a/packages/stablestudio-ui/public/examples/moon.png b/packages/stablestudio-ui/public/examples/moon.png new file mode 100644 index 0000000..0e8c110 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/moon.png differ diff --git a/packages/stablestudio-ui/public/examples/motorcycle.png b/packages/stablestudio-ui/public/examples/motorcycle.png new file mode 100644 index 0000000..b88554e Binary files /dev/null and b/packages/stablestudio-ui/public/examples/motorcycle.png differ diff --git a/packages/stablestudio-ui/public/examples/racecar.png b/packages/stablestudio-ui/public/examples/racecar.png new file mode 100644 index 0000000..e034971 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/racecar.png differ diff --git a/packages/stablestudio-ui/public/examples/river.png b/packages/stablestudio-ui/public/examples/river.png new file mode 100644 index 0000000..4855955 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/river.png differ diff --git a/packages/stablestudio-ui/public/examples/robot.png b/packages/stablestudio-ui/public/examples/robot.png new file mode 100644 index 0000000..bf811c0 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/robot.png differ diff --git a/packages/stablestudio-ui/public/examples/seascape.png b/packages/stablestudio-ui/public/examples/seascape.png new file mode 100644 index 0000000..79cd4de Binary files /dev/null and b/packages/stablestudio-ui/public/examples/seascape.png differ diff --git a/packages/stablestudio-ui/public/examples/spaceship.png b/packages/stablestudio-ui/public/examples/spaceship.png new file mode 100644 index 0000000..40aceb5 Binary files /dev/null and b/packages/stablestudio-ui/public/examples/spaceship.png differ diff --git a/packages/stablestudio-ui/public/examples/sushi.png b/packages/stablestudio-ui/public/examples/sushi.png new file mode 100644 index 0000000..e9763af Binary files /dev/null and b/packages/stablestudio-ui/public/examples/sushi.png differ diff --git a/packages/stablestudio-ui/public/examples/train.png b/packages/stablestudio-ui/public/examples/train.png new file mode 100644 index 0000000..e2c6afd Binary files /dev/null and b/packages/stablestudio-ui/public/examples/train.png differ diff --git a/packages/stablestudio-ui/public/favicon.svg b/packages/stablestudio-ui/public/favicon.svg new file mode 100644 index 0000000..3e18e37 --- /dev/null +++ b/packages/stablestudio-ui/public/favicon.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/packages/stablestudio-ui/public/logo.png b/packages/stablestudio-ui/public/logo.png new file mode 100644 index 0000000..27d3575 Binary files /dev/null and b/packages/stablestudio-ui/public/logo.png differ diff --git a/packages/stablestudio-ui/public/media/api_keys_screenshot.png b/packages/stablestudio-ui/public/media/api_keys_screenshot.png new file mode 100644 index 0000000..e08e127 Binary files /dev/null and b/packages/stablestudio-ui/public/media/api_keys_screenshot.png differ diff --git a/packages/stablestudio-ui/public/media/copy_api_key_screenshot.png b/packages/stablestudio-ui/public/media/copy_api_key_screenshot.png new file mode 100644 index 0000000..50ecd38 Binary files /dev/null and b/packages/stablestudio-ui/public/media/copy_api_key_screenshot.png differ diff --git a/packages/stablestudio-ui/public/media/create_api_key_screenshot.png b/packages/stablestudio-ui/public/media/create_api_key_screenshot.png new file mode 100644 index 0000000..16ea81f Binary files /dev/null and b/packages/stablestudio-ui/public/media/create_api_key_screenshot.png differ diff --git a/packages/stablestudio-ui/public/media/svg/icons/artstation.svg b/packages/stablestudio-ui/public/media/svg/icons/artstation.svg new file mode 100644 index 0000000..e2660ea --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/artstation.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/stablestudio-ui/public/media/svg/icons/cgsociety.svg b/packages/stablestudio-ui/public/media/svg/icons/cgsociety.svg new file mode 100644 index 0000000..a96b464 --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/cgsociety.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/stablestudio-ui/public/media/svg/icons/discord.svg b/packages/stablestudio-ui/public/media/svg/icons/discord.svg new file mode 100644 index 0000000..6f6819e --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/discord.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/stablestudio-ui/public/media/svg/icons/filledlogo.svg b/packages/stablestudio-ui/public/media/svg/icons/filledlogo.svg new file mode 100644 index 0000000..0face59 --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/filledlogo.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/stablestudio-ui/public/media/svg/icons/filledlogoblack.svg b/packages/stablestudio-ui/public/media/svg/icons/filledlogoblack.svg new file mode 100644 index 0000000..f493021 --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/filledlogoblack.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/stablestudio-ui/public/media/svg/icons/instagram.svg b/packages/stablestudio-ui/public/media/svg/icons/instagram.svg new file mode 100644 index 0000000..ddb2d6b --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/instagram.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/stablestudio-ui/public/media/svg/icons/twitter.svg b/packages/stablestudio-ui/public/media/svg/icons/twitter.svg new file mode 100644 index 0000000..cc7ce31 --- /dev/null +++ b/packages/stablestudio-ui/public/media/svg/icons/twitter.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/stablestudio-ui/public/presets/3d-model.png b/packages/stablestudio-ui/public/presets/3d-model.png new file mode 100644 index 0000000..5001d9d Binary files /dev/null and b/packages/stablestudio-ui/public/presets/3d-model.png differ diff --git a/packages/stablestudio-ui/public/presets/analog-film.png b/packages/stablestudio-ui/public/presets/analog-film.png new file mode 100644 index 0000000..f1b24cb Binary files /dev/null and b/packages/stablestudio-ui/public/presets/analog-film.png differ diff --git a/packages/stablestudio-ui/public/presets/anime.png b/packages/stablestudio-ui/public/presets/anime.png new file mode 100644 index 0000000..3ca2d2f Binary files /dev/null and b/packages/stablestudio-ui/public/presets/anime.png differ diff --git a/packages/stablestudio-ui/public/presets/cinematic.png b/packages/stablestudio-ui/public/presets/cinematic.png new file mode 100644 index 0000000..1433101 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/cinematic.png differ diff --git a/packages/stablestudio-ui/public/presets/comic-book.png b/packages/stablestudio-ui/public/presets/comic-book.png new file mode 100644 index 0000000..25484d3 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/comic-book.png differ diff --git a/packages/stablestudio-ui/public/presets/digital-art.png b/packages/stablestudio-ui/public/presets/digital-art.png new file mode 100644 index 0000000..6677259 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/digital-art.png differ diff --git a/packages/stablestudio-ui/public/presets/enhance.png b/packages/stablestudio-ui/public/presets/enhance.png new file mode 100644 index 0000000..678c67b Binary files /dev/null and b/packages/stablestudio-ui/public/presets/enhance.png differ diff --git a/packages/stablestudio-ui/public/presets/fantasy-art.png b/packages/stablestudio-ui/public/presets/fantasy-art.png new file mode 100644 index 0000000..d15dda8 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/fantasy-art.png differ diff --git a/packages/stablestudio-ui/public/presets/isometric.png b/packages/stablestudio-ui/public/presets/isometric.png new file mode 100644 index 0000000..8c60fba Binary files /dev/null and b/packages/stablestudio-ui/public/presets/isometric.png differ diff --git a/packages/stablestudio-ui/public/presets/line-art.png b/packages/stablestudio-ui/public/presets/line-art.png new file mode 100644 index 0000000..0e08dae Binary files /dev/null and b/packages/stablestudio-ui/public/presets/line-art.png differ diff --git a/packages/stablestudio-ui/public/presets/low-poly.png b/packages/stablestudio-ui/public/presets/low-poly.png new file mode 100644 index 0000000..ca391b7 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/low-poly.png differ diff --git a/packages/stablestudio-ui/public/presets/modeling-compound.png b/packages/stablestudio-ui/public/presets/modeling-compound.png new file mode 100644 index 0000000..9a25181 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/modeling-compound.png differ diff --git a/packages/stablestudio-ui/public/presets/neon-punk.png b/packages/stablestudio-ui/public/presets/neon-punk.png new file mode 100644 index 0000000..ac08962 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/neon-punk.png differ diff --git a/packages/stablestudio-ui/public/presets/origami.png b/packages/stablestudio-ui/public/presets/origami.png new file mode 100644 index 0000000..e23727f Binary files /dev/null and b/packages/stablestudio-ui/public/presets/origami.png differ diff --git a/packages/stablestudio-ui/public/presets/photographic.png b/packages/stablestudio-ui/public/presets/photographic.png new file mode 100644 index 0000000..daff600 Binary files /dev/null and b/packages/stablestudio-ui/public/presets/photographic.png differ diff --git a/packages/stablestudio-ui/public/presets/pixel-art.png b/packages/stablestudio-ui/public/presets/pixel-art.png new file mode 100644 index 0000000..1588ecf Binary files /dev/null and b/packages/stablestudio-ui/public/presets/pixel-art.png differ diff --git a/packages/stablestudio-ui/src/App/BottomBar/index.tsx b/packages/stablestudio-ui/src/App/BottomBar/index.tsx new file mode 100644 index 0000000..50eee42 --- /dev/null +++ b/packages/stablestudio-ui/src/App/BottomBar/index.tsx @@ -0,0 +1,62 @@ +import { motion } from "framer-motion"; +import { useLocation } from "react-router-dom"; +import { useClickAway } from "react-use"; +import { Generation } from "~/Generation"; +import { Theme } from "~/Theme"; + +export function BottomBar() { + const [open, setOpen] = useState(false); + const { input } = Generation.Image.Session.useCurrentInput(); + const createDream = Generation.Image.Session.useCreateDream(); + const tabRef = useRef(null); + const location = useLocation(); + console.log("BottomBar"); + + useClickAway(tabRef, () => setOpen(false)); + + if (!location.pathname.startsWith("/generate")) return null; + return ( + +
+ setOpen(!open)} + > + + + {open && input && ( + + + + )} + {input && ( + + createDream()} + fullWidth + /> + + )} +
+
+ ); +} diff --git a/packages/stablestudio-ui/src/App/Providers.tsx b/packages/stablestudio-ui/src/App/Providers.tsx new file mode 100644 index 0000000..f9f160e --- /dev/null +++ b/packages/stablestudio-ui/src/App/Providers.tsx @@ -0,0 +1,13 @@ +import { Environment } from "~/Environment"; +import { Remote } from "~/Remote"; +import { Router } from "~/Router"; + +export function Providers({ children }: React.PropsWithChildren) { + return ( + + + {children} + + + ); +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Resizer.tsx b/packages/stablestudio-ui/src/App/Sidebar/Resizer.tsx new file mode 100644 index 0000000..b30ef16 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Resizer.tsx @@ -0,0 +1,101 @@ +import { cx } from "@emotion/css"; +import { App } from "~/App"; +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export type Resizer = { + width: number; + onChange?: (width: number) => void; +}; + +export function Resizer({ position }: App.Sidebar.Props) { + const [resizing, setResizing] = useState(false); + const [sidebar, setSidebar] = App.Sidebar.use(position); + const isMobileDevice = Theme.useIsMobileDevice(); + const resize = Editor.Canvas.useResize(); + + const toggleSidebar = useCallback(() => { + if (isMobileDevice) { + return setSidebar(({ visible }) => ({ visible: !visible })); + } else { + setSidebar(({ width }) => ({ + width: width === 0 ? App.Sidebar.presetWidth() : 0, + })); + } + }, [isMobileDevice, setSidebar]); + + useEffect(() => { + const onMouseUp = () => setResizing(false); + const onMouseMove = (event: MouseEvent) => { + if (!resizing) return; + + event.preventDefault(); + event.stopPropagation(); + setSidebar({ + width: clamp( + 0, + position === "left" + ? event.clientX + : window.innerWidth - event.clientX, + 600 + ), + }); + resize(); + }; + + window.addEventListener("mousemove", onMouseMove); + window.addEventListener("mouseup", onMouseUp); + + return () => { + window.removeEventListener("mousemove", onMouseMove); + window.removeEventListener("mouseup", onMouseUp); + }; + }, [position, resize, resizing, setSidebar]); + + return ( +
!isMobileDevice && setResizing(true), + [isMobileDevice, setResizing] + )} + style={{ [position]: "100%" }} + className={classes( + "group absolute top-0 bottom-0 flex w-5 cursor-col-resize", + position === "right" && "justify-end" + )} + > +
+ 0 && sidebar.visible + ? Theme.Icon.ChevronLeft + : Theme.Icon.ChevronRight + } + /> +
+
+ + +
+
+ ); +} + +function Line({ resizing, className }: Styleable & { resizing?: boolean }) { + return ( +
+ ); +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Section.tsx b/packages/stablestudio-ui/src/App/Sidebar/Section.tsx new file mode 100644 index 0000000..2613494 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Section.tsx @@ -0,0 +1,117 @@ +import { Theme } from "~/Theme"; + +export function Section(props: Section.Props) { + const { + title, + children, + className: classNames, + collapsable, + defaultExpanded, + padding = Theme.Common.Size.preset(), + button, + icon, + divider = true, + onChange, + } = props; + const [expanded, setExpanded] = useState(!!defaultExpanded || !collapsable); + + const className = useMemo( + () => + typeof classNames === "function" + ? classNames({ ...props, expanded }) + : classNames, + [classNames, props, expanded] + ); + + useEffect(() => { + if (!defaultExpanded) return; + setExpanded(defaultExpanded); + }, [defaultExpanded]); + + const buttonProps = useMemo( + () => ({ testsdfsadfasdfs: true, transparent: true, className: "p-0" }), + [] + ); + + const buttonRendered = useMemo( + () => (typeof button === "function" ? button(buttonProps) : button), + [buttonProps, button] + ); + + return ( +
+ {title && ( +
+ { + if (!collapsable) return; + setExpanded(!expanded); + onChange?.(!expanded); + }} + iconLeft={ + icon + ? typeof icon === "function" + ? icon({ ...props, expanded }) + : icon + : collapsable && + ((props) => ( + + )) + } + > + {title} + + {buttonRendered} +
+ )} + {(expanded || !collapsable) && children && ( +
+ {children} +
+ )} +
+ ); +} + +export namespace Section { + export type Props = { + title?: false | string; + collapsable?: boolean; + defaultExpanded?: boolean; + padding?: Theme.Common.Size | "none"; + button?: React.ReactNode | ((props: Theme.Button.Props) => React.ReactNode); + divider?: boolean; + icon?: (props: Section.Props & { expanded: boolean }) => Theme.Icon.Prop; + + onChange?: (expanded: boolean) => void; + className?: + | string + | ((props: Section.Props & { expanded: boolean }) => string); + children?: React.ReactNode; + }; +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Shortcut.tsx b/packages/stablestudio-ui/src/App/Sidebar/Shortcut.tsx new file mode 100644 index 0000000..8e9040f --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Shortcut.tsx @@ -0,0 +1,72 @@ +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Shortcuts { + export const use = () => { + const toggleSidebars = doNothing; + const toggleLayerPanel = doNothing; + const toggleBrushPanel = doNothing; + const toggleLayersTab = doNothing; + const toggleHistoryTab = doNothing; + + Shortcut.use( + useMemo( + () => ({ + name: ["Sidebar", "Toggle Both"], + keys: ["Meta", "\\"], + icon: Theme.Icon.Sidebar, + action: toggleSidebars, + }), + [toggleSidebars] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Sidebar", "Toggle Right"], + keys: ["F7"], + icon: Theme.Icon.SidebarOpen, + action: toggleLayerPanel, + }), + [toggleLayerPanel] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Sidebar", "Toggle Left"], + keys: ["F5"], + icon: Theme.Icon.SidebarClose, + action: toggleBrushPanel, + }), + [toggleBrushPanel] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Sidebar", "Layers"], + keys: ["Control", "l"], + icon: Theme.Icon.Layers, + action: toggleLayersTab, + }), + [toggleLayersTab] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Sidebar", "History"], + keys: ["Control", "y"], + icon: Theme.Icon.History, + action: toggleHistoryTab, + }), + [toggleHistoryTab] + ) + ); + }; +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Sidebars.tsx b/packages/stablestudio-ui/src/App/Sidebar/Sidebars.tsx new file mode 100644 index 0000000..78e5638 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Sidebars.tsx @@ -0,0 +1,11 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +export function Sidebars() { + return ( + <> + + + + ); +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Tab/Bottom.tsx b/packages/stablestudio-ui/src/App/Sidebar/Tab/Bottom.tsx new file mode 100644 index 0000000..5c85131 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Tab/Bottom.tsx @@ -0,0 +1,18 @@ +import { App } from "~/App"; + +export function Bottom({ className, children }: StyleableWithChildren) { + return ( +
+ {children} +
+ ); +} + +export function Bottoms({ position }: App.Sidebar.Props) { + const [sidebar] = App.Sidebar.use(position); + const tabs = App.Sidebar.Tabs.use(position); + const tab = tabs.find((tab) => tab.name === sidebar.tab); + return <>{tab?.bottom}; +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Tab/Button.tsx b/packages/stablestudio-ui/src/App/Sidebar/Tab/Button.tsx new file mode 100644 index 0000000..9f21dd1 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Tab/Button.tsx @@ -0,0 +1,62 @@ +import { App } from "~/App"; +import { Router } from "~/Router"; +import { Theme } from "~/Theme"; + +export function Button(props: Theme.Button.Props) { + return ( + + ); +} + +export function Buttons({ position }: App.Sidebar.Props) { + const navigate = Router.useNavigate(); + const [sidebar, setSidebar] = App.Sidebar.use(position); + const tabs = App.Sidebar.Tabs.use(position); + + const isMobileDevice = Theme.useIsMobileDevice(); + + const noButtons = tabs.every((tab) => tab.button === false); + return useMemo(() => { + if (!tabs[0] || noButtons) return null; + return ( +
+ {tabs.map((tab) => { + if (tab.button === false) return null; + + const onClick = () => { + setSidebar((sidebar) => ({ ...sidebar, tab: tab.name })); + tab.route && navigate(tab.route); + }; + + const props = { + key: tab.name, + icon: tab.icon, + active: tab.name === sidebar.tab, + className: classes("justify-start", !!tab.button && "w-full"), + children: tab.name, + onClick, + }; + + return typeof tab.button === "function" ? ( + tab.button(props) + ) : ( +
+ ); + }, [tabs, noButtons, isMobileDevice, sidebar.tab, setSidebar, navigate]); +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Tab/Tabs.tsx b/packages/stablestudio-ui/src/App/Sidebar/Tab/Tabs.tsx new file mode 100644 index 0000000..f044ab6 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Tab/Tabs.tsx @@ -0,0 +1,41 @@ +import { App } from "~/App"; +import { GlobalState } from "~/GlobalState"; + +export type Tabs = App.Sidebar.Tab[]; +export namespace Tabs { + export const use = (position: App.Sidebar.Position) => { + const tabs = State.use(({ tabs }) => tabs); + return useMemo( + () => + Object.values(tabs) + .filter((tab) => tab.position === position) + .sort((a, b) => (a.index ?? Infinity) - (b.index ?? Infinity)), + [position, tabs] + ); + }; + + export type State = { + tabs: Record; + setTab: (name: App.Sidebar.Tab.Name, tab?: App.Sidebar.Tab) => void; + + leftElement?: HTMLDivElement | null; + setLeftElement: (element?: HTMLDivElement | null) => void; + + rightElement?: HTMLDivElement | null; + setRightElement: (element?: HTMLDivElement | null) => void; + }; + + export namespace State { + export const use = GlobalState.create((set) => ({ + tabs: {}, + setTab: (name, tab) => + set((state) => { + const { [name]: _previous, ...tabs } = state.tabs; + return { tabs: { ...tabs, ...(tab && { [name]: tab }) } }; + }), + + setLeftElement: (element) => set({ leftElement: element }), + setRightElement: (element) => set({ rightElement: element }), + })); + } +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/Tab/index.tsx b/packages/stablestudio-ui/src/App/Sidebar/Tab/index.tsx new file mode 100644 index 0000000..6612545 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/Tab/index.tsx @@ -0,0 +1,97 @@ +import * as ReactDOM from "react-dom"; +import { useLocation } from "react-router-dom"; + +import { App } from "~/App"; +import { GlobalState } from "~/GlobalState"; +import { Router } from "~/Router"; +import { Theme } from "~/Theme"; + +import { Bottom, Bottoms } from "./Bottom"; +import { Button, Buttons } from "./Button"; +import { Tabs } from "./Tabs"; + +export * from "./Tabs"; + +export type Tab = { + name: Tab.Name; + position: App.Sidebar.Position; + route?: Router.Route; + defaultActive?: boolean; + enabled?: boolean; + index?: number; + + icon?: Theme.Icon.Prop; + button?: Theme.Button.Prop; + + above?: React.ReactNode; + below?: React.ReactNode; + bottom?: React.ReactNode; + + onClick?: (event: MouseEvent) => void; +}; + +export function Tab({ position }: App.Sidebar.Props) { + const setElement = Tabs.State.use( + (state) => + position === "left" ? state.setLeftElement : state.setRightElement, + GlobalState.shallow + ); + + return ( +
+ ); +} + +export declare namespace Tab { + export { Bottom, Button, Buttons, Bottoms }; +} + +export namespace Tab { + Tab.Bottom = Bottom; + Tab.Button = Button; + Tab.Buttons = Buttons; + Tab.Bottoms = Bottoms; + + export type Name = string; + export type Props = Tab & StyleableWithChildren; + + export function Set({ children, ...props }: Props) { + const [sidebar, setSidebar] = App.Sidebar.use(props.position); + const location = useLocation(); + + const { setTab, element } = Tabs.State.use( + ({ setTab, ...state }) => ({ + setTab, + element: + props.position === "left" ? state.leftElement : state.rightElement, + }), + GlobalState.shallow + ); + + useEffect(() => { + setTab(props.name, { enabled: true, ...props }); + return () => setTab(props.name); + }, [props, setTab]); + + useEffect(() => { + (window.location.pathname === props.route || + (window.location.pathname === "/" && props.defaultActive)) && + setSidebar((sidebar) => ({ ...sidebar, tab: props.name })); + }, [props.name, props.defaultActive, setSidebar, props.route, location]); + + return useMemo( + () => ( + <> + {sidebar.tab === props.name && + props.enabled && + element && + ReactDOM.createPortal(children, element)} + + ), + [children, element, props.enabled, props.name, sidebar.tab] + ); + } +} diff --git a/packages/stablestudio-ui/src/App/Sidebar/index.tsx b/packages/stablestudio-ui/src/App/Sidebar/index.tsx new file mode 100644 index 0000000..bcacee9 --- /dev/null +++ b/packages/stablestudio-ui/src/App/Sidebar/index.tsx @@ -0,0 +1,119 @@ +import { GlobalState } from "~/GlobalState"; +import { Theme } from "~/Theme"; + +import { Resizer } from "./Resizer"; +import { Section } from "./Section"; +import { Shortcuts } from "./Shortcut"; +import { Tab, Tabs } from "./Tab"; + +export * from "./Sidebars"; + +export type Sidebar = { + visible: boolean; + width: number; + tab?: Tab.Name; +}; + +export function Sidebar({ position }: Sidebar.Props) { + const [sidebar] = Sidebar.use(position); + const tabs = Tabs.use(position); + const hasTabs = tabs.some((tab) => tab.enabled); + const isMobileDevice = Theme.useIsMobileDevice(); + const showing = hasTabs && sidebar.visible && sidebar.width > 300; + + const bar = useMemo( + () => ( + <> + + + + + ), + [position] + ); + + if (isMobileDevice) return null; + return ( +
+ {hasTabs && } +
+ {bar} +
+
+ ); +} + +export declare namespace Sidebar { + export { Section, Shortcuts, Tab, Tabs }; +} + +export namespace Sidebar { + Sidebar.Section = Section; + Sidebar.Shortcuts = Shortcuts; + Sidebar.Tab = Tab; + Sidebar.Tabs = Tabs; + + export type Props = { position: Position }; + export type Position = "left" | "right"; + + export const presetWidth = () => 400; + + export const use = (position: Position) => { + const { sidebar, stateSet } = State.use( + (state) => ({ + sidebar: state[position], + stateSet: state.setSidebar, + }), + GlobalState.shallow + ); + + const setSidebar = useCallback( + (setSidebar: React.SetStateAction>) => + stateSet(position, setSidebar), + [position, stateSet] + ); + + return useMemo(() => [sidebar, setSidebar] as const, [sidebar, setSidebar]); + }; + + type State = { + left: Sidebar; + right: Sidebar; + + setSidebar: ( + position: Position, + setSidebar: React.SetStateAction> + ) => void; + }; + + namespace State { + export const use = GlobalState.create((set) => { + const sidebar = { visible: true, width: presetWidth() }; + return { + left: sidebar, + right: sidebar, + + setSidebar: (position, setSidebar) => + set((state) => ({ + [position]: { + ...state[position], + ...(typeof setSidebar === "function" + ? setSidebar(state[position]) + : setSidebar), + }, + })), + }; + }); + } +} diff --git a/packages/stablestudio-ui/src/App/TopBar/Center/index.tsx b/packages/stablestudio-ui/src/App/TopBar/Center/index.tsx new file mode 100644 index 0000000..74773fc --- /dev/null +++ b/packages/stablestudio-ui/src/App/TopBar/Center/index.tsx @@ -0,0 +1,36 @@ +import * as ReactDOM from "react-dom"; + +import { GlobalState } from "~/GlobalState"; + +export function Center({ className, children }: StyleableWithChildren) { + const setElement = State.use(({ setElement }) => setElement); + return ( +
+ {children} +
+ ); +} + +export namespace Center { + export function Set({ children }: React.PropsWithChildren) { + const element = State.use(({ element }) => element, GlobalState.shallow); + return <>{element && ReactDOM.createPortal(children, element)}; + } +} + +type State = { + element?: HTMLDivElement | null; + setElement: (element?: HTMLDivElement | null) => void; +}; + +namespace State { + export const use = GlobalState.create((set) => ({ + setElement: (element) => set({ element }), + })); +} diff --git a/packages/stablestudio-ui/src/App/TopBar/Left/index.tsx b/packages/stablestudio-ui/src/App/TopBar/Left/index.tsx new file mode 100644 index 0000000..005fd02 --- /dev/null +++ b/packages/stablestudio-ui/src/App/TopBar/Left/index.tsx @@ -0,0 +1,12 @@ +import { Link } from "react-router-dom"; +import { Theme } from "~/Theme"; + +export const Left = () => { + return ( +
+ + + +
+ ); +}; diff --git a/packages/stablestudio-ui/src/App/TopBar/Right/index.tsx b/packages/stablestudio-ui/src/App/TopBar/Right/index.tsx new file mode 100644 index 0000000..3a615db --- /dev/null +++ b/packages/stablestudio-ui/src/App/TopBar/Right/index.tsx @@ -0,0 +1,37 @@ +import { Link } from "react-router-dom"; +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export const Right = () => { + const { setIsOpen } = Shortcut.Palette.use(); + const isMobileDevice = Theme.useIsMobileDevice(); + return ( +
+ <> + {!isMobileDevice && ( + + // cause a Ctrl+K to be triggered + setIsOpen(true) + } + > + Shortcuts + + + )} + + + + +
+ ); +}; diff --git a/packages/stablestudio-ui/src/App/TopBar/index.tsx b/packages/stablestudio-ui/src/App/TopBar/index.tsx new file mode 100644 index 0000000..fb70587 --- /dev/null +++ b/packages/stablestudio-ui/src/App/TopBar/index.tsx @@ -0,0 +1,61 @@ +import { Theme } from "~/Theme"; + +import { Center } from "./Center"; +import { Left } from "./Left"; +import { Right } from "./Right"; + +export function TopBar() { + return ( + + ); +} + +export declare namespace TopBar { + export { Center }; +} + +export namespace TopBar { + TopBar.Center = Center; + + export function Divider(props: Theme.Divider.Props) { + return ( + + ); + } + + export function Buttons({ children }: React.PropsWithChildren) { + return
{children}
; + } + + export function Button({ + menu, + ...props + }: Theme.Button.Props & { menu?: React.ReactNode }) { + return ( +
+ + {menu && ( + + )} +
+ ); + } +} diff --git a/packages/stablestudio-ui/src/App/index.tsx b/packages/stablestudio-ui/src/App/index.tsx new file mode 100644 index 0000000..e794996 --- /dev/null +++ b/packages/stablestudio-ui/src/App/index.tsx @@ -0,0 +1,42 @@ +import { Router } from "~/Router"; +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +import { BottomBar } from "./BottomBar"; +import { Providers } from "./Providers"; +import { Sidebar, Sidebars } from "./Sidebar"; +import { TopBar } from "./TopBar"; + +export function App() { + const isMobileDevice = Theme.useIsMobileDevice(); + return useMemo( + () => ( + +
+
+ + + +
+ +
+ +
+ +
+ {isMobileDevice && } +
+ + ), + [isMobileDevice] + ); +} + +export declare namespace App { + export { Sidebar, TopBar }; +} + +export namespace App { + App.Sidebar = Sidebar; + App.TopBar = TopBar; +} diff --git a/packages/stablestudio-ui/src/Device/index.ts b/packages/stablestudio-ui/src/Device/index.ts new file mode 100644 index 0000000..f884103 --- /dev/null +++ b/packages/stablestudio-ui/src/Device/index.ts @@ -0,0 +1,40 @@ +export namespace Device { + // TODO: Stop using `appVersion` + export const getInfo = () => { + const { userAgent } = navigator; + const appVersion = navigator.appVersion; + + const deviceType = + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + userAgent + ) + ? "Mobile/Phone" + : /iPad/i.test(userAgent) + ? "Tablet" + : "Desktop/Laptop"; + + const browserName = + userAgent.indexOf("Chrome") > -1 && + navigator.userAgent.indexOf("OPR") === -1 + ? "Chrome" + : userAgent.indexOf("Firefox") > -1 + ? "Firefox" + : userAgent.indexOf("Safari") > -1 && userAgent.indexOf("OPR") === -1 + ? "Safari" + : userAgent.indexOf("Edge") > -1 || userAgent.indexOf("edg/") > -1 + ? "Edge" + : userAgent.indexOf("OPR") > -1 + ? "Opera" + : "Unknown"; + + const operatingSystem = appVersion.match(/win/i) + ? "Windows" + : appVersion.match(/mac/i) + ? "Mac" + : appVersion.match(/linux/i) + ? "Linux" + : "Unknown"; + + return { deviceType, browserName, operatingSystem }; + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Blur.tsx b/packages/stablestudio-ui/src/Editor/Brush/Blur.tsx new file mode 100644 index 0000000..753092f --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Blur.tsx @@ -0,0 +1,68 @@ +import { Editor } from "~/Editor"; +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export type Blur = number; +export namespace Blur { + export const min = () => 0; + export const preset = () => 5; + export const max = () => 50; + + export const use = () => { + const brush = Editor.Brush.use(); + const setBrush = Editor.Brush.useSet(); + + const set = useCallback( + ( + setBlur: number | undefined | ((blur: number) => number | undefined) + ) => { + setBrush((brush) => { + const blur = + (typeof setBlur === "function" ? setBlur(brush.blur) : setBlur) ?? + preset(); + + return { ...brush, blur: clamp(min(), blur, max()) }; + }); + }, + [setBrush] + ); + + return useMemo(() => [brush.blur, set] as const, [brush.blur, set]); + }; + + export namespace Shortcuts { + export const use = () => { + const [, setBlur] = Editor.Brush.Blur.use(); + const [tool] = Editor.Tool.Active.use(); + const enabled = tool === "brush"; + + Shortcut.use( + useMemo( + () => ({ + name: ["Eraser", "Blur", "Increase"], + icon: Theme.Icon.Plus, + keys: ["Shift", "]"], + + enabled, + action: () => setBlur((blur) => blur + 1), + }), + [enabled, setBlur] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Eraser", "Blur", "Decrease"], + icon: Theme.Icon.Minus, + keys: ["Shift", "["], + + enabled, + action: () => setBlur((blur) => blur - 1), + }), + [enabled, setBlur] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Cursor.tsx b/packages/stablestudio-ui/src/Editor/Brush/Cursor.tsx new file mode 100644 index 0000000..d637f5d --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Cursor.tsx @@ -0,0 +1,75 @@ +import { Editor } from "~/Editor"; + +export function Cursor() { + const [activeTool] = Editor.Tool.Active.use(); + const [show, setShow] = useState(false); + const svg = useRef(null); + + const { size, strength } = Editor.Brush.use(); + + useEffect(() => { + function handleMouseMove(e: MouseEvent) { + if ( + svg.current && + show && + activeTool === "brush" && + e.clientX && + e.clientY + ) { + svg.current.style.left = e.clientX - size / 2 + "px"; + svg.current.style.top = e.clientY - size / 2 + "px"; + svg.current.style.display = "block"; + svg.current.style.cursor = "none"; + } else if (svg.current) { + svg.current.style.display = "none"; + } + } + + window.addEventListener("mousemove", handleMouseMove); + + document + .getElementById("canvas-container") + ?.addEventListener("mouseenter", () => setShow(true)); + + document + .getElementById("canvas-container") + ?.addEventListener("mouseleave", () => setShow(false)); + + return () => { + window.removeEventListener("mousemove", handleMouseMove); + + document + .getElementById("canvas-container") + ?.removeEventListener("mouseenter", () => setShow(true)); + + document + .getElementById("canvas-container") + ?.removeEventListener("mouseleave", () => setShow(false)); + }; + }, [svg, activeTool, size, show]); + + if (show && activeTool === "brush") { + document.body.style.cursor = "none"; + return ( + + + + ); + } else { + document.body.style.cursor = "default"; + return null; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/MaskLine.tsx b/packages/stablestudio-ui/src/Editor/Brush/MaskLine.tsx new file mode 100644 index 0000000..9d560ca --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/MaskLine.tsx @@ -0,0 +1,203 @@ +import Konva from "konva"; + +import { Editor } from "~/Editor"; + +export class MaskLine { + public strokeWidth = 0; + public strokeBlur = 0; + public strokeStrength = 0; + public points: number[] = []; + public line: Konva.Image | null = null; + public canvas: HTMLCanvasElement = document.createElement("canvas"); + + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + public context: CanvasRenderingContext2D = this.canvas.getContext("2d")!; + + addPoint(x: number, y: number) { + this.points.push(x); + this.points.push(y); + if (this.line) { + this.draw(); + this.line.getLayer()?.batchDraw(); + } else { + false && console.log("no line"); + } + } + + restart( + strokeWidth: number, + strokeBlur: number, + strokeStrength: number, + points: number[] + ) { + this.strokeWidth = strokeWidth; + this.strokeBlur = strokeBlur; + this.strokeStrength = strokeStrength; + this.points = points; + this.line?.visible(true); + } + + clear() { + this.points = []; + + if (this.line) { + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.line.visible(false); + this.line.getLayer()?.batchDraw(); + } + } + + draw() { + const [topLeftPoint, bottomRightPoint]: { x: number; y: number }[] = + this.points.reduce( + (acc, point, i) => { + if (!acc[0] || !acc[1]) return acc; + if (i % 2 === 0) { + if (point < acc[0].x) { + acc[0].x = point; + } + if (point > acc[1].x) { + acc[1].x = point; + } + } else { + if (point < acc[0].y) { + acc[0].y = point; + } + if (point > acc[1].y) { + acc[1].y = point; + } + } + return acc; + }, + [ + { x: Infinity, y: Infinity }, + { x: -Infinity, y: -Infinity }, + ] + ); + + if (!topLeftPoint || !bottomRightPoint) return; + + const width = bottomRightPoint.x - topLeftPoint.x; + const height = bottomRightPoint.y - topLeftPoint.y; + + this.canvas.width = width + this.strokeWidth * 2 + this.strokeBlur * 2; + this.canvas.height = height + this.strokeWidth * 2 + this.strokeBlur * 2; + + this.line?.position({ + x: topLeftPoint.x - this.strokeWidth - this.strokeBlur, + y: topLeftPoint.y - this.strokeWidth - this.strokeBlur, + }); + + this.line?.width(this.canvas.width); + this.line?.height(this.canvas.height); + + this.context.beginPath(); + this.context.fillStyle = "white"; + this.context.filter = `blur(${this.strokeBlur}px)`; + this.context.lineWidth = this.strokeWidth; + this.context.lineCap = "round"; + this.context.lineJoin = "round"; + this.context.globalAlpha = this.strokeStrength; + + const a = this.points[0]; + const b = this.points[1]; + + a && + b && + this.context.moveTo(a - (this.line?.x() || 0), b - (this.line?.y() || 0)); + + for (let i = 2; i < this.points.length; i += 2) { + const a = this.points[i]; + const b = this.points[i + 1]; + + a && + b && + this.context.lineTo( + a - (this.line?.x() ?? 0), + b - (this.line?.y() ?? 0) + ); + } + this.context.stroke(); + } +} + +export namespace MaskLine { + export const applyToImage = ( + image: Editor.Image, + line: Editor.Brush.MaskLine + ): Promise => + new Promise((resolve) => { + if (!image.element?.complete || !image.element.src) { + resolve(null); + return; + } + + // render image to a canvas, render maskLine with distination-out, then render canvas to image as a DataURL and set it as the image source + const canvas = document.createElement("canvas"); + canvas.width = image.element.width; + canvas.height = image.element.height; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const ctx = canvas.getContext("2d")!; + ctx.drawImage(image.element, 0, 0, canvas.width, canvas.height); + + const scale = Math.max( + image.width / image.element.width, + image.height / image.element.height + ); + + const offset = { + x: -((image.width - image.element.width * scale) / 2) / scale, + y: -((image.height - image.element.height * scale) / 2) / scale, + }; + + // render maskLine via points + ctx.beginPath(); + ctx.strokeStyle = "white"; + ctx.lineWidth = line.strokeWidth / scale; + ctx.lineCap = "round"; + ctx.lineJoin = "round"; + ctx.filter = `blur(${line.strokeBlur / scale}px)`; + ctx.globalAlpha = line.strokeStrength; + ctx.globalCompositeOperation = "destination-out"; + for (let i = 0; i < line.points.length; i += 2) { + const a = line.points[i]; + const b = line.points[i + 1]; + + if (!a || !b) continue; + + i === 0 + ? ctx.moveTo( + a / scale - image.x / scale + offset.x, + b / scale - image.y / scale + offset.y + ) + : ctx.lineTo( + a / scale - image.x / scale + offset.x, + b / scale - image.y / scale + offset.y + ); + } + + ctx.stroke(); + + // const m = document.createElement("a"); + // m.href = canvas.toDataURL("image/png"); + // m.download = "mask.png"; + // m.click(); + + // we are about to replace the image with a new blob url, + // so we need to revoke the old one to avoid memory leaks + // but, we dont want to revoke the OG image URL + if ( + image.element.src.startsWith("blob:") && + image.element.src !== image.src + ) + URL.revokeObjectURL(image.element.src); + + const element = new window.Image(); + element.id = image.id; + element.onload = () => resolve(element); + canvas.toBlob((blob) => { + if (blob) element.src = URL.createObjectURL(blob); + canvas.remove(); + }); + }); +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Panel.tsx b/packages/stablestudio-ui/src/Editor/Brush/Panel.tsx new file mode 100644 index 0000000..f39d10f --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Panel.tsx @@ -0,0 +1,139 @@ +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export function Panel() { + const setBrush = Editor.Brush.useSet(); + const brush = Editor.Brush.use(); + const { solid, blurred } = usePreviews({ onClick: setBrush }); + return ( +
+
+ {solid} + {blurred} +
+ Settings +
+ setBrush((brush) => ({ ...brush, size }))} + /> + + setBrush((brush) => ({ ...brush, strength: strength / 100 })) + } + /> + setBrush((brush) => ({ ...brush, blur }))} + /> +
+ Preview +
+ + + +
+
+ ); +} + +function Previews({ children }: React.PropsWithChildren) { + return ( +
{children}
+ ); +} + +function Preview({ + size = Editor.Brush.Size.preset(), + strength = Editor.Brush.Strength.preset(), + blur = Editor.Brush.Blur.preset(), + selectable = false, + scaleSize = (n) => n, + scaleBlur = (n) => n, + onClick, + ...props +}: Partial & { + highlighted?: boolean; + selectable?: boolean; + scaleSize?: (value: number) => number; + scaleBlur?: (value: number) => number; + onClick?: (brush: Editor.Brush) => void; +}) { + const brush = Editor.Brush.use(); + + const [hovering, setHovering] = useState(false); + const matches = size === brush.size && blur === brush.blur; + const highlighted = props.highlighted ?? (hovering || matches); + + return ( +
onClick?.({ ...brush, size, blur })} + onMouseEnter={() => setHovering(true)} + onMouseLeave={() => setHovering(false)} + > +
+
+ ); +} + +function usePreviews({ onClick }: { onClick: (brush: Editor.Brush) => void }) { + const blurMin = 2; + return useMemo(() => { + const count = 10; + const brushes = Array.from({ length: count }, (_, index) => { + const size = + Editor.Brush.Size.min() + + (index / (count - 1)) * + (Editor.Brush.Size.max() - Editor.Brush.Size.min()); + + const blur = + blurMin + + Math.pow(index / (count - 1), 2) * (Editor.Brush.Blur.max() - blurMin); + + return { size, blur }; + }); + + const presets = [...brushes, ...brushes].map(({ size, blur }, index) => { + const isSmooth = index >= brushes.length; + return ( + n / 6 + 5} + scaleBlur={(n) => Math.max(n / 4, isSmooth ? blurMin : 0)} + {...{ onClick, size, blur: isSmooth ? blur : 0 }} + /> + ); + }); + + return { + solid: presets.slice(0, brushes.length), + blurred: presets.slice(-brushes.length), + }; + }, [onClick]); +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Shortcut.tsx b/packages/stablestudio-ui/src/Editor/Brush/Shortcut.tsx new file mode 100644 index 0000000..1570d6d --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Shortcut.tsx @@ -0,0 +1,38 @@ +import { Editor } from "~/Editor"; +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Shortcuts { + export const use = () => { + const setTool = Editor.Tool.Active.useSet(); + const [tool] = Editor.Tool.Active.use(); + const enabled = tool === "brush"; + + Editor.Brush.Blur.Shortcuts.use(); + Editor.Brush.Size.Shortcuts.use(); + + Shortcut.Priority.use( + useMemo( + () => ({ + name: "Eraser", + level: "high", + enabled, + }), + [enabled] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: "Eraser", + icon: Theme.Icon.Eraser, + + keys: "e", + action: () => setTool("brush"), + }), + [setTool] + ) + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Sidebar.tsx b/packages/stablestudio-ui/src/Editor/Brush/Sidebar.tsx new file mode 100644 index 0000000..7f5cdf7 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Sidebar.tsx @@ -0,0 +1,104 @@ +import { App } from "~/App"; +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export namespace Sidebar { + export function Section() { + const setBrush = Editor.Brush.useSet(); + const brush = Editor.Brush.use(); + return ( + +
+
+ + v / 2.5} + scaleSize={(v) => v / 2.5} + /> +
+
+ setBrush((brush) => ({ ...brush, size }))} + /> + setBrush((brush) => ({ ...brush, blur }))} + /> + + setBrush((brush) => ({ ...brush, strength: strength / 100 })) + } + /> +
+
+
+ ); + } +} + +function Preview({ + size = Editor.Brush.Size.preset(), + strength = Editor.Brush.Strength.preset(), + blur = Editor.Brush.Blur.preset(), + selectable = false, + scaleSize = (n) => n, + scaleBlur = (n) => n, + onClick, + ...props +}: Partial & { + highlighted?: boolean; + selectable?: boolean; + scaleSize?: (value: number) => number; + scaleBlur?: (value: number) => number; + onClick?: (brush: Editor.Brush) => void; +}) { + const brush = Editor.Brush.use(); + + const [hovering, setHovering] = useState(false); + const matches = size === brush.size && blur === brush.blur; + const highlighted = props.highlighted ?? (hovering || matches); + + return ( +
onClick?.({ ...brush, size, blur })} + onMouseEnter={() => setHovering(true)} + onMouseLeave={() => setHovering(false)} + > +
+
+ ); +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Size.tsx b/packages/stablestudio-ui/src/Editor/Brush/Size.tsx new file mode 100644 index 0000000..78bd76f --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Size.tsx @@ -0,0 +1,70 @@ +import { Editor } from "~/Editor"; +import { Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export type Size = number; +export namespace Size { + export const min = () => 5; + export const preset = () => 50; + export const max = () => 200; + + export const use = () => { + const brush = Editor.Brush.use(); + const setBrush = Editor.Brush.useSet(); + + const set = useCallback( + ( + setSize: number | undefined | ((size: number) => number | undefined) + ) => { + setBrush((brush) => { + const size = + (typeof setSize === "function" ? setSize(brush.size) : setSize) ?? + preset(); + + return { ...brush, size: clamp(min(), size, max()) }; + }); + }, + [setBrush] + ); + + return useMemo(() => [brush.size, set] as const, [brush.size, set]); + }; + + export namespace Shortcuts { + export const use = () => { + const [, setSize] = Editor.Brush.Size.use(); + const [tool] = Editor.Tool.Active.use(); + const enabled = tool === "brush"; + + Shortcut.use( + useMemo( + () => ({ + name: ["Eraser", "Size", "Increase"], + icon: Theme.Icon.Plus, + + keys: "]", + action: () => setSize((size) => size + 5), + + enabled, + }), + [enabled, setSize] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: ["Eraser", "Size", "Decrease"], + icon: Theme.Icon.Minus, + + keys: "[", + action: () => setSize((size) => size - 5), + + enabled, + }), + [enabled, setSize] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/Strength.tsx b/packages/stablestudio-ui/src/Editor/Brush/Strength.tsx new file mode 100644 index 0000000..cb183f5 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/Strength.tsx @@ -0,0 +1,34 @@ +import { Editor } from "~/Editor"; + +export type Strength = number; +export namespace Strength { + export const min = () => 0; + export const preset = () => max(); + export const max = () => 1; + + export const use = () => { + const brush = Editor.Brush.use(); + const setBrush = Editor.Brush.useSet(); + + const set = useCallback( + ( + setStrength: + | number + | undefined + | ((strength: number) => number | undefined) + ) => { + setBrush((brush) => { + const strength = + (typeof setStrength === "function" + ? setStrength(brush.strength) + : setStrength) ?? preset(); + + return { ...brush, strength: clamp(min(), strength, max()) }; + }); + }, + [setBrush] + ); + + return useMemo(() => [brush.strength, set] as const, [brush.strength, set]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Brush/index.tsx b/packages/stablestudio-ui/src/Editor/Brush/index.tsx new file mode 100644 index 0000000..708b949 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Brush/index.tsx @@ -0,0 +1,244 @@ +import Konva from "konva"; +import { KonvaEventObject } from "konva/lib/Node"; +import { Image } from "react-konva"; + +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; +import { Theme } from "~/Theme"; + +import { Blur } from "./Blur"; +import { Cursor } from "./Cursor"; +import { MaskLine } from "./MaskLine"; +import { Panel } from "./Panel"; +import { Shortcuts } from "./Shortcut"; +import { Sidebar } from "./Sidebar"; +import { Size } from "./Size"; +import { Strength } from "./Strength"; + +export type Brush = { + size: Brush.Size; + strength: Brush.Strength; + blur: Brush.Blur; +}; + +export function Brush() { + const [activeTool] = Editor.Tool.Active.use(); + const maskLine = useRef(new MaskLine()); + const line = useRef(null); + const stageRef = Editor.Canvas.use(); + + const [, setForceUpdate] = useState(0); + + const entities = Editor.Entities.useMap(); + const setEntities = Editor.Entities.useSet(); + + const { blur, size, strength } = Editor.Brush.use(); + + useEffect(() => { + if (maskLine.current && line.current) { + maskLine.current.line = line.current; + } + }, []); + + Editor.Canvas.useMouseDown( + (e: KonvaEventObject) => { + if (activeTool === "brush" && e.evt.button === 0 && stageRef) { + const scale = stageRef.current?.scaleX() || 1; + const mousePos = stageRef.current?.getPointerPosition() || { + x: 0, + y: 0, + }; + const pos = stageRef.current?.getPosition() || { x: 0, y: 0 }; + maskLine.current.restart(size / scale, blur, strength, [ + // put out the first point (w/ end so it draws a dot) + mousePos.x / scale - pos.x / scale, + mousePos.y / scale - pos.y / scale, + + mousePos.x / scale - pos.x / scale, + mousePos.y / scale - pos.y / scale, + ]); + + setForceUpdate((n) => n + 1); + } + }, + [activeTool, size, blur, stageRef?.current, maskLine.current] + ); + + Editor.Canvas.useMouseUp(() => { + if (activeTool === "brush") { + // go through all images that our points line up to and raserize them + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const promises: Promise[] = []; + + entities.forEach((image) => { + if (image.type !== "image") { + return; + } + + for (let i = 0; i < maskLine.current.points.length; i += 2) { + const x = maskLine.current.points[i]; + const y = maskLine.current.points[i + 1]; + + if (!x || !y) return; + + // check if image x/y/w/h contains point x/y + // making sure to account for stroke width as circle radius + if ( + Brush.circleIntersectsRectange( + x, + y, + maskLine.current.strokeWidth + maskLine.current.strokeBlur, + image.x, + image.y, + image.width, + image.height + ) + ) { + // rasterize this image + promises.push(MaskLine.applyToImage(image, maskLine.current)); + break; + } + } + }); + + Promise.all(promises).then((newImages) => { + const newEntities: Map = new Map(); + + newImages.forEach((newImage) => { + if (!newImage) { + return; + } + + const e = entities.get(newImage.id) as Editor.Image; + + newEntities.set(e.id, { + ...e, + element: newImage as HTMLImageElement, + }); + }); + + setEntities((entities) => new Map([...entities, ...newEntities])); + + maskLine.current.clear(); + }); + } + }, [activeTool, maskLine.current]); + + Editor.Canvas.useMouseMove( + (e: KonvaEventObject) => { + if ( + activeTool === "brush" && + maskLine.current && + e.evt.buttons === 1 && + stageRef + ) { + const scale = stageRef.current?.scaleX() || 1; + const mousePos = stageRef.current?.getPointerPosition() || { + x: 0, + y: 0, + }; + const pos = stageRef.current?.getPosition() || { x: 0, y: 0 }; + + maskLine.current.addPoint( + mousePos.x / scale - pos.x / scale, + mousePos.y / scale - pos.y / scale + ); + } + }, + [activeTool, maskLine.current, stageRef?.current] + ); + + return ( + + ); +} + +export declare namespace Brush { + export { MaskLine, Cursor, Panel, Sidebar, Shortcuts, Blur, Size, Strength }; +} + +export namespace Brush { + Brush.MaskLine = MaskLine; + Brush.Panel = Panel; + Brush.Cursor = Cursor; + Brush.Sidebar = Sidebar; + Brush.Shortcuts = Shortcuts; + Brush.Blur = Blur; + Brush.Size = Size; + Brush.Strength = Strength; + + export function circleIntersectsRectange( + cx: number, + cy: number, + radius: number, + rx: number, + ry: number, + rw: number, + rh: number + ) { + const circleDistanceX = Math.abs(cx - (rx + rw / 2)); + const circleDistanceY = Math.abs(cy - (ry + rh / 2)); + + if (circleDistanceX > rw / 2 + radius) { + return false; + } + if (circleDistanceY > rh / 2 + radius) { + return false; + } + + if (circleDistanceX <= rw / 2) { + return true; + } + if (circleDistanceY <= rh / 2) { + return true; + } + + const cornerDistanceSq = + (circleDistanceX - rw / 2) ** 2 + (circleDistanceY - rh / 2) ** 2; + + return cornerDistanceSq <= radius ** 2; + } + + export const preset = (): Brush => ({ + size: Size.preset(), + strength: Strength.preset(), + blur: Blur.preset(), + }); + + const useState = GlobalState.create(() => ({ brush: preset() })); + + export const use = (): Brush => useState(({ brush }) => brush); + export const useSet = () => { + const brush = use(); + const set = useState.setState; + return useCallback( + (setBrush: React.SetStateAction) => + set({ + brush: typeof setBrush === "function" ? setBrush(brush) : setBrush, + }), + [set, brush] + ); + }; + + export function Tool() { + return ( + <> + + + + + + ); + } + + export function Icon() { + return ; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/Center.tsx b/packages/stablestudio-ui/src/Editor/Camera/Center.tsx new file mode 100644 index 0000000..7cba9f0 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/Center.tsx @@ -0,0 +1,22 @@ +import { Editor } from "~/Editor"; + +export namespace Center { + export const useGet = () => { + const canvas = Editor.Canvas.use(); + return useCallback(() => { + if (!canvas.current) return; + + const position = canvas.current.getPosition(); + const size = canvas.current.getSize(); + const scale = { + x: canvas.current.scaleX(), + y: canvas.current.scaleY(), + }; + + return { + x: (-position.x + size.width / 2) / scale.x, + y: (-position.y + size.height / 2) / scale.y, + }; + }, [canvas]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/Hand.tsx b/packages/stablestudio-ui/src/Editor/Camera/Hand.tsx new file mode 100644 index 0000000..4cb9fdf --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/Hand.tsx @@ -0,0 +1,31 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Hand { + export function Tool() { + return ( + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + const setTool = Editor.Tool.Active.useSet(); + Shortcut.use( + useMemo( + () => ({ + name: ["Camera", "Hand"], + icon: Theme.Icon.Hand, + + keys: "h", + action: () => setTool("hand"), + }), + [setTool] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/Reset.tsx b/packages/stablestudio-ui/src/Editor/Camera/Reset.tsx new file mode 100644 index 0000000..a6b5b51 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/Reset.tsx @@ -0,0 +1,41 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Reset { + export const use = () => { + const box = Editor.Entities.useSurroundingBox(); + const setCamera = Editor.Camera.useSet(); + return useCallback(() => { + if (!box) return; + setCamera(box); + }, [box, setCamera]); + }; + + export function Tool() { + const reset = use(); + return ( + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + const reset = Reset.use(); + Shortcut.use( + useMemo( + () => ({ + name: ["Camera", "Reset"], + icon: Theme.Icon.LocateFixed, + + keys: ["Meta", "9"], + action: reset, + }), + [reset] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/Shortcut.tsx b/packages/stablestudio-ui/src/Editor/Camera/Shortcut.tsx new file mode 100644 index 0000000..11e6ba5 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/Shortcut.tsx @@ -0,0 +1,9 @@ +import { Editor } from "~/Editor"; + +export namespace Shortcuts { + export const use = () => { + // Editor.Camera.Hand.Shortcuts.use(); + Editor.Camera.Reset.Shortcuts.use(); + Editor.Camera.Zoom.Shortcuts.use(); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/Zoom.tsx b/packages/stablestudio-ui/src/Editor/Camera/Zoom.tsx new file mode 100644 index 0000000..ce5e352 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/Zoom.tsx @@ -0,0 +1,124 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Zoom { + export function Tools() { + return ( + <> + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + In.Shortcuts.use(); + Out.Shortcuts.use(); + Reset.Shortcuts.use(); + }; + } + + export namespace In { + export const use = () => { + const canvasRef = Editor.Canvas.use(); + return useCallback(() => { + if (!canvasRef?.current) return; + Editor.Canvas.changeZoom(1.1, canvasRef.current); + }, [canvasRef]); + }; + + export function Tool() { + const zoomIn = use(); + return ( + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + const zoomIn = In.use(); + Shortcut.use( + useMemo( + () => ({ + name: ["Camera", "Zoom", "In"], + icon: Theme.Icon.ZoomIn, + + keys: ["Meta", "="], + action: zoomIn, + }), + [zoomIn] + ) + ); + }; + } + } + + export namespace Out { + export const use = () => { + const canvasRef = Editor.Canvas.use(); + return useCallback(() => { + if (!canvasRef?.current) return; + Editor.Canvas.changeZoom(0.9, canvasRef.current); + }, [canvasRef]); + }; + + export function Tool() { + const zoomOut = use(); + return ( + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + const zoomOut = Out.use(); + Shortcut.use( + useMemo( + () => ({ + name: ["Camera", "Zoom", "Out"], + icon: Theme.Icon.ZoomIn, + + keys: ["Meta", "-"], + action: zoomOut, + }), + [zoomOut] + ) + ); + }; + } + } + + export namespace Reset { + export const use = () => { + const canvasRef = Editor.Canvas.use(); + return useCallback(() => { + if (!canvasRef?.current) return; + Editor.Canvas.changeZoom(undefined, canvasRef.current); + }, [canvasRef]); + }; + + export namespace Shortcuts { + export const use = () => { + const resetZoom = Reset.use(); + Shortcut.use( + useMemo( + () => ({ + name: ["Camera", "Zoom", "Reset"], + icon: Theme.Icon.Search, + + keys: ["Meta", "0"], + action: resetZoom, + }), + [resetZoom] + ) + ); + }; + } + } +} diff --git a/packages/stablestudio-ui/src/Editor/Camera/index.tsx b/packages/stablestudio-ui/src/Editor/Camera/index.tsx new file mode 100644 index 0000000..58f14a1 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Camera/index.tsx @@ -0,0 +1,63 @@ +import { Editor } from "~/Editor"; +import { Box } from "~/Geometry"; + +import { Center } from "./Center"; +import { Hand } from "./Hand"; +import { Reset } from "./Reset"; +import { Shortcuts } from "./Shortcut"; +import { Zoom } from "./Zoom"; + +export type Camera = Box; + +export declare namespace Camera { + export { Center, Hand, Reset, Shortcuts, Zoom }; +} + +export namespace Camera { + Camera.Center = Center; + Camera.Hand = Hand; + Camera.Reset = Reset; + Camera.Shortcuts = Shortcuts; + Camera.Zoom = Zoom; + + export const useSet = () => { + const padding = 25; + const canvas = Editor.Canvas.use(); + + return useCallback( + (boxWithoutPadding: Box) => { + if (!canvas?.current) return; + + const box = { + x: boxWithoutPadding.x - padding, + y: boxWithoutPadding.y - padding, + width: boxWithoutPadding.width + padding * 2, + height: boxWithoutPadding.height + padding * 2, + }; + + const scale = Math.min( + canvas.current.width() / box.width, + canvas.current.height() / box.height + ); + + canvas.current.scale({ x: scale, y: scale }); + canvas.current.position({ + x: + -box.x * canvas.current.scaleX() + + canvas.current.width() / 2 - + (box.width * canvas.current.scaleX()) / 2, + + y: + -box.y * canvas.current.scaleY() + + canvas.current.height() / 2 - + (box.height * canvas.current.scaleY()) / 2, + }); + }, + [canvas, padding] + ); + }; + + export function Tools() { + return ; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/Event.tsx b/packages/stablestudio-ui/src/Editor/Canvas/Event.tsx new file mode 100644 index 0000000..0ec33ce --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/Event.tsx @@ -0,0 +1,7 @@ +import Konva from "konva"; + +export type Event = Konva.KonvaEventObject; +export namespace Event { + export type Mouse = Event; + export type Drag = Event; +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/ExportBox.tsx b/packages/stablestudio-ui/src/Editor/Canvas/ExportBox.tsx new file mode 100644 index 0000000..1290141 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/ExportBox.tsx @@ -0,0 +1,231 @@ +import Konva from "konva"; +import { Rect } from "react-konva"; +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; + +// TODO: Move to `Editor.Export` +export function ExportBox() { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const rectRef = useRef(null!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const strokeRectRef = useRef(null!); + + const { origin, setOrigin, size, setSize } = ExportBox.useState(); + + const [activeTool] = Editor.Tool.Active.use(); + const setActiveTool = Editor.Tool.Active.useSet(); + + const entities = Editor.Entities.use(); + const selection = Editor.Selection.use(); + const select = Editor.Selection.useSelect(); + + Editor.Canvas.useMouseDown( + (e) => { + if (activeTool === "export" && e.evt.button === 0) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const stage = e.target.getStage()!; + const scale = stage.scaleX() || 1; + const mousePos = stage.getPointerPosition() || { x: 0, y: 0 }; + const pos = stage.getPosition() || { x: 0, y: 0 }; + + setOrigin(() => [ + mousePos.x / scale - pos.x / scale, + mousePos.y / scale - pos.y / scale, + ]); + setSize(() => [0, 0]); + + if (rectRef.current) { + rectRef.current.visible(true); + strokeRectRef.current.visible(true); + } + } + }, + [activeTool, rectRef.current] + ); + + Editor.Canvas.useMouseMove( + (e) => { + if ( + activeTool === "export" && + origin !== null && + rectRef.current?.visible() && + e.evt.buttons === 1 + ) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const stage = e.target.getStage()!; + const scale = stage.scaleX() || 1; + const mousePos = stage.getPointerPosition() || { x: 0, y: 0 }; + const pos = stage.getPosition() || { x: 0, y: 0 }; + + const newWidth = mousePos.x / scale - pos.x / scale - origin[0]; + const newHeight = mousePos.y / scale - pos.y / scale - origin[1]; + + if (newWidth < 0) { + setOrigin((origin) => [ + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + origin![0] + newWidth, + strokeRectRef.current.y(), + ]); + setSize((size) => [-newWidth, size[1]]); + } else { + setSize((size) => [newWidth, size[1]]); + } + + if (newHeight < 0) { + setOrigin((origin) => [ + strokeRectRef.current.x(), + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + origin![1] + newHeight, + ]); + setSize((size) => [size[0], -newHeight]); + } else { + setSize((size) => [size[0], newHeight]); + } + + const selected: string[] = []; + let doUpd = false; + entities.forEach((image) => { + if (image.type !== "image") return; + if ( + Editor.Canvas.rectContainsRect( + rectRef.current.x(), + rectRef.current.y(), + rectRef.current.width(), + rectRef.current.height(), + + image.x, + image.y, + image.width, + image.height + ) + ) { + selected.push(image.id); + + if (!selection.has(image.id)) { + doUpd = true; + } + } else if (selection.has(image.id)) { + doUpd = true; + } + }); + + if (doUpd) { + select(selected); + } + } + }, + [activeTool, rectRef.current, origin] + ); + + Editor.Canvas.useMouseUp(() => { + if (activeTool === "export" && origin !== null && rectRef.current) { + const bounds = { + x: rectRef.current.x(), + y: rectRef.current.y(), + width: rectRef.current.width(), + height: rectRef.current.height(), + }; + + let images = entities.flatMap((e) => + e.type === "image" && e.visible ? [e] : [] + ); + + // check if the pixels are like less than 10 + if (rectRef.current.width() < 10 && rectRef.current.height() < 10) { + // we just want to render clicked on entity + const image = Editor.Canvas.Render.getImageFromPoint( + rectRef.current.x(), + rectRef.current.y(), + entities + .flatMap((e) => (e.type === "image" && e.visible ? [e] : [])) + .reverse() + ); + + if (image) { + const img: Editor.Image = { + ...image, + x: 0, + y: 0, + type: "image", + id: "export", + index: 0, + locked: false, + visible: true, + }; + images = [img]; + + bounds.x = image.x; + bounds.y = image.y; + bounds.width = image.width; + bounds.height = image.height; + } + } + + const canvas = Editor.Canvas.Render.createImageFromBox( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + images.reverse(), + 1 + ); + + if (canvas) { + const link = document.createElement("a"); + link.download = "export.png"; + link.href = canvas.toDataURL("image/png"); + link.click(); + canvas.remove(); + } + + setOrigin(() => null); + setActiveTool("select"); + } + }, [activeTool, rectRef.current]); + + return ( + <> + {origin && size && ( + <> + + + + )} + + ); +} + +export namespace ExportBox { + export const useState = GlobalState.create<{ + origin: [number, number] | null; + size: [number, number]; + setOrigin: ( + fn: (origin: [number, number] | null) => [number, number] | null + ) => void; + setSize: (fn: (size: [number, number]) => [number, number]) => void; + }>((set) => ({ + origin: null, + size: [0, 0], + setOrigin: (fn) => set((state) => ({ ...state, origin: fn(state.origin) })), + setSize: (fn) => set((state) => ({ ...state, size: fn(state.size) })), + })); +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/Grid.tsx b/packages/stablestudio-ui/src/Editor/Canvas/Grid.tsx new file mode 100644 index 0000000..f05e151 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/Grid.tsx @@ -0,0 +1,100 @@ +import Konva from "konva"; +import { Shape } from "react-konva"; + +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export function Grid() { + const dark = Theme.useDark(); + const stageRef = Editor.Canvas.use(); + + if (1) return null; + + if (!stageRef) { + return null; + } + + const sceneFunc = useCallback( + (context: Konva.Context) => { + if (!stageRef.current) return; + + const scale = stageRef.current.scaleX(); // 2 if zoomed in, 0.5 if zoomed out + + // dont draw grid if zoomed out too far + if (scale < 0.25) { + return; + } + + const stageSize = stageRef.current.getSize(); // get the size of the stage + const stagePos = stageRef.current.position(); // top left corner of viewport + const dotSize = 10; // size of the dots + const spacing = 64; // distance between dots + + // draw the background that gets replaced by the lines later (this will be the color of the grid dots) + context.beginPath(); + context.globalCompositeOperation = "source-over"; + context.fillStyle = dark + ? "rgba(255,255,255, 0.05)" + : "rgba(0, 0, 0, 0.04)"; + + context.fillRect( + -stagePos.x / scale, + -stagePos.y / scale, + stageSize.width / scale, + stageSize.height / scale + ); + context.closePath(); + + // draw lines with destination-out to make holes where they arent intersecting that are grid dots + context.globalCompositeOperation = "destination-out"; + context.strokeStyle = "white"; + + // calc lineWidth based on dotSize and scale. The lines should be just big enough to leave dots of the size of dotSize + const lineWidth = spacing - dotSize; + + // starting with the first line that enters the viewport, draw lines that are spaced by spacing with a width of lineWidth + // this will draw lines that are spaced by spacing and are just big enough to leave dots of the size of dotSize + context.lineWidth = lineWidth; + for ( + let x = + -stagePos.x / scale - + lineWidth * 2 - + dotSize / 2 + + (spacing - ((-stagePos.x / scale - lineWidth / 2) % spacing)); + x < stageSize.width / scale - stagePos.x / scale + lineWidth / 2; + x += spacing + ) { + context.beginPath(); + context.moveTo(x, -stagePos.y / scale - lineWidth / 2); + context.lineTo( + x, + stageSize.height / scale - stagePos.y / scale + lineWidth / 2 + ); + context.stroke(); + context.closePath(); + } + + for ( + let y = + -stagePos.y / scale - + lineWidth * 2 - + dotSize / 2 + + (spacing - ((-stagePos.y / scale - lineWidth / 2) % spacing)); + y < stageSize.height / scale - stagePos.y / scale + lineWidth / 2; + y += spacing + ) { + context.beginPath(); + context.moveTo(-stagePos.x / scale, y); + context.lineTo((-stagePos.x + stageSize.width) / scale, y); + context.stroke(); + context.closePath(); + } + + // reset the globalCompositeOperation + context.globalCompositeOperation = "source-over"; + }, + [stageRef, dark] + ); + + return ; +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/Render.tsx b/packages/stablestudio-ui/src/Editor/Canvas/Render.tsx new file mode 100644 index 0000000..5d7db2e --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/Render.tsx @@ -0,0 +1,305 @@ +import { Editor } from "~/Editor"; +import { Box, Boxes } from "~/Geometry"; + +export namespace Render { + export type RenderMode = "txt2img" | "img2img" | "inpaint"; + + export type RenderData = { + mode: RenderMode; + init: string; + mask: string; + }; + + export function getImageFromPoint( + x: number, + y: number, + images: Editor.Images + ) { + return images.find( + (image) => + image.x <= x && + image.x + image.width >= x && + image.y <= y && + image.y + image.height >= y && + image.element?.src && + image.visible + ); + } + + export function getBoundsOfImages(images: Editor.Images) { + return Boxes.surroundingBox(images) as Box; + } + + export function createImageFromBox( + x: number, + y: number, + width: number, + height: number, + images: Editor.Images, + opacity: number, + autoSize?: boolean, + useOriginals?: boolean + ) { + // check if there are any images intersecting with the box + const intersectingImages = images.filter( + (image) => + image.x <= x + width && + image.x + image.width >= x && + image.y <= y + height && + image.y + image.height >= y && + image.visible && + (useOriginals ? image.original.element?.src : image.element?.src) + ); + + console.log(intersectingImages, images); + + if (autoSize && intersectingImages.length > 0) { + // resize the box to fit the images + const bounds = getBoundsOfImages(intersectingImages); + x = bounds.x; + y = bounds.y; + width = bounds.width; + height = bounds.height; + } + + if (intersectingImages.length > 0) { + // get the canvas + const workingCanvas = document.createElement("canvas"); + + workingCanvas.width = width; + workingCanvas.height = height; + + const workingCtx = workingCanvas.getContext("2d"); + if (!workingCtx) return; + + intersectingImages.sort().forEach((image) => { + const scale = Math.max( + image.width / image.original.width, + image.height / image.original.height + ); + + const offset = { + x: -((image.width - image.original.width * scale) / 2) / scale, + y: -((image.height - image.original.height * scale) / 2) / scale, + }; + + if (!image.element?.src) return; + console.log("drawing image", image.element.src); + if (useOriginals ? image.original.element : image.element) { + workingCtx.drawImage( + image.element, + + offset.x, + offset.y, + image.width / scale, + image.height / scale, + + image.x - x, + image.y - y, + image.width, + image.height + ); + + if (useOriginals && image.original.element) { + // draw the original *behind* the image so as to preserve inpainted regions + workingCtx.globalCompositeOperation = "destination-over"; + workingCtx.drawImage( + image.original.element, + + offset.x, + offset.y, + image.width / scale, + image.height / scale, + + image.x - x, + image.y - y, + image.width, + image.height + ); + + workingCtx.globalCompositeOperation = "source-over"; + } + } + }); + + // now draw bg + if (useOriginals) { + // draw 50% gray on the canvas + workingCtx.fillStyle = "rgb(128, 128, 128)"; + workingCtx.globalCompositeOperation = "destination-over"; + workingCtx.fillRect(0, 0, workingCanvas.width, workingCanvas.height); + workingCtx.globalCompositeOperation = "source-over"; + } + + // if there's alpha, apply the alpha to the entire canvas at this point + if (opacity < 1) { + console.log("applying opacity", opacity); + workingCtx.globalAlpha = 1 - opacity; + workingCtx.fillStyle = "white"; + workingCtx.globalCompositeOperation = "destination-out"; + workingCtx.fillRect(0, 0, workingCanvas.width, workingCanvas.height); + workingCtx.globalAlpha = 1; + workingCtx.globalCompositeOperation = "source-over"; + } + + return workingCanvas; + } else { + return null; + } + } + + export function getGenerationMetadata( + images: Editor.Images, + box: Box, + opacity: number + ): RenderData | null { + const form = { + x: box.x, + y: box.y, + width: Math.ceil(box.width / 64) * 64, + height: Math.ceil(box.height / 64) * 64, + }; + + if (form.width * form.height > 1_048_576) { + console.log("box is too large"); + return null; + } + + const data: RenderData = { + mode: "txt2img", + init: "", + mask: "", + }; + + // check if there are any images intersecting with the box + const workingCanvas = createImageFromBox( + form.x, + form.y, + form.width, + form.height, + images, + opacity, + false, + false + ); + + const initImgCanvas = createImageFromBox( + form.x, + form.y, + form.width, + form.height, + images, + opacity, + false, + true + ); + + console.log("workingCanvas", workingCanvas?.width, workingCanvas?.height); + console.log("initImgCanvas", initImgCanvas?.width, initImgCanvas?.height); + + if (workingCanvas && initImgCanvas) { + // make a new canvas and draw the cutout into it + const maskCanvas = document.createElement("canvas"); + maskCanvas.width = initImgCanvas.width; + maskCanvas.height = initImgCanvas.height; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const maskCtx = maskCanvas.getContext("2d")!; + maskCtx.drawImage( + workingCanvas, + 0, + 0, + workingCanvas.width, + workingCanvas.height, + 0, + 0, + workingCanvas.width, + workingCanvas.height + ); + + // render white where the canvas is transparent and black where the canvas is opaque + // first render everything that exists as black using globalCompositeOperation = 'source-in' + maskCtx.fillStyle = "white"; + maskCtx.globalCompositeOperation = "source-in"; + maskCtx.fillRect(0, 0, maskCanvas.width, maskCanvas.height); + + // then just draw a rectangle over the canvas with white and use globalCompositeOperation = 'source-out' + maskCtx.fillStyle = "black"; + maskCtx.globalCompositeOperation = "destination-atop"; + maskCtx.fillRect(0, 0, maskCanvas.width, maskCanvas.height); + + maskCtx.globalCompositeOperation = "source-over"; + + // check if the mask is all white + const maskData = maskCtx.getImageData( + 0, + 0, + maskCanvas.width, + maskCanvas.height + ); + const maskBuffer32 = new Uint32Array(maskData.data.buffer); + let allWhite = true; + let nonWhitePxls = 0; + for (let i = 0; i < maskBuffer32.length; i++) { + // check if the pixel isnt white + if (maskBuffer32[i] !== 0xffffffff) { + nonWhitePxls++; + } + + // if there is enough non-white pixels, then we can stop checking + if (nonWhitePxls > 25) { + allWhite = false; + break; + } + } + + if (!allWhite) { + console.log("INPAINTING"); + data.mode = "inpaint"; + + // blur the greyscale mask a little bit to soften the edges between white and black + maskCtx.filter = "blur(20px)"; + maskCtx.drawImage( + maskCanvas, + 0, + 0, + maskCanvas.width, + maskCanvas.height, + 0, + 0, + maskCanvas.width, + maskCanvas.height + ); + } else { + console.log("IMG 2 IMG"); + data.mode = "img2img"; + + if (opacity >= 1) { + // if the opacity is one and we are doing img2img, make the mask 85% white (15% black) + maskCtx.fillStyle = "rgb(210, 210, 210)"; + maskCtx.fillRect(0, 0, maskCanvas.width, maskCanvas.height); + } + } + + // now render that to a PNG + data.mask = maskCanvas.toDataURL("image/png", 1); + + // download init img + // const m = document.createElement("a"); + // m.href = data.mask; + // m.download = "mask.png"; + // m.click(); + + data.init = initImgCanvas.toDataURL("image/png", 1); + + // download init img + // const a = document.createElement("a"); + // a.href = data.init; + // a.download = "init.png"; + // a.click(); + } else { + console.log("TEXT 2 IMG"); + } + + return data; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/SelectBox.tsx b/packages/stablestudio-ui/src/Editor/Canvas/SelectBox.tsx new file mode 100644 index 0000000..a1fae3e --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/SelectBox.tsx @@ -0,0 +1,141 @@ +import Konva from "konva"; +import { Rect } from "react-konva"; +import { Editor } from "~/Editor"; + +export function SelectBox() { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const rectRef = useRef(null!); + + const [origin, setOrigin] = useState<[number, number] | null>(null); + const [activeTool] = Editor.Tool.Active.use(); + + const entities = Editor.Entities.use(); + const selection = Editor.Selection.use(); + const select = Editor.Selection.useSelect(); + + const doSelection = useCallback(() => { + const selected: string[] = []; + let doUpd = false; + entities.forEach((image) => { + if (image.type !== "dream") return; + if ( + Editor.Canvas.rectContainsRect( + rectRef.current.x(), + rectRef.current.y(), + rectRef.current.width(), + rectRef.current.height(), + + image.x, + image.y, + image.width, + image.height + ) + ) { + selected.push(image.id); + + if (!selection.has(image.id)) { + doUpd = true; + } + } else if (selection.has(image.id)) { + doUpd = true; + } + }); + + if (doUpd) { + select(selected); + } + }, [entities, selection, select]); + + Editor.Canvas.useMouseDown( + (e) => { + if (activeTool === "select" && e.evt.button === 0) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const stage = e.target.getStage()!; + const scale = stage.scaleX() || 1; + const mousePos = stage.getPointerPosition() || { x: 0, y: 0 }; + const pos = stage.getPosition() || { x: 0, y: 0 }; + + const newOrigin: [number, number] = [ + mousePos.x / scale - pos.x / scale, + mousePos.y / scale - pos.y / scale, + ]; + + setOrigin(newOrigin); + + if (rectRef.current) { + rectRef.current.position({ x: newOrigin[0], y: newOrigin[1] }); + rectRef.current.width(0); + rectRef.current.height(0); + rectRef.current.visible(true); + } + } + }, + [activeTool, rectRef.current] + ); + + Editor.Canvas.useMouseMove( + (e) => { + if ( + activeTool === "select" && + origin !== null && + rectRef.current?.visible() && + e.evt.buttons === 1 + ) { + const stage = rectRef.current?.getStage(); + + if (!stage) { + console.error("No stage"); + return; + } + + stage.setPointersPositions(e.evt); + const scale = stage.scaleX() || 1; + const mousePos = stage.getPointerPosition() || { x: 0, y: 0 }; + const pos = stage.getPosition() || { x: 0, y: 0 }; + + const newWidth = mousePos.x / scale - pos.x / scale - origin[0]; + const newHeight = mousePos.y / scale - pos.y / scale - origin[1]; + + if (newWidth < 0) { + rectRef.current.position({ + x: origin[0] + newWidth, + y: rectRef.current.y(), + }); + rectRef.current.width(-newWidth); + } else { + rectRef.current.width(newWidth); + } + + if (newHeight < 0) { + rectRef.current.position({ + x: rectRef.current.x(), + y: origin[1] + newHeight, + }); + rectRef.current.height(-newHeight); + } else { + rectRef.current.height(newHeight); + } + + doSelection(); + } + }, + [activeTool, rectRef.current, origin] + ); + + Editor.Canvas.useMouseUp( + (e) => { + if (activeTool === "select" && origin !== null && rectRef.current) { + e.cancelBubble = true; + rectRef.current.visible(false); + + // select everything in the box + doSelection(); + + setOrigin(null); + } + }, + [activeTool, rectRef.current] + ); + + return ; +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/Setup.tsx b/packages/stablestudio-ui/src/Editor/Canvas/Setup.tsx new file mode 100644 index 0000000..a2b3391 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/Setup.tsx @@ -0,0 +1,62 @@ +import Konva from "konva"; +import { useDebounce, useWindowSize } from "react-use"; + +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; + +export namespace Setup { + const useGlobalState = GlobalState.create<{ + id?: ID; + canvas: React.RefObject; + loading: boolean; + zoom: number; + }>(() => ({ + canvas: React.createRef(), + loading: true, + zoom: 1, + })); + + export const useCanvas = () => useGlobalState(({ canvas }) => canvas); + + export const use = () => { + useAutomaticResize(); + + const resize = Editor.Canvas.useResize(); + const resetEditor = Editor.Reset.use(); + + const state = useGlobalState(); + const setState = useGlobalState.setState; + + const [id] = useState(ID.create()); + + useEffect(() => { + if (id === state.id) return; + setState({ id, loading: true }); + }, [id, state.id, setState]); + + useEffect(() => { + if (!state.loading || !state.id || !state.canvas.current) return; + + resize(); + resetEditor(); + setState({ loading: false }); + }, [state.loading, state.id, state.canvas, setState, resize, resetEditor]); + + return state; + }; + + const useAutomaticResize = () => { + const { height, width } = useWindowSize(); + const resize = Editor.Canvas.useResize(); + useDebounce(resize, 1000, [width, height, resize]); + }; + + export const setZoom = (zoom: number) => { + useGlobalState.setState({ zoom }); + }; + + export const useZoom = () => { + const { zoom } = useGlobalState(({ zoom }) => ({ zoom })); + return zoom; + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Canvas/index.tsx b/packages/stablestudio-ui/src/Editor/Canvas/index.tsx new file mode 100644 index 0000000..fdfae37 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Canvas/index.tsx @@ -0,0 +1,326 @@ +import Konva from "konva"; +import { Layer, Stage } from "react-konva"; + +import { Editor } from "~/Editor"; + +import { Event } from "./Event"; +import { ExportBox } from "./ExportBox"; +import { Grid } from "./Grid"; +import { Render } from "./Render"; +import { Setup } from "./Setup"; + +export function Canvas({ children }: React.PropsWithChildren) { + const ref = useRef(null); + + const { canvas, loading } = Setup.use(); + + const moving = useRef(false); + + const [activeTool] = Editor.Tool.Active.use(); + const clearSelection = Editor.Selection.useClear(); + + return ( +
event.preventDefault()} + > + ) => { + e.cancelBubble = true; + + if ( + (e.evt.buttons === 4 || + (e.evt.button === 0 && activeTool === "select")) && + moving.current + ) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const stage = e.target.getStage()!; + + // move the stage by the amount of the latest movement + const oldPos = stage.position(); + + stage.position({ + x: oldPos.x + e.evt.movementX, + y: oldPos.y + e.evt.movementY, + }); + + if (activeTool !== "brush") { + document.body.style.cursor = "grabbing"; + } + } + }} + onWheel={(e: Konva.KonvaEventObject) => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + Canvas.changeZoomRelative(e.target.getStage()!, e.evt.deltaY); + }} + onMouseDown={(e: Konva.KonvaEventObject) => { + if ( + e.evt.buttons === 4 || + (e.evt.button === 0 && activeTool === "select") + ) { + moving.current = true; + } + + if (activeTool === "select") { + // should only bubble up if no images were clicked (unselect all images) + clearSelection(); + } + }} + onMouseUp={() => { + moving.current = false; + if (activeTool !== "brush") { + document.body.style.cursor = "default"; + } + }} + onMouseLeave={() => { + moving.current = false; + }} + > + + + + {children} + + {/* */} + + + +
+ ); +} + +export declare namespace Canvas { + export { Event, ExportBox, Render }; +} + +export namespace Canvas { + export const use = () => Setup.useCanvas(); + + export const useGetContainer = () => { + const canvas = use(); + return useCallback( + () => canvas.current?.container().parentElement, + [canvas] + ); + }; + + export const useResize = () => { + const canvas = use(); + const getContainer = useGetContainer(); + return useCallback(() => { + if (!canvas.current) return; + + const container = getContainer(); + if (!container) return; + + const width = container.offsetWidth; + const height = container.offsetHeight; + + if (!width || !height) return; + + canvas.current.setSize({ width, height }); + }, [canvas, getContainer]); + }; + + export function useStageEvent( + events: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback: (e: Konva.KonvaEventObject) => void, + deps: unknown[] = [] + ) { + const stageRef = use(); + useEffect( + () => { + if (stageRef && stageRef.current) { + stageRef.current.on(events, callback); + return () => { + stageRef.current?.off(events, callback); + }; + } + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [events, callback, stageRef, ...deps] + ); + + return stageRef?.current || null; + } + + // hook to get mousemove event from stage + export function useMouseMove( + callback: (e: Konva.KonvaEventObject) => void, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + deps: any[] = [] + ) { + return useStageEvent("mousemove", callback, deps); + } + + // hook to get mouseup event from stage + export function useMouseUp( + callback: (e: Konva.KonvaEventObject) => void, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + deps: any[] = [] + ) { + return useStageEvent("mouseup", callback, deps); + } + + // hook to get mousedown event from stage + export function useMouseDown( + callback: (e: Konva.KonvaEventObject) => void, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + deps: any[] = [] + ) { + return useStageEvent("mousedown", callback, deps); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function collectSnapLines(entities: any[]) { + const vertical: number[] = []; + const horizontal: number[] = []; + + entities.forEach((entity) => { + const pos = entity.position(); + const width = entity.width(); + const height = entity.height(); + + vertical.push(pos.x, pos.x + width); + horizontal.push(pos.y, pos.y + height); + }); + + return { vertical, horizontal }; + } + + export function rectContainsRect( + srx: number, + sry: number, + srw: number, + srh: number, + + drx: number, + dry: number, + drw: number, + drh: number + ): boolean { + // check if the source rect contains the destination rect in any way + return ( + srx <= drx && + sry <= dry && + srx + srw >= drx + drw && + sry + srh >= dry + drh + ); + } + + export function changeZoom(factor: number | undefined, stage: Konva.Stage) { + const oldScale = stage.scaleX(); + const pointer = { + x: stage.width() / 2, + y: stage.height() / 2, + }; + + const mousePointTo = { + x: (pointer.x - stage.x()) / oldScale, + y: (pointer.y - stage.y()) / oldScale, + }; + + const newScale = factor ? oldScale * factor : 1; + + stage.scale({ x: newScale, y: newScale }); + + const newPos = { + x: pointer.x - mousePointTo.x * newScale, + y: pointer.y - mousePointTo.y * newScale, + }; + + stage.position(newPos); + stage.batchDraw(); + } + + export function changeZoomRelative( + stage: Konva.Stage, + delta: number, + mousePos?: { x: number; y: number } + ) { + if (delta === 0) return; + + const oldScale = stage.scaleX(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const pointer = stage.getPointerPosition()!; + + const mousePointTo = mousePos || { + x: (pointer.x - stage.x()) / oldScale, + y: (pointer.y - stage.y()) / oldScale, + }; + + const direction = delta > 0 ? -1 : 1; + + const newScale = + direction > 0 ? oldScale * (1 + 0.02) : oldScale * (1 - 0.02); + + stage.scale({ x: newScale, y: newScale }); + + const newPos = { + x: pointer.x - mousePointTo.x * newScale, + y: pointer.y - mousePointTo.y * newScale, + }; + + stage.position(newPos); + stage.batchDraw(); + + // set zoom in canvas store + const zoom = stage.scaleX(); + Setup.setZoom(zoom); + } + + export function useTriggerWheelEvent() { + const stage = use(); + return useCallback( + (e: WheelEvent) => { + if (e.deltaY === 0) { + // this happens if people have a touchpad/mouse that can scroll horizontally + return; + } + + if (stage && stage.current) { + stage.current.setPointersPositions(e); + changeZoomRelative(stage.current, e.deltaY); + } + }, + [stage] + ); + } + + export function useTriggerMouseMoveEvent() { + const stage = use(); + return useCallback( + (e: MouseEvent) => { + if (stage && stage.current) { + stage.current.fire( + "mousemove", + { + evt: e, + }, + true + ); + } + }, + [stage] + ); + } + + Canvas.Render = Render; + Canvas.ExportBox = ExportBox; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Box.tsx b/packages/stablestudio-ui/src/Editor/Dream/Box.tsx new file mode 100644 index 0000000..efa63eb --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Box.tsx @@ -0,0 +1,60 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +export function Box({ id, showHandles }: { id: ID; showHandles?: boolean }) { + const { input } = Generation.Image.Input.use(id); + const selected = Editor.Selection.useSelected(id); + const [dream] = Editor.Entity.use(id); + const loading = Generation.Image.Output.useIsGenerating( + dream ? dream?.outputID : undefined + ); + + if (!input) return null; + return ( + <> +
+ + {!selected && ( +
+ )} +
+ {selected && showHandles && !input.model.includes("xl") && ( + <> + + + + + + + + + + )} +
+
+ + ); +} + +function Handle({ className }: Styleable) { + const size = Editor.Entity.Handle.size(); + return ( +
+ ); +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Choose/index.tsx b/packages/stablestudio-ui/src/Editor/Dream/Choose/index.tsx new file mode 100644 index 0000000..5d674d1 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Choose/index.tsx @@ -0,0 +1,78 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +export namespace Choose { + export const use = (id: ID) => { + const flatten = Editor.Entities.useFlatten(); + const entities = Editor.Entities.use(); + const [entity, setEntity] = Editor.Entity.use(id); + const createImage = Editor.Image.Create.use(); + const { autoFlatten } = Editor.State.use(); + + return useCallback( + (image: Generation.Image) => { + if (!entity || !image.src) return; + + const title = + Generation.Image.Input.get(image.inputID)?.prompts[0].text ?? "Image"; + + const intersectingImages = entities.filter( + (image) => + image.type === "image" && + image.x < entity.x + entity.width && + image.x + image.width > entity.x && + image.y < entity.y + entity.height && + image.y + image.height > entity.y && + image.element?.src && + image.visible && + image.id !== id + ); + + const element = new window.Image(); + element.src = image.src; + + element.onload = () => { + const original = { + element, + width: element.width, + height: element.height, + }; + + if (intersectingImages.length >= 1 && autoFlatten) { + intersectingImages.push({ + ...Editor.Image.preset(), + index: entities.length, + x: entity.x, + y: entity.y, + width: entity.width, + height: entity.height, + original, + element, + title, + }); + + // flatten everything into one image layer + flatten(intersectingImages as Editor.Images); + } else { + createImage({ + title, + x: entity.x, + y: entity.y, + width: entity.width, + height: entity.height, + original, + element, + }); + } + }; + + setEntity((entity) => { + entity.locked = false; + entity.outputID = undefined; + entity.choicesPage = 0; + }); + }, + [autoFlatten, createImage, entities, entity, flatten, id, setEntity] + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Create/Shortcut.tsx b/packages/stablestudio-ui/src/Editor/Dream/Create/Shortcut.tsx new file mode 100644 index 0000000..d79968e --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Create/Shortcut.tsx @@ -0,0 +1,21 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Shortcuts { + export const use = () => { + const createDream = Editor.Dream.Create.use(); + Shortcut.use( + useMemo( + () => ({ + name: ["Dream", "Create"], + icon: Theme.Icon.Plus, + + keys: ["Meta", "d"], + action: () => createDream(), + }), + [createDream] + ) + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Create/index.tsx b/packages/stablestudio-ui/src/Editor/Dream/Create/index.tsx new file mode 100644 index 0000000..95cd0e2 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Create/index.tsx @@ -0,0 +1,102 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +import { Shortcuts } from "./Shortcut"; + +export declare namespace Create { + export { Shortcuts }; +} + +export namespace Create { + Create.Shortcuts = Shortcuts; + + type Options = { + allowOverlap?: boolean; + + dream?: Partial; + inputID?: ID; + }; + + export const use = () => { + const [inputs, setInputs] = Generation.Image.Inputs.use(); + + const entities = Editor.Entities.use(); + const setEntities = Editor.Entities.useSet(); + const select = Editor.Selection.useSelect(); + const getCameraCenter = Editor.Camera.Center.useGet(); + + return useCallback( + (options?: Options) => { + const id = options?.dream?.id ?? ID.create(); + const optionsInput = options?.inputID + ? inputs[options.inputID] + : undefined; + + const center = getCameraCenter(); + + const createDream = ( + initial: Editor.Dream = { + ...Editor.Dream.preset(), + ...options?.dream, + id, + index: entities.length, + }, + triesLeft = 10 + ): Editor.Dream => { + if (triesLeft === 0 || options?.allowOverlap) return initial; + + const entityCentered = !center + ? initial + : { + ...initial, + x: center.x - initial.width / 2, + y: center.y - initial.height / 2, + }; + + const overlappingEntity = entities.find( + ({ x, y, width, height }) => + entityCentered.x === x && + entityCentered.y === y && + entityCentered.width === width && + entityCentered.height === height + ); + + const offsetMax = 20; + return !overlappingEntity + ? entityCentered + : createDream( + { + ...entityCentered, + x: entityCentered.x + offsetMax * (Math.random() * 2 - 1), + y: entityCentered.y + offsetMax * (Math.random() * 2 - 1), + }, + triesLeft - 1 + ); + }; + + const entity = createDream(); + + entity.height = optionsInput?.height ?? entity.height; + entity.width = optionsInput?.width ?? entity.width; + + const input = { + ...Generation.Image.Input.initial(id), + ...optionsInput, + + id, + seed: 0, + }; + + setInputs((inputs) => ({ ...inputs, [id]: input })); + setEntities((previousEntities) => + new Map(previousEntities).set(id, entity) + ); + + select(id); + + return entity; + }, + [inputs, getCameraCenter, entities, setEntities, setInputs, select] + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Dreams.tsx b/packages/stablestudio-ui/src/Editor/Dream/Dreams.tsx new file mode 100644 index 0000000..ed581a3 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Dreams.tsx @@ -0,0 +1,6 @@ +import { Editor } from "~/Editor"; + +export type Dreams = Editor.Dream[]; +export namespace Dreams { + export const use = () => Editor.Entities.useType("dream"); +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Pagination.tsx b/packages/stablestudio-ui/src/Editor/Dream/Pagination.tsx new file mode 100644 index 0000000..7c20e93 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Pagination.tsx @@ -0,0 +1,99 @@ +import { AnimatePresence, motion } from "framer-motion"; +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Theme } from "~/Theme"; + +export function Pagination({ id }: { id: ID }) { + const [dream, setDream] = Editor.Entity.use(id); + const selected = Editor.Selection.useSelected(id); + const onChoose = Editor.Dream.Choose.use(id); + const output = Generation.Image.Output.use(dream?.outputID); + + const choiceCount = output?.imageIDs.length ?? 0; + const pages = + choiceCount > Editor.Dream.Results.pageSize() - 1 + ? Math.ceil(choiceCount / Editor.Dream.Results.pageSize()) + : choiceCount; + + const pageCount = dream?.lastMode !== "txt2img" ? choiceCount : pages; + const page = dream?.choicesPage ?? 0; + + const onPaginate = useCallback( + (newPage: number) => { + setDream((entity) => { + entity.choicesPage = newPage; + }); + }, + [setDream] + ); + + const onCancel = useCallback(() => { + setDream((entity) => { + entity.outputID = undefined; + entity.locked = false; + }); + }, [setDream]); + + const images = Generation.Images.useFromIDs(...(output?.imageIDs ?? [])); + const current = images?.[page]; + + return ( +
+ + {pageCount > 1 && selected && ( + +
+ current?.src && onChoose(current)} + > + Select + + + Cancel + + +
+
+ {page + 1} + /{pageCount} +
+ onPaginate(page > 0 ? page - 1 : pageCount - 1)} + transparent + size="lg" + /> + onPaginate(page >= pageCount - 1 ? 0 : page + 1)} + transparent + size="lg" + /> +
+ + )} + +
+ ); +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Render/index.tsx b/packages/stablestudio-ui/src/Editor/Dream/Render/index.tsx new file mode 100644 index 0000000..c608ca4 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Render/index.tsx @@ -0,0 +1,61 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +export namespace Render { + export const use = (id: ID) => { + const create = Generation.Image.Create.use(); + const entities = Editor.Entities.use(); + const [entity, setEntity] = Editor.Entity.use(id); + return useCallback(() => { + if (!entity) return; + + const input = Generation.Image.Input.get(id); + if (!input) return; + + setEntity((entity) => (entity.locked = true)); + const data = Editor.Canvas.Render.getGenerationMetadata( + entities + .filter((e) => e.type === "image" && e.visible) + .reverse() as Editor.Image[], + entity, + 1 + ); + + console.log(data); + + Generation.Image.Input.set(id, (input) => { + console.log(data); + input.init = data?.init + ? { + base64: data.init, + mask: false, + weight: 1, + } + : null; + input.mask = data?.mask + ? { + base64: data.mask, + mask: true, + weight: 1, + } + : null; + }); + + create({ + inputID: id, + modifiers: { + strength: 0, + }, + onStarted(output) { + if (!output) return; + setEntity((entity) => { + entity.outputID = output.id; + }); + }, + onException() { + setEntity((entity) => (entity.locked = false)); + }, + }); + }, [entity, setEntity, entities, create, id]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/Results.tsx b/packages/stablestudio-ui/src/Editor/Dream/Results.tsx new file mode 100644 index 0000000..f552d4a --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/Results.tsx @@ -0,0 +1,137 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Theme } from "~/Theme"; + +function Choice({ + choice, + onChoose, + filtered, +}: { + choice: string; + onChoose: () => void; + filtered?: boolean; +}) { + const [currentSrc, setCurrentSrc] = useState(choice); + + useEffect(() => { + const i = new Image(); + i.src = choice; + i.onload = () => setCurrentSrc(choice); + }, [choice]); + + return ( +
+
+ + + {filtered && } +
+
+
+ + {/* */} + +
+
+
+ ); +} + +export function Results({ id }: { id: ID }) { + const [entity] = Editor.Entity.use(id); + const onChoose = Editor.Dream.Choose.use(id); + const output = Generation.Image.Output.use(entity?.outputID); + + const pageSize = + output && + entity && + (output?.imageIDs?.length ?? 0) >= Results.pageSize() && + entity?.lastMode === "txt2img" + ? Results.pageSize() + : 1; + + const images = Generation.Images.useFromIDs( + ...(output && entity + ? output?.imageIDs?.slice( + (entity.choicesPage ?? 0) * pageSize, + ((entity.choicesPage ?? 0) + 1) * pageSize + ) ?? [] + : []) + ); + + const firstImage = images[0]; + if (!entity || !firstImage) return null; + + if (images && images.length === 1 && firstImage.src) { + return ( + onChoose(firstImage)} + filtered={false} + /> + ); + } + + return ( +
1 && + "pointer-events-auto bg-zinc-300 p-2 dark:bg-zinc-900" + )} + > + {images && + images + .filter((choice) => choice.src) + .map((choice) => ( + onChoose(choice)} + filtered={false} + /> + ))} +
+ ); +} + +export namespace Results { + export const pageSize = () => 4; +} diff --git a/packages/stablestudio-ui/src/Editor/Dream/index.tsx b/packages/stablestudio-ui/src/Editor/Dream/index.tsx new file mode 100644 index 0000000..9970d43 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Dream/index.tsx @@ -0,0 +1,80 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; + +import { Box } from "./Box"; +import { Choose } from "./Choose"; +import { Create } from "./Create"; +import { Pagination } from "./Pagination"; +import { Render } from "./Render"; +import { Results } from "./Results"; + +export * from "./Dreams"; + +export type Dream = Editor.Entity.Definition<{ + type: "dream"; + outputID?: ID; + choicesPage?: number; + lastMode?: Editor.Canvas.Render.RenderMode; +}>; + +export function Dream({ id }: { id: ID }) { + const [size, setSize] = useState({ width: 0, height: 0 }); + const { input } = Generation.Image.Input.use(id); + return ( + + {Editor.Floating.use({ + id, + ...size, + content: , + })} + {Editor.Floating.use({ + id: id + "pagination", + ...size, + content: , + })} + {Editor.Floating.use({ + id: id + "results", + ...size, + content: , + })} + + ); +} + +export declare namespace Dream { + export { Choose, Create, Pagination, Render, Results }; +} + +export namespace Dream { + Dream.Choose = Choose; + Dream.Create = Create; + Dream.Pagination = Pagination; + Dream.Render = Render; + Dream.Results = Results; + + export const preset = (): Omit => ({ + id: ID.create(), + type: "dream", + x: 0, + y: 0, + width: 512, + height: 512, + locked: false, + visible: true, + outputID: undefined, + }); + + export const use = (id: string) => Editor.Entity.useType(id, "dream"); +} diff --git a/packages/stablestudio-ui/src/Editor/Entity/Entities/Sidebar.tsx b/packages/stablestudio-ui/src/Editor/Entity/Entities/Sidebar.tsx new file mode 100644 index 0000000..122b069 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Entity/Entities/Sidebar.tsx @@ -0,0 +1,250 @@ +import { App } from "~/App"; +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Theme } from "~/Theme"; + +export namespace Sidebar { + export function Section() { + const entities = Editor.Entities.use(); + const createDream = Editor.Dream.Create.use(); + const deleteEntities = Editor.Entities.useDelete(); + const selected = Editor.Selection.use(); + const openFiles = Editor.Image.Import.useOpenFiles(); + + const { dreams, images, selectedDreams, selectedImages } = useMemo(() => { + const dreams = entities.filter((e) => e.type === "dream"); + const images = entities.filter((e) => e.type === "image"); + const selectedDreams = dreams.filter((d) => selected.has(d.id)); + const selectedImages = images.filter((i) => selected.has(i.id)); + return { dreams, images, selectedDreams, selectedImages }; + }, [entities, selected]); + + return ( + <> + +
+ createDream()} + /> + {selectedDreams.length > 0 && dreams.length > 0 && ( + + deleteEntities(...selectedDreams.map((d) => d.id)) + } + /> + )} +
+
+ {useMemo( + () => + dreams.length > 0 ? ( + dreams.flatMap(({ id }, index) => [ + , + ]) + ) : ( +
+ You don't have any dreams yet +
+ createDream()} + className="text-brand-300 cursor-pointer hover:underline" + > + Create + +  one to get started +
+ ), + [createDream, dreams] + )} +
+
+ +
+ openFiles()} + /> + {selectedImages.length > 0 && images.length > 0 && ( + + deleteEntities(...selectedImages.map((i) => i.id)) + } + /> + )} +
+
+ {useMemo( + () => + images.length > 0 ? ( + images + .filter((e) => e.type === "image") + .flatMap(({ id }, index) => [ + , + ]) + ) : ( +
+ You don't have any images yet +
+ Generate or  + openFiles()} + className="text-brand-300 cursor-pointer hover:underline" + > + import + +  some +
+ ), + [images, openFiles] + )} +
+
+ + ); + } +} + +function Entity({ id, ...props }: { id: ID; index: number; total: number }) { + const setCamera = Editor.Camera.useSet(); + + const title = Editor.Entity.useTitle(id); + const [entity] = Editor.Entity.use(id); + + const select = Editor.Selection.useSelect(); + const selection = Editor.Selection.use(); + const selected = useMemo(() => selection.has(id), [selection, id]); + + const onClick = useCallback(() => { + if (!entity) return; + if (!selected) select(entity.id); + setCamera(entity); + }, [entity, selected, select, setCamera]); + + return !entity ? null : ( +
+ +
+
+ {title} +
+
+ +
+ ); +} + +const Preview = ({ entity }: { entity: Editor.Entity }) => { + const src = entity.type === "image" && entity.element?.src; + return ( +
+ + {src && ( +
+ )} +
+ {!src && ( + + )} + {entity && entity.type === "dream" && } +
+
+ ); +}; + +function Loading({ id }: { id: ID }) { + const { input } = Generation.Image.Input.use(id); + input; + + return ; +} + +const Controls = ({ id }: { id: ID }) => { + const deleteEntity = Editor.Entities.useDelete(); + const [entity, setEntity] = Editor.Entity.use(id); + return ( +
+ {useMemo(() => { + const className = "hidden group-hover:block"; + + const visibilityIcon = ( + { + event.stopPropagation(); + setEntity((entity) => { + entity.visible = !entity.visible; + }); + }} + /> + ); + + const lockIcon = ( + { + event.stopPropagation(); + setEntity((entity) => { + entity.locked = !entity.locked; + }); + }} + /> + ); + + const removeIcon = ( + { + event.stopPropagation(); + deleteEntity(id); + }} + /> + ); + + return ( +
+ {visibilityIcon} + {lockIcon} + {removeIcon} +
+ ); + }, [entity?.visible, entity?.locked, setEntity, deleteEntity, id])} +
+ ); +}; diff --git a/packages/stablestudio-ui/src/Editor/Entity/Entities/Snapping.tsx b/packages/stablestudio-ui/src/Editor/Entity/Entities/Snapping.tsx new file mode 100644 index 0000000..665185c --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Entity/Entities/Snapping.tsx @@ -0,0 +1,139 @@ +import { Line } from "react-konva"; +import { Editor } from "~/Editor"; +import { Box } from "~/Geometry"; + +export namespace Snapping { + export type Line = { type: "origin" | "center" | "end" } & ( + | { x: number } + | { y: number } + ); + export type Lines = Line[]; + + export const use = (id?: ID, snapDistance = 10) => { + const entities = Editor.Entities.use(); + const { allowSnapping } = Editor.State.use(); + const [lines, setLines] = useState([]); + + const snapLines = useMemo( + () => + allowSnapping + ? entities + .filter((entity) => entity.id !== id) + .flatMap((entity) => { + const { x, y, width, height } = entity; + return [ + { x: x + width / 2, type: "center" }, + { y: y + height / 2, type: "center" }, + { x: x + width, type: "end" }, + { y: y + height, type: "end" }, + { x, type: "origin" }, + { y, type: "origin" }, + ] as Line[]; + }) + : [], + [allowSnapping, entities, id] + ); + + const snapComponent = () => { + if (!allowSnapping) return null; + + return ( + <> + {lines.map((line, index) => { + if ("x" in line) { + return ( + + ); + } + if ("y" in line) { + return ( + + ); + } + })} + + ); + }; + + const snap = useCallback( + (box: Box) => { + if (!allowSnapping) return box; + + const entitySnapLines = [ + { x: box.x + box.width / 2, type: "center" as const }, + { x: box.x + box.width, type: "end" as const }, + { x: box.x, type: "origin" as const }, + { y: box.y + box.height / 2, type: "center" as const }, + { y: box.y + box.height, type: "end" as const }, + { y: box.y, type: "origin" as const }, + ]; + + const distances = snapLines + .flatMap((snapLine) => { + return entitySnapLines + .filter((entityLine) => "x" in snapLine === "x" in entityLine) + .map((entityLine) => { + const axis = "x" in snapLine ? "x" : "y"; + + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + //@ts-ignore + const distance = Math.abs(snapLine[axis] - entityLine[axis]); + + return distance <= snapDistance + ? { distance, line: snapLine, type: entityLine.type } + : null; + }); + }) + .filter((d) => d !== null) + .sort((a, b) => (a?.distance ?? 0) - (b?.distance ?? 0)); + + if (distances.length > 0) { + // get one x and one y + const Xline = distances.find((d) => d && "x" in (d?.line ?? {})); + const Yline = distances.find((d) => d && "y" in (d?.line ?? {})); + + if (Xline && "x" in Xline.line) { + if (Xline.type === "origin") { + box.x = Xline.line.x; + } else if (Xline.type === "center") { + box.x = Xline.line.x - box.width / 2; + } else if (Xline.type === "end") { + box.x = Xline.line.x - box.width; + } + } + + if (Yline && "y" in Yline.line) { + if (Yline.type === "origin") { + box.y = Yline.line.y; + } else if (Yline.type === "center") { + box.y = Yline.line.y - box.height / 2; + } else if (Yline.type === "end") { + box.y = Yline.line.y - box.height; + } + } + + setLines( + [Xline?.line, Yline?.line].filter((l) => l !== undefined) as Lines + ); + return box; + } + + setLines([]); + return box; + }, + [allowSnapping, snapDistance, snapLines] + ); + + return [snapComponent, snap, setLines] as const; + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Entity/Entities/index.tsx b/packages/stablestudio-ui/src/Editor/Entity/Entities/index.tsx new file mode 100644 index 0000000..3687caa --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Entity/Entities/index.tsx @@ -0,0 +1,212 @@ +import { Layer } from "react-konva"; + +import { Editor } from "~/Editor"; +import { Boxes } from "~/Geometry"; +import { UndoRedo } from "~/UndoRedo"; + +import { Sidebar } from "./Sidebar"; +import { Snapping } from "./Snapping"; + +export type Entities = Map; + +export function Entities() { + const entities = Entities.use(); + return useMemo( + () => ( + <> + + {[...entities.reverse()] + .filter((entity) => entity.type === "image" && entity.visible) + .map((entity) => ( + + ))} + + + + {[...entities.reverse()] + .filter((entity) => entity.type === "dream" && entity.visible) + .map((entity) => ( + + ))} + + + + ), + [entities] + ); +} + +const useState = UndoRedo.create<{ + entities: Entities; + setEntities: (entities: React.SetStateAction) => void; +}>((set) => ({ + entities: new Map(), + setEntities: (setEntities) => + set(({ entities }) => ({ + entities: + typeof setEntities === "function" ? setEntities(entities) : setEntities, + })), +})); + +export declare namespace Entities { + export { Sidebar, Snapping }; +} + +export namespace Entities { + Entities.Sidebar = Sidebar; + Entities.Snapping = Snapping; + + export type List = Editor.Entity[]; + + export const get = () => useState.getState().entities; + export const set = (entities: React.SetStateAction) => + useState.getState().setEntities(entities); + + export const useMap = () => useState(({ entities }) => entities); + export const use = () => { + const entities = useMap(); + return useMemo( + () => [...entities.values()].sort((a, b) => b.index - a.index), + [entities] + ); + }; + + export const useType = (type: Editor.Entity["type"]) => { + const entities = use(); + return useMemo( + () => entities.filter((entity) => entity.type === type), + [entities, type] + ); + }; + + export const useSet = () => { + const { setEntities } = useState(); + return setEntities; + }; + + export const useSurroundingBox = () => { + const entities = use(); + return useMemo(() => Boxes.surroundingBox(entities), [entities]); + }; + + export const useDelete = () => { + const { setEntities } = useState(); + const selected = Editor.Selection.use(); + const select = Editor.Selection.useSelect(); + const deselect = Editor.Selection.useClear(); + return useCallback( + (...ids: ID[]) => + setEntities((previousEntities) => { + const list = [...previousEntities.values()]; + const entities = new Map(); + + list.forEach((entity) => { + if (ids.includes(entity.id)) return; + entities.set(entity.id, entity); + }); + + [...entities.values()].forEach((entity, index) => + entities.set(entity.id, { ...entity, index }) + ); + + const newSelection = Array.from(selected).filter( + (id) => !ids.includes(id) + ); + + if (newSelection.length === 0) { + deselect(); + } else { + select(newSelection[0] ?? [], ...newSelection.slice(1)); + } + + return entities; + }), + [setEntities, selected, deselect, select] + ); + }; + + export const useFlatten = () => { + const createImage = Editor.Image.Create.useFromURL(); + const deleteEntities = useDelete(); + const flatten = useCallback( + (images: Editor.Images) => { + const bounds = Editor.Canvas.Render.getBoundsOfImages(images); + const canvas = Editor.Canvas.Render.createImageFromBox( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + images as Editor.Images, + 1 + ); + + return new Promise((resolve) => { + canvas?.toBlob(async (blob) => { + if (!blob) return; + + const newEntity = await createImage(URL.createObjectURL(blob), { + ...Editor.Image.preset(), + x: bounds.x, + y: bounds.y, + width: bounds.width, + height: bounds.height, + title: "Flattened image", + }); + deleteEntities(...images.map(({ id }) => id)); + + return resolve(newEntity); + }); + }); + }, + [createImage, deleteEntities] + ); + + return flatten; + }; + + export const useDeleteEverything = () => { + const entities = use(); + const deleteEntities = useDelete(); + return useMemo( + () => + entities.length >= 1 + ? (predicate: (entity: Editor.Entity) => boolean = () => true) => + deleteEntities(...entities.filter(predicate).map(({ id }) => id)) + : undefined, + [entities, deleteEntities] + ); + }; + + export const useChangeOrder = () => { + const state = useState(); + const setState = useState.setState; + return useCallback( + ({ id, direction }: { id: ID; direction: "up" | "down" }) => { + const fromEntity = state.entities.get(id); + if (!fromEntity) return; + + const oldIndex = fromEntity.index; + const newIndex = + direction === "down" + ? Math.max(0, fromEntity.index - 1) + : Math.min(state.entities.size - 1, fromEntity.index + 1); + + if (oldIndex === newIndex) return; + + const toEntity = [...state.entities.values()].find( + (entity) => entity.index === newIndex + ); + + if (!toEntity) return; + + const entities = new Map(state.entities); + + entities.set(fromEntity.id, { ...fromEntity, index: newIndex }); + entities.set(toEntity.id, { ...toEntity, index: fromEntity.index }); + + setState({ entities }); + }, + [state, setState] + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Entity/index.tsx b/packages/stablestudio-ui/src/Editor/Entity/index.tsx new file mode 100644 index 0000000..33ac369 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Entity/index.tsx @@ -0,0 +1,347 @@ +import Konva from "konva"; +import { Group, Rect, Transformer } from "react-konva"; + +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Box, Size } from "~/Geometry"; + +import { Canvas } from "../Canvas"; +import { Setup } from "../Canvas/Setup"; + +export * from "./Entities"; + +export type Entity = Editor.Dream | Editor.Image; + +type Props = React.PropsWithChildren & { + id: ID; + + draggable?: boolean; + selectable?: boolean; + resizable?: boolean; + showHandles?: boolean; + showBorder?: boolean; + + sizeClamp?: Partial; + onSizeChange?: (size: Size) => void; +}; + +export function Entity({ + id, + + draggable = true, + selectable = true, + resizable = true, + + showHandles = true, + showBorder = true, + + onSizeChange, + sizeClamp = { + min: { width: 64, height: 64 }, + max: { width: 8192, height: 8192 }, + }, + + children, +}: Props) { + const [activeTool] = Editor.Tool.Active.use(); + const setCamera = Editor.Camera.useSet(); + + const [entity, setEntity] = Editor.Entity.use(id); + const [dragging, setDragging] = useState(false); + const dragEnabled = draggable && !entity?.locked && activeTool === "select"; + const [SnapLines, snap, setLines] = Editor.Entities.Snapping.use(id); + + const select = Editor.Selection.useSelect(); + const selected = Editor.Selection.useSelected(id); + const selection = Editor.Selection.use(); + const selectEnabled = selectable && activeTool === "select"; + + const groupRef = useRef(null); + const transformerRef = useRef(null); + + const zoom = Setup.useZoom(); + useEffect(() => { + if (entity && dragging) { + // drop entity if global zoom changes + groupRef.current?.stopDrag(); + transformerRef.current?.stopTransform(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [zoom]); + + const [local, setLocalRaw] = useState(() => { + const size = { + width: entity?.width ?? 512, + height: entity?.height ?? 512, + }; + + const local = { + x: entity?.x ?? 0, + y: entity?.y ?? 0, + ...size, + }; + + onSizeChange?.(size); + return local; + }); + + const setLocal = useCallback( + (setBox: React.SetStateAction>) => { + const box = typeof setBox === "function" ? setBox(local) : setBox; + const size = Size.Clamp.apply( + { + width: box.width ?? local.width, + height: box.height ?? local.height, + }, + sizeClamp + ); + + const snapped = { ...local, ...box, ...size }; + + setLocalRaw(snapped); + onSizeChange?.(size); + + return snapped; + }, + [local, sizeClamp, onSizeChange] + ); + + const onMouseDown = useCallback( + (event: Editor.Canvas.Event.Mouse) => { + event.evt.preventDefault(); + event.cancelBubble = !["brush", "export"].includes(activeTool); + + if (selected || !selectEnabled) return; + + const additionalSelections = event.evt.shiftKey ? selection : []; + + select(id, ...additionalSelections); + }, + [activeTool, selected, selectEnabled, selection, select, id] + ); + + const onDoubleClick = useCallback(() => setCamera(local), [local, setCamera]); + + const onTransformStart = useCallback((event: Editor.Canvas.Event.Mouse) => { + if (event.evt.button !== 0) return; + event.evt.preventDefault(); + event.cancelBubble = true; + }, []); + + const onTransform = useCallback( + (event: Editor.Canvas.Event) => { + const x = event.target.x(); + const y = event.target.y(); + + const size = Size.Clamp.apply( + { + width: local.width * event.target.scaleX(), + height: local.height * event.target.scaleY(), + }, + { + min: { width: 64, height: 64 }, + max: { width: 1024, height: 1024 }, + } + ); + + event.target.size(size); + event.target.scale({ x: 1, y: 1 }); + + setLocal({ x, y, ...size }); + !dragging && setDragging(true); + }, + [local.width, local.height, setLocal, dragging] + ); + + const onTransformEnd = useCallback( + (event: Editor.Canvas.Event.Drag) => + setEntity((entity) => { + entity.x = event.target.x(); + entity.y = event.target.y(); + entity.width = event.target.width(); + entity.height = event.target.height(); + setDragging(false); + }), + [setEntity] + ); + + const onDragStart = useCallback( + (event: Editor.Canvas.Event.Drag) => { + if (!dragEnabled) return event.target.stopDrag(); + setDragging(true); + + for (const id of selection) { + const node = groupRef.current?.getStage()?.findOne(`#${id}`); + if (node && node !== event.target && !node.isDragging()) { + node.startDrag(event); + } + } + }, + [dragEnabled, selection] + ); + + const onDragMove = useCallback( + (event: Canvas.Event.Drag) => { + const x = event.target.x(); + const y = event.target.y(); + const snapped = snap({ ...local, x, y }); + event.target.position({ x: snapped.x, y: snapped.y }); + setLocal({ ...snapped, width: local.width, height: local.height }); + }, + [local, setLocal, snap] + ); + + const onDragEnd = useCallback( + (event: Canvas.Event.Drag) => { + setDragging(false); + setEntity((entity) => { + entity.x = event.target.x(); + entity.y = event.target.y(); + }); + setLines([]); + }, + [setEntity, setLines] + ); + + useEffect(() => { + if (dragging) return; + setLocalRaw({ + x: entity?.x ?? local.x, + y: entity?.y ?? local.y, + width: entity?.width ?? local.width, + height: entity?.height ?? local.height, + }); + }, [ + entity?.x, + entity?.y, + entity?.width, + entity?.height, + setLocalRaw, + local.x, + local.y, + local.width, + local.height, + dragging, + ]); + + useEffect(() => { + if (!selected || !transformerRef.current || !groupRef.current) return; + transformerRef.current.nodes([groupRef.current]); + transformerRef.current.getLayer()?.batchDraw(); + }, [selected]); + + const boundFunction = useCallback( + ( + _oldBoundBox: Box & { rotation: number }, + newBoundBox: Box & { rotation: number } + ) => ({ + ...newBoundBox, + ...Size.Clamp.apply(newBoundBox, { + min: { width: 64, height: 64 }, + max: { width: 1024, height: 1024 }, + }), + }), + [] + ); + + if (!entity) return null; + return ( + <> + + + {children} + + {selected && !["brush", "export"].includes(activeTool) && resizable && ( + + )} + + + ); +} + +export namespace Entity { + export type Definition = Box & + Config & { + id: ID; + index: number; + type: Config["type"]; + visible: boolean; + locked: boolean; + title?: string; + }; + + export function use(id: string) { + const entities = Editor.Entities.useMap(); + const setEntities = Editor.Entities.useSet(); + + const entity = useMemo( + () => entities.get(id) as E | undefined, + [id, entities] + ); + + const setEntity = useCallback( + (setEntity: (entity: Mutable) => void) => { + setEntities((previousEntities) => { + const previousEntity = previousEntities.get(id); + return !previousEntity + ? previousEntities + : new Map(previousEntities).set( + id, + copy(previousEntity as E, (entity) => void setEntity(entity)) + ); + }); + }, + [id, setEntities] + ); + + return [entity, setEntity] as const; + } + + export function useType(id: string, type: Entity["type"]) { + const [entity, setEntity] = Editor.Entity.use(id); + return useMemo(() => { + if (entity && entity.type === type) return [entity, setEntity] as const; + }, [type, entity, setEntity]); + } + + export const useTitle = (id: ID): string | undefined => { + const { input } = Generation.Image.Input.use(id); + const [entity] = Editor.Entity.use(id); + return useMemo( + () => entity?.title ?? input?.prompts[0]?.text, + [entity?.title, input?.prompts] + ); + }; + + export namespace Handle { + export const size = () => 12; + } + + export namespace Border { + export const size = () => 2; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Export/Everything.tsx b/packages/stablestudio-ui/src/Editor/Export/Everything.tsx new file mode 100644 index 0000000..907062c --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Export/Everything.tsx @@ -0,0 +1,137 @@ +import { AnimatePresence, motion } from "framer-motion"; +import { Editor } from "~/Editor"; +import { Boxes } from "~/Geometry"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Everything { + export function Tool() { + const { setOrigin, setSize } = Editor.Canvas.ExportBox.useState( + (state) => ({ + setOrigin: state.setOrigin, + setSize: state.setSize, + }) + ); + + const [nothingInView, setNothingInView] = useState(false); + + const entities = Editor.Entities.use(); + const stageRef = Editor.Canvas.use(); + + function getFilteredEntities(): Editor.Images | undefined { + if (!stageRef || !stageRef.current) return undefined; + + const scale = stageRef.current.scaleX() || 1; + const position = stageRef.current.getPosition() || { x: 0, y: 0 }; + + // filter entities in the stageRef visibility (entity x/y/width/height inside of stageRef x/y/width/height) + return entities + .filter( + (entity) => + entity.type === "image" && + entity.visible && + entity.x * scale + position.x >= 0 && + entity.y * scale + position.y >= 0 && + entity.x * scale + entity.width * scale + position.x <= + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + stageRef.current!.width() && + entity.y * scale + entity.height * scale + position.y <= + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + stageRef.current!.height() + ) + .reverse() as Editor.Image[]; + } + + return ( + <> + { + if (stageRef && stageRef.current) { + const filtered = getFilteredEntities(); + if (filtered && filtered.length > 0) { + const bounds = Boxes.surroundingBox(filtered); + if (bounds) { + setOrigin(() => [bounds.x, bounds.y]); + setSize(() => [bounds.width, bounds.height]); + } + } else { + setNothingInView(true); + } + } + }} + onMouseLeave={() => { + setOrigin(() => null); + setSize(() => [0, 0]); + setNothingInView(false); + }} + onClick={() => { + const filtered = getFilteredEntities(); + if (filtered) { + const bounds = Boxes.surroundingBox(filtered); + if (bounds) { + const canvas = Editor.Canvas.Render.createImageFromBox( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + filtered, + 1 + ); + + if (canvas) { + const link = document.createElement("a"); + link.download = "export.png"; + link.href = canvas.toDataURL("image/png"); + link.click(); + canvas.remove(); + } + } + } + + setOrigin(() => null); + setSize(() => [0, 0]); + }} + > + + + + + {nothingInView && ( + +
+

+ No images in view +

+
+
+ )} +
+ + ); + } + + export namespace Shortcuts { + export const use = () => { + Shortcut.use( + useMemo( + () => ({ + name: ["Export", "Everything"], + icon: Theme.Icon.Download, + + keys: ["Meta", "e"], + action: () => + alert("TODO: We need to refactor `Editor.Export.Everything`"), + }), + [] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Export/Selection.tsx b/packages/stablestudio-ui/src/Editor/Export/Selection.tsx new file mode 100644 index 0000000..3e40c2f --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Export/Selection.tsx @@ -0,0 +1,31 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Selection { + export function Tool() { + return ( + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + const setTool = Editor.Tool.Active.useSet(); + Shortcut.use( + useMemo( + () => ({ + name: ["Export", "Selection"], + icon: Theme.Icon.Camera, + + keys: "c", + action: () => setTool("export"), + }), + [setTool] + ) + ); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Export/index.tsx b/packages/stablestudio-ui/src/Editor/Export/index.tsx new file mode 100644 index 0000000..7084ed4 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Export/index.tsx @@ -0,0 +1,29 @@ +import { Editor } from "~/Editor"; + +import { Everything } from "./Everything"; +import { Selection } from "./Selection"; + +export declare namespace Export { + export { Everything, Selection }; +} + +export namespace Export { + Export.Everything = Everything; + Export.Selection = Selection; + + export function Tools() { + return ( + + + + + ); + } + + export namespace Shortcuts { + export const use = () => { + Everything.Shortcuts.use(); + Selection.Shortcuts.use(); + }; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Floating/index.tsx b/packages/stablestudio-ui/src/Editor/Floating/index.tsx new file mode 100644 index 0000000..e81be58 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Floating/index.tsx @@ -0,0 +1,163 @@ +import Konva from "konva"; +import { Shape } from "react-konva"; + +import { Editor } from "~/Editor"; +import { Box } from "~/Geometry"; +import { GlobalState } from "~/GlobalState"; + +export function Floating() { + const { elements } = Floating.useState(); + const triggerWheelEvent = Editor.Canvas.useTriggerWheelEvent(); + const triggerMouseMoveEvent = Editor.Canvas.useTriggerMouseMoveEvent(); + return ( +
{ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + triggerMouseMoveEvent(e as any); + }} + > + {useMemo( + () => + Object.entries(elements).map( + ([id, { absolute, content, keepOnScreen }]) => { + return ( + + ); + } + ), + [elements] + )} +
+ ); +} + +function Element({ + id, + absolute, + content, + keepOnScreen, +}: { + id: ID; + absolute: Box; + content: React.ReactNode; + keepOnScreen?: boolean; +}) { + const elementRef = useRef(null); + + useEffect(() => { + if (keepOnScreen) { + const element = elementRef.current; + if (!element) return; + + const height = element.getBoundingClientRect().height; + const width = element.getBoundingClientRect().width; + + // make sure the element is not off the screen + const x = Math.min( + Math.max(absolute.x, width), + window.innerWidth - width - 10 + ); + + const y = Math.min( + Math.max(absolute.y, height), + window.innerHeight - height - 10 + ); + + element.style.left = `${x}px`; + element.style.top = `${y}px`; + } + }, [absolute, keepOnScreen]); + + return ( +
+ {content} +
+ ); +} + +export namespace Floating { + export const useState = GlobalState.create<{ + elements: { + [id: ID]: { + absolute: Box; + content: React.ReactNode; + keepOnScreen?: boolean; + }; + }; + }>(() => ({ + elements: {}, + })); + + export function use({ + id, + content, + keepOnScreen, + width = 0, + height = 0, + x = 0, + y = 0, + }: Partial & { + id: ID; + content: React.ReactNode; + keepOnScreen?: boolean; + }) { + const setState = useState.setState; + const setAbsolute = useCallback( + (absolute: Box) => { + setState((state) => ({ + ...state, + elements: { + ...state.elements, + [id]: { + absolute, + content, + keepOnScreen, + }, + }, + })); + }, + [setState, id, content, keepOnScreen] + ); + + const onResize = useCallback( + (_context: unknown, shape: Konva.Shape) => + setAbsolute({ + x: shape.getAbsolutePosition().x, + y: shape.getAbsolutePosition().y, + width: shape.getAbsoluteScale().x * width, + height: shape.getAbsoluteScale().y * height, + }), + [width, height, setAbsolute] + ); + + useEffect( + () => () => + setState((state) => { + const { [id]: _removedElement, ...elements } = state.elements; + return { ...state, elements }; + }), + [id, setState] + ); + + return ; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Image/Create/index.tsx b/packages/stablestudio-ui/src/Editor/Image/Create/index.tsx new file mode 100644 index 0000000..f4af394 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Image/Create/index.tsx @@ -0,0 +1,62 @@ +import { Editor } from "~/Editor"; + +export namespace Create { + export type Options = Partial; + + export const use = () => { + const entities = Editor.Entities.use(); + const setEntities = Editor.Entities.useSet(); + const getCameraCenter = Editor.Camera.Center.useGet(); + return useCallback( + (options?: Options) => { + const image: Editor.Image = { + ...Editor.Image.preset(), + ...options, + index: entities.length, + }; + + const center = getCameraCenter(); + const imageCentered = { + ...image, + x: image.x ?? (center ? center.x - image.width / 2 : 0), + y: image.y ?? (center ? center.y - image.height / 2 : 0), + }; + + setEntities((previousEntities) => + new Map(previousEntities).set(image.id, imageCentered) + ); + + return imageCentered; + }, + [getCameraCenter, entities.length, setEntities] + ); + }; + + export const useFromURL = () => { + const create = use(); + return useCallback( + async (url: URLString, options?: Options): Promise => + new Promise((resolve) => { + const element = new Image(); + element.crossOrigin = "anonymous"; + element.src = url; + element.onload = () => { + const size = { + width: element.width, + height: element.height, + }; + + resolve( + create({ + ...options, + ...size, + element, + original: { ...size, element }, + }) + ); + }; + }), + [create] + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Image/Import/index.tsx b/packages/stablestudio-ui/src/Editor/Image/Import/index.tsx new file mode 100644 index 0000000..1f06ed8 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Image/Import/index.tsx @@ -0,0 +1,77 @@ +import { Editor } from "~/Editor"; + +export namespace Import { + export const useOnDrop = () => { + const canvas = Editor.Canvas.use(); + const createImageFromURL = Editor.Image.Create.useFromURL(); + + return useCallback( + async (event: React.DragEvent) => { + if (!canvas.current) return; + + event.preventDefault(); + canvas.current.setPointersPositions(event); + + const mousePosition = canvas.current.getPointerPosition(); + if (!mousePosition) return; + + const scale = canvas.current.scaleX(); + const position = canvas.current.position(); + const x = (mousePosition.x - position.x) / scale; + const y = (mousePosition.y - position.y) / scale; + + for (const file of event.dataTransfer.files) { + const url = URL.createObjectURL(file); + createImageFromURL(url, { + x, + y, + title: file.name ?? "Imported Image", + }); + } + }, + [canvas, createImageFromURL] + ); + }; + + export const useOpenFiles = () => { + const getCameraCenter = Editor.Camera.Center.useGet(); + const createImageFromURL = Editor.Image.Create.useFromURL(); + + return useCallback(() => { + const center = getCameraCenter(); + if (!center) return; + + const x = center.x; + const y = center.y; + + const input = document.createElement("input"); + input.type = "file"; + input.multiple = true; + input.accept = "image/*"; + input.style.display = "none"; + document.body.appendChild(input); + input.click(); + + input.onchange = () => { + for (const file of input.files ?? []) { + const url = URL.createObjectURL(file); + + const element = new Image(); + element.src = url; + element.onload = () => { + const offset = { + x: element.width / 2, + y: element.height / 2, + }; + + createImageFromURL(url, { + x: x - offset.x, + y: y - offset.y, + title: file.name ?? "Imported Image", + }); + }; + } + }; + }, [createImageFromURL, getCameraCenter]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Image/Sidebar.tsx b/packages/stablestudio-ui/src/Editor/Image/Sidebar.tsx new file mode 100644 index 0000000..2a769b4 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Image/Sidebar.tsx @@ -0,0 +1,73 @@ +import { App } from "~/App"; +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export namespace Sidebar { + export function Tab({ id }: { id: ID }) { + const [entity, setEntity] = Editor.Entity.use(id); + if (!entity) return null; + return ( + <> + +
+
+ + setEntity((entity) => ({ ...entity, x })) + } + /> + + setEntity((entity) => ({ ...entity, y })) + } + /> +
+
+
+ + setEntity((entity) => ({ ...entity, width: w })) + } + /> + + setEntity((entity) => ({ ...entity, height: h })) + } + /> +
+
+
+
+ + ); + } +} diff --git a/packages/stablestudio-ui/src/Editor/Image/index.tsx b/packages/stablestudio-ui/src/Editor/Image/index.tsx new file mode 100644 index 0000000..b06f054 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Image/index.tsx @@ -0,0 +1,71 @@ +import { Rect } from "react-konva"; + +import { Editor } from "~/Editor"; +import { Size } from "~/Geometry"; + +import { Create } from "./Create"; +import { Import } from "./Import"; +import { Sidebar } from "./Sidebar"; + +export type Images = Image[]; +export type Image = Editor.Entity.Definition<{ + type: "image"; + outputID?: ID; + src?: string; + element?: HTMLImageElement; + original: Size & { element?: HTMLImageElement }; +}>; + +export function Image({ id }: { id: ID }) { + const [image] = Editor.Entity.use(id); + const [{ width, height }, setSize] = useState({ width: 0, height: 0 }); + return ( + + {image && ( + + )} + + ); +} + +export declare namespace Image { + export { Create, Import, Sidebar }; +} + +export namespace Image { + Image.Create = Create; + Image.Import = Import; + Image.Sidebar = Sidebar; + + export const preset = (): Omit => { + const size = { + width: 512, + height: 512, + }; + + return { + id: ID.create(), + type: "image", + + visible: true, + locked: false, + + x: 0, + y: 0, + + ...size, + original: size, + }; + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Import/index.tsx b/packages/stablestudio-ui/src/Editor/Import/index.tsx new file mode 100644 index 0000000..a80ab61 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Import/index.tsx @@ -0,0 +1,31 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Router } from "~/Router"; + +export namespace Import { + export const use = (image?: Generation.Image) => { + const navigate = Router.useNavigate(); + const createDream = Editor.Dream.Create.use(); + const createImage = Editor.Image.Create.useFromURL(); + return useCallback(async () => { + if (!image?.src) return; + + const editorImage = await createImage(image.src, { + ...image, + title: Generation.Image.Input.get(image.inputID)?.prompts[0].text, + }); + + createDream({ + inputID: image.inputID, + dream: { + x: editorImage.x, + y: editorImage.y, + width: editorImage.width, + height: editorImage.height, + }, + }); + + navigate("/edit"); + }, [image, createImage, createDream, navigate]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Panel/Panels.tsx b/packages/stablestudio-ui/src/Editor/Panel/Panels.tsx new file mode 100644 index 0000000..2c12918 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Panel/Panels.tsx @@ -0,0 +1,59 @@ +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; + +export function Panels({ + fixed = false, + left, + right, + children, + className, +}: StyleableWithChildren & { + fixed?: boolean; + left?: boolean; + right?: boolean; +}) { + return ( +
+ {children} +
+ ); +} + +export namespace Panels { + const useState = GlobalState.create(() => ({ + topLeft: false, + topRight: false, + bottomLeft: false, + bottomRight: false, + })); + + export const useExpanded = (position: Editor.Panel.Position) => { + const state = useState(); + const setState = useState.setState; + + const expanded = useMemo(() => state[position], [state, position]); + const setExpanded = useCallback( + (setExpanded?: React.SetStateAction) => + setState({ + [position]: + setExpanded === undefined + ? !expanded + : typeof setExpanded === "function" + ? setExpanded(expanded) + : setExpanded, + }), + [position, expanded, setState] + ); + + return [expanded, setExpanded] as const; + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Panel/index.tsx b/packages/stablestudio-ui/src/Editor/Panel/index.tsx new file mode 100644 index 0000000..b4a8ff0 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Panel/index.tsx @@ -0,0 +1,122 @@ +import { Editor } from "~/Editor"; +import { Theme } from "~/Theme"; + +export * from "./Panels"; + +export function Panel({ + visible = true, + position, + icon, + title, + left, + className, + contentClassName, + children, + ...props +}: StyleableWithChildren & { + contentClassName?: string; + visible?: boolean; + position: Panel.Position; + icon?: React.ComponentProps["icon"]; + title?: React.ReactNode; + bar?: React.ReactNode; + left?: React.ReactNode; + onClick?: () => void; +}) { + const [expanded, setExpanded] = Editor.Panels.useExpanded(position); + const bottom = position == "bottomLeft" || position == "bottomRight"; + const right = position === "topRight" || position === "bottomRight"; + + const resizeCanvas = Editor.Canvas.useResize(); + useEffect(resizeCanvas, [expanded, resizeCanvas]); + + const onClick = useCallback( + () => props.onClick ?? setExpanded((expanded) => !expanded), + [props.onClick, setExpanded] + ); + + const Chevron = useCallback( + (props: Styleable) => ( + + ), + [bottom, expanded, right] + ); + + const button = title && children && visible && ( +
+ {!expanded && left} + + {title} + +
+ ); + + const barContent = ( +
+ {props.bar} +
+ ); + + const bar = ( +
+ {right && barContent} +
setExpanded(false)} + className={classes("flex grow cursor-pointer", right && "justify-end")} + > + {button} +
+ {!right && barContent} +
+ ); + + return ( +
+ {!bottom && !expanded && button} + {expanded && children && ( +
+ {expanded && left && ( +
{left}
+ )} + {!bottom && bar} + {children} + {bottom && bar} +
+ )} + {bottom && !expanded && button} +
+ ); +} + +export namespace Panel { + export type Position = "topLeft" | "topRight" | "bottomLeft" | "bottomRight"; +} diff --git a/packages/stablestudio-ui/src/Editor/Reset/index.tsx b/packages/stablestudio-ui/src/Editor/Reset/index.tsx new file mode 100644 index 0000000..5f8f919 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Reset/index.tsx @@ -0,0 +1,10 @@ +import { Editor } from "~/Editor"; + +export namespace Reset { + export const use = () => { + const resetCamera = Editor.Camera.Reset.use(); + return useCallback(() => { + resetCamera(); + }, [resetCamera]); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Selection/Shortcut.tsx b/packages/stablestudio-ui/src/Editor/Selection/Shortcut.tsx new file mode 100644 index 0000000..1bd2b59 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Selection/Shortcut.tsx @@ -0,0 +1,56 @@ +import { Editor } from "~/Editor"; +import { Shortcut as Shortcut } from "~/Shortcut"; +import { Theme } from "~/Theme"; + +export namespace Shortcuts { + export const use = () => { + const selection = Editor.Selection.use(); + const deleteEntities = Editor.Entities.useDelete(); + const setTool = Editor.Tool.Active.useSet(); + const [tool] = Editor.Tool.Active.use(); + + const name = useMemo( + () => `Selection (${selection.size})`, + [selection.size] + ); + + Shortcut.Priority.use( + useMemo( + () => ({ + name, + level: "high", + enabled: selection.size > 0, + }), + [name, selection.size] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: "Select", + icon: Editor.Selection.Icon, + + keys: "v", + action: () => setTool("select"), + }), + [setTool] + ) + ); + + Shortcut.use( + useMemo( + () => ({ + name: [name, "Delete"], + icon: Theme.Icon.Trash, + + keys: [["Backspace"], ["Delete"]], + action: () => deleteEntities(...selection), + + enabled: selection.size > 0 && tool === "select", + }), + [name, selection, tool, deleteEntities] + ) + ); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Selection/index.tsx b/packages/stablestudio-ui/src/Editor/Selection/index.tsx new file mode 100644 index 0000000..cace2ea --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Selection/index.tsx @@ -0,0 +1,84 @@ +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; +import { Theme } from "~/Theme"; + +import { Shortcuts } from "./Shortcut"; + +export type Selection = Set; + +export declare namespace Selection { + export { Shortcuts }; +} + +export namespace Selection { + Selection.Shortcuts = Shortcuts; + + const useState = GlobalState.create(() => ({ + selection: new Set(), + })); + + export const use = () => useState(({ selection }) => selection); + export const useSelect = () => { + const setState = useState.setState; + return useCallback( + (first: ID | ID[], ...rest: ID[]) => { + const ids = [...(typeof first === "string" ? [first] : first), ...rest]; + return setState({ selection: new Set(ids) }); + }, + [setState] + ); + }; + + export const useSelected = (id: ID) => { + const selection = use(); + return useMemo(() => selection.has(id), [id, selection]); + }; + + export const useClear = () => { + const setState = useState.setState; + return useCallback(() => setState({ selection: new Set() }), [setState]); + }; + + export type OnlyOne = ID | undefined; + export namespace OnlyOne { + export const use = (id?: ID) => { + const selection = useState(({ selection }) => selection); + return useMemo(() => { + if (selection.size !== 1 || (id && !selection.has(id))) return; + return id ?? [...selection][0]; + }, [id, selection]); + }; + + export const useSet = (id: ID) => { + const setState = useState.setState; + return useCallback( + (setSelected: React.SetStateAction) => { + setState(({ selection: previousSelection }) => { + const selection = new Set(previousSelection); + const isCurrentlySelected = selection.has(id); + const shouldBeSelected = + typeof setSelected === "function" + ? setSelected(isCurrentlySelected) + : setSelected; + + shouldBeSelected ? selection.add(id) : selection.delete(id); + return { selection }; + }); + }, + [id, setState] + ); + }; + } + + export function Tool() { + return ( + + + + ); + } + + export function Icon(props: React.ComponentProps) { + return ; + } +} diff --git a/packages/stablestudio-ui/src/Editor/Shortcut/index.tsx b/packages/stablestudio-ui/src/Editor/Shortcut/index.tsx new file mode 100644 index 0000000..6b7566b --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Shortcut/index.tsx @@ -0,0 +1,13 @@ +import { Editor } from "~/Editor"; +import { UndoRedo } from "~/UndoRedo"; + +export namespace Shortcuts { + export const use = () => { + UndoRedo.Shortcuts.use(); + Editor.Dream.Create.Shortcuts.use(); + Editor.Brush.Shortcuts.use(); + Editor.Selection.Shortcuts.use(); + Editor.Export.Shortcuts.use(); + Editor.Camera.Shortcuts.use(); + }; +} diff --git a/packages/stablestudio-ui/src/Editor/Sidebar/index.tsx b/packages/stablestudio-ui/src/Editor/Sidebar/index.tsx new file mode 100644 index 0000000..eeecc6d --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Sidebar/index.tsx @@ -0,0 +1,225 @@ +import { App } from "~/App"; +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Router } from "~/Router"; +import { Theme } from "~/Theme"; + +const tips = [ + "You can drag and drop images into the editor to import them", + "Use the V key to switch to the select tool", + "Use the E key to switch to the eraser tool", + "Use the C key to switch to the snapshot tool", + "You can use the mouse wheel to zoom in and out", + "Try using multiple dreams to quickly switch between prompt and style presets", + "You can use the mouse wheel to zoom in and out", + "Hold shift to select multiple layers and move them together", +]; + +export function Sidebar() { + const location = Router.useLocation(); + const selectedID = Editor.Selection.OnlyOne.use(); + const dreams = Editor.Entities.useType("dream") as Editor.Dream[]; + const [inputID, setInputID] = useState(""); + const createDream = Editor.Dream.Render.use(inputID); + + useEffect(() => { + selectedID && setInputID(selectedID); + }, [selectedID]); + + const outputID = useMemo(() => { + const dream = dreams.filter((d) => d.id === selectedID)[0]; + return dream?.outputID; + }, [dreams, selectedID]); + + const generating = Generation.Image.Output.useIsGenerating(outputID); + const isDream = useMemo( + () => dreams.filter(({ id }) => id === selectedID).length > 0, + [dreams, selectedID] + ); + + const bottom = selectedID && ( + + createDream()} + fullWidth + disabled={ + !inputID || + generating || + !(dreams.filter((d) => d.id === selectedID).length > 0) + } + loading={generating} + /> + + ); + + return ( + <> + ( + + Edit + + )} + > + + {isDream && ( + + )} + {!isDream && selectedID && } + {!selectedID && } + + + + + + ); +} + +function EditorSettings({ name }: { name?: string }) { + const { + color, + setColor, + allowSnapping, + setAllowSnapping, + autoFlatten, + setAutoFlatten, + } = Editor.State.use(); + + const pickerRef = useRef(null); + + return ( + +
+
+ +

Snapping

+
+ +
+
+ +

Auto flatten

+
+ +
+
+ +

Background fill

+
+ +
+
{ + if (pickerRef.current) { + pickerRef.current.focus(); + pickerRef.current.click(); + } + }} + > + { + setColor(e.target.value.replace("#", "")); + }} + /> +
+ +
+
+
+
+ ); +} + +function EmptySidebar() { + const createNewDreambox = Editor.Dream.Create.use(); + const uploadImage = Editor.Image.Import.useOpenFiles(); + + const [tipIndex, setTipIndex] = useState( + Math.ceil(Math.random() * (tips.length - 1)) + ); + + return ( + <> + createNewDreambox()} + transparent + /> + } + /> + uploadImage()} + transparent + /> + } + /> + +
+ setTipIndex(Math.ceil(Math.random() * (tips.length - 1))) + } + > +

Tip

+

{tips[tipIndex]}

+
+ + ); +} diff --git a/packages/stablestudio-ui/src/Editor/Tool/Panel.tsx b/packages/stablestudio-ui/src/Editor/Tool/Panel.tsx new file mode 100644 index 0000000..cec3841 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Tool/Panel.tsx @@ -0,0 +1,29 @@ +import { Editor } from "~/Editor"; + +export function Panel() { + const [tool] = Editor.Tool.Active.use(); + + const { body } = useMemo(() => { + switch (tool) { + case "brush": + return { + body: , + }; + + default: + return {}; + } + }, [tool]); + + return ( + + {tool}} + contentClassName="w-[300px]" + > + {body} + + + ); +} diff --git a/packages/stablestudio-ui/src/Editor/Tool/Sidebar.tsx b/packages/stablestudio-ui/src/Editor/Tool/Sidebar.tsx new file mode 100644 index 0000000..b43ea79 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Tool/Sidebar.tsx @@ -0,0 +1,16 @@ +import { Editor } from "~/Editor"; + +export namespace Sidebar { + export function Section() { + const [tool] = Editor.Tool.Active.use(); + return useMemo(() => { + switch (tool) { + case "brush": + return ; + + default: + return null; + } + }, [tool]); + } +} diff --git a/packages/stablestudio-ui/src/Editor/Tool/Tools.tsx b/packages/stablestudio-ui/src/Editor/Tool/Tools.tsx new file mode 100644 index 0000000..265f905 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Tool/Tools.tsx @@ -0,0 +1,19 @@ +import { App } from "~/App"; +import { Editor } from "~/Editor"; + +export function Tools() { + const [sidebar] = App.Sidebar.use("left"); + if (sidebar.tab !== "Edit") return null; + return ( + <> +
+ + + + +
+ +
+ + ); +} diff --git a/packages/stablestudio-ui/src/Editor/Tool/index.tsx b/packages/stablestudio-ui/src/Editor/Tool/index.tsx new file mode 100644 index 0000000..5873e94 --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/Tool/index.tsx @@ -0,0 +1,91 @@ +import { Editor } from "~/Editor"; +import { GlobalState } from "~/GlobalState"; +import { Theme } from "~/Theme"; + +import { Panel } from "./Panel"; +import { Sidebar } from "./Sidebar"; + +export * from "./Tools"; + +export type Tool = "select" | "hand" | "brush" | "export"; + +export function Tool({ + tool, + label, + active, + onClick, + onMouseEnter, + onMouseLeave, + children, +}: React.PropsWithChildren & { + tool?: Editor.Tool; + label?: string; + active?: boolean; + onClick?: () => void; + onMouseEnter?: () => void; + onMouseLeave?: () => void; +}) { + const [activeTool, setActiveTool] = Editor.Tool.Active.use(); + + const content = ( +
+
{ + if (!tool) return; + setActiveTool(tool); + }) + } + onMouseEnter={onMouseEnter} + onMouseLeave={onMouseLeave} + className={classes( + "m-0.5 flex h-10 w-10 cursor-pointer items-center justify-center rounded", + active || tool === activeTool ? "bg-brand-500" : "hover:bg-zinc-700" + )} + > + {children} +
+
+ ); + + return !label ? ( + content + ) : ( + + {content} + + ); +} + +export declare namespace Tool { + export { Panel, Sidebar }; +} + +export namespace Tool { + Tool.Panel = Panel; + Tool.Sidebar = Sidebar; + + export function Group({ children }: React.PropsWithChildren) { + return ( +
{children}
+ ); + } + + export type Active = Tool; + export type State = { + value: Active; + set: (value: Active) => void; + }; + + export namespace Active { + const state = GlobalState.create((set) => ({ + value: "select", + set: (value) => set({ value }), + })); + + export const use = () => [state().value, state().set] as const; + export const useSet = () => state().set; + export const useReset = () => state().set("select"); + } +} diff --git a/packages/stablestudio-ui/src/Editor/TopBar/index.tsx b/packages/stablestudio-ui/src/Editor/TopBar/index.tsx new file mode 100644 index 0000000..15307ba --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/TopBar/index.tsx @@ -0,0 +1,11 @@ +import { App } from "~/App"; + +import { Editor } from ".."; + +export function TopBar() { + return ( + + + + ); +} diff --git a/packages/stablestudio-ui/src/Editor/index.tsx b/packages/stablestudio-ui/src/Editor/index.tsx new file mode 100644 index 0000000..3ccc99e --- /dev/null +++ b/packages/stablestudio-ui/src/Editor/index.tsx @@ -0,0 +1,119 @@ +// import { App } from "~/App"; + +import { GlobalState } from "~/GlobalState"; + +import { Brush } from "./Brush"; +import { Camera } from "./Camera"; +import { Canvas } from "./Canvas"; +import { Dream } from "./Dream"; +import { Entities, Entity } from "./Entity"; +import { Export } from "./Export"; +import { Floating } from "./Floating"; +import { Image, Images } from "./Image"; +import { Import } from "./Import"; +import { Panel, Panels } from "./Panel"; +import { Reset } from "./Reset"; +import { Selection } from "./Selection"; +import { Shortcuts } from "./Shortcut"; +import { Sidebar } from "./Sidebar"; +import { Tool, Tools } from "./Tool"; +import { TopBar } from "./TopBar"; + +export function Editor() { + Shortcuts.use(); + + const createDream = Editor.Dream.Create.use(); + const { color } = Editor.State.use(); + + useEffect(() => { + const entities = Editor.Entities.get(); + if (entities.size > 0) return; + createDream(); + }, [createDream]); + + // App.Breadcrumbs.useSet(["defaultProject", "edit"]); + return useMemo( + () => ( + <> + +
+ + + + +
+ + ), + [color] + ); +} + +export declare namespace Editor { + export { + Brush, + Camera, + Canvas, + Dream, + Entities, + Entity, + Export, + Floating, + Image, + Images, + Import, + Panel, + Panels, + Reset, + Selection, + Shortcuts, + Sidebar, + Tool, + Tools, + }; +} + +export namespace Editor { + Editor.Brush = Brush; + Editor.Camera = Camera; + Editor.Canvas = Canvas; + Editor.Dream = Dream; + Editor.Entities = Entities; + Editor.Entity = Entity; + Editor.Export = Export; + Editor.Floating = Floating; + Editor.Image = Image; + Editor.Import = Import; + Editor.Panel = Panel; + Editor.Panels = Panels; + Editor.Reset = Reset; + Editor.Selection = Selection; + Editor.Shortcuts = Shortcuts; + Editor.Sidebar = Sidebar; + Editor.Tool = Tool; + Editor.Tools = Tools; + + export type State = { + color: string; + setColor: (color: string) => void; + allowSnapping: boolean; + setAllowSnapping: (allowSnapping: boolean) => void; + autoFlatten: boolean; + setAutoFlatten: (autoFlatten: boolean) => void; + }; + + export namespace State { + export const use = GlobalState.create((set) => ({ + color: "121212", + setColor: (color) => set((state) => ({ ...state, color })), + allowSnapping: true, + setAllowSnapping: (allowSnapping) => + set((state) => ({ ...state, allowSnapping })), + autoFlatten: true, + setAutoFlatten: (autoFlatten) => + set((state) => ({ ...state, autoFlatten })), + })); + } +} diff --git a/packages/stablestudio-ui/src/Environment/index.tsx b/packages/stablestudio-ui/src/Environment/index.tsx new file mode 100644 index 0000000..e9842cc --- /dev/null +++ b/packages/stablestudio-ui/src/Environment/index.tsx @@ -0,0 +1,48 @@ +import { CustomError } from "ts-custom-error"; + +declare global { + interface ImportMeta { + readonly env: Environment; + } + + interface ImportMetaEnv { + readonly VITE_GIT_HASH: string; + readonly VITE_USE_EXAMPLE_PLUGIN: string; + } +} + +export type Environment = ImportMetaEnv; +export namespace Environment { + export type VariableName = keyof typeof variables extends `VITE_${infer K}` + ? K + : never; + + const variables = { + VITE_GIT_HASH: import.meta.env.VITE_GIT_HASH, + VITE_USE_EXAMPLE_PLUGIN: import.meta.env.VITE_USE_EXAMPLE_PLUGIN ?? "false", + } as const; + + export function get(name: VariableName): string { + return variables[`VITE_${name}` as const]; + } + + export class MissingVariablesError extends CustomError { + constructor(missingVariables: string[]) { + missingVariables.map((name) => `\`${name}\` is \`undefined\`!`); + super(missingVariables.join("\n")); + } + } + + export function Provider({ children }: React.PropsWithChildren) { + useEffect(() => { + const missingVariables = Object.entries(variables) + .filter(([, value]) => `${value ?? ""}` === "") + .map(([name]) => name); + + if (!missingVariables[0]) return; + throw new Environment.MissingVariablesError(missingVariables); + }, []); + + return <>{children}; + } +} diff --git a/packages/stablestudio-ui/src/Generation/Image/ClipBoard/index.tsx b/packages/stablestudio-ui/src/Generation/Image/ClipBoard/index.tsx new file mode 100644 index 0000000..b5ac771 --- /dev/null +++ b/packages/stablestudio-ui/src/Generation/Image/ClipBoard/index.tsx @@ -0,0 +1,12 @@ +import { Generation } from "~/Generation"; + +export namespace ClipBoard { + export const useCopy = () => + useCallback(async (image: Generation.Image) => { + const blob = await Generation.Image.blob(image); + if (!blob) return; + + const clipboard = new ClipboardItem({ [blob.type]: blob }); + await navigator.clipboard.write([clipboard]); + }, []); +} diff --git a/packages/stablestudio-ui/src/Generation/Image/Controls/Button/index.tsx b/packages/stablestudio-ui/src/Generation/Image/Controls/Button/index.tsx new file mode 100644 index 0000000..397e194 --- /dev/null +++ b/packages/stablestudio-ui/src/Generation/Image/Controls/Button/index.tsx @@ -0,0 +1,61 @@ +import { motion } from "framer-motion"; + +import { Theme } from "~/Theme"; + +export function Buttons({ + className, + children, + y, +}: StyleableWithChildren & { y: number }) { + return ( + + {children} + + ); +} + +export function Button({ + button, + className, + name, + ...props +}: Theme.Button.Props & { + alwaysShow?: boolean; + noBg?: boolean; + button?: React.FunctionComponent; + name?: React.ReactNode; +}) { + const buttonProps: Theme.Button.Props = { + ...props, + outline: false, + className: classes( + className, + "pointer-events-auto bg-transparent", + !props.noBg && + !props.disabled && + "hover:bg-brand-400 dark:hover:bg-brand-400" + ), + }; + + const content = button ? ( + button(buttonProps) + ) : ( + + ); + + return ( + <> + {name ? ( + + {content} + + ) : ( + content + )} + + ); +} diff --git a/packages/stablestudio-ui/src/Generation/Image/Controls/index.tsx b/packages/stablestudio-ui/src/Generation/Image/Controls/index.tsx new file mode 100644 index 0000000..0c511c2 --- /dev/null +++ b/packages/stablestudio-ui/src/Generation/Image/Controls/index.tsx @@ -0,0 +1,121 @@ +import { Editor } from "~/Editor"; +import { Generation } from "~/Generation"; +import { Theme } from "~/Theme"; + +import { Button, Buttons } from "./Button"; + +export function Controls({ image }: { image: Generation.Image }) { + const download = Generation.Image.Download.use(image); + const setInitialImage = Generation.Image.Session.useSetInitialImage(); + const createVariations = Generation.Image.Session.useCreateVariations(image); + const sendToEditor = Editor.Import.use(image); + + const { input } = Generation.Image.Input.use(image.inputID); + const isInitialImage = useMemo( + () => !!input?.init && "src" in input.init && input.init?.src === image.src, + [input, image.src] + ); + + const createVariationsButton = useMemo( + () => + input?.id && + !Generation.Image.Input.isUpscaling(input) && ( + + ); + + if (props.label) { + return ( + + {button} + + ); + } else { + return button; + } +} + +export namespace Button { + export type Prop = React.ReactNode | React.FunctionComponent; + export type Props = StyleableWithChildren & { + size?: Theme.Common.Size; + fullWidth?: boolean; + + color?: Theme.Common.Color | "darkerZinc"; + outline?: boolean; + transparent?: boolean; + translucent?: boolean; + + autoFocus?: boolean; + active?: boolean; + disabled?: boolean; + selected?: boolean; + itemsCenter?: boolean; + style?: React.CSSProperties; + + icon?: Theme.Icon.Prop; + iconLeft?: Theme.Icon.Prop; + iconRight?: Theme.Icon.Prop; + + badge?: React.ReactNode | React.FunctionComponent; + badgeRight?: React.ReactNode | React.FunctionComponent; + + label?: React.ReactNode; + labelPlacement?: "top" | "bottom" | "left" | "right"; + + loading?: boolean; + onClick?: (event: MouseEvent) => void; + onDoubleClick?: (event: MouseEvent) => void; + }; + + export const useStates = ({ loading, disabled }: Props) => + useMemo( + () => + loading || disabled + ? "cursor-not-allowed opacity-50" + : "cursor-pointer opacity-100", + [loading, disabled] + ); + + export const useSizing = ({ + size = Theme.Common.Size.preset(), + fullWidth, + children, + }: Props) => { + return useMemo(() => { + return classes( + "w-fit", + fullWidth && "w-full", + + size === "sm" && classes("px-2.5 py-1 text-sm", !children && "px-1"), + size === "md" && classes("px-3 py-1 text-base", !children && "px-1"), + + (size === "lg" || size === "xl") && + classes("px-4 py-2 text-base", !children && "px-2") + ); + }, [fullWidth, size, children]); + }; + + export const useColors = ({ + color = Theme.Common.Color.preset(), + outline, + transparent, + translucent, + }: Props) => + useMemo( + () => + classes( + { + brand: + "bg-brand-500 shadow-brand-500-md dark:shadow-none dark:bg-brand-600 dark:hover:bg-brand-500 border-brand-500 dark:border-brand-600", + + indigo: + "text-white bg-brand-500 shadow-brand-500-md dark:shadow-none dark:bg-brand-600", + + red: "bg-red-600 hover:bg-red-700 active:bg-red-800", + + green: "bg-green-600 hover:bg-green-700 active:bg-green-800", + + yellow: "bg-yellow-600 hover:bg-yellow-700 active:bg-yellow-800", + + zinc: "shadow-black/5 bg-zinc-200 dark:shadow-none dark:text-white/80 dark:hover:text-white dark:bg-zinc-800 dark:hover:bg-zinc-700 border-zinc-800 dark:border-zinc-700", + + darkerZinc: + "bg-zinc-900 border border-zinc-700 hover:border-zinc-300 duration-100 transition text-white", + + outline: + "shadow-none dark:text-white text-black border border-transparent hover:border-zinc-700 focus:border-brand-500 active:bg-brand-500 active:text-white active:border-brand-500", + }[outline ? "outline" : color], + + outline && "dark:hover:bg-zinc-700", + + transparent && + "bg-transparent hover:bg-transparent dark:bg-transparent dark:hover:bg-transparent shadow-none", + + translucent && "dark:bg-opacity-60 dark:hover:bg-opacity-80" + ), + [color, outline, transparent, translucent] + ); + + export const useIcons = ({ + icon, + iconLeft = icon, + iconRight, + size = Theme.Common.Size.preset(), + loading, + children, + }: Props) => { + return useMemo(() => { + const render = (icon: typeof iconRight, position: "left" | "right") => { + const className = classes( + "opacity-75 duration-100 group-hover:opacity-100 shrink", + size === "sm" && "h-5 w-5", + size === "md" && "h-6 w-6 p-px origin-center", + size === "lg" && "h-6 w-6", + position === "left" && "mr-1 -ml-1", + position === "right" && "ml-1 -mr-1", + !children ? "mx-0" : "p-0.5" + ); + + if (loading) return ; + if (!icon) return null; + + if (typeof icon === "function") + return icon({ className, strokeWidth: 2.2 }); + + if (typeof icon !== "object") return icon; + if (React.isValidElement(icon)) return icon; + + return null; + }; + + return { + left: (loading || iconLeft) && render(iconLeft, "left"), + right: iconRight && render(iconRight, "right"), + }; + }, [iconLeft, iconRight, size, loading, children]); + }; + + export const useBadges = ({ badgeRight, size, fullWidth }: Props) => + useMemo(() => { + const render = (badge: typeof badgeRight, position: "right") => { + const className = classes( + position === "right" && !fullWidth && "ml-1 -mr-1" + ); + + if (!badge) return null; + + if (typeof badge === "function") return badge({ size, className }); + if (typeof badge !== "object") return badge; + + if (React.isValidElement(badge)) return badge; + + return null; + }; + + const right = render(badgeRight, "right"); + + return { + right: + right && !fullWidth ? ( + right + ) : ( +
+ {right} +
+ ), + }; + }, [badgeRight, size, fullWidth]); +} diff --git a/packages/stablestudio-ui/src/Theme/Checkbox/index.tsx b/packages/stablestudio-ui/src/Theme/Checkbox/index.tsx new file mode 100644 index 0000000..41640cd --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Checkbox/index.tsx @@ -0,0 +1,90 @@ +import { Theme } from "~/Theme"; + +export function Checkbox(props: Checkbox.Props) { + const label = ( + <> + {props.label && ( +
+ {props.label} +
+ )} + + ); + + return ( +
props.onChange(!props.value)} + className={classes( + "flex w-fit cursor-pointer items-center gap-2", + props.left && "flex-row", + props.right && "flex-row-reverse", + props.disabled && "cursor-not-allowed", + !props.left && !props.right && "flex-row", + props.className + )} + > + {props.labelLeft && label} +
{ + if (e.key === " " && e.target === e.currentTarget) { + props.onChange(!props.value); + } + }} + className={classes( + "flex shrink-0 items-center justify-center rounded border-none border-black/5 dark:border", + + (!props.variant || props.variant === "indigo") && + props.value && + "bg-brand-500 dark:bg-brand-600", + + props.variant === "red" && props.value && "bg-red-600", + props.variant === "green" && props.value && "bg-green-600", + props.variant === "yellow" && props.value && "bg-yellow-600", + props.variant === "gray" && props.value && "bg-zinc-600", + !props.value && "bg-black/10 dark:bg-zinc-700", + + props.size === "sm" + ? "h-4 w-4" + : props.size === "lg" + ? "h-6 w-6" + : "h-5 w-5" + )} + > + {props.value && ( + + )} +
+ {!props.labelLeft && label} +
+ ); +} + +export namespace Checkbox { + export type Props = Styleable & { + label?: React.ReactNode; + labelLeft?: boolean; + labelClassName?: string; + + size?: Theme.Common.Size; + variant?: "indigo" | "red" | "green" | "yellow" | "gray"; + disabled?: boolean; + bold?: boolean; + + left?: boolean; + right?: boolean; + + onChange: (value: boolean) => void; + value: boolean; + }; +} diff --git a/packages/stablestudio-ui/src/Theme/Checkered/index.tsx b/packages/stablestudio-ui/src/Theme/Checkered/index.tsx new file mode 100644 index 0000000..f7d76c9 --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Checkered/index.tsx @@ -0,0 +1,25 @@ +import { Theme } from "~/Theme"; + +export function Checkered({ + size = Theme.Common.Size.preset(), + className, +}: Styleable & { + size?: Theme.Common.Size; +}) { + return ( +
+
+
+ ); +} diff --git a/packages/stablestudio-ui/src/Theme/Common/index.tsx b/packages/stablestudio-ui/src/Theme/Common/index.tsx new file mode 100644 index 0000000..1ee2933 --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Common/index.tsx @@ -0,0 +1,11 @@ +export namespace Common { + export type Size = "sm" | "md" | "lg" | "xl"; + export namespace Size { + export const preset = (): Size => "md"; + } + + export type Color = "brand" | "indigo" | "red" | "green" | "yellow" | "zinc"; + export namespace Color { + export const preset = (): Color => "zinc"; + } +} diff --git a/packages/stablestudio-ui/src/Theme/Divider/index.tsx b/packages/stablestudio-ui/src/Theme/Divider/index.tsx new file mode 100644 index 0000000..6332871 --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Divider/index.tsx @@ -0,0 +1,48 @@ +export function Divider({ + variant = "horizontal", + children, + className, + lineClassName, +}: Divider.Props) { + const line = ( +
+ ); + + return ( +
+ {line} + {children && ( +
+ {children} +
+ )} + {children && line} +
+ ); +} + +export namespace Divider { + export type Props = StyleableWithChildren & { + variant?: "horizontal" | "vertical"; + lineClassName?: string; + }; + + export function Inline() { + return /; + } +} diff --git a/packages/stablestudio-ui/src/Theme/Dropdown/index.tsx b/packages/stablestudio-ui/src/Theme/Dropdown/index.tsx new file mode 100644 index 0000000..a209d5e --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Dropdown/index.tsx @@ -0,0 +1,137 @@ +import { useClickAway } from "react-use"; + +import { Theme } from ".."; + +export type Dropdown< + Options extends Dropdown.Options, + Item extends Dropdown.Options[number] = Dropdown.Options[number], + Value extends Item["value"] = Item["value"] +> = StyleableWithChildren & { + value?: Value; + options?: Options; + onChange?: (item: Item) => void; + + title?: React.ReactNode; + placeholder?: string; + size?: Theme.Common.Size; + noPadding?: boolean; + transparent?: boolean; + disabled?: boolean; + fullWidth?: boolean; + fixed?: boolean; + innerClassName?: string; +}; + +export function Dropdown({ + value, + onChange, + + title, + placeholder = "Select Option...", + size = Theme.Common.Size.preset(), + transparent, + fullWidth, + + className, + + ...props +}: Dropdown) { + // TODO: Share with `Theme.Button` + const sizing = useMemo( + () => + classes( + size === "sm" && "px-2.5 py-1 text-sm", + size === "md" && "px-2 py-1.5 text-base", + size === "lg" && "px-4 py-1 text-lg" + ), + [size] + ); + + const [open, setOpen] = useState(false); + const selectRef = useRef(null); + const parentRef = useRef(null); + + useLayoutEffect(() => { + // set the width to the side of the select + some room for the icon + if (parentRef.current && selectRef.current && !fullWidth) { + parentRef.current.style.width = `${ + selectRef.current.getBoundingClientRect().width + 16 + }px`; + } + }, [fullWidth]); + + useClickAway(parentRef, () => setOpen(false)); + + return ( +
+
+ +
+
+ {open ? ( + + ) : ( + + )} +
+
+
+ ); +} + +export namespace Dropdown { + export type Options = Item[]; + export type Item = { + value: string; + label: React.ReactNode; + icon?: React.ReactNode; + description?: React.ReactNode; + disabled?: boolean; + }; +} diff --git a/packages/stablestudio-ui/src/Theme/Icon/SVGs.tsx b/packages/stablestudio-ui/src/Theme/Icon/SVGs.tsx new file mode 100644 index 0000000..cbaa5a9 --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Icon/SVGs.tsx @@ -0,0 +1,434 @@ +import { Theme } from "~/Theme"; + +type Props = Theme.Icon.Props; + +export function Instagram(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function Twitter(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function Discord(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function CGSociety(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + + )); +} + +export function ArtStation(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function InfoIcon({ width, height, color, ...props }: Props) { + return ( + + + + + ); +} + +export function ShareIcon(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function AspectRatio(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + )); +} + +export function ModelIcon(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + )); +} + +export function SlidersIcon(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function SeedIcon(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function Scale(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + + + + + + + + )); +} + +export function Steps(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + + + + + + + )); +} + +export function Rectangle(props: Props) { + return defaults(props)(({ width, height, color = "#3F3F46", ...props }) => ( + + + + + + + + )); +} + +export function Generate(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + )); +} + +export function Variation(props: Props) { + return defaults(props)(({ width, height, ...props }) => ( + + + + + + )); +} + +export function Dream(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + + + + )); +} + +export function Upscale(props: Props) { + return defaults(props)(({ width, height, color, ...props }) => ( + + + + + + + )); +} + +const defaults = + (props: Props) => + (render: (props: Props) => JSX.Element): JSX.Element => + render({ + ...props, + color: props.color ?? "currentColor", + }); diff --git a/packages/stablestudio-ui/src/Theme/Icon/index.tsx b/packages/stablestudio-ui/src/Theme/Icon/index.tsx new file mode 100644 index 0000000..1acce91 --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Icon/index.tsx @@ -0,0 +1,278 @@ +import { + AlertCircle, + AlertTriangle, + ArrowLeftCircle, + Brush, + Camera, + Check, + ChevronDown, + ChevronLeft, + ChevronRight, + ChevronsDownUp, + ChevronsLeftRight, + ChevronUp, + Clapperboard, + Coins, + Copy, + Dices, + Download, + Edit, + Eraser, + ExternalLink, + Eye, + EyeOff, + Focus, + Folders, + Hand, + History, + Image, + ImagePlus, + Import, + Info, + Keyboard, + Layers, + Locate, + LocateFixed, + Lock, + LucideProps, + Minus, + MoreHorizontal, + MoreVertical, + Palette, + Pencil, + Plus, + Redo, + RefreshCw as RefreshClockwise, + Search, + MousePointer2 as Select, + Settings, + Sidebar, + SidebarClose, + SidebarOpen, + Slash, + Sliders, + Sprout, + Star, + TimerReset, + Trash, + Undo, + Unlock, + Upload, + Users, + Wand2 as Wand, + Wrench, + X, + ZoomIn, + ZoomOut, +} from "lucide-react"; + +import { + ArtStation, + AspectRatio, + CGSociety, + Discord, + Dream, + Generate, + InfoIcon, + Instagram, + ModelIcon, + Rectangle, + Scale, + ShareIcon, + SlidersIcon, + Steps, + Twitter, + Upscale, + Variation, +} from "./SVGs"; + +export declare namespace Icon { + export { + AlertCircle, + AlertTriangle, + Brush, + Camera, + Image, + Check, + ChevronDown, + ChevronLeft, + ChevronRight, + ChevronUp, + Clapperboard, + Users, + ChevronsDownUp, + Copy, + Dices, + Download, + Eye, + Edit, + EyeOff, + ExternalLink, + Hand, + History, + Import, + Info, + Layers, + Locate, + Undo, + Redo, + LocateFixed, + Minus, + MoreVertical, + MoreHorizontal, + Slash, + Plus, + Select, + Sidebar, + SidebarOpen, + SidebarClose, + Search, + Settings, + Sliders, + Trash, + Wand, + Upload, + Wrench, + X, + RefreshClockwise, + ArtStation, + Instagram, + Twitter, + Discord, + CGSociety, + InfoIcon, + ShareIcon, + AspectRatio, + ModelIcon, + SlidersIcon, + Sprout, + Star, + TimerReset, + ZoomIn, + ZoomOut, + Focus, + Palette, + Steps, + Generate, + Scale, + Folders, + Coins, + Eraser, + Lock, + Unlock, + Rectangle, + ArrowLeftCircle, + ImagePlus, + Variation, + Pencil, + Dream, + Upscale, + Keyboard, + ChevronsLeftRight, + }; +} + +export namespace Icon { + export type Prop = React.ReactNode | React.FunctionComponent; + export type Props = LucideProps; + + function makeComponent(Icon: (props: Props) => JSX.Element) { + return (props: Props) => ; + } + + Icon.AlertCircle = makeComponent(AlertCircle); + Icon.AlertTriangle = makeComponent(AlertTriangle); + Icon.Brush = makeComponent(Brush); + Icon.Camera = makeComponent(Camera); + Icon.Check = makeComponent(Check); + Icon.ChevronDown = makeComponent(ChevronDown); + Icon.ChevronUp = makeComponent(ChevronUp); + Icon.ChevronsDownUp = makeComponent(ChevronsDownUp); + Icon.ChevronLeft = makeComponent(ChevronLeft); + Icon.Users = makeComponent(Users); + Icon.Clapperboard = makeComponent(Clapperboard); + Icon.ChevronRight = makeComponent(ChevronRight); + Icon.Copy = makeComponent(Copy); + Icon.Dices = makeComponent(Dices); + Icon.Download = makeComponent(Download); + Icon.Image = makeComponent(Image); + Icon.Eye = makeComponent(Eye); + Icon.Folders = makeComponent(Folders); + Icon.Download = makeComponent(Download); + Icon.EyeOff = makeComponent(EyeOff); + Icon.Edit = makeComponent(Edit); + Icon.ExternalLink = makeComponent(ExternalLink); + Icon.Slash = makeComponent(Slash); + Icon.Hand = makeComponent(Hand); + Icon.History = makeComponent(History); + Icon.Import = makeComponent(Import); + Icon.Info = makeComponent(Info); + Icon.Layers = makeComponent(Layers); + Icon.Palette = makeComponent(Palette); + Icon.Locate = makeComponent(Locate); + Icon.LocateFixed = makeComponent(LocateFixed); + Icon.Minus = makeComponent(Minus); + Icon.MoreVertical = makeComponent(MoreVertical); + Icon.MoreHorizontal = makeComponent(MoreHorizontal); + Icon.Plus = makeComponent(Plus); + Icon.Select = makeComponent(Select); + Icon.Settings = makeComponent(Settings); + Icon.Sliders = makeComponent(Sliders); + Icon.Trash = makeComponent(Trash); + Icon.Wand = makeComponent(Wand); + Icon.Undo = makeComponent(Undo); + Icon.Redo = makeComponent(Redo); + Icon.Upload = makeComponent(Upload); + Icon.Wrench = makeComponent(Wrench); + Icon.X = makeComponent(X); + Icon.ArtStation = makeComponent(ArtStation); + Icon.Instagram = makeComponent(Instagram); + Icon.Twitter = makeComponent(Twitter); + Icon.Discord = makeComponent(Discord); + Icon.Generate = makeComponent(Generate); + Icon.CGSociety = makeComponent(CGSociety); + Icon.RefreshClockwise = makeComponent(RefreshClockwise); + Icon.InfoIcon = makeComponent(InfoIcon); + Icon.ShareIcon = makeComponent(ShareIcon); + Icon.Search = makeComponent(Search); + Icon.AspectRatio = makeComponent(AspectRatio); + Icon.ModelIcon = makeComponent(ModelIcon); + Icon.SlidersIcon = makeComponent(SlidersIcon); + Icon.Sprout = makeComponent(Sprout); + Icon.Star = makeComponent(Star); + Icon.TimerReset = makeComponent(TimerReset); + Icon.ZoomIn = makeComponent(ZoomIn); + Icon.ZoomOut = makeComponent(ZoomOut); + Icon.Focus = makeComponent(Focus); + Icon.Sidebar = makeComponent(Sidebar); + Icon.SidebarOpen = makeComponent(SidebarOpen); + Icon.SidebarClose = makeComponent(SidebarClose); + Icon.Steps = makeComponent(Steps); + Icon.Scale = makeComponent(Scale); + Icon.Coins = makeComponent(Coins); + Icon.Eraser = makeComponent(Eraser); + Icon.Lock = makeComponent(Lock); + Icon.Unlock = makeComponent(Unlock); + Icon.Rectangle = makeComponent(Rectangle); + Icon.ArrowLeftCircle = makeComponent(ArrowLeftCircle); + Icon.ImagePlus = makeComponent(ImagePlus); + Icon.Variation = makeComponent(Variation); + Icon.Pencil = makeComponent(Pencil); + Icon.Dream = makeComponent(Dream); + Icon.Upscale = makeComponent(Upscale); + Icon.Keyboard = makeComponent(Keyboard); + Icon.ChevronsLeftRight = makeComponent(ChevronsLeftRight); + + export function Invisible(props: Props) { + return ( + + ); + } +} diff --git a/packages/stablestudio-ui/src/Theme/Input/index.tsx b/packages/stablestudio-ui/src/Theme/Input/index.tsx new file mode 100644 index 0000000..650c71c --- /dev/null +++ b/packages/stablestudio-ui/src/Theme/Input/index.tsx @@ -0,0 +1,218 @@ +import { Theme } from "~/Theme"; + +export type Input = Styleable & { + loading?: boolean; + autoSize?: boolean; + value?: string; + + icon?: React.ReactNode | React.FunctionComponent; + iconLeft?: React.ReactNode | React.FunctionComponent; + iconRight?: React.ReactNode | React.FunctionComponent; + + onChange: (value: string) => void; + + onFocus?: ( + event: + | React.FocusEvent + | React.FocusEvent + ) => void; + + onBlur?: ( + event: + | React.FocusEvent + | React.FocusEvent + ) => void; + + onKeyDown?: React.KeyboardEventHandler< + HTMLTextAreaElement | HTMLInputElement + >; + + autoFocus?: boolean; + placeholder?: string; + disabled?: boolean; + fullWidth?: boolean; + size?: Theme.Common.Size; + transparent?: boolean; + type?: "text" | "password" | "number" | "email" | "url"; +}; + +export function Input(props: Input) { + if (props.autoSize) { + return ; + } else { + return ; + } +} + +function AutosizeTextArea({ + size = Theme.Common.Size.preset(), + autoFocus = false, + + value, + onChange, + + ...props +}: Input) { + const textareaRef = useRef(null); + const [, setForceUpdate] = useState(0); + + useEffect(() => { + if (textareaRef.current) { + const styles = window.getComputedStyle(textareaRef.current); + textareaRef.current.style.height = "auto"; + + const newHeight = + textareaRef.current.scrollHeight + + parseInt(styles.paddingTop) + + parseInt(styles.paddingBottom); + + if (newHeight === 0) { + setForceUpdate((n) => n + 1); + return; + } + + textareaRef.current.style.height = newHeight + "px"; + } + }, [value]); + + useEffect(() => { + if (!textareaRef.current || !autoFocus) return; + textareaRef.current.blur(); + textareaRef.current.focus(); + }, [autoFocus]); + + return ( +