likec4 1.19.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/prompt.cjs +45 -0
- package/dist/chunks/prompt.mjs +1 -1
- package/dist/cli/index.cjs +469 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.mjs +35 -35
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +16459 -0
- package/dist/index.d.mts +135 -137
- package/dist/index.d.ts +135 -137
- package/dist/index.mjs +1 -1
- package/dist/model/index.cjs +1 -0
- package/dist/model/index.d.cts +258 -0
- package/dist/model/index.mjs +1 -1
- package/dist/shared/{likec4.LktBLTET.mjs → likec4.1r1CQuHw.mjs} +2 -2
- package/dist/shared/{likec4.CbSUX9bc.mjs → likec4.CLgnaOeL.mjs} +182 -179
- package/dist/shared/likec4.CfqfZIn-.cjs +1856 -0
- package/dist/shared/likec4.D81G5JV4.cjs +9 -0
- package/dist/shared/likec4.DCwaTTuF.d.cts +1625 -0
- package/package.json +22 -15
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";const LikeC4=require("../shared/likec4.CfqfZIn-.cjs");require("node:util");const path$1=require("node:path"),process$1=require("node:process");require("node:tty");const assert=require("assert"),require$$0=require("path"),require$$0$1=require("fs"),require$$0$2=require("util"),require$$0$3=require("url"),fs=require("node:fs"),fsPromises=require("node:fs/promises"),os=require("node:os"),node_url=require("node:url"),c$1=require("@vitejs/plugin-react-swc"),index_DafVOuVd=require("../shared/likec4.D81G5JV4.cjs"),vite=require("vite"),playwright=require("playwright"),net=require("node:net"),promises=require("node:timers/promises");require("tty"),require("os"),require("crypto"),require("net"),require("child_process"),require("@hpcc-js/wasm-graphviz"),require("buffer"),require("node:child_process"),require("node:string_decoder"),require("node:events"),require("node:v8"),require("node:stream"),require("node:buffer"),require("node:stream/promises");var _documentCurrentScript=typeof document<"u"?document.currentScript:null;function _interopDefaultCompat(s){return s&&typeof s=="object"&&"default"in s?s.default:s}const path__default=_interopDefaultCompat(path$1),process__default=_interopDefaultCompat(process$1),fs__default=_interopDefaultCompat(fs),os__default=_interopDefaultCompat(os),c__default=_interopDefaultCompat(c$1),net__default=_interopDefaultCompat(net),i=!1,align={right:alignRight,center:alignCenter},top=0,right=1,bottom=2,left=3;class UI{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){const t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);const t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){const t=e.split(`
|
|
3
|
+
`).map(o=>o.split(" "));let n=0;return t.forEach(o=>{o.length>1&&mixin$1.stringWidth(o[0])>n&&(n=Math.min(Math.floor(this.width*.5),mixin$1.stringWidth(o[0])))}),t.forEach(o=>{this.div(...o.map((a,l)=>({text:a.trim(),padding:this.measurePadding(a),width:l===0&&o.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){const t=mixin$1.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){const e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(t=>!t.hidden).map(t=>t.text).join(`
|
|
4
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,o)=>{let a="";n.forEach((l,d)=>{const{width:w}=e[d],L=this.negatePadding(e[d]);let y=l;if(L>mixin$1.stringWidth(l)&&(y+=" ".repeat(L-mixin$1.stringWidth(l))),e[d].align&&e[d].align!=="left"&&this.wrap){const N=align[e[d].align];y=N(y,L),mixin$1.stringWidth(y)<L&&(y+=" ".repeat((w||0)-mixin$1.stringWidth(y)-1))}const B=e[d].padding||[0,0,0,0];B[left]&&(a+=" ".repeat(B[left])),a+=addBorder(e[d],y,"| "),a+=y,a+=addBorder(e[d],y," |"),B[right]&&(a+=" ".repeat(B[right])),o===0&&t.length>0&&(a=this.renderInline(a,t[t.length-1]))}),t.push({text:a.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){const n=e.match(/^ */),o=n?n[0].length:0,a=t.text,l=mixin$1.stringWidth(a.trimRight());return t.span?this.wrap?o<l?e:(t.hidden=!0,a.trimRight()+" ".repeat(o-l)+e.trimLeft()):(t.hidden=!0,a+e):e}rasterize(e){const t=[],n=this.columnWidths(e);let o;return e.forEach((a,l)=>{a.width=n[l],this.wrap?o=mixin$1.wrap(a.text,this.negatePadding(a),{hard:!0}).split(`
|
|
5
|
+
`):o=a.text.split(`
|
|
6
|
+
`),a.border&&(o.unshift("."+"-".repeat(this.negatePadding(a)+2)+"."),o.push("'"+"-".repeat(this.negatePadding(a)+2)+"'")),a.padding&&(o.unshift(...new Array(a.padding[top]||0).fill("")),o.push(...new Array(a.padding[bottom]||0).fill(""))),o.forEach((d,w)=>{t[w]||t.push([]);const L=t[w];for(let y=0;y<l;y++)L[y]===void 0&&L.push("");L.push(d)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[left]||0)+(e.padding[right]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(l=>l.width||mixin$1.stringWidth(l.text));let t=e.length,n=this.width;const o=e.map(l=>{if(l.width)return t--,n-=l.width,l.width}),a=t?Math.floor(n/t):0;return o.map((l,d)=>l===void 0?Math.max(a,_minWidth(e[d])):l)}}function addBorder(s,e,t){return s.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function _minWidth(s){const e=s.padding||[],t=1+(e[left]||0)+(e[right]||0);return s.border?t+4:t}function getWindowWidth(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function alignRight(s,e){s=s.trim();const t=mixin$1.stringWidth(s);return t<e?" ".repeat(e-t)+s:s}function alignCenter(s,e){s=s.trim();const t=mixin$1.stringWidth(s);return t>=e?s:" ".repeat(e-t>>1)+s}let mixin$1;function cliui(s,e){return mixin$1=e,new UI({width:s?.width||getWindowWidth(),wrap:s?.wrap})}const ansi=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function stripAnsi(s){return s.replace(ansi,"")}function wrap(s,e){const[t,n]=s.match(ansi)||["",""];s=stripAnsi(s);let o="";for(let a=0;a<s.length;a++)a!==0&&a%e===0&&(o+=`
|
|
7
|
+
`),o+=s.charAt(a);return t&&n&&(o=`${t}${o}${n}`),o}function ui(s){return cliui(s,{stringWidth:e=>[...e].length,stripAnsi,wrap})}function escalade(s,e){let t=require$$0.resolve(".",s),n;for(require$$0$1.statSync(t).isDirectory()||(t=require$$0.dirname(t));;){if(n=e(t,require$$0$1.readdirSync(t)),n)return require$$0.resolve(t,n);if(t=require$$0.dirname(n=t),n===t)break}}function camelCase(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let t="",n=!1;const o=s.match(/^-+/);for(let a=o?o[0].length:0;a<s.length;a++){let l=s.charAt(a);n&&(n=!1,l=l.toUpperCase()),a!==0&&(l==="-"||l==="_")?n=!0:l!=="-"&&l!=="_"&&(t+=l)}return t}}function decamelize(s,e){const t=s.toLowerCase();e=e||"-";let n="";for(let o=0;o<s.length;o++){const a=t.charAt(o),l=s.charAt(o);a!==l&&o>0?n+=`${e}${t.charAt(o)}`:n+=l}return n}function looksLikeNumber(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function tokenizeArgString(s){if(Array.isArray(s))return s.map(l=>typeof l!="string"?l+"":l);s=s.trim();let e=0,t=null,n=null,o=null;const a=[];for(let l=0;l<s.length;l++){if(t=n,n=s.charAt(l),n===" "&&!o){t!==" "&&e++;continue}n===o?o=null:(n==="'"||n==='"')&&!o&&(o=n),a[e]||(a[e]=""),a[e]+=n}return a}var DefaultValuesForTypeKey;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(DefaultValuesForTypeKey||(DefaultValuesForTypeKey={}));let mixin;class YargsParser{constructor(e){mixin=e}parse(e,t){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),o=tokenizeArgString(e),a=typeof e=="string",l=combineAliases(Object.assign(Object.create(null),n.alias)),d=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),w=Object.assign(Object.create(null),n.default),L=n.configObjects||[],y=n.envPrefix,B=d["populate--"],N=B?"--":"_",z=Object.create(null),Q=Object.create(null),H=n.__||mixin.format,T={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},X=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,ne=new RegExp("^--"+d["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(_){const W=typeof _=="object"?_.key:_,Z=Object.keys(_).map(function(K){return{boolean:"bools",string:"strings",number:"numbers"}[K]}).filter(Boolean).pop();Z&&(T[Z][W]=!0),T.arrays[W]=!0,T.keys.push(W)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(_){T.bools[_]=!0,T.keys.push(_)}),[].concat(n.string||[]).filter(Boolean).forEach(function(_){T.strings[_]=!0,T.keys.push(_)}),[].concat(n.number||[]).filter(Boolean).forEach(function(_){T.numbers[_]=!0,T.keys.push(_)}),[].concat(n.count||[]).filter(Boolean).forEach(function(_){T.counts[_]=!0,T.keys.push(_)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(_){T.normalize[_]=!0,T.keys.push(_)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([_,W])=>{typeof W=="number"&&(T.nargs[_]=W,T.keys.push(_))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([_,W])=>{typeof W=="function"&&(T.coercions[_]=W,T.keys.push(_))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(_){T.configs[_]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([_,W])=>{(typeof W=="boolean"||typeof W=="function")&&(T.configs[_]=W)})),Le(n.key,l,n.default,T.arrays),Object.keys(w).forEach(function(_){(T.aliases[_]||[]).forEach(function(W){w[W]=w[_]})});let le=null;Ne();let oe=[];const fe=Object.assign(Object.create(null),{_:[]}),ve={};for(let _=0;_<o.length;_++){const W=o[_],Z=W.replace(/^-{3,}/,"---");let K,U,re,te,ue,ye;if(W!=="--"&&/^-/.test(W)&&we(W))_e(W);else if(Z.match(/^---+(=|$)/)){_e(W);continue}else if(W.match(/^--.+=/)||!d["short-option-groups"]&&W.match(/^-.+=/))te=W.match(/^--?([^=]+)=([\s\S]*)$/),te!==null&&Array.isArray(te)&&te.length>=3&&(ce(te[1],T.arrays)?_=$e(_,te[1],o,te[2]):ce(te[1],T.nargs)!==!1?_=Pe(_,te[1],o,te[2]):ge(te[1],te[2],!0));else if(W.match(ne)&&d["boolean-negation"])te=W.match(ne),te!==null&&Array.isArray(te)&&te.length>=2&&(U=te[1],ge(U,ce(U,T.arrays)?[!1]:!1));else if(W.match(/^--.+/)||!d["short-option-groups"]&&W.match(/^-[^-]+/))te=W.match(/^--?(.+)/),te!==null&&Array.isArray(te)&&te.length>=2&&(U=te[1],ce(U,T.arrays)?_=$e(_,U,o):ce(U,T.nargs)!==!1?_=Pe(_,U,o):(ue=o[_+1],ue!==void 0&&(!ue.match(/^-/)||ue.match(X))&&!ce(U,T.bools)&&!ce(U,T.counts)||/^(true|false)$/.test(ue)?(ge(U,ue),_++):ge(U,Ae(U))));else if(W.match(/^-.\..+=/))te=W.match(/^-([^=]+)=([\s\S]*)$/),te!==null&&Array.isArray(te)&&te.length>=3&&ge(te[1],te[2]);else if(W.match(/^-.\..+/)&&!W.match(X))ue=o[_+1],te=W.match(/^-(.\..+)/),te!==null&&Array.isArray(te)&&te.length>=2&&(U=te[1],ue!==void 0&&!ue.match(/^-/)&&!ce(U,T.bools)&&!ce(U,T.counts)?(ge(U,ue),_++):ge(U,Ae(U)));else if(W.match(/^-[^-]+/)&&!W.match(X)){re=W.slice(1,-1).split(""),K=!1;for(let Be=0;Be<re.length;Be++){if(ue=W.slice(Be+2),re[Be+1]&&re[Be+1]==="="){ye=W.slice(Be+3),U=re[Be],ce(U,T.arrays)?_=$e(_,U,o,ye):ce(U,T.nargs)!==!1?_=Pe(_,U,o,ye):ge(U,ye),K=!0;break}if(ue==="-"){ge(re[Be],ue);continue}if(/[A-Za-z]/.test(re[Be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(ue)&&ce(ue,T.bools)===!1){ge(re[Be],ue),K=!0;break}if(re[Be+1]&&re[Be+1].match(/\W/)){ge(re[Be],ue),K=!0;break}else ge(re[Be],Ae(re[Be]))}U=W.slice(-1)[0],!K&&U!=="-"&&(ce(U,T.arrays)?_=$e(_,U,o):ce(U,T.nargs)!==!1?_=Pe(_,U,o):(ue=o[_+1],ue!==void 0&&(!/^(-|--)[^-]/.test(ue)||ue.match(X))&&!ce(U,T.bools)&&!ce(U,T.counts)||/^(true|false)$/.test(ue)?(ge(U,ue),_++):ge(U,Ae(U))))}else if(W.match(/^-[0-9]$/)&&W.match(X)&&ce(W.slice(1),T.bools))U=W.slice(1),ge(U,Ae(U));else if(W==="--"){oe=o.slice(_+1);break}else if(d["halt-at-non-option"]){oe=o.slice(_);break}else _e(W)}pe(fe,!0),pe(fe,!1),de(fe),be(),Ce(fe,T.aliases,w,!0),Fe(fe),d["set-placeholder-key"]&&je(fe),Object.keys(T.counts).forEach(function(_){xe(fe,_.split("."))||ge(_,0)}),B&&oe.length&&(fe[N]=[]),oe.forEach(function(_){fe[N].push(_)}),d["camel-case-expansion"]&&d["strip-dashed"]&&Object.keys(fe).filter(_=>_!=="--"&&_.includes("-")).forEach(_=>{delete fe[_]}),d["strip-aliased"]&&[].concat(...Object.keys(l).map(_=>l[_])).forEach(_=>{d["camel-case-expansion"]&&_.includes("-")&&delete fe[_.split(".").map(W=>camelCase(W)).join(".")],delete fe[_]});function _e(_){const W=ie("_",_);(typeof W=="string"||typeof W=="number")&&fe._.push(W)}function Pe(_,W,Z,K){let U,re=ce(W,T.nargs);if(re=typeof re!="number"||isNaN(re)?1:re,re===0)return Se(K)||(le=Error(H("Argument unexpected for: %s",W))),ge(W,Ae(W)),_;let te=Se(K)?0:1;if(d["nargs-eats-options"])Z.length-(_+1)+te<re&&(le=Error(H("Not enough arguments following: %s",W))),te=re;else{for(U=_+1;U<Z.length&&(!Z[U].match(/^-[^0-9]/)||Z[U].match(X)||we(Z[U]));U++)te++;te<re&&(le=Error(H("Not enough arguments following: %s",W)))}let ue=Math.min(te,re);for(!Se(K)&&ue>0&&(ge(W,K),ue--),U=_+1;U<ue+_+1;U++)ge(W,Z[U]);return _+ue}function $e(_,W,Z,K){let U=[],re=K||Z[_+1];const te=ce(W,T.nargs);if(ce(W,T.bools)&&!/^(true|false)$/.test(re))U.push(!0);else if(Se(re)||Se(K)&&/^-/.test(re)&&!X.test(re)&&!we(re)){if(w[W]!==void 0){const ue=w[W];U=Array.isArray(ue)?ue:[ue]}}else{Se(K)||U.push(ee(W,K,!0));for(let ue=_+1;ue<Z.length&&!(!d["greedy-arrays"]&&U.length>0||te&&typeof te=="number"&&U.length>=te||(re=Z[ue],/^-/.test(re)&&!X.test(re)&&!we(re)));ue++)_=ue,U.push(ee(W,re,a))}return typeof te=="number"&&(te&&U.length<te||isNaN(te)&&U.length===0)&&(le=Error(H("Not enough arguments following: %s",W))),ge(W,U),_}function ge(_,W,Z=a){if(/-/.test(_)&&d["camel-case-expansion"]){const re=_.split(".").map(function(te){return camelCase(te)}).join(".");se(_,re)}const K=ee(_,W,Z),U=_.split(".");Ie(fe,U,K),T.aliases[_]&&T.aliases[_].forEach(function(re){const te=re.split(".");Ie(fe,te,K)}),U.length>1&&d["dot-notation"]&&(T.aliases[U[0]]||[]).forEach(function(re){let te=re.split(".");const ue=[].concat(U);ue.shift(),te=te.concat(ue),(T.aliases[_]||[]).includes(te.join("."))||Ie(fe,te,K)}),ce(_,T.normalize)&&!ce(_,T.arrays)&&[_].concat(T.aliases[_]||[]).forEach(function(te){Object.defineProperty(ve,te,{enumerable:!0,get(){return W},set(ue){W=typeof ue=="string"?mixin.normalize(ue):ue}})})}function se(_,W){T.aliases[_]&&T.aliases[_].length||(T.aliases[_]=[W],z[W]=!0),T.aliases[W]&&T.aliases[W].length||se(W,_)}function ee(_,W,Z){Z&&(W=stripQuotes(W)),(ce(_,T.bools)||ce(_,T.counts))&&typeof W=="string"&&(W=W==="true");let K=Array.isArray(W)?W.map(function(U){return ie(_,U)}):ie(_,W);return ce(_,T.counts)&&(Se(K)||typeof K=="boolean")&&(K=increment()),ce(_,T.normalize)&&ce(_,T.arrays)&&(Array.isArray(W)?K=W.map(U=>mixin.normalize(U)):K=mixin.normalize(W)),K}function ie(_,W){return!d["parse-positional-numbers"]&&_==="_"||!ce(_,T.strings)&&!ce(_,T.bools)&&!Array.isArray(W)&&(looksLikeNumber(W)&&d["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${W}`)))||!Se(W)&&ce(_,T.numbers))&&(W=Number(W)),W}function de(_){const W=Object.create(null);Ce(W,T.aliases,w),Object.keys(T.configs).forEach(function(Z){const K=_[Z]||W[Z];if(K)try{let U=null;const re=mixin.resolve(mixin.cwd(),K),te=T.configs[Z];if(typeof te=="function"){try{U=te(re)}catch(ue){U=ue}if(U instanceof Error){le=U;return}}else U=mixin.require(re);me(U)}catch(U){U.name==="PermissionDenied"?le=U:_[Z]&&(le=Error(H("Invalid JSON config file: %s",K)))}})}function me(_,W){Object.keys(_).forEach(function(Z){const K=_[Z],U=W?W+"."+Z:Z;typeof K=="object"&&K!==null&&!Array.isArray(K)&&d["dot-notation"]?me(K,U):(!xe(fe,U.split("."))||ce(U,T.arrays)&&d["combine-arrays"])&&ge(U,K)})}function be(){typeof L<"u"&&L.forEach(function(_){me(_)})}function pe(_,W){if(typeof y>"u")return;const Z=typeof y=="string"?y:"",K=mixin.env();Object.keys(K).forEach(function(U){if(Z===""||U.lastIndexOf(Z,0)===0){const re=U.split("__").map(function(te,ue){return ue===0&&(te=te.substring(Z.length)),camelCase(te)});(W&&T.configs[re.join(".")]||!W)&&!xe(_,re)&&ge(re.join("."),K[U])}})}function Fe(_){let W;const Z=new Set;Object.keys(_).forEach(function(K){if(!Z.has(K)&&(W=ce(K,T.coercions),typeof W=="function"))try{const U=ie(K,W(_[K]));[].concat(T.aliases[K]||[],K).forEach(re=>{Z.add(re),_[re]=U})}catch(U){le=U}})}function je(_){return T.keys.forEach(W=>{~W.indexOf(".")||typeof _[W]>"u"&&(_[W]=void 0)}),_}function Ce(_,W,Z,K=!1){Object.keys(Z).forEach(function(U){xe(_,U.split("."))||(Ie(_,U.split("."),Z[U]),K&&(Q[U]=!0),(W[U]||[]).forEach(function(re){xe(_,re.split("."))||Ie(_,re.split("."),Z[U])}))})}function xe(_,W){let Z=_;d["dot-notation"]||(W=[W.join(".")]),W.slice(0,-1).forEach(function(U){Z=Z[U]||{}});const K=W[W.length-1];return typeof Z!="object"?!1:K in Z}function Ie(_,W,Z){let K=_;d["dot-notation"]||(W=[W.join(".")]),W.slice(0,-1).forEach(function(ye){ye=sanitizeKey(ye),typeof K=="object"&&K[ye]===void 0&&(K[ye]={}),typeof K[ye]!="object"||Array.isArray(K[ye])?(Array.isArray(K[ye])?K[ye].push({}):K[ye]=[K[ye],{}],K=K[ye][K[ye].length-1]):K=K[ye]});const U=sanitizeKey(W[W.length-1]),re=ce(W.join("."),T.arrays),te=Array.isArray(Z);let ue=d["duplicate-arguments-array"];!ue&&ce(U,T.nargs)&&(ue=!0,(!Se(K[U])&&T.nargs[U]===1||Array.isArray(K[U])&&K[U].length===T.nargs[U])&&(K[U]=void 0)),Z===increment()?K[U]=increment(K[U]):Array.isArray(K[U])?ue&&re&&te?K[U]=d["flatten-duplicate-arrays"]?K[U].concat(Z):(Array.isArray(K[U][0])?K[U]:[K[U]]).concat([Z]):!ue&&!!re==!!te?K[U]=Z:K[U]=K[U].concat([Z]):K[U]===void 0&&re?K[U]=te?Z:[Z]:ue&&!(K[U]===void 0||ce(U,T.counts)||ce(U,T.bools))?K[U]=[K[U],Z]:K[U]=Z}function Le(..._){_.forEach(function(W){Object.keys(W||{}).forEach(function(Z){T.aliases[Z]||(T.aliases[Z]=[].concat(l[Z]||[]),T.aliases[Z].concat(Z).forEach(function(K){if(/-/.test(K)&&d["camel-case-expansion"]){const U=camelCase(K);U!==Z&&T.aliases[Z].indexOf(U)===-1&&(T.aliases[Z].push(U),z[U]=!0)}}),T.aliases[Z].concat(Z).forEach(function(K){if(K.length>1&&/[A-Z]/.test(K)&&d["camel-case-expansion"]){const U=decamelize(K,"-");U!==Z&&T.aliases[Z].indexOf(U)===-1&&(T.aliases[Z].push(U),z[U]=!0)}}),T.aliases[Z].forEach(function(K){T.aliases[K]=[Z].concat(T.aliases[Z].filter(function(U){return K!==U}))}))})})}function ce(_,W){const Z=[].concat(T.aliases[_]||[],_),K=Object.keys(W),U=Z.find(re=>K.includes(re));return U?W[U]:!1}function ke(_){const W=Object.keys(T);return[].concat(W.map(K=>T[K])).some(function(K){return Array.isArray(K)?K.includes(_):K[_]})}function ae(_,...W){return[].concat(...W).some(function(K){const U=_.match(K);return U&&ke(U[1])})}function De(_){if(_.match(X)||!_.match(/^-[^-]+/))return!1;let W=!0,Z;const K=_.slice(1).split("");for(let U=0;U<K.length;U++){if(Z=_.slice(U+2),!ke(K[U])){W=!1;break}if(K[U+1]&&K[U+1]==="="||Z==="-"||/[A-Za-z]/.test(K[U])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(Z)||K[U+1]&&K[U+1].match(/\W/))break}return W}function we(_){return d["unknown-options-as-args"]&&he(_)}function he(_){return _=_.replace(/^-{3,}/,"--"),_.match(X)||De(_)?!1:!ae(_,/^-+([^=]+?)=[\s\S]*$/,ne,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Ae(_){return!ce(_,T.bools)&&!ce(_,T.counts)&&`${_}`in w?w[_]:Ee(Oe(_))}function Ee(_){return{[DefaultValuesForTypeKey.BOOLEAN]:!0,[DefaultValuesForTypeKey.STRING]:"",[DefaultValuesForTypeKey.NUMBER]:void 0,[DefaultValuesForTypeKey.ARRAY]:[]}[_]}function Oe(_){let W=DefaultValuesForTypeKey.BOOLEAN;return ce(_,T.strings)?W=DefaultValuesForTypeKey.STRING:ce(_,T.numbers)?W=DefaultValuesForTypeKey.NUMBER:ce(_,T.bools)?W=DefaultValuesForTypeKey.BOOLEAN:ce(_,T.arrays)&&(W=DefaultValuesForTypeKey.ARRAY),W}function Se(_){return _===void 0}function Ne(){Object.keys(T.counts).find(_=>ce(_,T.arrays)?(le=Error(H("Invalid configuration: %s, opts.count excludes opts.array.",_)),!0):ce(_,T.nargs)?(le=Error(H("Invalid configuration: %s, opts.count excludes opts.narg.",_)),!0):!1)}return{aliases:Object.assign({},T.aliases),argv:Object.assign(ve,fe),configuration:d,defaulted:Object.assign({},Q),error:le,newAliases:Object.assign({},z)}}}function combineAliases(s){const e=[],t=Object.create(null);let n=!0;for(Object.keys(s).forEach(function(o){e.push([].concat(s[o],o))});n;){n=!1;for(let o=0;o<e.length;o++)for(let a=o+1;a<e.length;a++)if(e[o].filter(function(d){return e[a].indexOf(d)!==-1}).length){e[o]=e[o].concat(e[a]),e.splice(a,1),n=!0;break}}return e.forEach(function(o){o=o.filter(function(l,d,w){return w.indexOf(l)===d});const a=o.pop();a!==void 0&&typeof a=="string"&&(t[a]=o)}),t}function increment(s){return s!==void 0?s+1:1}function sanitizeKey(s){return s==="__proto__"?"___proto___":s}function stripQuotes(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}var _a,_b,_c;const minNodeVersion=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,nodeVersion=(_b=(_a=process==null?void 0:process.versions)===null||_a===void 0?void 0:_a.node)!==null&&_b!==void 0?_b:(_c=process==null?void 0:process.version)===null||_c===void 0?void 0:_c.slice(1);if(nodeVersion&&Number(nodeVersion.match(/^([^.]+)/)[1])<minNodeVersion)throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const env=process?process.env:{},parser=new YargsParser({cwd:process.cwd,env:()=>env,format:require$$0$2.format,normalize:require$$0.normalize,resolve:require$$0.resolve,require:s=>{if(typeof require<"u")return require(s);if(s.match(/\.json$/))return JSON.parse(require$$0$1.readFileSync(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),yargsParser=function(e,t){return parser.parse(e.slice(),t).argv};yargsParser.detailed=function(s,e){return parser.parse(s.slice(),e)},yargsParser.camelCase=camelCase,yargsParser.decamelize=decamelize,yargsParser.looksLikeNumber=looksLikeNumber;function getProcessArgvBinIndex(){return isBundledElectronApp()?0:1}function isBundledElectronApp(){return isElectronApp()&&!process.defaultApp}function isElectronApp(){return!!process.versions.electron}function hideBin(s){return s.slice(getProcessArgvBinIndex()+1)}function getProcessArgvBin(){return process.argv[getProcessArgvBinIndex()]}class YError extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,YError)}}const shim$3={fs:{readFileSync:require$$0$1.readFileSync,writeFile:require$$0$1.writeFile},format:require$$0$2.format,resolve:require$$0.resolve,exists:s=>{try{return require$$0$1.statSync(s).isFile()}catch{return!1}}};let shim$2;class Y18N{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const t=e.shift();let n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),shim$2.format.apply(shim$2.format,[this.cache[this.locale][t]||t].concat(e))}__n(){const e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),o=e.shift();let a=function(){};typeof e[e.length-1]=="function"&&(a=e.pop()),this.cache[this.locale]||this._readLocaleFile();let l=o===1?t:n;this.cache[this.locale][t]&&(l=this.cache[this.locale][t][o===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:a})):a();const d=[l];return~l.indexOf("%d")&&d.push(o),shim$2.format.apply(shim$2.format,d.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(o,a){const l=t[a+1];n+=o,typeof l<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const e=this,t=this.writeQueue[0],n=t.directory,o=t.locale,a=t.cb,l=this._resolveLocaleFile(n,o),d=JSON.stringify(this.cache[o],null,2);shim$2.fs.writeFile(l,d,"utf-8",function(w){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),a(w)})}_readLocaleFile(){let e={};const t=this._resolveLocaleFile(this.directory,this.locale);try{shim$2.fs.readFileSync&&(e=JSON.parse(shim$2.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=shim$2.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){const o=shim$2.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(e){return shim$2.exists(e)}}function y18n$1(s,e){shim$2=e;const t=new Y18N(s);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}const y18n=s=>y18n$1(s,shim$3),REQUIRE_ERROR="require is not supported by ESM",REQUIRE_DIRECTORY_ERROR="loading a directory of commands is not supported yet for ESM";let __dirname$1;try{__dirname$1=require$$0$3.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("cli/index.cjs",document.baseURI).href)}catch{__dirname$1=process.cwd()}const mainFilename=__dirname$1.substring(0,__dirname$1.lastIndexOf("node_modules")),shim$1={assert:{notStrictEqual:assert.notStrictEqual,strictEqual:assert.strictEqual},cliui:ui,findUp:escalade,getEnv:s=>process.env[s],inspect:require$$0$2.inspect,getCallerFile:()=>{throw new YError(REQUIRE_DIRECTORY_ERROR)},getProcessArgvBin,mainFilename:mainFilename||process.cwd(),Parser:yargsParser,path:{basename:require$$0.basename,dirname:require$$0.dirname,extname:require$$0.extname,relative:require$$0.relative,resolve:require$$0.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,e)=>process.emitWarning(s,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:require$$0$1.readFileSync,require:()=>{throw new YError(REQUIRE_ERROR)},requireDirectory:()=>{throw new YError(REQUIRE_DIRECTORY_ERROR)},stringWidth:s=>[...s].length,y18n:y18n({directory:require$$0.resolve(__dirname$1,"../../../locales"),updateFiles:!1})};function assertNotStrictEqual(s,e,t,n){t.assert.notStrictEqual(s,e,n)}function assertSingleKey(s,e){e.assert.strictEqual(typeof s,"string")}function objectKeys(s){return Object.keys(s)}function isPromise(s){return!!s&&!!s.then&&typeof s.then=="function"}function parseCommand(s){const t=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,o=t.shift();if(!o)throw new Error(`No command found in: ${s}`);const a={cmd:o.replace(n,""),demanded:[],optional:[]};return t.forEach((l,d)=>{let w=!1;l=l.replace(/\s/g,""),/\.+[\]>]/.test(l)&&d===t.length-1&&(w=!0),/^\[/.test(l)?a.optional.push({cmd:l.replace(n,"").split("|"),variadic:w}):a.demanded.push({cmd:l.replace(n,"").split("|"),variadic:w})}),a}const positionName=["first","second","third","fourth","fifth","sixth"];function argsert(s,e,t){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,e]:[parseCommand(`cmd ${s}`),e,t]}try{let o=0;const[a,l,d]=n(),w=[].slice.call(l);for(;w.length&&w[w.length-1]===void 0;)w.pop();const L=d||w.length;if(L<a.demanded.length)throw new YError(`Not enough arguments provided. Expected ${a.demanded.length} but received ${w.length}.`);const y=a.demanded.length+a.optional.length;if(L>y)throw new YError(`Too many arguments provided. Expected max ${y} but received ${L}.`);a.demanded.forEach(B=>{const N=w.shift(),z=guessType(N);B.cmd.filter(H=>H===z||H==="*").length===0&&argumentTypeError(z,B.cmd,o),o+=1}),a.optional.forEach(B=>{if(w.length===0)return;const N=w.shift(),z=guessType(N);B.cmd.filter(H=>H===z||H==="*").length===0&&argumentTypeError(z,B.cmd,o),o+=1})}catch(o){console.warn(o.stack)}}function guessType(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function argumentTypeError(s,e,t){throw new YError(`Invalid ${positionName[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${s}.`)}class GlobalMiddleware{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,o=!1){if(argsert("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let a=0;a<e.length;a++){if(typeof e[a]!="function")throw Error("middleware must be a function");const l=e[a];l.applyBeforeValidation=t,l.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){const a=e;a.applyBeforeValidation=t,a.global=n,a.mutates=o,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(o=>{const a=[...n[t]||[],t];return o.option?!a.includes(o.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}}function commandMiddlewareFactory(s){return s?s.map(e=>(e.applyBeforeValidation=!1,e)):[]}function applyMiddleware(s,e,t,n){return t.reduce((o,a)=>{if(a.applyBeforeValidation!==n)return o;if(a.mutates){if(a.applied)return o;a.applied=!0}if(isPromise(o))return o.then(l=>Promise.all([l,a(l,e)])).then(([l,d])=>Object.assign(l,d));{const l=a(o,e);return isPromise(l)?l.then(d=>Object.assign(o,d)):Object.assign(o,l)}},s)}function maybeAsyncResult(s,e,t=n=>{throw n}){try{const n=isFunction(s)?s():s;return isPromise(n)?n.then(o=>e(o)):e(n)}catch(n){return t(n)}}function isFunction(s){return typeof s=="function"}function whichModule(s){if(typeof require>"u")return null;for(let e=0,t=Object.keys(require.cache),n;e<t.length;e++)if(n=require.cache[t[e]],n.exports===s)return n;return null}const DEFAULT_MARKER=/(^\*)|(^\$0)/;class CommandInstance{constructor(e,t,n,o){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=o,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,o){o=o||{},typeof o.recurse!="boolean"&&(o.recurse=!1),Array.isArray(o.extensions)||(o.extensions=["js"]);const a=typeof o.visit=="function"?o.visit:l=>l;o.visit=(l,d,w)=>{const L=a(l,d,w);if(L){if(this.requireCache.has(d))return L;this.requireCache.add(d),this.addHandler(L)}return L},this.shim.requireDirectory({require:t,filename:n},e,o)}addHandler(e,t,n,o,a,l){let d=[];const w=commandMiddlewareFactory(a);if(o=o||(()=>{}),Array.isArray(e))if(isCommandAndAliases(e))[e,...d]=e;else for(const L of e)this.addHandler(L);else if(isCommandHandlerDefinition(e)){let L=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(L=[].concat(L).concat(e.aliases)),this.addHandler(L,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(isCommandBuilderDefinition(n)){this.addHandler([e].concat(d),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){const L=parseCommand(e);d=d.map(N=>parseCommand(N).cmd);let y=!1;const B=[L.cmd].concat(d).filter(N=>DEFAULT_MARKER.test(N)?(y=!0,!1):!0);B.length===0&&y&&B.push("$0"),y&&(L.cmd=B[0],d=B.slice(1),e=e.replace(DEFAULT_MARKER,L.cmd)),d.forEach(N=>{this.aliasMap[N]=L.cmd}),t!==!1&&this.usage.command(e,t,y,d,l),this.handlers[L.cmd]={original:e,description:t,handler:o,builder:n||{},middlewares:w,deprecated:l,demanded:L.demanded,optional:L.optional},y&&(this.defaultCommand=this.handlers[L.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,o,a,l){const d=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,w=t.getInternalMethods().getContext(),L=w.commands.slice(),y=!e;e&&(w.commands.push(e),w.fullCommands.push(d.original));const B=this.applyBuilderUpdateUsageAndParse(y,d,t,n.aliases,L,o,a,l);return isPromise(B)?B.then(N=>this.applyMiddlewareAndGetResult(y,d,N.innerArgv,w,a,N.aliases,t)):this.applyMiddlewareAndGetResult(y,d,B.innerArgv,w,a,B.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,o,a,l,d,w){const L=t.builder;let y=n;if(isCommandBuilderCallback(L)){n.getInternalMethods().getUsageInstance().freeze();const B=L(n.getInternalMethods().reset(o),w);if(isPromise(B))return B.then(N=>(y=isYargsInstance(N)?N:n,this.parseAndUpdateUsage(e,t,y,a,l,d)))}else isCommandBuilderOptionDefinitions(L)&&(n.getInternalMethods().getUsageInstance().freeze(),y=n.getInternalMethods().reset(o),Object.keys(t.builder).forEach(B=>{y.option(B,L[B])}));return this.parseAndUpdateUsage(e,t,y,a,l,d)}parseAndUpdateUsage(e,t,n,o,a,l){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(o,t),t.description);const d=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,a,l);return isPromise(d)?d.then(w=>({aliases:n.parsed.aliases,innerArgv:w})):{aliases:n.parsed.aliases,innerArgv:d}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){const n=DEFAULT_MARKER.test(t.original)?t.original.replace(DEFAULT_MARKER,"").trim():t.original,o=e.filter(a=>!DEFAULT_MARKER.test(a));return o.push(n),`$0 ${o.join(" ")}`}handleValidationAndGetResult(e,t,n,o,a,l,d,w){if(!l.getInternalMethods().getHasOutput()){const L=l.getInternalMethods().runValidation(a,w,l.parsed.error,e);n=maybeAsyncResult(n,y=>(L(y),y))}if(t.handler&&!l.getInternalMethods().getHasOutput()){l.getInternalMethods().setHasOutput();const L=!!l.getOptions().configuration["populate--"];l.getInternalMethods().postProcess(n,L,!1,!1),n=applyMiddleware(n,l,d,!1),n=maybeAsyncResult(n,y=>{const B=t.handler(y);return isPromise(B)?B.then(()=>y):y}),e||l.getInternalMethods().getUsageInstance().cacheHelpMessage(),isPromise(n)&&!l.getInternalMethods().hasParseCallback()&&n.catch(y=>{try{l.getInternalMethods().getUsageInstance().fail(null,y)}catch{}})}return e||(o.commands.pop(),o.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,o,a,l,d){let w={};if(a)return n;d.getInternalMethods().getHasOutput()||(w=this.populatePositionals(t,n,o,d));const L=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),y=applyMiddleware(n,d,L,!0);return isPromise(y)?y.then(B=>this.handleValidationAndGetResult(e,t,B,o,l,d,L,w)):this.handleValidationAndGetResult(e,t,y,o,l,d,L,w)}populatePositionals(e,t,n,o){t._=t._.slice(n.commands.length);const a=e.demanded.slice(0),l=e.optional.slice(0),d={};for(this.validation.positionalCount(a.length,t._.length);a.length;){const w=a.shift();this.populatePositional(w,t,d)}for(;l.length;){const w=l.shift();this.populatePositional(w,t,d)}return t._=n.commands.concat(t._.map(w=>""+w)),this.postProcessPositionals(t,d,this.cmdToParseOptions(e.original),o),d}populatePositional(e,t,n){const o=e.cmd[0];e.variadic?n[o]=t._.splice(0).map(String):t._.length&&(n[o]=[String(t._.shift())])}cmdToParseOptions(e){const t={array:[],default:{},alias:{},demand:{}},n=parseCommand(e);return n.demanded.forEach(o=>{const[a,...l]=o.cmd;o.variadic&&(t.array.push(a),t.default[a]=[]),t.alias[a]=l,t.demand[a]=!0}),n.optional.forEach(o=>{const[a,...l]=o.cmd;o.variadic&&(t.array.push(a),t.default[a]=[]),t.alias[a]=l}),t}postProcessPositionals(e,t,n,o){const a=Object.assign({},o.getOptions());a.default=Object.assign(n.default,a.default);for(const L of Object.keys(n.alias))a.alias[L]=(a.alias[L]||[]).concat(n.alias[L]);a.array=a.array.concat(n.array),a.config={};const l=[];if(Object.keys(t).forEach(L=>{t[L].map(y=>{a.configuration["unknown-options-as-args"]&&(a.key[L]=!0),l.push(`--${L}`),l.push(y)})}),!l.length)return;const d=Object.assign({},a.configuration,{"populate--":!1}),w=this.shim.Parser.detailed(l,Object.assign({},a,{configuration:d}));if(w.error)o.getInternalMethods().getUsageInstance().fail(w.error.message,w.error);else{const L=Object.keys(t);Object.keys(t).forEach(y=>{L.push(...w.aliases[y])}),Object.keys(w.argv).forEach(y=>{L.includes(y)&&(t[y]||(t[y]=w.argv[y]),!this.isInConfigs(o,y)&&!this.isDefaulted(o,y)&&Object.prototype.hasOwnProperty.call(e,y)&&Object.prototype.hasOwnProperty.call(w.argv,y)&&(Array.isArray(e[y])||Array.isArray(w.argv[y]))?e[y]=[].concat(e[y],w.argv[y]):e[y]=w.argv[y])})}}isDefaulted(e,t){const{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){const{configObjects:n}=e.getOptions();return n.some(o=>Object.prototype.hasOwnProperty.call(o,t))||n.some(o=>Object.prototype.hasOwnProperty.call(o,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){const n=DEFAULT_MARKER.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}const t=this.defaultCommand.builder;if(isCommandBuilderCallback(t))return t(e,!0);isCommandBuilderDefinition(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){const t=whichModule(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(const o of[e,t,n]){if(typeof o=="string"||o===!1)return o;assertNotStrictEqual(o,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const e=this.frozens.pop();assertNotStrictEqual(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function command(s,e,t,n){return new CommandInstance(s,e,t,n)}function isCommandBuilderDefinition(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function isCommandAndAliases(s){return s.every(e=>typeof e=="string")}function isCommandBuilderCallback(s){return typeof s=="function"}function isCommandBuilderOptionDefinitions(s){return typeof s=="object"}function isCommandHandlerDefinition(s){return typeof s=="object"&&!Array.isArray(s)}function objFilter(s={},e=()=>!0){const t={};return objectKeys(s).forEach(n=>{e(n,s[n])&&(t[n]=s[n])}),t}function setBlocking(s){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{const t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(s)})}function isBoolean(s){return typeof s=="boolean"}function usage(s,e){const t=e.y18n.__,n={},o=[];n.failFn=function(ee){o.push(ee)};let a=null,l=null,d=!0;n.showHelpOnFail=function(ee=!0,ie){const[de,me]=typeof ee=="string"?[!0,ee]:[ee,ie];return s.getInternalMethods().isGlobalContext()&&(l=me),a=me,d=de,n};let w=!1;n.fail=function(ee,ie){const de=s.getInternalMethods().getLoggerInstance();if(o.length)for(let me=o.length-1;me>=0;--me){const be=o[me];if(isBoolean(be)){if(ie)throw ie;if(ee)throw Error(ee)}else be(ee,ie,n)}else{if(s.getExitProcess()&&setBlocking(!0),!w){w=!0,d&&(s.showHelp("error"),de.error()),(ee||ie)&&de.error(ee||ie);const me=a||l;me&&((ee||ie)&&de.error(""),de.error(me))}if(ie=ie||new YError(ee),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,ie);throw ie}};let L=[],y=!1;n.usage=(se,ee)=>se===null?(y=!0,L=[],n):(y=!1,L.push([se,ee||""]),n),n.getUsage=()=>L,n.getUsageDisabled=()=>y,n.getPositionalGroupName=()=>t("Positionals:");let B=[];n.example=(se,ee)=>{B.push([se,ee||""])};let N=[];n.command=function(ee,ie,de,me,be=!1){de&&(N=N.map(pe=>(pe[2]=!1,pe))),N.push([ee,ie||"",de,me,be])},n.getCommands=()=>N;let z={};n.describe=function(ee,ie){Array.isArray(ee)?ee.forEach(de=>{n.describe(de,ie)}):typeof ee=="object"?Object.keys(ee).forEach(de=>{n.describe(de,ee[de])}):z[ee]=ie},n.getDescriptions=()=>z;let Q=[];n.epilog=se=>{Q.push(se)};let H=!1,T;n.wrap=se=>{H=!0,T=se},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(H||(T=Pe(),H=!0),T);const X="__yargsString__:";n.deferY18nLookup=se=>X+se,n.help=function(){if(oe)return oe;le();const ee=s.customScriptName?s.$0:e.path.basename(s.$0),ie=s.getDemandedOptions(),de=s.getDemandedCommands(),me=s.getDeprecatedOptions(),be=s.getGroups(),pe=s.getOptions();let Fe=[];Fe=Fe.concat(Object.keys(z)),Fe=Fe.concat(Object.keys(ie)),Fe=Fe.concat(Object.keys(de)),Fe=Fe.concat(Object.keys(pe.default)),Fe=Fe.filter(ve),Fe=Object.keys(Fe.reduce((ae,De)=>(De!=="_"&&(ae[De]=!0),ae),{}));const je=n.getWrap(),Ce=e.cliui({width:je,wrap:!!je});if(!y){if(L.length)L.forEach(ae=>{Ce.div({text:`${ae[0].replace(/\$0/g,ee)}`}),ae[1]&&Ce.div({text:`${ae[1]}`,padding:[1,0,0,0]})}),Ce.div();else if(N.length){let ae=null;de._?ae=`${ee} <${t("command")}>
|
|
8
|
+
`:ae=`${ee} [${t("command")}]
|
|
9
|
+
`,Ce.div(`${ae}`)}}if(N.length>1||N.length===1&&!N[0][2]){Ce.div(t("Commands:"));const ae=s.getInternalMethods().getContext(),De=ae.commands.length?`${ae.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(N=N.sort((he,Ae)=>he[0].localeCompare(Ae[0])));const we=ee?`${ee} `:"";N.forEach(he=>{const Ae=`${we}${De}${he[0].replace(/^\$0 ?/,"")}`;Ce.span({text:Ae,padding:[0,2,0,2],width:ne(N,je,`${ee}${De}`)+4},{text:he[1]});const Ee=[];he[2]&&Ee.push(`[${t("default")}]`),he[3]&&he[3].length&&Ee.push(`[${t("aliases:")} ${he[3].join(", ")}]`),he[4]&&(typeof he[4]=="string"?Ee.push(`[${t("deprecated: %s",he[4])}]`):Ee.push(`[${t("deprecated")}]`)),Ee.length?Ce.div({text:Ee.join(" "),padding:[0,0,0,2],align:"right"}):Ce.div()}),Ce.div()}const xe=(Object.keys(pe.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);Fe=Fe.filter(ae=>!s.parsed.newAliases[ae]&&xe.every(De=>(pe.alias[De]||[]).indexOf(ae)===-1));const Ie=t("Options:");be[Ie]||(be[Ie]=[]),fe(Fe,pe.alias,be,Ie);const Le=ae=>/^--/.test(getText(ae)),ce=Object.keys(be).filter(ae=>be[ae].length>0).map(ae=>{const De=be[ae].filter(ve).map(we=>{if(xe.includes(we))return we;for(let he=0,Ae;(Ae=xe[he])!==void 0;he++)if((pe.alias[Ae]||[]).includes(we))return Ae;return we});return{groupName:ae,normalizedKeys:De}}).filter(({normalizedKeys:ae})=>ae.length>0).map(({groupName:ae,normalizedKeys:De})=>{const we=De.reduce((he,Ae)=>(he[Ae]=[Ae].concat(pe.alias[Ae]||[]).map(Ee=>ae===n.getPositionalGroupName()?Ee:(/^[0-9]$/.test(Ee)?pe.boolean.includes(Ae)?"-":"--":Ee.length>1?"--":"-")+Ee).sort((Ee,Oe)=>Le(Ee)===Le(Oe)?0:Le(Ee)?1:-1).join(", "),he),{});return{groupName:ae,normalizedKeys:De,switches:we}});if(ce.filter(({groupName:ae})=>ae!==n.getPositionalGroupName()).some(({normalizedKeys:ae,switches:De})=>!ae.every(we=>Le(De[we])))&&ce.filter(({groupName:ae})=>ae!==n.getPositionalGroupName()).forEach(({normalizedKeys:ae,switches:De})=>{ae.forEach(we=>{Le(De[we])&&(De[we]=addIndentation(De[we],4))})}),ce.forEach(({groupName:ae,normalizedKeys:De,switches:we})=>{Ce.div(ae),De.forEach(he=>{const Ae=we[he];let Ee=z[he]||"",Oe=null;Ee.includes(X)&&(Ee=t(Ee.substring(X.length))),pe.boolean.includes(he)&&(Oe=`[${t("boolean")}]`),pe.count.includes(he)&&(Oe=`[${t("count")}]`),pe.string.includes(he)&&(Oe=`[${t("string")}]`),pe.normalize.includes(he)&&(Oe=`[${t("string")}]`),pe.array.includes(he)&&(Oe=`[${t("array")}]`),pe.number.includes(he)&&(Oe=`[${t("number")}]`);const Se=W=>typeof W=="string"?`[${t("deprecated: %s",W)}]`:`[${t("deprecated")}]`,Ne=[he in me?Se(me[he]):null,Oe,he in ie?`[${t("required")}]`:null,pe.choices&&pe.choices[he]?`[${t("choices:")} ${n.stringifiedValues(pe.choices[he])}]`:null,_e(pe.default[he],pe.defaultDescription[he])].filter(Boolean).join(" ");Ce.span({text:getText(Ae),padding:[0,2,0,2+getIndentation(Ae)],width:ne(we,je)+4},Ee);const _=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;Ne&&!_?Ce.div({text:Ne,padding:[0,0,0,2],align:"right"}):Ce.div()}),Ce.div()}),B.length&&(Ce.div(t("Examples:")),B.forEach(ae=>{ae[0]=ae[0].replace(/\$0/g,ee)}),B.forEach(ae=>{ae[1]===""?Ce.div({text:ae[0],padding:[0,2,0,2]}):Ce.div({text:ae[0],padding:[0,2,0,2],width:ne(B,je)+4},{text:ae[1]})}),Ce.div()),Q.length>0){const ae=Q.map(De=>De.replace(/\$0/g,ee)).join(`
|
|
10
|
+
`);Ce.div(`${ae}
|
|
11
|
+
`)}return Ce.toString().replace(/\s*$/,"")};function ne(se,ee,ie){let de=0;return Array.isArray(se)||(se=Object.values(se).map(me=>[me])),se.forEach(me=>{de=Math.max(e.stringWidth(ie?`${ie} ${getText(me[0])}`:getText(me[0]))+getIndentation(me[0]),de)}),ee&&(de=Math.min(de,parseInt((ee*.5).toString(),10))),de}function le(){const se=s.getDemandedOptions(),ee=s.getOptions();(Object.keys(ee.alias)||[]).forEach(ie=>{ee.alias[ie].forEach(de=>{z[de]&&n.describe(ie,z[de]),de in se&&s.demandOption(ie,se[de]),ee.boolean.includes(de)&&s.boolean(ie),ee.count.includes(de)&&s.count(ie),ee.string.includes(de)&&s.string(ie),ee.normalize.includes(de)&&s.normalize(ie),ee.array.includes(de)&&s.array(ie),ee.number.includes(de)&&s.number(ie)})})}let oe;n.cacheHelpMessage=function(){oe=this.help()},n.clearCachedHelpMessage=function(){oe=void 0},n.hasCachedHelpMessage=function(){return!!oe};function fe(se,ee,ie,de){let me=[],be=null;return Object.keys(ie).forEach(pe=>{me=me.concat(ie[pe])}),se.forEach(pe=>{be=[pe].concat(ee[pe]),be.some(Fe=>me.indexOf(Fe)!==-1)||ie[de].push(pe)}),me}function ve(se){return s.getOptions().hiddenOptions.indexOf(se)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=se=>{const ee=s.getInternalMethods().getLoggerInstance();se||(se="error"),(typeof se=="function"?se:ee[se])(n.help())},n.functionDescription=se=>["(",se.name?e.Parser.decamelize(se.name,"-"):t("generated-value"),")"].join(""),n.stringifiedValues=function(ee,ie){let de="";const me=ie||", ",be=[].concat(ee);return!ee||!be.length||be.forEach(pe=>{de.length&&(de+=me),de+=JSON.stringify(pe)}),de};function _e(se,ee){let ie=`[${t("default:")} `;if(se===void 0&&!ee)return null;if(ee)ie+=ee;else switch(typeof se){case"string":ie+=`"${se}"`;break;case"object":ie+=JSON.stringify(se);break;default:ie+=se}return`${ie}]`}function Pe(){return e.process.stdColumns?Math.min(80,e.process.stdColumns):80}let $e=null;n.version=se=>{$e=se},n.showVersion=se=>{const ee=s.getInternalMethods().getLoggerInstance();se||(se="error"),(typeof se=="function"?se:ee[se])($e)},n.reset=function(ee){return a=null,w=!1,L=[],y=!1,Q=[],B=[],N=[],z=objFilter(z,ie=>!ee[ie]),n};const ge=[];return n.freeze=function(){ge.push({failMessage:a,failureOutput:w,usages:L,usageDisabled:y,epilogs:Q,examples:B,commands:N,descriptions:z})},n.unfreeze=function(ee=!1){const ie=ge.pop();ie&&(ee?(z={...ie.descriptions,...z},N=[...ie.commands,...N],L=[...ie.usages,...L],B=[...ie.examples,...B],Q=[...ie.epilogs,...Q]):{failMessage:a,failureOutput:w,usages:L,usageDisabled:y,epilogs:Q,examples:B,commands:N,descriptions:z}=ie)},n}function isIndentedText(s){return typeof s=="object"}function addIndentation(s,e){return isIndentedText(s)?{text:s.text,indentation:s.indentation+e}:{text:s,indentation:e}}function getIndentation(s){return isIndentedText(s)?s.indentation:0}function getText(s){return isIndentedText(s)?s.text:s}const completionShTemplate=`###-begin-{{app_name}}-completions-###
|
|
12
|
+
#
|
|
13
|
+
# yargs command completion script
|
|
14
|
+
#
|
|
15
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
|
16
|
+
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
|
17
|
+
#
|
|
18
|
+
_{{app_name}}_yargs_completions()
|
|
19
|
+
{
|
|
20
|
+
local cur_word args type_list
|
|
21
|
+
|
|
22
|
+
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
23
|
+
args=("\${COMP_WORDS[@]}")
|
|
24
|
+
|
|
25
|
+
# ask yargs to generate completions.
|
|
26
|
+
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
27
|
+
|
|
28
|
+
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
|
29
|
+
|
|
30
|
+
# if no match was found, fall back to filename completion
|
|
31
|
+
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
|
32
|
+
COMPREPLY=()
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
return 0
|
|
36
|
+
}
|
|
37
|
+
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
38
|
+
###-end-{{app_name}}-completions-###
|
|
39
|
+
`,completionZshTemplate=`#compdef {{app_name}}
|
|
40
|
+
###-begin-{{app_name}}-completions-###
|
|
41
|
+
#
|
|
42
|
+
# yargs command completion script
|
|
43
|
+
#
|
|
44
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
45
|
+
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
|
|
46
|
+
#
|
|
47
|
+
_{{app_name}}_yargs_completions()
|
|
48
|
+
{
|
|
49
|
+
local reply
|
|
50
|
+
local si=$IFS
|
|
51
|
+
IFS=$'
|
|
52
|
+
' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
|
53
|
+
IFS=$si
|
|
54
|
+
_describe 'values' reply
|
|
55
|
+
}
|
|
56
|
+
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
57
|
+
###-end-{{app_name}}-completions-###
|
|
58
|
+
`;class Completion{constructor(e,t,n,o){var a,l,d;this.yargs=e,this.usage=t,this.command=n,this.shim=o,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(d=((a=this.shim.getEnv("SHELL"))===null||a===void 0?void 0:a.includes("zsh"))||((l=this.shim.getEnv("ZSH_NAME"))===null||l===void 0?void 0:l.includes("zsh")))!==null&&d!==void 0?d:!1}defaultCompletion(e,t,n,o){const a=this.command.getCommandHandlers();for(let d=0,w=e.length;d<w;++d)if(a[e[d]]&&a[e[d]].builder){const L=a[e[d]].builder;if(isCommandBuilderCallback(L)){this.indexAfterLastReset=d+1;const y=this.yargs.getInternalMethods().reset();return L(y,!0),y.argv}}const l=[];this.commandCompletions(l,e,n),this.optionCompletions(l,e,t,n),this.choicesFromOptionsCompletions(l,e,t,n),this.choicesFromPositionalsCompletions(l,e,t,n),o(null,l)}commandCompletions(e,t,n){const o=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&o[o.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(a=>{const l=parseCommand(a[0]).cmd;if(t.indexOf(l)===-1)if(!this.zshShell)e.push(l);else{const d=a[1]||"";e.push(l.replace(/:/g,"\\:")+":"+d)}})}optionCompletions(e,t,n,o){if((o.match(/^-/)||o===""&&e.length===0)&&!this.previousArgHasChoices(t)){const a=this.yargs.getOptions(),l=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(a.key).forEach(d=>{const w=!!a.configuration["boolean-negation"]&&a.boolean.includes(d);!l.includes(d)&&!a.hiddenOptions.includes(d)&&!this.argsContainKey(t,d,w)&&this.completeOptionKey(d,e,o,w&&!!a.default[d])})}}choicesFromOptionsCompletions(e,t,n,o){if(this.previousArgHasChoices(t)){const a=this.getPreviousArgChoices(t);a&&a.length>0&&e.push(...a.map(l=>l.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,o){if(o===""&&e.length>0&&this.previousArgHasChoices(t))return;const a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],l=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),d=a[n._.length-l-1];if(!d)return;const w=this.yargs.getOptions().choices[d]||[];for(const L of w)L.startsWith(o)&&e.push(L.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;const o=t.replace(/^-+/,""),a=this.yargs.getOptions(),l=[o,...this.yargs.getAliases()[o]||[]];let d;for(const w of l)if(Object.prototype.hasOwnProperty.call(a.key,w)&&Array.isArray(a.choices[w])){d=a.choices[w];break}if(d)return d.filter(w=>!n||w.startsWith(n))}previousArgHasChoices(e){const t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){const o=a=>e.indexOf((/^[^0-9]$/.test(a)?"-":"--")+a)!==-1;if(o(t)||n&&o(`no-${t}`))return!0;if(this.aliases){for(const a of this.aliases[t])if(o(a))return!0}return!1}completeOptionKey(e,t,n,o){var a,l,d,w;let L=e;if(this.zshShell){const z=this.usage.getDescriptions(),Q=(l=(a=this===null||this===void 0?void 0:this.aliases)===null||a===void 0?void 0:a[e])===null||l===void 0?void 0:l.find(X=>{const ne=z[X];return typeof ne=="string"&&ne.length>0}),H=Q?z[Q]:void 0,T=(w=(d=z[e])!==null&&d!==void 0?d:H)!==null&&w!==void 0?w:"";L=`${e.replace(/:/g,"\\:")}:${T.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const y=z=>/^--/.test(z),B=z=>/^[^0-9]$/.test(z),N=!y(n)&&B(e)?"-":"--";t.push(N+L),o&&t.push(N+"no-"+L)}customCompletion(e,t,n,o){if(assertNotStrictEqual(this.customCompletionFunction,null,this.shim),isSyncCompletionFunction(this.customCompletionFunction)){const a=this.customCompletionFunction(n,t);return isPromise(a)?a.then(l=>{this.shim.process.nextTick(()=>{o(null,l)})}).catch(l=>{this.shim.process.nextTick(()=>{o(l,void 0)})}):o(null,a)}else return isFallbackCompletionFunction(this.customCompletionFunction)?this.customCompletionFunction(n,t,(a=o)=>this.defaultCompletion(e,t,n,a),a=>{o(null,a)}):this.customCompletionFunction(n,t,a=>{o(null,a)})}getCompletion(e,t){const n=e.length?e[e.length-1]:"",o=this.yargs.parse(e,!0),a=this.customCompletionFunction?l=>this.customCompletion(e,l,n,t):l=>this.defaultCompletion(e,l,n,t);return isPromise(o)?o.then(a):a(o)}generateCompletionScript(e,t){let n=this.zshShell?completionZshTemplate:completionShTemplate;const o=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,o),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function completion(s,e,t,n){return new Completion(s,e,t,n)}function isSyncCompletionFunction(s){return s.length<3}function isFallbackCompletionFunction(s){return s.length>3}function levenshtein(s,e){if(s.length===0)return e.length;if(e.length===0)return s.length;const t=[];let n;for(n=0;n<=e.length;n++)t[n]=[n];let o;for(o=0;o<=s.length;o++)t[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=s.length;o++)e.charAt(n-1)===s.charAt(o-1)?t[n][o]=t[n-1][o-1]:n>1&&o>1&&e.charAt(n-2)===s.charAt(o-1)&&e.charAt(n-1)===s.charAt(o-2)?t[n][o]=t[n-2][o-2]+1:t[n][o]=Math.min(t[n-1][o-1]+1,Math.min(t[n][o-1]+1,t[n-1][o]+1));return t[e.length][s.length]}const specialKeys=["$0","--","_"];function validation(s,e,t){const n=t.y18n.__,o=t.y18n.__n,a={};a.nonOptionCount=function(B){const N=s.getDemandedCommands(),Q=B._.length+(B["--"]?B["--"].length:0)-s.getInternalMethods().getContext().commands.length;N._&&(Q<N._.min||Q>N._.max)&&(Q<N._.min?N._.minMsg!==void 0?e.fail(N._.minMsg?N._.minMsg.replace(/\$0/g,Q.toString()).replace(/\$1/,N._.min.toString()):null):e.fail(o("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Q,Q.toString(),N._.min.toString())):Q>N._.max&&(N._.maxMsg!==void 0?e.fail(N._.maxMsg?N._.maxMsg.replace(/\$0/g,Q.toString()).replace(/\$1/,N._.max.toString()):null):e.fail(o("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",Q,Q.toString(),N._.max.toString()))))},a.positionalCount=function(B,N){N<B&&e.fail(o("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",N,N+"",B+""))},a.requiredArguments=function(B,N){let z=null;for(const Q of Object.keys(N))(!Object.prototype.hasOwnProperty.call(B,Q)||typeof B[Q]>"u")&&(z=z||{},z[Q]=N[Q]);if(z){const Q=[];for(const T of Object.keys(z)){const X=z[T];X&&Q.indexOf(X)<0&&Q.push(X)}const H=Q.length?`
|
|
59
|
+
${Q.join(`
|
|
60
|
+
`)}`:"";e.fail(o("Missing required argument: %s","Missing required arguments: %s",Object.keys(z).length,Object.keys(z).join(", ")+H))}},a.unknownArguments=function(B,N,z,Q,H=!0){var T;const X=s.getInternalMethods().getCommandInstance().getCommands(),ne=[],le=s.getInternalMethods().getContext();if(Object.keys(B).forEach(oe=>{!specialKeys.includes(oe)&&!Object.prototype.hasOwnProperty.call(z,oe)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),oe)&&!a.isValidAndSomeAliasIsNotNew(oe,N)&&ne.push(oe)}),H&&(le.commands.length>0||X.length>0||Q)&&B._.slice(le.commands.length).forEach(oe=>{X.includes(""+oe)||ne.push(""+oe)}),H){const fe=((T=s.getDemandedCommands()._)===null||T===void 0?void 0:T.max)||0,ve=le.commands.length+fe;ve<B._.length&&B._.slice(ve).forEach(_e=>{_e=String(_e),!le.commands.includes(_e)&&!ne.includes(_e)&&ne.push(_e)})}ne.length&&e.fail(o("Unknown argument: %s","Unknown arguments: %s",ne.length,ne.map(oe=>oe.trim()?oe:`"${oe}"`).join(", ")))},a.unknownCommands=function(B){const N=s.getInternalMethods().getCommandInstance().getCommands(),z=[],Q=s.getInternalMethods().getContext();return(Q.commands.length>0||N.length>0)&&B._.slice(Q.commands.length).forEach(H=>{N.includes(""+H)||z.push(""+H)}),z.length>0?(e.fail(o("Unknown command: %s","Unknown commands: %s",z.length,z.join(", "))),!0):!1},a.isValidAndSomeAliasIsNotNew=function(B,N){if(!Object.prototype.hasOwnProperty.call(N,B))return!1;const z=s.parsed.newAliases;return[B,...N[B]].some(Q=>!Object.prototype.hasOwnProperty.call(z,Q)||!z[B])},a.limitedChoices=function(B){const N=s.getOptions(),z={};if(!Object.keys(N.choices).length)return;Object.keys(B).forEach(T=>{specialKeys.indexOf(T)===-1&&Object.prototype.hasOwnProperty.call(N.choices,T)&&[].concat(B[T]).forEach(X=>{N.choices[T].indexOf(X)===-1&&X!==void 0&&(z[T]=(z[T]||[]).concat(X))})});const Q=Object.keys(z);if(!Q.length)return;let H=n("Invalid values:");Q.forEach(T=>{H+=`
|
|
61
|
+
${n("Argument: %s, Given: %s, Choices: %s",T,e.stringifiedValues(z[T]),e.stringifiedValues(N.choices[T]))}`}),e.fail(H)};let l={};a.implies=function(B,N){argsert("<string|object> [array|number|string]",[B,N],arguments.length),typeof B=="object"?Object.keys(B).forEach(z=>{a.implies(z,B[z])}):(s.global(B),l[B]||(l[B]=[]),Array.isArray(N)?N.forEach(z=>a.implies(B,z)):(assertNotStrictEqual(N,void 0,t),l[B].push(N)))},a.getImplied=function(){return l};function d(y,B){const N=Number(B);return B=isNaN(N)?B:N,typeof B=="number"?B=y._.length>=B:B.match(/^--no-.+/)?(B=B.match(/^--no-(.+)/)[1],B=!Object.prototype.hasOwnProperty.call(y,B)):B=Object.prototype.hasOwnProperty.call(y,B),B}a.implications=function(B){const N=[];if(Object.keys(l).forEach(z=>{const Q=z;(l[z]||[]).forEach(H=>{let T=Q;const X=H;T=d(B,T),H=d(B,H),T&&!H&&N.push(` ${Q} -> ${X}`)})}),N.length){let z=`${n("Implications failed:")}
|
|
62
|
+
`;N.forEach(Q=>{z+=Q}),e.fail(z)}};let w={};a.conflicts=function(B,N){argsert("<string|object> [array|string]",[B,N],arguments.length),typeof B=="object"?Object.keys(B).forEach(z=>{a.conflicts(z,B[z])}):(s.global(B),w[B]||(w[B]=[]),Array.isArray(N)?N.forEach(z=>a.conflicts(B,z)):w[B].push(N))},a.getConflicting=()=>w,a.conflicting=function(B){Object.keys(B).forEach(N=>{w[N]&&w[N].forEach(z=>{z&&B[N]!==void 0&&B[z]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",N,z))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(w).forEach(N=>{w[N].forEach(z=>{z&&B[t.Parser.camelCase(N)]!==void 0&&B[t.Parser.camelCase(z)]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",N,z))})})},a.recommendCommands=function(B,N){N=N.sort((T,X)=>X.length-T.length);let Q=null,H=1/0;for(let T=0,X;(X=N[T])!==void 0;T++){const ne=levenshtein(B,X);ne<=3&&ne<H&&(H=ne,Q=X)}Q&&e.fail(n("Did you mean %s?",Q))},a.reset=function(B){return l=objFilter(l,N=>!B[N]),w=objFilter(w,N=>!B[N]),a};const L=[];return a.freeze=function(){L.push({implied:l,conflicting:w})},a.unfreeze=function(){const B=L.pop();assertNotStrictEqual(B,void 0,t),{implied:l,conflicting:w}=B},a}let previouslyVisitedConfigs=[],shim;function applyExtends(s,e,t,n){shim=n;let o={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return o;const a=/\.json|\..*rc$/.test(s.extends);let l=null;if(a)l=getPathToDefaultConfig(e,s.extends);else try{l=require.resolve(s.extends)}catch{return s}checkForCircularExtends(l),previouslyVisitedConfigs.push(l),o=a?JSON.parse(shim.readFileSync(l,"utf8")):require(s.extends),delete s.extends,o=applyExtends(o,shim.path.dirname(l),t,shim)}return previouslyVisitedConfigs=[],t?mergeDeep(o,s):Object.assign({},o,s)}function checkForCircularExtends(s){if(previouslyVisitedConfigs.indexOf(s)>-1)throw new YError(`Circular extended configurations: '${s}'.`)}function getPathToDefaultConfig(s,e){return shim.path.resolve(s,e)}function mergeDeep(s,e){const t={};function n(o){return o&&typeof o=="object"&&!Array.isArray(o)}Object.assign(t,s);for(const o of Object.keys(e))n(e[o])&&n(t[o])?t[o]=mergeDeep(s[o],e[o]):t[o]=e[o];return t}var __classPrivateFieldSet=function(s,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!o:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(s,t):o?o.value=t:e.set(s,t),t},__classPrivateFieldGet=function(s,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(s):n?n.value:e.get(s)},_YargsInstance_command,_YargsInstance_cwd,_YargsInstance_context,_YargsInstance_completion,_YargsInstance_completionCommand,_YargsInstance_defaultShowHiddenOpt,_YargsInstance_exitError,_YargsInstance_detectLocale,_YargsInstance_emittedWarnings,_YargsInstance_exitProcess,_YargsInstance_frozens,_YargsInstance_globalMiddleware,_YargsInstance_groups,_YargsInstance_hasOutput,_YargsInstance_helpOpt,_YargsInstance_isGlobalContext,_YargsInstance_logger,_YargsInstance_output,_YargsInstance_options,_YargsInstance_parentRequire,_YargsInstance_parserConfig,_YargsInstance_parseFn,_YargsInstance_parseContext,_YargsInstance_pkgs,_YargsInstance_preservedGroups,_YargsInstance_processArgs,_YargsInstance_recommendCommands,_YargsInstance_shim,_YargsInstance_strict,_YargsInstance_strictCommands,_YargsInstance_strictOptions,_YargsInstance_usage,_YargsInstance_usageConfig,_YargsInstance_versionOpt,_YargsInstance_validation;function YargsFactory(s){return(e=[],t=s.process.cwd(),n)=>{const o=new YargsInstance(e,t,n,s);return Object.defineProperty(o,"argv",{get:()=>o.parse(),enumerable:!0}),o.help(),o.version(),o}}const kCopyDoubleDash=Symbol("copyDoubleDash"),kCreateLogger=Symbol("copyDoubleDash"),kDeleteFromParserHintObject=Symbol("deleteFromParserHintObject"),kEmitWarning=Symbol("emitWarning"),kFreeze=Symbol("freeze"),kGetDollarZero=Symbol("getDollarZero"),kGetParserConfiguration=Symbol("getParserConfiguration"),kGetUsageConfiguration=Symbol("getUsageConfiguration"),kGuessLocale=Symbol("guessLocale"),kGuessVersion=Symbol("guessVersion"),kParsePositionalNumbers=Symbol("parsePositionalNumbers"),kPkgUp=Symbol("pkgUp"),kPopulateParserHintArray=Symbol("populateParserHintArray"),kPopulateParserHintSingleValueDictionary=Symbol("populateParserHintSingleValueDictionary"),kPopulateParserHintArrayDictionary=Symbol("populateParserHintArrayDictionary"),kPopulateParserHintDictionary=Symbol("populateParserHintDictionary"),kSanitizeKey=Symbol("sanitizeKey"),kSetKey=Symbol("setKey"),kUnfreeze=Symbol("unfreeze"),kValidateAsync=Symbol("validateAsync"),kGetCommandInstance=Symbol("getCommandInstance"),kGetContext=Symbol("getContext"),kGetHasOutput=Symbol("getHasOutput"),kGetLoggerInstance=Symbol("getLoggerInstance"),kGetParseContext=Symbol("getParseContext"),kGetUsageInstance=Symbol("getUsageInstance"),kGetValidationInstance=Symbol("getValidationInstance"),kHasParseCallback=Symbol("hasParseCallback"),kIsGlobalContext=Symbol("isGlobalContext"),kPostProcess=Symbol("postProcess"),kRebase=Symbol("rebase"),kReset=Symbol("reset"),kRunYargsParserAndExecuteCommands=Symbol("runYargsParserAndExecuteCommands"),kRunValidation=Symbol("runValidation"),kSetHasOutput=Symbol("setHasOutput"),kTrackManuallySetKeys=Symbol("kTrackManuallySetKeys");class YargsInstance{constructor(e=[],t,n,o){this.customScriptName=!1,this.parsed=!1,_YargsInstance_command.set(this,void 0),_YargsInstance_cwd.set(this,void 0),_YargsInstance_context.set(this,{commands:[],fullCommands:[]}),_YargsInstance_completion.set(this,null),_YargsInstance_completionCommand.set(this,null),_YargsInstance_defaultShowHiddenOpt.set(this,"show-hidden"),_YargsInstance_exitError.set(this,null),_YargsInstance_detectLocale.set(this,!0),_YargsInstance_emittedWarnings.set(this,{}),_YargsInstance_exitProcess.set(this,!0),_YargsInstance_frozens.set(this,[]),_YargsInstance_globalMiddleware.set(this,void 0),_YargsInstance_groups.set(this,{}),_YargsInstance_hasOutput.set(this,!1),_YargsInstance_helpOpt.set(this,null),_YargsInstance_isGlobalContext.set(this,!0),_YargsInstance_logger.set(this,void 0),_YargsInstance_output.set(this,""),_YargsInstance_options.set(this,void 0),_YargsInstance_parentRequire.set(this,void 0),_YargsInstance_parserConfig.set(this,{}),_YargsInstance_parseFn.set(this,null),_YargsInstance_parseContext.set(this,null),_YargsInstance_pkgs.set(this,{}),_YargsInstance_preservedGroups.set(this,{}),_YargsInstance_processArgs.set(this,void 0),_YargsInstance_recommendCommands.set(this,!1),_YargsInstance_shim.set(this,void 0),_YargsInstance_strict.set(this,!1),_YargsInstance_strictCommands.set(this,!1),_YargsInstance_strictOptions.set(this,!1),_YargsInstance_usage.set(this,void 0),_YargsInstance_usageConfig.set(this,{}),_YargsInstance_versionOpt.set(this,null),_YargsInstance_validation.set(this,void 0),__classPrivateFieldSet(this,_YargsInstance_shim,o,"f"),__classPrivateFieldSet(this,_YargsInstance_processArgs,e,"f"),__classPrivateFieldSet(this,_YargsInstance_cwd,t,"f"),__classPrivateFieldSet(this,_YargsInstance_parentRequire,n,"f"),__classPrivateFieldSet(this,_YargsInstance_globalMiddleware,new GlobalMiddleware(this),"f"),this.$0=this[kGetDollarZero](),this[kReset](),__classPrivateFieldSet(this,_YargsInstance_command,__classPrivateFieldGet(this,_YargsInstance_command,"f"),"f"),__classPrivateFieldSet(this,_YargsInstance_usage,__classPrivateFieldGet(this,_YargsInstance_usage,"f"),"f"),__classPrivateFieldSet(this,_YargsInstance_validation,__classPrivateFieldGet(this,_YargsInstance_validation,"f"),"f"),__classPrivateFieldSet(this,_YargsInstance_options,__classPrivateFieldGet(this,_YargsInstance_options,"f"),"f"),__classPrivateFieldGet(this,_YargsInstance_options,"f").showHiddenOpt=__classPrivateFieldGet(this,_YargsInstance_defaultShowHiddenOpt,"f"),__classPrivateFieldSet(this,_YargsInstance_logger,this[kCreateLogger](),"f")}addHelpOpt(e,t){const n="help";return argsert("[string|boolean] [string]",[e,t],arguments.length),__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")&&(this[kDeleteFromParserHintObject](__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")),__classPrivateFieldSet(this,_YargsInstance_helpOpt,null,"f")),e===!1&&t===void 0?this:(__classPrivateFieldSet(this,_YargsInstance_helpOpt,typeof e=="string"?e:n,"f"),this.boolean(__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")),this.describe(__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f"),t||__classPrivateFieldGet(this,_YargsInstance_usage,"f").deferY18nLookup("Show help")),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(argsert("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;const n=typeof e=="string"?e:__classPrivateFieldGet(this,_YargsInstance_defaultShowHiddenOpt,"f");return this.boolean(n),this.describe(n,t||__classPrivateFieldGet(this,_YargsInstance_usage,"f").deferY18nLookup("Show hidden options")),__classPrivateFieldGet(this,_YargsInstance_options,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return argsert("<object|string|array> [string|array]",[e,t],arguments.length),this[kPopulateParserHintArrayDictionary](this.alias.bind(this),"alias",e,t),this}array(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("array",e),this[kTrackManuallySetKeys](e),this}boolean(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("boolean",e),this[kTrackManuallySetKeys](e),this}check(e,t){return argsert("<function> [boolean]",[e,t],arguments.length),this.middleware((n,o)=>maybeAsyncResult(()=>e(n,o.getOptions()),a=>(a?(typeof a=="string"||a instanceof Error)&&__classPrivateFieldGet(this,_YargsInstance_usage,"f").fail(a.toString(),a):__classPrivateFieldGet(this,_YargsInstance_usage,"f").fail(__classPrivateFieldGet(this,_YargsInstance_shim,"f").y18n.__("Argument check failed: %s",e.toString())),n),a=>(__classPrivateFieldGet(this,_YargsInstance_usage,"f").fail(a.message?a.message:a.toString(),a),n)),!1,t),this}choices(e,t){return argsert("<object|string|array> [string|array]",[e,t],arguments.length),this[kPopulateParserHintArrayDictionary](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(argsert("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new YError("coerce callback must be provided");for(const n of e)this.coerce(n,t);return this}else if(typeof e=="object"){for(const n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new YError("coerce callback must be provided");return __classPrivateFieldGet(this,_YargsInstance_options,"f").key[e]=!0,__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").addCoerceMiddleware((n,o)=>{let a;return Object.prototype.hasOwnProperty.call(n,e)?maybeAsyncResult(()=>(a=o.getAliases(),t(n[e])),d=>{n[e]=d;const w=o.getInternalMethods().getParserConfiguration()["strip-aliased"];if(a[e]&&w!==!0)for(const L of a[e])n[L]=d;return n},d=>{throw new YError(d.message)}):n},e),this}conflicts(e,t){return argsert("<string|object> [string|array]",[e,t],arguments.length),__classPrivateFieldGet(this,_YargsInstance_validation,"f").conflicts(e,t),this}config(e="config",t,n){return argsert("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=applyExtends(e,__classPrivateFieldGet(this,_YargsInstance_cwd,"f"),this[kGetParserConfiguration]()["deep-merge-config"]||!1,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects=(__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects||[]).concat(e),this):(typeof t=="function"&&(n=t,t=void 0),this.describe(e,t||__classPrivateFieldGet(this,_YargsInstance_usage,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(o=>{__classPrivateFieldGet(this,_YargsInstance_options,"f").config[o]=n||!0}),this)}completion(e,t,n){return argsert("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t=="function"&&(n=t,t=void 0),__classPrivateFieldSet(this,_YargsInstance_completionCommand,e||__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f")||"completion","f"),!t&&t!==!1&&(t="generate completion script"),this.command(__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f"),t),n&&__classPrivateFieldGet(this,_YargsInstance_completion,"f").registerFunction(n),this}command(e,t,n,o,a,l){return argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,o,a,l],arguments.length),__classPrivateFieldGet(this,_YargsInstance_command,"f").addHandler(e,t,n,o,a,l),this}commands(e,t,n,o,a,l){return this.command(e,t,n,o,a,l)}commandDir(e,t){argsert("<string> [object]",[e,t],arguments.length);const n=__classPrivateFieldGet(this,_YargsInstance_parentRequire,"f")||__classPrivateFieldGet(this,_YargsInstance_shim,"f").require;return __classPrivateFieldGet(this,_YargsInstance_command,"f").addDirectory(e,n,__classPrivateFieldGet(this,_YargsInstance_shim,"f").getCallerFile(),t),this}count(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("count",e),this[kTrackManuallySetKeys](e),this}default(e,t,n){return argsert("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(assertSingleKey(e,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),__classPrivateFieldGet(this,_YargsInstance_options,"f").defaultDescription[e]=n),typeof t=="function"&&(assertSingleKey(e,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),__classPrivateFieldGet(this,_YargsInstance_options,"f").defaultDescription[e]||(__classPrivateFieldGet(this,_YargsInstance_options,"f").defaultDescription[e]=__classPrivateFieldGet(this,_YargsInstance_usage,"f").functionDescription(t)),t=t.call()),this[kPopulateParserHintSingleValueDictionary](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,o){return argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,o],arguments.length),typeof t!="number"&&(n=t,t=1/0),this.global("_",!1),__classPrivateFieldGet(this,_YargsInstance_options,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:o},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(o=>{assertNotStrictEqual(n,!0,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),this.demandOption(o,n)}),t=1/0):typeof t!="number"&&(n=t,t=1/0),typeof e=="number"?(assertNotStrictEqual(n,!0,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(o=>{assertNotStrictEqual(n,!0,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),this.demandOption(o,n)}):typeof n=="string"?this.demandOption(e,n):(n===!0||typeof n>"u")&&this.demandOption(e),this}demandOption(e,t){return argsert("<object|string|array> [string]",[e,t],arguments.length),this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return argsert("<string> [string|boolean]",[e,t],arguments.length),__classPrivateFieldGet(this,_YargsInstance_options,"f").deprecatedOptions[e]=t,this}describe(e,t){return argsert("<object|string|array> [string]",[e,t],arguments.length),this[kSetKey](e,!0),__classPrivateFieldGet(this,_YargsInstance_usage,"f").describe(e,t),this}detectLocale(e){return argsert("<boolean>",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_detectLocale,e,"f"),this}env(e){return argsert("[string|boolean]",[e],arguments.length),e===!1?delete __classPrivateFieldGet(this,_YargsInstance_options,"f").envPrefix:__classPrivateFieldGet(this,_YargsInstance_options,"f").envPrefix=e||"",this}epilogue(e){return argsert("<string>",[e],arguments.length),__classPrivateFieldGet(this,_YargsInstance_usage,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return argsert("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach(n=>this.example(...n)):__classPrivateFieldGet(this,_YargsInstance_usage,"f").example(e,t),this}exit(e,t){__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f"),__classPrivateFieldSet(this,_YargsInstance_exitError,t,"f"),__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")&&__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.exit(e)}exitProcess(e=!0){return argsert("[boolean]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_exitProcess,e,"f"),this}fail(e){if(argsert("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new YError("Invalid first argument. Expected function or boolean 'false'");return __classPrivateFieldGet(this,_YargsInstance_usage,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return argsert("<array> [function]",[e,t],arguments.length),t?__classPrivateFieldGet(this,_YargsInstance_completion,"f").getCompletion(e,t):new Promise((n,o)=>{__classPrivateFieldGet(this,_YargsInstance_completion,"f").getCompletion(e,(a,l)=>{a?o(a):n(l)})})}getDemandedOptions(){return argsert([],0),__classPrivateFieldGet(this,_YargsInstance_options,"f").demandedOptions}getDemandedCommands(){return argsert([],0),__classPrivateFieldGet(this,_YargsInstance_options,"f").demandedCommands}getDeprecatedOptions(){return argsert([],0),__classPrivateFieldGet(this,_YargsInstance_options,"f").deprecatedOptions}getDetectLocale(){return __classPrivateFieldGet(this,_YargsInstance_detectLocale,"f")}getExitProcess(){return __classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")}getGroups(){return Object.assign({},__classPrivateFieldGet(this,_YargsInstance_groups,"f"),__classPrivateFieldGet(this,_YargsInstance_preservedGroups,"f"))}getHelp(){if(__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f"),!__classPrivateFieldGet(this,_YargsInstance_usage,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this,_YargsInstance_processArgs,"f"),void 0,void 0,0,!0);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,_YargsInstance_usage,"f").help())}const e=__classPrivateFieldGet(this,_YargsInstance_command,"f").runDefaultBuilderOn(this);if(isPromise(e))return e.then(()=>__classPrivateFieldGet(this,_YargsInstance_usage,"f").help())}return Promise.resolve(__classPrivateFieldGet(this,_YargsInstance_usage,"f").help())}getOptions(){return __classPrivateFieldGet(this,_YargsInstance_options,"f")}getStrict(){return __classPrivateFieldGet(this,_YargsInstance_strict,"f")}getStrictCommands(){return __classPrivateFieldGet(this,_YargsInstance_strictCommands,"f")}getStrictOptions(){return __classPrivateFieldGet(this,_YargsInstance_strictOptions,"f")}global(e,t){return argsert("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1?__classPrivateFieldGet(this,_YargsInstance_options,"f").local=__classPrivateFieldGet(this,_YargsInstance_options,"f").local.filter(n=>e.indexOf(n)===-1):e.forEach(n=>{__classPrivateFieldGet(this,_YargsInstance_options,"f").local.includes(n)||__classPrivateFieldGet(this,_YargsInstance_options,"f").local.push(n)}),this}group(e,t){argsert("<string|array> <string>",[e,t],arguments.length);const n=__classPrivateFieldGet(this,_YargsInstance_preservedGroups,"f")[t]||__classPrivateFieldGet(this,_YargsInstance_groups,"f")[t];__classPrivateFieldGet(this,_YargsInstance_preservedGroups,"f")[t]&&delete __classPrivateFieldGet(this,_YargsInstance_preservedGroups,"f")[t];const o={};return __classPrivateFieldGet(this,_YargsInstance_groups,"f")[t]=(n||[]).concat(e).filter(a=>o[a]?!1:o[a]=!0),this}hide(e){return argsert("<string>",[e],arguments.length),__classPrivateFieldGet(this,_YargsInstance_options,"f").hiddenOptions.push(e),this}implies(e,t){return argsert("<string|object> [number|string|array]",[e,t],arguments.length),__classPrivateFieldGet(this,_YargsInstance_validation,"f").implies(e,t),this}locale(e){return argsert("[string]",[e],arguments.length),e===void 0?(this[kGuessLocale](),__classPrivateFieldGet(this,_YargsInstance_shim,"f").y18n.getLocale()):(__classPrivateFieldSet(this,_YargsInstance_detectLocale,!1,"f"),__classPrivateFieldGet(this,_YargsInstance_shim,"f").y18n.setLocale(e),this)}middleware(e,t,n){return __classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").addMiddleware(e,!!t,n)}nargs(e,t){return argsert("<string|object|array> [number]",[e,t],arguments.length),this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this),"narg",e,t),this}normalize(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("normalize",e),this}number(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("number",e),this[kTrackManuallySetKeys](e),this}option(e,t){if(argsert("<string|object> [object]",[e,t],arguments.length),typeof e=="object")Object.keys(e).forEach(n=>{this.options(n,e[n])});else{typeof t!="object"&&(t={}),this[kTrackManuallySetKeys](e),__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f")&&(e==="version"||t?.alias==="version")&&this[kEmitWarning](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
63
|
+
`),void 0,"versionWarning"),__classPrivateFieldGet(this,_YargsInstance_options,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);const n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);const o=t.demand||t.required||t.require;o&&this.demand(e,o),t.demandOption&&this.demandOption(e,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(e),typeof t.global=="boolean"&&this.global(e,t.global),t.defaultDescription&&(__classPrivateFieldGet(this,_YargsInstance_options,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);const a=t.describe||t.description||t.desc,l=__classPrivateFieldGet(this,_YargsInstance_usage,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(l,e)||typeof a=="string")&&this.describe(e,a),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){argsert("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[kFreeze](),typeof e>"u"&&(e=__classPrivateFieldGet(this,_YargsInstance_processArgs,"f")),typeof t=="object"&&(__classPrivateFieldSet(this,_YargsInstance_parseContext,t,"f"),t=n),typeof t=="function"&&(__classPrivateFieldSet(this,_YargsInstance_parseFn,t,"f"),t=!1),t||__classPrivateFieldSet(this,_YargsInstance_processArgs,e,"f"),__classPrivateFieldGet(this,_YargsInstance_parseFn,"f")&&__classPrivateFieldSet(this,_YargsInstance_exitProcess,!1,"f");const o=this[kRunYargsParserAndExecuteCommands](e,!!t),a=this.parsed;return __classPrivateFieldGet(this,_YargsInstance_completion,"f").setParsed(this.parsed),isPromise(o)?o.then(l=>(__classPrivateFieldGet(this,_YargsInstance_parseFn,"f")&&__classPrivateFieldGet(this,_YargsInstance_parseFn,"f").call(this,__classPrivateFieldGet(this,_YargsInstance_exitError,"f"),l,__classPrivateFieldGet(this,_YargsInstance_output,"f")),l)).catch(l=>{throw __classPrivateFieldGet(this,_YargsInstance_parseFn,"f")&&__classPrivateFieldGet(this,_YargsInstance_parseFn,"f")(l,this.parsed.argv,__classPrivateFieldGet(this,_YargsInstance_output,"f")),l}).finally(()=>{this[kUnfreeze](),this.parsed=a}):(__classPrivateFieldGet(this,_YargsInstance_parseFn,"f")&&__classPrivateFieldGet(this,_YargsInstance_parseFn,"f").call(this,__classPrivateFieldGet(this,_YargsInstance_exitError,"f"),o,__classPrivateFieldGet(this,_YargsInstance_output,"f")),this[kUnfreeze](),this.parsed=a,o)}parseAsync(e,t,n){const o=this.parse(e,t,n);return isPromise(o)?o:Promise.resolve(o)}parseSync(e,t,n){const o=this.parse(e,t,n);if(isPromise(o))throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return o}parserConfiguration(e){return argsert("<object>",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_parserConfig,e,"f"),this}pkgConf(e,t){argsert("<string> [string]",[e,t],arguments.length);let n=null;const o=this[kPkgUp](t||__classPrivateFieldGet(this,_YargsInstance_cwd,"f"));return o[e]&&typeof o[e]=="object"&&(n=applyExtends(o[e],t||__classPrivateFieldGet(this,_YargsInstance_cwd,"f"),this[kGetParserConfiguration]()["deep-merge-config"]||!1,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects=(__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects||[]).concat(n)),this}positional(e,t){argsert("<string> <object>",[e,t],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=objFilter(t,(l,d)=>l==="type"&&!["string","number","boolean"].includes(d)?!1:n.includes(l));const o=__classPrivateFieldGet(this,_YargsInstance_context,"f").fullCommands[__classPrivateFieldGet(this,_YargsInstance_context,"f").fullCommands.length-1],a=o?__classPrivateFieldGet(this,_YargsInstance_command,"f").cmdToParseOptions(o):{array:[],alias:{},default:{},demand:{}};return objectKeys(a).forEach(l=>{const d=a[l];Array.isArray(d)?d.indexOf(e)!==-1&&(t[l]=!0):d[e]&&!(l in t)&&(t[l]=d[e])}),this.group(e,__classPrivateFieldGet(this,_YargsInstance_usage,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return argsert("[boolean]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_recommendCommands,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return argsert("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&__classPrivateFieldGet(this,_YargsInstance_options,"f").narg[e]?this:(this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,t){return argsert("[string] [string]",[e,t],arguments.length),e=e||this.$0,__classPrivateFieldGet(this,_YargsInstance_logger,"f").log(__classPrivateFieldGet(this,_YargsInstance_completion,"f").generateCompletionScript(e,t||__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f")||"completion")),this}showHelp(e){if(argsert("[string|function]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f"),!__classPrivateFieldGet(this,_YargsInstance_usage,"f").hasCachedHelpMessage()){if(!this.parsed){const n=this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this,_YargsInstance_processArgs,"f"),void 0,void 0,0,!0);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,_YargsInstance_usage,"f").showHelp(e)}),this}const t=__classPrivateFieldGet(this,_YargsInstance_command,"f").runDefaultBuilderOn(this);if(isPromise(t))return t.then(()=>{__classPrivateFieldGet(this,_YargsInstance_usage,"f").showHelp(e)}),this}return __classPrivateFieldGet(this,_YargsInstance_usage,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return argsert("[boolean|string] [string]",[e,t],arguments.length),__classPrivateFieldGet(this,_YargsInstance_usage,"f").showHelpOnFail(e,t),this}showVersion(e){return argsert("[string|function]",[e],arguments.length),__classPrivateFieldGet(this,_YargsInstance_usage,"f").showVersion(e),this}skipValidation(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("skipValidation",e),this}strict(e){return argsert("[boolean]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_strict,e!==!1,"f"),this}strictCommands(e){return argsert("[boolean]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_strictCommands,e!==!1,"f"),this}strictOptions(e){return argsert("[boolean]",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_strictOptions,e!==!1,"f"),this}string(e){return argsert("<array|string>",[e],arguments.length),this[kPopulateParserHintArray]("string",e),this[kTrackManuallySetKeys](e),this}terminalWidth(){return argsert([],0),__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return argsert("<object>",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_detectLocale,!1,"f"),__classPrivateFieldGet(this,_YargsInstance_shim,"f").y18n.updateLocale(e),this}usage(e,t,n,o){if(argsert("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,o],arguments.length),t!==void 0){if(assertNotStrictEqual(e,null,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,o);throw new YError(".usage() description must start with $0 if being used as alias for .command()")}else return __classPrivateFieldGet(this,_YargsInstance_usage,"f").usage(e),this}usageConfiguration(e){return argsert("<object>",[e],arguments.length),__classPrivateFieldSet(this,_YargsInstance_usageConfig,e,"f"),this}version(e,t,n){const o="version";if(argsert("[boolean|string] [string] [string]",[e,t,n],arguments.length),__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f")&&(this[kDeleteFromParserHintObject](__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f")),__classPrivateFieldGet(this,_YargsInstance_usage,"f").version(void 0),__classPrivateFieldSet(this,_YargsInstance_versionOpt,null,"f")),arguments.length===0)n=this[kGuessVersion](),e=o;else if(arguments.length===1){if(e===!1)return this;n=e,e=o}else arguments.length===2&&(n=t,t=void 0);return __classPrivateFieldSet(this,_YargsInstance_versionOpt,typeof e=="string"?e:o,"f"),t=t||__classPrivateFieldGet(this,_YargsInstance_usage,"f").deferY18nLookup("Show version number"),__classPrivateFieldGet(this,_YargsInstance_usage,"f").version(n||void 0),this.boolean(__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f")),this.describe(__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f"),t),this}wrap(e){return argsert("<number|null|undefined>",[e],arguments.length),__classPrivateFieldGet(this,_YargsInstance_usage,"f").wrap(e),this}[(_YargsInstance_command=new WeakMap,_YargsInstance_cwd=new WeakMap,_YargsInstance_context=new WeakMap,_YargsInstance_completion=new WeakMap,_YargsInstance_completionCommand=new WeakMap,_YargsInstance_defaultShowHiddenOpt=new WeakMap,_YargsInstance_exitError=new WeakMap,_YargsInstance_detectLocale=new WeakMap,_YargsInstance_emittedWarnings=new WeakMap,_YargsInstance_exitProcess=new WeakMap,_YargsInstance_frozens=new WeakMap,_YargsInstance_globalMiddleware=new WeakMap,_YargsInstance_groups=new WeakMap,_YargsInstance_hasOutput=new WeakMap,_YargsInstance_helpOpt=new WeakMap,_YargsInstance_isGlobalContext=new WeakMap,_YargsInstance_logger=new WeakMap,_YargsInstance_output=new WeakMap,_YargsInstance_options=new WeakMap,_YargsInstance_parentRequire=new WeakMap,_YargsInstance_parserConfig=new WeakMap,_YargsInstance_parseFn=new WeakMap,_YargsInstance_parseContext=new WeakMap,_YargsInstance_pkgs=new WeakMap,_YargsInstance_preservedGroups=new WeakMap,_YargsInstance_processArgs=new WeakMap,_YargsInstance_recommendCommands=new WeakMap,_YargsInstance_shim=new WeakMap,_YargsInstance_strict=new WeakMap,_YargsInstance_strictCommands=new WeakMap,_YargsInstance_strictOptions=new WeakMap,_YargsInstance_usage=new WeakMap,_YargsInstance_usageConfig=new WeakMap,_YargsInstance_versionOpt=new WeakMap,_YargsInstance_validation=new WeakMap,kCopyDoubleDash)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[kCreateLogger](){return{log:(...e)=>{this[kHasParseCallback]()||console.log(...e),__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f"),__classPrivateFieldGet(this,_YargsInstance_output,"f").length&&__classPrivateFieldSet(this,_YargsInstance_output,__classPrivateFieldGet(this,_YargsInstance_output,"f")+`
|
|
64
|
+
`,"f"),__classPrivateFieldSet(this,_YargsInstance_output,__classPrivateFieldGet(this,_YargsInstance_output,"f")+e.join(" "),"f")},error:(...e)=>{this[kHasParseCallback]()||console.error(...e),__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f"),__classPrivateFieldGet(this,_YargsInstance_output,"f").length&&__classPrivateFieldSet(this,_YargsInstance_output,__classPrivateFieldGet(this,_YargsInstance_output,"f")+`
|
|
65
|
+
`,"f"),__classPrivateFieldSet(this,_YargsInstance_output,__classPrivateFieldGet(this,_YargsInstance_output,"f")+e.join(" "),"f")}}}[kDeleteFromParserHintObject](e){objectKeys(__classPrivateFieldGet(this,_YargsInstance_options,"f")).forEach(t=>{if((o=>o==="configObjects")(t))return;const n=__classPrivateFieldGet(this,_YargsInstance_options,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n=="object"&&delete n[e]}),delete __classPrivateFieldGet(this,_YargsInstance_usage,"f").getDescriptions()[e]}[kEmitWarning](e,t,n){__classPrivateFieldGet(this,_YargsInstance_emittedWarnings,"f")[n]||(__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.emitWarning(e,t),__classPrivateFieldGet(this,_YargsInstance_emittedWarnings,"f")[n]=!0)}[kFreeze](){__classPrivateFieldGet(this,_YargsInstance_frozens,"f").push({options:__classPrivateFieldGet(this,_YargsInstance_options,"f"),configObjects:__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f"),groups:__classPrivateFieldGet(this,_YargsInstance_groups,"f"),strict:__classPrivateFieldGet(this,_YargsInstance_strict,"f"),strictCommands:__classPrivateFieldGet(this,_YargsInstance_strictCommands,"f"),strictOptions:__classPrivateFieldGet(this,_YargsInstance_strictOptions,"f"),completionCommand:__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f"),output:__classPrivateFieldGet(this,_YargsInstance_output,"f"),exitError:__classPrivateFieldGet(this,_YargsInstance_exitError,"f"),hasOutput:__classPrivateFieldGet(this,_YargsInstance_hasOutput,"f"),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,_YargsInstance_parseFn,"f"),parseContext:__classPrivateFieldGet(this,_YargsInstance_parseContext,"f")}),__classPrivateFieldGet(this,_YargsInstance_usage,"f").freeze(),__classPrivateFieldGet(this,_YargsInstance_validation,"f").freeze(),__classPrivateFieldGet(this,_YargsInstance_command,"f").freeze(),__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").freeze()}[kGetDollarZero](){let e="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.argv()[0])?t=__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.argv().slice(1,2):t=__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.argv().slice(0,1),e=t.map(n=>{const o=this[kRebase](__classPrivateFieldGet(this,_YargsInstance_cwd,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&o.length<n.length?o:n}).join(" ").trim(),__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("_")&&__classPrivateFieldGet(this,_YargsInstance_shim,"f").getProcessArgvBin()===__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("_")&&(e=__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("_").replace(`${__classPrivateFieldGet(this,_YargsInstance_shim,"f").path.dirname(__classPrivateFieldGet(this,_YargsInstance_shim,"f").process.execPath())}/`,"")),e}[kGetParserConfiguration](){return __classPrivateFieldGet(this,_YargsInstance_parserConfig,"f")}[kGetUsageConfiguration](){return __classPrivateFieldGet(this,_YargsInstance_usageConfig,"f")}[kGuessLocale](){if(!__classPrivateFieldGet(this,_YargsInstance_detectLocale,"f"))return;const e=__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("LC_ALL")||__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("LC_MESSAGES")||__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("LANG")||__classPrivateFieldGet(this,_YargsInstance_shim,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[kGuessVersion](){return this[kPkgUp]().version||"unknown"}[kParsePositionalNumbers](e){const t=e["--"]?e["--"]:e._;for(let n=0,o;(o=t[n])!==void 0;n++)__classPrivateFieldGet(this,_YargsInstance_shim,"f").Parser.looksLikeNumber(o)&&Number.isSafeInteger(Math.floor(parseFloat(`${o}`)))&&(t[n]=Number(o));return e}[kPkgUp](e){const t=e||"*";if(__classPrivateFieldGet(this,_YargsInstance_pkgs,"f")[t])return __classPrivateFieldGet(this,_YargsInstance_pkgs,"f")[t];let n={};try{let o=e||__classPrivateFieldGet(this,_YargsInstance_shim,"f").mainFilename;!e&&__classPrivateFieldGet(this,_YargsInstance_shim,"f").path.extname(o)&&(o=__classPrivateFieldGet(this,_YargsInstance_shim,"f").path.dirname(o));const a=__classPrivateFieldGet(this,_YargsInstance_shim,"f").findUp(o,(l,d)=>{if(d.includes("package.json"))return"package.json"});assertNotStrictEqual(a,void 0,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),n=JSON.parse(__classPrivateFieldGet(this,_YargsInstance_shim,"f").readFileSync(a,"utf8"))}catch{}return __classPrivateFieldGet(this,_YargsInstance_pkgs,"f")[t]=n||{},__classPrivateFieldGet(this,_YargsInstance_pkgs,"f")[t]}[kPopulateParserHintArray](e,t){t=[].concat(t),t.forEach(n=>{n=this[kSanitizeKey](n),__classPrivateFieldGet(this,_YargsInstance_options,"f")[e].push(n)})}[kPopulateParserHintSingleValueDictionary](e,t,n,o){this[kPopulateParserHintDictionary](e,t,n,o,(a,l,d)=>{__classPrivateFieldGet(this,_YargsInstance_options,"f")[a][l]=d})}[kPopulateParserHintArrayDictionary](e,t,n,o){this[kPopulateParserHintDictionary](e,t,n,o,(a,l,d)=>{__classPrivateFieldGet(this,_YargsInstance_options,"f")[a][l]=(__classPrivateFieldGet(this,_YargsInstance_options,"f")[a][l]||[]).concat(d)})}[kPopulateParserHintDictionary](e,t,n,o,a){if(Array.isArray(n))n.forEach(l=>{e(l,o)});else if((l=>typeof l=="object")(n))for(const l of objectKeys(n))e(l,n[l]);else a(t,this[kSanitizeKey](n),o)}[kSanitizeKey](e){return e==="__proto__"?"___proto___":e}[kSetKey](e,t){return this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this),"key",e,t),this}[kUnfreeze](){var e,t,n,o,a,l,d,w,L,y,B,N;const z=__classPrivateFieldGet(this,_YargsInstance_frozens,"f").pop();assertNotStrictEqual(z,void 0,__classPrivateFieldGet(this,_YargsInstance_shim,"f"));let Q;e=this,t=this,n=this,o=this,a=this,l=this,d=this,w=this,L=this,y=this,B=this,N=this,{options:{set value(H){__classPrivateFieldSet(e,_YargsInstance_options,H,"f")}}.value,configObjects:Q,exitProcess:{set value(H){__classPrivateFieldSet(t,_YargsInstance_exitProcess,H,"f")}}.value,groups:{set value(H){__classPrivateFieldSet(n,_YargsInstance_groups,H,"f")}}.value,output:{set value(H){__classPrivateFieldSet(o,_YargsInstance_output,H,"f")}}.value,exitError:{set value(H){__classPrivateFieldSet(a,_YargsInstance_exitError,H,"f")}}.value,hasOutput:{set value(H){__classPrivateFieldSet(l,_YargsInstance_hasOutput,H,"f")}}.value,parsed:this.parsed,strict:{set value(H){__classPrivateFieldSet(d,_YargsInstance_strict,H,"f")}}.value,strictCommands:{set value(H){__classPrivateFieldSet(w,_YargsInstance_strictCommands,H,"f")}}.value,strictOptions:{set value(H){__classPrivateFieldSet(L,_YargsInstance_strictOptions,H,"f")}}.value,completionCommand:{set value(H){__classPrivateFieldSet(y,_YargsInstance_completionCommand,H,"f")}}.value,parseFn:{set value(H){__classPrivateFieldSet(B,_YargsInstance_parseFn,H,"f")}}.value,parseContext:{set value(H){__classPrivateFieldSet(N,_YargsInstance_parseContext,H,"f")}}.value}=z,__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects=Q,__classPrivateFieldGet(this,_YargsInstance_usage,"f").unfreeze(),__classPrivateFieldGet(this,_YargsInstance_validation,"f").unfreeze(),__classPrivateFieldGet(this,_YargsInstance_command,"f").unfreeze(),__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").unfreeze()}[kValidateAsync](e,t){return maybeAsyncResult(t,n=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[kGetCommandInstance].bind(this),getContext:this[kGetContext].bind(this),getHasOutput:this[kGetHasOutput].bind(this),getLoggerInstance:this[kGetLoggerInstance].bind(this),getParseContext:this[kGetParseContext].bind(this),getParserConfiguration:this[kGetParserConfiguration].bind(this),getUsageConfiguration:this[kGetUsageConfiguration].bind(this),getUsageInstance:this[kGetUsageInstance].bind(this),getValidationInstance:this[kGetValidationInstance].bind(this),hasParseCallback:this[kHasParseCallback].bind(this),isGlobalContext:this[kIsGlobalContext].bind(this),postProcess:this[kPostProcess].bind(this),reset:this[kReset].bind(this),runValidation:this[kRunValidation].bind(this),runYargsParserAndExecuteCommands:this[kRunYargsParserAndExecuteCommands].bind(this),setHasOutput:this[kSetHasOutput].bind(this)}}[kGetCommandInstance](){return __classPrivateFieldGet(this,_YargsInstance_command,"f")}[kGetContext](){return __classPrivateFieldGet(this,_YargsInstance_context,"f")}[kGetHasOutput](){return __classPrivateFieldGet(this,_YargsInstance_hasOutput,"f")}[kGetLoggerInstance](){return __classPrivateFieldGet(this,_YargsInstance_logger,"f")}[kGetParseContext](){return __classPrivateFieldGet(this,_YargsInstance_parseContext,"f")||{}}[kGetUsageInstance](){return __classPrivateFieldGet(this,_YargsInstance_usage,"f")}[kGetValidationInstance](){return __classPrivateFieldGet(this,_YargsInstance_validation,"f")}[kHasParseCallback](){return!!__classPrivateFieldGet(this,_YargsInstance_parseFn,"f")}[kIsGlobalContext](){return __classPrivateFieldGet(this,_YargsInstance_isGlobalContext,"f")}[kPostProcess](e,t,n,o){return n||isPromise(e)||(t||(e=this[kCopyDoubleDash](e)),(this[kGetParserConfiguration]()["parse-positional-numbers"]||this[kGetParserConfiguration]()["parse-positional-numbers"]===void 0)&&(e=this[kParsePositionalNumbers](e)),o&&(e=applyMiddleware(e,this,__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").getMiddleware(),!1))),e}[kReset](e={}){__classPrivateFieldSet(this,_YargsInstance_options,__classPrivateFieldGet(this,_YargsInstance_options,"f")||{},"f");const t={};t.local=__classPrivateFieldGet(this,_YargsInstance_options,"f").local||[],t.configObjects=__classPrivateFieldGet(this,_YargsInstance_options,"f").configObjects||[];const n={};t.local.forEach(l=>{n[l]=!0,(e[l]||[]).forEach(d=>{n[d]=!0})}),Object.assign(__classPrivateFieldGet(this,_YargsInstance_preservedGroups,"f"),Object.keys(__classPrivateFieldGet(this,_YargsInstance_groups,"f")).reduce((l,d)=>{const w=__classPrivateFieldGet(this,_YargsInstance_groups,"f")[d].filter(L=>!(L in n));return w.length>0&&(l[d]=w),l},{})),__classPrivateFieldSet(this,_YargsInstance_groups,{},"f");const o=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],a=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return o.forEach(l=>{t[l]=(__classPrivateFieldGet(this,_YargsInstance_options,"f")[l]||[]).filter(d=>!n[d])}),a.forEach(l=>{t[l]=objFilter(__classPrivateFieldGet(this,_YargsInstance_options,"f")[l],d=>!n[d])}),t.envPrefix=__classPrivateFieldGet(this,_YargsInstance_options,"f").envPrefix,__classPrivateFieldSet(this,_YargsInstance_options,t,"f"),__classPrivateFieldSet(this,_YargsInstance_usage,__classPrivateFieldGet(this,_YargsInstance_usage,"f")?__classPrivateFieldGet(this,_YargsInstance_usage,"f").reset(n):usage(this,__classPrivateFieldGet(this,_YargsInstance_shim,"f")),"f"),__classPrivateFieldSet(this,_YargsInstance_validation,__classPrivateFieldGet(this,_YargsInstance_validation,"f")?__classPrivateFieldGet(this,_YargsInstance_validation,"f").reset(n):validation(this,__classPrivateFieldGet(this,_YargsInstance_usage,"f"),__classPrivateFieldGet(this,_YargsInstance_shim,"f")),"f"),__classPrivateFieldSet(this,_YargsInstance_command,__classPrivateFieldGet(this,_YargsInstance_command,"f")?__classPrivateFieldGet(this,_YargsInstance_command,"f").reset():command(__classPrivateFieldGet(this,_YargsInstance_usage,"f"),__classPrivateFieldGet(this,_YargsInstance_validation,"f"),__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f"),__classPrivateFieldGet(this,_YargsInstance_shim,"f")),"f"),__classPrivateFieldGet(this,_YargsInstance_completion,"f")||__classPrivateFieldSet(this,_YargsInstance_completion,completion(this,__classPrivateFieldGet(this,_YargsInstance_usage,"f"),__classPrivateFieldGet(this,_YargsInstance_command,"f"),__classPrivateFieldGet(this,_YargsInstance_shim,"f")),"f"),__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").reset(),__classPrivateFieldSet(this,_YargsInstance_completionCommand,null,"f"),__classPrivateFieldSet(this,_YargsInstance_output,"","f"),__classPrivateFieldSet(this,_YargsInstance_exitError,null,"f"),__classPrivateFieldSet(this,_YargsInstance_hasOutput,!1,"f"),this.parsed=!1,this}[kRebase](e,t){return __classPrivateFieldGet(this,_YargsInstance_shim,"f").path.relative(e,t)}[kRunYargsParserAndExecuteCommands](e,t,n,o=0,a=!1){let l=!!n||a;e=e||__classPrivateFieldGet(this,_YargsInstance_processArgs,"f"),__classPrivateFieldGet(this,_YargsInstance_options,"f").__=__classPrivateFieldGet(this,_YargsInstance_shim,"f").y18n.__,__classPrivateFieldGet(this,_YargsInstance_options,"f").configuration=this[kGetParserConfiguration]();const d=!!__classPrivateFieldGet(this,_YargsInstance_options,"f").configuration["populate--"],w=Object.assign({},__classPrivateFieldGet(this,_YargsInstance_options,"f").configuration,{"populate--":!0}),L=__classPrivateFieldGet(this,_YargsInstance_shim,"f").Parser.detailed(e,Object.assign({},__classPrivateFieldGet(this,_YargsInstance_options,"f"),{configuration:{"parse-positional-numbers":!1,...w}})),y=Object.assign(L.argv,__classPrivateFieldGet(this,_YargsInstance_parseContext,"f"));let B;const N=L.aliases;let z=!1,Q=!1;Object.keys(y).forEach(H=>{H===__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")&&y[H]?z=!0:H===__classPrivateFieldGet(this,_YargsInstance_versionOpt,"f")&&y[H]&&(Q=!0)}),y.$0=this.$0,this.parsed=L,o===0&&__classPrivateFieldGet(this,_YargsInstance_usage,"f").clearCachedHelpMessage();try{if(this[kGuessLocale](),t)return this[kPostProcess](y,d,!!n,!1);__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")&&[__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")].concat(N[__classPrivateFieldGet(this,_YargsInstance_helpOpt,"f")]||[]).filter(le=>le.length>1).includes(""+y._[y._.length-1])&&(y._.pop(),z=!0),__classPrivateFieldSet(this,_YargsInstance_isGlobalContext,!1,"f");const H=__classPrivateFieldGet(this,_YargsInstance_command,"f").getCommands(),T=__classPrivateFieldGet(this,_YargsInstance_completion,"f").completionKey in y,X=z||T||a;if(y._.length){if(H.length){let ne;for(let le=o||0,oe;y._[le]!==void 0;le++)if(oe=String(y._[le]),H.includes(oe)&&oe!==__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f")){const fe=__classPrivateFieldGet(this,_YargsInstance_command,"f").runCommand(oe,this,L,le+1,a,z||Q||a);return this[kPostProcess](fe,d,!!n,!1)}else if(!ne&&oe!==__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f")){ne=oe;break}!__classPrivateFieldGet(this,_YargsInstance_command,"f").hasDefaultCommand()&&__classPrivateFieldGet(this,_YargsInstance_recommendCommands,"f")&&ne&&!X&&__classPrivateFieldGet(this,_YargsInstance_validation,"f").recommendCommands(ne,H)}__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f")&&y._.includes(__classPrivateFieldGet(this,_YargsInstance_completionCommand,"f"))&&!T&&(__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,_YargsInstance_command,"f").hasDefaultCommand()&&!X){const ne=__classPrivateFieldGet(this,_YargsInstance_command,"f").runCommand(null,this,L,0,a,z||Q||a);return this[kPostProcess](ne,d,!!n,!1)}if(T){__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")&&setBlocking(!0),e=[].concat(e);const ne=e.slice(e.indexOf(`--${__classPrivateFieldGet(this,_YargsInstance_completion,"f").completionKey}`)+1);return __classPrivateFieldGet(this,_YargsInstance_completion,"f").getCompletion(ne,(le,oe)=>{if(le)throw new YError(le.message);(oe||[]).forEach(fe=>{__classPrivateFieldGet(this,_YargsInstance_logger,"f").log(fe)}),this.exit(0)}),this[kPostProcess](y,!d,!!n,!1)}if(__classPrivateFieldGet(this,_YargsInstance_hasOutput,"f")||(z?(__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")&&setBlocking(!0),l=!0,this.showHelp("log"),this.exit(0)):Q&&(__classPrivateFieldGet(this,_YargsInstance_exitProcess,"f")&&setBlocking(!0),l=!0,__classPrivateFieldGet(this,_YargsInstance_usage,"f").showVersion("log"),this.exit(0))),!l&&__classPrivateFieldGet(this,_YargsInstance_options,"f").skipValidation.length>0&&(l=Object.keys(y).some(ne=>__classPrivateFieldGet(this,_YargsInstance_options,"f").skipValidation.indexOf(ne)>=0&&y[ne]===!0)),!l){if(L.error)throw new YError(L.error.message);if(!T){const ne=this[kRunValidation](N,{},L.error);n||(B=applyMiddleware(y,this,__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").getMiddleware(),!0)),B=this[kValidateAsync](ne,B??y),isPromise(B)&&!n&&(B=B.then(()=>applyMiddleware(y,this,__classPrivateFieldGet(this,_YargsInstance_globalMiddleware,"f").getMiddleware(),!1)))}}}catch(H){if(H instanceof YError)__classPrivateFieldGet(this,_YargsInstance_usage,"f").fail(H.message,H);else throw H}return this[kPostProcess](B??y,d,!!n,!0)}[kRunValidation](e,t,n,o){const a={...this.getDemandedOptions()};return l=>{if(n)throw new YError(n.message);__classPrivateFieldGet(this,_YargsInstance_validation,"f").nonOptionCount(l),__classPrivateFieldGet(this,_YargsInstance_validation,"f").requiredArguments(l,a);let d=!1;__classPrivateFieldGet(this,_YargsInstance_strictCommands,"f")&&(d=__classPrivateFieldGet(this,_YargsInstance_validation,"f").unknownCommands(l)),__classPrivateFieldGet(this,_YargsInstance_strict,"f")&&!d?__classPrivateFieldGet(this,_YargsInstance_validation,"f").unknownArguments(l,e,t,!!o):__classPrivateFieldGet(this,_YargsInstance_strictOptions,"f")&&__classPrivateFieldGet(this,_YargsInstance_validation,"f").unknownArguments(l,e,{},!1,!1),__classPrivateFieldGet(this,_YargsInstance_validation,"f").limitedChoices(l),__classPrivateFieldGet(this,_YargsInstance_validation,"f").implications(l),__classPrivateFieldGet(this,_YargsInstance_validation,"f").conflicting(l)}}[kSetHasOutput](){__classPrivateFieldSet(this,_YargsInstance_hasOutput,!0,"f")}[kTrackManuallySetKeys](e){if(typeof e=="string")__classPrivateFieldGet(this,_YargsInstance_options,"f").key[e]=!0;else for(const t of e)__classPrivateFieldGet(this,_YargsInstance_options,"f").key[t]=!0}}function isYargsInstance(s){return!!s&&typeof s.getInternalMethods=="function"}const Yargs=YargsFactory(shim$1),path={type:"string",desc:"<directory> with LikeC4 sources (default is current directory)",normalize:!0,default:".",coerce:path$1.resolve},useDotBin={alias:"use-dot-bin",boolean:!0,type:"boolean",desc:'use graphviz binaries ("dot" should be on PATH)',default:!1},useHashHistory={boolean:!0,type:"boolean",desc:'use hash history for navigation, e.g. "/#/view" instead of "/view"'},outdir={alias:"o",type:"string",desc:"<directory> output directory",normalize:!0,coerce:path$1.resolve},webcomponentPrefix={alias:"w",type:"string",desc:'prefix for Webcomponents, e.g "c4" generates <c4-view ../>',default:"likec4"},base={alias:["base-url"],type:"string",desc:'base url the app is being served from, e.g. "/" or "/pages/"'},useOverview={boolean:!0,type:"boolean",desc:"overview all diagrams as graph [experimental]",default:!1},toPath=s=>s instanceof URL?node_url.fileURLToPath(s):s;function findUpSync(s,{cwd:e=process__default.cwd(),type:t="file",stopAt:n}={}){let o=path__default.resolve(toPath(e)??"");const{root:a}=path__default.parse(o);for(n=path__default.resolve(o,toPath(n)??a);o&&o!==n&&o!==a;){const l=path__default.isAbsolute(s)?s:path__default.join(o,s);try{const d=fs__default.statSync(l,{throwIfNoEntry:!1});if(t==="file"&&d?.isFile()||t==="directory"&&d?.isDirectory())return l}catch{}o=path__default.dirname(o)}}function packageUpSync({cwd:s=process__default.cwd()}={}){return findUpSync("package.json",{cwd:s})}const r=path$1.dirname(node_url.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("cli/index.cjs",document.baseURI).href)),k=`
|
|
66
|
+
/* prettier-ignore-start */
|
|
67
|
+
/* eslint-disable */
|
|
68
|
+
|
|
69
|
+
/******************************************************************************
|
|
70
|
+
* This file was generated
|
|
71
|
+
* DO NOT EDIT MANUALLY!
|
|
72
|
+
******************************************************************************/
|
|
73
|
+
|
|
74
|
+
`.trimStart(),u$1=`
|
|
75
|
+
|
|
76
|
+
/* prettier-ignore-end */
|
|
77
|
+
`,JsBanners={banner:k,footer:u$1};function findPkgRoot(){const s=packageUpSync({cwd:r});if(!s)throw new Error("likec4 package folder not found");return path$1.dirname(s)}function viteAppRoot(){const s=findPkgRoot(),e=[path$1.resolve(s,"__app__"),path$1.resolve(r,"../__app__"),path$1.resolve(r,"../../__app__"),path$1.resolve(r,"../../dist/__app__")],t=LikeC4.f(e,fs.existsSync);if(!t)throw LikeC4.Y.error(`likec4 app root does not exist, tried:
|
|
78
|
+
${e.join(`
|
|
79
|
+
`)}`),new Error("likec4 app root does not exist");return t}async function mkTempPublicDir(){const s=await fsPromises.mkdtemp(path$1.join(os.tmpdir(),".likec4-public-"));return await fsPromises.writeFile(path$1.join(s,"likec4-views.js"),`// generated by likec4
|
|
80
|
+
`),s}const chunkSizeWarningLimit=1e4;function viteAliases(){const s=findPkgRoot();return{"likec4/icons":path$1.resolve(s,"icons"),"likec4/react":path$1.resolve(s,"react"),"likec4/model":path$1.resolve(s,"dist/model")}}function getSourceRegion(s){var e,t;if(s){if("astNode"in s)return getSourceRegionOfAstNode(s);if(Array.isArray(s))return s.reduce(mergeDocumentSegment,void 0);{const n=s,o=isCstNode(n)?getDocumentURIOrUndefined((t=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&t!==void 0?t:n?.astNode):void 0;return copyDocumentSegment(n,o)}}else return}function isCstNode(s){return typeof s<"u"&&"element"in s&&"text"in s}function getDocumentURIOrUndefined(s){try{return LikeC4.g(s).uri.toString()}catch{return}}function getSourceRegionOfAstNode(s){var e,t;const{astNode:n,property:o,index:a}=s??{},l=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||l===void 0)){if(o===void 0)return copyDocumentSegment(l,getDocumentURI(n));{const d=w=>a!==void 0&&a>-1&&Array.isArray(n[o])?a<w.length?w[a]:void 0:w.reduce(mergeDocumentSegment,void 0);if(!((t=l.assignments)===null||t===void 0)&&t[o]){const w=d(l.assignments[o]);return w&©DocumentSegment(w,getDocumentURI(n))}else if(n.$cstNode){const w=d(LikeC4.a(n.$cstNode,o));return w&©DocumentSegment(w,getDocumentURI(n))}else return}}}function getDocumentURI(s){var e,t,n,o;return s.$cstNode?(t=(e=LikeC4.g(s))===null||e===void 0?void 0:e.uri)===null||t===void 0?void 0:t.toString():s.$textRegion?s.$textRegion.documentURI||((o=(n=new LikeC4.T(s,a=>a.$container?[a.$container]:[]).find(a=>{var l;return(l=a.$textRegion)===null||l===void 0?void 0:l.documentURI}))===null||n===void 0?void 0:n.$textRegion)===null||o===void 0?void 0:o.documentURI):void 0}function copyDocumentSegment(s,e){var t,n;const o={offset:s.offset,end:(t=s.end)!==null&&t!==void 0?t:s.offset+s.length,length:(n=s.length)!==null&&n!==void 0?n:s.end-s.offset};return s.range&&(o.range=s.range),e??(e=s.fileURI),e&&(o.fileURI=e),o}function mergeDocumentSegment(s,e){var t,n;if(s){if(!e)return s&©DocumentSegment(s)}else return e&©DocumentSegment(e);const o=(t=s.end)!==null&&t!==void 0?t:s.offset+s.length,a=(n=e.end)!==null&&n!==void 0?n:e.offset+e.length,l=Math.min(s.offset,e.offset),d=Math.max(o,a),w=d-l,L={offset:l,end:d,length:w};if(s.range&&e.range&&(L.range={start:e.range.start.line<s.range.start.line||e.range.start.line===s.range.start.line&&e.range.start.character<s.range.start.character?e.range.start:s.range.start,end:e.range.end.line>s.range.end.line||e.range.end.line===s.range.end.line&&e.range.end.character>s.range.end.character?e.range.end:s.range.end}),s.fileURI||e.fileURI){const y=s.fileURI,B=e.fileURI,N=y&&B&&y!==B?`<unmergable text regions of ${y}, ${B}>`:y??B;L.fileURI=N}return L}class Context{constructor(e){this.defaultIndentation=" ",this.pendingIndent=!0,this.currentIndents=[],this.recentNonImmediateIndents=[],this.traceData=[],this.lines=[[]],this.length=0,typeof e=="string"?this.defaultIndentation=e:typeof e=="number"&&(this.defaultIndentation="".padStart(e))}get content(){return this.lines.map(e=>e.join("")).join("")}get contentLength(){return this.length}get currentLineNumber(){return this.lines.length-1}get currentLineContent(){return this.lines[this.currentLineNumber].join("")}get currentPosition(){return{offset:this.contentLength,line:this.currentLineNumber,character:this.currentLineContent.length}}append(e,t){if(e.length>0){const n=t&&this.currentPosition;this.lines[this.currentLineNumber].push(e),this.length+=e.length,n&&this.indentPendingTraceRegions(n)}}indentPendingTraceRegions(e){for(let t=this.traceData.length-1;t>=0;t--){const n=this.traceData[t];n.targetStart&&n.targetStart.offset===e.offset&&(n.targetStart=this.currentPosition)}}increaseIndent(e){this.currentIndents.push(e),e.indentImmediately||this.recentNonImmediateIndents.push(e)}decreaseIndent(){this.currentIndents.pop()}get relevantIndents(){return this.currentIndents.filter(e=>!this.recentNonImmediateIndents.includes(e))}resetCurrentLine(){this.length-=this.lines[this.currentLineNumber].join("").length,this.lines[this.currentLineNumber]=[],this.pendingIndent=!0}addNewLine(){this.pendingIndent=!0,this.lines.push([]),this.recentNonImmediateIndents.length=0}pushTraceRegion(e){const t=createTraceRegion(e,this.currentPosition,n=>{var o,a;return(a=(o=this.traceData[this.traceData.length-1])===null||o===void 0?void 0:o.children)===null||a===void 0?void 0:a.push(n)});return this.traceData.push(t),t}popTraceRegion(e){const t=this.traceData.pop();return this.assertTrue(t===e,"Trace region mismatch!"),t}getParentTraceSourceFileURI(){var e;for(let t=this.traceData.length-1;t>-1;t--){const n=(e=this.traceData[t].sourceRegion)===null||e===void 0?void 0:e.fileURI;if(n)return n}}assertTrue(e,t){if(!e)throw new Error(t)}}function createTraceRegion(s,e,t){const n={sourceRegion:s,targetRegion:void 0,children:[],targetStart:e,complete:o=>{var a,l;return n.targetRegion={offset:n.targetStart.offset,end:o.offset,length:o.offset-n.targetStart.offset,range:{start:{line:n.targetStart.line,character:n.targetStart.character},end:{line:o.line,character:o.character}}},delete n.targetStart,((a=n.children)===null||a===void 0?void 0:a.length)===0&&delete n.children,!((l=n.targetRegion)===null||l===void 0)&&l.length&&t(n),delete n.complete,n}};return n}function processGeneratorNode(s,e){const t=new Context(e),n=t.pushTraceRegion(void 0);processNodeInternal(s,t),t.popTraceRegion(n),n.complete&&n.complete(t.currentPosition);const o=n.children&&n.children.length===1?n.children[0]:void 0,a=o?.targetRegion,l=n.targetRegion;return a&&o.sourceRegion&&a.offset===l.offset&&a.length===l.length?{text:t.content,trace:o}:{text:t.content,trace:n}}function processNodeInternal(s,e){typeof s=="string"?processStringNode(s,e):s instanceof IndentNode?processIndentNode(s,e):s instanceof CompositeGeneratorNode?processCompositeNode(s,e):s instanceof NewLineNode&&processNewLineNode(s,e)}function hasContent(s,e){return typeof s=="string"?s.length!==0:s instanceof CompositeGeneratorNode?s.contents.some(t=>hasContent(t,e)):s instanceof NewLineNode?!(s.ifNotEmpty&&e.currentLineContent.length===0):!1}function processStringNode(s,e){s&&(e.pendingIndent&&handlePendingIndent(e,!1),e.append(s))}function handlePendingIndent(s,e){var t;let n="";for(const o of s.relevantIndents.filter(a=>a.indentEmptyLines||!e))n+=(t=o.indentation)!==null&&t!==void 0?t:s.defaultIndentation;s.append(n,!0),s.pendingIndent=!1}function processCompositeNode(s,e){let t;const n=getSourceRegion(s.tracedSource);n&&(t=e.pushTraceRegion(n));for(const o of s.contents)processNodeInternal(o,e);if(t){e.popTraceRegion(t);const o=e.getParentTraceSourceFileURI();o&&n?.fileURI===o&&delete n.fileURI,t.complete&&t.complete(e.currentPosition)}}function processIndentNode(s,e){var t;if(hasContent(s,e)){s.indentImmediately&&!e.pendingIndent&&e.append((t=s.indentation)!==null&&t!==void 0?t:e.defaultIndentation,!0);try{e.increaseIndent(s),processCompositeNode(s,e)}finally{e.decreaseIndent()}}}function processNewLineNode(s,e){s.ifNotEmpty&&!hasNonWhitespace(e.currentLineContent)?e.resetCurrentLine():(e.pendingIndent&&handlePendingIndent(e,!0),e.append(s.lineDelimiter),e.addNewLine())}function hasNonWhitespace(s){return s.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const nonWhitespace=/\S|$/;function findIndentation(s){const e=s.filter(n=>n.length>0).map(n=>n.search(nonWhitespace)),t=e.length===0?0:Math.min(...e);return Math.max(0,t)}function expandToNode(s,...e){const t=findIndentationAndTemplateStructure(s),n=splitTemplateLinesAndMergeWithSubstitutions(s,e,t);return composeFinalGeneratorNode(n)}function expandTracedToNode(s,e,t){return(n,...o)=>traceToNode(s,e,t)(expandToNode(n,...o))}function findIndentationAndTemplateStructure(s){const e=s.join("_").split(LikeC4.N),t=e.length>1&&e[0].trim().length===0,n=t&&e.length>1&&e[e.length-1].trim().length===0;if(e.length===1||e.length!==0&&e[0].trim().length!==0||e.length===2&&e[1].trim().length===0)return{indentation:0,omitFirstLine:t,omitLastLine:n,trimLastLine:e.length!==1&&e[e.length-1].trim().length===0};{let o=t?e.slice(1):e;o=n?o.slice(0,o.length-1):o,o=o.filter(l=>l.length!==0);const a=findIndentation(o);return{indentation:a,omitFirstLine:t,omitLastLine:n&&(e[e.length-1].length<a||!e[e.length-1].startsWith(o[0].substring(0,a)))}}}function splitTemplateLinesAndMergeWithSubstitutions(s,e,{indentation:t,omitFirstLine:n,omitLastLine:o,trimLastLine:a}){const l=[];s.forEach((L,y)=>{l.push(...L.split(LikeC4.N).map((B,N)=>N===0||B.length<t?B:B.substring(t)).reduce(y===0?(B,N,z)=>z===0?n?[]:[N]:z===1&&B.length===0?[N]:B.concat(NEWLINE,N):(B,N,z)=>z===0?[N]:B.concat(NEWLINE,N),[]).filter(B=>!(typeof B=="string"&&B.length===0)).concat(isGeneratorNode(e[y])?e[y]:e[y]!==void 0?{content:String(e[y])}:y<e.length?UNDEFINED_SEGMENT:[]))});const d=l.length,w=d!==0?l[d-1]:void 0;return(o||a)&&typeof w=="string"&&w.trim().length===0?n&&d!==1&&l[d-2]===NEWLINE?l.slice(0,d-2):l.slice(0,d-1):l}const NEWLINE={isNewLine:!0},UNDEFINED_SEGMENT={isUndefinedSegment:!0},isNewLineMarker=s=>s===NEWLINE,isUndefinedSegmentMarker=s=>s===UNDEFINED_SEGMENT,isSubstitutionWrapper=s=>s.content!==void 0;function composeFinalGeneratorNode(s){return s.reduce((t,n,o)=>isUndefinedSegmentMarker(n)?t:isNewLineMarker(n)?{node:o!==0&&(isUndefinedSegmentMarker(s[o-1])||isGeneratorNode(s[o-1]))||o>1&&typeof s[o-1]=="string"&&(isUndefinedSegmentMarker(s[o-2])||isGeneratorNode(s[o-2]))?t.node.appendNewLineIfNotEmpty():t.node.appendNewLine()}:(()=>{var a;const l=(o===0||isNewLineMarker(s[o-1]))&&typeof n=="string"&&n.length!==0?"".padStart(n.length-n.trimStart().length):"",d=isSubstitutionWrapper(n)?n.content:n;let w;return{node:t.indented?t.node:l.length!==0?t.node.indent({indentation:l,indentImmediately:!1,indentedChildren:L=>w=L.append(d)}):t.node.append(d),indented:w??((a=t.indented)===null||a===void 0?void 0:a.append(d))}})(),{node:new CompositeGeneratorNode}).node}const EOL=typeof process>"u"?`
|
|
81
|
+
`:process.platform==="win32"?`\r
|
|
82
|
+
`:`
|
|
83
|
+
`;function isGeneratorNode(s){return s instanceof CompositeGeneratorNode||s instanceof IndentNode||s instanceof NewLineNode}function toString(s,e){return isGeneratorNode(s)?processGeneratorNode(s,e).text:String(s)}class CompositeGeneratorNode{constructor(...e){this.contents=[],this.append(...e)}isEmpty(){return this.contents.length===0}trace(e,t,n){if(LikeC4.i(e)){if(this.tracedSource={astNode:e,property:t,index:n},this.tracedSource.property===void 0&&this.tracedSource.index!==void 0&&this.tracedSource.index>-1)throw new Error("Generation support: 'property' argument must not be 'undefined' if a non-negative value is assigned to 'index' in 'CompositeGeneratorNode.trace(...)'.")}else this.tracedSource=e;return this}append(...e){for(const t of e)typeof t=="function"?t(this):t&&this.contents.push(t);return this}appendIf(e,...t){return e?this.append(...t):this}appendNewLine(){return this.append(NL)}appendNewLineIf(e){return e?this.append(NL):this}appendNewLineIfNotEmpty(){return this.append(NLEmpty)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...t){return this.append(expandToNode(e,...t))}appendTemplateIf(e){return e?(t,...n)=>this.appendTemplate(t,...n):()=>this}indent(e){const{indentedChildren:t,indentation:n,indentEmptyLines:o,indentImmediately:a}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},l=new IndentNode(n,a,o);return this.contents.push(l),Array.isArray(t)?l.append(...t):t&&l.append(t),this}appendTraced(e,t,n){return o=>this.append(new CompositeGeneratorNode().trace(e,t,n).append(o))}appendTracedIf(e,t,n,o){return e?this.appendTraced(typeof t=="function"?t():t,n,o):()=>this}appendTracedTemplate(e,t,n){return(o,...a)=>this.append(expandTracedToNode(e,t,n)(o,...a))}appendTracedTemplateIf(e,t,n,o){return e?this.appendTracedTemplate(typeof t=="function"?t():t,n,o):()=>this}}function traceToNode(s,e,t){return n=>n instanceof CompositeGeneratorNode&&n.tracedSource===void 0?n.trace(s,e,t):new CompositeGeneratorNode().trace(s,e,t).append(n)}class IndentNode extends CompositeGeneratorNode{constructor(e,t=!0,n=!1){super(),this.indentImmediately=!0,this.indentEmptyLines=!1,typeof e=="string"?this.indentation=e:typeof e=="number"&&(this.indentation="".padStart(e)),this.indentImmediately=t,this.indentEmptyLines=n}}class NewLineNode{constructor(e,t=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??EOL,this.ifNotEmpty=t}}const NL=new NewLineNode,NLEmpty=new NewLineNode(void 0,!0),defaultToGenerated=s=>s===void 0||typeof s=="string"||isGeneratorNode(s)?s:String(s);function joinToNode(s,e=defaultToGenerated,t={}){const n=typeof e=="function"?e:defaultToGenerated,{filter:o,prefix:a,suffix:l,separator:d,appendNewLineIfNotEmpty:w,skipNewLineAfterLastItem:L}=typeof e=="object"?e:t,y=typeof a=="function"?a:()=>a,B=typeof l=="function"?l:()=>l;return reduceWithIsLast(s,(N,z,Q,H)=>{if(o&&!o(z,Q,H))return N;const T=n(z,Q,H);return T===void 0?N:(N??(N=new CompositeGeneratorNode)).append(y(z,Q,H)).append(T).append(B(z,Q,H)).appendIf(!H,d).appendNewLineIfNotEmptyIf(!N.isEmpty()&&!!w&&(!H||!L))})}function reduceWithIsLast(s,e,t){const n=s[Symbol.iterator]();let o=n.next(),a=0,l=t;for(;!o.done;){const d=n.next();l=e(l,o.value,a,!!d.done),o=d,a++}return l}var Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,unicode={Space_Separator,ID_Start,ID_Continue},util={isSpaceSeparator(s){return typeof s=="string"&&unicode.Space_Separator.test(s)},isIdStartChar(s){return typeof s=="string"&&(s>="a"&&s<="z"||s>="A"&&s<="Z"||s==="$"||s==="_"||unicode.ID_Start.test(s))},isIdContinueChar(s){return typeof s=="string"&&(s>="a"&&s<="z"||s>="A"&&s<="Z"||s>="0"&&s<="9"||s==="$"||s==="_"||s==="\u200C"||s==="\u200D"||unicode.ID_Continue.test(s))},isDigit(s){return typeof s=="string"&&/[0-9]/.test(s)},isHexDigit(s){return typeof s=="string"&&/[0-9A-Fa-f]/.test(s)}};let source,parseState,stack,pos,line,column,token,key,root;var parse=function(e,t){source=String(e),parseState="start",stack=[],pos=0,line=1,column=0,token=void 0,key=void 0,root=void 0;do token=lex(),parseStates[parseState]();while(token.type!=="eof");return typeof t=="function"?internalize({"":root},"",t):root};function internalize(s,e,t){const n=s[e];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let o=0;o<n.length;o++){const a=String(o),l=internalize(n,a,t);l===void 0?delete n[a]:Object.defineProperty(n,a,{value:l,writable:!0,enumerable:!0,configurable:!0})}else for(const o in n){const a=internalize(n,o,t);a===void 0?delete n[o]:Object.defineProperty(n,o,{value:a,writable:!0,enumerable:!0,configurable:!0})}return t.call(s,e,n)}let lexState,buffer,doubleQuote,sign,c;function lex(){for(lexState="default",buffer="",doubleQuote=!1,sign=1;;){c=peek();const s=lexStates[lexState]();if(s)return s}}function peek(){if(source[pos])return String.fromCodePoint(source.codePointAt(pos))}function read(){const s=peek();return s===`
|
|
84
|
+
`?(line++,column=0):s?column+=s.length:column++,s&&(pos+=s.length),s}const lexStates={default(){switch(c){case" ":case"\v":case"\f":case" ":case"\xA0":case"\uFEFF":case`
|
|
85
|
+
`:case"\r":case"\u2028":case"\u2029":read();return;case"/":read(),lexState="comment";return;case void 0:return read(),newToken("eof")}if(util.isSpaceSeparator(c)){read();return}return lexStates[parseState]()},comment(){switch(c){case"*":read(),lexState="multiLineComment";return;case"/":read(),lexState="singleLineComment";return}throw invalidChar(read())},multiLineComment(){switch(c){case"*":read(),lexState="multiLineCommentAsterisk";return;case void 0:throw invalidChar(read())}read()},multiLineCommentAsterisk(){switch(c){case"*":read();return;case"/":read(),lexState="default";return;case void 0:throw invalidChar(read())}read(),lexState="multiLineComment"},singleLineComment(){switch(c){case`
|
|
86
|
+
`:case"\r":case"\u2028":case"\u2029":read(),lexState="default";return;case void 0:return read(),newToken("eof")}read()},value(){switch(c){case"{":case"[":return newToken("punctuator",read());case"n":return read(),literal("ull"),newToken("null",null);case"t":return read(),literal("rue"),newToken("boolean",!0);case"f":return read(),literal("alse"),newToken("boolean",!1);case"-":case"+":read()==="-"&&(sign=-1),lexState="sign";return;case".":buffer=read(),lexState="decimalPointLeading";return;case"0":buffer=read(),lexState="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":buffer=read(),lexState="decimalInteger";return;case"I":return read(),literal("nfinity"),newToken("numeric",1/0);case"N":return read(),literal("aN"),newToken("numeric",NaN);case'"':case"'":doubleQuote=read()==='"',buffer="",lexState="string";return}throw invalidChar(read())},identifierNameStartEscape(){if(c!=="u")throw invalidChar(read());read();const s=unicodeEscape();switch(s){case"$":case"_":break;default:if(!util.isIdStartChar(s))throw invalidIdentifier();break}buffer+=s,lexState="identifierName"},identifierName(){switch(c){case"$":case"_":case"\u200C":case"\u200D":buffer+=read();return;case"\\":read(),lexState="identifierNameEscape";return}if(util.isIdContinueChar(c)){buffer+=read();return}return newToken("identifier",buffer)},identifierNameEscape(){if(c!=="u")throw invalidChar(read());read();const s=unicodeEscape();switch(s){case"$":case"_":case"\u200C":case"\u200D":break;default:if(!util.isIdContinueChar(s))throw invalidIdentifier();break}buffer+=s,lexState="identifierName"},sign(){switch(c){case".":buffer=read(),lexState="decimalPointLeading";return;case"0":buffer=read(),lexState="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":buffer=read(),lexState="decimalInteger";return;case"I":return read(),literal("nfinity"),newToken("numeric",sign*(1/0));case"N":return read(),literal("aN"),newToken("numeric",NaN)}throw invalidChar(read())},zero(){switch(c){case".":buffer+=read(),lexState="decimalPoint";return;case"e":case"E":buffer+=read(),lexState="decimalExponent";return;case"x":case"X":buffer+=read(),lexState="hexadecimal";return}return newToken("numeric",sign*0)},decimalInteger(){switch(c){case".":buffer+=read(),lexState="decimalPoint";return;case"e":case"E":buffer+=read(),lexState="decimalExponent";return}if(util.isDigit(c)){buffer+=read();return}return newToken("numeric",sign*Number(buffer))},decimalPointLeading(){if(util.isDigit(c)){buffer+=read(),lexState="decimalFraction";return}throw invalidChar(read())},decimalPoint(){switch(c){case"e":case"E":buffer+=read(),lexState="decimalExponent";return}if(util.isDigit(c)){buffer+=read(),lexState="decimalFraction";return}return newToken("numeric",sign*Number(buffer))},decimalFraction(){switch(c){case"e":case"E":buffer+=read(),lexState="decimalExponent";return}if(util.isDigit(c)){buffer+=read();return}return newToken("numeric",sign*Number(buffer))},decimalExponent(){switch(c){case"+":case"-":buffer+=read(),lexState="decimalExponentSign";return}if(util.isDigit(c)){buffer+=read(),lexState="decimalExponentInteger";return}throw invalidChar(read())},decimalExponentSign(){if(util.isDigit(c)){buffer+=read(),lexState="decimalExponentInteger";return}throw invalidChar(read())},decimalExponentInteger(){if(util.isDigit(c)){buffer+=read();return}return newToken("numeric",sign*Number(buffer))},hexadecimal(){if(util.isHexDigit(c)){buffer+=read(),lexState="hexadecimalInteger";return}throw invalidChar(read())},hexadecimalInteger(){if(util.isHexDigit(c)){buffer+=read();return}return newToken("numeric",sign*Number(buffer))},string(){switch(c){case"\\":read(),buffer+=escape();return;case'"':if(doubleQuote)return read(),newToken("string",buffer);buffer+=read();return;case"'":if(!doubleQuote)return read(),newToken("string",buffer);buffer+=read();return;case`
|
|
87
|
+
`:case"\r":throw invalidChar(read());case"\u2028":case"\u2029":separatorChar(c);break;case void 0:throw invalidChar(read())}buffer+=read()},start(){switch(c){case"{":case"[":return newToken("punctuator",read())}lexState="value"},beforePropertyName(){switch(c){case"$":case"_":buffer=read(),lexState="identifierName";return;case"\\":read(),lexState="identifierNameStartEscape";return;case"}":return newToken("punctuator",read());case'"':case"'":doubleQuote=read()==='"',lexState="string";return}if(util.isIdStartChar(c)){buffer+=read(),lexState="identifierName";return}throw invalidChar(read())},afterPropertyName(){if(c===":")return newToken("punctuator",read());throw invalidChar(read())},beforePropertyValue(){lexState="value"},afterPropertyValue(){switch(c){case",":case"}":return newToken("punctuator",read())}throw invalidChar(read())},beforeArrayValue(){if(c==="]")return newToken("punctuator",read());lexState="value"},afterArrayValue(){switch(c){case",":case"]":return newToken("punctuator",read())}throw invalidChar(read())},end(){throw invalidChar(read())}};function newToken(s,e){return{type:s,value:e,line,column}}function literal(s){for(const e of s){if(peek()!==e)throw invalidChar(read());read()}}function escape(){switch(peek()){case"b":return read(),"\b";case"f":return read(),"\f";case"n":return read(),`
|
|
88
|
+
`;case"r":return read(),"\r";case"t":return read()," ";case"v":return read(),"\v";case"0":if(read(),util.isDigit(peek()))throw invalidChar(read());return"\0";case"x":return read(),hexEscape();case"u":return read(),unicodeEscape();case`
|
|
89
|
+
`:case"\u2028":case"\u2029":return read(),"";case"\r":return read(),peek()===`
|
|
90
|
+
`&&read(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":throw invalidChar(read());case void 0:throw invalidChar(read())}return read()}function hexEscape(){let s="",e=peek();if(!util.isHexDigit(e)||(s+=read(),e=peek(),!util.isHexDigit(e)))throw invalidChar(read());return s+=read(),String.fromCodePoint(parseInt(s,16))}function unicodeEscape(){let s="",e=4;for(;e-- >0;){const t=peek();if(!util.isHexDigit(t))throw invalidChar(read());s+=read()}return String.fromCodePoint(parseInt(s,16))}const parseStates={start(){if(token.type==="eof")throw invalidEOF();push()},beforePropertyName(){switch(token.type){case"identifier":case"string":key=token.value,parseState="afterPropertyName";return;case"punctuator":pop();return;case"eof":throw invalidEOF()}},afterPropertyName(){if(token.type==="eof")throw invalidEOF();parseState="beforePropertyValue"},beforePropertyValue(){if(token.type==="eof")throw invalidEOF();push()},beforeArrayValue(){if(token.type==="eof")throw invalidEOF();if(token.type==="punctuator"&&token.value==="]"){pop();return}push()},afterPropertyValue(){if(token.type==="eof")throw invalidEOF();switch(token.value){case",":parseState="beforePropertyName";return;case"}":pop()}},afterArrayValue(){if(token.type==="eof")throw invalidEOF();switch(token.value){case",":parseState="beforeArrayValue";return;case"]":pop()}},end(){}};function push(){let s;switch(token.type){case"punctuator":switch(token.value){case"{":s={};break;case"[":s=[];break}break;case"null":case"boolean":case"numeric":case"string":s=token.value;break}if(root===void 0)root=s;else{const e=stack[stack.length-1];Array.isArray(e)?e.push(s):Object.defineProperty(e,key,{value:s,writable:!0,enumerable:!0,configurable:!0})}if(s!==null&&typeof s=="object")stack.push(s),Array.isArray(s)?parseState="beforeArrayValue":parseState="beforePropertyName";else{const e=stack[stack.length-1];e==null?parseState="end":Array.isArray(e)?parseState="afterArrayValue":parseState="afterPropertyValue"}}function pop(){stack.pop();const s=stack[stack.length-1];s==null?parseState="end":Array.isArray(s)?parseState="afterArrayValue":parseState="afterPropertyValue"}function invalidChar(s){return syntaxError(s===void 0?`JSON5: invalid end of input at ${line}:${column}`:`JSON5: invalid character '${formatChar(s)}' at ${line}:${column}`)}function invalidEOF(){return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)}function invalidIdentifier(){return column-=5,syntaxError(`JSON5: invalid identifier character at ${line}:${column}`)}function separatorChar(s){console.warn(`JSON5: '${formatChar(s)}' in strings is not valid ECMAScript; consider escaping`)}function formatChar(s){const e={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(e[s])return e[s];if(s<" "){const t=s.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return s}function syntaxError(s){const e=new SyntaxError(s);return e.lineNumber=line,e.columnNumber=column,e}var stringify=function(e,t,n){const o=[];let a="",l,d,w="",L;if(t!=null&&typeof t=="object"&&!Array.isArray(t)&&(n=t.space,L=t.quote,t=t.replacer),typeof t=="function")d=t;else if(Array.isArray(t)){l=[];for(const H of t){let T;typeof H=="string"?T=H:(typeof H=="number"||H instanceof String||H instanceof Number)&&(T=String(H)),T!==void 0&&l.indexOf(T)<0&&l.push(T)}}return n instanceof Number?n=Number(n):n instanceof String&&(n=String(n)),typeof n=="number"?n>0&&(n=Math.min(10,Math.floor(n)),w=" ".substr(0,n)):typeof n=="string"&&(w=n.substr(0,10)),y("",{"":e});function y(H,T){let X=T[H];switch(X!=null&&(typeof X.toJSON5=="function"?X=X.toJSON5(H):typeof X.toJSON=="function"&&(X=X.toJSON(H))),d&&(X=d.call(T,H,X)),X instanceof Number?X=Number(X):X instanceof String?X=String(X):X instanceof Boolean&&(X=X.valueOf()),X){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof X=="string")return B(X);if(typeof X=="number")return String(X);if(typeof X=="object")return Array.isArray(X)?Q(X):N(X)}function B(H){const T={"'":.1,'"':.2},X={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};let ne="";for(let oe=0;oe<H.length;oe++){const fe=H[oe];switch(fe){case"'":case'"':T[fe]++,ne+=fe;continue;case"\0":if(util.isDigit(H[oe+1])){ne+="\\x00";continue}}if(X[fe]){ne+=X[fe];continue}if(fe<" "){let ve=fe.charCodeAt(0).toString(16);ne+="\\x"+("00"+ve).substring(ve.length);continue}ne+=fe}const le=L||Object.keys(T).reduce((oe,fe)=>T[oe]<T[fe]?oe:fe);return ne=ne.replace(new RegExp(le,"g"),X[le]),le+ne+le}function N(H){if(o.indexOf(H)>=0)throw TypeError("Converting circular structure to JSON5");o.push(H);let T=a;a=a+w;let X=l||Object.keys(H),ne=[];for(const oe of X){const fe=y(oe,H);if(fe!==void 0){let ve=z(oe)+":";w!==""&&(ve+=" "),ve+=fe,ne.push(ve)}}let le;if(ne.length===0)le="{}";else{let oe;if(w==="")oe=ne.join(","),le="{"+oe+"}";else{let fe=`,
|
|
91
|
+
`+a;oe=ne.join(fe),le=`{
|
|
92
|
+
`+a+oe+`,
|
|
93
|
+
`+T+"}"}}return o.pop(),a=T,le}function z(H){if(H.length===0)return B(H);const T=String.fromCodePoint(H.codePointAt(0));if(!util.isIdStartChar(T))return B(H);for(let X=T.length;X<H.length;X++)if(!util.isIdContinueChar(String.fromCodePoint(H.codePointAt(X))))return B(H);return H}function Q(H){if(o.indexOf(H)>=0)throw TypeError("Converting circular structure to JSON5");o.push(H);let T=a;a=a+w;let X=[];for(let le=0;le<H.length;le++){const oe=y(String(le),H);X.push(oe!==void 0?oe:"null")}let ne;if(X.length===0)ne="[]";else if(w==="")ne="["+X.join(",")+"]";else{let le=`,
|
|
94
|
+
`+a,oe=X.join(le);ne=`[
|
|
95
|
+
`+a+oe+`,
|
|
96
|
+
`+T+"]"}return o.pop(),a=T,ne}};const JSON5={parse,stringify};var lib=JSON5;const E=s=>s.charAt(0).toLocaleUpperCase()+s.slice(1),v=s=>s.split(".").map(E).join(""),x=s=>v(s.parent?s.id.slice(s.parent.length+1):s.id),M=({autoLayout:s})=>{switch(s.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},b=({shape:s})=>{switch(s){case"queue":case"cylinder":case"rectangle":case"person":return s;case"storage":return"stored_data";case"mobile":case"browser":return"rectangle"}};function P$1(s){const{nodes:e,edges:t}=s,n=new Map,o=(l,d)=>{const w=x(l),L=(d?d+".":"")+w;n.set(l.id,L);const y=JSON.stringify(l.title),B=b(l);return new CompositeGeneratorNode().append(w,": {",NL).indent({indentedChildren:N=>N.append("label: ",y,NL).appendIf(B!=="rectangle","shape: ",B,NL).appendIf(l.children.length>0,NL,joinToNode(e.filter(z=>z.parent===l.id),z=>o(z,L))),indentation:2}).append("}",NL)},a=l=>new CompositeGeneratorNode().append(n.get(l.source)," -> ",n.get(l.target)).append(d=>l.label&&d.append(": ",JSON.stringify(l.label)));return toString(new CompositeGeneratorNode().append("direction: ",M(s),NL,NL).append(joinToNode(e.filter(l=>LikeC4.n(l.parent)),l=>o(l),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,NL,joinToNode(t,l=>a(l),{appendNewLineIfNotEmpty:!0})))}const A$1=s=>s.charAt(0).toLocaleUpperCase()+s.slice(1),O$1=s=>s.split(".").map(A$1).join(""),$$1=s=>O$1(s.parent?s.id.slice(s.parent.length+1):s.id),R=({shape:s})=>{switch(s){case"queue":case"cylinder":return["[(",")]"];case"person":return["[fa:fa-user ","]"];case"storage":return["([","])"];case"mobile":case"browser":case"rectangle":return["[","]"]}};function S(s){const{nodes:e,edges:t}=s,n=new Map,o=(l,d)=>{const w=$$1(l),L=(d?d+".":"")+w;n.set(l.id,L);const y=l.title.replaceAll(`
|
|
97
|
+
`,"\\n"),B=R(l),N=new CompositeGeneratorNode;return l.children.length>0?N.append("subgraph ",L,"[",JSON.stringify(l.title),"]",NL).indent({indentedChildren:[joinToNode(e.filter(z=>z.parent===l.id),z=>o(z,L),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",NL):N.append(L,B[0],y,B[1]),N},a=l=>new CompositeGeneratorNode().append(n.get(l.source)," -.",l.label?' "'+l.label.replaceAll(`
|
|
98
|
+
`,"\\n")+'" .-':"-","> ",n.get(l.target));return toString(new CompositeGeneratorNode().appendIf(s.title!==null&&s.title.length>0,"---",NL,`title: ${JSON.stringify(s.title)}`,NL,"---",NL).append("graph ",s.autoLayout.direction,NL).indent({indentedChildren:l=>{l.append(joinToNode(e.filter(d=>LikeC4.n(d.parent)),d=>o(d),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,joinToNode(t,d=>a(d),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function q(s){const e=new CompositeGeneratorNode;return e.appendTemplate`
|
|
99
|
+
/* prettier-ignore-start */
|
|
100
|
+
/* eslint-disable */
|
|
101
|
+
|
|
102
|
+
/******************************************************************************
|
|
103
|
+
* This file was generated
|
|
104
|
+
* DO NOT EDIT MANUALLY!
|
|
105
|
+
******************************************************************************/
|
|
106
|
+
|
|
107
|
+
import { LikeC4Model } from 'likec4/model'
|
|
108
|
+
|
|
109
|
+
export const likeC4Model = LikeC4Model.fromDump(${lib.stringify(s.$model,{space:2,quote:"'"})})
|
|
110
|
+
|
|
111
|
+
export type LikeC4ModelTypes = typeof likeC4Model.Aux
|
|
112
|
+
export type LikeC4ElementId = LikeC4ModelTypes['Fqn']
|
|
113
|
+
export type LikeC4DeploymentId = LikeC4ModelTypes['Deployment']
|
|
114
|
+
export type LikeC4ViewId = LikeC4ModelTypes['ViewId']
|
|
115
|
+
|
|
116
|
+
/* prettier-ignore-end */
|
|
117
|
+
`,toString(e)}function h(s){return joinToNode(s,e=>expandToNode`${lib.stringify(e.id)}`,{separator:" | "})}function J(s){const e=Array.from(s),t=new CompositeGeneratorNode;return t.appendTemplate`
|
|
118
|
+
/******************************************************************************
|
|
119
|
+
* This file was generated
|
|
120
|
+
* DO NOT EDIT MANUALLY!
|
|
121
|
+
******************************************************************************/
|
|
122
|
+
/* prettier-ignore-start */
|
|
123
|
+
/* eslint-disable */
|
|
124
|
+
|
|
125
|
+
// @ts-nocheck
|
|
126
|
+
|
|
127
|
+
import type { DiagramView } from 'likec4'
|
|
128
|
+
`.append(NL,NL),e.length===0?(t.append("export {}",NL),toString(t)):(t.appendTemplate`
|
|
129
|
+
export type LikeC4ViewId = ${h(e)};
|
|
130
|
+
export const LikeC4Views = {
|
|
131
|
+
`.indent({indentation:2,indentedChildren(n){n.appendNewLineIf(e.length>1).append(joinToNode(e,o=>expandToNode`${lib.stringify(o.id)}: (${lib.stringify(o)} as unknown) as DiagramView`,{separator:",",appendNewLineIfNotEmpty:!0}))}}).append("} as const satisfies Record<LikeC4ViewId, DiagramView>",NL,NL).appendTemplate`
|
|
132
|
+
export type LikeC4Views = typeof LikeC4Views
|
|
133
|
+
|
|
134
|
+
export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId {
|
|
135
|
+
return (
|
|
136
|
+
value != null &&
|
|
137
|
+
typeof value === 'string' &&
|
|
138
|
+
!!LikeC4Views[value]
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* prettier-ignore-end */
|
|
143
|
+
`.append(NL),toString(t))}function u(s){s instanceof Set&&(s=[...s].sort(index_DafVOuVd.k));const e=s.map(t=>` | ${JSON.stringify(t)}`);return e.length===0&&e.push(" never"),e.join(`
|
|
144
|
+
`)+";"}function Y(s){const{fqns:e,tags:t,kinds:n}=index_DafVOuVd.i([...s.elements()]).reduce((l,d)=>(l.fqns.push(d.id),l.kinds.add(d.kind),l.tags.push(...d.tags),l),{fqns:[],kinds:new Set,tags:[]}),o=index_DafVOuVd.i([...s.deployment.elements()]).map(l=>l.id),{viewIds:a}=[...s.views()].reduce((l,d)=>(l.viewIds.add(d.id),l.tags.push(...d.tags),l.tags.push(...d.includedTags),l),{viewIds:new Set,tags:t});return`
|
|
145
|
+
/* prettier-ignore-start */
|
|
146
|
+
/* eslint-disable */
|
|
147
|
+
|
|
148
|
+
/******************************************************************************
|
|
149
|
+
* This file was generated
|
|
150
|
+
* DO NOT EDIT MANUALLY!
|
|
151
|
+
******************************************************************************/
|
|
152
|
+
|
|
153
|
+
import type { PropsWithChildren } from 'react'
|
|
154
|
+
import type { JSX } from 'react/jsx-runtime'
|
|
155
|
+
import type {
|
|
156
|
+
LikeC4Model as GenericLikeC4Model,
|
|
157
|
+
} from 'likec4/model'
|
|
158
|
+
import type {
|
|
159
|
+
LikeC4ViewProps as GenericLikeC4ViewProps,
|
|
160
|
+
ViewData,
|
|
161
|
+
ReactLikeC4Props as GenericReactLikeC4Props
|
|
162
|
+
} from 'likec4/react'
|
|
163
|
+
|
|
164
|
+
type LikeC4ElementId =
|
|
165
|
+
${u(e)}
|
|
166
|
+
|
|
167
|
+
type LikeC4DeploymentId =
|
|
168
|
+
${u(o)}
|
|
169
|
+
|
|
170
|
+
type LikeC4ViewId =
|
|
171
|
+
${u(a)}
|
|
172
|
+
|
|
173
|
+
type LikeC4ElementKind =
|
|
174
|
+
${u(n)}
|
|
175
|
+
|
|
176
|
+
type LikeC4Tag =
|
|
177
|
+
${u(new Set(t))}
|
|
178
|
+
|
|
179
|
+
type LikeC4ViewData = ViewData<LikeC4ViewId, LikeC4Tag>
|
|
180
|
+
|
|
181
|
+
declare const LikeC4Views: {
|
|
182
|
+
readonly [K in LikeC4ViewId]: LikeC4ViewData
|
|
183
|
+
};
|
|
184
|
+
declare function isLikeC4ViewId(value: unknown): value is LikeC4ViewId;
|
|
185
|
+
|
|
186
|
+
type Aux = GenericLikeC4Model.Typed<LikeC4ElementId, LikeC4DeploymentId, LikeC4ViewId, LikeC4ViewData>;
|
|
187
|
+
type LikeC4Model = GenericLikeC4Model<Aux>;
|
|
188
|
+
type LikeC4ViewModel = GenericLikeC4Model.View<Aux>;
|
|
189
|
+
|
|
190
|
+
declare const likeC4Model: LikeC4Model;
|
|
191
|
+
declare function useLikeC4Model(): LikeC4Model;
|
|
192
|
+
declare function useLikeC4View(viewId: LikeC4ViewId): LikeC4ViewData;
|
|
193
|
+
declare function useLikeC4ViewModel(viewId: LikeC4ViewId): LikeC4ViewModel;
|
|
194
|
+
|
|
195
|
+
declare function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element;
|
|
196
|
+
|
|
197
|
+
type IconRendererProps = {
|
|
198
|
+
node: {
|
|
199
|
+
id: string
|
|
200
|
+
title: string
|
|
201
|
+
icon?: string | undefined
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
declare function RenderIcon(props: IconRendererProps): JSX.Element;
|
|
205
|
+
|
|
206
|
+
type LikeC4ViewProps = GenericLikeC4ViewProps<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>;
|
|
207
|
+
declare function LikeC4View({viewId, ...props}: LikeC4ViewProps): JSX.Element;
|
|
208
|
+
|
|
209
|
+
type ReactLikeC4Props =
|
|
210
|
+
& Omit<GenericReactLikeC4Props<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>, 'view' | 'renderIcon'>
|
|
211
|
+
& {
|
|
212
|
+
viewId: LikeC4ViewId
|
|
213
|
+
};
|
|
214
|
+
declare function ReactLikeC4({viewId, ...props}: ReactLikeC4Props): JSX.Element;
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
type LikeC4ElementId,
|
|
218
|
+
type LikeC4DeploymentId,
|
|
219
|
+
type LikeC4ViewId,
|
|
220
|
+
type LikeC4Tag,
|
|
221
|
+
type LikeC4ElementKind,
|
|
222
|
+
type LikeC4ViewData,
|
|
223
|
+
type LikeC4ViewProps,
|
|
224
|
+
type ReactLikeC4Props,
|
|
225
|
+
type LikeC4Model,
|
|
226
|
+
isLikeC4ViewId,
|
|
227
|
+
useLikeC4Model,
|
|
228
|
+
useLikeC4View,
|
|
229
|
+
useLikeC4ViewModel,
|
|
230
|
+
likeC4Model,
|
|
231
|
+
LikeC4Views,
|
|
232
|
+
LikeC4ModelProvider,
|
|
233
|
+
LikeC4View,
|
|
234
|
+
RenderIcon,
|
|
235
|
+
ReactLikeC4
|
|
236
|
+
}
|
|
237
|
+
/* prettier-ignore-end */
|
|
238
|
+
`.trimStart()}function generateD2Sources(s){const e=new CompositeGeneratorNode;return e.appendTemplate`
|
|
239
|
+
/******************************************************************************
|
|
240
|
+
* This file was generated
|
|
241
|
+
* DO NOT EDIT MANUALLY!
|
|
242
|
+
******************************************************************************/
|
|
243
|
+
/* eslint-disable */
|
|
244
|
+
|
|
245
|
+
export function d2Source(viewId) {
|
|
246
|
+
switch (viewId) {
|
|
247
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(joinToNode(s,n=>expandToNode`
|
|
248
|
+
case ${JSON.stringify(n.id)}: {
|
|
249
|
+
return ${JSON.stringify(P$1(n))}
|
|
250
|
+
}
|
|
251
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
252
|
+
default: {
|
|
253
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
254
|
+
}
|
|
255
|
+
`}}).append(NL," }",NL).appendTemplate`
|
|
256
|
+
}
|
|
257
|
+
`.append(NL,NL),toString(e)}function generateDotSources(s){const e=new CompositeGeneratorNode;return e.appendTemplate`
|
|
258
|
+
/******************************************************************************
|
|
259
|
+
* This file was generated
|
|
260
|
+
* DO NOT EDIT MANUALLY!
|
|
261
|
+
******************************************************************************/
|
|
262
|
+
/* eslint-disable */
|
|
263
|
+
|
|
264
|
+
export function dotSource(viewId) {
|
|
265
|
+
switch (viewId) {
|
|
266
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(joinToNode(Object.keys(s),n=>expandToNode`
|
|
267
|
+
case ${JSON.stringify(n)}: {
|
|
268
|
+
return ${JSON.stringify(s[n].dot)}
|
|
269
|
+
}
|
|
270
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
271
|
+
default: {
|
|
272
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
273
|
+
}
|
|
274
|
+
`}}).append(NL," }",NL).appendTemplate`
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function svgSource(viewId) {
|
|
278
|
+
switch (viewId) {
|
|
279
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(joinToNode(Object.keys(s),n=>expandToNode`
|
|
280
|
+
case ${JSON.stringify(n)}: {
|
|
281
|
+
return ${JSON.stringify(s[n].svg)}
|
|
282
|
+
}
|
|
283
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
284
|
+
default: {
|
|
285
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
286
|
+
}
|
|
287
|
+
`}}).append(NL," }",NL,"}",NL,NL),toString(e)}function generateIconRendererSource(s){const e=LikeC4.x(s.flatMap(o=>o.nodes.map(a=>a.icon)),LikeC4.c(LikeC4.t),LikeC4.c(o=>LikeC4.d(o)&&!o.toLowerCase().startsWith("http")),LikeC4.b()).sort(),{imports:t,cases:n}=e.reduce((o,a,l)=>{const[d,w]=a.split(":"),L="Icon"+l.toString().padStart(2,"0");return o.imports.push(`import ${L} from 'likec4/icons/${d}/${w}'`),o.cases.push(` '${d}:${w}': ${L}`),o},{imports:[],cases:[]});return`
|
|
288
|
+
${t.join(`
|
|
289
|
+
`)}
|
|
290
|
+
|
|
291
|
+
export const Icons = {
|
|
292
|
+
${n.join(`,
|
|
293
|
+
`)}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (import.meta.hot) {
|
|
297
|
+
import.meta.hot.accept(md => {
|
|
298
|
+
const update = md.Icons
|
|
299
|
+
if (update) {
|
|
300
|
+
if (!import.meta.hot.data.icons) {
|
|
301
|
+
import.meta.hot.data.icons = Icons
|
|
302
|
+
}
|
|
303
|
+
Object.assign(import.meta.hot.data.icons, update)
|
|
304
|
+
} else {
|
|
305
|
+
import.meta.hot.invalidate()
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
`}function likec4ModelSources(s){const{views:e,...t}=s.$model;return`
|
|
310
|
+
import { createLikeC4Model } from 'likec4/model'
|
|
311
|
+
import { nano } from 'likec4/react'
|
|
312
|
+
|
|
313
|
+
// This is needed for better tree shaking
|
|
314
|
+
export const LikeC4Views = ${lib.stringify(e)}
|
|
315
|
+
|
|
316
|
+
export const likeC4Model = /* @__PURE__ */ createLikeC4Model(Object.assign(
|
|
317
|
+
${lib.stringify(t)},
|
|
318
|
+
{views: LikeC4Views}
|
|
319
|
+
))
|
|
320
|
+
|
|
321
|
+
export const $likec4model = /* @__PURE__ */ nano.atom(likeC4Model)
|
|
322
|
+
|
|
323
|
+
export function useLikeC4Model() {
|
|
324
|
+
return nano.useStore($likec4model)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (import.meta.hot) {
|
|
328
|
+
import.meta.hot.accept(md => {
|
|
329
|
+
const update = md.$likec4model
|
|
330
|
+
if (update) {
|
|
331
|
+
if (!import.meta.hot.data.$current) {
|
|
332
|
+
import.meta.hot.data.$current = $likec4model
|
|
333
|
+
}
|
|
334
|
+
import.meta.hot.data.$current.set(update.get())
|
|
335
|
+
} else {
|
|
336
|
+
import.meta.hot.invalidate()
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
`}function generateMmdSources(s){const e=new CompositeGeneratorNode;return e.appendTemplate`
|
|
341
|
+
/******************************************************************************
|
|
342
|
+
* This file was generated
|
|
343
|
+
* DO NOT EDIT MANUALLY!
|
|
344
|
+
******************************************************************************/
|
|
345
|
+
/* eslint-disable */
|
|
346
|
+
|
|
347
|
+
export function mmdSource(viewId) {
|
|
348
|
+
switch (viewId) {
|
|
349
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(joinToNode(s,n=>expandToNode`
|
|
350
|
+
case ${JSON.stringify(n.id)}: {
|
|
351
|
+
return ${JSON.stringify(S(n))}
|
|
352
|
+
}
|
|
353
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
354
|
+
default: {
|
|
355
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
356
|
+
}
|
|
357
|
+
`}}).append(NL," }",NL).appendTemplate`
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
`.append(NL,NL),toString(e)}function generateOverviewGraphSource(s){return`
|
|
361
|
+
import { nano } from 'likec4/react'
|
|
362
|
+
|
|
363
|
+
export const $graph = nano.atom(${lib.stringify(s,null,2)})
|
|
364
|
+
|
|
365
|
+
export const useOverviewGraph = () => {
|
|
366
|
+
return nano.useStore($graph)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (import.meta.hot) {
|
|
370
|
+
import.meta.hot.accept(md => {
|
|
371
|
+
const update = md.$graph
|
|
372
|
+
if (update) {
|
|
373
|
+
if (!import.meta.hot.data.graph) {
|
|
374
|
+
import.meta.hot.data.graph = $graph
|
|
375
|
+
}
|
|
376
|
+
import.meta.hot.data.graph.set(update.value)
|
|
377
|
+
} else {
|
|
378
|
+
import.meta.hot.invalidate()
|
|
379
|
+
}
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
`}function diagramPreviewsSources(s,e){const{imports:t,cases:n}=s.reduce((o,{id:a},l)=>{const d=path$1.resolve(e,`${a}.png`);if(!fs.existsSync(d))return o;const w="Png"+l.toString().padStart(2,"0");return o.imports.push(`import ${w} from 'likec4/previews/${a}.png'`),o.cases.push(` ${JSON.stringify(a)}: ${w}`),o},{imports:[],cases:[]});return`
|
|
383
|
+
import { nano } from 'likec4/react'
|
|
384
|
+
// assets dir: ${e}
|
|
385
|
+
|
|
386
|
+
${t.join(`
|
|
387
|
+
`)}
|
|
388
|
+
|
|
389
|
+
const Previews = {
|
|
390
|
+
${n.join(`,
|
|
391
|
+
`)}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export let $previews = nano.map(Previews)
|
|
395
|
+
|
|
396
|
+
export let usePreviewUrl = (id) => {
|
|
397
|
+
const views = nano.useStore($previews, {
|
|
398
|
+
keys: [id]
|
|
399
|
+
})
|
|
400
|
+
return views[id] ?? null
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (import.meta.hot) {
|
|
404
|
+
import.meta.hot.accept(md => {
|
|
405
|
+
const update = md.$previews
|
|
406
|
+
if (update) {
|
|
407
|
+
if (!import.meta.hot.data.$current) {
|
|
408
|
+
import.meta.hot.data.$current = $previews
|
|
409
|
+
}
|
|
410
|
+
const oldKeys = new Set([...Object.keys(import.meta.hot.data.$current.get())])
|
|
411
|
+
for (const [id, view] of Object.entries(update.get())) {
|
|
412
|
+
oldKeys.delete(id)
|
|
413
|
+
import.meta.hot.data.$current.setKey(id, view)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
for (const key of oldKeys.values()) {
|
|
417
|
+
import.meta.hot.data.$current.setKey(key, undefined)
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
import.meta.hot.invalidate()
|
|
421
|
+
}
|
|
422
|
+
})
|
|
423
|
+
}
|
|
424
|
+
`}const P={id:"virtual:likec4/dot-sources",virtualId:"\0likec4-plugin/dot-sources.js",async load({likec4:s,logger:e}){e.info(LikeC4.p.dim("generating virtual:likec4/dot-sources"));const t=await s.viewsService.viewsAsGraphvizOut(),n=LikeC4.h(t,({id:o,svg:a,dot:l})=>[o,{dot:l,svg:a}]);return generateDotSources(n)}},V={id:"virtual:likec4/d2-sources",virtualId:"\0likec4-plugin/d2-sources.js",async load({likec4:s,logger:e}){e.info(LikeC4.p.dim("generating virtual:likec4/d2-sources"));const t=await s.viewsService.computedViews();return generateD2Sources(t)}},j={id:"virtual:likec4/mmd-sources",virtualId:"\0likec4-plugin/mmd-sources.js",async load({likec4:s,logger:e}){e.info(LikeC4.p.dim("generating virtual:likec4/mmd-sources"));const t=await s.viewsService.computedViews();return generateMmdSources(t)}},C={id:"virtual:likec4/icons",virtualId:"\0likec4-plugin/icons.js",async load({likec4:s,logger:e}){e.info(LikeC4.p.dim("generating virtual:likec4/icons"));const t=await s.viewsService.computedViews();return generateIconRendererSource(t)}},O={id:"virtual:likec4/overview-graph",virtualId:"\0likec4-plugin/overview-graph.js",async load({likec4:s,logger:e,useOverviewGraph:t}){if(t===!0)try{e.info(LikeC4.p.dim("generating virtual:likec4/overview-graph"));const n=await s.viewsService.overviewGraph();return generateOverviewGraphSource(n)}catch(n){e.error(n)}return e.info(LikeC4.p.dim("generating empty virtual:likec4/overview-graph")),generateOverviewGraphSource({nodes:[],edges:[],bounds:{x:0,y:0,width:10,height:10}})}},m={id:"virtual:likec4/previews",virtualId:"\0likec4-plugin/previews.js",async load({likec4:s,logger:e,assetsDir:t}){e.info(LikeC4.p.dim("generating virtual:likec4/previews"));const n=await s.viewsService.computedViews();return diagramPreviewsSources(n,t)}},G={id:"virtual:likec4/model",virtualId:"\0likec4-plugin/model.js",async load({likec4:s,logger:e,assetsDir:t}){e.info(LikeC4.p.dim("generating virtual:likec4/model"));const n=await s.layoutedModel();return likec4ModelSources(n)}},modules=[C,P,V,j,O,m,G],$=s=>{const e=s.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")};function likec4Plugin({useOverviewGraph:s=!1,languageServices:e}){let t,n=e.workspace;return{name:"vite-plugin-likec4",configResolved(o){if(t=o.logger,s){const a=o.resolve.alias.find(l=>l.find==="likec4/previews")?.replacement;a?(n=a,t.info(LikeC4.p.dim("likec4/previews alias")+" "+LikeC4.p.dim(n))):t.warn("likec4/previews alias not found")}},resolveId(o){const a=modules.find(l=>l.id===o);return a?a.virtualId:null},async load(o){const a=modules.find(l=>l.virtualId===o);return a?await a.load({logger:t,likec4:e,assetsDir:n,useOverviewGraph:s}):null},configureServer(o){const a=LikeC4.e(1),l=()=>{a.clearQueue(),a(async()=>{const[L]=e.getErrors();if(L){o.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:"Validation error: "+L.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:L.sourceFsPath,line:L.range.start.line+1,column:L.range.start.character+1}}});return}for(const y of modules){const B=o.moduleGraph.getModuleById(y.virtualId);if(B&&B.importers.size>0){t.info(`${LikeC4.p.green("trigger hmr")} ${LikeC4.p.dim(B.url)}`);try{await o.reloadModule(B)}catch(N){t.error(N)}}}})},d=e.workspace;t.info(`${LikeC4.p.dim("watch")} ${d}`);const w=L=>y=>{$(y)&&e.notifyUpdate({[L]:y})};if(o.watcher.add(d).on("add",w("changed")).on("change",w("changed")).on("unlink",w("removed")),s&&!n.startsWith(e.workspace)){t.info(`${LikeC4.p.dim("watch")} ${n}`);const L=()=>{const y=o.moduleGraph.getModuleById(m.virtualId);y&&y.importers.size>0&&o.reloadModule(y)};o.watcher.add(n).on("add",L).on("change",L).on("unlink",L)}e.onModelUpdate(()=>{LikeC4.Y.debug("likec4 model update"),l()})}}}const viteConfig=async({languageServices:s,likec4AssetsDir:e,...t})=>{const n=t.customLogger??LikeC4.j("c4:vite"),o=viteAppRoot(),a=t?.useOverviewGraph===!0;n.info(`${LikeC4.p.cyan("likec4 app root")} ${LikeC4.p.dim(o)}`);const l=t.outputDir??path$1.resolve(s.workspace,"dist");n.info(LikeC4.p.cyan("output")+" "+LikeC4.p.dim(l));let d="/";t.base&&(d=LikeC4.w(t.base),!LikeC4.k(d)&&d!=="./"&&(d=LikeC4.m(d))),d!=="/"&&n.info(`${LikeC4.p.green("app base url")} ${LikeC4.p.dim(d)}`);const w=t.webcomponentPrefix??"likec4";return{isDev:!1,likec4AssetsDir:e,webcomponentPrefix:w,root:o,languageServices:s,clearScreen:!1,base:d,resolve:{alias:{...viteAliases(),"likec4/previews":e}},configFile:!1,mode:"production",optimizeDeps:{include:["likec4/model","likec4/react","react","react-dom","react/jsx-runtime","react/jsx-dev-runtime","react-dom/client"],force:!0},define:{WEBCOMPONENT_PREFIX:JSON.stringify(w),__USE_STYLE_BUNDLE__:"false",__USE_OVERVIEW_GRAPH__:a?"true":"false",__USE_HASH_HISTORY__:t?.useHashHistory===!0?"true":"false","process.env.NODE_ENV":'"production"'},build:{outDir:l,modulePreload:!1,emptyOutDir:!1,cssCodeSplit:!1,sourcemap:!1,cssMinify:!0,minify:!0,copyPublicDir:!0,chunkSizeWarningLimit,commonjsOptions:{defaultIsModuleExports:L=>L.includes("react")?!0:"auto"},rollupOptions:{treeshake:{preset:"recommended"},output:{hoistTransitiveImports:!1,compact:!0}}},customLogger:n,plugins:[c__default(),likec4Plugin({languageServices:s,useOverviewGraph:a})]}};async function viteWebcomponentConfig({languageServices:s,outDir:e,base:t,webcomponentPrefix:n="likec4",filename:o="likec4-views.js"}){const a=LikeC4.j("c4:lib"),l=viteAppRoot();return a.info(LikeC4.p.cyan("outDir")+" "+LikeC4.p.dim(e)),{root:l,clearScreen:!1,base:t,configFile:!1,publicDir:!1,mode:"production",define:{WEBCOMPONENT_PREFIX:JSON.stringify(n),"process.env.NODE_ENV":'"production"'},esbuild:{...JsBanners},build:{outDir:e,emptyOutDir:!1,sourcemap:!1,minify:!0,assetsInlineLimit:100*1024,chunkSizeWarningLimit,lib:{entry:"webcomponent/webcomponent.js",fileName(d,w){return o},formats:["iife"],name:"LikeC4Views"},commonjsOptions:{defaultIsModuleExports:d=>d.includes("react")?!0:"auto",requireReturnsDefault:"auto"},rollupOptions:{treeshake:{preset:"recommended"},output:{format:"iife",hoistTransitiveImports:!1,compact:!0}}},customLogger:a,plugins:[likec4Plugin({languageServices:s,useOverviewGraph:!1})]}}const Assets=["favicon.ico","robots.txt"],viteBuild=async({buildWebcomponent:s=!0,webcomponentPrefix:e="likec4",languageServices:t,likec4AssetsDir:n,...o})=>{n??=await fsPromises.mkdtemp(path$1.join(os.tmpdir(),".likec4-assets-"));const{isDev:a,...l}=await viteConfig({...o,languageServices:t,likec4AssetsDir:n,webcomponentPrefix:e}),d=await mkTempPublicDir();for(const y of Assets){const B=path$1.resolve(l.root,y);fs.existsSync(B)&&fs.copyFileSync(B,path$1.resolve(d,y))}const w=await t.diagrams();if(w.length===0)throw process.exitCode=1,new Error("no views found");if(w.forEach(y=>{y.hasLayoutDrift&&l.customLogger.warn(LikeC4.p.yellow("drift detected, manual layout can not be applied, view:")+" "+LikeC4.p.red(y.id))}),s){const y=await viteWebcomponentConfig({webcomponentPrefix:e,languageServices:t,outDir:d,base:l.base});await vite.build(y)}await vite.build({...l,publicDir:d,mode:"production"});const L=path$1.resolve(l.build.outDir,"index.html");fs.existsSync(L)&&fs.copyFileSync(L,path$1.resolve(l.build.outDir,"404.html"))};function resolveServerUrl(s){if(s.resolvedUrls)return LikeC4.o(s.resolvedUrls.network)??LikeC4.o(s.resolvedUrls.local)}function printServerUrls(s){if(!s.resolvedUrls)throw new Error("Vite server is not ready, no resolvedUrls");LikeC4.Y.box([LikeC4.p.green("LikeC4 served at:"),"",LikeC4.p.dim("Local: ")+s.resolvedUrls.local.join(`
|
|
425
|
+
`+"".padEnd(9," ")),LikeC4.p.dim("Network: ")+s.resolvedUrls.network.join(`
|
|
426
|
+
`+"".padEnd(9," "))].join(`
|
|
427
|
+
`))}class Locked extends Error{constructor(e){super(`${e} is locked`)}}const lockedPorts={old:new Set,young:new Set},releaseOldLockedPortsIntervalMs=1e3*15,minPort=1024,maxPort=65535;let timeout;const getLocalHosts=()=>{const s=os__default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(const t of Object.values(s))for(const n of t)e.add(n.address);return e},checkAvailablePort=s=>new Promise((e,t)=>{const n=net__default.createServer();n.unref(),n.on("error",t),n.listen(s,()=>{const{port:o}=n.address();n.close(()=>{e(o)})})}),getAvailablePort=async(s,e)=>{if(s.host||s.port===0)return checkAvailablePort(s);for(const t of e)try{await checkAvailablePort({port:s.port,host:t})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},portCheckSequence=function*(s){s&&(yield*s),yield 0};async function getPorts(s){let e,t=new Set;if(s&&(s.port&&(e=typeof s.port=="number"?[s.port]:s.port),s.exclude)){const o=s.exclude;if(typeof o[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(const a of o){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}t=new Set(o)}timeout===void 0&&(timeout=setTimeout(()=>{timeout=void 0,lockedPorts.old=lockedPorts.young,lockedPorts.young=new Set},releaseOldLockedPortsIntervalMs),timeout.unref&&timeout.unref());const n=getLocalHosts();for(const o of portCheckSequence(e))try{if(t.has(o))continue;let a=await getAvailablePort({...s,port:o},n);for(;lockedPorts.old.has(a)||lockedPorts.young.has(a);){if(o!==0)throw new Locked(o);a=await getAvailablePort({...s,port:o},n)}return lockedPorts.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof Locked))throw a}throw new Error("No available ports found")}function portNumbers(s,e){if(!Number.isInteger(s)||!Number.isInteger(e))throw new TypeError("`from` and `to` must be integer numbers");if(s<minPort||s>maxPort)throw new RangeError(`'from' must be between ${minPort} and ${maxPort}`);if(e<minPort||e>maxPort)throw new RangeError(`'to' must be between ${minPort} and ${maxPort}`);if(s>e)throw new RangeError("`to` must be greater than or equal to `from`");return function*(n,o){for(let a=n;a<=o;a++)yield a}(s,e)}async function viteDev({buildWebcomponent:s=!0,hmr:e=!0,webcomponentPrefix:t="likec4",languageServices:n,likec4AssetsDir:o,openBrowser:a,...l}){o??=await fsPromises.mkdtemp(path$1.join(os.tmpdir(),".likec4-assets-"));const{isDev:d,...w}=await viteConfig({...l,languageServices:n,likec4AssetsDir:o,webcomponentPrefix:t}),L=await getPorts({port:[5173,...portNumbers(61e3,61010),...portNumbers(62002,62010)]}),y=await getPorts({port:portNumbers(24678,24690)}),B=await mkTempPublicDir();let N;if(s){const Q=await viteWebcomponentConfig({webcomponentPrefix:t,languageServices:n,outDir:B,base:w.base});N=vite.build({...Q,logLevel:"warn"}).catch(H=>(LikeC4.Y.warn("webcomponent build failed",H),LikeC4.Y.warn("Ignoring error and continuing"),Promise.resolve()))}const z=await vite.createServer({...w,define:Object.assign({},w.define,e&&{"process.env.NODE_ENV":'"development"'}),mode:e?"development":w.mode,publicDir:B,server:{host:"0.0.0.0",port:L,hmr:e&&{overlay:!0,port:y},fs:{strict:!1},open:a??!d}});return await z.listen(),N&&await N,z}async function takeScreenshot({browserContext:s,views:e,output:t,logger:n,timeout:o,maxAttempts:a,outputType:l,theme:d}){let w;const L=e.map(N=>({view:N,attempt:1})),y=[];let B;for(;B=L.shift();){const{view:N,attempt:z}=B,Q=`/export/${encodeURIComponent(N.id)}`;try{if(z>1){w&&(w.close({runBeforeUnload:!0}).catch(le=>n.error(`failed to close page: ${le}`)),w=void 0);const ne=LikeC4.u(z*200,{min:200,max:1e3});n.info(LikeC4.p.cyan(Q)+LikeC4.p.dim(` attempt ${z} of ${a} after ${ne}ms`)),await promises.setTimeout(ne)}else N.hasLayoutDrift&&n.warn(LikeC4.p.yellow("Drift detected, manual layout can not be applied, view may be invalid: ")+LikeC4.p.red(N.id)),n.info(LikeC4.p.cyan(Q));w??=await s.newPage(),await w.setViewportSize({width:N.bounds.width+20*2,height:N.bounds.height+20*2}),await w.goto(Q+`?padding=20&theme=${d}`);const H=w.getByRole("presentation");await H.waitFor(),N.nodes.some(ne=>LikeC4.d(ne.icon)&&ne.icon.toLowerCase().startsWith("http"))&&await I(w,o);let T=".";l==="relative"&&(T=N.relativePath??".",T.includes("/")?T=T.slice(0,T.lastIndexOf("/")):T=".");const X=path$1.resolve(t,T,`${N.id}.png`);await H.screenshot({path:X,omitBackground:!0}),y.push({view:N,path:X})}catch(H){w?.close({runBeforeUnload:!0}).catch(T=>n.error(`failed to close page: ${T}`)),n.error(LikeC4.p.red("failed "+Q+`
|
|
428
|
+
`+H)),z<a&&(L.push({view:N,attempt:z+1}),n.info(LikeC4.p.dim(`retry ${Q}`))),w=void 0}}return y}async function I(s,e){let t=await s.locator("//img").all();if(!t.length)return;const n=t.map(o=>o.evaluate(a=>a.complete||new Promise((l,d)=>{a.onload=l,a.onerror=d}),{timeout:Math.max(3e4,e)}));await Promise.allSettled(n)}async function exportViewsToPNG({logger:s,serverUrl:e,theme:t="light",timeoutMs:n=15e3,views:o,output:a,outputType:l="relative",maxAttempts:d=3}){s.info(`${LikeC4.p.cyan("export output")} ${LikeC4.p.dim(a)}`),s.info(`${LikeC4.p.cyan("from server")} ${LikeC4.p.dim(e)}`);const w=playwright.chromium.executablePath();s.info(LikeC4.p.cyan("Start chromium")),s.info(LikeC4.p.dim(w));const L=await playwright.chromium.launch();s.info(LikeC4.p.cyan("Color scheme: ")+t);const y=await L.newContext({deviceScaleFactor:2,colorScheme:t,baseURL:e,ignoreHTTPSErrors:!0,reducedMotion:"reduce",isMobile:!1});y.setDefaultNavigationTimeout(n),y.setDefaultTimeout(n);try{return await takeScreenshot({browserContext:y,views:o,output:a,outputType:l,logger:s,maxAttempts:d,timeout:n,theme:t})}finally{s.info(LikeC4.p.cyan("close chromium")),await y.close(),await L.close()}}async function pngHandler({path:s,useDotBin:e,theme:t="light",output:n,outputType:o,serverUrl:a,ignore:l=!1,timeoutMs:d=1e4,maxAttempts:w=3}){const L=LikeC4.j("c4:export"),y=process$1.hrtime(),B=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"});n??=B.workspace;const N=await B.diagrams();if(!index_DafVOuVd.Q(N,1))throw L.warn("no views found"),new Error("no views found");let z;if(!a&&(L.info(LikeC4.p.cyan("start preview server")),z=await viteDev({languageServices:B,buildWebcomponent:!1,openBrowser:!1,useOverviewGraph:!1,hmr:!1}),a=resolveServerUrl(z),!a))throw L.error("Vite server is not ready, no resolvedUrls"),new Error("Vite server is not ready, no resolvedUrls");try{const Q=await exportViewsToPNG({logger:L,serverUrl:a,theme:t,timeoutMs:d,views:N,output:n,outputType:o,maxAttempts:w}),{pretty:H}=LikeC4.q(y);if(Q.length>0&&L.info(LikeC4.p.green(`exported ${Q.length} views in ${H}`)),Q.length!==N.length&&(l&&Q.length>0?L.info(LikeC4.p.dim("ignore")+" "+LikeC4.p.red(`failed ${N.length-Q.length} out of ${N.length} views`)):L.error(LikeC4.p.red(`failed ${N.length-Q.length} out of ${N.length} views`))),Q.length!==N.length&&(Q.length===0||!l))throw new Error(`Failed ${N.length-Q.length} out of ${N.length} views`)}finally{z&&(L.info(LikeC4.p.cyan("stop server")),await z.close().catch(Q=>{L.error(Q)}))}}const{cyan:p,dim:f}=LikeC4.p;async function buildHandler({path:s,useDotBin:e,useHashHistory:t,webcomponentPrefix:n,useOverview:o=!1,output:a,base:l}){const d=LikeC4.j("c4:build"),w=await LikeC4.L.fromWorkspace(s,{graphviz:e?"binary":"wasm",logger:"vite"}),L=a??path$1.resolve(w.workspace,"dist");let y=path$1.resolve(L,"assets");if(o)try{y=path$1.resolve(L,"assets","previews"),await fsPromises.mkdir(y,{recursive:!0}),d.info(`${p("Generate previews")} ${f(y)}
|
|
429
|
+
`),await pngHandler({path:s,useDotBin:e,output:y,outputType:"flat",ignore:!0})}catch(B){d.error(LikeC4.p.red("Failed to generate previews")),d.error(B),d.warn(LikeC4.p.yellow("Ignore previews and continue build")),fs.rmSync(y,{recursive:!0,force:!0}),o=!1}await viteBuild({base:l,useHashHistory:t,customLogger:d,useOverviewGraph:o,webcomponentPrefix:n,languageServices:w,likec4AssetsDir:y,outputDir:a}),o&&(d.info(`${p("clean previews")} ${f(y)}`),fs.rmSync(y,{recursive:!0,force:!0}))}const buildCmd={command:"build [path]",aliases:["bundle"],describe:"Build a static website",builder:s=>s.positional("path",path).option("output",{alias:"o",type:"string",desc:"output directory for production build",normalize:!0,coerce:path$1.resolve}).option("base",base).option("use-hash-history",useHashHistory).option("use-dot",useDotBin).option("webcomponent-prefix",webcomponentPrefix).option("use-overview",useOverview).example(`${LikeC4.p.green("$0 build -o ./build ./src")}`,LikeC4.p.gray("Search for likec4 files in 'src' and output static site to 'build'")),handler:async s=>{await buildHandler({path:s.path,output:s.output,base:s.base,useHashHistory:s["use-hash-history"],useDotBin:s["use-dot"],useOverview:s["use-overview"]??!1,webcomponentPrefix:s["webcomponent-prefix"]})}};async function A(s,e,t){const n=".ts";e=e??path$1.resolve(s.workspace,"likec4.generated"+n),path$1.extname(e)!==n&&(e=e+n),await fsPromises.mkdir(path$1.dirname(e),{recursive:!0});const o=await s.diagrams(),a=J([...o]);await fsPromises.writeFile(e,a),t.info(`${LikeC4.p.dim("generated")} ${path$1.relative(process.cwd(),e)}`)}async function D(s,e,t){await fsPromises.mkdir(e,{recursive:!0}),t.info(`${LikeC4.p.dim("format")} ${LikeC4.p.green("dot")}`),t.info(`${LikeC4.p.dim("outdir")} ${e}`);const n=new Set,o=await s.viewsService.layoutAllViews();let a=0;for(const{diagram:l,dot:d}of o)try{const w=l.relativePath??"";w!==""&&!n.has(w)&&(await fsPromises.mkdir(path$1.resolve(e,w),{recursive:!0}),n.add(w));const L=path$1.resolve(e,w,l.id+".dot");index_DafVOuVd.u(d,`dot for ${l.id} not found`),await fsPromises.writeFile(L,d),t.info(`${LikeC4.p.dim("generated")} ${path$1.relative(process.cwd(),L)}`),a++}catch(w){t.error(`error while generating ${l.id}`,{error:w})}a>0&&t.info(`${LikeC4.p.dim("total")} ${a} files`)}async function F(s,e,t,n){await fsPromises.mkdir(t,{recursive:!0}),n.info(`${LikeC4.p.dim("format")} ${LikeC4.p.green(e)}`),n.info(`${LikeC4.p.dim("outdir")} ${t}`);let o,a;switch(e){case"d2":o=".d2",a=P$1;break;case"mermaid":o=".mmd",a=S;break;default:index_DafVOuVd.l(e)}const l=new Set,d=await s.diagrams();let w=0;for(const L of d)try{let y=L.relativePath??".";y.includes("/")?y=y.slice(0,y.lastIndexOf("/")):y=".",y!==""&&!l.has(y)&&(await fsPromises.mkdir(path$1.resolve(t,y),{recursive:!0}),l.add(y));const B=path$1.resolve(t,y,L.id+o),N=a(L);await fsPromises.writeFile(B,N),n.info(`${LikeC4.p.dim("generated")} ${path$1.relative(process.cwd(),B)}`),w++}catch(y){n.error(`error while generating ${L.id}`,{error:y})}w>0&&n.info(`${LikeC4.p.dim("total")} ${w} files`)}async function legacyHandler({path:s,useDotBin:e,...t}){const n=LikeC4.j("c4:codegen"),o=LikeC4.s(n),a=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"});if((await a.viewsService.computedViews()).length===0)throw n.warn("no views found"),process.exitCode=1,new Error("no views found");switch(t.format){case"views":{await A(a,t.outfile,n);break}case"dot":{await D(a,t.outdir??s,n);break}case"d2":case"mermaid":{await F(a,t.format,t.outdir??s,n);break}default:index_DafVOuVd.l(t)}o.stopAndLog()}async function modelHandler({path:s,useDotBin:e,outfile:t}){const n=LikeC4.j("c4:codegen"),o=LikeC4.s(n),a=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"});n.info(`${LikeC4.p.dim("format")} ${LikeC4.p.green("model")}`);const l=await a.layoutedModel();for(const B of l.views())B.$view.hasLayoutDrift&&n.warn(LikeC4.p.yellow("drift detected, manual layout can not be applied, view:")+" "+LikeC4.p.red(B.id));let d=path$1.resolve(a.workspace,"likec4-model.ts");if(t&&(d=path$1.isAbsolute(t)?t:path$1.resolve(t),fs.existsSync(t)&&(await fsPromises.stat(t)).isDirectory()))throw new Error(`output file is a directory: ${t}`);const w=path$1.basename(d);n.info(`${LikeC4.p.dim("filename")} ${w}`);const L=path$1.extname(w).toLocaleLowerCase();if(![".ts",".mts",".cts"].includes(L))throw n.error(`output file ${t} has extension "${L}"`),new Error(`output file ${t} must be a .ts, .mts or .cts file`);const y=path$1.dirname(d);n.info(`${LikeC4.p.dim("outdir")} ${y}`),await fsPromises.mkdir(y,{recursive:!0}),await fsPromises.writeFile(d,q(l),{encoding:"utf-8"}),LikeC4.Y.box({message:LikeC4.r(`
|
|
430
|
+
${LikeC4.p.dim("Source with LikeC4Model generated:")}
|
|
431
|
+
${path$1.relative(process$1.cwd(),d)}
|
|
432
|
+
|
|
433
|
+
${LikeC4.p.dim("How to use:")}
|
|
434
|
+
${LikeC4.p.underline("https://likec4.dev/tooling/code-generation/model/")}
|
|
435
|
+
`).trim(),style:{padding:2,borderColor:"green",borderStyle:"rounded"}}),o.stopAndLog()}async function viteReactConfig({languageServices:s,outDir:e,filename:t="likec4-react.mjs"}){const n=LikeC4.j("c4:react"),o=viteAppRoot();return n.info(`${LikeC4.p.cyan("likec4 app root")} ${LikeC4.p.dim(o)}`),n.info(LikeC4.p.cyan("outDir")+" "+LikeC4.p.dim(e)),{customLogger:n,root:o,configFile:!1,clearScreen:!1,publicDir:!1,mode:"production",resolve:{conditions:["production"],alias:viteAliases()},esbuild:{banner:`'use client'
|
|
436
|
+
`+JsBanners.banner,footer:JsBanners.footer,jsx:"transform",jsxDev:!1,jsxSideEffects:!1,minifyIdentifiers:!1,minifySyntax:!1,minifyWhitespace:!1,tsconfigRaw:{compilerOptions:{target:"ES2022",useDefineForClassFields:!0,verbatimModuleSyntax:!0,jsx:"react-jsx"}}},build:{outDir:e,emptyOutDir:!1,sourcemap:!1,minify:!1,target:"es2022",copyPublicDir:!1,chunkSizeWarningLimit,lib:{entry:"react/likec4.tsx",fileName(a,l){return t},formats:["es"]},rollupOptions:{output:{compact:!1,exports:"named"},external:["likec4/react","likec4/model","react","react-dom","react/jsx-runtime","react/jsx-dev-runtime","react-dom/client",/likec4\/icons\/.*/],onwarn(a,l){a.code!=="SOURCEMAP_ERROR"&&l(a)}}},plugins:[c__default({}),likec4Plugin({languageServices:s,useOverviewGraph:!1})]}}async function reactHandler({path:s,useDotBin:e,outfile:t}){const n=LikeC4.j("c4:codegen"),o=LikeC4.s(n),a=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"});n.info(`${LikeC4.p.dim("format")} ${LikeC4.p.green("react")}`);const l=await a.diagrams();if(l.length===0)throw process.exitCode=1,new Error("no views found");l.forEach(z=>{z.hasLayoutDrift&&n.warn(LikeC4.p.yellow("drift detected, manual layout can not be applied, view:")+" "+LikeC4.p.red(z.id))});let d=path$1.resolve(a.workspace,"likec4-views.js");if(t&&(d=path$1.isAbsolute(t)?t:path$1.resolve(t),fs.existsSync(t)&&(await fsPromises.stat(t)).isDirectory()))throw new Error(`output file is a directory: ${t}`);const w=path$1.dirname(d);n.info(`${LikeC4.p.dim("outdir")} ${w}`);const L=path$1.basename(d);n.info(`${LikeC4.p.dim("filename")} ${L}`);const y=path$1.extname(L).toLocaleLowerCase();if(![".js",".mjs",".jsx"].includes(y))throw n.error(`output file ${t} has extension "${y}"`),new Error(`output file ${t} must be a .js, .jsx or .mjs`);const B=await viteReactConfig({languageServices:a,outDir:w,filename:L});await vite.build({...B,logLevel:"warn"});const N=await a.layoutedModel();await fsPromises.writeFile(path$1.resolve(w,path$1.basename(d,y)+(y===".mjs"?".d.mts":".d.ts")),Y(N)),LikeC4.Y.box({message:LikeC4.r(`
|
|
437
|
+
${LikeC4.p.dim("Source generated:")}
|
|
438
|
+
${path$1.relative(process$1.cwd(),d)}
|
|
439
|
+
|
|
440
|
+
${LikeC4.p.dim("How to use:")}
|
|
441
|
+
${LikeC4.p.underline("https://likec4.dev/tooling/code-generation/react/")}
|
|
442
|
+
`).trim(),style:{padding:2,borderColor:"green",borderStyle:"rounded"}}),o.stopAndLog()}async function webcomponentHandler({path:s,useDotBin:e,webcomponentPrefix:t="likec4",outfile:n}){const o=LikeC4.j("c4:codegen"),a=LikeC4.s(o),l=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"});o.info(`${LikeC4.p.dim("format")} ${LikeC4.p.green("webcomponent")}`);const d=await l.diagrams();if(!LikeC4.v(d,1))throw o.warn("no views found"),process.exitCode=1,new Error("no views found");d.forEach(Q=>{Q.hasLayoutDrift&&o.warn(LikeC4.p.yellow("drift detected, manual layout can not be applied, view:")+" "+LikeC4.p.red(Q.id))});let w=path$1.resolve(l.workspace,"likec4-views.js");if(n&&(w=path$1.isAbsolute(n)?n:path$1.resolve(n),fs.existsSync(n)&&(await fsPromises.stat(n)).isDirectory()))throw new Error(`output file is a directory: ${n}`);LikeC4.Y.debug(`${LikeC4.p.dim("outfilepath")} ${w}`);const L=path$1.basename(w);LikeC4.Y.debug(`${LikeC4.p.dim("filename")} ${L}`);const y=path$1.extname(L).toLocaleLowerCase();if(y!==".js"&&y!==".mjs")throw LikeC4.Y.warn(`output file ${n} has extension "${y}"`),new Error(`output file ${n} must be a .js or .mjs`);const B=await mkTempPublicDir();LikeC4.Y.debug(`${LikeC4.p.dim("created temp public")} ${B}`);const N=await viteWebcomponentConfig({languageServices:l,outDir:B,filename:L,webcomponentPrefix:t,base:"/"});LikeC4.Y.debug(`${LikeC4.p.dim("vite build webcomponent")}`),await vite.build({...N,logLevel:"warn"});const z=path$1.resolve(B,L);if(!fs.existsSync(z))throw new Error(`output file not found: ${z}`);await fsPromises.mkdir(path$1.dirname(w),{recursive:!0}),await fsPromises.copyFile(z,w),o.info(`${LikeC4.p.dim("generated")} ${w}`),LikeC4.Y.debug(`${LikeC4.p.dim("remove temp public")}`),await fsPromises.rm(B,{recursive:!0,force:!0}),LikeC4.Y.box(LikeC4.r(`
|
|
443
|
+
${LikeC4.p.dim("Webcomponents generated to:")}
|
|
444
|
+
${path$1.relative(process$1.cwd(),w)}
|
|
445
|
+
|
|
446
|
+
${LikeC4.p.dim("Setup and usage instructions:")}
|
|
447
|
+
${LikeC4.p.blue("https://likec4.dev/tooling/code-generation/webcomponent/")}
|
|
448
|
+
`)),a.stopAndLog()}const codegenCmd={command:"codegen <command> [path]",aliases:["generate","gen"],describe:"Generate various artifacts from LikeC4 sources",builder:s=>s.positional("path",path).command("react [path]","generate react component to render likec4 view",e=>e.option("outfile",{alias:"o",type:"string",desc:"<file> path to output file (.jsx, .mjs or .js)",normalize:!0,coerce:require$$0.resolve}).option("use-dot",useDotBin),async e=>{await reactHandler({useDotBin:e.useDotBin,path:e.path,outfile:e.outfile})}).command({command:"webcomponent [path]",aliases:["wc","webcomp"],describe:"generate js with webcomponents",builder:e=>e.option("outfile",{alias:"o",type:"string",desc:"<file> path to output file (.mjs or .js)",normalize:!0,coerce:require$$0.resolve}).option("webcomponent-prefix",webcomponentPrefix).option("use-dot",useDotBin),handler:async e=>{await webcomponentHandler({useDotBin:e.useDotBin,path:e.path,outfile:e.outfile,webcomponentPrefix:e.webcomponentPrefix})}}).command({command:"model [path]",aliases:["ts"],describe:"generate LikeC4Model (.ts)",builder:e=>e.option("outfile",{alias:"o",type:"string",desc:"<file> path to output file (.ts)",normalize:!0,coerce:require$$0.resolve}).option("use-dot",useDotBin),handler:async e=>{await modelHandler({path:e.path,useDotBin:e.useDotBin,outfile:e.outfile})}}).command({command:"views-data [path]",aliases:["views"],describe:"generate likec4 views data (.ts)",builder:e=>e.option("outfile",{alias:"o",type:"string",desc:"<file> output .ts file",normalize:!0,coerce:require$$0.resolve}).option("use-dot",useDotBin),handler:async e=>{await legacyHandler({format:"views",path:e.path,useDotBin:e.useDotBin,outfile:e.outfile})}}).command({command:"dot [path]",describe:"generate graphviz files (.dot)",builder:e=>e.option("outdir",outdir).option("use-dot",useDotBin),handler:async e=>{await legacyHandler({format:"dot",path:e.path,useDotBin:e.useDotBin,outdir:e.outdir})}}).command({command:"d2 [path]",describe:"generate D2 files (.d2)",builder:e=>e.option("outdir",outdir).option("use-dot",useDotBin),handler:async e=>{await legacyHandler({format:"d2",path:e.path,useDotBin:e.useDotBin,outdir:e.outdir})}}).command({command:"mermaid [path]",aliases:["mmd"],describe:"generate Mermaid files (.mmd)",builder:e=>e.option("outdir",outdir).option("use-dot",useDotBin),handler:async e=>{await legacyHandler({format:"mermaid",useDotBin:e.useDotBin,path:e.path,outdir:e.outdir})}}).epilog(`${LikeC4.p.bold("Examples:")}
|
|
449
|
+
likec4 gen react -o dist/likec4-views.mjs ./src/likec4
|
|
450
|
+
likec4 gen model -o likec4-model.ts
|
|
451
|
+
likec4 gen webcomponent -o likec4.js --webcomponent-prefix c4 --use-dot-bin ./src
|
|
452
|
+
likec4 gen views-data -o ./src/likec4-data.ts
|
|
453
|
+
likec4 gen ts --outfile ../likec4.ts
|
|
454
|
+
likec4 gen mmd --outdir assets/
|
|
455
|
+
likec4 gen dot -o out .
|
|
456
|
+
`),handler:()=>{}};async function handler$2({path:s,useDotBin:e,outfile:t}){const n=LikeC4.j("c4:export"),o=LikeC4.s(n),a=await(await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"})).layoutedModel();path$1.extname(t)!==".json"&&(t=t+".json"),await fsPromises.mkdir(path$1.dirname(t),{recursive:!0});const l=JSON.stringify(a.$model,null,2);await fsPromises.writeFile(t,l),n.info(`${LikeC4.p.dim("generated")} ${path$1.relative(process.cwd(),t)}`),o.stopAndLog("\u2713 export in ")}const exportCmd={command:"export <format> [path]",describe:"Export to images or JSON",builder:s=>s.usage(`${LikeC4.p.bold("Usage:")} $0 export <format> [path]`).positional("path",path).command({command:"png [path]",describe:"export views to PNG",builder:e=>e.option("output",outdir).option("theme",{choices:["light","dark"],desc:"color-scheme to use, default is light"}).option("flat",{boolean:!0,type:"boolean",desc:"ignore sources structure and export all PNGs in output directory"}).option("use-dot",useDotBin).options({ignore:{boolean:!0,alias:"i",desc:"continue if some views failed to export"},timeout:{type:"number",alias:"t",desc:"(sec) timeout for playwright ",default:10},"max-attempts":{type:"number",describe:"",desc:"(number) max attempts to export failing view",default:3},"server-url":{type:"string",desc:"use this url instead of starting new likec4 server"}}).epilog(`${LikeC4.p.bold("Examples:")}
|
|
457
|
+
${LikeC4.p.green("$0 export png")}
|
|
458
|
+
${LikeC4.p.gray("Search for likec4 files in current directory and output PNG next to sources")}
|
|
459
|
+
|
|
460
|
+
${LikeC4.p.green("$0 export png --theme dark -o ./png src/likec4 ")}
|
|
461
|
+
${LikeC4.p.gray("Search for likec4 files in src/likec4 and output PNG with dark theme to png folder")}
|
|
462
|
+
`),handler:async e=>{index_DafVOuVd.u(e.timeout>=1,"timeout must be >= 1"),index_DafVOuVd.u(e["max-attempts"]>=1,"max-attempts must be >= 1"),await pngHandler({path:e.path,useDotBin:e.useDotBin,output:e.output,timeoutMs:e.timeout*1e3,maxAttempts:e.maxAttempts,ignore:e.ignore===!0,outputType:e.flat?"flat":"relative",serverUrl:e.serverUrl,theme:e.theme??"light"})}}).command({command:"json [path]",describe:"export model to JSON",builder:e=>e.option("outfile",{alias:"o",type:"string",desc:"<file> output .json file",default:"likec4.json",normalize:!0,coerce:path$1.resolve}).option("use-dot",useDotBin).epilog(`${LikeC4.p.bold("Examples:")}
|
|
463
|
+
${LikeC4.p.green("$0 export json")}
|
|
464
|
+
${LikeC4.p.gray("Search for likec4 files in current directory and output JSON to likec4.json")}
|
|
465
|
+
|
|
466
|
+
${LikeC4.p.green("$0 export json -o ./generated/likec4.json src/likec4 ")}
|
|
467
|
+
${LikeC4.p.gray("Search for likec4 files in src/likec4 and output JSON to generated/likec4.json")}
|
|
468
|
+
`),handler:async e=>{await handler$2({path:e.path,useDotBin:e.useDotBin,outfile:e.outfile})}}).updateStrings({"Commands:":LikeC4.p.bold("Formats:")}),handler:()=>{}};async function vitePreview(s){const{isDev:e,...t}=await viteConfig({...s,likec4AssetsDir:"",webcomponentPrefix:void 0}),n=await getPorts({port:portNumbers(62001,62010)}),o=s?.open??!1;return await vite.preview({...t,mode:"production",preview:{host:"0.0.0.0",port:n,open:o}})}async function handler$1({path:s,output:e,base:t}){const n=await LikeC4.L.fromWorkspace(s,{logger:"vite"}),o=await vitePreview({base:t,languageServices:n,outputDir:e,open:!0});printServerUrls(o)}const previewCmd={command:"preview [path]",describe:"Start local server to preview production build",builder:s=>s.positional("path",{type:"string",desc:`Directory with LikeC4 source files
|
|
469
|
+
if not specified search in current directory`,normalize:!0}).options({output:{alias:"o",type:"string",desc:"output directory from production build",normalize:!0},base:{type:"string",desc:"base url the app is being served from"}}).coerce(["path","output"],require$$0.resolve).default("path",require$$0.resolve("."),"."),async handler(s){await handler$1(s)}};async function handler({path:s,useDotBin:e,webcomponentPrefix:t,useHashHistory:n,useOverview:o=!1,base:a}){const l=await LikeC4.L.fromWorkspace(s,{logger:"vite",graphviz:e?"binary":"wasm"}),d=await fsPromises.mkdtemp(path$1.join(os.tmpdir(),".likec4-assets-")),w=await viteDev({buildWebcomponent:!i,hmr:!0,base:a,webcomponentPrefix:t,languageServices:l,useHashHistory:n,useOverviewGraph:o,likec4AssetsDir:d});if(w.config.logger.clearScreen("info"),printServerUrls(w),!o)return;const L=await l.diagrams();if(LikeC4.v(L,1)){const y=LikeC4.j("c4:export"),B=resolveServerUrl(w);if(!B){y.error("no preview server url");return}y.info(LikeC4.p.cyan("wait 5sec before generating previews")),await LikeC4.E(5e3);try{await exportViewsToPNG({serverUrl:B,logger:y,views:L,theme:"light",output:d,outputType:"flat"}),await LikeC4.E(1e3),y.info(LikeC4.p.yellow("Note: changes in sources do not trigger preview updates, restart is required"))}catch(N){y.error(LikeC4.p.red("Failed to generate previews")),y.error(N)}}else w.config.logger.warn("no views found, no previews generated")}const serveCmd={command:"start [path]",aliases:["serve","dev"],describe:"Start local dev server to preview LikeC4 views",builder:s=>s.positional("path",path).option("base",base).option("webcomponent-prefix",webcomponentPrefix).option("use-hash-history",useHashHistory).option("use-overview",useOverview).option("use-dot",useDotBin),handler:async s=>{await handler({path:s.path,useDotBin:s["use-dot"],base:s.base,useOverview:s["use-overview"]??!1,webcomponentPrefix:s["webcomponent-prefix"],useHashHistory:s["use-hash-history"]})}};LikeC4.Y.level=LikeC4.y.debug;const g=Yargs(hideBin(process$1.argv)).scriptName("likec4").usage("Usage: $0 <command>").command(serveCmd).command(buildCmd).command(codegenCmd).command(exportCmd).command(previewCmd).help("help").version(LikeC4.z).alias("v","version").alias("h","help").demandCommand(1,"Please run with valid command").strict().recommendCommands().showHelpOnFail(!0,"Something is wrong, run with --help").updateStrings({"Options:":LikeC4.p.bold("Options:"),"Positionals:":LikeC4.p.bold("Arguments:"),"Commands:":LikeC4.p.bold("Commands:"),"Examples:":LikeC4.p.bold("Examples:")}).wrap(LikeC4.u(process$1.stdout.columns-20,{min:80,max:120})).parseAsync();g.catch(()=>process$1.exit(1)),process.on("unhandledRejection",s=>{LikeC4.Y.error(s)});
|