commitsmile
Version:
Make smile on your commits
62 lines (58 loc) • 13.4 kB
JavaScript
import {createRequire}from'node:module';import {c as c$1,a,b as b$1}from'./chunk-3WSMN7T6.mjs';import {b,k as k$1}from'./chunk-G5RJVSXQ.mjs';createRequire(import.meta.url);
function B(t,e){let r=t.slice(0,e).split(/\r\n|\n|\r/g);return [r.length,r.pop().length+1]}function G(t,e,r){let i=t.split(/\r\n|\n|\r/g),n="",l=(Math.log10(e+1)|0)+1;for(let o=e-1;o<=e+1;o++){let a=i[o-1];a&&(n+=o.toString().padEnd(l," "),n+=": ",n+=a,n+=`
`,o===e&&(n+=" ".repeat(l+r+2),n+=`^
`));}return n}function v(t,e=0,r=t.length){let i=t.indexOf(`
`,e);return t[i-1]==="\r"&&i--,i<=r?i:-1}function $(t,e){for(let r=e;r<t.length;r++){let i=t[r];if(i===`
`)return r;if(i==="\r"&&t[r+1]===`
`)return r+1;if(i<" "&&i!==" "||i==="\x7F")throw new s("control characters are not allowed in comments",{toml:t,ptr:e})}return t.length}function m(t,e,r,i){let n;for(;(n=t[e])===" "||n===" "||!r&&(n===`
`||n==="\r"&&t[e+1]===`
`);)e++;return i||n!=="#"?e:m(t,$(t,e),r)}function L(t,e,r,i,n=!1){if(!i)return e=v(t,e),e<0?t.length:e;for(let l=e;l<t.length;l++){let o=t[l];if(o==="#")l=v(t,l);else {if(o===r)return l+1;if(o===i||n&&(o===`
`||o==="\r"&&t[l+1]===`
`))return l}}throw new s("cannot find end of structure",{toml:t,ptr:e})}function P(t,e){let r=t[e],i=r===t[e+1]&&t[e+1]===t[e+2]?t.slice(e,e+3):r;e+=i.length-1;do e=t.indexOf(i,++e);while(e>-1&&r!=="'"&&t[e-1]==="\\"&&t[e-2]!=="\\");return e>-1&&(e+=i.length,i.length>1&&(t[e]===r&&e++,t[e]===r&&e++)),e}function C(t,e=0,r=t.length){let i=t[e]==="'",n=t[e++]===t[e]&&t[e]===t[e+1];n&&(r-=2,t[e+=2]==="\r"&&e++,t[e]===`
`&&e++);let l=0,o,a="",f=e;for(;e<r-1;){let u=t[e++];if(u===`
`||u==="\r"&&t[e]===`
`){if(!n)throw new s("newlines are not allowed in strings",{toml:t,ptr:e-1})}else if(u<" "&&u!==" "||u==="\x7F")throw new s("control characters are not allowed in strings",{toml:t,ptr:e-1});if(o){if(o=!1,u==="u"||u==="U"){let g=t.slice(e,e+=u==="u"?4:8);if(!tt.test(g))throw new s("invalid unicode escape",{toml:t,ptr:l});try{a+=String.fromCodePoint(parseInt(g,16));}catch{throw new s("invalid unicode escape",{toml:t,ptr:l})}}else if(n&&(u===`
`||u===" "||u===" "||u==="\r")){if(e=m(t,e-1,!0),t[e]!==`
`&&t[e]!=="\r")throw new s("invalid escape: only line-ending whitespace may be escaped",{toml:t,ptr:l});e=m(t,e);}else if(u in M)a+=M[u];else throw new s("unrecognized escape sequence",{toml:t,ptr:l});f=e;}else !i&&u==="\\"&&(l=e-1,o=!0,a+=t.slice(f,l));}return a+t.slice(f,r-1)}function et(t,e,r){if(t==="true")return !0;if(t==="false")return !1;if(t==="-inf")return -1/0;if(t==="inf"||t==="+inf")return 1/0;if(t==="nan"||t==="+nan"||t==="-nan")return NaN;if(t==="-0")return 0;let i;if((i=R.test(t))||X.test(t)){if(Y.test(t))throw new s("leading zeroes are not allowed",{toml:e,ptr:r});let l=+t.replace(/_/g,"");if(isNaN(l))throw new s("invalid number",{toml:e,ptr:r});if(i&&!Number.isSafeInteger(l))throw new s("integer value cannot be represented losslessly",{toml:e,ptr:r});return l}let n=new Q(t);if(!n.isValid())throw new s("invalid value",{toml:e,ptr:r});return n}function rt(t,e,r,i){let n=t.slice(e,r),l=n.indexOf("#");l>-1&&($(t,l),n=n.slice(0,l));let o=n.trimEnd();if(!i){let a=n.indexOf(`
`,o.length);if(a>-1)throw new s("newlines are not allowed in inline tables",{toml:t,ptr:e+a})}return [o,l]}function S(t,e,r){let i=t[e];if(i==="["||i==="{"){let[o,a]=i==="["?lt(t,e):nt(t,e),f=L(t,a,",",r);if(r==="}"){let u=v(t,a,f);if(u>-1)throw new s("newlines are not allowed in inline tables",{toml:t,ptr:u})}return [o,f]}let n;if(i==='"'||i==="'"){n=P(t,e);let o=C(t,e,n);if(r){if(n=m(t,n,r!=="]"),t[n]&&t[n]!==","&&t[n]!==r&&t[n]!==`
`&&t[n]!=="\r")throw new s("unexpected character encountered",{toml:t,ptr:n});n+=+(t[n]===",");}return [o,n]}n=L(t,e,",",r);let l=rt(t,e,n-+(t[n-1]===","),r==="]");if(!l[0])throw new s("incomplete key-value declaration: no value specified",{toml:t,ptr:e});return r&&l[1]>-1&&(n=m(t,e+l[1]),n+=+(t[n]===",")),[et(l[0],t,e),n]}function k(t,e,r="="){let i=e-1,n=[],l=t.indexOf(r,e);if(l<0)throw new s("incomplete key-value: cannot find end of key",{toml:t,ptr:e});do{let o=t[e=++i];if(o!==" "&&o!==" ")if(o==='"'||o==="'"){if(o===t[e+1]&&o===t[e+2])throw new s("multiline strings are not allowed in keys",{toml:t,ptr:e});let a=P(t,e);if(a<0)throw new s("unfinished string encountered",{toml:t,ptr:e});i=t.indexOf(".",a);let f=t.slice(a,i<0||i>l?l:i),u=v(f);if(u>-1)throw new s("newlines are not allowed in keys",{toml:t,ptr:e+i+u});if(f.trimStart())throw new s("found extra tokens after the string part",{toml:t,ptr:a});if(l<a&&(l=t.indexOf(r,a),l<0))throw new s("incomplete key-value: cannot find end of key",{toml:t,ptr:e});n.push(C(t,e,a));}else {i=t.indexOf(".",e);let a=t.slice(e,i<0||i>l?l:i);if(!it.test(a))throw new s("only letter, numbers, dashes and underscores are allowed in keys",{toml:t,ptr:e});n.push(a.trimEnd());}}while(i+1&&i<l);return [n,m(t,l+1,!0,!0)]}function nt(t,e){let r={},i=new Set,n,l=0;for(e++;(n=t[e++])!=="}"&&n;){if(n===`
`)throw new s("newlines are not allowed in inline tables",{toml:t,ptr:e-1});if(n==="#")throw new s("inline tables cannot contain comments",{toml:t,ptr:e-1});if(n===",")throw new s("expected key-value, found comma",{toml:t,ptr:e-1});if(n!==" "&&n!==" "){let o,a=r,f=!1,[u,g]=k(t,e-1);for(let y=0;y<u.length;y++){if(y&&(a=f?a[o]:a[o]={}),o=u[y],(f=Object.hasOwn(a,o))&&(typeof a[o]!="object"||i.has(a[o])))throw new s("trying to redefine an already defined value",{toml:t,ptr:e});!f&&o==="__proto__"&&Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0});}if(f)throw new s("trying to redefine an already defined value",{toml:t,ptr:e});let[E,W]=S(t,g,"}");i.add(E),a[o]=E,e=W,l=t[e-1]===","?e-1:0;}}if(l)throw new s("trailing commas are not allowed in inline tables",{toml:t,ptr:l});if(!n)throw new s("unfinished table encountered",{toml:t,ptr:e});return [r,e]}function lt(t,e){let r=[],i;for(e++;(i=t[e++])!=="]"&&i;){if(i===",")throw new s("expected value, found comma",{toml:t,ptr:e-1});if(i==="#")e=$(t,e);else if(i!==" "&&i!==" "&&i!==`
`&&i!=="\r"){let n=S(t,e-1,"]");r.push(n[0]),e=n[1];}}if(!i)throw new s("unfinished array encountered",{toml:t,ptr:e});return [r,e]}function z(t,e,r,i){let n=e,l=r,o,a=!1,f;for(let u=0;u<t.length;u++){if(u){if(n=a?n[o]:n[o]={},l=(f=l[o]).c,i===0&&(f.t===1||f.t===2))return null;if(f.t===2){let g=n.length-1;n=n[g],l=l[g].c;}}if(o=t[u],(a=Object.hasOwn(n,o))&&l[o]?.t===0&&l[o]?.d)return null;a||(o==="__proto__"&&(Object.defineProperty(n,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(l,o,{enumerable:!0,configurable:!0,writable:!0})),l[o]={t:u<t.length-1&&i===2?3:i,d:!1,i:0,c:{}});}if(f=l[o],f.t!==i&&!(i===1&&f.t===3)||(i===2&&(f.d||(f.d=!0,n[o]=[]),n[o].push(n={}),f.c[f.i++]=f={t:1,d:!1,i:0,c:{}}),f.d))return null;if(f.d=!0,i===1)n=a?n[o]:n[o]={};else if(i===0&&a)return null;return [o,n,f.c]}function ot(t){let e={},r={},i=e,n=r;for(let l=m(t,0);l<t.length;){if(t[l]==="["){let o=t[++l]==="[",a=k(t,l+=+o,"]");if(o){if(t[a[1]-1]!=="]")throw new s("expected end of table declaration",{toml:t,ptr:a[1]-1});a[1]++;}let f=z(a[0],e,r,o?2:1);if(!f)throw new s("trying to redefine an already defined table or value",{toml:t,ptr:l});n=f[2],i=f[1],l=a[1];}else {let o=k(t,l),a=z(o[0],i,n,0);if(!a)throw new s("trying to redefine an already defined table or value",{toml:t,ptr:l});let f=S(t,o[1]);a[1][a[0]]=f[0],l=f[1];}if(l=m(t,l,!0),t[l]&&t[l]!==`
`&&t[l]!=="\r")throw new s("each key-value declaration must be followed by an end-of-line",{toml:t,ptr:l});l=m(t,l);}return e}function O(t){let e=typeof t;if(e==="object"){if(Array.isArray(t))return "array";if(t instanceof Date)return "date"}return e}function at(t){for(let e=0;e<t.length;e++)if(O(t[e])!=="object")return !1;return t.length!=0}function j(t){return JSON.stringify(t).replace(/\x7f/g,"\\u007f")}function _(t,e=O(t)){if(e==="number")return isNaN(t)?"nan":t===1/0?"inf":t===-1/0?"-inf":t.toString();if(e==="bigint"||e==="boolean")return t.toString();if(e==="string")return j(t);if(e==="date"){if(isNaN(t.getTime()))throw new TypeError("cannot serialize invalid date");return t.toISOString()}if(e==="object")return ft(t);if(e==="array")return st(t)}function ft(t){let e=Object.keys(t);if(e.length===0)return "{}";let r="{ ";for(let i=0;i<e.length;i++){let n=e[i];i&&(r+=", "),r+=F.test(n)?n:j(n),r+=" = ",r+=_(t[n]);}return r+" }"}function st(t){if(t.length===0)return "[]";let e="[ ";for(let r=0;r<t.length;r++){if(r&&(e+=", "),t[r]===null||t[r]===void 0)throw new TypeError("arrays cannot contain null or undefined values");e+=_(t[r]);}return e+" ]"}function ut(t,e){let r="";for(let i=0;i<t.length;i++)r+=`[[${e}]]
`,r+=N(t[i],e),r+=`
`;return r}function N(t,e=""){let r="",i="",n=Object.keys(t);for(let l=0;l<n.length;l++){let o=n[l];if(t[o]!==null&&t[o]!==void 0){let a=O(t[o]);if(a==="symbol"||a==="function")throw new TypeError(`cannot serialize values of type '${a}'`);let f=F.test(o)?o:j(o);if(a==="array"&&at(t[o]))i+=ut(t[o],e?`${e}.${f}`:f);else if(a==="object"){let u=e?`${e}.${f}`:f;i+=`[${u}]
`,i+=N(t[o],u),i+=`
`;}else r+=f,r+=" = ",r+=_(t[o],a),r+=`
`;}}return `${r}
${i}`.trim()}function ct(t){if(O(t)!=="object")throw new TypeError("stringify can only be called with an object");return N(t)}function mt(t){let e=ot(t);return a(t,e,{preserveIndentation:!1}),e}function gt(t){let e=b$1(t,{preserveIndentation:!1}),r=ct(t);return e.whitespace.start+r+e.whitespace.end}var q,J,x,Z,c,T,h,w,p,d,s,H,K,Q,R,X,Y,tt,M,it,F,dt=b(()=>{k$1();c$1();q=Object.defineProperty,J=(t,e,r)=>e in t?q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x=(t,e,r)=>(J(t,typeof e!="symbol"?e+"":e,r),r),Z=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},c=(t,e,r)=>(Z(t,e,"read from private field"),r?r.call(t):e.get(t)),T=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r);},h=(t,e,r,i)=>(Z(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);s=class extends Error{constructor(e,r){let[i,n]=B(r.toml,r.ptr),l=G(r.toml,i,n);super(`Invalid TOML document: ${e}
${l}`,r),x(this,"line"),x(this,"column"),x(this,"codeblock"),this.line=i,this.column=n,this.codeblock=l;}};H=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i,K=class b extends Date{constructor(e){let r=!0,i=!0,n="Z";if(typeof e=="string"){let l=e.match(H);l?(l[1]||(r=!1,e=`0000-01-01T${e}`),i=!!l[2],l[2]&&+l[2]>23?e="":(n=l[3]||null,e=e.toUpperCase(),!n&&i&&(e+="Z"))):e="";}super(e),T(this,w,!1),T(this,p,!1),T(this,d,null),isNaN(this.getTime())||(h(this,w,r),h(this,p,i),h(this,d,n));}isDateTime(){return c(this,w)&&c(this,p)}isLocal(){return !c(this,w)||!c(this,p)||!c(this,d)}isDate(){return c(this,w)&&!c(this,p)}isTime(){return c(this,p)&&!c(this,w)}isValid(){return c(this,w)||c(this,p)}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(c(this,d)===null)return e.slice(0,-1);if(c(this,d)==="Z")return e;let r=+c(this,d).slice(1,3)*60+ +c(this,d).slice(4,6);return r=c(this,d)[0]==="-"?r:-r,new Date(this.getTime()-r*6e4).toISOString().slice(0,-1)+c(this,d)}static wrapAsOffsetDateTime(e,r="Z"){let i=new b(e);return h(i,d,r),i}static wrapAsLocalDateTime(e){let r=new b(e);return h(r,d,null),r}static wrapAsLocalDate(e){let r=new b(e);return h(r,p,!1),h(r,d,null),r}static wrapAsLocalTime(e){let r=new b(e);return h(r,w,!1),h(r,d,null),r}};w=new WeakMap,p=new WeakMap,d=new WeakMap;Q=K;R=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,X=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Y=/^[+-]?0[0-9_]/,tt=/^[0-9a-f]{4,8}$/i,M={b:"\b",t:" ",n:`
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};it=/^[a-zA-Z0-9-_]+[ \t]*$/;F=/^[a-z0-9-_]+$/i;});/*! Bundled license information:
confbox/dist/toml.mjs:
(*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
*/export{mt as a,gt as b,dt as c};