@tailorkit/cli 0.1.0-beta.7 → 0.1.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fileURLToPath as e}from"node:url";import{dirname as t}from"node:path";const n=e(import.meta.url);t(n);import{t as r}from"../index.js";import{z as i}from"zod";import{readFile as a,writeFile as o}from"fs/promises";import s from"path";import{createRequire as c}from"module";import{build as l}from"vite";var u=262144,d=2048,f=e=>{if(e.length<33||![137,80,78,71,13,10,26,10].every((t,n)=>e[n]===t))throw Error(`Logo content is not a valid PNG file.`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=e[12]===73&&e[13]===72&&e[14]===68&&e[15]===82;if(t.getUint32(8)!==13||!n)throw Error(`Logo content is not a valid PNG file.`);return{width:t.getUint32(16),height:t.getUint32(20)}},p=e=>{let t=(t,n)=>new TextDecoder().decode(e.subarray(t,n));if(e.length<30||t(0,4)!==`RIFF`||t(8,12)!==`WEBP`)throw Error(`Logo content is not a valid WebP file.`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t(12,16);if(r===`VP8X`)return{width:1+n.getUint16(24,!0)+(e[26]??0)*65536,height:1+n.getUint16(27,!0)+(e[29]??0)*65536};if(r===`VP8L`&&e[20]===47){let e=n.getUint32(21,!0);return{width:e%16384+1,height:Math.floor(e/16384)%16384+1}}if(r===`VP8 `&&e[23]===157&&e[24]===1&&e[25]===42)return{width:n.getUint16(26,!0)%16384,height:n.getUint16(28,!0)%16384};throw Error(`Logo content is not a supported WebP file.`)},m=e=>{let t=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!1}).decode(e);if(!/<svg(?:\s|>)/iu.test(t))throw Error(`Logo content is not a valid SVG file.`);if(/<(?:script|foreignObject|iframe|object|embed)(?:\s|>)/iu.test(t)||/\son[a-z]+\s*=/iu.test(t)||/(?:href|src)\s*=\s*["'](?!#)/iu.test(t)||/(?:@import|url\(\s*(?!["']?#))/iu.test(t)||/<!DOCTYPE|<!ENTITY|<\?xml-stylesheet/iu.test(t))throw Error(`SVG logos cannot contain scripts or external resources.`)};function h(e,t){if(e.byteLength<1||e.byteLength>262144)throw Error(`Logo must be between 1 and ${u} bytes.`);if(t===`image/svg+xml`)return m(e),{};let n=t===`image/png`?f(e):p(e);if(n.width<1||n.height<1||n.width>2048||n.height>2048)throw Error(`Raster logos cannot exceed ${d} by ${d} pixels.`);return n}var g=10,_=e=>{let t=/^(\d+)\./u.exec(e);if(!t?.[1])throw Error(`Unable to parse Preact version "${e}".`);return{major:Number.parseInt(t[1],10),version:e}},v=e=>{let t=_(e);if(t.major<g)throw Error(`TailorKit requires Preact ${g}.0.0 or newer, but found ${e}.`);return t},y=i.object({assets:i.object({client:i.literal(`client.js`),logos:i.object({dark:i.string().regex(/^logo-dark\.(?:png|svg|webp)$/u).optional(),light:i.string().regex(/^logo-light\.(?:png|svg|webp)$/u).optional()}).optional()}),version:i.literal(1)}),b=e=>y.parse({assets:{client:`client.js`,...e&&Object.keys(e).length>0?{logos:e}:{}},version:1}),x
|
|
2
|
-
`,`utf-8`),d};function
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{dirname as t}from"node:path";const n=e(import.meta.url);t(n);import{t as r}from"../index.js";import{z as i}from"zod";import{readFile as a,writeFile as o}from"fs/promises";import s from"path";import{createRequire as c}from"module";import{build as l}from"vite";var u=262144,d=2048,f=e=>{if(e.length<33||![137,80,78,71,13,10,26,10].every((t,n)=>e[n]===t))throw Error(`Logo content is not a valid PNG file.`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=e[12]===73&&e[13]===72&&e[14]===68&&e[15]===82;if(t.getUint32(8)!==13||!n)throw Error(`Logo content is not a valid PNG file.`);return{width:t.getUint32(16),height:t.getUint32(20)}},p=e=>{let t=(t,n)=>new TextDecoder().decode(e.subarray(t,n));if(e.length<30||t(0,4)!==`RIFF`||t(8,12)!==`WEBP`)throw Error(`Logo content is not a valid WebP file.`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t(12,16);if(r===`VP8X`)return{width:1+n.getUint16(24,!0)+(e[26]??0)*65536,height:1+n.getUint16(27,!0)+(e[29]??0)*65536};if(r===`VP8L`&&e[20]===47){let e=n.getUint32(21,!0);return{width:e%16384+1,height:Math.floor(e/16384)%16384+1}}if(r===`VP8 `&&e[23]===157&&e[24]===1&&e[25]===42)return{width:n.getUint16(26,!0)%16384,height:n.getUint16(28,!0)%16384};throw Error(`Logo content is not a supported WebP file.`)},m=e=>{let t=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!1}).decode(e);if(!/<svg(?:\s|>)/iu.test(t))throw Error(`Logo content is not a valid SVG file.`);if(/<(?:script|foreignObject|iframe|object|embed)(?:\s|>)/iu.test(t)||/\son[a-z]+\s*=/iu.test(t)||/(?:href|src)\s*=\s*["'](?!#)/iu.test(t)||/(?:@import|url\(\s*(?!["']?#))/iu.test(t)||/<!DOCTYPE|<!ENTITY|<\?xml-stylesheet/iu.test(t))throw Error(`SVG logos cannot contain scripts or external resources.`)};function h(e,t){if(e.byteLength<1||e.byteLength>262144)throw Error(`Logo must be between 1 and ${u} bytes.`);if(t===`image/svg+xml`)return m(e),{};let n=t===`image/png`?f(e):p(e);if(n.width<1||n.height<1||n.width>2048||n.height>2048)throw Error(`Raster logos cannot exceed ${d} by ${d} pixels.`);return n}var g=10,_=e=>{let t=/^(\d+)\./u.exec(e);if(!t?.[1])throw Error(`Unable to parse Preact version "${e}".`);return{major:Number.parseInt(t[1],10),version:e}},v=e=>{let t=_(e);if(t.major<g)throw Error(`TailorKit requires Preact ${g}.0.0 or newer, but found ${e}.`);return t},y=i.object({assets:i.object({client:i.literal(`client.js`),logos:i.object({dark:i.string().regex(/^logo-dark\.(?:png|svg|webp)$/u).optional(),light:i.string().regex(/^logo-light\.(?:png|svg|webp)$/u).optional()}).optional()}),version:i.literal(1)}),b=e=>y.parse({assets:{client:`client.js`,...e&&Object.keys(e).length>0?{logos:e}:{}},version:1}),x=`preact/package.json`,S=`\0tailorkit-preact-package-json`,C=async(e={})=>{let t=await r(e.configPath,e.cwd),n=e.entry??t.config.client?.entry??`./src/client.ts`,i=e.outDir??t.config.build?.outDir??`.tailorkit`,c=w(t.root);v(c);let u=s.resolve(t.root,i),d=await l({build:{emptyOutDir:!0,lib:{entry:s.resolve(t.root,n),fileName:`client`,formats:[`es`]},outDir:u,watch:e.watch?{}:null,minify:`oxc`,rollupOptions:{output:{comments:{annotation:!1,jsdoc:!1,legal:!1},minify:!0,minifyInternalExports:!0}}},configFile:!1,mode:e.mode,plugins:[{name:`tailorkit-preact-package-json`,enforce:`pre`,resolveId(e){return e===x?S:null},load(e){if(e===S){let e=JSON.stringify(c);return`export const version = ${e}; export default { version: ${e} };`}return null}}],root:t.root}),f={};for(let e of[`light`,`dark`]){let n=t.config.logos?.[e];if(!n)continue;let r=s.extname(n).toLowerCase().slice(1),i={png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`}[r];if(!i)throw Error(`The ${e} logo must be an SVG, PNG, or WebP file.`);let c=await a(s.resolve(t.root,n));h(c,i);let l=`logo-${e}.${r}`;await o(s.join(u,l),c),f[e]=l}return await o(s.join(u,`tailorkit-upload.json`),`${JSON.stringify(b(f),null,2)}
|
|
2
|
+
`,`utf-8`),d};function w(e){let t=c(s.join(e,`package.json`));try{let e=t(t.resolve(`preact/package.json`));if(typeof e.version==`string`)return e.version}catch(e){throw Error(`TailorKit requires Preact to build an app. Install preact@^10 and try again.`,{cause:e})}throw Error(`Unable to read the installed Preact version.`)}export{C as buildApp,y as tailorkitUploadManifestSchema};
|
package/dist/index.js
CHANGED
|
@@ -5,34 +5,34 @@ import{fileURLToPath as e}from"node:url";import{dirname as t}from"node:path";con
|
|
|
5
5
|
`+u}let p=r(e.buffer,o[l],s[l],e.position,f);u+=n.repeat(` `,t.indent)+i((e.line+1).toString(),d)+` | `+p.str+`
|
|
6
6
|
`,u+=n.repeat(`-`,t.indent+d+3+p.pos)+`^
|
|
7
7
|
`;for(let a=1;a<=t.linesAfter&&!(l+a>=s.length);a++){let c=r(e.buffer,o[l+a],s[l+a],e.position-(o[l]-o[l+a]),f);u+=n.repeat(` `,t.indent)+i((e.line+a+1).toString(),d)+` | `+c.str+`
|
|
8
|
-
`}return u.replace(/\n$/,``)}t.exports=a})),k=E(((e,t)=>{var n=de(),r=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],i=[`scalar`,`sequence`,`mapping`];function a(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function o(e,t){if(t||={},Object.keys(t).forEach(function(t){if(r.indexOf(t)===-1)throw new n(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=a(t.styleAliases||null),i.indexOf(this.kind)===-1)throw new n(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}t.exports=o})),
|
|
9
|
-
\r`;function i(e){if(e===null)return!1;let t=0,n=e.length,i=r;for(let r=0;r<n;r++){let n=i.indexOf(e.charAt(r));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0}function a(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,i=r,a=0,o=[];for(let e=0;e<n;e++)e%4==0&&e&&(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)),a=a<<6|i.indexOf(t.charAt(e));let s=n%4*6;return s===0?(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)):s===18?(o.push(a>>10&255),o.push(a>>2&255)):s===12&&o.push(a>>4&255),new Uint8Array(o)}function o(e){let t=``,n=0,i=e.length,a=r;for(let r=0;r<i;r++)r%3==0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];let o=i%3;return o===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):o===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):o===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function s(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}t.exports=new n(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:i,construct:a,predicate:s,represent:o})})),
|
|
10
|
-
`;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return`
`;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function re(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function ie(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var ae=Array(256),oe=Array(256);for(let e=0;e<256;e++)ae[e]=+!!ne(e),oe[e]=ne(e);function T(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||a,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxTotalMergeKeys=typeof t.maxTotalMergeKeys==`number`?t.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function E(e,t){let n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=i(n),new r(t,n)}function D(e,t){throw E(e,t)}function se(e,t){e.onWarning&&e.onWarning.call(null,E(e,t))}function O(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];o.call(n,t)||(n[t]={existed:o.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function ce(e){e.anchorMapTransactions.push(Object.create(null))}function le(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],i=Object.keys(t);for(let e=0,n=i.length;e<n;e+=1){let n=i[e];o.call(r,n)||(r[n]=t[n])}}function k(e){let t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let r=n.length-1;r>=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function
|
|
11
|
-
`,t-1))}function
|
|
8
|
+
`}return u.replace(/\n$/,``)}t.exports=a})),k=E(((e,t)=>{var n=de(),r=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],i=[`scalar`,`sequence`,`mapping`];function a(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function o(e,t){if(t||={},Object.keys(t).forEach(function(t){if(r.indexOf(t)===-1)throw new n(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=a(t.styleAliases||null),i.indexOf(this.kind)===-1)throw new n(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}t.exports=o})),A=E(((e,t)=>{var n=de(),r=k();function i(e,t){let n=[];return e[t].forEach(function(e){let t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function a(){let e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function t(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,n=arguments.length;e<n;e+=1)arguments[e].forEach(t);return e}function o(e){return this.extend(e)}o.prototype.extend=function(e){let t=[],s=[];if(e instanceof r)s.push(e);else if(Array.isArray(e))s=s.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(s=s.concat(e.explicit));else throw new n(`Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })`);t.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`);if(e.loadKind&&e.loadKind!==`scalar`)throw new n(`There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.`);if(e.multi)throw new n(`There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.`)}),s.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`)});let c=Object.create(o.prototype);return c.implicit=(this.implicit||[]).concat(t),c.explicit=(this.explicit||[]).concat(s),c.compiledImplicit=i(c,`implicit`),c.compiledExplicit=i(c,`explicit`),c.compiledTypeMap=a(c.compiledImplicit,c.compiledExplicit),c},t.exports=o})),pe=E(((e,t)=>{t.exports=new(k())(`tag:yaml.org,2002:str`,{kind:`scalar`,construct:function(e){return e===null?``:e}})})),j=E(((e,t)=>{t.exports=new(k())(`tag:yaml.org,2002:seq`,{kind:`sequence`,construct:function(e){return e===null?[]:e}})})),M=E(((e,t)=>{t.exports=new(k())(`tag:yaml.org,2002:map`,{kind:`mapping`,construct:function(e){return e===null?{}:e}})})),me=E(((e,t)=>{t.exports=new(A())({explicit:[pe(),j(),M()]})})),N=E(((e,t)=>{var n=k();function r(e){if(e===null)return!0;let t=e.length;return t===1&&e===`~`||t===4&&(e===`null`||e===`Null`||e===`NULL`)}function i(){return null}function a(e){return e===null}t.exports=new n(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{canonical:function(){return`~`},lowercase:function(){return`null`},uppercase:function(){return`NULL`},camelcase:function(){return`Null`},empty:function(){return``}},defaultStyle:`lowercase`})})),he=E(((e,t)=>{var n=k();function r(e){if(e===null)return!1;let t=e.length;return t===4&&(e===`true`||e===`True`||e===`TRUE`)||t===5&&(e===`false`||e===`False`||e===`FALSE`)}function i(e){return e===`true`||e===`True`||e===`TRUE`}function a(e){return Object.prototype.toString.call(e)===`[object Boolean]`}t.exports=new n(`tag:yaml.org,2002:bool`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{lowercase:function(e){return e?`true`:`false`},uppercase:function(e){return e?`TRUE`:`FALSE`},camelcase:function(e){return e?`True`:`False`}},defaultStyle:`lowercase`})})),P=E(((e,t)=>{var n=ue(),r=k();function i(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function a(e){return e>=48&&e<=55}function o(e){return e>=48&&e<=57}function s(e){if(e===null)return!1;let t=e.length,n=0,r=!1;if(!t)return!1;let s=e[n];if((s===`-`||s===`+`)&&(s=e[++n]),s===`0`){if(n+1===t)return!0;if(s=e[++n],s===`b`){for(n++;n<t;n++){if(s=e[n],s!==`0`&&s!==`1`)return!1;r=!0}return r&&isFinite(c(e))}if(s===`x`){for(n++;n<t;n++){if(!i(e.charCodeAt(n)))return!1;r=!0}return r&&isFinite(c(e))}if(s===`o`){for(n++;n<t;n++){if(!a(e.charCodeAt(n)))return!1;r=!0}return r&&isFinite(c(e))}}for(;n<t;n++){if(!o(e.charCodeAt(n)))return!1;r=!0}return r?isFinite(c(e)):!1}function c(e){let t=e,n=1,r=t[0];if((r===`-`||r===`+`)&&(r===`-`&&(n=-1),t=t.slice(1),r=t[0]),t===`0`)return 0;if(r===`0`){if(t[1]===`b`)return n*parseInt(t.slice(2),2);if(t[1]===`x`)return n*parseInt(t.slice(2),16);if(t[1]===`o`)return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function l(e){return c(e)}function u(e){return Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!n.isNegativeZero(e)}t.exports=new r(`tag:yaml.org,2002:int`,{kind:`scalar`,resolve:s,construct:l,predicate:u,represent:{binary:function(e){return e>=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}})})),F=E(((e,t)=>{var n=ue(),r=k(),i=RegExp(`^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),a=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function o(e){return e===null||!i.test(e)?!1:isFinite(parseFloat(e,10))?!0:a.test(e)}function s(e){let t=e.toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}var c=/^[-+]?[0-9]+e/;function l(e,t){if(isNaN(e))switch(t){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(e===1/0)switch(t){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(e===-1/0)switch(t){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(n.isNegativeZero(e))return`-0.0`;let r=e.toString(10);return c.test(r)?r.replace(`e`,`.e`):r}function u(e){return Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||n.isNegativeZero(e))}t.exports=new r(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:o,construct:s,predicate:u,represent:l,defaultStyle:`lowercase`})})),I=E(((e,t)=>{t.exports=me().extend({implicit:[N(),he(),P(),F()]})})),ge=E(((e,t)=>{t.exports=I()})),_e=E(((e,t)=>{var n=k(),r=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),i=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function a(e){return e===null?!1:r.exec(e)!==null||i.exec(e)!==null}function o(e){let t=0,n=null,a=r.exec(e);if(a===null&&(a=i.exec(e)),a===null)throw Error(`Date resolve error`);let o=+a[1],s=a[2]-1,c=+a[3];if(!a[4])return new Date(Date.UTC(o,s,c));let l=+a[4],u=+a[5],d=+a[6];if(a[7]){for(t=a[7].slice(0,3);t.length<3;)t+=`0`;t=+t}if(a[9]){let e=+a[10],t=+(a[11]||0);n=(e*60+t)*6e4,a[9]===`-`&&(n=-n)}let f=new Date(Date.UTC(o,s,c,l,u,d,t));return n&&f.setTime(f.getTime()-n),f}function s(e){return e.toISOString()}t.exports=new n(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:a,construct:o,instanceOf:Date,represent:s})})),ve=E(((e,t)=>{var n=k();function r(e){return e===`<<`||e===null}t.exports=new n(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:r})})),ye=E(((e,t)=>{var n=k(),r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
9
|
+
\r`;function i(e){if(e===null)return!1;let t=0,n=e.length,i=r;for(let r=0;r<n;r++){let n=i.indexOf(e.charAt(r));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0}function a(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,i=r,a=0,o=[];for(let e=0;e<n;e++)e%4==0&&e&&(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)),a=a<<6|i.indexOf(t.charAt(e));let s=n%4*6;return s===0?(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)):s===18?(o.push(a>>10&255),o.push(a>>2&255)):s===12&&o.push(a>>4&255),new Uint8Array(o)}function o(e){let t=``,n=0,i=e.length,a=r;for(let r=0;r<i;r++)r%3==0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];let o=i%3;return o===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):o===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):o===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function s(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}t.exports=new n(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:i,construct:a,predicate:s,represent:o})})),L=E(((e,t)=>{var n=k(),r=Object.prototype.hasOwnProperty,i=Object.prototype.toString;function a(e){if(e===null)return!0;let t={},n=e;for(let e=0,a=n.length;e<a;e+=1){let a=n[e],o=!1;if(i.call(a)!==`[object Object]`)return!1;let s;for(s in a)if(r.call(a,s)){if(!o)o=!0;else return!1}if(!o||r.call(t,s))return!1;Object.defineProperty(t,s,{value:!0})}return!0}function o(e){return e===null?[]:e}t.exports=new n(`tag:yaml.org,2002:omap`,{kind:`sequence`,resolve:a,construct:o})})),be=E(((e,t)=>{var n=k(),r=Object.prototype.toString;function i(e){if(e===null)return!0;let t=e,n=Array(t.length);for(let e=0,i=t.length;e<i;e+=1){let i=t[e];if(r.call(i)!==`[object Object]`)return!1;let a=Object.keys(i);if(a.length!==1)return!1;n[e]=[a[0],i[a[0]]]}return!0}function a(e){if(e===null)return[];let t=e,n=Array(t.length);for(let e=0,r=t.length;e<r;e+=1){let r=t[e],i=Object.keys(r);n[e]=[i[0],r[i[0]]]}return n}t.exports=new n(`tag:yaml.org,2002:pairs`,{kind:`sequence`,resolve:i,construct:a})})),xe=E(((e,t)=>{var n=k(),r=Object.prototype.hasOwnProperty;function i(e){if(e===null)return!0;let t=e;for(let e in t)if(r.call(t,e)&&t[e]!==null)return!1;return!0}function a(e){return e===null?{}:e}t.exports=new n(`tag:yaml.org,2002:set`,{kind:`mapping`,resolve:i,construct:a})})),Se=E(((e,t)=>{t.exports=ge().extend({implicit:[_e(),ve()],explicit:[ye(),L(),be(),xe()]})})),Ce=E(((e,t)=>{var n=ue(),r=de(),i=fe(),a=Se(),o=Object.prototype.hasOwnProperty,s=1,c=2,l=3,u=4,d=1,f=2,p=3,m=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,h=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,_=/^(?:!|!!|![0-9A-Za-z-]+!)$/,v=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function y(e){return Object.prototype.toString.call(e)}function b(e){return e===10||e===13}function x(e){return e===9||e===32}function S(e){return e===9||e===32||e===10||e===13}function C(e){return e===44||e===91||e===93||e===123||e===125}function w(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function ee(e){return e===120?2:e===117?4:e===85?8:0}function te(e){return e>=48&&e<=57?e-48:-1}function ne(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return`
|
|
10
|
+
`;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return`
`;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function re(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function ie(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var ae=Array(256),oe=Array(256);for(let e=0;e<256;e++)ae[e]=+!!ne(e),oe[e]=ne(e);function T(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||a,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxTotalMergeKeys=typeof t.maxTotalMergeKeys==`number`?t.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function E(e,t){let n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=i(n),new r(t,n)}function D(e,t){throw E(e,t)}function se(e,t){e.onWarning&&e.onWarning.call(null,E(e,t))}function O(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];o.call(n,t)||(n[t]={existed:o.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function ce(e){e.anchorMapTransactions.push(Object.create(null))}function le(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],i=Object.keys(t);for(let e=0,n=i.length;e<n;e+=1){let n=i[e];o.call(r,n)||(r[n]=t[n])}}function k(e){let t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let r=n.length-1;r>=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function A(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function pe(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}var j={YAML:function(e,t,n){e.version!==null&&D(e,`duplication of %YAML directive`),n.length!==1&&D(e,`YAML directive accepts exactly one argument`);let r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&D(e,`ill-formed argument of the YAML directive`);let i=parseInt(r[1],10),a=parseInt(r[2],10);i!==1&&D(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&se(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){let r;n.length!==2&&D(e,`TAG directive accepts exactly two arguments`);let i=n[0];r=n[1],_.test(i)||D(e,`ill-formed tag handle (first argument) of the TAG directive`),o.call(e.tagMap,i)&&D(e,`there is a previously declared suffix for "`+i+`" tag handle`),v.test(r)||D(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{r=decodeURIComponent(r)}catch{D(e,`tag prefix is malformed: `+r)}e.tagMap[i]=r}};function M(e,t,n,r){if(t<n){let i=e.input.slice(t,n);if(r)for(let t=0,n=i.length;t<n;t+=1){let n=i.charCodeAt(t);n===9||n>=32&&n<=1114111||D(e,`expected valid JSON character`)}else m.test(i)&&D(e,`the stream contains non-printable characters`);e.result+=i}}function me(e,t,r,i){n.isObject(r)||D(e,`cannot merge mappings; the provided source object is unacceptable`);let a=Object.keys(r);for(let n=0,s=a.length;n<s;n+=1){let s=a[n];e.maxTotalMergeKeys!==-1&&++e.totalMergeKeys>e.maxTotalMergeKeys&&D(e,`merge keys exceeded maxTotalMergeKeys (`+e.maxTotalMergeKeys+`)`),o.call(t,s)||(ie(t,s,r[s]),i[s]=!0)}}function N(e,t,n,r,i,a,s,c,l){if(Array.isArray(i)){i=Array.prototype.slice.call(i);for(let t=0,n=i.length;t<n;t+=1)Array.isArray(i[t])&&D(e,`nested arrays are not supported inside keys`),typeof i==`object`&&y(i[t])===`[object Object]`&&(i[t]=`[object Object]`)}if(typeof i==`object`&&y(i)===`[object Object]`&&(i=`[object Object]`),i=String(i),t===null&&(t={}),r===`tag:yaml.org,2002:merge`){if(Array.isArray(a))for(let r=0,i=a.length;r<i;r+=1)me(e,t,a[r],n);else me(e,t,a,n)}else!e.json&&!o.call(n,i)&&o.call(t,i)&&(e.line=s||e.line,e.lineStart=c||e.lineStart,e.position=l||e.position,D(e,`duplicated mapping key`)),ie(t,i,a),delete n[i];return t}function he(e){let t=e.input.charCodeAt(e.position);t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):D(e,`a line break is expected`),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function P(e,t,n){let r=0,i=e.input.charCodeAt(e.position);for(;i!==0;){for(;x(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(b(i))for(he(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&se(e,`deficient indentation`),r}function F(e){let t=e.position,n=e.input.charCodeAt(t);return!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||S(n)))}function I(e,t){t===1?e.result+=` `:t>1&&(e.result+=n.repeat(`
|
|
11
|
+
`,t-1))}function ge(e,t,n){let r,i,a,o,s,c,l=e.kind,u=e.result,d=e.input.charCodeAt(e.position);if(S(d)||C(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96)return!1;if(d===63||d===45){let t=e.input.charCodeAt(e.position+1);if(S(t)||n&&C(t))return!1}for(e.kind=`scalar`,e.result=``,r=i=e.position,a=!1;d!==0;){if(d===58){let t=e.input.charCodeAt(e.position+1);if(S(t)||n&&C(t))break}else if(d===35){if(S(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&F(e)||n&&C(d))break;else if(b(d)){if(o=e.line,s=e.lineStart,c=e.lineIndent,P(e,!1,-1),e.lineIndent>=t){a=!0,d=e.input.charCodeAt(e.position);continue}e.position=i,e.line=o,e.lineStart=s,e.lineIndent=c;break}a&&=(M(e,r,i,!1),I(e,e.line-o),r=i=e.position,!1),x(d)||(i=e.position+1),d=e.input.charCodeAt(++e.position)}return M(e,r,i,!1),e.result?!0:(e.kind=l,e.result=u,!1)}function _e(e,t){let n,r,i=e.input.charCodeAt(e.position);if(i!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39){if(M(e,n,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)n=e.position,e.position++,r=e.position;else return!0}else b(i)?(M(e,n,r,!0),I(e,P(e,!1,t)),n=r=e.position):e.position===e.lineStart&&F(e)?D(e,`unexpected end of the document within a single quoted scalar`):(e.position++,x(i)||(r=e.position));D(e,`unexpected end of the stream within a single quoted scalar`)}function ve(e,t){let n,r,i,a=e.input.charCodeAt(e.position);if(a!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===34)return M(e,n,e.position,!0),e.position++,!0;else if(a===92){if(M(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),b(a))P(e,!1,t);else if(a<256&&ae[a])e.result+=oe[a],e.position++;else if((i=ee(a))>0){let t=i,n=0;for(;t>0;t--)a=e.input.charCodeAt(++e.position),(i=w(a))>=0?n=(n<<4)+i:D(e,`expected hexadecimal character`);e.result+=re(n),e.position++}else D(e,`unknown escape sequence`);n=r=e.position}else b(a)?(M(e,n,r,!0),I(e,P(e,!1,t)),n=r=e.position):e.position===e.lineStart&&F(e)?D(e,`unexpected end of the document within a double quoted scalar`):(e.position++,x(a)||(r=e.position));D(e,`unexpected end of the stream within a double quoted scalar`)}function ye(e,t){let n=!0,r,i,a,o=e.tag,c,l=e.anchor,u,d,f,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)u=93,p=!1,c=[];else if(v===123)u=125,p=!0,c={};else return!1;for(e.anchor!==null&&O(e,e.anchor,c),v=e.input.charCodeAt(++e.position);v!==0;){if(P(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=o,e.anchor=l,e.kind=p?`mapping`:`sequence`,e.result=c,!0;n?v===44&&D(e,`expected the node content, but found ','`):D(e,`missed comma between flow collection entries`),g=h=_=null,d=f=!1,v===63&&S(e.input.charCodeAt(e.position+1))&&(d=f=!0,e.position++,P(e,!0,t)),r=e.line,i=e.lineStart,a=e.position,R(e,t,s,!1,!0),g=e.tag,h=e.result,P(e,!0,t),v=e.input.charCodeAt(e.position),(f||e.line===r)&&v===58&&(d=!0,v=e.input.charCodeAt(++e.position),P(e,!0,t),R(e,t,s,!1,!0),_=e.result),p?N(e,c,m,g,h,_,r,i,a):d?c.push(N(e,null,m,g,h,_,r,i,a)):c.push(h),P(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}D(e,`unexpected end of the stream within a flow collection`)}function L(e,t){let r,i=d,a=!1,o=!1,s=t,c=0,l=!1,u,m=e.input.charCodeAt(e.position);if(m===124)r=!1;else if(m===62)r=!0;else return!1;for(e.kind=`scalar`,e.result=``;m!==0;)if(m=e.input.charCodeAt(++e.position),m===43||m===45)d===i?i=m===43?p:f:D(e,`repeat of a chomping mode identifier`);else if((u=te(m))>=0)u===0?D(e,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?D(e,`repeat of an indentation width identifier`):(s=t+u-1,o=!0);else break;if(x(m)){do m=e.input.charCodeAt(++e.position);while(x(m));if(m===35)do m=e.input.charCodeAt(++e.position);while(!b(m)&&m!==0)}for(;m!==0;){for(he(e),e.lineIndent=0,m=e.input.charCodeAt(e.position);(!o||e.lineIndent<s)&&m===32;)e.lineIndent++,m=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>s&&(s=e.lineIndent),b(m)){c++;continue}if(!o&&s===0&&D(e,`missing indentation for block scalar`),e.lineIndent<s){i===p?e.result+=n.repeat(`
|
|
12
12
|
`,a?1+c:c):i===d&&a&&(e.result+=`
|
|
13
13
|
`);break}r?x(m)?(l=!0,e.result+=n.repeat(`
|
|
14
14
|
`,a?1+c:c)):l?(l=!1,e.result+=n.repeat(`
|
|
15
15
|
`,c+1)):c===0?a&&(e.result+=` `):e.result+=n.repeat(`
|
|
16
16
|
`,c):e.result+=n.repeat(`
|
|
17
|
-
`,a?1+c:c),a=!0,o=!0,c=0;let t=e.position;for(;!b(m)&&m!==0;)m=e.input.charCodeAt(++e.position);
|
|
18
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));let n=new T(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,D(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)
|
|
17
|
+
`,a?1+c:c),a=!0,o=!0,c=0;let t=e.position;for(;!b(m)&&m!==0;)m=e.input.charCodeAt(++e.position);M(e,t,e.position,!1)}return!0}function be(e,t){let n=e.tag,r=e.anchor,i=[],a=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&O(e,e.anchor,i);let o=e.input.charCodeAt(e.position);for(;o!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,D(e,`tab characters must not be used in indentation`)),!(o!==45||!S(e.input.charCodeAt(e.position+1))));){if(a=!0,e.position++,P(e,!0,-1)&&e.lineIndent<=t){i.push(null),o=e.input.charCodeAt(e.position);continue}let n=e.line;if(R(e,t,l,!1,!0),i.push(e.result),P(e,!0,-1),o=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&o!==0)D(e,`bad indentation of a sequence entry`);else if(e.lineIndent<t)break}return a?(e.tag=n,e.anchor=r,e.kind=`sequence`,e.result=i,!0):!1}function xe(e,t,n){let r,i,a,o,s=e.tag,l=e.anchor,d={},f=Object.create(null),p=null,m=null,h=null,g=!1,_=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&O(e,e.anchor,d);let v=e.input.charCodeAt(e.position);for(;v!==0;){!g&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,D(e,`tab characters must not be used in indentation`));let y=e.input.charCodeAt(e.position+1),b=e.line;if((v===63||v===58)&&S(y))v===63?(g&&(N(e,d,f,p,m,null,i,a,o),p=m=h=null),_=!0,g=!0,r=!0):g?(g=!1,r=!0):D(e,`incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line`),e.position+=1,v=y;else{if(i=e.line,a=e.lineStart,o=e.position,!R(e,n,c,!1,!0))break;if(e.line===b){for(v=e.input.charCodeAt(e.position);x(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),S(v)||D(e,`a whitespace character is expected after the key-value separator within a block mapping`),g&&(N(e,d,f,p,m,null,i,a,o),p=m=h=null),_=!0,g=!1,r=!1,p=e.tag,m=e.result;else if(_)D(e,`can not read an implicit mapping pair; a colon is missed`);else return e.tag=s,e.anchor=l,!0}else if(_)D(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return e.tag=s,e.anchor=l,!0}if((e.line===b||e.lineIndent>t)&&(g&&(i=e.line,a=e.lineStart,o=e.position),R(e,t,u,!0,r)&&(g?m=e.result:h=e.result),g||(N(e,d,f,p,m,h,i,a,o),p=m=h=null),P(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===b||e.lineIndent>t)&&v!==0)D(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return g&&N(e,d,f,p,m,null,i,a,o),_&&(e.tag=s,e.anchor=l,e.kind=`mapping`,e.result=d),_}function Ce(e){let t=!1,n=!1,r,i,a=e.input.charCodeAt(e.position);if(a!==33)return!1;e.tag!==null&&D(e,`duplication of a tag property`),a=e.input.charCodeAt(++e.position),a===60?(t=!0,a=e.input.charCodeAt(++e.position)):a===33?(n=!0,r=`!!`,a=e.input.charCodeAt(++e.position)):r=`!`;let s=e.position;if(t){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(s,e.position),a=e.input.charCodeAt(++e.position)):D(e,`unexpected end of the stream within a verbatim tag`)}else{for(;a!==0&&!S(a);)a===33&&(n?D(e,`tag suffix cannot contain exclamation marks`):(r=e.input.slice(s-1,e.position+1),_.test(r)||D(e,`named tag handle cannot contain such characters`),n=!0,s=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(s,e.position),g.test(i)&&D(e,`tag suffix cannot contain flow indicator characters`)}i&&!v.test(i)&&D(e,`tag name cannot contain such characters: `+i);try{i=decodeURIComponent(i)}catch{D(e,`tag name is malformed: `+i)}return t?e.tag=i:o.call(e.tagMap,r)?e.tag=e.tagMap[r]+i:r===`!`?e.tag=`!`+i:r===`!!`?e.tag=`tag:yaml.org,2002:`+i:D(e,`undeclared tag handle "`+r+`"`),!0}function we(e){let t=e.input.charCodeAt(e.position);if(t!==38)return!1;e.anchor!==null&&D(e,`duplication of an anchor property`),t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!S(t)&&!C(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&D(e,`name of an anchor node must contain at least one character`),e.anchor=e.input.slice(n,e.position),!0}function Te(e){let t=e.input.charCodeAt(e.position);if(t!==42)return!1;t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!S(t)&&!C(t);)t=e.input.charCodeAt(++e.position);e.position===n&&D(e,`name of an alias node must contain at least one character`);let r=e.input.slice(n,e.position);return o.call(e.anchorMap,r)||D(e,`unidentified alias "`+r+`"`),e.result=e.anchorMap[r],P(e,!0,-1),!0}function Ee(e,t,n,r){let i=A(e);return ce(e),pe(e,t),e.tag=null,e.anchor=null,e.kind=null,e.result=null,xe(e,n,r)&&e.kind===`mapping`?(le(e),!0):(k(e),pe(e,i),!1)}function R(e,t,n,r,i){let a,d,f=1,p=!1,m=!1,h=null,g,_,v;e.depth>=e.maxDepth&&D(e,`nesting exceeded maxDepth (`+e.maxDepth+`)`),e.depth+=1,e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let y=a=d=u===n||l===n;if(r&&P(e,!0,-1)&&(p=!0,e.lineIndent>t?f=1:e.lineIndent===t?f=0:e.lineIndent<t&&(f=-1)),f===1)for(;;){let n=e.input.charCodeAt(e.position),r=A(e);if(p&&(n===33&&e.tag!==null||n===38&&e.anchor!==null)||!Ce(e)&&!we(e))break;h===null&&(h=r),P(e,!0,-1)?(p=!0,d=y,e.lineIndent>t?f=1:e.lineIndent===t?f=0:e.lineIndent<t&&(f=-1)):d=!1}if(d&&=p||i,f===1||u===n){if(_=s===n||c===n?t:t+1,v=e.position-e.lineStart,f===1){if(d&&(be(e,v)||xe(e,v,_))||ye(e,_))m=!0;else{let t=e.input.charCodeAt(e.position);h!==null&&y&&!d&&t!==124&&t!==62&&Ee(e,h,h.position-h.lineStart,_)||a&&L(e,_)||_e(e,_)||ve(e,_)?m=!0:Te(e)?(m=!0,(e.tag!==null||e.anchor!==null)&&D(e,`alias node should not have any properties`)):ge(e,_,s===n)&&(m=!0,e.tag===null&&(e.tag=`?`)),e.anchor!==null&&O(e,e.anchor,e.result)}}else f===0&&(m=d&&be(e,v))}if(e.tag===null)e.anchor!==null&&O(e,e.anchor,e.result);else if(e.tag===`?`){e.result!==null&&e.kind!==`scalar`&&D(e,`unacceptable node kind for !<?> tag; it should be "scalar", not "`+e.kind+`"`);for(let t=0,n=e.implicitTypes.length;t<n;t+=1)if(g=e.implicitTypes[t],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&O(e,e.anchor,e.result);break}}else if(e.tag!==`!`){if(o.call(e.typeMap[e.kind||`fallback`],e.tag))g=e.typeMap[e.kind||`fallback`][e.tag];else{g=null;let t=e.typeMap.multi[e.kind||`fallback`];for(let n=0,r=t.length;n<r;n+=1)if(e.tag.slice(0,t[n].tag.length)===t[n].tag){g=t[n];break}}g||D(e,`unknown tag !<`+e.tag+`>`),e.result!==null&&g.kind!==e.kind&&D(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+g.kind+`", not "`+e.kind+`"`),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&O(e,e.anchor,e.result)):D(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),--e.depth,e.tag!==null||e.anchor!==null||m}function De(e){let t=e.position,n=!1,r;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(r=e.input.charCodeAt(e.position))!==0&&(P(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||r!==37));){n=!0,r=e.input.charCodeAt(++e.position);let t=e.position;for(;r!==0&&!S(r);)r=e.input.charCodeAt(++e.position);let i=e.input.slice(t,e.position),a=[];for(i.length<1&&D(e,`directive name must not be less than one character in length`);r!==0;){for(;x(r);)r=e.input.charCodeAt(++e.position);if(r===35){do r=e.input.charCodeAt(++e.position);while(r!==0&&!b(r));break}if(b(r))break;for(t=e.position;r!==0&&!S(r);)r=e.input.charCodeAt(++e.position);a.push(e.input.slice(t,e.position))}r!==0&&he(e),o.call(j,i)?j[i](e,i,a):se(e,`unknown document directive "`+i+`"`)}if(P(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,P(e,!0,-1)):n&&D(e,`directives end mark is expected`),R(e,e.lineIndent-1,u,!1,!0),P(e,!0,-1),e.checkLineBreaks&&h.test(e.input.slice(t,e.position))&&se(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&F(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,P(e,!0,-1));return}e.position<e.length-1&&D(e,`end of the stream or a document separator is expected`)}function z(e,t){e=String(e),t||={},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
18
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));let n=new T(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,D(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)De(n);return n.documents}function Oe(e,t,n){typeof t==`object`&&t&&n===void 0&&(n=t,t=null);let r=z(e,n);if(typeof t!=`function`)return r;for(let e=0,n=r.length;e<n;e+=1)t(r[e])}function ke(e,t){let n=z(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new r(`expected a single document in the stream, but found more`)}}t.exports.loadAll=Oe,t.exports.load=ke})),we=E(((e,t)=>{var n=ue(),r=de(),i=Se(),a=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,c=9,l=10,u=13,d=32,f=33,p=34,m=35,h=37,g=38,_=39,v=42,y=44,b=45,x=58,S=61,C=62,w=63,ee=64,te=91,ne=93,re=96,ie=123,ae=124,oe=125,T={};T[0]=`\\0`,T[7]=`\\a`,T[8]=`\\b`,T[9]=`\\t`,T[10]=`\\n`,T[11]=`\\v`,T[12]=`\\f`,T[13]=`\\r`,T[27]=`\\e`,T[34]=`\\"`,T[92]=`\\\\`,T[133]=`\\N`,T[160]=`\\_`,T[8232]=`\\L`,T[8233]=`\\P`;var E=[`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],D=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function se(e,t){if(t===null)return{};let n={},r=Object.keys(t);for(let i=0,a=r.length;i<a;i+=1){let a=r[i],s=String(t[a]);a.slice(0,2)===`!!`&&(a=`tag:yaml.org,2002:`+a.slice(2));let c=e.compiledTypeMap.fallback[a];c&&o.call(c.styleAliases,s)&&(s=c.styleAliases[s]),n[a]=s}return n}function O(e){let t,i,a=e.toString(16).toUpperCase();if(e<=255)t=`x`,i=2;else if(e<=65535)t=`u`,i=4;else if(e<=4294967295)t=`U`,i=8;else throw new r(`code point within a string may not be greater than 0xFFFFFFFF`);return`\\`+t+n.repeat(`0`,i-a.length)+a}var ce=1,le=2;function fe(e){this.schema=e.schema||i,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=n.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=se(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType===`"`?le:ce,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer==`function`?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result=``,this.duplicates=[],this.usedDuplicates=null}function k(e,t){let r=n.repeat(` `,t),i=0,a=``,o=e.length;for(;i<o;){let t,n=e.indexOf(`
|
|
19
19
|
`,i);n===-1?(t=e.slice(i),i=o):(t=e.slice(i,n+1),i=n+1),t.length&&t!==`
|
|
20
|
-
`&&(a+=r),a+=t}return a}function
|
|
21
|
-
`+n.repeat(` `,e.indent*t)}function
|
|
20
|
+
`&&(a+=r),a+=t}return a}function A(e,t){return`
|
|
21
|
+
`+n.repeat(` `,e.indent*t)}function pe(e,t){for(let n=0,r=e.implicitTypes.length;n<r;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}function j(e){return e===d||e===c}function M(e){return e>=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==s||e>=65536&&e<=1114111}function me(e){return M(e)&&e!==s&&e!==u&&e!==l}function N(e,t,n){let r=me(e),i=r&&!j(e);return(n?r:r&&e!==y&&e!==te&&e!==ne&&e!==ie&&e!==oe)&&e!==m&&!(t===x&&!i)||me(t)&&!j(t)&&e===m||t===x&&i}function he(e){return M(e)&&e!==s&&!j(e)&&e!==b&&e!==w&&e!==x&&e!==y&&e!==te&&e!==ne&&e!==ie&&e!==oe&&e!==m&&e!==g&&e!==v&&e!==f&&e!==ae&&e!==S&&e!==C&&e!==_&&e!==p&&e!==h&&e!==ee&&e!==re}function P(e){return!j(e)&&e!==x}function F(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function I(e){return/^\n* /.test(e)}var ge=1,_e=2,ve=3,ye=4,L=5;function be(e,t,n,r,i,a,o,s){let c,u=0,d=null,f=!1,p=!1,m=r!==-1,h=-1,g=he(F(e,0))&&P(F(e,e.length-1));if(t||o)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=F(e,c),!M(u))return L;g&&=N(u,d,s),d=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=F(e,c),u===l)f=!0,m&&(p||=c-h-1>r&&e[h+1]!==` `,h=c);else if(!M(u))return L;g&&=N(u,d,s),d=u}p||=m&&c-h-1>r&&e[h+1]!==` `}return!f&&!p?g&&!o&&!i(e)?ge:a===le?L:_e:n>9&&I(e)?L:o?a===le?L:_e:p?ye:ve}function xe(e,t,n,i,a){e.dump=function(){if(t.length===0)return e.quotingType===le?`""`:`''`;if(!e.noCompatMode&&(E.indexOf(t)!==-1||D.test(t)))return e.quotingType===le?`"`+t+`"`:`'`+t+`'`;let o=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),c=i||e.flowLevel>-1&&n>=e.flowLevel;function l(t){return pe(e,t)}switch(be(t,c,e.indent,s,l,e.quotingType,e.forceQuotes&&!i,a)){case ge:return t;case _e:return`'`+t.replace(/'/g,`''`)+`'`;case ve:return`|`+Ce(t,e.indent)+we(k(t,o));case ye:return`>`+Ce(t,e.indent)+we(k(Te(t,s),o));case L:return`"`+R(t,s)+`"`;default:throw new r(`impossible error: invalid scalar style`)}}()}function Ce(e,t){let n=I(e)?String(t):``,r=e[e.length-1]===`
|
|
22
22
|
`;return n+(r&&(e[e.length-2]===`
|
|
23
23
|
`||e===`
|
|
24
24
|
`)?`+`:r?``:`-`)+`
|
|
25
|
-
`}function
|
|
26
|
-
`?e.slice(0,-1):e}function
|
|
27
|
-
`);return r=r===-1?e.length:r,n.lastIndex=r,
|
|
25
|
+
`}function we(e){return e[e.length-1]===`
|
|
26
|
+
`?e.slice(0,-1):e}function Te(e,t){let n=/(\n+)([^\n]*)/g,r=function(){let r=e.indexOf(`
|
|
27
|
+
`);return r=r===-1?e.length:r,n.lastIndex=r,Ee(e.slice(0,r),t)}(),i=e[0]===`
|
|
28
28
|
`||e[0]===` `,a,o;for(;o=n.exec(e);){let e=o[1],n=o[2];a=n[0]===` `,r+=e+(!i&&!a&&n!==``?`
|
|
29
|
-
`:``)+
|
|
29
|
+
`:``)+Ee(n,t),i=a}return r}function Ee(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=`
|
|
30
30
|
`+e.slice(i,a),i=a+1),o=s;return c+=`
|
|
31
31
|
`,e.length-i>t&&o>i?c+=e.slice(i,o)+`
|
|
32
|
-
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function
|
|
33
|
-
`:``}t.exports.dump=
|
|
32
|
+
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function R(e){let t=``,n=0;for(let r=0;r<e.length;n>=65536?r+=2:r++){n=F(e,r);let i=T[n];!i&&M(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=i||O(n)}return t}function De(e,t,n){let r=``,i=e.tag;for(let i=0,a=n.length;i<a;i+=1){let a=n[i];e.replacer&&(a=e.replacer.call(n,String(i),a)),(B(e,t,a,!1,!1)||a===void 0&&B(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump)}e.tag=i,e.dump=`[`+r+`]`}function z(e,t,n,r){let i=``,a=e.tag;for(let a=0,o=n.length;a<o;a+=1){let o=n[a];e.replacer&&(o=e.replacer.call(n,String(a),o)),(B(e,t+1,o,!0,!0,!1,!0)||o===void 0&&B(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=A(e,t)),e.dump&&l===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump)}e.tag=a,e.dump=i||`[]`}function Oe(e,t,n){let r=``,i=e.tag,a=Object.keys(n);for(let i=0,o=a.length;i<o;i+=1){let o=``;r!==``&&(o+=`, `),e.condenseFlow&&(o+=`"`);let s=a[i],c=n[s];e.replacer&&(c=e.replacer.call(n,s,c)),B(e,t,s,!1,!1)&&(e.dump.length>1024&&(o+=`? `),o+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),B(e,t,c,!1,!1)&&(o+=e.dump,r+=o))}e.tag=i,e.dump=`{`+r+`}`}function ke(e,t,n,i){let a=``,o=e.tag,s=Object.keys(n);if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==`function`)s.sort(e.sortKeys);else if(e.sortKeys)throw new r(`sortKeys must be a boolean or a function`);for(let r=0,o=s.length;r<o;r+=1){let o=``;(!i||a!==``)&&(o+=A(e,t));let c=s[r],u=n[c];if(e.replacer&&(u=e.replacer.call(n,c,u)),!B(e,t+1,c,!0,!0,!0))continue;let d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024;d&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`?`:o+=`? `),o+=e.dump,d&&(o+=A(e,t)),B(e,t+1,u,!0,d)&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`:`:o+=`: `,o+=e.dump,a+=o)}e.tag=o,e.dump=a||`{}`}function Ae(e,t,n){let i=n?e.explicitTypes:e.implicitTypes;for(let s=0,c=i.length;s<c;s+=1){let c=i[s];if((c.instanceOf||c.predicate)&&(!c.instanceOf||typeof t==`object`&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(e.tag=n?c.multi&&c.representName?c.representName(t):c.tag:`?`,c.represent){let n=e.styleMap[c.tag]||c.defaultStyle,i;if(a.call(c.represent)===`[object Function]`)i=c.represent(t,n);else if(o.call(c.represent,n))i=c.represent[n](t,n);else throw new r(`!<`+c.tag+`> tag resolver accepts not "`+n+`" style`);e.dump=i}return!0}}return!1}function B(e,t,n,i,o,s,c){e.tag=null,e.dump=n,Ae(e,n,!1)||Ae(e,n,!0);let l=a.call(e.dump),u=i;i&&=e.flowLevel<0||e.flowLevel>t;let d=l===`[object Object]`||l===`[object Array]`,f,p;if(d&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!==`?`||p||e.indent!==2&&t>0)&&(o=!1),p&&e.usedDuplicates[f])e.dump=`*ref_`+f;else{if(d&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l===`[object Object]`)i&&Object.keys(e.dump).length!==0?(ke(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(Oe(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object Array]`)i&&e.dump.length!==0?(e.noArrayIndent&&!c&&t>0?z(e,t-1,e.dump,o):z(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(De(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object String]`)e.tag!==`?`&&xe(e,e.dump,t,s,u);else if(l===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new r(`unacceptable kind of an object to dump `+l)}if(e.tag!==null&&e.tag!==`?`){let t=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`);t=e.tag[0]===`!`?`!`+t:t.slice(0,18)===`tag:yaml.org,2002:`?`!!`+t.slice(18):`!<`+t+`>`,e.dump=t+` `+e.dump}}return!0}function je(e,t){let n=[],r=[];V(e,n,r);let i=r.length;for(let e=0;e<i;e+=1)t.duplicates.push(n[r[e]]);t.usedDuplicates=Array(i)}function V(e,t,n){if(typeof e==`object`&&e){let r=t.indexOf(e);if(r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(let r=0,i=e.length;r<i;r+=1)V(e[r],t,n);else{let r=Object.keys(e);for(let i=0,a=r.length;i<a;i+=1)V(e[r[i]],t,n)}}}function Me(e,t){t||={};let n=new fe(t);n.noRefs||je(e,n);let r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),B(n,0,r,!0,!0)?n.dump+`
|
|
33
|
+
`:``}t.exports.dump=Me})),Te=E(((e,t)=>{var n=Ce(),r=we();function i(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}t.exports.Type=k(),t.exports.Schema=A(),t.exports.FAILSAFE_SCHEMA=me(),t.exports.JSON_SCHEMA=I(),t.exports.CORE_SCHEMA=ge(),t.exports.DEFAULT_SCHEMA=Se(),t.exports.load=n.load,t.exports.loadAll=n.loadAll,t.exports.dump=r.dump,t.exports.YAMLException=de(),t.exports.types={binary:ye(),float:F(),map:M(),null:N(),pairs:be(),set:xe(),timestamp:_e(),bool:he(),int:P(),merge:ve(),omap:L(),seq:j(),str:pe()},t.exports.safeLoad=i(`safeLoad`,`load`),t.exports.safeLoadAll=i(`safeLoadAll`,`loadAll`),t.exports.safeDump=i(`safeDump`,`dump`)})),Ee=E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadYaml=e.loadJson=e.loadJs=e.loadJsSync=void 0;var t=D(`fs/promises`),n=D(`url`);e.loadJsSync=function(e){return delete D.cache[D.resolve(e)],D(e)},e.loadJs=async function(r){try{let{href:e}=(0,n.pathToFileURL)(await(0,t.realpath)(r));return(await import(e)).default}catch(t){try{return(0,e.loadJsSync)(r,``)}catch(e){throw e.code===`ERR_REQUIRE_ESM`||e instanceof SyntaxError&&e.toString().includes(`Cannot use import statement outside a module`)?t:e}}},e.loadJson=function(e,t){try{return JSON.parse(t)}catch(t){throw t.message=`JSON Error in ${e}:\n${t.message}`,t}};var r;e.loadYaml=function(e,t){r===void 0&&(r=Te());try{return r.load(t)}catch(t){throw t.message=`YAML Error in ${e}:\n${t.message}`,t}}})),R=E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLoadersSync=e.defaultLoaders=e.metaSearchPlaces=e.globalConfigSearchPlacesSync=e.globalConfigSearchPlaces=e.getDefaultSearchPlacesSync=e.getDefaultSearchPlaces=void 0;var t=Ee();function n(e){return[`package.json`,`.${e}rc`,`.${e}rc.json`,`.${e}rc.yaml`,`.${e}rc.yml`,`.${e}rc.js`,`.${e}rc.ts`,`.${e}rc.cjs`,`.${e}rc.mjs`,`.config/${e}rc`,`.config/${e}rc.json`,`.config/${e}rc.yaml`,`.config/${e}rc.yml`,`.config/${e}rc.js`,`.config/${e}rc.ts`,`.config/${e}rc.cjs`,`.config/${e}rc.mjs`,`${e}.config.js`,`${e}.config.ts`,`${e}.config.cjs`,`${e}.config.mjs`]}e.getDefaultSearchPlaces=n;function r(e){return[`package.json`,`.${e}rc`,`.${e}rc.json`,`.${e}rc.yaml`,`.${e}rc.yml`,`.${e}rc.js`,`.${e}rc.ts`,`.${e}rc.cjs`,`.config/${e}rc`,`.config/${e}rc.json`,`.config/${e}rc.yaml`,`.config/${e}rc.yml`,`.config/${e}rc.js`,`.config/${e}rc.ts`,`.config/${e}rc.cjs`,`${e}.config.js`,`${e}.config.ts`,`${e}.config.cjs`]}e.getDefaultSearchPlacesSync=r,e.globalConfigSearchPlaces=[`config`,`config.json`,`config.yaml`,`config.yml`,`config.js`,`config.ts`,`config.cjs`,`config.mjs`],e.globalConfigSearchPlacesSync=[`config`,`config.json`,`config.yaml`,`config.yml`,`config.js`,`config.ts`,`config.cjs`],e.metaSearchPlaces=[`package.json`,`package.yaml`,`.config/config.json`,`.config/config.yaml`,`.config/config.yml`,`.config/config.js`,`.config/config.ts`,`.config/config.cjs`,`.config/config.mjs`],e.defaultLoaders=Object.freeze({".mjs":t.loadJs,".cjs":t.loadJs,".js":t.loadJs,".ts":t.loadJs,".cts":t.loadJs,".mts":t.loadJs,".json":t.loadJson,".yaml":t.loadYaml,".yml":t.loadYaml,noExt:t.loadYaml}),e.defaultLoadersSync=Object.freeze({".cjs":t.loadJsSync,".js":t.loadJsSync,".cts":t.loadJsSync,".ts":t.loadJsSync,".json":t.loadJson,".yaml":t.loadYaml,".yml":t.loadYaml,noExt:t.loadYaml})})),De=E(((e,t)=>{var n=D(`path`),r=D(`os`),i=r.homedir(),a=r.tmpdir(),{env:o}=process,s=e=>{let t=n.join(i,`Library`);return{data:n.join(t,`Application Support`,e),config:n.join(t,`Preferences`,e),cache:n.join(t,`Caches`,e),log:n.join(t,`Logs`,e),temp:n.join(a,e)}},c=e=>{let t=o.APPDATA||n.join(i,`AppData`,`Roaming`),r=o.LOCALAPPDATA||n.join(i,`AppData`,`Local`);return{data:n.join(r,e,`Data`),config:n.join(t,e,`Config`),cache:n.join(r,e,`Cache`),log:n.join(r,e,`Log`),temp:n.join(a,e)}},l=e=>{let t=n.basename(i);return{data:n.join(o.XDG_DATA_HOME||n.join(i,`.local`,`share`),e),config:n.join(o.XDG_CONFIG_HOME||n.join(i,`.config`),e),cache:n.join(o.XDG_CACHE_HOME||n.join(i,`.cache`),e),log:n.join(o.XDG_STATE_HOME||n.join(i,`.local`,`state`),e),temp:n.join(a,t,e)}},u=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected string, got ${typeof e}`);return t=Object.assign({suffix:`nodejs`},t),t.suffix&&(e+=`-${t.suffix}`),process.platform===`darwin`?s(e):process.platform===`win32`?c(e):l(e)};t.exports=u,t.exports.default=u})),z=E((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.isDirectorySync=e.isDirectory=e.removeUndefinedValuesFromObject=e.decodeFileContent=e.getPropertyByPath=e.emplace=void 0;var i=r(D(`fs`));function a(e,t,n){let r=e.get(t);if(r!==void 0)return r;let i=n();return e.set(t,i),i}e.emplace=a;function o(e,t){return typeof t==`string`&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:(typeof t==`string`?t.split(`.`):t).reduce((e,t)=>e===void 0?e:e[t],e)}e.getPropertyByPath=o;function s(e){return e[0]===255&&e[1]===254?new TextDecoder(`utf-16le`).decode(e):e[0]===254&&e[1]===255?new TextDecoder(`utf-16be`).decode(e):e.toString(`utf-8`)}e.decodeFileContent=s;function c(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}e.removeUndefinedValuesFromObject=c;async function l(e){try{return(await i.promises.stat(e)).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}}e.isDirectory=l;function u(e){try{return i.default.statSync(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}}e.isDirectorySync=u})),Oe=E((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.getExtensionDescription=e.ExplorerBase=void 0;var n=t(De()),r=t(D(`os`)),i=t(D(`path`)),a=z();e.ExplorerBase=class{#e=!1;config;loadCache;searchCache;constructor(e){this.config=e,e.cache&&(this.loadCache=new Map,this.searchCache=new Map),this.#t()}set loadingMetaConfig(e){this.#e=e}#t(){let e=this.config;for(let t of e.searchPlaces){let e=i.default.extname(t),n=this.config.loaders[e||`noExt`]??this.config.loaders.default;if(n===void 0)throw Error(`Missing loader for ${o(t)}.`);if(typeof n!=`function`)throw Error(`Loader for ${o(t)} is not a function: Received ${typeof n}.`)}}clearLoadCache(){this.loadCache&&this.loadCache.clear()}clearSearchCache(){this.searchCache&&this.searchCache.clear()}clearCaches(){this.clearLoadCache(),this.clearSearchCache()}toCosmiconfigResult(e,t){if(t===null)return null;if(t===void 0)return{filepath:e,config:void 0,isEmpty:!0};if(this.config.applyPackagePropertyPathToConfiguration||this.#e){let e=this.config.packageProp??this.config.moduleName;t=(0,a.getPropertyByPath)(t,e)}return t===void 0?{filepath:e,config:void 0,isEmpty:!0}:{config:t,filepath:e}}validateImports(e,t,n){let r=i.default.dirname(e);for(let a of t){if(typeof a!=`string`)throw Error(`${e}: Key $import must contain a string or a list of strings`);let t=i.default.resolve(r,a);if(t===e)throw Error(`Self-import detected in ${e}`);let o=n.indexOf(t);if(o!==-1)throw Error(`Circular import detected:
|
|
34
34
|
${[...n,t].map((e,t)=>`${t+1}. ${e}`).join(`
|
|
35
|
-
`)} (same as ${o+1}.)`)}}getSearchPlacesForDir(e,t){return(e.isGlobalConfig?t:this.config.searchPlaces).map(t=>i.default.join(e.path,t))}getGlobalConfigDir(){return(0,n.default)(this.config.moduleName,{suffix:``}).config}*getGlobalDirs(e){let t=i.default.resolve(this.config.stopDir??r.default.homedir());yield{path:e,isGlobalConfig:!1};let n=e;for(;n!==t;){let e=i.default.dirname(n);if(e===n)break;yield{path:e,isGlobalConfig:!1},n=e}yield{path:this.getGlobalConfigDir(),isGlobalConfig:!0}}};function o(e){return e?`extension "${e}"`:`files without extensions`}e.getExtensionDescription=o})),Ae=E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mergeAll=e.hasOwn=void 0,e.hasOwn=Function.prototype.call.bind(Object.prototype.hasOwnProperty);var t=Function.prototype.call.bind(Object.prototype.toString);function n(e){return t(e)===`[object Object]`}function r(t,i,a){for(let o of Object.keys(i)){if(o===`__proto__`||o===`constructor`)continue;let s=i[o];if((0,e.hasOwn)(t,o)){if(Array.isArray(t[o])&&Array.isArray(s)){if(a.mergeArrays){t[o].push(...s);continue}}else if(n(t[o])&&n(s)){t[o]=r(t[o],s,a);continue}}t[o]=s}return t}function i(e,t){return e.reduce((e,n)=>r(e,n,t),{})}e.mergeAll=i})),je=E((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Explorer=void 0;var n=t(D(`fs/promises`)),r=t(D(`path`)),i=L(),a=ke(),o=Ae(),s=R();e.Explorer=class extends a.ExplorerBase{async load(e){e=r.default.resolve(e);let t=async()=>await this.config.transform(await this.#e(e));return this.loadCache?await(0,s.emplace)(this.loadCache,e,t):await t()}async search(e=``){if(this.config.metaConfigFilePath){this.loadingMetaConfig=!0;let e=await this.load(this.config.metaConfigFilePath);if(this.loadingMetaConfig=!1,e&&!e.isEmpty)return e}e=r.default.resolve(e);let t=this.#i(e),n=await t.next();if(n.done)throw Error(`Could not find any folders to iterate through (start from ${e})`);let a=n.value,o=async()=>{if(await(0,s.isDirectory)(a.path))for(let e of this.getSearchPlacesForDir(a,i.globalConfigSearchPlaces))try{let t=await this.#e(e);if(t!==null&&!(t.isEmpty&&this.config.ignoreEmptySearchPlaces))return await this.config.transform(t)}catch(e){if(e.code===`ENOENT`||e.code===`EISDIR`||e.code===`ENOTDIR`||e.code===`EACCES`)continue;throw e}let e=await t.next();return e.done?await this.config.transform(null):(a=e.value,this.searchCache?await(0,s.emplace)(this.searchCache,a.path,o):await o())};return this.searchCache?await(0,s.emplace)(this.searchCache,e,o):await o()}async#e(e,t=[]){let r=(0,s.decodeFileContent)(await n.default.readFile(e));return this.toCosmiconfigResult(e,await this.#t(e,r,t))}async#t(e,t,n){let i=await this.#n(e,t);if(!i||!(0,o.hasOwn)(i,`$import`))return i;let a=r.default.dirname(e),{$import:s,...c}=i,l=Array.isArray(s)?s:[s],u=[...n,e];this.validateImports(e,l,u);let d=await Promise.all(l.map(async e=>{let t=r.default.resolve(a,e);return(await this.#e(t,u))?.config}));return(0,o.mergeAll)([...d,c],{mergeArrays:this.config.mergeImportArrays})}async#n(e,t){if(t.trim()===``)return;let n=r.default.extname(e),i=this.config.loaders[n||`noExt`]??this.config.loaders.default;if(!i)throw Error(`No loader specified for ${(0,a.getExtensionDescription)(n)}`);try{let a=await i(e,t);return r.default.basename(e,n)===`package`?(0,s.getPropertyByPath)(a,this.config.packageProp??this.config.moduleName)??null:a}catch(t){throw t.filepath=e,t}}async#r(e){try{return await n.default.stat(e),!0}catch{return!1}}async*#i(e){switch(this.config.searchStrategy){case`none`:yield{path:e,isGlobalConfig:!1};return;case`project`:{let t=e;for(;;){yield{path:t,isGlobalConfig:!1};let e=!1;for(let n of[`json`,`yaml`]){let i=r.default.join(t,`package.${n}`);if(await this.#r(i)){e=!0;break}}if(e)return;let n=r.default.dirname(t);if(n===t)return;t=n}}case`global`:yield*this.getGlobalDirs(e)}}}})),z=E((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.ExplorerSync=void 0;var n=t(D(`fs`)),r=t(D(`path`)),i=L(),a=ke(),o=Ae(),s=R();e.ExplorerSync=class extends a.ExplorerBase{load(e){e=r.default.resolve(e);let t=()=>this.config.transform(this.#e(e));return this.loadCache?(0,s.emplace)(this.loadCache,e,t):t()}search(e=``){if(this.config.metaConfigFilePath){this.loadingMetaConfig=!0;let e=this.load(this.config.metaConfigFilePath);if(this.loadingMetaConfig=!1,e&&!e.isEmpty)return e}e=r.default.resolve(e);let t=this.#i(e),n=t.next();if(n.done)throw Error(`Could not find any folders to iterate through (start from ${e})`);let a=n.value,o=()=>{if((0,s.isDirectorySync)(a.path))for(let e of this.getSearchPlacesForDir(a,i.globalConfigSearchPlacesSync))try{let t=this.#e(e);if(t!==null&&!(t.isEmpty&&this.config.ignoreEmptySearchPlaces))return this.config.transform(t)}catch(e){if(e.code===`ENOENT`||e.code===`EISDIR`||e.code===`ENOTDIR`||e.code===`EACCES`)continue;throw e}let e=t.next();return e.done?this.config.transform(null):(a=e.value,this.searchCache?(0,s.emplace)(this.searchCache,a.path,o):o())};return this.searchCache?(0,s.emplace)(this.searchCache,e,o):o()}#e(e,t=[]){let r=(0,s.decodeFileContent)(n.default.readFileSync(e));return this.toCosmiconfigResult(e,this.#t(e,r,t))}#t(e,t,n){let i=this.#n(e,t);if(!i||!(0,o.hasOwn)(i,`$import`))return i;let a=r.default.dirname(e),{$import:s,...c}=i,l=Array.isArray(s)?s:[s],u=[...n,e];this.validateImports(e,l,u);let d=l.map(e=>{let t=r.default.resolve(a,e);return this.#e(t,u)?.config});return(0,o.mergeAll)([...d,c],{mergeArrays:this.config.mergeImportArrays})}#n(e,t){if(t.trim()===``)return;let n=r.default.extname(e),i=this.config.loaders[n||`noExt`]??this.config.loaders.default;if(!i)throw Error(`No loader specified for ${(0,a.getExtensionDescription)(n)}`);try{let a=i(e,t);return r.default.basename(e,n)===`package`?(0,s.getPropertyByPath)(a,this.config.packageProp??this.config.moduleName)??null:a}catch(t){throw t.filepath=e,t}}#r(e){try{return n.default.statSync(e),!0}catch{return!1}}*#i(e){switch(this.config.searchStrategy){case`none`:yield{path:e,isGlobalConfig:!1};return;case`project`:{let t=e;for(;;){yield{path:t,isGlobalConfig:!1};let e=!1;for(let n of[`json`,`yaml`]){let i=r.default.join(t,`package.${n}`);if(this.#r(i)){e=!0;break}}if(e)return;let n=r.default.dirname(t);if(n===t)return;t=n}}case`global`:yield*this.getGlobalDirs(e)}}loadSync(e){return this.load(e)}searchSync(e=``){return this.search(e)}}})),Me=(0,E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLoadersSync=e.defaultLoaders=e.globalConfigSearchPlacesSync=e.globalConfigSearchPlaces=e.getDefaultSearchPlacesSync=e.getDefaultSearchPlaces=e.cosmiconfigSync=e.cosmiconfig=void 0;var t=L();Object.defineProperty(e,"defaultLoaders",{enumerable:!0,get:function(){return t.defaultLoaders}}),Object.defineProperty(e,"defaultLoadersSync",{enumerable:!0,get:function(){return t.defaultLoadersSync}}),Object.defineProperty(e,"getDefaultSearchPlaces",{enumerable:!0,get:function(){return t.getDefaultSearchPlaces}}),Object.defineProperty(e,"getDefaultSearchPlacesSync",{enumerable:!0,get:function(){return t.getDefaultSearchPlacesSync}}),Object.defineProperty(e,"globalConfigSearchPlaces",{enumerable:!0,get:function(){return t.globalConfigSearchPlaces}}),Object.defineProperty(e,"globalConfigSearchPlacesSync",{enumerable:!0,get:function(){return t.globalConfigSearchPlacesSync}});var n=je(),r=z(),i=R(),a=function(e){return e};function o(){let e=new r.ExplorerSync({moduleName:`cosmiconfig`,stopDir:process.cwd(),searchPlaces:t.metaSearchPlaces,ignoreEmptySearchPlaces:!1,applyPackagePropertyPathToConfiguration:!0,loaders:t.defaultLoaders,transform:a,cache:!0,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:`none`}).search();if(!e)return null;if(e.config?.loaders)throw Error(`Can not specify loaders in meta config file`);if(e.config?.searchStrategy)throw Error(`Can not specify searchStrategy in meta config file`);let n={mergeSearchPlaces:!0,...e.config??{}};return{config:(0,i.removeUndefinedValuesFromObject)(n),filepath:e.filepath}}function s(e,t,n){let r=n.searchPlaces?.map(t=>t.replace(`{name}`,e));return n.mergeSearchPlaces?[...r??[],...t]:r??t}function c(e,t,n){let r=o();if(!r)return{...t,...(0,i.removeUndefinedValuesFromObject)(n),loaders:{...t.loaders,...n.loaders}};let a=r.config,c=n.searchPlaces??t.searchPlaces;return{...t,...(0,i.removeUndefinedValuesFromObject)(n),metaConfigFilePath:r.filepath,...a,searchPlaces:s(e,c,a),loaders:{...t.loaders,...n.loaders}}}function l(e){if(e.searchStrategy!=null&&e.searchStrategy!==`global`&&e.stopDir)throw Error('Can not supply `stopDir` option with `searchStrategy` other than "global"')}function u(e,n){return l(n),c(e,{moduleName:e,searchPlaces:(0,t.getDefaultSearchPlaces)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:a,loaders:t.defaultLoaders,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:n.stopDir?`global`:`none`},n)}function d(e,n){return l(n),c(e,{moduleName:e,searchPlaces:(0,t.getDefaultSearchPlacesSync)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:a,loaders:t.defaultLoadersSync,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:n.stopDir?`global`:`none`},n)}function f(e,t={}){let r=u(e,t),i=new n.Explorer(r);return{search:i.search.bind(i),load:i.load.bind(i),clearLoadCache:i.clearLoadCache.bind(i),clearSearchCache:i.clearSearchCache.bind(i),clearCaches:i.clearCaches.bind(i)}}e.cosmiconfig=f;function p(e,t={}){let n=d(e,t),i=new r.ExplorerSync(n);return{search:i.search.bind(i),load:i.load.bind(i),clearLoadCache:i.clearLoadCache.bind(i),clearSearchCache:i.clearSearchCache.bind(i),clearCaches:i.clearCaches.bind(i)}}e.cosmiconfigSync=p}))().cosmiconfig)(`tailorkit`,{searchPlaces:[`tailorkit.config.ts`,`tailorkit.config.mjs`,`tailorkit.config.js`]}),B=async(e,t=process.cwd())=>{let n=ee.resolve(t),r=e===void 0?await Me.search(n):await Me.load(ee.resolve(n,e));if(r===null)throw Error(`Could not find tailorkit config from ${n}.`);return{config:le.parse(r.config),filepath:r.filepath,root:ee.dirname(r.filepath)}};function Ne(e){return e[0]??{}}function Pe(e){return Array.isArray(e)?e:e==null?[]:[e]}var Fe=`orpc`,Ie=`@orpc/shared`,Le=`1.15.0`,Re=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function ze(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function Be(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var Ve=2,He=`__${Ie}@${Le}/otel/config__`;function Ue(){return globalThis[He]}function We(e,t={},n){return(Ue()?.tracer)?.startSpan(e,t,n)}function V(e,t,n={}){if(!e)return;let r=Ge(t);e.recordException(r),(!n.signal?.aborted||n.signal.reason!==t)&&e.setStatus({code:Ve,message:r.message})}function Ge(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function H({name:e,context:t,...n},r){let i=Ue()?.tracer;if(!i)return r();let a=async e=>{try{return await r(e)}catch(t){throw V(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,a):i.startActiveSpan(e,n,a)}async function Ke(e,t){let n=Ue();if(!e||!n)return t();let r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function U(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var qe=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Je=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=Be(async()=>{if(this.#e)return{done:!0,value:void 0};try{let t=await e();return t.done&&(this.#e=!0),t}catch(e){throw this.#e=!0,e}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n(`next`))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n(`return`)),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n(`throw`)),e}async[qe](){this.#e=!0,this.#t||(this.#t=!0,await this.#n(`dispose`))}[Symbol.asyncIterator](){return this}};function Ye({name:e,...t},n){let r;return new Je(async()=>{r??=We(e);try{let e=await Ke(r,()=>n.next());return r?.addEvent(e.done?`completed`:`yielded`),e}catch(e){throw V(r,e,t),e}},async e=>{try{e!==`next`&&await Ke(r,()=>n.return?.())}catch(e){throw V(r,e,t),e}finally{r?.end()}})}function Xe(e,t,n){let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function Ze(e){if(e)return JSON.parse(e)}function Qe(e){return JSON.stringify(e)}function $e(e){return tt(e)?Object.getPrototypeOf(e)?.constructor:null}function et(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function tt(e){return!!e&&(typeof e==`object`||typeof e==`function`)}function nt(e,...t){return typeof e==`function`?e(...t):e}function rt(e){return new Proxy(e,{get(e,t,n){let r=Reflect.get(e,t,n);return t!==`then`||typeof r!=`function`?r:new Proxy(r,{apply(t,n,r){if(r.length!==2||r.some(e=>!at(e)))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,rt(new Proxy(e,{get:(e,t,n)=>{if(i&&t===`then`){i=!1;return}return Reflect.get(e,t,n)}})))}})}})}var it=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;function at(e){return typeof e==`function`&&it.test(e.toString())}function ot(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){let i=r in t?t:nt(e),a=Reflect.get(i,r);return typeof a==`function`?a.bind(i):a},has(n,r){return Reflect.has(t,r)||Reflect.has(nt(e),r)}})}function st(e){try{return decodeURIComponent(e)}catch{return e}}var ct=`@orpc/client`,lt=`1.15.0`,ut=new Set([`bind`,`valueOf`,`toString`,`toJSON`]),dt={BAD_REQUEST:{status:400,message:`Bad Request`},UNAUTHORIZED:{status:401,message:`Unauthorized`},FORBIDDEN:{status:403,message:`Forbidden`},NOT_FOUND:{status:404,message:`Not Found`},METHOD_NOT_SUPPORTED:{status:405,message:`Method Not Supported`},NOT_ACCEPTABLE:{status:406,message:`Not Acceptable`},TIMEOUT:{status:408,message:`Request Timeout`},CONFLICT:{status:409,message:`Conflict`},PRECONDITION_FAILED:{status:412,message:`Precondition Failed`},PAYLOAD_TOO_LARGE:{status:413,message:`Payload Too Large`},UNSUPPORTED_MEDIA_TYPE:{status:415,message:`Unsupported Media Type`},UNPROCESSABLE_CONTENT:{status:422,message:`Unprocessable Content`},TOO_MANY_REQUESTS:{status:429,message:`Too Many Requests`},CLIENT_CLOSED_REQUEST:{status:499,message:`Client Closed Request`},INTERNAL_SERVER_ERROR:{status:500,message:`Internal Server Error`},NOT_IMPLEMENTED:{status:501,message:`Not Implemented`},BAD_GATEWAY:{status:502,message:`Bad Gateway`},SERVICE_UNAVAILABLE:{status:503,message:`Service Unavailable`},GATEWAY_TIMEOUT:{status:504,message:`Gateway Timeout`}};function ft(e,t){return t??dt[e]?.status??500}function pt(e,t){return t||dt[e]?.message||e}var mt,W=class e extends Error{defined;code;status;data;static{let t=Symbol.for(`__${ct}@${lt}/error/ORPC_ERROR_CONSTRUCTORS__`);globalThis[t]??=new WeakSet,mt=globalThis[t],mt.add(e)}constructor(e,...t){let n=Ne(t);if(n.status!==void 0&&!gt(n.status))throw Error(`[ORPCError] Invalid error status code.`);let r=pt(e,n.message);super(r,n),this.code=e,this.status=ft(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(mt.has(this)){let t=$e(e);if(t&&mt.has(t))return!0}return super[Symbol.hasInstance](e)}};function ht(e){return e instanceof W?e:new W(`INTERNAL_SERVER_ERROR`,{message:`Internal server error`,cause:e})}function gt(e){return e<200||e>=400}function _t(e){if(!et(e))return!1;let t=[`defined`,`code`,`status`,`message`,`data`];return!Object.keys(e).some(e=>!t.includes(e))&&`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`status`in e&&typeof e.status==`number`&>(e.status)&&`message`in e&&typeof e.message==`string`}function vt(e,t={}){return new W(e.code,{...t,...e})}var yt=class extends TypeError{},bt=class extends TypeError{},xt=class extends Error{data;constructor(e){super(e?.message??`An error event was received`,e),this.data=e?.data}},St=/\r\n|\r(?!\n)|\n/,Ct=/(?:\r\n|\r(?!\n)|\n){2}/,wt=/(?:\r\n|\r(?!\n)|\n){2}/g,Tt=13,Et=10,Dt=32;function Ot(e){let t={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(let n of e.split(St)){if(n===``)continue;let e=n.indexOf(`:`),r=e===-1?``:n.slice(n.charCodeAt(e+1)===Dt?e+2:e+1);if(e===0){t.comments.push(r);continue}switch(e===-1?n:n.slice(0,e)){case`data`:t.data=t.data===void 0?r:`${t.data}
|
|
35
|
+
`)} (same as ${o+1}.)`)}}getSearchPlacesForDir(e,t){return(e.isGlobalConfig?t:this.config.searchPlaces).map(t=>i.default.join(e.path,t))}getGlobalConfigDir(){return(0,n.default)(this.config.moduleName,{suffix:``}).config}*getGlobalDirs(e){let t=i.default.resolve(this.config.stopDir??r.default.homedir());yield{path:e,isGlobalConfig:!1};let n=e;for(;n!==t;){let e=i.default.dirname(n);if(e===n)break;yield{path:e,isGlobalConfig:!1},n=e}yield{path:this.getGlobalConfigDir(),isGlobalConfig:!0}}};function o(e){return e?`extension "${e}"`:`files without extensions`}e.getExtensionDescription=o})),ke=E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mergeAll=e.hasOwn=void 0,e.hasOwn=Function.prototype.call.bind(Object.prototype.hasOwnProperty);var t=Function.prototype.call.bind(Object.prototype.toString);function n(e){return t(e)===`[object Object]`}function r(t,i,a){for(let o of Object.keys(i)){if(o===`__proto__`||o===`constructor`)continue;let s=i[o];if((0,e.hasOwn)(t,o)){if(Array.isArray(t[o])&&Array.isArray(s)){if(a.mergeArrays){t[o].push(...s);continue}}else if(n(t[o])&&n(s)){t[o]=r(t[o],s,a);continue}}t[o]=s}return t}function i(e,t){return e.reduce((e,n)=>r(e,n,t),{})}e.mergeAll=i})),Ae=E((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Explorer=void 0;var n=t(D(`fs/promises`)),r=t(D(`path`)),i=R(),a=Oe(),o=ke(),s=z();e.Explorer=class extends a.ExplorerBase{async load(e){e=r.default.resolve(e);let t=async()=>await this.config.transform(await this.#e(e));return this.loadCache?await(0,s.emplace)(this.loadCache,e,t):await t()}async search(e=``){if(this.config.metaConfigFilePath){this.loadingMetaConfig=!0;let e=await this.load(this.config.metaConfigFilePath);if(this.loadingMetaConfig=!1,e&&!e.isEmpty)return e}e=r.default.resolve(e);let t=this.#i(e),n=await t.next();if(n.done)throw Error(`Could not find any folders to iterate through (start from ${e})`);let a=n.value,o=async()=>{if(await(0,s.isDirectory)(a.path))for(let e of this.getSearchPlacesForDir(a,i.globalConfigSearchPlaces))try{let t=await this.#e(e);if(t!==null&&!(t.isEmpty&&this.config.ignoreEmptySearchPlaces))return await this.config.transform(t)}catch(e){if(e.code===`ENOENT`||e.code===`EISDIR`||e.code===`ENOTDIR`||e.code===`EACCES`)continue;throw e}let e=await t.next();return e.done?await this.config.transform(null):(a=e.value,this.searchCache?await(0,s.emplace)(this.searchCache,a.path,o):await o())};return this.searchCache?await(0,s.emplace)(this.searchCache,e,o):await o()}async#e(e,t=[]){let r=(0,s.decodeFileContent)(await n.default.readFile(e));return this.toCosmiconfigResult(e,await this.#t(e,r,t))}async#t(e,t,n){let i=await this.#n(e,t);if(!i||!(0,o.hasOwn)(i,`$import`))return i;let a=r.default.dirname(e),{$import:s,...c}=i,l=Array.isArray(s)?s:[s],u=[...n,e];this.validateImports(e,l,u);let d=await Promise.all(l.map(async e=>{let t=r.default.resolve(a,e);return(await this.#e(t,u))?.config}));return(0,o.mergeAll)([...d,c],{mergeArrays:this.config.mergeImportArrays})}async#n(e,t){if(t.trim()===``)return;let n=r.default.extname(e),i=this.config.loaders[n||`noExt`]??this.config.loaders.default;if(!i)throw Error(`No loader specified for ${(0,a.getExtensionDescription)(n)}`);try{let a=await i(e,t);return r.default.basename(e,n)===`package`?(0,s.getPropertyByPath)(a,this.config.packageProp??this.config.moduleName)??null:a}catch(t){throw t.filepath=e,t}}async#r(e){try{return await n.default.stat(e),!0}catch{return!1}}async*#i(e){switch(this.config.searchStrategy){case`none`:yield{path:e,isGlobalConfig:!1};return;case`project`:{let t=e;for(;;){yield{path:t,isGlobalConfig:!1};let e=!1;for(let n of[`json`,`yaml`]){let i=r.default.join(t,`package.${n}`);if(await this.#r(i)){e=!0;break}}if(e)return;let n=r.default.dirname(t);if(n===t)return;t=n}}case`global`:yield*this.getGlobalDirs(e)}}}})),B=E((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.ExplorerSync=void 0;var n=t(D(`fs`)),r=t(D(`path`)),i=R(),a=Oe(),o=ke(),s=z();e.ExplorerSync=class extends a.ExplorerBase{load(e){e=r.default.resolve(e);let t=()=>this.config.transform(this.#e(e));return this.loadCache?(0,s.emplace)(this.loadCache,e,t):t()}search(e=``){if(this.config.metaConfigFilePath){this.loadingMetaConfig=!0;let e=this.load(this.config.metaConfigFilePath);if(this.loadingMetaConfig=!1,e&&!e.isEmpty)return e}e=r.default.resolve(e);let t=this.#i(e),n=t.next();if(n.done)throw Error(`Could not find any folders to iterate through (start from ${e})`);let a=n.value,o=()=>{if((0,s.isDirectorySync)(a.path))for(let e of this.getSearchPlacesForDir(a,i.globalConfigSearchPlacesSync))try{let t=this.#e(e);if(t!==null&&!(t.isEmpty&&this.config.ignoreEmptySearchPlaces))return this.config.transform(t)}catch(e){if(e.code===`ENOENT`||e.code===`EISDIR`||e.code===`ENOTDIR`||e.code===`EACCES`)continue;throw e}let e=t.next();return e.done?this.config.transform(null):(a=e.value,this.searchCache?(0,s.emplace)(this.searchCache,a.path,o):o())};return this.searchCache?(0,s.emplace)(this.searchCache,e,o):o()}#e(e,t=[]){let r=(0,s.decodeFileContent)(n.default.readFileSync(e));return this.toCosmiconfigResult(e,this.#t(e,r,t))}#t(e,t,n){let i=this.#n(e,t);if(!i||!(0,o.hasOwn)(i,`$import`))return i;let a=r.default.dirname(e),{$import:s,...c}=i,l=Array.isArray(s)?s:[s],u=[...n,e];this.validateImports(e,l,u);let d=l.map(e=>{let t=r.default.resolve(a,e);return this.#e(t,u)?.config});return(0,o.mergeAll)([...d,c],{mergeArrays:this.config.mergeImportArrays})}#n(e,t){if(t.trim()===``)return;let n=r.default.extname(e),i=this.config.loaders[n||`noExt`]??this.config.loaders.default;if(!i)throw Error(`No loader specified for ${(0,a.getExtensionDescription)(n)}`);try{let a=i(e,t);return r.default.basename(e,n)===`package`?(0,s.getPropertyByPath)(a,this.config.packageProp??this.config.moduleName)??null:a}catch(t){throw t.filepath=e,t}}#r(e){try{return n.default.statSync(e),!0}catch{return!1}}*#i(e){switch(this.config.searchStrategy){case`none`:yield{path:e,isGlobalConfig:!1};return;case`project`:{let t=e;for(;;){yield{path:t,isGlobalConfig:!1};let e=!1;for(let n of[`json`,`yaml`]){let i=r.default.join(t,`package.${n}`);if(this.#r(i)){e=!0;break}}if(e)return;let n=r.default.dirname(t);if(n===t)return;t=n}}case`global`:yield*this.getGlobalDirs(e)}}loadSync(e){return this.load(e)}searchSync(e=``){return this.search(e)}}})),je=(0,E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLoadersSync=e.defaultLoaders=e.globalConfigSearchPlacesSync=e.globalConfigSearchPlaces=e.getDefaultSearchPlacesSync=e.getDefaultSearchPlaces=e.cosmiconfigSync=e.cosmiconfig=void 0;var t=R();Object.defineProperty(e,"defaultLoaders",{enumerable:!0,get:function(){return t.defaultLoaders}}),Object.defineProperty(e,"defaultLoadersSync",{enumerable:!0,get:function(){return t.defaultLoadersSync}}),Object.defineProperty(e,"getDefaultSearchPlaces",{enumerable:!0,get:function(){return t.getDefaultSearchPlaces}}),Object.defineProperty(e,"getDefaultSearchPlacesSync",{enumerable:!0,get:function(){return t.getDefaultSearchPlacesSync}}),Object.defineProperty(e,"globalConfigSearchPlaces",{enumerable:!0,get:function(){return t.globalConfigSearchPlaces}}),Object.defineProperty(e,"globalConfigSearchPlacesSync",{enumerable:!0,get:function(){return t.globalConfigSearchPlacesSync}});var n=Ae(),r=B(),i=z(),a=function(e){return e};function o(){let e=new r.ExplorerSync({moduleName:`cosmiconfig`,stopDir:process.cwd(),searchPlaces:t.metaSearchPlaces,ignoreEmptySearchPlaces:!1,applyPackagePropertyPathToConfiguration:!0,loaders:t.defaultLoaders,transform:a,cache:!0,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:`none`}).search();if(!e)return null;if(e.config?.loaders)throw Error(`Can not specify loaders in meta config file`);if(e.config?.searchStrategy)throw Error(`Can not specify searchStrategy in meta config file`);let n={mergeSearchPlaces:!0,...e.config??{}};return{config:(0,i.removeUndefinedValuesFromObject)(n),filepath:e.filepath}}function s(e,t,n){let r=n.searchPlaces?.map(t=>t.replace(`{name}`,e));return n.mergeSearchPlaces?[...r??[],...t]:r??t}function c(e,t,n){let r=o();if(!r)return{...t,...(0,i.removeUndefinedValuesFromObject)(n),loaders:{...t.loaders,...n.loaders}};let a=r.config,c=n.searchPlaces??t.searchPlaces;return{...t,...(0,i.removeUndefinedValuesFromObject)(n),metaConfigFilePath:r.filepath,...a,searchPlaces:s(e,c,a),loaders:{...t.loaders,...n.loaders}}}function l(e){if(e.searchStrategy!=null&&e.searchStrategy!==`global`&&e.stopDir)throw Error('Can not supply `stopDir` option with `searchStrategy` other than "global"')}function u(e,n){return l(n),c(e,{moduleName:e,searchPlaces:(0,t.getDefaultSearchPlaces)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:a,loaders:t.defaultLoaders,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:n.stopDir?`global`:`none`},n)}function d(e,n){return l(n),c(e,{moduleName:e,searchPlaces:(0,t.getDefaultSearchPlacesSync)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:a,loaders:t.defaultLoadersSync,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:n.stopDir?`global`:`none`},n)}function f(e,t={}){let r=u(e,t),i=new n.Explorer(r);return{search:i.search.bind(i),load:i.load.bind(i),clearLoadCache:i.clearLoadCache.bind(i),clearSearchCache:i.clearSearchCache.bind(i),clearCaches:i.clearCaches.bind(i)}}e.cosmiconfig=f;function p(e,t={}){let n=d(e,t),i=new r.ExplorerSync(n);return{search:i.search.bind(i),load:i.load.bind(i),clearLoadCache:i.clearLoadCache.bind(i),clearSearchCache:i.clearSearchCache.bind(i),clearCaches:i.clearCaches.bind(i)}}e.cosmiconfigSync=p}))().cosmiconfig)(`tailorkit`,{searchPlaces:[`tailorkit.config.ts`,`tailorkit.config.mjs`,`tailorkit.config.js`]}),V=async(e,t=process.cwd())=>{let n=ee.resolve(t),r=e===void 0?await je.search(n):await je.load(ee.resolve(n,e));if(r===null)throw Error(`Could not find tailorkit config from ${n}.`);return{config:le.parse(r.config),filepath:r.filepath,root:ee.dirname(r.filepath)}};function Me(e){return e[0]??{}}function Ne(e){return Array.isArray(e)?e:e==null?[]:[e]}var Pe=`orpc`,Fe=`@orpc/shared`,Ie=`1.15.0`,Le=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function Re(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function ze(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var Be=2,Ve=`__${Fe}@${Ie}/otel/config__`;function He(){return globalThis[Ve]}function Ue(e,t={},n){return(He()?.tracer)?.startSpan(e,t,n)}function We(e,t,n={}){if(!e)return;let r=Ge(t);e.recordException(r),(!n.signal?.aborted||n.signal.reason!==t)&&e.setStatus({code:Be,message:r.message})}function Ge(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function H({name:e,context:t,...n},r){let i=He()?.tracer;if(!i)return r();let a=async e=>{try{return await r(e)}catch(t){throw We(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,a):i.startActiveSpan(e,n,a)}async function Ke(e,t){let n=He();if(!e||!n)return t();let r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function U(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var qe=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Je=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=ze(async()=>{if(this.#e)return{done:!0,value:void 0};try{let t=await e();return t.done&&(this.#e=!0),t}catch(e){throw this.#e=!0,e}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n(`next`))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n(`return`)),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n(`throw`)),e}async[qe](){this.#e=!0,this.#t||(this.#t=!0,await this.#n(`dispose`))}[Symbol.asyncIterator](){return this}};function Ye({name:e,...t},n){let r;return new Je(async()=>{r??=Ue(e);try{let e=await Ke(r,()=>n.next());return r?.addEvent(e.done?`completed`:`yielded`),e}catch(e){throw We(r,e,t),e}},async e=>{try{e!==`next`&&await Ke(r,()=>n.return?.())}catch(e){throw We(r,e,t),e}finally{r?.end()}})}function Xe(e,t,n){let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function Ze(e){if(e)return JSON.parse(e)}function Qe(e){return JSON.stringify(e)}function $e(e){return tt(e)?Object.getPrototypeOf(e)?.constructor:null}function et(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function tt(e){return!!e&&(typeof e==`object`||typeof e==`function`)}function nt(e,...t){return typeof e==`function`?e(...t):e}function rt(e){return new Proxy(e,{get(e,t,n){let r=Reflect.get(e,t,n);return t!==`then`||typeof r!=`function`?r:new Proxy(r,{apply(t,n,r){if(r.length!==2||r.some(e=>!at(e)))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,rt(new Proxy(e,{get:(e,t,n)=>{if(i&&t===`then`){i=!1;return}return Reflect.get(e,t,n)}})))}})}})}var it=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;function at(e){return typeof e==`function`&&it.test(e.toString())}function ot(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){let i=r in t?t:nt(e),a=Reflect.get(i,r);return typeof a==`function`?a.bind(i):a},has(n,r){return Reflect.has(t,r)||Reflect.has(nt(e),r)}})}function st(e){try{return decodeURIComponent(e)}catch{return e}}var ct=`@orpc/client`,lt=`1.15.0`,ut=new Set([`bind`,`valueOf`,`toString`,`toJSON`]),dt={BAD_REQUEST:{status:400,message:`Bad Request`},UNAUTHORIZED:{status:401,message:`Unauthorized`},FORBIDDEN:{status:403,message:`Forbidden`},NOT_FOUND:{status:404,message:`Not Found`},METHOD_NOT_SUPPORTED:{status:405,message:`Method Not Supported`},NOT_ACCEPTABLE:{status:406,message:`Not Acceptable`},TIMEOUT:{status:408,message:`Request Timeout`},CONFLICT:{status:409,message:`Conflict`},PRECONDITION_FAILED:{status:412,message:`Precondition Failed`},PAYLOAD_TOO_LARGE:{status:413,message:`Payload Too Large`},UNSUPPORTED_MEDIA_TYPE:{status:415,message:`Unsupported Media Type`},UNPROCESSABLE_CONTENT:{status:422,message:`Unprocessable Content`},TOO_MANY_REQUESTS:{status:429,message:`Too Many Requests`},CLIENT_CLOSED_REQUEST:{status:499,message:`Client Closed Request`},INTERNAL_SERVER_ERROR:{status:500,message:`Internal Server Error`},NOT_IMPLEMENTED:{status:501,message:`Not Implemented`},BAD_GATEWAY:{status:502,message:`Bad Gateway`},SERVICE_UNAVAILABLE:{status:503,message:`Service Unavailable`},GATEWAY_TIMEOUT:{status:504,message:`Gateway Timeout`}};function ft(e,t){return t??dt[e]?.status??500}function pt(e,t){return t||dt[e]?.message||e}var mt,W=class e extends Error{defined;code;status;data;static{let t=Symbol.for(`__${ct}@${lt}/error/ORPC_ERROR_CONSTRUCTORS__`);globalThis[t]??=new WeakSet,mt=globalThis[t],mt.add(e)}constructor(e,...t){let n=Me(t);if(n.status!==void 0&&!gt(n.status))throw Error(`[ORPCError] Invalid error status code.`);let r=pt(e,n.message);super(r,n),this.code=e,this.status=ft(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(mt.has(this)){let t=$e(e);if(t&&mt.has(t))return!0}return super[Symbol.hasInstance](e)}};function ht(e){return e instanceof W?e:new W(`INTERNAL_SERVER_ERROR`,{message:`Internal server error`,cause:e})}function gt(e){return e<200||e>=400}function _t(e){if(!et(e))return!1;let t=[`defined`,`code`,`status`,`message`,`data`];return!Object.keys(e).some(e=>!t.includes(e))&&`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`status`in e&&typeof e.status==`number`&>(e.status)&&`message`in e&&typeof e.message==`string`}function vt(e,t={}){return new W(e.code,{...t,...e})}var yt=class extends TypeError{},bt=class extends TypeError{},xt=class extends Error{data;constructor(e){super(e?.message??`An error event was received`,e),this.data=e?.data}},St=/\r\n|\r(?!\n)|\n/,Ct=/(?:\r\n|\r(?!\n)|\n){2}/,wt=/(?:\r\n|\r(?!\n)|\n){2}/g,Tt=13,Et=10,Dt=32;function Ot(e){let t={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(let n of e.split(St)){if(n===``)continue;let e=n.indexOf(`:`),r=e===-1?``:n.slice(n.charCodeAt(e+1)===Dt?e+2:e+1);if(e===0){t.comments.push(r);continue}switch(e===-1?n:n.slice(0,e)){case`data`:t.data=t.data===void 0?r:`${t.data}
|
|
36
36
|
${r}`;break;case`event`:t.event=r;break;case`id`:t.id=r;break;case`retry`:{let e=Number.parseInt(r,10);e>=0&&e.toString()===r&&(t.retry=e);break}}}return t}var kt=class{constructor(e={}){this.options=e}pending=[];tail=``;discardLeadingLF=!1;feed(e){if(e===``||this.discardLeadingLF&&(this.discardLeadingLF=!1,e.charCodeAt(0)===Et&&(e=e.slice(1),e===``)))return;let t=this.tail+e;if(!Ct.test(t)){this.pending.push(e),this.tail=t.slice(-3);return}this.pending.push(e);let n=this.pending.length===1?e:this.pending.join(``),r=n.length-t.length,i=[],a=0;for(let e of t.matchAll(wt))i.push(n.slice(a,r+e.index)),a=r+e.index+e[0].length;let o=n.slice(a);this.pending.length=0,this.tail=o.slice(-3),o===``?this.discardLeadingLF=e.charCodeAt(e.length-1)===Tt:this.pending.push(o);for(let e of i){let t=Ot(e);this.options.onEvent&&this.options.onEvent(t)}}end(){if(this.pending.length!==0)throw new bt(`Event Iterator ended before complete`)}},At=class extends TransformStream{constructor(){let e;super({start(t){e=new kt({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}},jt=/\r\n|[\n\r]/,Mt=/\r\n|[\n\r]/g;function Nt(e){return jt.test(e)}function Pt(e){if(Nt(e))throw new yt(`Event's id must not contain a carriage return or newline character`)}function Ft(e){if(Nt(e))throw new yt(`Event's event must not contain a carriage return or newline character`)}function It(e){if(!Number.isInteger(e)||e<0)throw new yt(`Event's retry must be a integer and >= 0`)}function Lt(e){if(Nt(e))throw new yt(`Event's comment must not contain a carriage return or newline character`)}function Rt(e){return e===void 0?``:`data: ${e.replace(Mt,`
|
|
37
37
|
data: `)}
|
|
38
38
|
`}function zt(e){let t=``;for(let n of e??[])Lt(n),t+=`: ${n}
|
|
@@ -40,14 +40,14 @@ data: `)}
|
|
|
40
40
|
`),e.retry!==void 0&&(It(e.retry),t+=`retry: ${e.retry}
|
|
41
41
|
`),e.id!==void 0&&(Pt(e.id),t+=`id: ${e.id}
|
|
42
42
|
`),t+=Rt(e.data),t+=`
|
|
43
|
-
`,t}var Vt=Symbol(`ORPC_EVENT_SOURCE_META`);function Ht(e,t){if(t.id===void 0&&t.retry===void 0&&!t.comments?.length)return e;if(t.id!==void 0&&Pt(t.id),t.retry!==void 0&&It(t.retry),t.comments!==void 0)for(let e of t.comments)Lt(e);return new Proxy(e,{get(e,n,r){return n===Vt?t:Reflect.get(e,n,r)}})}function Ut(e){return tt(e)?Reflect.get(e,Vt):void 0}var Wt=class extends Je{hibernationCallback;constructor(e){super(async()=>{throw Error(`Cannot iterate over hibernating iterator directly`)},async e=>{if(e!==`next`)throw Error(`Cannot cleanup hibernating iterator directly`)}),this.hibernationCallback=e}};function Gt(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/"/g,`\\"`)}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function Kt(e){let t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&typeof t[2]==`string`)return st(t[2]);let n=e.match(/filename="((?:\\"|[^"])*)"/i);if(n&&typeof n[1]==`string`)return n[1].replace(/\\"/g,`"`)}function qt(e,t){let n={...e};for(let e in t)Array.isArray(t[e])?n[e]=[...Pe(n[e]),...t[e]]:t[e]!==void 0&&(n[e]=Array.isArray(n[e])?[...n[e],t[e]]:n[e]===void 0?t[e]:[n[e],t[e]]);return n}function Jt(e,t){let n=async e=>{let n=await t.error(e);if(n!==e){let t=Ut(e);t&&tt(n)&&(n=Ht(n,t))}return n};return new Je(async()=>{let{done:r,value:i}=await(async()=>{try{return await e.next()}catch(e){throw await n(e)}})(),a=await t.value(i,r);if(a!==i){let e=Ut(i);e&&tt(a)&&(a=Ht(a,e))}return{done:r,value:a}},async()=>{try{await e.return?.()}catch(e){throw await n(e)}})}function Yt(e){return{...e,context:e.context??{}}}function Xt(e,t={}){let n=t.path??[];return rt(new Proxy(async(...[t,r={}])=>await e.call(n,t,Yt(r)),{get(r,i){return typeof i!=`string`||ut.has(i)?Reflect.get(r,i):Xt(e,{...t,path:[...n,i]})}}))}function Zt(e,t={}){let n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new At))?.getReader(),r,i=!1;return new Je(async()=>{r??=We(`consume_event_iterator_stream`);try{for(;;){if(n===void 0)return{done:!0,value:void 0};let{done:e,value:t}=await Ke(r,()=>n.read());if(e){if(i)throw new Re(`Stream was cancelled`);return{done:!0,value:void 0}}switch(t.event){case`message`:{let e=Ze(t.data);return tt(e)&&(e=Ht(e,t)),r?.addEvent(`message`),{done:!1,value:e}}case`error`:{let e=new xt({data:Ze(t.data)});throw e=Ht(e,t),r?.addEvent(`error`),e}case`done`:{let e=Ze(t.data);return tt(e)&&(e=Ht(e,t)),r?.addEvent(`done`),{done:!0,value:e}}default:r?.addEvent(`maybe_keepalive`)}}}catch(e){throw e instanceof xt||V(r,e,t),e}},async e=>{try{e!==`next`&&(i=!0,r?.addEvent(`cancelled`)),await Ke(r,()=>n?.cancel())}catch(e){throw V(r,e,t),e}finally{r?.end()}})}function Qt(e,t={}){let n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,i=t.eventIteratorKeepAliveComment??``,a=t.eventIteratorInitialCommentEnabled??!0,o=t.eventIteratorInitialComment??``,s=!1,c,l;return new ReadableStream({start(e){l=We(`stream_event_iterator`),a&&e.enqueue(Bt({comments:[o]}))},async pull(t){try{n&&(c=setInterval(()=>{t.enqueue(Bt({comments:[i]})),l?.addEvent(`keepalive`)},r));let a=await Ke(l,()=>e.next());if(clearInterval(c),s)return;let o=Ut(a.value);if(!a.done||a.value!==void 0||o!==void 0){let e=a.done?`done`:`message`;t.enqueue(Bt({...o,event:e,data:Qe(a.value)})),l?.addEvent(e)}a.done&&(t.close(),l?.end())}catch(e){if(clearInterval(c),s)return;e instanceof xt?(t.enqueue(Bt({...Ut(e),event:`error`,data:Qe(e.data)})),l?.addEvent(`error`),t.close()):(V(l,e),t.error(e)),l?.end()}},async cancel(){try{s=!0,clearInterval(c),l?.addEvent(`cancelled`),await Ke(l,()=>e.return?.())}catch(e){throw V(l,e),e}finally{l?.end()}}}).pipeThrough(new TextEncoderStream)}function $t(e,t={}){return H({name:`parse_standard_body`,signal:t.signal},async()=>{let n=e.headers.get(`content-disposition`);if(typeof n==`string`){let t=Kt(n)??`blob`,r=await e.blob();return new File([r],t,{type:r.type})}let r=e.headers.get(`content-type`);if(!r||r.startsWith(`application/json`))return Ze(await e.text());if(r.startsWith(`multipart/form-data`))return await e.formData();if(r.startsWith(`application/x-www-form-urlencoded`)){let t=await e.text();return new URLSearchParams(t)}if(r.startsWith(`text/event-stream`))return Zt(e.body,t);if(r.startsWith(`text/plain`))return await e.text();let i=await e.blob();return new File([i],`blob`,{type:i.type})})}function en(e,t,n={}){if(e instanceof ReadableStream)return e;let r=t.get(`content-disposition`);if(t.delete(`content-type`),t.delete(`content-disposition`),e!==void 0)return e instanceof Blob?(t.set(`content-type`,e.type),t.set(`content-length`,e.size.toString()),t.set(`content-disposition`,r??Gt(e instanceof File?e.name:`blob`)),e):e instanceof FormData||e instanceof URLSearchParams?e:U(e)?(t.set(`content-type`,`text/event-stream`),Qt(e,n)):(t.set(`content-type`,`application/json`),Qe(e))}function tn(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]=t[n]===void 0?e:[t[n],e]}),t}function nn(e,t=new Headers){for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.append(n,r);return t}function rn(e,t={}){let n=nn(e.headers),r=en(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}function an(e,t={}){return{body:ze(()=>$t(e,t)),status:e.status,get headers(){let t=tn(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}var on=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(let t of this.plugins)t.init?.(e)}},sn=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new on(n.plugins).init(n),this.interceptors=Pe(n.interceptors),this.clientInterceptors=Pe(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return H({name:`${Fe}.${e.join(`/`)}`,signal:n.signal},r=>(r?.setAttribute(`rpc.system`,Fe),r?.setAttribute(`rpc.method`,e.join(`.`)),U(t)&&(t=Ye({name:`consume_event_iterator_input`,signal:n.signal},t)),Xe(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=Ue(),a,o=i?.trace.getActiveSpan()??r;o&&i&&(a=i?.trace.setSpan(i.context.active(),o));let s=await H({name:`encode_request`,context:a},()=>this.codec.encode(e,t,n)),c=await Xe(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>H({name:`send_request`,signal:r.signal,context:a},()=>this.sender.call(n,r,t,e))),l=await H({name:`decode_response`,context:a},()=>this.codec.decode(c,n,e,t));return U(l)?Ye({name:`consume_event_iterator_output`,signal:n.signal},l):l})))}},G={BIGINT:0,DATE:1,NAN:2,UNDEFINED:3,URL:4,REGEXP:5,SET:6,MAP:7},cn=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw Error(`Custom serializer type must be unique.`)}serialize(e,t=[],n=[],r=[],i=[]){for(let a of this.customSerializers)if(a.condition(e)){let o=this.serialize(a.serialize(e),t,n,r,i);return n.push([a.type,...t]),o}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if(typeof e==`bigint`)return n.push([G.BIGINT,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([G.DATE,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([G.NAN,...t]),[null,n,r,i];if(e instanceof URL)return n.push([G.URL,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([G.REGEXP,...t]),[e.toString(),n,r,i];if(e instanceof Set){let a=this.serialize(Array.from(e),t,n,r,i);return n.push([G.SET,...t]),a}if(e instanceof Map){let a=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([G.MAP,...t]),a}if(Array.isArray(e))return[e.map((e,a)=>e===void 0?(n.push([G.UNDEFINED,...t,a]),null):this.serialize(e,[...t,a],n,r,i)[0]),n,r,i];if(et(e)){let a={};for(let o in e)(o!==`toJSON`||typeof e[o]!=`function`)&&(a[o]=this.serialize(e[o],[...t,o],n,r,i)[0]);return[a,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){let i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,a=`data`;e.forEach(e=>{if(n=n[a],a=e,!Object.hasOwn(n,a))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${a}`)}),n[a]=r(t)});for(let e of t){let t=e[0],n=i,r=`data`;for(let t=1;t<e.length;t++)if(n=n[r],r=e[t],!Object.hasOwn(n,r))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${r}`);for(let e of this.customSerializers)if(e.type===t){n[r]=e.deserialize(n[r]);break}switch(t){case G.BIGINT:n[r]=BigInt(n[r]);break;case G.DATE:n[r]=new Date(n[r]??`Invalid Date`);break;case G.NAN:n[r]=NaN;break;case G.UNDEFINED:n[r]=void 0;break;case G.URL:n[r]=new URL(n[r]);break;case G.REGEXP:{let[,e,t]=n[r].match(/^\/(.*)\/([a-z]*)$/);n[r]=new RegExp(e,t);break}case G.SET:n[r]=new Set(n[r]);break;case G.MAP:n[r]=new Map(n[r])}}return i.data}};function ln(e){return`/${e.map(encodeURIComponent).join(`/`)}`}function un(e){return typeof e.forEach==`function`?tn(e):e}function dn(e){return Object.entries(dt).find(([,t])=>t.status===e)?.[0]??`MALFORMED_ORPC_ERROR_RESPONSE`}var fn=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??`POST`,this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=un(await nt(this.headers,n,e,t));n.lastEventId!==void 0&&(r=qt(r,{"last-event-id":n.lastEventId}));let i=await nt(this.expectedMethod,n,e,t),a=await nt(this.baseUrl,n,e,t),o=new URL(a);o.pathname=`${o.pathname.replace(/\/$/,``)}${ln(e)}`;let s=this.serializer.serialize(t);if(i===`GET`&&!(s instanceof FormData)&&!U(s)){let a=await nt(this.maxUrlLength,n,e,t),c=new URL(o);if(c.searchParams.append(`data`,Qe(s)),c.toString().length<=a)return{body:void 0,method:i,headers:r,url:c,signal:n.signal}}return{url:o,method:i===`GET`?this.fallbackMethod:i,headers:r,body:s,signal:n.signal}}async decode(e){let t=!gt(e.status),n=await(async()=>{let t=!1;try{let n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(e){throw Error(t?`Invalid RPC response format.`:`Cannot parse response body, please check the response body and content-type.`,{cause:e})}})();if(!t)throw _t(n)?vt(n):new W(dn(e.status),{status:e.status,data:{...e,body:n}});return n}},pn=class{constructor(e){this.jsonSerializer=e}serialize(e){return U(e)?Jt(e,{value:async e=>this.#e(e,!1),error:async e=>new xt({data:this.#e(ht(e).toJSON(),!1),cause:e})}):this.#e(e,!0)}#e(e,t){let[n,r,i,a]=this.jsonSerializer.serialize(e),o=r.length===0?void 0:r;if(!t||a.length===0)return{json:n,meta:o};let s=new FormData;return s.set(`data`,Qe({json:n,meta:o,maps:i})),a.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return U(e)?Jt(e,{value:async e=>this.#t(e),error:async e=>{if(!(e instanceof xt))return e;let t=this.#t(e.data);return _t(t)?vt(t,{cause:e}):new xt({data:t,cause:e})}}):this.#t(e)}#t(e){if(e===void 0)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);let t=JSON.parse(e.get(`data`));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},mn=class extends sn{constructor(e,t){let n=new fn(new pn(new cn(t)),t);super(n,e,t)}},hn=class extends on{initRuntimeAdapter(e){for(let t of this.plugins)t.initRuntimeAdapter?.(e)}},gn=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new hn(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=Pe(e.adapterInterceptors)}async call(e,t,n,r){let i=rn(e,this.toFetchRequestOptions);return an(await Xe(this.adapterInterceptors,{...t,request:i,path:n,input:r,init:{redirect:`manual`}},({request:e,path:t,input:n,init:r,...i})=>this.fetch(e,r,i,t,n)),{signal:i.signal})}},_n=class extends mn{constructor(e){let t=new gn(e);super(t,e)}},vn=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function yn(e,t){return{...e,...t}}async function bn(e,t){let{code:n,status:r,message:i,data:a,cause:o,defined:s}=t,c=e?.[t.code];if(!c||ft(t.code,c.status)!==t.status)return s?new W(n,{defined:!1,status:r,message:i,data:a,cause:o}):t;if(!c.data)return s?t:new W(n,{defined:!0,status:r,message:i,data:a,cause:o});let l=await c.data[`~standard`].validate(t.data);return l.issues?s?new W(n,{defined:!1,status:r,message:i,data:a,cause:o}):t:new W(n,{defined:!0,status:r,message:i,data:l.value,cause:o})}var xn=class{"~orpc";constructor(e){if(e.route?.successStatus&>(e.route.successStatus))throw Error(`[ContractProcedure] Invalid successStatus.`);if(Object.values(e.errorMap).some(e=>e&&e.status&&!gt(e.status)))throw Error(`[ContractProcedure] Invalid error status code.`);this[`~orpc`]=e}};function Sn(e){return e instanceof xn||(typeof e==`object`||typeof e==`function`)&&e!==null&&`~orpc`in e&&typeof e[`~orpc`]==`object`&&e[`~orpc`]!==null&&`errorMap`in e[`~orpc`]&&`route`in e[`~orpc`]&&`meta`in e[`~orpc`]}function Cn(e,t){return{...e,...t}}function wn(e,t){return{...e,...t}}function Tn(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}function En(e,t){return{...e,tags:[...t,...e.tags??[]]}}function Dn(e,t){return e?`${e}${t}`:t}function On(e,t){return e?[...e,...t]:t}function kn(e,t){let n=e;return t.prefix&&(n=Tn(n,t.prefix)),t.tags?.length&&(n=En(n,t.tags)),n}function An(e,t){if(Sn(e))return new xn({...e[`~orpc`],errorMap:yn(t.errorMap,e[`~orpc`].errorMap),route:kn(e[`~orpc`].route,t)});if(typeof e!=`object`||!e)return e;let n={};for(let r in e)n[r]=An(e[r],t);return n}new class e extends xn{constructor(e){super(e),this[`~orpc`].prefix=e.prefix,this[`~orpc`].tags=e.tags}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t})}output(t){return new e({...this[`~orpc`],outputSchema:t})}prefix(t){return new e({...this[`~orpc`],prefix:Dn(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:On(this[`~orpc`].tags,t)})}router(e){return An(e,this[`~orpc`])}}({errorMap:{},route:{},meta:{}});var jn=Symbol(`ORPC_LAZY_SYMBOL`);function Mn(e,t={}){return{[jn]:{loader:e,meta:t}}}function Nn(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&jn in e}function Pn(e){return e[jn].meta}function Fn(e){return Nn(e)?e[jn].loader():Promise.resolve({default:e})}function In(e,t){if(t.length>e.length)return!1;for(let n=0;n<e.length;n++){if(t[n]===void 0)return!0;if(e[n]!==t[n])return!1}return!0}function Ln(e,t,n){return n.dedupeLeading&&In(t,e)?t:[...e,...t]}function Rn(e,t){return[...e,t]}var zn=class{"~orpc";constructor(e){this[`~orpc`]=e}};function Bn(e){return e instanceof zn||Sn(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function Vn(e,t){return{...e,...t}}function Hn(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=Ne(t),i=e[n];return new W(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function Un(e){return{output:e,context:{}}}function Wn(e,...t){let n=Ne(t);return async(...[t,r])=>{let i=Pe(n.path),{default:a}=await Fn(e),o=r?.context??{},s=await nt(n.context??{},o),c=Hn(a[`~orpc`].errorMap),l=async e=>e instanceof W?await bn(a[`~orpc`].errorMap,e):e;try{let e=await H({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),Xe(Pe(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>qn(e.procedure,e))));return U(e)?e instanceof Wt?e:ot(e,Jt(Ye({name:`consume_event_iterator_output`,signal:r?.signal},e),{value:e=>e,error:e=>l(e)})):e}catch(e){throw await l(e)}}}async function Gn(e,t){let n=e[`~orpc`].inputSchema;return n?H({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new W(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new vn({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function Kn(e,t){let n=e[`~orpc`].outputSchema;return n?H({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new W(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new vn({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function qn(e,t){let n=e[`~orpc`].middlewares,r=Math.min(Math.max(0,e[`~orpc`].inputValidationIndex),n.length),i=Math.min(Math.max(0,e[`~orpc`].outputValidationIndex),n.length),a=async(o,s,c)=>{let l=c;o===r&&(l=await Gn(e,l));let u=n[o],d=u?await H({name:`middleware.${u.name}`,signal:t.signal},async e=>(e?.setAttribute(`middleware.index`,o),e?.setAttribute(`middleware.name`,u.name),(await u({...t,context:s,next:async(...[e])=>{let t=e?.context??{};return{output:await a(o+1,Vn(s,t),l),context:t}}},l,Un)).output)):await H({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await Kn(e,d):d};return a(0,t.context,t.input)}function Jn(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||Bn(n)||!tt(n))return;if(!Nn(n)){n=n[r];continue}let i=n,a=t.slice(e);return Mn(async()=>Fn(Jn((await Fn(i)).default,a)),Pn(i))}return n}function Yn(e){return new Proxy(e,{get(t,n){return typeof n==`string`?Yn(Jn(e,[n])):Reflect.get(t,n)}})}function Xn(e,t){if(Nn(e)){let n=Pn(e),r=n?.prefix?Dn(t.prefix,n?.prefix):t.prefix;return Yn(Mn(async()=>{let{default:n}=await Fn(e);return Fn(Xn(n,t))},{...n,prefix:r}))}if(Bn(e)){let n=Ln(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new zn({...e[`~orpc`],route:kn(e[`~orpc`].route,t),errorMap:yn(t.errorMap,e[`~orpc`].errorMap),middlewares:n,inputValidationIndex:e[`~orpc`].inputValidationIndex+r,outputValidationIndex:e[`~orpc`].outputValidationIndex+r})}if(typeof e!=`object`||!e)return e;let n={};for(let r in e)n[r]=Xn(e[r],t);return n}var Zn=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Qn=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},$n=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},er=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Qn(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Zn(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):tr({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},tr=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},nr=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=$n(r),s=Object.entries(i).map(([t,i])=>tr({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},rr=/\{[^{}]+\}/g,ir=({path:e,url:t})=>{let n=t,r=t.match(rr);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,er({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,nr({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${tr({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},ar=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=ir({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function or(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}var sr=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},cr={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},lr=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=er({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=nr({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=tr({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},ur=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},dr=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1;async function fr(e){for(let t of e.security??[]){if(dr(e,t.name))continue;let n=await sr(t,e.auth);if(!n)continue;let r=t.name??`Authorization`;switch(t.in){case`query`:e.query||={},e.query[r]=n;break;case`cookie`:e.headers.append(`Cookie`,`${r}=${n}`);break;default:e.headers.set(r,n)}}}var pr=e=>ar({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:lr(e.querySerializer),url:e.url}),mr=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=gr(e.headers,t.headers),n},hr=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},gr=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?hr(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},_r=class{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}},vr=()=>({error:new _r,request:new _r,response:new _r}),yr=lr({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),br={"Content-Type":`application/json`},xr=(e={})=>({...cr,headers:br,parseAs:`auto`,querySerializer:yr,...e});function Sr({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u}){let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,h=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,h);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t,p=p.replace(/\r\n?/g,`
|
|
43
|
+
`,t}var Vt=Symbol(`ORPC_EVENT_SOURCE_META`);function Ht(e,t){if(t.id===void 0&&t.retry===void 0&&!t.comments?.length)return e;if(t.id!==void 0&&Pt(t.id),t.retry!==void 0&&It(t.retry),t.comments!==void 0)for(let e of t.comments)Lt(e);return new Proxy(e,{get(e,n,r){return n===Vt?t:Reflect.get(e,n,r)}})}function Ut(e){return tt(e)?Reflect.get(e,Vt):void 0}var Wt=class extends Je{hibernationCallback;constructor(e){super(async()=>{throw Error(`Cannot iterate over hibernating iterator directly`)},async e=>{if(e!==`next`)throw Error(`Cannot cleanup hibernating iterator directly`)}),this.hibernationCallback=e}};function Gt(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/"/g,`\\"`)}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function Kt(e){let t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&typeof t[2]==`string`)return st(t[2]);let n=e.match(/filename="((?:\\"|[^"])*)"/i);if(n&&typeof n[1]==`string`)return n[1].replace(/\\"/g,`"`)}function qt(e,t){let n={...e};for(let e in t)Array.isArray(t[e])?n[e]=[...Ne(n[e]),...t[e]]:t[e]!==void 0&&(n[e]=Array.isArray(n[e])?[...n[e],t[e]]:n[e]===void 0?t[e]:[n[e],t[e]]);return n}function Jt(e,t){let n=async e=>{let n=await t.error(e);if(n!==e){let t=Ut(e);t&&tt(n)&&(n=Ht(n,t))}return n};return new Je(async()=>{let{done:r,value:i}=await(async()=>{try{return await e.next()}catch(e){throw await n(e)}})(),a=await t.value(i,r);if(a!==i){let e=Ut(i);e&&tt(a)&&(a=Ht(a,e))}return{done:r,value:a}},async()=>{try{await e.return?.()}catch(e){throw await n(e)}})}function Yt(e){return{...e,context:e.context??{}}}function Xt(e,t={}){let n=t.path??[];return rt(new Proxy(async(...[t,r={}])=>await e.call(n,t,Yt(r)),{get(r,i){return typeof i!=`string`||ut.has(i)?Reflect.get(r,i):Xt(e,{...t,path:[...n,i]})}}))}function Zt(e,t={}){let n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new At))?.getReader(),r,i=!1;return new Je(async()=>{r??=Ue(`consume_event_iterator_stream`);try{for(;;){if(n===void 0)return{done:!0,value:void 0};let{done:e,value:t}=await Ke(r,()=>n.read());if(e){if(i)throw new Le(`Stream was cancelled`);return{done:!0,value:void 0}}switch(t.event){case`message`:{let e=Ze(t.data);return tt(e)&&(e=Ht(e,t)),r?.addEvent(`message`),{done:!1,value:e}}case`error`:{let e=new xt({data:Ze(t.data)});throw e=Ht(e,t),r?.addEvent(`error`),e}case`done`:{let e=Ze(t.data);return tt(e)&&(e=Ht(e,t)),r?.addEvent(`done`),{done:!0,value:e}}default:r?.addEvent(`maybe_keepalive`)}}}catch(e){throw e instanceof xt||We(r,e,t),e}},async e=>{try{e!==`next`&&(i=!0,r?.addEvent(`cancelled`)),await Ke(r,()=>n?.cancel())}catch(e){throw We(r,e,t),e}finally{r?.end()}})}function Qt(e,t={}){let n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,i=t.eventIteratorKeepAliveComment??``,a=t.eventIteratorInitialCommentEnabled??!0,o=t.eventIteratorInitialComment??``,s=!1,c,l;return new ReadableStream({start(e){l=Ue(`stream_event_iterator`),a&&e.enqueue(Bt({comments:[o]}))},async pull(t){try{n&&(c=setInterval(()=>{t.enqueue(Bt({comments:[i]})),l?.addEvent(`keepalive`)},r));let a=await Ke(l,()=>e.next());if(clearInterval(c),s)return;let o=Ut(a.value);if(!a.done||a.value!==void 0||o!==void 0){let e=a.done?`done`:`message`;t.enqueue(Bt({...o,event:e,data:Qe(a.value)})),l?.addEvent(e)}a.done&&(t.close(),l?.end())}catch(e){if(clearInterval(c),s)return;e instanceof xt?(t.enqueue(Bt({...Ut(e),event:`error`,data:Qe(e.data)})),l?.addEvent(`error`),t.close()):(We(l,e),t.error(e)),l?.end()}},async cancel(){try{s=!0,clearInterval(c),l?.addEvent(`cancelled`),await Ke(l,()=>e.return?.())}catch(e){throw We(l,e),e}finally{l?.end()}}}).pipeThrough(new TextEncoderStream)}function $t(e,t={}){return H({name:`parse_standard_body`,signal:t.signal},async()=>{let n=e.headers.get(`content-disposition`);if(typeof n==`string`){let t=Kt(n)??`blob`,r=await e.blob();return new File([r],t,{type:r.type})}let r=e.headers.get(`content-type`);if(!r||r.startsWith(`application/json`))return Ze(await e.text());if(r.startsWith(`multipart/form-data`))return await e.formData();if(r.startsWith(`application/x-www-form-urlencoded`)){let t=await e.text();return new URLSearchParams(t)}if(r.startsWith(`text/event-stream`))return Zt(e.body,t);if(r.startsWith(`text/plain`))return await e.text();let i=await e.blob();return new File([i],`blob`,{type:i.type})})}function en(e,t,n={}){if(e instanceof ReadableStream)return e;let r=t.get(`content-disposition`);if(t.delete(`content-type`),t.delete(`content-disposition`),e!==void 0)return e instanceof Blob?(t.set(`content-type`,e.type),t.set(`content-length`,e.size.toString()),t.set(`content-disposition`,r??Gt(e instanceof File?e.name:`blob`)),e):e instanceof FormData||e instanceof URLSearchParams?e:U(e)?(t.set(`content-type`,`text/event-stream`),Qt(e,n)):(t.set(`content-type`,`application/json`),Qe(e))}function tn(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]=t[n]===void 0?e:[t[n],e]}),t}function nn(e,t=new Headers){for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.append(n,r);return t}function rn(e,t={}){let n=nn(e.headers),r=en(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}function an(e,t={}){return{body:Re(()=>$t(e,t)),status:e.status,get headers(){let t=tn(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}var on=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(let t of this.plugins)t.init?.(e)}},sn=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new on(n.plugins).init(n),this.interceptors=Ne(n.interceptors),this.clientInterceptors=Ne(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return H({name:`${Pe}.${e.join(`/`)}`,signal:n.signal},r=>(r?.setAttribute(`rpc.system`,Pe),r?.setAttribute(`rpc.method`,e.join(`.`)),U(t)&&(t=Ye({name:`consume_event_iterator_input`,signal:n.signal},t)),Xe(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=He(),a,o=i?.trace.getActiveSpan()??r;o&&i&&(a=i?.trace.setSpan(i.context.active(),o));let s=await H({name:`encode_request`,context:a},()=>this.codec.encode(e,t,n)),c=await Xe(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>H({name:`send_request`,signal:r.signal,context:a},()=>this.sender.call(n,r,t,e))),l=await H({name:`decode_response`,context:a},()=>this.codec.decode(c,n,e,t));return U(l)?Ye({name:`consume_event_iterator_output`,signal:n.signal},l):l})))}},G={BIGINT:0,DATE:1,NAN:2,UNDEFINED:3,URL:4,REGEXP:5,SET:6,MAP:7},cn=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw Error(`Custom serializer type must be unique.`)}serialize(e,t=[],n=[],r=[],i=[]){for(let a of this.customSerializers)if(a.condition(e)){let o=this.serialize(a.serialize(e),t,n,r,i);return n.push([a.type,...t]),o}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if(typeof e==`bigint`)return n.push([G.BIGINT,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([G.DATE,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([G.NAN,...t]),[null,n,r,i];if(e instanceof URL)return n.push([G.URL,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([G.REGEXP,...t]),[e.toString(),n,r,i];if(e instanceof Set){let a=this.serialize(Array.from(e),t,n,r,i);return n.push([G.SET,...t]),a}if(e instanceof Map){let a=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([G.MAP,...t]),a}if(Array.isArray(e))return[e.map((e,a)=>e===void 0?(n.push([G.UNDEFINED,...t,a]),null):this.serialize(e,[...t,a],n,r,i)[0]),n,r,i];if(et(e)){let a={};for(let o in e)(o!==`toJSON`||typeof e[o]!=`function`)&&(a[o]=this.serialize(e[o],[...t,o],n,r,i)[0]);return[a,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){let i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,a=`data`;e.forEach(e=>{if(n=n[a],a=e,!Object.hasOwn(n,a))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${a}`)}),n[a]=r(t)});for(let e of t){let t=e[0],n=i,r=`data`;for(let t=1;t<e.length;t++)if(n=n[r],r=e[t],!Object.hasOwn(n,r))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${r}`);for(let e of this.customSerializers)if(e.type===t){n[r]=e.deserialize(n[r]);break}switch(t){case G.BIGINT:n[r]=BigInt(n[r]);break;case G.DATE:n[r]=new Date(n[r]??`Invalid Date`);break;case G.NAN:n[r]=NaN;break;case G.UNDEFINED:n[r]=void 0;break;case G.URL:n[r]=new URL(n[r]);break;case G.REGEXP:{let[,e,t]=n[r].match(/^\/(.*)\/([a-z]*)$/);n[r]=new RegExp(e,t);break}case G.SET:n[r]=new Set(n[r]);break;case G.MAP:n[r]=new Map(n[r])}}return i.data}};function ln(e){return`/${e.map(encodeURIComponent).join(`/`)}`}function un(e){return typeof e.forEach==`function`?tn(e):e}function dn(e){return Object.entries(dt).find(([,t])=>t.status===e)?.[0]??`MALFORMED_ORPC_ERROR_RESPONSE`}var fn=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??`POST`,this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=un(await nt(this.headers,n,e,t));n.lastEventId!==void 0&&(r=qt(r,{"last-event-id":n.lastEventId}));let i=await nt(this.expectedMethod,n,e,t),a=await nt(this.baseUrl,n,e,t),o=new URL(a);o.pathname=`${o.pathname.replace(/\/$/,``)}${ln(e)}`;let s=this.serializer.serialize(t);if(i===`GET`&&!(s instanceof FormData)&&!U(s)){let a=await nt(this.maxUrlLength,n,e,t),c=new URL(o);if(c.searchParams.append(`data`,Qe(s)),c.toString().length<=a)return{body:void 0,method:i,headers:r,url:c,signal:n.signal}}return{url:o,method:i===`GET`?this.fallbackMethod:i,headers:r,body:s,signal:n.signal}}async decode(e){let t=!gt(e.status),n=await(async()=>{let t=!1;try{let n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(e){throw Error(t?`Invalid RPC response format.`:`Cannot parse response body, please check the response body and content-type.`,{cause:e})}})();if(!t)throw _t(n)?vt(n):new W(dn(e.status),{status:e.status,data:{...e,body:n}});return n}},pn=class{constructor(e){this.jsonSerializer=e}serialize(e){return U(e)?Jt(e,{value:async e=>this.#e(e,!1),error:async e=>new xt({data:this.#e(ht(e).toJSON(),!1),cause:e})}):this.#e(e,!0)}#e(e,t){let[n,r,i,a]=this.jsonSerializer.serialize(e),o=r.length===0?void 0:r;if(!t||a.length===0)return{json:n,meta:o};let s=new FormData;return s.set(`data`,Qe({json:n,meta:o,maps:i})),a.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return U(e)?Jt(e,{value:async e=>this.#t(e),error:async e=>{if(!(e instanceof xt))return e;let t=this.#t(e.data);return _t(t)?vt(t,{cause:e}):new xt({data:t,cause:e})}}):this.#t(e)}#t(e){if(e===void 0)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);let t=JSON.parse(e.get(`data`));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},mn=class extends sn{constructor(e,t){let n=new fn(new pn(new cn(t)),t);super(n,e,t)}},hn=class extends on{initRuntimeAdapter(e){for(let t of this.plugins)t.initRuntimeAdapter?.(e)}},gn=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new hn(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=Ne(e.adapterInterceptors)}async call(e,t,n,r){let i=rn(e,this.toFetchRequestOptions);return an(await Xe(this.adapterInterceptors,{...t,request:i,path:n,input:r,init:{redirect:`manual`}},({request:e,path:t,input:n,init:r,...i})=>this.fetch(e,r,i,t,n)),{signal:i.signal})}},_n=class extends mn{constructor(e){let t=new gn(e);super(t,e)}},vn=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function yn(e,t){return{...e,...t}}async function bn(e,t){let{code:n,status:r,message:i,data:a,cause:o,defined:s}=t,c=e?.[t.code];if(!c||ft(t.code,c.status)!==t.status)return s?new W(n,{defined:!1,status:r,message:i,data:a,cause:o}):t;if(!c.data)return s?t:new W(n,{defined:!0,status:r,message:i,data:a,cause:o});let l=await c.data[`~standard`].validate(t.data);return l.issues?s?new W(n,{defined:!1,status:r,message:i,data:a,cause:o}):t:new W(n,{defined:!0,status:r,message:i,data:l.value,cause:o})}var xn=class{"~orpc";constructor(e){if(e.route?.successStatus&>(e.route.successStatus))throw Error(`[ContractProcedure] Invalid successStatus.`);if(Object.values(e.errorMap).some(e=>e&&e.status&&!gt(e.status)))throw Error(`[ContractProcedure] Invalid error status code.`);this[`~orpc`]=e}};function Sn(e){return e instanceof xn||(typeof e==`object`||typeof e==`function`)&&e!==null&&`~orpc`in e&&typeof e[`~orpc`]==`object`&&e[`~orpc`]!==null&&`errorMap`in e[`~orpc`]&&`route`in e[`~orpc`]&&`meta`in e[`~orpc`]}function Cn(e,t){return{...e,...t}}function wn(e,t){return{...e,...t}}function Tn(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}function En(e,t){return{...e,tags:[...t,...e.tags??[]]}}function Dn(e,t){return e?`${e}${t}`:t}function On(e,t){return e?[...e,...t]:t}function kn(e,t){let n=e;return t.prefix&&(n=Tn(n,t.prefix)),t.tags?.length&&(n=En(n,t.tags)),n}function An(e,t){if(Sn(e))return new xn({...e[`~orpc`],errorMap:yn(t.errorMap,e[`~orpc`].errorMap),route:kn(e[`~orpc`].route,t)});if(typeof e!=`object`||!e)return e;let n={};for(let r in e)n[r]=An(e[r],t);return n}new class e extends xn{constructor(e){super(e),this[`~orpc`].prefix=e.prefix,this[`~orpc`].tags=e.tags}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t})}output(t){return new e({...this[`~orpc`],outputSchema:t})}prefix(t){return new e({...this[`~orpc`],prefix:Dn(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:On(this[`~orpc`].tags,t)})}router(e){return An(e,this[`~orpc`])}}({errorMap:{},route:{},meta:{}});var jn=Symbol(`ORPC_LAZY_SYMBOL`);function Mn(e,t={}){return{[jn]:{loader:e,meta:t}}}function Nn(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&jn in e}function Pn(e){return e[jn].meta}function Fn(e){return Nn(e)?e[jn].loader():Promise.resolve({default:e})}function In(e,t){if(t.length>e.length)return!1;for(let n=0;n<e.length;n++){if(t[n]===void 0)return!0;if(e[n]!==t[n])return!1}return!0}function Ln(e,t,n){return n.dedupeLeading&&In(t,e)?t:[...e,...t]}function Rn(e,t){return[...e,t]}var zn=class{"~orpc";constructor(e){this[`~orpc`]=e}};function Bn(e){return e instanceof zn||Sn(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function Vn(e,t){return{...e,...t}}function Hn(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=Me(t),i=e[n];return new W(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function Un(e){return{output:e,context:{}}}function Wn(e,...t){let n=Me(t);return async(...[t,r])=>{let i=Ne(n.path),{default:a}=await Fn(e),o=r?.context??{},s=await nt(n.context??{},o),c=Hn(a[`~orpc`].errorMap),l=async e=>e instanceof W?await bn(a[`~orpc`].errorMap,e):e;try{let e=await H({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),Xe(Ne(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>qn(e.procedure,e))));return U(e)?e instanceof Wt?e:ot(e,Jt(Ye({name:`consume_event_iterator_output`,signal:r?.signal},e),{value:e=>e,error:e=>l(e)})):e}catch(e){throw await l(e)}}}async function Gn(e,t){let n=e[`~orpc`].inputSchema;return n?H({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new W(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new vn({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function Kn(e,t){let n=e[`~orpc`].outputSchema;return n?H({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new W(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new vn({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function qn(e,t){let n=e[`~orpc`].middlewares,r=Math.min(Math.max(0,e[`~orpc`].inputValidationIndex),n.length),i=Math.min(Math.max(0,e[`~orpc`].outputValidationIndex),n.length),a=async(o,s,c)=>{let l=c;o===r&&(l=await Gn(e,l));let u=n[o],d=u?await H({name:`middleware.${u.name}`,signal:t.signal},async e=>(e?.setAttribute(`middleware.index`,o),e?.setAttribute(`middleware.name`,u.name),(await u({...t,context:s,next:async(...[e])=>{let t=e?.context??{};return{output:await a(o+1,Vn(s,t),l),context:t}}},l,Un)).output)):await H({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await Kn(e,d):d};return a(0,t.context,t.input)}function Jn(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||Bn(n)||!tt(n))return;if(!Nn(n)){n=n[r];continue}let i=n,a=t.slice(e);return Mn(async()=>Fn(Jn((await Fn(i)).default,a)),Pn(i))}return n}function Yn(e){return new Proxy(e,{get(t,n){return typeof n==`string`?Yn(Jn(e,[n])):Reflect.get(t,n)}})}function Xn(e,t){if(Nn(e)){let n=Pn(e),r=n?.prefix?Dn(t.prefix,n?.prefix):t.prefix;return Yn(Mn(async()=>{let{default:n}=await Fn(e);return Fn(Xn(n,t))},{...n,prefix:r}))}if(Bn(e)){let n=Ln(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new zn({...e[`~orpc`],route:kn(e[`~orpc`].route,t),errorMap:yn(t.errorMap,e[`~orpc`].errorMap),middlewares:n,inputValidationIndex:e[`~orpc`].inputValidationIndex+r,outputValidationIndex:e[`~orpc`].outputValidationIndex+r})}if(typeof e!=`object`||!e)return e;let n={};for(let r in e)n[r]=Xn(e[r],t);return n}var Zn=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Qn=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},$n=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},er=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Qn(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Zn(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):tr({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},tr=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},nr=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=$n(r),s=Object.entries(i).map(([t,i])=>tr({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},rr=/\{[^{}]+\}/g,ir=({path:e,url:t})=>{let n=t,r=t.match(rr);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,er({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,nr({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${tr({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},ar=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=ir({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function or(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}var sr=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},cr={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},lr=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=er({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=nr({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=tr({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},ur=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},dr=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1;async function fr(e){for(let t of e.security??[]){if(dr(e,t.name))continue;let n=await sr(t,e.auth);if(!n)continue;let r=t.name??`Authorization`;switch(t.in){case`query`:e.query||={},e.query[r]=n;break;case`cookie`:e.headers.append(`Cookie`,`${r}=${n}`);break;default:e.headers.set(r,n)}}}var pr=e=>ar({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:lr(e.querySerializer),url:e.url}),mr=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=gr(e.headers,t.headers),n},hr=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},gr=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?hr(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},_r=class{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}},vr=()=>({error:new _r,request:new _r,response:new _r}),yr=lr({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),br={"Content-Type":`application/json`},xr=(e={})=>({...cr,headers:br,parseAs:`auto`,querySerializer:yr,...e});function Sr({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u}){let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,h=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,h);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t,p=p.replace(/\r\n?/g,`
|
|
44
44
|
`);let a=p.split(`
|
|
45
45
|
|
|
46
46
|
`);p=a.pop()??``;for(let e of a){let t=e.split(`
|
|
47
47
|
`),a=[],o;for(let e of t)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))d=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(c=t)}let s,l=!1;if(a.length){let e=a.join(`
|
|
48
|
-
`);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,h),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;let n=Math.min(c*2**(p-1),s??3e4);await f(n)}}}()}}var K=((e={})=>{let t=mr(xr(),e),n=()=>({...t}),r=e=>(t=mr(t,e),n()),i=vr(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:gr(t.headers,e.headers),serializedBody:void 0};n.security&&await fr(n),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`);let r=n;return{opts:r,url:pr(r)}},o=async e=>{let n=e.throwOnError??t.throwOnError,r=e.responseStyle??t.responseStyle,o,s;try{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:or(t)};o=new Request(n,r);for(let e of i.request.fns)e&&(o=await e(o,t));let c=t.fetch;s=await c(o);for(let e of i.response.fns)e&&(s=await e(s,o,t));let l={request:o,response:s};if(s.ok){let e=(t.parseAs===`auto`?ur(s.headers.get(`Content-Type`)):t.parseAs)??`json`;if(s.status===204||s.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await s[e]();break;case`formData`:n=new FormData;break;case`stream`:n=s.body;break;default:n={}}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`text`:n=await s[e]();break;case`json`:{let e=await s.text();n=e?JSON.parse(e):{};break}case`stream`:return t.responseStyle===`data`?s.body:{data:s.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await s.text(),d;try{d=JSON.parse(u)}catch{}throw d??u}catch(t){let a=t;for(let t of i.error.fns)t&&(a=await t(a,s,o,e));if(a||={},n)throw a;return r===`data`?void 0:{error:a,request:o,response:s}}},s=e=>t=>o({...t,method:e}),c=e=>async t=>{let{opts:n,url:r}=await a(t);return Sr({...n,body:n.body,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of i.request.fns)e&&(r=await e(r,n));return r},serializedBody:or(n),url:r})};return{buildUrl:e=>pr({...t,...e}),connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,sse:{connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),head:c(`HEAD`),options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),trace:c(`TRACE`)},trace:s(`TRACE`)}})(xr({baseUrl:`https://tailorkit.dev/api/platform`})),Cr=e=>(e.client??K).get({url:`/apps`,...e}),wr=e=>(e.client??K).post({url:`/apps`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Tr=e=>(e.client??K).delete({url:`/apps/{appId}`,...e}),Er=e=>(e.client??K).get({url:`/apps/{appId}`,...e}),Dr=e=>(e.client??K).put({url:`/apps/{appId}`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Or=e=>(e.client??K).post({url:`/apps/{appId}/deploy`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),kr=e=>(e.client??K).post({url:`/cli-auth/approve`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Ar=e=>(e.client??K).post({url:`/cli-auth/deny`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),jr=e=>(e.client??K).post({url:`/cli-auth/poll`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Mr=e=>(e.client??K).post({url:`/cli-auth/start`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Nr=e=>(e.client??K).post({url:`/cli-auth/verify-token`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Pr=e=>(e.client??K).get({url:`/deployments`,...e}),Fr=e=>(e.client??K).post({url:`/deployments`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Ir=e=>(e.client??K).get({url:`/deployments/{deploymentId}`,...e}),Lr=e=>(e.client??K).post({url:`/deployments/{deploymentId}`,...e,headers:{"Content-Type":`application/json`,...e.headers}});Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});var Rr={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function q(e,t){return t===void 0?Rr[e]:t}function zr(e){let t=((...t)=>e(...t));return t.mapInput=t=>zr((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?zr(t).mapInput(n):t;return zr((t,n,i,...a)=>e({...t,next:(...[e])=>r({...t,context:{...t.context,...e?.context},next:(...[n])=>t.next({context:{...e?.context,...n?.context}})},n,i,...a)},n,i,...a))},t}function Br(e){return async t=>{try{return[null,await e(t)]}catch(e){if(e instanceof Error&&`digest`in e&&typeof e.digest==`string`&&e.digest.startsWith(`NEXT_`)||e instanceof Response&&`options`in e&&et(e.options)||et(e)&&e.isNotFound===!0)throw e;return[ht(e).toJSON(),void 0]}}}var Vr=class e extends zn{errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}use(t,n){let r=n?zr(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:Rn(this[`~orpc`].middlewares,r)})}callable(...e){let t=Wn(this,...e);return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}actionable(...e){let t=Br(Wn(this,...e));return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}},Hr=new class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:q(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:q(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:q(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)})}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}middleware(e){return zr(e)}errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?zr(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:Rn(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new Vr({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:Dn(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:On(this[`~orpc`].tags,t)})}router(e){return Xn(e,this[`~orpc`])}lazy(e){return Xn(Mn(e),this[`~orpc`])}}({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:q(`initialInputValidationIndex`),outputValidationIndex:q(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function Ur(e){return Xt(new _n({async fetch(t,n){let r=await(typeof e.headers==`function`?e.headers():e.headers),i=new Headers(r);return new Headers(n?.headers).forEach((e,t)=>{i.set(t,e)}),(e.fetch??fetch)(t,{...n,headers:i})},method:`POST`,url:e.url}))}var J=Hr.$context();function Wr(e){if(!e.tailorkit)throw new W(`UNAUTHORIZED`,{message:`Unauthorized.`});return e.tailorkit}function Y(e){return Wr(e).scopeId}function Gr(e){let[t,n]=e.headers.get(`authorization`)?.split(` `)??[];if(t!==`Bearer`||!n)throw new W(`UNAUTHORIZED`,{message:`Missing CLI deploy token.`});return n}var X=J.middleware(async({context:e,next:t})=>{let n=await Nr({body:{deployToken:Gr(e.request)},client:e.platform,headers:e.platformHeaders}),r=`data`in n?n.data:n;if(!r?.scopeId)throw new W(`UNAUTHORIZED`,{message:`Invalid CLI deploy token.`});return t({context:{tailorkit:{scopeId:r.scopeId}}})}),Kr=J.middleware(async({context:e,next:t})=>{let n=await e.authenticate({request:e.request});if(!n)throw new W(`UNAUTHORIZED`,{message:`Unauthorized.`});return t({context:{tailorkit:n}})}),qr=async(e,t)=>{if(e===void 0)return t;let n=await e[`~standard`].validate(t);if(`issues`in n)throw new W(`BAD_REQUEST`,{message:`Invalid TailorKit payload`});return n.value};J.use(Kr).input(w.object({input:w.unknown().optional(),path:w.string()})).handler(async({context:e,input:t})=>{let n=e.actions.get(t.path);if(n===void 0)throw new W(`NOT_FOUND`,{message:`Action not found`});let r=await qr(n.definition.input,t.input),i=await n.handler({context:Wr(e).actionContext,input:r});return qr(n.definition.output,i)});var Jr=w.object({page:w.number().int().min(1).optional(),pageSize:w.number().int().min(1).max(100).optional()}),Yr=w.object({description:w.string().nullable(),name:w.string()});J.use(X).input(Yr).handler(async({context:e,input:t})=>await wr({body:{...t,scopeId:Y(e)},client:e.platform,headers:e.platformHeaders})),J.use(X).input(w.object({appId:w.string()})).handler(async({context:e,input:t})=>await Tr({client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string(),deploymentId:w.string()})).handler(async({context:e,input:t})=>await Or({body:{deploymentId:t.deploymentId},client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()})).handler(async({context:e,input:t})=>await Er({client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(Jr.optional()).handler(async({context:e,input:t})=>await Cr({client:e.platform,headers:e.platformHeaders,query:{page:t?.page,pageSize:t?.pageSize,scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()}).extend(Yr.shape)).handler(async({context:e,input:t})=>await Dr({body:{description:t.description,name:t.name},client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}}));var Xr=async e=>{try{return await e}catch(e){throw typeof e==`string`&&e.toLowerCase()===`unauthorized`?new W(`UNAUTHORIZED`,{message:`TailorKit platform rejected the host project key. Check TAILORKIT_PROJECT_KEY.`}):e}};J.use(Kr).input(w.object({userCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(kr({body:{scopeId:Y(e),userCode:t.userCode},client:e.platform,headers:e.platformHeaders}))),J.use(Kr).input(w.object({userCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(Ar({body:{userCode:t.userCode},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({deviceCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(jr({body:{deviceCode:t.deviceCode},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({})).handler(async({context:e})=>await Xr(Mr({body:{},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({})).use(X).handler(({context:e})=>({scopeId:Y(e)}));var Zr=w.object({page:w.number().int().min(1).optional(),pageSize:w.number().int().min(1).max(100).optional()}),Qr=w.object({checksum:w.string(),contentLength:w.number().int().min(1),contentType:w.literal(`application/javascript`),encoding:w.literal(`utf-8`),objectKey:w.literal(`client.js`)}),$r=w.object({checksum:w.string(),contentLength:w.number().int().min(1).max(262144),contentType:w.enum([`image/svg+xml`,`image/png`,`image/webp`])}),ei=w.tuple([Qr]),ti=w.object({dark:$r.optional(),light:$r.optional()}).optional(),ni=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e){let t=e.message;return typeof t==`string`?t:void 0}},ri=e=>ni(e)?.toLowerCase().includes(`not found`)??!1,ii=e=>{throw ri(e)?new W(`NOT_FOUND`,{message:`App not found.`}):e};J.use(X).input(w.object({appId:w.string(),assets:ei,logos:ti})).handler(async({context:e,input:t})=>{try{return await Fr({body:{appId:t.appId,assets:t.assets,logos:t.logos,scopeId:Y(e)},client:e.platform,headers:e.platformHeaders})}catch(e){ii(e)}}),J.use(X).input(w.object({deploymentId:w.string()})).handler(async({context:e,input:t})=>await Ir({client:e.platform,headers:e.platformHeaders,path:{deploymentId:t.deploymentId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()}).merge(Zr)).handler(async({context:e,input:t})=>await Pr({client:e.platform,headers:e.platformHeaders,query:{appId:t.appId,page:t.page,pageSize:t.pageSize,scopeId:Y(e)}})),J.use(X).input(w.object({deploymentId:w.string(),rollout:w.boolean().optional()})).handler(async({context:e,input:t})=>await Lr({body:{scopeId:Y(e),rollout:t.rollout},client:e.platform,headers:e.platformHeaders,path:{deploymentId:t.deploymentId}}));var ai=e=>{let t=new URL(e);return t.hash=``,t.search=``,t.pathname=t.pathname.replace(/\/+$/u,``),t.toString().replace(/\/$/u,``)},oi=C.join(x(),`.tailorkit`,`auth.json`),si=18e5,ci=2e3,li=w.object({deployToken:w.string().min(1),scopeId:w.string().min(1).optional()}),ui=w.object({hosts:w.record(w.string(),li).optional()}).passthrough(),di=e=>new Promise(t=>setTimeout(t,e)),fi=e=>{if(e&&typeof e==`object`&&`error`in e&&e.error!==void 0)throw e.error},pi=async()=>{try{return ui.parse(JSON.parse(await _(oi,`utf-8`)))}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return{};throw e}},mi=async e=>{await g(C.dirname(oi),{recursive:!0}),await b(oi,`${JSON.stringify(e,null,2)}\n`,{encoding:`utf-8`,mode:384}),await h(oi,384)},hi=async e=>{let t=await B(e.configPath,e.cwd);if(t.config.host)return ai(t.config.host);throw Error(`Missing TailorKit host URL. Set host in tailorkit.config.ts.`)},gi=(e,t)=>{let n=new URL(e);return n.pathname=`${n.pathname.replace(/\/+$/u,``)}/cli-auth/approve`,n.search=``,n.searchParams.set(`code`,t),n.hash=``,n.toString()},_i=e=>Error(`Not logged in for ${e}. Run tailorkit login after checking host in tailorkit.config.ts.`),vi=async(e,t)=>{let n=await pi();await mi({...n,hosts:{...n.hosts,[e]:t}})},yi=async e=>{let t=await pi();if(!t.hosts?.[e])return!1;let{[e]:n,...r}=t.hosts,i={...t,hosts:r};return Object.keys(r).length===0?(await v(oi,{force:!0}),!0):(await mi(i),!0)},bi=async e=>(await pi()).hosts?.[e],xi=async(e,t)=>{let n=await hi(e),r=Ur({url:n}),i=await r.cliAuth.start({});fi(i);let a=`data`in i?i.data:i,o=new Date(a.expiresAt),s=Date.now()+(e.timeout??si);for(t({expiresAt:o,hostUrl:n,userCode:a.userCode});Date.now()<s&&Date.now()<o.getTime();){await di(ci);let e=await r.cliAuth.poll({deviceCode:a.deviceCode});fi(e);let t=`data`in e?e.data:e;switch(t.status){case`pending`:continue;case`denied`:throw Error(`CLI login was denied.`);case`expired`:throw Error(`CLI login expired.`);case`approved`:return await vi(n,{deployToken:t.deployToken,scopeId:t.scopeId}),{hostUrl:n,scopeId:t.scopeId};default:throw Error(`Unexpected CLI login status.`)}}throw Error(`Timed out waiting for CLI login approval.`)},Si=async e=>{let t=await hi(e),n=await bi(t);if(!n?.deployToken)throw _i(t);let r=Ur({headers:{authorization:`Bearer ${n.deployToken}`},url:t}),i;try{let e=await r.cliAuth.verifyToken({});fi(e),i=`data`in e?e.data:e}catch{throw _i(t)}return await vi(t,{deployToken:n.deployToken,scopeId:i.scopeId}),{hostUrl:t,scopeId:i.scopeId}},Ci=async e=>{let t=await hi(e);return{hostUrl:t,removed:await yi(t)}},wi=1048576,Ti=re(ie),Ei={png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`},Di=e=>{if(e&&typeof e==`object`&&`error`in e&&e.error!==void 0)throw e.error;let t=e&&typeof e==`object`&&`data`in e?e.data:e;return t&&typeof t==`object`&&`body`in t?t.body:t},Oi=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e){let t=e.message;return typeof t==`string`?t:void 0}},ki=e=>Oi(e)?.toLowerCase().includes(`not found`)??!1,Ai=async(e,t)=>{let n=C.join(e,`tailorkit-upload.json`);return t.parse(JSON.parse(await _(n,`utf-8`)))},ji=e=>te(`sha256`).update(e).digest(`hex`),Mi=async e=>{try{let t=JSON.parse(await _(C.join(e,`package.json`),`utf-8`));if(typeof t.name==`string`&&t.name.trim())return t.name.trim()}catch{}return C.basename(e)},Ni=async(e,t)=>{let n=await _(e,`utf-8`),r=` appId: ${JSON.stringify(t)},`;if(/^\s*appId\s*:/mu.test(n)){await b(e,n.replace(/^(\s*)appId\s*:\s*(['"]).*?\2\s*,?/mu,`$1appId: ${JSON.stringify(t)},`),`utf-8`);return}let i=/(export\s+default\s+\{)(\r?\n)/u;if(i.test(n)){await b(e,n.replace(i,`$1$2${r}$2`),`utf-8`);return}let a=/(export\s+default\s+(?:defineTailorKitConfig|defineConfig)\(\s*\{)(\r?\n)/u;if(a.test(n)){await b(e,n.replace(a,`$1$2${r}$2`),`utf-8`);return}throw Error(`Could not write appId to ${e}. Add appId: ${JSON.stringify(t)} manually.`)},Pi=async(e,t)=>{if(t.byteLength>wi)throw Error(`Deployment asset exceeds ${wi} bytes.`);let n=new Headers(e.headers);n.has(`content-type`)||n.set(`content-type`,`application/javascript`);let r=await fetch(e.uploadUrl,{body:new Uint8Array(t),headers:n,method:`PUT`});if(!r.ok)throw Error(`Asset upload failed with ${r.status} ${r.statusText}.`)},Fi=e=>{for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=C.join(e,t);if(ne(n))return n}},Ii=e=>{let t=r(C.join(e,`package.json`));try{return t(`typescript`)}catch{return}},Li=(e,t,n)=>t.map(t=>{let r=t,i=e.flattenDiagnosticMessageText(r.messageText,`
|
|
48
|
+
`);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,h),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;let n=Math.min(c*2**(p-1),s??3e4);await f(n)}}}()}}var K=((e={})=>{let t=mr(xr(),e),n=()=>({...t}),r=e=>(t=mr(t,e),n()),i=vr(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:gr(t.headers,e.headers),serializedBody:void 0};n.security&&await fr(n),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`);let r=n;return{opts:r,url:pr(r)}},o=async e=>{let n=e.throwOnError??t.throwOnError,r=e.responseStyle??t.responseStyle,o,s;try{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:or(t)};o=new Request(n,r);for(let e of i.request.fns)e&&(o=await e(o,t));let c=t.fetch;s=await c(o);for(let e of i.response.fns)e&&(s=await e(s,o,t));let l={request:o,response:s};if(s.ok){let e=(t.parseAs===`auto`?ur(s.headers.get(`Content-Type`)):t.parseAs)??`json`;if(s.status===204||s.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await s[e]();break;case`formData`:n=new FormData;break;case`stream`:n=s.body;break;default:n={}}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`text`:n=await s[e]();break;case`json`:{let e=await s.text();n=e?JSON.parse(e):{};break}case`stream`:return t.responseStyle===`data`?s.body:{data:s.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await s.text(),d;try{d=JSON.parse(u)}catch{}throw d??u}catch(t){let a=t;for(let t of i.error.fns)t&&(a=await t(a,s,o,e));if(a||={},n)throw a;return r===`data`?void 0:{error:a,request:o,response:s}}},s=e=>t=>o({...t,method:e}),c=e=>async t=>{let{opts:n,url:r}=await a(t);return Sr({...n,body:n.body,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of i.request.fns)e&&(r=await e(r,n));return r},serializedBody:or(n),url:r})};return{buildUrl:e=>pr({...t,...e}),connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,sse:{connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),head:c(`HEAD`),options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),trace:c(`TRACE`)},trace:s(`TRACE`)}})(xr({baseUrl:`https://tailorkit.dev/api/platform`})),Cr=e=>(e.client??K).get({url:`/apps`,...e}),wr=e=>(e.client??K).post({url:`/apps`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Tr=e=>(e.client??K).delete({url:`/apps/{appId}`,...e}),Er=e=>(e.client??K).get({url:`/apps/{appId}`,...e}),Dr=e=>(e.client??K).put({url:`/apps/{appId}`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Or=e=>(e.client??K).post({url:`/apps/{appId}/deploy`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),kr=e=>(e.client??K).post({url:`/cli-auth/approve`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Ar=e=>(e.client??K).post({url:`/cli-auth/deny`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),jr=e=>(e.client??K).post({url:`/cli-auth/poll`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Mr=e=>(e.client??K).post({url:`/cli-auth/start`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Nr=e=>(e.client??K).post({url:`/cli-auth/verify-token`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Pr=e=>(e.client??K).get({url:`/deployments`,...e}),Fr=e=>(e.client??K).post({url:`/deployments`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),Ir=e=>(e.client??K).get({url:`/deployments/{deploymentId}`,...e}),Lr=e=>(e.client??K).post({url:`/deployments/{deploymentId}`,...e,headers:{"Content-Type":`application/json`,...e.headers}});Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});var Rr={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function q(e,t){return t===void 0?Rr[e]:t}function zr(e){let t=((...t)=>e(...t));return t.mapInput=t=>zr((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?zr(t).mapInput(n):t;return zr((t,n,i,...a)=>e({...t,next:(...[e])=>r({...t,context:{...t.context,...e?.context},next:(...[n])=>t.next({context:{...e?.context,...n?.context}})},n,i,...a)},n,i,...a))},t}function Br(e){return async t=>{try{return[null,await e(t)]}catch(e){if(e instanceof Error&&`digest`in e&&typeof e.digest==`string`&&e.digest.startsWith(`NEXT_`)||e instanceof Response&&`options`in e&&et(e.options)||et(e)&&e.isNotFound===!0)throw e;return[ht(e).toJSON(),void 0]}}}var Vr=class e extends zn{errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}use(t,n){let r=n?zr(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:Rn(this[`~orpc`].middlewares,r)})}callable(...e){let t=Wn(this,...e);return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}actionable(...e){let t=Br(Wn(this,...e));return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}},Hr=new class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:q(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:q(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:q(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)})}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}middleware(e){return zr(e)}errors(t){return new e({...this[`~orpc`],errorMap:yn(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?zr(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:Rn(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:Cn(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:wn(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:q(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:q(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new Vr({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:Dn(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:On(this[`~orpc`].tags,t)})}router(e){return Xn(e,this[`~orpc`])}lazy(e){return Xn(Mn(e),this[`~orpc`])}}({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:q(`initialInputValidationIndex`),outputValidationIndex:q(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function Ur(e){return Xt(new _n({async fetch(t,n){let r=await(typeof e.headers==`function`?e.headers():e.headers),i=new Headers(r);return new Headers(n?.headers).forEach((e,t)=>{i.set(t,e)}),(e.fetch??fetch)(t,{...n,headers:i})},method:`POST`,url:e.url}))}var J=Hr.$context();function Wr(e){if(!e.tailorkit)throw new W(`UNAUTHORIZED`,{message:`Unauthorized.`});return e.tailorkit}function Y(e){return Wr(e).scopeId}function Gr(e){let[t,n]=e.headers.get(`authorization`)?.split(` `)??[];if(t!==`Bearer`||!n)throw new W(`UNAUTHORIZED`,{message:`Missing CLI deploy token.`});return n}var X=J.middleware(async({context:e,next:t})=>{let n=await Nr({body:{deployToken:Gr(e.request)},client:e.platform,headers:e.platformHeaders}),r=`data`in n?n.data:n;if(!r?.scopeId)throw new W(`UNAUTHORIZED`,{message:`Invalid CLI deploy token.`});return t({context:{tailorkit:{scopeId:r.scopeId}}})}),Kr=J.middleware(async({context:e,next:t})=>{let n=await e.authenticate({request:e.request});if(!n)throw new W(`UNAUTHORIZED`,{message:`Unauthorized.`});return t({context:{tailorkit:n}})}),qr=async(e,t)=>{if(e===void 0)return t;let n=await e[`~standard`].validate(t);if(`issues`in n)throw new W(`BAD_REQUEST`,{message:`Invalid TailorKit payload`});return n.value};J.use(Kr).input(w.object({input:w.unknown().optional(),path:w.string()})).handler(async({context:e,input:t})=>{let n=e.actions.get(t.path);if(n===void 0)throw new W(`NOT_FOUND`,{message:`Action not found`});let r=await qr(n.definition.input,t.input),i=await n.handler({context:Wr(e).actionContext,input:r});return qr(n.definition.output,i)});var Jr=w.object({page:w.number().int().min(1).optional(),pageSize:w.number().int().min(1).max(100).optional()}),Yr=w.object({description:w.string().nullable(),name:w.string()});J.use(X).input(Yr).handler(async({context:e,input:t})=>await wr({body:{...t,scopeId:Y(e)},client:e.platform,headers:e.platformHeaders})),J.use(X).input(w.object({appId:w.string()})).handler(async({context:e,input:t})=>await Tr({client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string(),deploymentId:w.string()})).handler(async({context:e,input:t})=>await Or({body:{deploymentId:t.deploymentId},client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()})).handler(async({context:e,input:t})=>await Er({client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}})),J.use(X).input(Jr.optional()).handler(async({context:e,input:t})=>await Cr({client:e.platform,headers:e.platformHeaders,query:{page:t?.page,pageSize:t?.pageSize,scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()}).extend(Yr.shape)).handler(async({context:e,input:t})=>await Dr({body:{description:t.description,name:t.name},client:e.platform,headers:e.platformHeaders,path:{appId:t.appId},query:{scopeId:Y(e)}}));var Xr=async e=>{try{return await e}catch(e){throw typeof e==`string`&&e.toLowerCase()===`unauthorized`?new W(`UNAUTHORIZED`,{message:`TailorKit platform rejected the host project key. Check TAILORKIT_PROJECT_KEY.`}):e}};J.use(Kr).input(w.object({userCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(kr({body:{scopeId:Y(e),userCode:t.userCode},client:e.platform,headers:e.platformHeaders}))),J.use(Kr).input(w.object({userCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(Ar({body:{userCode:t.userCode},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({deviceCode:w.string().min(1)})).handler(async({context:e,input:t})=>await Xr(jr({body:{deviceCode:t.deviceCode},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({})).handler(async({context:e})=>await Xr(Mr({body:{},client:e.platform,headers:e.platformHeaders}))),J.input(w.object({})).use(X).handler(({context:e})=>({scopeId:Y(e)}));var Zr=w.object({page:w.number().int().min(1).optional(),pageSize:w.number().int().min(1).max(100).optional()}),Qr=w.object({checksum:w.string(),contentLength:w.number().int().min(1),contentType:w.literal(`application/javascript`),encoding:w.literal(`utf-8`),objectKey:w.literal(`client.js`)}),$r=w.object({checksum:w.string(),contentLength:w.number().int().min(1).max(262144),contentType:w.enum([`image/svg+xml`,`image/png`,`image/webp`])}),ei=w.tuple([Qr]),ti=w.object({dark:$r.optional(),light:$r.optional()}).optional(),ni=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e){let t=e.message;return typeof t==`string`?t:void 0}},ri=e=>ni(e)?.toLowerCase().includes(`not found`)??!1,ii=e=>{throw ri(e)?new W(`NOT_FOUND`,{message:`App not found.`}):e};J.use(X).input(w.object({appId:w.string(),assets:ei,logos:ti})).handler(async({context:e,input:t})=>{try{return await Fr({body:{appId:t.appId,assets:t.assets,logos:t.logos,scopeId:Y(e)},client:e.platform,headers:e.platformHeaders})}catch(e){ii(e)}}),J.use(X).input(w.object({deploymentId:w.string()})).handler(async({context:e,input:t})=>await Ir({client:e.platform,headers:e.platformHeaders,path:{deploymentId:t.deploymentId},query:{scopeId:Y(e)}})),J.use(X).input(w.object({appId:w.string()}).merge(Zr)).handler(async({context:e,input:t})=>await Pr({client:e.platform,headers:e.platformHeaders,query:{appId:t.appId,page:t.page,pageSize:t.pageSize,scopeId:Y(e)}})),J.use(X).input(w.object({deploymentId:w.string(),rollout:w.boolean().optional()})).handler(async({context:e,input:t})=>await Lr({body:{scopeId:Y(e),rollout:t.rollout},client:e.platform,headers:e.platformHeaders,path:{deploymentId:t.deploymentId}}));var ai=e=>{let t=new URL(e);return t.hash=``,t.search=``,t.pathname=t.pathname.replace(/\/+$/u,``),t.toString().replace(/\/$/u,``)},oi=C.join(x(),`.tailorkit`,`auth.json`),si=18e5,ci=2e3,li=w.object({deployToken:w.string().min(1),scopeId:w.string().min(1).optional()}),ui=w.object({hosts:w.record(w.string(),li).optional()}).passthrough(),di=e=>new Promise(t=>setTimeout(t,e)),fi=e=>{if(e&&typeof e==`object`&&`error`in e&&e.error!==void 0)throw e.error},pi=async()=>{try{return ui.parse(JSON.parse(await _(oi,`utf-8`)))}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return{};throw e}},mi=async e=>{await g(C.dirname(oi),{recursive:!0}),await b(oi,`${JSON.stringify(e,null,2)}\n`,{encoding:`utf-8`,mode:384}),await h(oi,384)},hi=async e=>{let t=await V(e.configPath,e.cwd);if(t.config.host)return ai(t.config.host);throw Error(`Missing TailorKit host URL. Set host in tailorkit.config.ts.`)},gi=(e,t)=>{let n=new URL(e);return n.pathname=`${n.pathname.replace(/\/+$/u,``)}/cli-auth/approve`,n.search=``,n.searchParams.set(`code`,t),n.hash=``,n.toString()},_i=e=>Error(`Not logged in for ${e}. Run tailorkit login after checking host in tailorkit.config.ts.`),vi=async(e,t)=>{let n=await pi();await mi({...n,hosts:{...n.hosts,[e]:t}})},yi=async e=>{let t=await pi();if(!t.hosts?.[e])return!1;let{[e]:n,...r}=t.hosts,i={...t,hosts:r};return Object.keys(r).length===0?(await v(oi,{force:!0}),!0):(await mi(i),!0)},bi=async e=>(await pi()).hosts?.[e],xi=async(e,t)=>{let n=await hi(e),r=Ur({url:n}),i=await r.cliAuth.start({});fi(i);let a=`data`in i?i.data:i,o=new Date(a.expiresAt),s=Date.now()+(e.timeout??si);for(t({expiresAt:o,hostUrl:n,userCode:a.userCode});Date.now()<s&&Date.now()<o.getTime();){await di(ci);let e=await r.cliAuth.poll({deviceCode:a.deviceCode});fi(e);let t=`data`in e?e.data:e;switch(t.status){case`pending`:continue;case`denied`:throw Error(`CLI login was denied.`);case`expired`:throw Error(`CLI login expired.`);case`approved`:return await vi(n,{deployToken:t.deployToken,scopeId:t.scopeId}),{hostUrl:n,scopeId:t.scopeId};default:throw Error(`Unexpected CLI login status.`)}}throw Error(`Timed out waiting for CLI login approval.`)},Si=async e=>{let t=await hi(e),n=await bi(t);if(!n?.deployToken)throw _i(t);let r=Ur({headers:{authorization:`Bearer ${n.deployToken}`},url:t}),i;try{let e=await r.cliAuth.verifyToken({});fi(e),i=`data`in e?e.data:e}catch{throw _i(t)}return await vi(t,{deployToken:n.deployToken,scopeId:i.scopeId}),{hostUrl:t,scopeId:i.scopeId}},Ci=async e=>{let t=await hi(e);return{hostUrl:t,removed:await yi(t)}},wi=1048576,Ti=re(ie),Ei={png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`},Di=e=>{if(e&&typeof e==`object`&&`error`in e&&e.error!==void 0)throw e.error;let t=e&&typeof e==`object`&&`data`in e?e.data:e;return t&&typeof t==`object`&&`body`in t?t.body:t},Oi=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e){let t=e.message;return typeof t==`string`?t:void 0}},ki=e=>Oi(e)?.toLowerCase().includes(`not found`)??!1,Ai=async(e,t)=>{let n=C.join(e,`tailorkit-upload.json`);return t.parse(JSON.parse(await _(n,`utf-8`)))},ji=e=>te(`sha256`).update(e).digest(`hex`),Mi=async e=>{try{let t=JSON.parse(await _(C.join(e,`package.json`),`utf-8`));if(typeof t.name==`string`&&t.name.trim())return t.name.trim()}catch{}return C.basename(e)},Ni=async(e,t)=>{let n=await _(e,`utf-8`),r=` appId: ${JSON.stringify(t)},`;if(/^\s*appId\s*:/mu.test(n)){await b(e,n.replace(/^(\s*)appId\s*:\s*(['"]).*?\2\s*,?/mu,`$1appId: ${JSON.stringify(t)},`),`utf-8`);return}let i=/(export\s+default\s+\{)(\r?\n)/u;if(i.test(n)){await b(e,n.replace(i,`$1$2${r}$2`),`utf-8`);return}let a=/(export\s+default\s+(?:defineTailorKitConfig|defineConfig)\(\s*\{)(\r?\n)/u;if(a.test(n)){await b(e,n.replace(a,`$1$2${r}$2`),`utf-8`);return}throw Error(`Could not write appId to ${e}. Add appId: ${JSON.stringify(t)} manually.`)},Pi=async(e,t)=>{if(!e.uploadUrl)return;if(t.byteLength>wi)throw Error(`Deployment asset exceeds ${wi} bytes.`);let n=new Headers(e.headers);n.has(`content-type`)||n.set(`content-type`,`application/javascript`);let r=await fetch(e.uploadUrl,{body:new Uint8Array(t),headers:n,method:`PUT`});if(!r.ok)throw Error(`Asset upload failed with ${r.status} ${r.statusText}.`)},Fi=e=>{for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=C.join(e,t);if(ne(n))return n}},Ii=e=>{let t=r(C.join(e,`package.json`));try{return t(`typescript`)}catch{return}},Li=(e,t,n)=>t.map(t=>{let r=t,i=e.flattenDiagnosticMessageText(r.messageText,`
|
|
49
49
|
`);if(r.file===void 0||r.start===void 0)return`TS${r.code}: ${i}`;let a=e.getLineAndCharacterOfPosition(r.file,r.start);return`${C.relative(n,r.file.fileName)}(${a.line+1},${a.character+1}): error TS${r.code}: ${i}`}).join(`
|
|
50
|
-
`),Ri=(e,t)=>{let n=Ii(e.root),r=Fi(e.root);if(n===void 0||r===void 0)return;let i=t.entry??e.config.client?.entry??`./src/client.ts`,a=C.resolve(e.root,i),o=n.readConfigFile(r,n.sys.readFile);if(o.error!==void 0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,[o.error],e.root)};let s=n.parseJsonConfigFileContent(o.config,n.sys,e.root,{noEmit:!0},r);if(s.errors.length>0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,s.errors,e.root)};let c=n.createCompilerHost(s.options),l=n.createProgram({host:c,options:s.options,rootNames:[a]}),u=[...n.getPreEmitDiagnostics(l),...l.emit().diagnostics];if(u.length!==0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,u,e.root)}},zi=async e=>{let t=await
|
|
50
|
+
`),Ri=(e,t)=>{let n=Ii(e.root),r=Fi(e.root);if(n===void 0||r===void 0)return;let i=t.entry??e.config.client?.entry??`./src/client.ts`,a=C.resolve(e.root,i),o=n.readConfigFile(r,n.sys.readFile);if(o.error!==void 0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,[o.error],e.root)};let s=n.parseJsonConfigFileContent(o.config,n.sys,e.root,{noEmit:!0},r);if(s.errors.length>0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,s.errors,e.root)};let c=n.createCompilerHost(s.options),l=n.createProgram({host:c,options:s.options,rootNames:[a]}),u=[...n.getPreEmitDiagnostics(l),...l.emit().diagnostics];if(u.length!==0)return{command:`tsc --noEmit ${C.relative(e.root,a)}`,exitCode:1,output:Li(n,u,e.root)}},zi=async e=>{let t=await V(e.configPath,e.cwd),n=t.config.appId,r=!1,i=await Si(e),a=await bi(i.hostUrl);if(!a?.deployToken)throw Error(`Not logged in for ${i.hostUrl}. Run tailorkit login after checking host in tailorkit.config.ts.`);let{buildApp:o,tailorkitUploadManifestSchema:s}=await import(`./assets/builder-D5o0m6gu.js`),[c,l]=await Promise.allSettled([o(e),Ri(t,e)]);if(c.status===`rejected`)throw c.reason;if(l.status===`rejected`)throw l.reason;if(l.value!==void 0&&!await e.onTypecheckFailed?.(l.value))throw Error(`Deployment cancelled because type check failed.`);let u=C.resolve(t.root,e.outDir??t.config.build?.outDir??`.tailorkit`),d=await Ai(u,s),f=C.join(u,d.assets.client),p=await _(f),m=await Ti(p),h=Object.entries(d.assets.logos??{}),g=await Promise.all(h.map(async([e,t])=>{let n=await _(C.join(u,t)),r=Ei[C.extname(t).slice(1)];if(!r)throw Error(`Unsupported ${e} logo format.`);return{content:n,contentType:r,filename:t,variant:e}}));if(p.byteLength>wi)throw Error(`Combined client assets are ${p.byteLength} bytes and cannot exceed ${wi} bytes.`);let v=Ur({headers:{authorization:`Bearer ${a.deployToken}`},url:i.hostUrl}),y=async a=>{let o=await Mi(t.root);if(!await e.onMissingAppId?.({appName:o,configPath:t.filepath,hostUrl:i.hostUrl,reason:a}))throw Error(`Deployment cancelled.`);return n=Di(await v.apps.create({description:null,name:o})).id,r=!0,await Ni(t.filepath,n),n};n||=await y(`missing`);let b=async e=>Di(await v.deployments.create({appId:e,assets:[{checksum:ji(p),contentLength:p.byteLength,contentType:`application/javascript`,encoding:`utf-8`,objectKey:`client.js`}],logos:g.length>0?Object.fromEntries(g.map(e=>[e.variant,{checksum:ji(e.content),contentLength:e.content.byteLength,contentType:e.contentType}])):void 0})),x;try{x=await b(n)}catch(e){if(!ki(e))throw e;n=await y(`not-found`),x=await b(n)}if(x.assets.length!==1||!x.assets[0])throw Error(`Deployment did not return an upload URL for the client asset.`);await Promise.all([Pi(x.assets[0],p),...g.map(e=>{let t=x.logos?.[e.variant];if(!t)throw Error(`Deployment did not return an upload URL for the ${e.variant} logo.`);return Pi(t,e.content)})]);let S=Di(await v.deployments.publish({deploymentId:x.deployment.id,rollout:!0})),w=await Promise.all(g.map(async e=>({gzipSize:(await Ti(e.content)).byteLength,path:e.filename,size:e.content.byteLength})));return{appId:n,createdApp:r,deploymentId:S.id,hostUrl:i.hostUrl,status:S.status,uploadedFiles:[{gzipSize:m.byteLength,path:d.assets.client,size:p.byteLength},...w]}},Bi=w.enum([`object`,`array`,`string`,`number`,`boolean`,`null`]),Z=w.object({$schema:w.enum([`https://json-schema.org/draft/2020-12/schema`]).optional(),type:w.union([Bi,w.array(w.string())]).optional(),properties:w.lazy(()=>w.record(w.string(),Z)).optional(),required:w.array(w.string()).optional(),additionalProperties:w.union([w.boolean(),w.lazy(()=>Z)]).optional(),enum:w.array(w.unknown()).optional(),const:w.unknown().optional(),items:w.lazy(()=>Z).optional(),anyOf:w.lazy(()=>w.array(Z)).optional(),oneOf:w.lazy(()=>w.array(Z)).optional(),allOf:w.lazy(()=>w.array(Z)).optional(),not:w.lazy(()=>Z).optional()}).strict(),Vi=w.object({async:w.boolean().optional(),input:Z.optional(),output:Z.optional()}),Hi=w.object({fields:Z.optional(),callbacks:w.record(w.string(),Vi),children:w.boolean()}),Ui=w.record(w.string(),Hi),Wi=w.string().regex(/^\/.*$/u,{message:`Screen keys must start with "/".`}),Gi=w.object({context:Z.optional()}).strict(),Ki=w.record(Wi,Gi),qi=w.object({input:w.record(w.string(),w.unknown()).optional(),output:w.record(w.string(),w.unknown()).optional()}),Ji=w.lazy(()=>w.record(w.string(),w.union([qi,Ji])));w.object({version:w.literal(1),actions:Ji.default({}),components:Ui,screens:Ki.default({})});var Yi=`/* eslint-disable */
|
|
51
51
|
|
|
52
52
|
// This file was automatically generated by TailorKit.
|
|
53
53
|
// Documentation: https://tailorkit.dev/docs
|
|
@@ -56,25 +56,25 @@ data: `)}
|
|
|
56
56
|
// Exclude this file from linting and formatting to avoid checking generated code.
|
|
57
57
|
|
|
58
58
|
import { createRemoteComponent } from "tailorkit/app";
|
|
59
|
-
`,
|
|
60
|
-
`)},
|
|
61
|
-
`)},
|
|
62
|
-
`);t.push(` ${
|
|
63
|
-
`)},
|
|
64
|
-
`)},
|
|
65
|
-
`);i.push(`${r}${
|
|
66
|
-
`)},
|
|
67
|
-
`);n.push(` ${
|
|
68
|
-
`)},
|
|
59
|
+
`,Xi=`Record<string, never>`,Zi=new Set([`Box`,`Flex`,`Grid`,`Inline`]),Qi=e=>JSON.stringify(e),$i=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)?e:Qi(e),ea=e=>typeof e==`string`?Qi(e):typeof e==`number`||typeof e==`boolean`||e===null?JSON.stringify(e):`unknown`,Q=(e,t=0)=>{if(e===void 0)return`unknown`;if(ta(e))return`never`;if(e.const!==void 0)return ea(e.const);if(e.enum!==void 0&&e.enum.length>0)return e.enum.map(ea).join(` | `);if(e.anyOf!==void 0&&e.anyOf.length>0){let n=e.anyOf.filter(e=>!ta(e)).map(e=>Q(e,t)).filter(e=>e!==`never`);return n.length===0?`never`:[...new Set(n)].join(` | `)}let n=Array.isArray(e.type)?e.type[0]:e.type;return n===`string`?`string`:n===`number`||n===`integer`?`number`:n===`boolean`?`boolean`:n===`array`?`${Q(e.items,t)}[]`:n===`object`?ra(e,t):`unknown`},ta=e=>e.not!==void 0&&Object.keys(e.not).length===0,na=e=>{let t=e.properties??{},n=Object.values(t);return(Array.isArray(e.type)?e.type.includes(`object`):e.type===`object`)&&n.length>0&&n.every(ta)},ra=(e,t)=>{let n=e.properties??{},r=Object.entries(n);if(na(e))return`never`;if(r.length===0)return Xi;let i=new Set(e.required),a=` `.repeat(t),o=` `.repeat(t+2),s=[`{`];for(let[e,n]of r){let r=i.has(e)?``:`?`;s.push(`${o}${$i(e)}${r}: ${Q(n,t+2)};`)}return s.push(`${a}}`),s.join(`
|
|
60
|
+
`)},ia=e=>{let t=e.replaceAll(/[^A-Za-z0-9_$]/gu,`_`);return/^[A-Za-z_$]/u.test(t)?t:`_${t}`},aa=e=>`${ia(e)}Props`,oa=e=>{let t=ia(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`},sa=e=>{if(e.fields?.properties!==void 0)return e.fields.properties;let t={};for(let n of e.fieldKeys??[])t[n]={};return t},ca=(e,t)=>{if(e?.anyOf===void 0||e.anyOf.length!==2)return;let[n,r]=e.anyOf.filter(e=>!ta(e));if(n===void 0||r===void 0)return;let i,a;if(n.type===`object`?(i=r,a=n):r.type===`object`&&(i=n,a=r),i===void 0||a===void 0)return;let o=Q(i,t);if(o===`never`)return`never`;let s=Object.values(a.properties??{});if(s.length!==0&&!s.map(e=>Q(e,t)).some(e=>e!==o&&e!==`never`))return`Responsive<${o}>`},la=(e,t)=>ca(e,t)??Q(e,t),ua=e=>{let t={},n=new Map,r=new Set;for(let[i,a]of Object.entries(e))if(Zi.has(i))for(let[e,i]of Object.entries(sa(a))){let a=oa(e),o=la(i,0),s=n.get(a);if(s===void 0){n.set(a,o),t[e]=a;continue}s!==o&&r.add(a)}return Object.fromEntries(Object.entries(t).filter(([,e])=>!r.has(e)))},da=(e,t)=>{let n=[`export type Breakpoint = "base" | "sm" | "md" | "lg" | "xl" | "2xl";`,`export type Responsive<TValue> = TValue | Partial<Record<Breakpoint, TValue>>;`],r=new Set;for(let[i,a]of Object.entries(e))if(Zi.has(i))for(let[e,i]of Object.entries(sa(a))){let a=t[e];a===void 0||r.has(a)||(r.add(a),n.push(`export type ${a} = ${la(i,0)};`))}return n.join(`
|
|
61
|
+
`)},fa=e=>{let t=[`export interface ScreenPropsByPath {`];for(let[n,r]of Object.entries(e)){let e=Q(r.context,4).split(`
|
|
62
|
+
`);t.push(` ${Qi(n)}: {`),t.push(` context: ${e[0]}`);for(let n of e.slice(1,-1))t.push(n);let i=e.at(-1);i!==void 0&&e.length>1?t.push(`${i};`):t[t.length-1]=`${t.at(-1)};`,t.push(` };`)}return t.push(`}`),t.join(`
|
|
63
|
+
`)},pa=(e,t,n)=>{let r=aa(e),i=sa(t),a=t.callbacks??{},o=[`export interface ${r} {`];for(let[e,t]of Object.entries(i))o.push(` ${$i(e)}?: ${n[e]??la(t,2)};`);for(let[e,t]of Object.entries(a)){let n=t.input===void 0?``:`input: ${Q(t.input,2)}`;o.push(` ${$i(e)}?: (${n}) => void;`)}o.push(`}`),o.push(``);let s=Object.entries(a).map(([e,t])=>`${Qi(e)}: ${t.input===void 0?0:1}`),c=s.length>0?`,\n callbacks: { ${s.join(`, `)} }`:``;return o.push(`export const ${ia(e)} = /* @__PURE__ */ createRemoteComponent<${r}, ${t.children===!0}>(${Qi(e)}, {`),o.push(` children: ${t.children===!0}${c},`),o.push(`});`),o.join(`
|
|
64
|
+
`)},ma=e=>`input`in e||`output`in e,ha=(e,t=0)=>{let n=` `.repeat(t),r=` `.repeat(t+2),i=[`{`];for(let[n,a]of Object.entries(e))if(ma(a)){let e=Q(a.input,t+2),o=Q(a.output,t+2);i.push(`${r}${$i(n)}: (input: ${e}) => Promise<${o}>;`)}else{let e=ha(a,t+2).split(`
|
|
65
|
+
`);i.push(`${r}${$i(n)}: ${e[0]}`),i.push(...e.slice(1,-1)),i.push(`${e.at(-1)};`)}return i.push(`${n}}`),i.join(`
|
|
66
|
+
`)},ga=(e,t=[])=>{let n=[`{`];for(let[r,i]of Object.entries(e)){let e=[...t,r];if(ma(i))n.push(` ${$i(r)}: async (input: unknown) => {`),n.push(` const response = await fetch(${Qi(`/api/tailorkit/actions/${e.join(`.`)}`)}, {`),n.push(` body: JSON.stringify(input),`),n.push(` headers: { "content-type": "application/json" },`),n.push(` method: "POST",`),n.push(` });`),n.push(` if (!response.ok) throw new Error(await response.text());`),n.push(` return response.json();`),n.push(` },`);else{let t=ga(i,e).split(`
|
|
67
|
+
`);n.push(` ${$i(r)}: ${t[0]}`),n.push(...t.slice(1).map(e=>` ${e}`)),n.push(`,`)}}return n.push(`}`),n.join(`
|
|
68
|
+
`)},_a=e=>{let t=ha(e.actions??{}),n=e.components??{},r=ua(n),i=[Yi,fa(e.screens??{}),`declare module "tailorkit/app" {
|
|
69
69
|
interface TailorKitScreens extends ScreenPropsByPath {}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export type ScreenPath = keyof ScreenPropsByPath & string;
|
|
73
73
|
export type ScreenProps<TPath extends ScreenPath> = ScreenPropsByPath[TPath];
|
|
74
74
|
export type TailorKitActions = ${t};
|
|
75
|
-
export const actions = ${
|
|
75
|
+
export const actions = ${ga(e.actions??{})} as TailorKitActions;`,da(n,r)];for(let[e,t]of Object.entries(n)){let{children:n}=Hi.parse(t);i.push(pa(e,{...t,children:n},r))}return`${i.join(`
|
|
76
76
|
|
|
77
|
-
`)}\n`},
|
|
77
|
+
`)}\n`},va=(e,t)=>{let n=new URL(e);return n.pathname=`${n.pathname.replace(/\/$/u,``)}/${t.replace(/^\//u,``)}`,n.toString()},ya=async e=>{let t=va(e,`schema`),n=await fetch(t);if(!n.ok)throw Error(`Unable to fetch TailorKit schema from ${t}: ${n.statusText}`);return await n.json()},ba=async(e={})=>{let t=C.resolve(e.cwd??`.`),n=C.resolve(t,e.outFile??C.join(`src`,`tailorkit.gen.ts`)),r=_a(await ya((await V(e.configPath,t)).config.host));return await g(C.dirname(n),{recursive:!0}),await b(n,r,`utf-8`),n},xa=`{
|
|
78
78
|
"name": "{{ packageName }}",
|
|
79
79
|
"description": "A TailorKit.dev app that embeds in a host app to extend what it can do.",
|
|
80
80
|
"private": true,
|
|
@@ -103,7 +103,7 @@ export const actions = ${oa(e.actions??{})} as TailorKitActions;`,ta(n,r)];for(l
|
|
|
103
103
|
},
|
|
104
104
|
"type": "module"
|
|
105
105
|
}
|
|
106
|
-
`,
|
|
106
|
+
`,Sa=`{
|
|
107
107
|
"compilerOptions": {
|
|
108
108
|
"allowSyntheticDefaultImports": true,
|
|
109
109
|
"esModuleInterop": true,
|
|
@@ -120,7 +120,7 @@ export const actions = ${oa(e.actions??{})} as TailorKitActions;`,ta(n,r)];for(l
|
|
|
120
120
|
},
|
|
121
121
|
"include": ["src", "tailorkit.config.ts"]
|
|
122
122
|
}
|
|
123
|
-
`,
|
|
123
|
+
`,Ca=`import type { TailorKitConfig } from "tailorkit/app/config";
|
|
124
124
|
|
|
125
125
|
const config = {
|
|
126
126
|
host: "{{ hostUrl }}",
|
|
@@ -130,7 +130,7 @@ const config = {
|
|
|
130
130
|
} satisfies TailorKitConfig;
|
|
131
131
|
|
|
132
132
|
export default config;
|
|
133
|
-
`,
|
|
133
|
+
`,wa=`# TailorKit
|
|
134
134
|
.tailorkit
|
|
135
135
|
|
|
136
136
|
# Logs
|
|
@@ -163,17 +163,17 @@ CLAUDE.local.md
|
|
|
163
163
|
**/.idea
|
|
164
164
|
**/.#*
|
|
165
165
|
.nvmrc
|
|
166
|
-
`,
|
|
166
|
+
`,Ta=`import { defineConfig } from "oxlint";
|
|
167
167
|
|
|
168
168
|
export default defineConfig({
|
|
169
169
|
ignorePatterns: ["src/tailorkit.gen.ts"],
|
|
170
170
|
});
|
|
171
|
-
`,
|
|
171
|
+
`,Ea=`import { defineConfig } from "oxfmt";
|
|
172
172
|
|
|
173
173
|
export default defineConfig({
|
|
174
174
|
ignorePatterns: ["src/tailorkit.gen.ts"],
|
|
175
175
|
});
|
|
176
|
-
`,
|
|
176
|
+
`,Da=`import { defineClient } from "tailorkit/app";
|
|
177
177
|
import defaultScreen from "./screens/default";
|
|
178
178
|
|
|
179
179
|
const client = defineClient({
|
|
@@ -183,7 +183,7 @@ const client = defineClient({
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
export default client;
|
|
186
|
-
`,
|
|
186
|
+
`,Oa=`import { createScreen } from "tailorkit/app";
|
|
187
187
|
|
|
188
188
|
const screen = createScreen("/", {
|
|
189
189
|
component: ScreenComponent,
|
|
@@ -196,7 +196,7 @@ function ScreenComponent() {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
export default screen;
|
|
199
|
-
`,
|
|
199
|
+
`,ka=`/* eslint-disable */
|
|
200
200
|
|
|
201
201
|
// This file was automatically generated by TailorKit.
|
|
202
202
|
// Documentation: https://tailorkit.dev/docs
|
|
@@ -230,14 +230,14 @@ export interface ButtonProps {
|
|
|
230
230
|
onClick?: () => void;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
export const Button = createRemoteComponent<ButtonProps,
|
|
234
|
-
|
|
233
|
+
export const Button = createRemoteComponent<ButtonProps, true>("Button", {
|
|
234
|
+
children: true,
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
export interface CardProps {
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
export const Card = createRemoteComponent<CardProps,
|
|
241
|
-
|
|
240
|
+
export const Card = createRemoteComponent<CardProps, true>("Card", {
|
|
241
|
+
children: true,
|
|
242
242
|
});
|
|
243
|
-
`,ba=new oe({strictVariables:!0}),xa=(e,t)=>ba.parseAndRender(e,t),Sa=e=>g(e,{recursive:!0}).then(()=>{}),Ca=async(e,t,n)=>{if(!n&&ne(e))throw Error(`${e} already exists. Use --force to overwrite it.`);await b(e,t,`utf-8`)},wa=async e=>{let{targetDirectory:t,force:n,formatting:r,hostUrl:i,linting:a,packageName:o,packageVersions:s,useWorkspaceDependencies:c}=e,l=c?`workspace:*`:s.tailorkit,u=[],d=[];a&&(u.push(`pnpm run lint`),d.push(`pnpm run lint:fix`)),r&&(u.push(`pnpm run format`),d.push(`pnpm run format:fix`));let f={checkScript:u.join(` && `),fixScript:d.join(` && `),formatting:r,hostUrl:i,linting:a,oxfmtVersion:s.oxfmt,oxlintVersion:s.oxlint,packageName:o,preactVersion:s.preact,tailorkitVersion:l,typescriptVersion:s.typescript};await Sa(C.join(t,`src`,`screens`));let p=[{template:da,dest:`package.json`},{template:fa,dest:`tsconfig.json`},{template:pa,dest:`tailorkit.config.ts`},{template:ma,dest:`.gitignore`},{template:ha,dest:`oxlint.config.ts`,condition:a},{template:ga,dest:`oxfmt.config.ts`,condition:r},{template:_a,dest:C.join(`src`,`client.ts`)},{template:va,dest:C.join(`src`,`screens`,`default.tsx`)},{template:ya,dest:C.join(`src`,`tailorkit.gen.ts`)}];await Promise.all(p.filter(e=>e.condition!==!1).map(async({template:e,dest:r})=>{let i=await xa(e,f);await Ca(C.join(t,r),i,n)}))},Ta=`https://registry.npmjs.org`,Ea=5e3,Da={oxfmt:{fallback:`^0.46.0`,matcher:`^0`,packageName:`oxfmt`},oxlint:{fallback:`^1.61.0`,matcher:`^1`,packageName:`oxlint`},preact:{fallback:`^10.29.1`,matcher:`^10`,packageName:`preact`},tailorkit:{fallback:`latest`,matcher:`^0`,packageName:`tailorkit`},typescript:{fallback:`^6.0.3`,matcher:`^6`,packageName:`typescript`}},Oa=e=>{let t=/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$/u.exec(e);if(!t?.groups)return;let{major:n,minor:r,patch:i}=t.groups;if(!(!n||!r||!i))return{major:Number.parseInt(n,10),minor:Number.parseInt(r,10),patch:Number.parseInt(i,10),raw:e}},ka=(e,t)=>e.major===t.major?e.minor===t.minor?e.patch-t.patch:e.minor-t.minor:e.major-t.major,Aa=(e,t)=>{let n=/^\^(?<major>\d+)(?:\.(?<minor>\d+))?/u.exec(t);if(!n?.groups?.major)return!1;let r=Number.parseInt(n.groups.major,10),i=Number.parseInt(n.groups.minor??`0`,10);return e.major===r&&e.minor>=i},ja=async({fallback:e,matcher:t,packageName:n})=>{try{let r=await fetch(`${Ta}/${encodeURIComponent(n)}`,{signal:AbortSignal.timeout(Ea)});if(!r.ok)return e;let i=await r.json(),a=Object.keys(i.versions??{}).map(Oa).filter(e=>e!==void 0).filter(e=>Aa(e,t)).toSorted(ka).at(-1);return a?`^${a.raw}`:e}catch{return e}},Ma=async()=>{let[e,t,n,r,i]=await Promise.all([ja(Da.oxfmt),ja(Da.oxlint),ja(Da.preact),ja(Da.tailorkit),ja(Da.typescript)]);return{oxfmt:e,oxlint:t,preact:n,tailorkit:r,typescript:i}},Na=[`pnpm`,`yarn`,`npm`,`bun`],Pa=e=>Na.includes(e),Fa=e=>e.trim().toLowerCase().replaceAll(/[^a-z0-9._/-]+/gu,`-`).replaceAll(/^-+|-+$/gu,``),Ia=e=>(s(e)&&(i(`Init cancelled.`),process.exit(0)),e),La=(e,t)=>C.resolve(t,e??`.`),Ra=async(e,t)=>{let n=Fa(C.basename(t))||`tailorkit-app`;return Fa(e===void 0?Ia(await f({defaultValue:n,message:`Package name`,placeholder:n,validate:e=>Fa(e??``).length===0?`Enter a package name.`:void 0})):e)},za=async e=>{if(e!==void 0){if(Pa(e))return e;throw Error(`--package-manager must be one of: ${Na.join(`, `)}.`)}return Ia(await u({initialValue:`pnpm`,message:`Package manager`,options:Na.map(e=>({label:e,value:e}))}))},Ba=async e=>e===void 0?Ia(await a({initialValue:!0,message:`Add linting with oxlint?`})):e,Va=async e=>e===void 0?Ia(await a({initialValue:!0,message:`Add formatting with oxfmt?`})):e,Ha=e=>{try{ai(e??``);return}catch{return`Enter a valid host URL.`}},Ua=async e=>{if(e!==void 0){let t=Ha(e);if(t!==void 0)throw Error(t);return ai(e)}let t=`https://example.com/api/tailorkit`;return ai(Ia(await f({defaultValue:t,message:`Host URL`,placeholder:t,validate:Ha})))},Wa=async e=>e===void 0?Ia(await a({initialValue:!0,message:`Install dependencies?`})):e,Ga=async(e,t)=>t||!ne(e)?t:Ia(await a({initialValue:!1,message:`${m.cyan(e)} already exists. Overwrite matching files?`})),Ka=(e,t,n)=>new Promise((r,i)=>{let a=ae(e,t,{cwd:n,stdio:`inherit`});a.on(`close`,r),a.on(`error`,i)}),qa=async(e,t)=>{let n=d();n.start(`Installing dependencies with ${t}`);let r=await Ka(t,[`install`],e);if(r!==0)throw n.stop(`Install failed.`),Error(`${t} install exited with code ${r}.`);n.stop(`Installed dependencies.`)},Ja=async(e,t)=>{let n=d();n.start(`Formatting project`);let r=await Ka(t,[`run`,`format:fix`],e);if(r!==0)throw n.stop(`Formatting failed.`),Error(`${t} run format:fix exited with code ${r}.`);n.stop(`Formatted project.`)},Ya=async e=>{let t=La(e.directory,e.cwd),n=await Ra(e.name,t),r=C.join(t,n),i=await Ga(r,e.force??!1),a=await za(e.packageManager),o=await Ua(e.host),s=await Ba(e.linting),c=await Va(e.formatting),l=await Wa(e.install),u=d();u.start(`Resolving package versions`);let f=await Ma();return u.stop(`Resolved package versions.`),await g(r,{recursive:!0}),await wa({force:i,formatting:c,hostUrl:o,linting:s,packageName:n,packageVersions:f,targetDirectory:r}),l&&(await qa(r,a),c&&await Ja(r,a)),r},Xa={".css":`text/css; charset=utf-8`,".html":`text/html; charset=utf-8`,".js":`text/javascript; charset=utf-8`,".json":`application/json; charset=utf-8`,".map":`application/json; charset=utf-8`},Za=e=>Xa[C.extname(e)]??`application/octet-stream`,Qa=e=>{if(e===void 0)return;let t=Number.parseInt(String(e),10);if(!Number.isInteger(t)||t<=0)throw Error(`--port must be a positive integer.`);return t},$a=e=>({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,host:e.host,mode:e.mode,outDir:e.outDir,port:Qa(e.port)}),eo=(e,t)=>T(async(n,r)=>{try{let i=new URL(n.url??`/`,`http://localhost`);if(i.pathname===`/apps`){r.writeHead(200,{"access-control-allow-origin":`*`,"content-type":`application/json; charset=utf-8`}),r.end(JSON.stringify(t));return}let a=decodeURIComponent(i.pathname),o=a===`/`?`client.js`:a.slice(1),s=C.resolve(e,o),c=C.relative(e,s);if(c.startsWith(`..`)||C.isAbsolute(c)){r.writeHead(403),r.end(`Forbidden`);return}if(!(await y(s).catch(()=>null))?.isFile()){r.writeHead(404),r.end(`Not found`);return}r.writeHead(200,{"access-control-allow-origin":`*`,"content-type":Za(s)}),r.end(await _(s))}catch(e){r.writeHead(500),r.end(e instanceof Error?e.message:String(e))}}),to=async e=>{let t=C.join(e,`package.json`),n=JSON.parse(await _(t,`utf-8`)),r=typeof n.name==`string`?n.name:C.basename(e);return[{clientPath:`/client.js`,description:typeof n.description==`string`?n.description:void 0,id:r,name:typeof n.name==`string`?n.name:void 0}]},no=async e=>{let t=await B(e.configPath,e.cwd),n=C.resolve(t.root,e.outDir??t.config.build?.outDir??`.tailorkit`),r=e.host??`127.0.0.1`,i=e.port??4175,{buildApp:a}=await import(`./assets/builder-C5n1ZFm9.js`),o=await a({configPath:e.configPath,cwd:e.cwd,entry:e.entry,mode:e.mode,outDir:e.outDir,watch:!0}),s=()=>{o&&typeof o==`object`&&`close`in o&&o.close()},l=eo(n,await to(t.root));await new Promise((e,t)=>{l.once(`error`,t),l.listen(i,r,e)}),l.removeAllListeners(`error`),process.once(`SIGINT`,()=>{s(),l.close(),process.exit(0)}),process.once(`SIGTERM`,()=>{s(),l.close(),process.exit(0)}),c.info(m.green(`Experimental preview running at http://${r}:${i}`)),c.info(m.dim(`Serving built worker assets from ${n}`))},ro=e=>{let t=S();return t===`darwin`?{args:[e],command:`open`}:t===`win32`?{args:[`/c`,`start`,``,e],command:`cmd`}:{args:[e],command:`xdg-open`}},io=e=>new Promise(t=>{let{args:n,command:r}=ro(e),i=ae(r,n,{detached:!0,stdio:`ignore`,windowsHide:!0});i.once(`error`,()=>{t(!1)}),i.once(`spawn`,()=>{i.unref(),t(!0)})}),$=p(`tailorkit`),ao=e=>{if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=10?1:2)} ${t[r]}`};$.option(`--cwd <path>`,`Working directory`,{default:`.`}),$.command(`login`,`Authenticate the TailorKit CLI with a host app`).option(`--config <path>`,`Path to tailorkit config`).option(`--open`,`Open the approval URL in the default browser`,{default:!0}).option(`--timeout <seconds>`,`Seconds to wait for approval`,{default:1800}).action(async e=>{o(m.bold(`TailorKit`));let t=d(),n=!1;try{let r=Number.parseInt(String(e.timeout??`1800`),10);if(!Number.isInteger(r)||r<=0)throw Error(`--timeout must be a positive integer.`);await xi({configPath:e.config,cwd:String(e.cwd??`.`),timeout:r*1e3},({expiresAt:r,hostUrl:i,userCode:a})=>{let o=gi(i,a);e.open!==!1&&io(o),c.info(`Enter this code in the host app: ${m.bold(a)}`),c.info(`Approval URL: ${m.cyan(o)}`),c.info(`Code expires at ${r.toLocaleString()}.`),c.info(`Waiting for approval...`),t.start(`Checking approval status`),n=!0}),n&&t.stop(`Approved.`),l(`Authenticated successfully.`)}catch(e){n&&t.stop(`Approval failed.`),c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`logout`,`Remove stored TailorKit CLI credentials for a host app`).option(`--config <path>`,`Path to tailorkit config`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await Ci({configPath:e.config,cwd:String(e.cwd??`.`)});l(t.removed?`Logged out of ${m.cyan(t.hostUrl)}.`:`No stored credentials found for ${m.cyan(t.hostUrl)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`whoami`,`Show the current TailorKit CLI authentication scope`).option(`--config <path>`,`Path to tailorkit config`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await Si({configPath:e.config,cwd:String(e.cwd??`.`)});c.info(`Host: ${m.cyan(t.hostUrl)}`),c.info(`Scope: ${m.cyan(t.scopeId)}`),l(`Authenticated.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`deploy`,`Build and deploy the TailorKit app`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));let t=d();try{t.start(`Building and deploying app`);let n=await zi({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,mode:e.mode,onMissingAppId:async({appName:e,configPath:n,hostUrl:r,reason:i})=>{t.stop(`App not linked.`),c.info(i===`missing`?`No appId found in ${m.cyan(n)}.`:`The appId in ${m.cyan(n)} does not exist.`),c.info(`Host: ${m.cyan(r)}`);let o=await a({initialValue:!0,message:i===`missing`?`Create a TailorKit app named ${e}?`:`Create a new TailorKit app named ${e} and update the config?`});return!s(o)&&(o&&t.start(`Creating app and deploying`),o)},onTypecheckFailed:async({command:e,output:n})=>{t.stop(`Type check failed.`),c.error(`Type check failed while running ${m.cyan(e)}.`),n&&c.error(n);let r=await a({initialValue:!1,message:`Type check failed, but the app built successfully. Upload anyway?`});return!s(r)&&(r&&t.start(`Uploading app`),r)},outDir:e.outDir});t.stop(`Deployed app.`),n.createdApp&&c.info(`Created app and updated tailorkit.config.ts with ${m.cyan(n.appId)}.`),c.info(`Host: ${m.cyan(n.hostUrl)}`),c.info(`App: ${m.cyan(n.appId)}`),c.info(`Deployment: ${m.cyan(n.deploymentId)}`),c.info(`Uploaded files:`);for(let e of n.uploadedFiles)c.info(` ${m.cyan(e.path)} ${m.dim(`${ao(e.size)} raw, ${ao(e.gzipSize)} gzip`)}`);n.status&&c.info(`Status: ${m.cyan(n.status)}`),l(`Deployment published.`)}catch(e){t.stop(`Deployment failed.`),c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`build`,`Build the TailorKit app`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));try{let{buildApp:t}=await import(`./assets/builder-C5n1ZFm9.js`);await t({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,mode:e.mode,outDir:e.outDir}),l(`Built app.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`experimental-preview`,`Build and preview the TailorKit worker`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--host <host>`,`Preview host`).option(`--port <port>`,`Preview port`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));try{await no($a(e))}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`generate`,`Generate TailorKit app bindings`).option(`--config <path>`,`Path to tailorkit config`).option(`--out <path>`,`Generated TypeScript output file`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await ua({configPath:e.config,cwd:String(e.cwd??`.`),outFile:e.out});l(`Generated ${m.cyan(t)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`init [directory]`,`Create a new TailorKit app`).option(`--name <name>`,`Package name`).option(`--host <url>`,`TailorKit host URL`).option(`--package-manager <pm>`,`Package manager: bun, yarn, pnpm, or npm`).option(`--lint`,`Add oxlint (use --no-lint to skip)`).option(`--format`,`Add oxfmt (use --no-format to skip)`).option(`--install`,`Install dependencies after scaffolding (use --no-install to skip)`).option(`--force`,`Overwrite existing files`).action(async(e,t)=>{o(m.bold(`TailorKit`));try{let n=await Ya({cwd:String(t.cwd??`.`),directory:e,force:t.force,formatting:t.format,host:t.host,install:t.install,linting:t.lint,name:t.name,packageManager:t.packageManager});l(`Created app at ${m.cyan(n)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.help(),$.version(`0.1.0-beta.7`),$.parse();export{B as t};
|
|
243
|
+
`,Aa=new oe({strictVariables:!0}),ja=(e,t)=>Aa.parseAndRender(e,t),Ma=e=>g(e,{recursive:!0}).then(()=>{}),Na=async(e,t,n)=>{if(!n&&ne(e))throw Error(`${e} already exists. Use --force to overwrite it.`);await b(e,t,`utf-8`)},Pa=async e=>{let{targetDirectory:t,force:n,formatting:r,hostUrl:i,linting:a,packageName:o,packageVersions:s,useWorkspaceDependencies:c}=e,l=c?`workspace:*`:s.tailorkit,u=[],d=[];a&&(u.push(`pnpm run lint`),d.push(`pnpm run lint:fix`)),r&&(u.push(`pnpm run format`),d.push(`pnpm run format:fix`));let f={checkScript:u.join(` && `),fixScript:d.join(` && `),formatting:r,hostUrl:i,linting:a,oxfmtVersion:s.oxfmt,oxlintVersion:s.oxlint,packageName:o,preactVersion:s.preact,tailorkitVersion:l,typescriptVersion:s.typescript};await Ma(C.join(t,`src`,`screens`));let p=[{template:xa,dest:`package.json`},{template:Sa,dest:`tsconfig.json`},{template:Ca,dest:`tailorkit.config.ts`},{template:wa,dest:`.gitignore`},{template:Ta,dest:`oxlint.config.ts`,condition:a},{template:Ea,dest:`oxfmt.config.ts`,condition:r},{template:Da,dest:C.join(`src`,`client.ts`)},{template:Oa,dest:C.join(`src`,`screens`,`default.tsx`)},{template:ka,dest:C.join(`src`,`tailorkit.gen.ts`)}];await Promise.all(p.filter(e=>e.condition!==!1).map(async({template:e,dest:r})=>{let i=await ja(e,f);await Na(C.join(t,r),i,n)}))},Fa=`https://registry.npmjs.org`,Ia=5e3,La={oxfmt:{fallback:`^0.46.0`,matcher:`^0`,packageName:`oxfmt`},oxlint:{fallback:`^1.61.0`,matcher:`^1`,packageName:`oxlint`},preact:{fallback:`^10.29.1`,matcher:`^10`,packageName:`preact`},tailorkit:{fallback:`latest`,matcher:`^0`,packageName:`tailorkit`},typescript:{fallback:`^6.0.3`,matcher:`^6`,packageName:`typescript`}},Ra=e=>{let t=/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$/u.exec(e);if(!t?.groups)return;let{major:n,minor:r,patch:i}=t.groups;if(!(!n||!r||!i))return{major:Number.parseInt(n,10),minor:Number.parseInt(r,10),patch:Number.parseInt(i,10),raw:e}},za=(e,t)=>e.major===t.major?e.minor===t.minor?e.patch-t.patch:e.minor-t.minor:e.major-t.major,Ba=(e,t)=>{let n=/^\^(?<major>\d+)(?:\.(?<minor>\d+))?/u.exec(t);if(!n?.groups?.major)return!1;let r=Number.parseInt(n.groups.major,10),i=Number.parseInt(n.groups.minor??`0`,10);return e.major===r&&e.minor>=i},Va=async({fallback:e,matcher:t,packageName:n})=>{try{let r=await fetch(`${Fa}/${encodeURIComponent(n)}`,{signal:AbortSignal.timeout(Ia)});if(!r.ok)return e;let i=await r.json(),a=Object.keys(i.versions??{}).map(Ra).filter(e=>e!==void 0).filter(e=>Ba(e,t)).toSorted(za).at(-1);return a?`^${a.raw}`:e}catch{return e}},Ha=async()=>{let[e,t,n,r,i]=await Promise.all([Va(La.oxfmt),Va(La.oxlint),Va(La.preact),Va(La.tailorkit),Va(La.typescript)]);return{oxfmt:e,oxlint:t,preact:n,tailorkit:r,typescript:i}},Ua=[`pnpm`,`yarn`,`npm`,`bun`],Wa=e=>Ua.includes(e),Ga=e=>e.trim().toLowerCase().replaceAll(/[^a-z0-9._/-]+/gu,`-`).replaceAll(/^-+|-+$/gu,``),Ka=e=>(s(e)&&(i(`Init cancelled.`),process.exit(0)),e),qa=(e,t)=>C.resolve(t,e??`.`),Ja=async(e,t)=>{let n=Ga(C.basename(t))||`tailorkit-app`;return Ga(e===void 0?Ka(await f({defaultValue:n,message:`Package name`,placeholder:n,validate:e=>Ga(e??``).length===0?`Enter a package name.`:void 0})):e)},Ya=async e=>{if(e!==void 0){if(Wa(e))return e;throw Error(`--package-manager must be one of: ${Ua.join(`, `)}.`)}return Ka(await u({initialValue:`pnpm`,message:`Package manager`,options:Ua.map(e=>({label:e,value:e}))}))},Xa=async e=>e===void 0?Ka(await a({initialValue:!0,message:`Add linting with oxlint?`})):e,Za=async e=>e===void 0?Ka(await a({initialValue:!0,message:`Add formatting with oxfmt?`})):e,Qa=e=>{try{ai(e??``);return}catch{return`Enter a valid host URL.`}},$a=async e=>{if(e!==void 0){let t=Qa(e);if(t!==void 0)throw Error(t);return ai(e)}let t=`https://example.com/api/tailorkit`;return ai(Ka(await f({defaultValue:t,message:`Host URL`,placeholder:t,validate:Qa})))},eo=async e=>e===void 0?Ka(await a({initialValue:!0,message:`Install dependencies?`})):e,to=async(e,t)=>t||!ne(e)?t:Ka(await a({initialValue:!1,message:`${m.cyan(e)} already exists. Overwrite matching files?`})),no=(e,t,n)=>new Promise((r,i)=>{let a=ae(e,t,{cwd:n,stdio:`inherit`});a.on(`close`,r),a.on(`error`,i)}),ro=async(e,t)=>{let n=d();n.start(`Installing dependencies with ${t}`);let r=await no(t,[`install`],e);if(r!==0)throw n.stop(`Install failed.`),Error(`${t} install exited with code ${r}.`);n.stop(`Installed dependencies.`)},io=async(e,t)=>{let n=d();n.start(`Formatting project`);let r=await no(t,[`run`,`format:fix`],e);if(r!==0)throw n.stop(`Formatting failed.`),Error(`${t} run format:fix exited with code ${r}.`);n.stop(`Formatted project.`)},ao=async e=>{let t=qa(e.directory,e.cwd),n=await Ja(e.name,t),r=C.join(t,n),i=await to(r,e.force??!1),a=await Ya(e.packageManager),o=await $a(e.host),s=await Xa(e.linting),c=await Za(e.formatting),l=await eo(e.install),u=d();u.start(`Resolving package versions`);let f=await Ha();return u.stop(`Resolved package versions.`),await g(r,{recursive:!0}),await Pa({force:i,formatting:c,hostUrl:o,linting:s,packageName:n,packageVersions:f,targetDirectory:r}),l&&(await ro(r,a),c&&await io(r,a)),r},oo={".css":`text/css; charset=utf-8`,".html":`text/html; charset=utf-8`,".js":`text/javascript; charset=utf-8`,".json":`application/json; charset=utf-8`,".map":`application/json; charset=utf-8`},so=e=>oo[C.extname(e)]??`application/octet-stream`,co=e=>{if(e===void 0)return;let t=Number.parseInt(String(e),10);if(!Number.isInteger(t)||t<=0)throw Error(`--port must be a positive integer.`);return t},lo=e=>({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,host:e.host,mode:e.mode,outDir:e.outDir,port:co(e.port)}),uo=(e,t)=>T(async(n,r)=>{try{let i=new URL(n.url??`/`,`http://localhost`);if(i.pathname===`/apps`){r.writeHead(200,{"access-control-allow-origin":`*`,"content-type":`application/json; charset=utf-8`}),r.end(JSON.stringify(t));return}let a=decodeURIComponent(i.pathname),o=a===`/`?`client.js`:a.slice(1),s=C.resolve(e,o),c=C.relative(e,s);if(c.startsWith(`..`)||C.isAbsolute(c)){r.writeHead(403),r.end(`Forbidden`);return}if(!(await y(s).catch(()=>null))?.isFile()){r.writeHead(404),r.end(`Not found`);return}r.writeHead(200,{"access-control-allow-origin":`*`,"content-type":so(s)}),r.end(await _(s))}catch(e){r.writeHead(500),r.end(e instanceof Error?e.message:String(e))}}),fo=async e=>{let t=C.join(e,`package.json`),n=JSON.parse(await _(t,`utf-8`)),r=typeof n.name==`string`?n.name:C.basename(e);return[{clientPath:`/client.js`,description:typeof n.description==`string`?n.description:void 0,id:r,name:typeof n.name==`string`?n.name:void 0}]},po=async e=>{let t=await V(e.configPath,e.cwd),n=C.resolve(t.root,e.outDir??t.config.build?.outDir??`.tailorkit`),r=e.host??`127.0.0.1`,i=e.port??4175,{buildApp:a}=await import(`./assets/builder-D5o0m6gu.js`),o=await a({configPath:e.configPath,cwd:e.cwd,entry:e.entry,mode:e.mode,outDir:e.outDir,watch:!0}),s=()=>{o&&typeof o==`object`&&`close`in o&&o.close()},l=uo(n,await fo(t.root));await new Promise((e,t)=>{l.once(`error`,t),l.listen(i,r,e)}),l.removeAllListeners(`error`),process.once(`SIGINT`,()=>{s(),l.close(),process.exit(0)}),process.once(`SIGTERM`,()=>{s(),l.close(),process.exit(0)}),c.info(m.green(`Experimental preview running at http://${r}:${i}`)),c.info(m.dim(`Serving built app client from ${n}`))},mo=e=>{let t=S();return t===`darwin`?{args:[e],command:`open`}:t===`win32`?{args:[`/c`,`start`,``,e],command:`cmd`}:{args:[e],command:`xdg-open`}},ho=e=>new Promise(t=>{let{args:n,command:r}=mo(e),i=ae(r,n,{detached:!0,stdio:`ignore`,windowsHide:!0});i.once(`error`,()=>{t(!1)}),i.once(`spawn`,()=>{i.unref(),t(!0)})}),$=p(`tailorkit`),go=e=>{if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(n>=10?1:2)} ${t[r]}`};$.option(`--cwd <path>`,`Working directory`,{default:`.`}),$.command(`login`,`Authenticate the TailorKit CLI with a host app`).option(`--config <path>`,`Path to tailorkit config`).option(`--open`,`Open the approval URL in the default browser`,{default:!0}).option(`--timeout <seconds>`,`Seconds to wait for approval`,{default:1800}).action(async e=>{o(m.bold(`TailorKit`));let t=d(),n=!1;try{let r=Number.parseInt(String(e.timeout??`1800`),10);if(!Number.isInteger(r)||r<=0)throw Error(`--timeout must be a positive integer.`);await xi({configPath:e.config,cwd:String(e.cwd??`.`),timeout:r*1e3},({expiresAt:r,hostUrl:i,userCode:a})=>{let o=gi(i,a);e.open!==!1&&ho(o),c.info(`Enter this code in the host app: ${m.bold(a)}`),c.info(`Approval URL: ${m.cyan(o)}`),c.info(`Code expires at ${r.toLocaleString()}.`),c.info(`Waiting for approval...`),t.start(`Checking approval status`),n=!0}),n&&t.stop(`Approved.`),l(`Authenticated successfully.`)}catch(e){n&&t.stop(`Approval failed.`),c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`logout`,`Remove stored TailorKit CLI credentials for a host app`).option(`--config <path>`,`Path to tailorkit config`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await Ci({configPath:e.config,cwd:String(e.cwd??`.`)});l(t.removed?`Logged out of ${m.cyan(t.hostUrl)}.`:`No stored credentials found for ${m.cyan(t.hostUrl)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`whoami`,`Show the current TailorKit CLI authentication scope`).option(`--config <path>`,`Path to tailorkit config`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await Si({configPath:e.config,cwd:String(e.cwd??`.`)});c.info(`Host: ${m.cyan(t.hostUrl)}`),c.info(`Scope: ${m.cyan(t.scopeId)}`),l(`Authenticated.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`deploy`,`Build and deploy the TailorKit app`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));let t=d();try{t.start(`Building and deploying app`);let n=await zi({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,mode:e.mode,onMissingAppId:async({appName:e,configPath:n,hostUrl:r,reason:i})=>{t.stop(`App not linked.`),c.info(i===`missing`?`No appId found in ${m.cyan(n)}.`:`The appId in ${m.cyan(n)} does not exist.`),c.info(`Host: ${m.cyan(r)}`);let o=await a({initialValue:!0,message:i===`missing`?`Create a TailorKit app named ${e}?`:`Create a new TailorKit app named ${e} and update the config?`});return!s(o)&&(o&&t.start(`Creating app and deploying`),o)},onTypecheckFailed:async({command:e,output:n})=>{t.stop(`Type check failed.`),c.error(`Type check failed while running ${m.cyan(e)}.`),n&&c.error(n);let r=await a({initialValue:!1,message:`Type check failed, but the app built successfully. Upload anyway?`});return!s(r)&&(r&&t.start(`Uploading app`),r)},outDir:e.outDir});t.stop(`Deployed app.`),n.createdApp&&c.info(`Created app and updated tailorkit.config.ts with ${m.cyan(n.appId)}.`),c.info(`Host: ${m.cyan(n.hostUrl)}`),c.info(`App: ${m.cyan(n.appId)}`),c.info(`Deployment: ${m.cyan(n.deploymentId)}`),c.info(`Uploaded files:`);for(let e of n.uploadedFiles)c.info(` ${m.cyan(e.path)} ${m.dim(`${go(e.size)} raw, ${go(e.gzipSize)} gzip`)}`);n.status&&c.info(`Status: ${m.cyan(n.status)}`),l(`Deployment published.`)}catch(e){t.stop(`Deployment failed.`),c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`build`,`Build the TailorKit app`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));try{let{buildApp:t}=await import(`./assets/builder-D5o0m6gu.js`);await t({configPath:e.config,cwd:String(e.cwd??`.`),entry:e.entry,mode:e.mode,outDir:e.outDir}),l(`Built app.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`experimental-preview`,`Build and preview the TailorKit app`).option(`--config <path>`,`Path to tailorkit config`).option(`--entry <path>`,`Client entry file`).option(`--out-dir <path>`,`Build output directory`).option(`--host <host>`,`Preview host`).option(`--port <port>`,`Preview port`).option(`--mode <mode>`,`Vite mode`).action(async e=>{o(m.bold(`TailorKit`));try{await po(lo(e))}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`generate`,`Generate TailorKit app bindings`).option(`--config <path>`,`Path to tailorkit config`).option(`--out <path>`,`Generated TypeScript output file`).action(async e=>{o(m.bold(`TailorKit`));try{let t=await ba({configPath:e.config,cwd:String(e.cwd??`.`),outFile:e.out});l(`Generated ${m.cyan(t)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.command(`init [directory]`,`Create a new TailorKit app`).option(`--name <name>`,`Package name`).option(`--host <url>`,`TailorKit host URL`).option(`--package-manager <pm>`,`Package manager: bun, yarn, pnpm, or npm`).option(`--lint`,`Add oxlint (use --no-lint to skip)`).option(`--format`,`Add oxfmt (use --no-format to skip)`).option(`--install`,`Install dependencies after scaffolding (use --no-install to skip)`).option(`--force`,`Overwrite existing files`).action(async(e,t)=>{o(m.bold(`TailorKit`));try{let n=await ao({cwd:String(t.cwd??`.`),directory:e,force:t.force,formatting:t.format,host:t.host,install:t.install,linting:t.lint,name:t.name,packageManager:t.packageManager});l(`Created app at ${m.cyan(n)}.`)}catch(e){c.error(e instanceof Error?e.message:String(e)),process.exit(1)}}),$.help(),$.version(`0.1.0-beta.8`),$.parse();export{V as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.8",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@clack/prompts": "^1.7.0",
|
|
26
|
-
"@tailorkit/app": "0.1.0-beta.
|
|
27
|
-
"@tailorkit/core": "0.1.0-beta.
|
|
26
|
+
"@tailorkit/app": "0.1.0-beta.8",
|
|
27
|
+
"@tailorkit/core": "0.1.0-beta.8",
|
|
28
28
|
"cac": "^7.0.0",
|
|
29
29
|
"liquidjs": "^10.29.0",
|
|
30
30
|
"picocolors": "^1.1.1",
|