lone-format 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -3
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +1668 -1159
- package/dist/lone-format.umd.cjs +8 -8
- package/package.json +4 -2
- package/dist/src/components/JsonFormat/JsonNode.vue.d.ts +0 -65
- package/dist/src/components/JsonFormat/index.vue.d.ts +0 -56
- package/dist/src/components/JsonFormat/types.d.ts +0 -36
- package/dist/src/components/index.d.ts +0 -2
- package/dist/src/index.d.ts +0 -6
package/dist/lone-format.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(fe,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(fe=typeof globalThis<"u"?globalThis:fe||self,p(fe.LoneFormat={},fe.Vue))})(this,function(fe,p){"use strict";function Ie(z){return z&&z.__esModule&&Object.prototype.hasOwnProperty.call(z,"default")?z.default:z}var de={exports:{}},ye={exports:{}},ge={exports:{}},Te=ge.exports,Ae;function Oe(){return Ae||(Ae=1,function(z){(function(Z){var E,te=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,O=Math.ceil,j=Math.floor,V="[BigNumber Error] ",_=V+"Number primitive has more than 15 significant digits: ",D=1e14,w=14,F=9007199254740991,v=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],T=1e7,P=1e9;function H(S){var B,L,g,u=y.prototype={constructor:y,toString:null,valueOf:null},N=new y(1),k=20,d=4,m=-7,M=21,q=-1e7,X=1e7,re=!1,ae=1,ue=0,ke={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},pe="0123456789abcdefghijklmnopqrstuvwxyz",Ne=!0;function y(e,t){var n,a,o,s,f,r,i,c,l=this;if(!(l instanceof y))return new y(e,t);if(t==null){if(e&&e._isBigNumber===!0){l.s=e.s,!e.c||e.e>X?l.c=l.e=null:e.e<q?l.c=[l.e=0]:(l.e=e.e,l.c=e.c.slice());return}if((r=typeof e=="number")&&e*0==0){if(l.s=1/e<0?(e=-e,-1):1,e===~~e){for(s=0,f=e;f>=10;f/=10,s++);s>X?l.c=l.e=null:(l.e=s,l.c=[e]);return}c=String(e)}else{if(!te.test(c=String(e)))return g(l,c,r);l.s=c.charCodeAt(0)==45?(c=c.slice(1),-1):1}(s=c.indexOf("."))>-1&&(c=c.replace(".","")),(f=c.search(/e/i))>0?(s<0&&(s=f),s+=+c.slice(f+1),c=c.substring(0,f)):s<0&&(s=c.length)}else{if(x(t,2,pe.length,"Base"),t==10&&Ne)return l=new y(e),ie(l,k+l.e+1,d);if(c=String(e),r=typeof e=="number"){if(e*0!=0)return g(l,c,r,t);if(l.s=1/e<0?(c=c.slice(1),-1):1,y.DEBUG&&c.replace(/^0\.0*|\./,"").length>15)throw Error(_+e)}else l.s=c.charCodeAt(0)===45?(c=c.slice(1),-1):1;for(n=pe.slice(0,t),s=f=0,i=c.length;f<i;f++)if(n.indexOf(a=c.charAt(f))<0){if(a=="."){if(f>s){s=i;continue}}else if(!o&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){o=!0,f=-1,s=0;continue}return g(l,String(e),r,t)}r=!1,c=L(c,t,10,l.s),(s=c.indexOf("."))>-1?c=c.replace(".",""):s=c.length}for(f=0;c.charCodeAt(f)===48;f++);for(i=c.length;c.charCodeAt(--i)===48;);if(c=c.slice(f,++i)){if(i-=f,r&&y.DEBUG&&i>15&&(e>F||e!==j(e)))throw Error(_+l.s*e);if((s=s-f-1)>X)l.c=l.e=null;else if(s<q)l.c=[l.e=0];else{if(l.e=s,l.c=[],f=(s+1)%w,s<0&&(f+=w),f<i){for(f&&l.c.push(+c.slice(0,f)),i-=w;f<i;)l.c.push(+c.slice(f,f+=w));f=w-(c=c.slice(f)).length}else f-=i;for(;f--;c+="0");l.c.push(+c)}}else l.c=[l.e=0]}y.clone=H,y.ROUND_UP=0,y.ROUND_DOWN=1,y.ROUND_CEIL=2,y.ROUND_FLOOR=3,y.ROUND_HALF_UP=4,y.ROUND_HALF_DOWN=5,y.ROUND_HALF_EVEN=6,y.ROUND_HALF_CEIL=7,y.ROUND_HALF_FLOOR=8,y.EUCLID=9,y.config=y.set=function(e){var t,n;if(e!=null)if(typeof e=="object"){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(n=e[t],x(n,0,P,t),k=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(n=e[t],x(n,0,8,t),d=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(n=e[t],n&&n.pop?(x(n[0],-P,0,t),x(n[1],0,P,t),m=n[0],M=n[1]):(x(n,-P,P,t),m=-(M=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if(n=e[t],n&&n.pop)x(n[0],-P,-1,t),x(n[1],1,P,t),q=n[0],X=n[1];else if(x(n,-P,P,t),n)q=-(X=n<0?-n:n);else throw Error(V+t+" cannot be zero: "+n);if(e.hasOwnProperty(t="CRYPTO"))if(n=e[t],n===!!n)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))re=n;else throw re=!n,Error(V+"crypto unavailable");else re=n;else throw Error(V+t+" not true or false: "+n);if(e.hasOwnProperty(t="MODULO_MODE")&&(n=e[t],x(n,0,9,t),ae=n),e.hasOwnProperty(t="POW_PRECISION")&&(n=e[t],x(n,0,P,t),ue=n),e.hasOwnProperty(t="FORMAT"))if(n=e[t],typeof n=="object")ke=n;else throw Error(V+t+" not an object: "+n);if(e.hasOwnProperty(t="ALPHABET"))if(n=e[t],typeof n=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))Ne=n.slice(0,10)=="0123456789",pe=n;else throw Error(V+t+" invalid: "+n)}else throw Error(V+"Object expected: "+e);return{DECIMAL_PLACES:k,ROUNDING_MODE:d,EXPONENTIAL_AT:[m,M],RANGE:[q,X],CRYPTO:re,MODULO_MODE:ae,POW_PRECISION:ue,FORMAT:ke,ALPHABET:pe}},y.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!y.DEBUG)return!0;var t,n,a=e.c,o=e.e,s=e.s;e:if({}.toString.call(a)=="[object Array]"){if((s===1||s===-1)&&o>=-P&&o<=P&&o===j(o)){if(a[0]===0){if(o===0&&a.length===1)return!0;break e}if(t=(o+1)%w,t<1&&(t+=w),String(a[0]).length==t){for(t=0;t<a.length;t++)if(n=a[t],n<0||n>=D||n!==j(n))break e;if(n!==0)return!0}}}else if(a===null&&o===null&&(s===null||s===1||s===-1))return!0;throw Error(V+"Invalid BigNumber: "+e)},y.maximum=y.max=function(){return be(arguments,-1)},y.minimum=y.min=function(){return be(arguments,1)},y.random=function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return j(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(n){var a,o,s,f,r,i=0,c=[],l=new y(N);if(n==null?n=k:x(n,0,P),f=O(n/w),re)if(crypto.getRandomValues){for(a=crypto.getRandomValues(new Uint32Array(f*=2));i<f;)r=a[i]*131072+(a[i+1]>>>11),r>=9e15?(o=crypto.getRandomValues(new Uint32Array(2)),a[i]=o[0],a[i+1]=o[1]):(c.push(r%1e14),i+=2);i=f/2}else if(crypto.randomBytes){for(a=crypto.randomBytes(f*=7);i<f;)r=(a[i]&31)*281474976710656+a[i+1]*1099511627776+a[i+2]*4294967296+a[i+3]*16777216+(a[i+4]<<16)+(a[i+5]<<8)+a[i+6],r>=9e15?crypto.randomBytes(7).copy(a,i):(c.push(r%1e14),i+=7);i=f/7}else throw re=!1,Error(V+"crypto unavailable");if(!re)for(;i<f;)r=t(),r<9e15&&(c[i++]=r%1e14);for(f=c[--i],n%=w,f&&n&&(r=v[w-n],c[i]=j(f/r)*r);c[i]===0;c.pop(),i--);if(i<0)c=[s=0];else{for(s=-1;c[0]===0;c.splice(0,1),s-=w);for(i=1,r=c[0];r>=10;r/=10,i++);i<w&&(s-=w-i)}return l.e=s,l.c=c,l}}(),y.sum=function(){for(var e=1,t=arguments,n=new y(t[0]);e<t.length;)n=n.plus(t[e++]);return n},L=function(){var e="0123456789";function t(n,a,o,s){for(var f,r=[0],i,c=0,l=n.length;c<l;){for(i=r.length;i--;r[i]*=a);for(r[0]+=s.indexOf(n.charAt(c++)),f=0;f<r.length;f++)r[f]>o-1&&(r[f+1]==null&&(r[f+1]=0),r[f+1]+=r[f]/o|0,r[f]%=o)}return r.reverse()}return function(n,a,o,s,f){var r,i,c,l,h,A,C,J,Y=n.indexOf("."),ee=k,$=d;for(Y>=0&&(l=ue,ue=0,n=n.replace(".",""),J=new y(a),A=J.pow(n.length-Y),ue=l,J.c=t(U(R(A.c),A.e,"0"),10,o,e),J.e=J.c.length),C=t(n,a,o,f?(r=pe,e):(r=e,pe)),c=l=C.length;C[--l]==0;C.pop());if(!C[0])return r.charAt(0);if(Y<0?--c:(A.c=C,A.e=c,A.s=s,A=B(A,J,ee,$,o),C=A.c,h=A.r,c=A.e),i=c+ee+1,Y=C[i],l=o/2,h=h||i<0||C[i+1]!=null,h=$<4?(Y!=null||h)&&($==0||$==(A.s<0?3:2)):Y>l||Y==l&&($==4||h||$==6&&C[i-1]&1||$==(A.s<0?8:7)),i<1||!C[0])n=h?U(r.charAt(1),-ee,r.charAt(0)):r.charAt(0);else{if(C.length=i,h)for(--o;++C[--i]>o;)C[i]=0,i||(++c,C=[1].concat(C));for(l=C.length;!C[--l];);for(Y=0,n="";Y<=l;n+=r.charAt(C[Y++]));n=U(n,c,r.charAt(0))}return n}}(),B=function(){function e(a,o,s){var f,r,i,c,l=0,h=a.length,A=o%T,C=o/T|0;for(a=a.slice();h--;)i=a[h]%T,c=a[h]/T|0,f=C*i+c*A,r=A*i+f%T*T+l,l=(r/s|0)+(f/T|0)+C*c,a[h]=r%s;return l&&(a=[l].concat(a)),a}function t(a,o,s,f){var r,i;if(s!=f)i=s>f?1:-1;else for(r=i=0;r<s;r++)if(a[r]!=o[r]){i=a[r]>o[r]?1:-1;break}return i}function n(a,o,s,f){for(var r=0;s--;)a[s]-=r,r=a[s]<o[s]?1:0,a[s]=r*f+a[s]-o[s];for(;!a[0]&&a.length>1;a.splice(0,1));}return function(a,o,s,f,r){var i,c,l,h,A,C,J,Y,ee,$,G,ne,me,ve,Be,le,he,se=a.s==o.s?1:-1,oe=a.c,Q=o.c;if(!oe||!oe[0]||!Q||!Q[0])return new y(!a.s||!o.s||(oe?Q&&oe[0]==Q[0]:!Q)?NaN:oe&&oe[0]==0||!Q?se*0:se/0);for(Y=new y(se),ee=Y.c=[],c=a.e-o.e,se=s+c+1,r||(r=D,c=K(a.e/w)-K(o.e/w),se=se/w|0),l=0;Q[l]==(oe[l]||0);l++);if(Q[l]>(oe[l]||0)&&c--,se<0)ee.push(1),h=!0;else{for(ve=oe.length,le=Q.length,l=0,se+=2,A=j(r/(Q[0]+1)),A>1&&(Q=e(Q,A,r),oe=e(oe,A,r),le=Q.length,ve=oe.length),me=le,$=oe.slice(0,le),G=$.length;G<le;$[G++]=0);he=Q.slice(),he=[0].concat(he),Be=Q[0],Q[1]>=r/2&&Be++;do{if(A=0,i=t(Q,$,le,G),i<0){if(ne=$[0],le!=G&&(ne=ne*r+($[1]||0)),A=j(ne/Be),A>1)for(A>=r&&(A=r-1),C=e(Q,A,r),J=C.length,G=$.length;t(C,$,J,G)==1;)A--,n(C,le<J?he:Q,J,r),J=C.length,i=1;else A==0&&(i=A=1),C=Q.slice(),J=C.length;if(J<G&&(C=[0].concat(C)),n($,C,G,r),G=$.length,i==-1)for(;t(Q,$,le,G)<1;)A++,n($,le<G?he:Q,G,r),G=$.length}else i===0&&(A++,$=[0]);ee[l++]=A,$[0]?$[G++]=oe[me]||0:($=[oe[me]],G=1)}while((me++<ve||$[0]!=null)&&se--);h=$[0]!=null,ee[0]||ee.splice(0,1)}if(r==D){for(l=1,se=ee[0];se>=10;se/=10,l++);ie(Y,s+(Y.e=l+c*w-1)+1,f,h)}else Y.e=c,Y.r=+h;return Y}}();function we(e,t,n,a){var o,s,f,r,i;if(n==null?n=d:x(n,0,8),!e.c)return e.toString();if(o=e.c[0],f=e.e,t==null)i=R(e.c),i=a==1||a==2&&(f<=m||f>=M)?I(i,f):U(i,f,"0");else if(e=ie(new y(e),t,n),s=e.e,i=R(e.c),r=i.length,a==1||a==2&&(t<=s||s<=m)){for(;r<t;i+="0",r++);i=I(i,s)}else if(t-=f+(a===2&&s>f),i=U(i,s,"0"),s+1>r){if(--t>0)for(i+=".";t--;i+="0");}else if(t+=s-r,t>0)for(s+1==r&&(i+=".");t--;i+="0");return e.s<0&&o?"-"+i:i}function be(e,t){for(var n,a,o=1,s=new y(e[0]);o<e.length;o++)a=new y(e[o]),(!a.s||(n=W(s,a))===t||n===0&&s.s===t)&&(s=a);return s}function Ee(e,t,n){for(var a=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,a++);return(n=a+n*w-1)>X?e.c=e.e=null:n<q?e.c=[e.e=0]:(e.e=n,e.c=t),e}g=function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,a=/^-?(Infinity|NaN)$/,o=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,f,r,i){var c,l=r?f:f.replace(o,"");if(a.test(l))s.s=isNaN(l)?null:l<0?-1:1;else{if(!r&&(l=l.replace(e,function(h,A,C){return c=(C=C.toLowerCase())=="x"?16:C=="b"?2:8,!i||i==c?A:h}),i&&(c=i,l=l.replace(t,"$1").replace(n,"0.$1")),f!=l))return new y(l,c);if(y.DEBUG)throw Error(V+"Not a"+(i?" base "+i:"")+" number: "+f);s.s=null}s.c=s.e=null}}();function ie(e,t,n,a){var o,s,f,r,i,c,l,h=e.c,A=v;if(h){e:{for(o=1,r=h[0];r>=10;r/=10,o++);if(s=t-o,s<0)s+=w,f=t,i=h[c=0],l=j(i/A[o-f-1]%10);else if(c=O((s+1)/w),c>=h.length)if(a){for(;h.length<=c;h.push(0));i=l=0,o=1,s%=w,f=s-w+1}else break e;else{for(i=r=h[c],o=1;r>=10;r/=10,o++);s%=w,f=s-w+o,l=f<0?0:j(i/A[o-f-1]%10)}if(a=a||t<0||h[c+1]!=null||(f<0?i:i%A[o-f-1]),a=n<4?(l||a)&&(n==0||n==(e.s<0?3:2)):l>5||l==5&&(n==4||a||n==6&&(s>0?f>0?i/A[o-f]:0:h[c-1])%10&1||n==(e.s<0?8:7)),t<1||!h[0])return h.length=0,a?(t-=e.e+1,h[0]=A[(w-t%w)%w],e.e=-t||0):h[0]=e.e=0,e;if(s==0?(h.length=c,r=1,c--):(h.length=c+1,r=A[w-s],h[c]=f>0?j(i/A[o-f]%A[f])*r:0),a)for(;;)if(c==0){for(s=1,f=h[0];f>=10;f/=10,s++);for(f=h[0]+=r,r=1;f>=10;f/=10,r++);s!=r&&(e.e++,h[0]==D&&(h[0]=1));break}else{if(h[c]+=r,h[c]!=D)break;h[c--]=0,r=1}for(s=h.length;h[--s]===0;h.pop());}e.e>X?e.c=e.e=null:e.e<q&&(e.c=[e.e=0])}return e}function ce(e){var t,n=e.e;return n===null?e.toString():(t=R(e.c),t=n<=m||n>=M?I(t,n):U(t,n,"0"),e.s<0?"-"+t:t)}return u.absoluteValue=u.abs=function(){var e=new y(this);return e.s<0&&(e.s=1),e},u.comparedTo=function(e,t){return W(this,new y(e,t))},u.decimalPlaces=u.dp=function(e,t){var n,a,o,s=this;if(e!=null)return x(e,0,P),t==null?t=d:x(t,0,8),ie(new y(s),e+s.e+1,t);if(!(n=s.c))return null;if(a=((o=n.length-1)-K(this.e/w))*w,o=n[o])for(;o%10==0;o/=10,a--);return a<0&&(a=0),a},u.dividedBy=u.div=function(e,t){return B(this,new y(e,t),k,d)},u.dividedToIntegerBy=u.idiv=function(e,t){return B(this,new y(e,t),0,1)},u.exponentiatedBy=u.pow=function(e,t){var n,a,o,s,f,r,i,c,l,h=this;if(e=new y(e),e.c&&!e.isInteger())throw Error(V+"Exponent not an integer: "+ce(e));if(t!=null&&(t=new y(t)),r=e.e>14,!h.c||!h.c[0]||h.c[0]==1&&!h.e&&h.c.length==1||!e.c||!e.c[0])return l=new y(Math.pow(+ce(h),r?e.s*(2-b(e)):+ce(e))),t?l.mod(t):l;if(i=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new y(NaN);a=!i&&h.isInteger()&&t.isInteger(),a&&(h=h.mod(t))}else{if(e.e>9&&(h.e>0||h.e<-1||(h.e==0?h.c[0]>1||r&&h.c[1]>=24e7:h.c[0]<8e13||r&&h.c[0]<=9999975e7)))return s=h.s<0&&b(e)?-0:0,h.e>-1&&(s=1/s),new y(i?1/s:s);ue&&(s=O(ue/w+2))}for(r?(n=new y(.5),i&&(e.s=1),c=b(e)):(o=Math.abs(+ce(e)),c=o%2),l=new y(N);;){if(c){if(l=l.times(h),!l.c)break;s?l.c.length>s&&(l.c.length=s):a&&(l=l.mod(t))}if(o){if(o=j(o/2),o===0)break;c=o%2}else if(e=e.times(n),ie(e,e.e+1,1),e.e>14)c=b(e);else{if(o=+ce(e),o===0)break;c=o%2}h=h.times(h),s?h.c&&h.c.length>s&&(h.c.length=s):a&&(h=h.mod(t))}return a?l:(i&&(l=N.div(l)),t?l.mod(t):s?ie(l,ue,d,f):l)},u.integerValue=function(e){var t=new y(this);return e==null?e=d:x(e,0,8),ie(t,t.e+1,e)},u.isEqualTo=u.eq=function(e,t){return W(this,new y(e,t))===0},u.isFinite=function(){return!!this.c},u.isGreaterThan=u.gt=function(e,t){return W(this,new y(e,t))>0},u.isGreaterThanOrEqualTo=u.gte=function(e,t){return(t=W(this,new y(e,t)))===1||t===0},u.isInteger=function(){return!!this.c&&K(this.e/w)>this.c.length-2},u.isLessThan=u.lt=function(e,t){return W(this,new y(e,t))<0},u.isLessThanOrEqualTo=u.lte=function(e,t){return(t=W(this,new y(e,t)))===-1||t===0},u.isNaN=function(){return!this.s},u.isNegative=function(){return this.s<0},u.isPositive=function(){return this.s>0},u.isZero=function(){return!!this.c&&this.c[0]==0},u.minus=function(e,t){var n,a,o,s,f=this,r=f.s;if(e=new y(e,t),t=e.s,!r||!t)return new y(NaN);if(r!=t)return e.s=-t,f.plus(e);var i=f.e/w,c=e.e/w,l=f.c,h=e.c;if(!i||!c){if(!l||!h)return l?(e.s=-t,e):new y(h?f:NaN);if(!l[0]||!h[0])return h[0]?(e.s=-t,e):new y(l[0]?f:d==3?-0:0)}if(i=K(i),c=K(c),l=l.slice(),r=i-c){for((s=r<0)?(r=-r,o=l):(c=i,o=h),o.reverse(),t=r;t--;o.push(0));o.reverse()}else for(a=(s=(r=l.length)<(t=h.length))?r:t,r=t=0;t<a;t++)if(l[t]!=h[t]){s=l[t]<h[t];break}if(s&&(o=l,l=h,h=o,e.s=-e.s),t=(a=h.length)-(n=l.length),t>0)for(;t--;l[n++]=0);for(t=D-1;a>r;){if(l[--a]<h[a]){for(n=a;n&&!l[--n];l[n]=t);--l[n],l[a]+=D}l[a]-=h[a]}for(;l[0]==0;l.splice(0,1),--c);return l[0]?Ee(e,l,c):(e.s=d==3?-1:1,e.c=[e.e=0],e)},u.modulo=u.mod=function(e,t){var n,a,o=this;return e=new y(e,t),!o.c||!e.s||e.c&&!e.c[0]?new y(NaN):!e.c||o.c&&!o.c[0]?new y(o):(ae==9?(a=e.s,e.s=1,n=B(o,e,0,3),e.s=a,n.s*=a):n=B(o,e,0,ae),e=o.minus(n.times(e)),!e.c[0]&&ae==1&&(e.s=o.s),e)},u.multipliedBy=u.times=function(e,t){var n,a,o,s,f,r,i,c,l,h,A,C,J,Y,ee,$=this,G=$.c,ne=(e=new y(e,t)).c;if(!G||!ne||!G[0]||!ne[0])return!$.s||!e.s||G&&!G[0]&&!ne||ne&&!ne[0]&&!G?e.c=e.e=e.s=null:(e.s*=$.s,!G||!ne?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(a=K($.e/w)+K(e.e/w),e.s*=$.s,i=G.length,h=ne.length,i<h&&(J=G,G=ne,ne=J,o=i,i=h,h=o),o=i+h,J=[];o--;J.push(0));for(Y=D,ee=T,o=h;--o>=0;){for(n=0,A=ne[o]%ee,C=ne[o]/ee|0,f=i,s=o+f;s>o;)c=G[--f]%ee,l=G[f]/ee|0,r=C*c+l*A,c=A*c+r%ee*ee+J[s]+n,n=(c/Y|0)+(r/ee|0)+C*l,J[s--]=c%Y;J[s]=n}return n?++a:J.splice(0,1),Ee(e,J,a)},u.negated=function(){var e=new y(this);return e.s=-e.s||null,e},u.plus=function(e,t){var n,a=this,o=a.s;if(e=new y(e,t),t=e.s,!o||!t)return new y(NaN);if(o!=t)return e.s=-t,a.minus(e);var s=a.e/w,f=e.e/w,r=a.c,i=e.c;if(!s||!f){if(!r||!i)return new y(o/0);if(!r[0]||!i[0])return i[0]?e:new y(r[0]?a:o*0)}if(s=K(s),f=K(f),r=r.slice(),o=s-f){for(o>0?(f=s,n=i):(o=-o,n=r),n.reverse();o--;n.push(0));n.reverse()}for(o=r.length,t=i.length,o-t<0&&(n=i,i=r,r=n,t=o),o=0;t;)o=(r[--t]=r[t]+i[t]+o)/D|0,r[t]=D===r[t]?0:r[t]%D;return o&&(r=[o].concat(r),++f),Ee(e,r,f)},u.precision=u.sd=function(e,t){var n,a,o,s=this;if(e!=null&&e!==!!e)return x(e,1,P),t==null?t=d:x(t,0,8),ie(new y(s),e,t);if(!(n=s.c))return null;if(o=n.length-1,a=o*w+1,o=n[o]){for(;o%10==0;o/=10,a--);for(o=n[0];o>=10;o/=10,a++);}return e&&s.e+1>a&&(a=s.e+1),a},u.shiftedBy=function(e){return x(e,-F,F),this.times("1e"+e)},u.squareRoot=u.sqrt=function(){var e,t,n,a,o,s=this,f=s.c,r=s.s,i=s.e,c=k+4,l=new y("0.5");if(r!==1||!f||!f[0])return new y(!r||r<0&&(!f||f[0])?NaN:f?s:1/0);if(r=Math.sqrt(+ce(s)),r==0||r==1/0?(t=R(f),(t.length+i)%2==0&&(t+="0"),r=Math.sqrt(+t),i=K((i+1)/2)-(i<0||i%2),r==1/0?t="5e"+i:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new y(t)):n=new y(r+""),n.c[0]){for(i=n.e,r=i+c,r<3&&(r=0);;)if(o=n,n=l.times(o.plus(B(s,o,c,1))),R(o.c).slice(0,r)===(t=R(n.c)).slice(0,r))if(n.e<i&&--r,t=t.slice(r-3,r+1),t=="9999"||!a&&t=="4999"){if(!a&&(ie(o,o.e+k+2,0),o.times(o).eq(s))){n=o;break}c+=4,r+=4,a=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(ie(n,n.e+k+2,1),e=!n.times(n).eq(s));break}}return ie(n,n.e+k+1,d,e)},u.toExponential=function(e,t){return e!=null&&(x(e,0,P),e++),we(this,e,t,1)},u.toFixed=function(e,t){return e!=null&&(x(e,0,P),e=e+this.e+1),we(this,e,t)},u.toFormat=function(e,t,n){var a,o=this;if(n==null)e!=null&&t&&typeof t=="object"?(n=t,t=null):e&&typeof e=="object"?(n=e,e=t=null):n=ke;else if(typeof n!="object")throw Error(V+"Argument not an object: "+n);if(a=o.toFixed(e,t),o.c){var s,f=a.split("."),r=+n.groupSize,i=+n.secondaryGroupSize,c=n.groupSeparator||"",l=f[0],h=f[1],A=o.s<0,C=A?l.slice(1):l,J=C.length;if(i&&(s=r,r=i,i=s,J-=s),r>0&&J>0){for(s=J%r||r,l=C.substr(0,s);s<J;s+=r)l+=c+C.substr(s,r);i>0&&(l+=c+C.slice(s)),A&&(l="-"+l)}a=h?l+(n.decimalSeparator||"")+((i=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):l}return(n.prefix||"")+a+(n.suffix||"")},u.toFraction=function(e){var t,n,a,o,s,f,r,i,c,l,h,A,C=this,J=C.c;if(e!=null&&(r=new y(e),!r.isInteger()&&(r.c||r.s!==1)||r.lt(N)))throw Error(V+"Argument "+(r.isInteger()?"out of range: ":"not an integer: ")+ce(r));if(!J)return new y(C);for(t=new y(N),c=n=new y(N),a=i=new y(N),A=R(J),s=t.e=A.length-C.e-1,t.c[0]=v[(f=s%w)<0?w+f:f],e=!e||r.comparedTo(t)>0?s>0?t:c:r,f=X,X=1/0,r=new y(A),i.c[0]=0;l=B(r,t,0,1),o=n.plus(l.times(a)),o.comparedTo(e)!=1;)n=a,a=o,c=i.plus(l.times(o=c)),i=o,t=r.minus(l.times(o=t)),r=o;return o=B(e.minus(n),a,0,1),i=i.plus(o.times(c)),n=n.plus(o.times(a)),i.s=c.s=C.s,s=s*2,h=B(c,a,s,d).minus(C).abs().comparedTo(B(i,n,s,d).minus(C).abs())<1?[c,a]:[i,n],X=f,h},u.toNumber=function(){return+ce(this)},u.toPrecision=function(e,t){return e!=null&&x(e,1,P),we(this,e,t,2)},u.toString=function(e){var t,n=this,a=n.s,o=n.e;return o===null?a?(t="Infinity",a<0&&(t="-"+t)):t="NaN":(e==null?t=o<=m||o>=M?I(R(n.c),o):U(R(n.c),o,"0"):e===10&&Ne?(n=ie(new y(n),k+o+1,d),t=U(R(n.c),n.e,"0")):(x(e,2,pe.length,"Base"),t=L(U(R(n.c),o,"0"),10,e,a,!0)),a<0&&n.c[0]&&(t="-"+t)),t},u.valueOf=u.toJSON=function(){return ce(this)},u._isBigNumber=!0,S!=null&&y.set(S),y}function K(S){var B=S|0;return S>0||S===B?B:B-1}function R(S){for(var B,L,g=1,u=S.length,N=S[0]+"";g<u;){for(B=S[g++]+"",L=w-B.length;L--;B="0"+B);N+=B}for(u=N.length;N.charCodeAt(--u)===48;);return N.slice(0,u+1||1)}function W(S,B){var L,g,u=S.c,N=B.c,k=S.s,d=B.s,m=S.e,M=B.e;if(!k||!d)return null;if(L=u&&!u[0],g=N&&!N[0],L||g)return L?g?0:-d:k;if(k!=d)return k;if(L=k<0,g=m==M,!u||!N)return g?0:!u^L?1:-1;if(!g)return m>M^L?1:-1;for(d=(m=u.length)<(M=N.length)?m:M,k=0;k<d;k++)if(u[k]!=N[k])return u[k]>N[k]^L?1:-1;return m==M?0:m>M^L?1:-1}function x(S,B,L,g){if(S<B||S>L||S!==j(S))throw Error(V+(g||"Argument")+(typeof S=="number"?S<B||S>L?" out of range: ":" not an integer: ":" not a primitive number: ")+String(S))}function b(S){var B=S.c.length-1;return K(S.e/w)==B&&S.c[B]%2!=0}function I(S,B){return(S.length>1?S.charAt(0)+"."+S.slice(1):S)+(B<0?"e":"e+")+B}function U(S,B,L){var g,u;if(B<0){for(u=L+".";++B;u+=L);S=u+S}else if(g=S.length,++B>g){for(u=L,B-=g;--B;u+=L);S+=u}else B<g&&(S=S.slice(0,B)+"."+S.slice(B));return S}E=H(),E.default=E.BigNumber=E,z.exports?z.exports=E:(Z||(Z=typeof self<"u"&&self?self:window),Z.BigNumber=E)})(Te)}(ge)),ge.exports}var xe;function Pe(){return xe||(xe=1,function(z){var Z=Oe(),E=z.exports;(function(){var te=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,O,j,V={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},_;function D(F){return te.lastIndex=0,te.test(F)?'"'+F.replace(te,function(v){var T=V[v];return typeof T=="string"?T:"\\u"+("0000"+v.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+F+'"'}function w(F,v){var T,P,H,K,R=O,W,x=v[F],b=x!=null&&(x instanceof Z||Z.isBigNumber(x));switch(x&&typeof x=="object"&&typeof x.toJSON=="function"&&(x=x.toJSON(F)),typeof _=="function"&&(x=_.call(v,F,x)),typeof x){case"string":return b?x:D(x);case"number":return isFinite(x)?String(x):"null";case"boolean":case"null":case"bigint":return String(x);case"object":if(!x)return"null";if(O+=j,W=[],Object.prototype.toString.apply(x)==="[object Array]"){for(K=x.length,T=0;T<K;T+=1)W[T]=w(T,x)||"null";return H=W.length===0?"[]":O?`[
|
|
2
|
-
`+O+W.join(`,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`,r:"\r",t:" "},w,F=function(b){throw{name:"SyntaxError",message:b,at:V,text:w}},v=function(b){return b&&b!==_&&F("Expected '"+b+"' instead of '"+_+"'"),_=w.charAt(V),V+=1,_},T=function(){var b,I="";for(_==="-"&&(I="-",v("-"));_>="0"&&_<="9";)I+=_,v();if(_===".")for(I+=".";v()&&_>="0"&&_<="9";)I+=_;if(_==="e"||_==="E")for(I+=_,v(),(_==="-"||_==="+")&&(I+=_,v());_>="0"&&_<="9";)I+=_,v();if(b=+I,!isFinite(b))F("Bad number");else return z==null&&(z=Oe()),I.length>15?j.storeAsString?I:j.useNativeBigInt?BigInt(I):new z(I):j.alwaysParseAsBig?j.useNativeBigInt?BigInt(b):new z(b):b},P=function(){var b,I,U="",S;if(_==='"')for(var B=V;v();){if(_==='"')return V-1>B&&(U+=w.substring(B,V-1)),v(),U;if(_==="\\"){if(V-1>B&&(U+=w.substring(B,V-1)),v(),_==="u"){for(S=0,I=0;I<4&&(b=parseInt(v(),16),!!isFinite(b));I+=1)S=S*16+b;U+=String.fromCharCode(S)}else if(typeof D[_]=="string")U+=D[_];else break;B=V}}F("Bad string")},H=function(){for(;_&&_<=" ";)v()},K=function(){switch(_){case"t":return v("t"),v("r"),v("u"),v("e"),!0;case"f":return v("f"),v("a"),v("l"),v("s"),v("e"),!1;case"n":return v("n"),v("u"),v("l"),v("l"),null}F("Unexpected '"+_+"'")},R,W=function(){var b=[];if(_==="["){if(v("["),H(),_==="]")return v("]"),b;for(;_;){if(b.push(R()),H(),_==="]")return v("]"),b;v(","),H()}}F("Bad array")},x=function(){var b,I=Object.create(null);if(_==="{"){if(v("{"),H(),_==="}")return v("}"),I;for(;_;){if(b=P(),H(),v(":"),j.strict===!0&&Object.hasOwnProperty.call(I,b)&&F('Duplicate key "'+b+'"'),Z.test(b)===!0?j.protoAction==="error"?F("Object contains forbidden prototype property"):j.protoAction==="ignore"?R():I[b]=R():E.test(b)===!0?j.constructorAction==="error"?F("Object contains forbidden constructor property"):j.constructorAction==="ignore"?R():I[b]=R():I[b]=R(),H(),_==="}")return v("}"),I;v(","),H()}}F("Bad object")};return R=function(){switch(H(),_){case"{":return x();case"[":return W();case'"':return P();case"-":return T();default:return _>="0"&&_<="9"?T():K()}},function(b,I){var U;return w=b+"",V=0,_=" ",U=R(),H(),_&&F("Syntax error"),typeof I=="function"?function S(B,L){var g,u=B[L];return u&&typeof u=="object"&&Object.keys(u).forEach(function(N){g=S(u,N),g!==void 0?u[N]=g:delete u[N]}),I.call(B,L,u)}({"":U},""):U}};return _e=te,_e}var Ce;function $e(){if(Ce)return de.exports;Ce=1;var z=Pe().stringify,Z=De();return de.exports=function(E){return{parse:Z(E),stringify:z}},de.exports.parse=Z(),de.exports.stringify=z,de.exports}var Fe=$e();const Je=Ie(Fe),Re={class:"json-node"},Me={key:0,class:"json-node__container"},Le={class:"json-node__line"},Ue={key:2,class:"json-node__colon"},qe=["title"],Ge={key:3,class:"json-node__collapsed"},ze={key:4,class:"json-node__comma"},He={key:0,class:"json-node__children"},Xe={class:"json-node__line"},Ke={class:"json-node__bracket"},We={key:0,class:"json-node__comma"},Ye={key:1,class:"json-node__primitive"},Qe={key:2,class:"json-node__colon"},Ze=["title"],et={key:5,class:"json-node__comma"},tt=p.defineComponent({name:"JsonNode",__name:"JsonNode",props:{value:{},keyName:{},level:{},path:{default:""},expanded:{},isLast:{type:Boolean,default:!1}},emits:["update:value","toggle-expand","copy","update:key"],setup(z,{emit:Z}){p.useCssVars(d=>({"623b775d":d.level}));const E=z,te=Z,O=p.ref(!1),j=p.ref(!1),V=p.ref(""),_=p.ref(""),D=d=>{if(!/^-?\d+(\.\d+)?$/.test(d))return!1;const m=Number(d);return!Number.isSafeInteger(m)||d.length>15},w=p.computed(()=>E.value!==null&&typeof E.value=="object"),F=p.computed(()=>Array.isArray(E.value)),v=p.computed(()=>E.path?E.path:E.keyName?E.keyName:"root"),T=p.computed(()=>E.expanded.has(v.value)),P=p.computed(()=>E.keyName),H=p.computed(()=>F.value?"[":"{"),K=p.computed(()=>F.value?"]":"}"),R=p.computed(()=>{if(!E.value)return"";const m=Object.keys(E.value).length;return F.value?m>0?` ${m} items `:" ":m>0?` ${m} keys `:" "}),W=p.computed(()=>{const d=typeof E.value;return E.value===null?"json-node__value--null":d==="boolean"?"json-node__value--boolean":d==="number"?"json-node__value--number":d==="string"?D(E.value)?"json-node__value--number":"json-node__value--string":""}),x=p.computed(()=>j.value?_.value:E.value===null?"null":typeof E.value=="boolean"||typeof E.value=="number"?String(E.value):typeof E.value=="string"?D(E.value)?E.value:`"${E.value}"`:String(E.value)),b=p.computed(()=>"Click to edit, double-click to copy"),I=d=>E.level===0?d:v.value?`${v.value}.${d}`:d,U=d=>{const m=Object.keys(E.value);return m.indexOf(d)===m.length-1},S=()=>{te("toggle-expand",v.value)},B=()=>{E.level!==0&&(O.value=!0,V.value=E.keyName,p.nextTick(()=>{const d=document.querySelectorAll(".json-node__key-input"),m=d[d.length-1];m&&(m.focus(),m.select())}))},L=()=>{w.value||(j.value=!0,typeof E.value=="string"&&D(E.value)||typeof E.value=="string"?_.value=E.value:_.value=String(E.value),p.nextTick(()=>{const d=document.querySelectorAll(".json-node__value-input"),m=d[d.length-1];m&&(m.focus(),m.select())}))},g=()=>{if(E.level===0||!O.value)return;const d=V.value.trim();if(!d){N();return}if(d===E.keyName){O.value=!1;return}O.value=!1,te("update:key",v.value,d)},u=()=>{try{let d;const m=_.value.trim();if(m==="null")d=null;else if(m==="true"||m==="false")d=m==="true";else if(!isNaN(Number(m))&&m!==""){const M=Number(m);!Number.isSafeInteger(M)||m.length>15?d=m:d=M}else d=_.value;te("update:value",v.value,d),j.value=!1}catch(d){console.error("Failed to parse value:",d),j.value=!1}},N=()=>{O.value=!1,V.value=E.keyName},k=()=>{j.value=!1,typeof E.value=="string"&&D(E.value)||typeof E.value=="string"?_.value=E.value:_.value=String(E.value)};return(d,m)=>{const M=p.resolveComponent("JsonNode",!0);return p.openBlock(),p.createElementBlock("div",Re,[w.value?(p.openBlock(),p.createElementBlock("div",Me,[p.createElementVNode("div",Le,[d.keyName&&!O.value?(p.openBlock(),p.createElementBlock("span",{key:0,class:"json-node__key",onClick:B,title:"Click to edit key"},' "'+p.toDisplayString(P.value)+'" ',1)):p.createCommentVNode("",!0),d.keyName&&O.value?p.withDirectives((p.openBlock(),p.createElementBlock("input",{key:1,"onUpdate:modelValue":m[0]||(m[0]=q=>V.value=q),onKeyup:[p.withKeys(g,["enter"]),p.withKeys(N,["escape"])],onBlur:g,class:"json-node__key-input"},null,544)),[[p.vModelText,V.value]]):p.createCommentVNode("",!0),d.keyName?(p.openBlock(),p.createElementBlock("span",Ue,": ")):p.createCommentVNode("",!0),p.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:S,title:T.value?"Click to collapse":"Click to expand"},p.toDisplayString(H.value),9,qe),T.value?p.createCommentVNode("",!0):(p.openBlock(),p.createElementBlock("span",Ge,[p.createTextVNode(p.toDisplayString(R.value)+" ",1),p.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:S},p.toDisplayString(K.value),1)])),!T.value&&!d.isLast?(p.openBlock(),p.createElementBlock("span",ze,",")):p.createCommentVNode("",!0)]),T.value?(p.openBlock(),p.createElementBlock("div",He,[(p.openBlock(!0),p.createElementBlock(p.Fragment,null,p.renderList(d.value,(q,X)=>(p.openBlock(),p.createElementBlock("div",{key:X,class:"json-node__child"},[p.createVNode(M,{value:q,"key-name":F.value?"":String(X),level:d.level+1,path:I(String(X)),expanded:d.expanded,"onUpdate:value":m[1]||(m[1]=(re,ae)=>d.$emit("update:value",re,ae)),onToggleExpand:m[2]||(m[2]=re=>d.$emit("toggle-expand",re)),onCopy:m[3]||(m[3]=re=>d.$emit("copy",re)),"onUpdate:key":m[4]||(m[4]=(re,ae)=>d.$emit("update:key",re,ae)),"is-last":U(String(X))},null,8,["value","key-name","level","path","expanded","is-last"])]))),128)),p.createElementVNode("div",Xe,[p.createElementVNode("span",Ke,p.toDisplayString(K.value),1),d.isLast?p.createCommentVNode("",!0):(p.openBlock(),p.createElementBlock("span",We,","))])])):p.createCommentVNode("",!0)])):(p.openBlock(),p.createElementBlock("div",Ye,[d.keyName&&!O.value?(p.openBlock(),p.createElementBlock("span",{key:0,class:"json-node__key",onClick:B,title:"Click to edit key"},' "'+p.toDisplayString(P.value)+'" ',1)):p.createCommentVNode("",!0),d.keyName&&O.value?p.withDirectives((p.openBlock(),p.createElementBlock("input",{key:1,"onUpdate:modelValue":m[5]||(m[5]=q=>V.value=q),onKeyup:[p.withKeys(g,["enter"]),p.withKeys(N,["escape"])],onBlur:g,class:"json-node__key-input"},null,544)),[[p.vModelText,V.value]]):p.createCommentVNode("",!0),d.keyName?(p.openBlock(),p.createElementBlock("span",Qe,": ")):p.createCommentVNode("",!0),j.value?p.createCommentVNode("",!0):(p.openBlock(),p.createElementBlock("span",{key:3,class:p.normalizeClass(["json-node__value",W.value]),onClick:L,onDblclick:m[6]||(m[6]=q=>d.$emit("copy",d.value)),title:b.value},p.toDisplayString(x.value),43,Ze)),j.value?p.withDirectives((p.openBlock(),p.createElementBlock("input",{key:4,"onUpdate:modelValue":m[7]||(m[7]=q=>_.value=q),onKeyup:[p.withKeys(u,["enter"]),p.withKeys(k,["escape"])],onBlur:u,class:"json-node__value-input"},null,544)),[[p.vModelText,_.value]]):p.createCommentVNode("",!0),d.isLast?p.createCommentVNode("",!0):(p.openBlock(),p.createElementBlock("span",et,","))]))])}}}),je=(z,Z)=>{const E=z.__vccOpts||z;for(const[te,O]of Z)E[te]=O;return E},nt=je(tt,[["__scopeId","data-v-ac834fbd"]]),rt={class:"json-format"},ot={key:0,class:"json-format__toolbar"},it={class:"json-format__actions"},st=["disabled"],lt=["disabled"],at=["disabled"],ct={class:"json-format__info"},ft={key:0,class:"json-format__status json-format__status--success"},ut={key:1,class:"json-format__status json-format__status--error"},pt={class:"json-format__content"},dt={key:0,class:"json-format__error"},ht={key:1,class:"json-format__viewer"},Ve=je(p.defineComponent({name:"JsonFormat",__name:"index",props:{modelValue:{default:""},readonly:{type:Boolean,default:!1},maxDepth:{default:10},showToolbar:{type:Boolean,default:!0}},emits:["update:modelValue","copy-success","copy-error","expand-all","collapse-all"],setup(z,{expose:Z,emit:E}){const te=Je({storeAsString:!0,useNativeBigInt:!1}),O=z,j=E,V=p.ref(null),_=p.ref(""),D=p.ref(new Set),w=p.computed(()=>_.value===""),F=g=>{if(!g.trim()){V.value=null,_.value="";return}try{V.value=te.parse(g),_.value="",p.nextTick(()=>{V.value!==null&&H()})}catch(u){_.value=u instanceof Error?u.message:"Unknown parsing error",V.value=null}};p.watch(()=>O.modelValue,g=>{F(g)},{immediate:!0});const v=(g,u)=>{if(!O.readonly)try{const N=T(V.value,g,u),k=te.stringify(N,null,2);j("update:modelValue",k)}catch(N){console.error("Failed to update JSON:",N)}},T=(g,u,N)=>{if(!u||u==="root")return N;const k=u.split("."),d=U(g,k.slice(0,-1));let m=d;for(let q=0;q<k.length-1;q++){const X=k[q];X!=="root"&&(Array.isArray(m)?m=m[parseInt(X)]:m=m[X])}const M=k[k.length-1];return M==="root"?N:(Array.isArray(m)?m[parseInt(M)]=N:m[M]=N,d)},P=g=>{D.value.has(g)?D.value.delete(g):D.value.add(g)},H=()=>{const g=new Set,u=(N,k="")=>{N!==null&&typeof N=="object"&&(g.add(k||"root"),Array.isArray(N)?N.forEach((d,m)=>{const M=k?`${k}.${m}`:`${m}`;u(d,M)}):Object.keys(N).forEach(d=>{const m=k?`${k}.${d}`:d;u(N[d],m)}))};u(V.value),D.value=g,j("expand-all")},K=()=>{D.value=new Set(["root"]),j("collapse-all")},R=async()=>{if(w.value)try{const u=JSON.stringify(V.value,null,2).replace(/"(\d{16,})"/g,"$1");await navigator.clipboard.writeText(u),j("copy-success",u)}catch(g){console.error("Failed to copy JSON:",g),j("copy-error",g instanceof Error?g:new Error("Failed to copy JSON"))}},W=g=>{if(!/^-?\d+(\.\d+)?$/.test(g))return!1;const u=Number(g);return!Number.isSafeInteger(u)||g.length>15},x=async g=>{try{let u;typeof g=="string"&&W(g)?u=g:typeof g=="string"?u=`"${g}"`:u=JSON.stringify(g),await navigator.clipboard.writeText(u)}catch(u){console.error("Failed to copy value:",u)}},b=(g,u)=>{if(!O.readonly)try{const N=I(V.value,g,u),k=te.stringify(N,null,2);j("update:modelValue",k),L(g,u)}catch(N){console.error("Failed to rename key:",N)}},I=(g,u,N)=>{if(!u||u==="root")return g;const k=u.split("."),d=U(g,k.slice(0,-1));if(k.length===1){const q=k[0];return d&&typeof d=="object"&&!Array.isArray(d)?S(d,q,N):d}let m=d;for(let q=0;q<k.length-1;q++){const X=k[q];Array.isArray(m)?m=m[parseInt(X)]:m=m[X]}const M=k[k.length-1];if(!Array.isArray(m)&&m&&typeof m=="object"){const q=S(m,M,N),X=k.slice(0,-1);X.length>0&&B(d,X,q)}return d},U=(g,u)=>{if(u.length===0)return g;if(Array.isArray(g)){const N=[...g],k=u[0],d=parseInt(k);return u.length===1||(N[d]=U(g[d],u.slice(1))),N}else if(g&&typeof g=="object"){const N={...g},k=u[0];return u.length===1||(N[k]=U(g[k],u.slice(1))),N}return g},S=(g,u,N)=>{if(!g||typeof g!="object"||Array.isArray(g))return g;const k=Object.keys(g),d={};for(const m of k)m===u?d[N]=g[m]:d[m]=g[m];return d},B=(g,u,N)=>{let k=g;for(let m=0;m<u.length-1;m++){const M=u[m];Array.isArray(k)?k=k[parseInt(M)]:k=k[M]}const d=u[u.length-1];Array.isArray(k)?k[parseInt(d)]=N:k[d]=N},L=(g,u)=>{const N=new Set;D.value.forEach(k=>{if(k===g){const d=g.split(".");d[d.length-1]=u,N.add(d.join("."))}else if(k.startsWith(g+".")){const d=g.split(".");d[d.length-1]=u;const m=d.join("."),M=k.substring(g.length);N.add(m+M)}else N.add(k)}),D.value=N};return Z({copyJson:R,expandAll:H,collapseAll:K,toggleExpand:P,updateValue:v,updateKey:b,isValidJson:()=>w.value,getParsedJson:()=>V.value,getExpandedNodes:()=>D.value,getParseError:()=>_.value,parseJson:g=>F(g),copyValue:g=>x(g)}),(g,u)=>(p.openBlock(),p.createElementBlock("div",rt,[g.showToolbar?(p.openBlock(),p.createElementBlock("div",ot,[p.createElementVNode("div",it,[p.createElementVNode("button",{class:"json-format__btn json-format__btn--primary",onClick:R,disabled:!w.value,title:"Copy JSON"}," 📋 Copy ",8,st),p.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:H,disabled:!w.value,title:"Expand All"}," ⬇️ Expand All ",8,lt),p.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:K,disabled:!w.value,title:"Collapse All"}," ➡️ Collapse All ",8,at)]),p.createElementVNode("div",ct,[w.value?(p.openBlock(),p.createElementBlock("span",ft," ✅ Valid JSON ")):(p.openBlock(),p.createElementBlock("span",ut," ❌ Invalid JSON "))])])):p.createCommentVNode("",!0),p.createElementVNode("div",pt,[w.value?(p.openBlock(),p.createElementBlock("div",ht,[p.createVNode(nt,{value:V.value,"key-name":"",level:0,expanded:D.value,"is-last":!0,"onUpdate:value":v,onToggleExpand:P,onCopy:x,"onUpdate:key":b},null,8,["value","expanded"])])):(p.openBlock(),p.createElementBlock("div",dt,[u[0]||(u[0]=p.createElementVNode("h4",null,"JSON Parse Error:",-1)),p.createElementVNode("pre",null,p.toDisplayString(_.value),1)]))])]))}}),[["__scopeId","data-v-ad2f6a66"]]),gt=[Ve],mt={install:z=>{gt.forEach(Z=>{const E=Z.name||Z.__name||"UnknownComponent";z.component(E,Z)})}};fe.JsonFormat=Ve,fe.default=mt,Object.defineProperties(fe,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(I,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(I=typeof globalThis<"u"?globalThis:I||self,s(I.LoneFormat={},I.Vue))})(this,function(I,s){"use strict";class J{add(e,t,o){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(n){this[n]=this[n]||[],t&&this[n][o?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(o){o.call(t&&t.context?t.context:t,t)})}}class ee{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];t.forEach(n=>{if(typeof n!="object"||!n.name||!n.init)throw new Error("Invalid JSEP plugin format");this.registered[n.name]||(n.init(this.jsep),this.registered[n.name]=n)})}}class i{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+i.version}static addUnaryOp(e){return i.max_unop_len=Math.max(e.length,i.max_unop_len),i.unary_ops[e]=1,i}static addBinaryOp(e,t,o){return i.max_binop_len=Math.max(e.length,i.max_binop_len),i.binary_ops[e]=t,o?i.right_associative.add(e):i.right_associative.delete(e),i}static addIdentifierChar(e){return i.additional_identifier_chars.add(e),i}static addLiteral(e,t){return i.literals[e]=t,i}static removeUnaryOp(e){return delete i.unary_ops[e],e.length===i.max_unop_len&&(i.max_unop_len=i.getMaxKeyLen(i.unary_ops)),i}static removeAllUnaryOps(){return i.unary_ops={},i.max_unop_len=0,i}static removeIdentifierChar(e){return i.additional_identifier_chars.delete(e),i}static removeBinaryOp(e){return delete i.binary_ops[e],e.length===i.max_binop_len&&(i.max_binop_len=i.getMaxKeyLen(i.binary_ops)),i.right_associative.delete(e),i}static removeAllBinaryOps(){return i.binary_ops={},i.max_binop_len=0,i}static removeLiteral(e){return delete i.literals[e],i}static removeAllLiterals(){return i.literals={},i}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new i(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return i.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!i.binary_ops[String.fromCharCode(e)]||i.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return i.isIdentifierStart(e)||i.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(i.hooks[e]){const o={context:this,node:t};return i.hooks.run(e,o),o.node}return t}searchHook(e){if(i.hooks[e]){const t={context:this};return i.hooks[e].find(function(o){return o.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===i.SPACE_CODE||e===i.TAB_CODE||e===i.LF_CODE||e===i.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:i.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],o,n;for(;this.index<this.expr.length;)if(o=this.code,o===i.SEMCOL_CODE||o===i.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(o===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,i.max_binop_len),t=e.length;for(;t>0;){if(i.binary_ops.hasOwnProperty(e)&&(!i.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!i.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,o,n,l,u,f,d,h;if(u=this.gobbleToken(),!u||(t=this.gobbleBinaryOp(),!t))return u;for(l={value:t,prec:i.binaryPrecedence(t),right_a:i.right_associative.has(t)},f=this.gobbleToken(),f||this.throwError("Expected expression after "+t),n=[u,l,f];t=this.gobbleBinaryOp();){if(o=i.binaryPrecedence(t),o===0){this.index-=t.length;break}l={value:t,prec:o,right_a:i.right_associative.has(t)},h=t;const b=k=>l.right_a&&k.right_a?o>k.prec:o<=k.prec;for(;n.length>2&&b(n[n.length-2]);)f=n.pop(),t=n.pop().value,u=n.pop(),e={type:i.BINARY_EXP,operator:t,left:u,right:f},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+h),n.push(l,e)}for(d=n.length-1,e=n[d];d>1;)e={type:i.BINARY_EXP,operator:n[d-1].value,left:n[d-2],right:e},d-=2;return e}gobbleToken(){let e,t,o,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,i.isDecimalDigit(e)||e===i.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===i.SQUOTE_CODE||e===i.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===i.OBRACK_CODE)n=this.gobbleArray();else{for(t=this.expr.substr(this.index,i.max_unop_len),o=t.length;o>0;){if(i.unary_ops.hasOwnProperty(t)&&(!i.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!i.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=o;const l=this.gobbleToken();return l||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:i.UNARY_EXP,operator:t,argument:l,prefix:!0})}t=t.substr(0,--o)}i.isIdentifierStart(e)?(n=this.gobbleIdentifier(),i.literals.hasOwnProperty(n.name)?n={type:i.LITERAL,value:i.literals[n.name],raw:n.name}:n.name===i.this_str&&(n={type:i.THIS_EXP})):e===i.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===i.PERIOD_CODE||t===i.OBRACK_CODE||t===i.OPAREN_CODE||t===i.QUMARK_CODE;){let o;if(t===i.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==i.PERIOD_CODE)break;o=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===i.OBRACK_CODE?(e={type:i.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},e.property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),t=this.code,t!==i.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===i.OPAREN_CODE?e={type:i.CALL_EXP,arguments:this.gobbleArguments(i.CPAREN_CODE),callee:e}:(t===i.PERIOD_CODE||o)&&(o&&this.index--,this.gobbleSpaces(),e={type:i.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),o&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,o;for(;i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===i.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);i.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return o=this.code,i.isIdentifierStart(o)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(o===i.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===i.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:i.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="";const t=this.index,o=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let l=this.expr.charAt(this.index++);if(l===o){n=!0;break}else if(l==="\\")switch(l=this.expr.charAt(this.index++),l){case"n":e+=`
|
|
2
|
+
`;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=l}else e+=l}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:i.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(i.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,i.isIdentifierPart(e));)this.index++;return{type:i.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){const t=[];let o=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let l=this.code;if(l===e){o=!0,this.index++,e===i.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(l===i.COMMA_CODE){if(this.index++,n++,n!==t.length){if(e===i.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===i.CBRACK_CODE)for(let u=t.length;u<n;u++)t.push(null)}}else if(t.length!==n&&n!==0)this.throwError("Expected comma");else{const u=this.gobbleExpression();(!u||u.type===i.COMPOUND)&&this.throwError("Expected comma"),t.push(u)}}return o||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(i.CPAREN_CODE);if(this.code===i.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:i.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:i.ARRAY_EXP,elements:this.gobbleArguments(i.CBRACK_CODE)}}}const te=new J;Object.assign(i,{hooks:te,plugins:new ee(i),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),i.max_unop_len=i.getMaxKeyLen(i.unary_ops),i.max_binop_len=i.getMaxKeyLen(i.binary_ops);const B=r=>new i(r).parse(),re=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(i).filter(r=>!re.includes(r)&&B[r]===void 0).forEach(r=>{B[r]=i[r]}),B.Jsep=i;const ne="ConditionalExpression";var oe={name:"ternary",init(r){r.hooks.add("after-expression",function(t){if(t.node&&this.code===r.QUMARK_CODE){this.index++;const o=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===r.COLON_CODE){this.index++;const l=this.gobbleExpression();if(l||this.throwError("Expected expression"),t.node={type:ne,test:o,consequent:n,alternate:l},o.operator&&r.binary_ops[o.operator]<=.9){let u=o;for(;u.right.operator&&r.binary_ops[u.right.operator]<=.9;)u=u.right;t.node.test=u.right,u.right=t.node,t.node=o}}else this.throwError("Expected :")}})}};B.plugins.register(oe);const z=47,se=92;var ie={name:"regex",init(r){r.hooks.add("gobble-token",function(t){if(this.code===z){const o=++this.index;let n=!1;for(;this.index<this.expr.length;){if(this.code===z&&!n){const l=this.expr.slice(o,this.index);let u="";for(;++this.index<this.expr.length;){const d=this.code;if(d>=97&&d<=122||d>=65&&d<=90||d>=48&&d<=57)u+=this.char;else break}let f;try{f=new RegExp(l,u)}catch(d){this.throwError(d.message)}return t.node={type:r.LITERAL,value:f,raw:this.expr.slice(o-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===r.OBRACK_CODE?n=!0:n&&this.code===r.CBRACK_CODE&&(n=!1),this.index+=this.code===se?2:1}this.throwError("Unclosed Regex")}})}};const q=43,V={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[q,45],assignmentPrecedence:.9,init(r){const e=[r.IDENTIFIER,r.MEMBER_EXP];V.assignmentOperators.forEach(o=>r.addBinaryOp(o,V.assignmentPrecedence,!0)),r.hooks.add("gobble-token",function(n){const l=this.code;V.updateOperators.some(u=>u===l&&u===this.expr.charCodeAt(this.index+1))&&(this.index+=2,n.node={type:"UpdateExpression",operator:l===q?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!n.node.argument||!e.includes(n.node.argument.type))&&this.throwError(`Unexpected ${n.node.operator}`))}),r.hooks.add("after-token",function(n){if(n.node){const l=this.code;V.updateOperators.some(u=>u===l&&u===this.expr.charCodeAt(this.index+1))&&(e.includes(n.node.type)||this.throwError(`Unexpected ${n.node.operator}`),this.index+=2,n.node={type:"UpdateExpression",operator:l===q?"++":"--",argument:n.node,prefix:!1})}}),r.hooks.add("after-expression",function(n){n.node&&t(n.node)});function t(o){V.assignmentOperators.has(o.operator)?(o.type="AssignmentExpression",t(o.left),t(o.right)):o.operator||Object.values(o).forEach(n=>{n&&typeof n=="object"&&t(n)})}}};B.plugins.register(ie,V),B.addUnaryOp("typeof"),B.addLiteral("null",null),B.addLiteral("undefined",void 0);const ae=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),C={evalAst(r,e){switch(r.type){case"BinaryExpression":case"LogicalExpression":return C.evalBinaryExpression(r,e);case"Compound":return C.evalCompound(r,e);case"ConditionalExpression":return C.evalConditionalExpression(r,e);case"Identifier":return C.evalIdentifier(r,e);case"Literal":return C.evalLiteral(r,e);case"MemberExpression":return C.evalMemberExpression(r,e);case"UnaryExpression":return C.evalUnaryExpression(r,e);case"ArrayExpression":return C.evalArrayExpression(r,e);case"CallExpression":return C.evalCallExpression(r,e);case"AssignmentExpression":return C.evalAssignmentExpression(r,e);default:throw SyntaxError("Unexpected expression",r)}},evalBinaryExpression(r,e){return{"||":(o,n)=>o||n(),"&&":(o,n)=>o&&n(),"|":(o,n)=>o|n(),"^":(o,n)=>o^n(),"&":(o,n)=>o&n(),"==":(o,n)=>o==n(),"!=":(o,n)=>o!=n(),"===":(o,n)=>o===n(),"!==":(o,n)=>o!==n(),"<":(o,n)=>o<n(),">":(o,n)=>o>n(),"<=":(o,n)=>o<=n(),">=":(o,n)=>o>=n(),"<<":(o,n)=>o<<n(),">>":(o,n)=>o>>n(),">>>":(o,n)=>o>>>n(),"+":(o,n)=>o+n(),"-":(o,n)=>o-n(),"*":(o,n)=>o*n(),"/":(o,n)=>o/n(),"%":(o,n)=>o%n()}[r.operator](C.evalAst(r.left,e),()=>C.evalAst(r.right,e))},evalCompound(r,e){let t;for(let o=0;o<r.body.length;o++){r.body[o].type==="Identifier"&&["var","let","const"].includes(r.body[o].name)&&r.body[o+1]&&r.body[o+1].type==="AssignmentExpression"&&(o+=1);const n=r.body[o];t=C.evalAst(n,e)}return t},evalConditionalExpression(r,e){return C.evalAst(r.test,e)?C.evalAst(r.consequent,e):C.evalAst(r.alternate,e)},evalIdentifier(r,e){if(Object.hasOwn(e,r.name))return e[r.name];throw ReferenceError(`${r.name} is not defined`)},evalLiteral(r){return r.value},evalMemberExpression(r,e){const t=String(r.computed?C.evalAst(r.property):r.property.name),o=C.evalAst(r.object,e);if(o==null)throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);if(!Object.hasOwn(o,t)&&ae.has(t))throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);const n=o[t];return typeof n=="function"?n.bind(o):n},evalUnaryExpression(r,e){return{"-":o=>-C.evalAst(o,e),"!":o=>!C.evalAst(o,e),"~":o=>~C.evalAst(o,e),"+":o=>+C.evalAst(o,e),typeof:o=>typeof C.evalAst(o,e)}[r.operator](r.argument)},evalArrayExpression(r,e){return r.elements.map(t=>C.evalAst(t,e))},evalCallExpression(r,e){const t=r.arguments.map(n=>C.evalAst(n,e));return C.evalAst(r.callee,e)(...t)},evalAssignmentExpression(r,e){if(r.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");const t=r.left.name,o=C.evalAst(r.right,e);return e[t]=o,e[t]}};class le{constructor(e){this.code=e,this.ast=B(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return C.evalAst(this.ast,t)}}function T(r,e){return r=r.slice(),r.push(e),r}function G(r,e){return e=e.slice(),e.unshift(r),e}class ce extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function O(r,e,t,o,n){if(!(this instanceof O))try{return new O(r,e,t,o,n)}catch(u){if(!u.avoidNew)throw u;return u.value}typeof r=="string"&&(n=o,o=t,t=e,e=r,r=null);const l=r&&typeof r=="object";if(r=r||{},this.json=r.json||t,this.path=r.path||e,this.resultType=r.resultType||"value",this.flatten=r.flatten||!1,this.wrap=Object.hasOwn(r,"wrap")?r.wrap:!0,this.sandbox=r.sandbox||{},this.eval=r.eval===void 0?"safe":r.eval,this.ignoreEvalErrors=typeof r.ignoreEvalErrors>"u"?!1:r.ignoreEvalErrors,this.parent=r.parent||null,this.parentProperty=r.parentProperty||null,this.callback=r.callback||o||null,this.otherTypeCallback=r.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},r.autostart!==!1){const u={path:l?r.path:e};l?"json"in r&&(u.json=r.json):u.json=t;const f=this.evaluate(u);if(!f||typeof f!="object")throw new ce(f);return f}}O.prototype.evaluate=function(r,e,t,o){let n=this.parent,l=this.parentProperty,{flatten:u,wrap:f}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,t=t||this.callback,this.currOtherTypeCallback=o||this.otherTypeCallback,e=e||this.json,r=r||this.path,r&&typeof r=="object"&&!Array.isArray(r)){if(!r.path&&r.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(r,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=r),u=Object.hasOwn(r,"flatten")?r.flatten:u,this.currResultType=Object.hasOwn(r,"resultType")?r.resultType:this.currResultType,this.currSandbox=Object.hasOwn(r,"sandbox")?r.sandbox:this.currSandbox,f=Object.hasOwn(r,"wrap")?r.wrap:f,this.currEval=Object.hasOwn(r,"eval")?r.eval:this.currEval,t=Object.hasOwn(r,"callback")?r.callback:t,this.currOtherTypeCallback=Object.hasOwn(r,"otherTypeCallback")?r.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(r,"parent")?r.parent:n,l=Object.hasOwn(r,"parentProperty")?r.parentProperty:l,r=r.path}if(n=n||null,l=l||null,Array.isArray(r)&&(r=O.toPathString(r)),!r&&r!==""||!e)return;const d=O.toPathArray(r);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;const h=this._trace(d,e,["$"],n,l,t).filter(function(b){return b&&!b.isParentSelector});return h.length?!f&&h.length===1&&!h[0].hasArrExpr?this._getPreferredOutput(h[0]):h.reduce((b,k)=>{const w=this._getPreferredOutput(k);return u&&Array.isArray(w)?b=b.concat(w):b.push(w),b},[]):f?[]:void 0},O.prototype._getPreferredOutput=function(r){const e=this.currResultType;switch(e){case"all":{const t=Array.isArray(r.path)?r.path:O.toPathArray(r.path);return r.pointer=O.toPointer(t),r.path=typeof r.path=="string"?r.path:O.toPathString(r.path),r}case"value":case"parent":case"parentProperty":return r[e];case"path":return O.toPathString(r[e]);case"pointer":return O.toPointer(r.path);default:throw new TypeError("Unknown result type")}},O.prototype._handleCallback=function(r,e,t){if(e){const o=this._getPreferredOutput(r);r.path=typeof r.path=="string"?r.path:O.toPathString(r.path),e(o,t,r)}},O.prototype._trace=function(r,e,t,o,n,l,u,f){let d;if(!r.length)return d={path:t,value:e,parent:o,parentProperty:n,hasArrExpr:u},this._handleCallback(d,l,"value"),d;const h=r[0],b=r.slice(1),k=[];function w(m){Array.isArray(m)?m.forEach(S=>{k.push(S)}):k.push(m)}if((typeof h!="string"||f)&&e&&Object.hasOwn(e,h))w(this._trace(b,e[h],T(t,h),e,h,l,u));else if(h==="*")this._walk(e,m=>{w(this._trace(b,e[m],T(t,m),e,m,l,!0,!0))});else if(h==="..")w(this._trace(b,e,t,o,n,l,u)),this._walk(e,m=>{typeof e[m]=="object"&&w(this._trace(r.slice(),e[m],T(t,m),e,m,l,!0))});else{if(h==="^")return this._hasParentSelector=!0,{path:t.slice(0,-1),expr:b,isParentSelector:!0};if(h==="~")return d={path:T(t,h),value:n,parent:o,parentProperty:null},this._handleCallback(d,l,"property"),d;if(h==="$")w(this._trace(b,e,t,null,null,l,u));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(h))w(this._slice(h,b,e,t,o,n,l));else if(h.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const m=h.replace(/^\?\((.*?)\)$/u,"$1"),S=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);S?this._walk(e,A=>{const D=[S[2]],P=S[1]?e[A][S[1]]:e[A];this._trace(D,P,t,o,n,l,!0).length>0&&w(this._trace(b,e[A],T(t,A),e,A,l,!0))}):this._walk(e,A=>{this._eval(m,e[A],A,t,o,n)&&w(this._trace(b,e[A],T(t,A),e,A,l,!0))})}else if(h[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");w(this._trace(G(this._eval(h,e,t.at(-1),t.slice(0,-1),o,n),b),e,t,o,n,l,u))}else if(h[0]==="@"){let m=!1;const S=h.slice(1,-2);switch(S){case"scalar":(!e||!["object","function"].includes(typeof e))&&(m=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===S&&(m=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(m=!0);break;case"number":Number.isFinite(e)&&(m=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(m=!0);break;case"object":e&&typeof e===S&&(m=!0);break;case"array":Array.isArray(e)&&(m=!0);break;case"other":m=this.currOtherTypeCallback(e,t,o,n);break;case"null":e===null&&(m=!0);break;default:throw new TypeError("Unknown value type "+S)}if(m)return d={path:t,value:e,parent:o,parentProperty:n},this._handleCallback(d,l,"value"),d}else if(h[0]==="`"&&e&&Object.hasOwn(e,h.slice(1))){const m=h.slice(1);w(this._trace(b,e[m],T(t,m),e,m,l,u,!0))}else if(h.includes(",")){const m=h.split(",");for(const S of m)w(this._trace(G(S,b),e,t,o,n,l,!0))}else!f&&e&&Object.hasOwn(e,h)&&w(this._trace(b,e[h],T(t,h),e,h,l,u,!0))}if(this._hasParentSelector)for(let m=0;m<k.length;m++){const S=k[m];if(S&&S.isParentSelector){const A=this._trace(S.expr,e,S.path,o,n,l,u);if(Array.isArray(A)){k[m]=A[0];const D=A.length;for(let P=1;P<D;P++)m++,k.splice(m,0,A[P])}else k[m]=A}}return k},O.prototype._walk=function(r,e){if(Array.isArray(r)){const t=r.length;for(let o=0;o<t;o++)e(o)}else r&&typeof r=="object"&&Object.keys(r).forEach(t=>{e(t)})},O.prototype._slice=function(r,e,t,o,n,l,u){if(!Array.isArray(t))return;const f=t.length,d=r.split(":"),h=d[2]&&Number.parseInt(d[2])||1;let b=d[0]&&Number.parseInt(d[0])||0,k=d[1]&&Number.parseInt(d[1])||f;b=b<0?Math.max(0,b+f):Math.min(f,b),k=k<0?Math.max(0,k+f):Math.min(f,k);const w=[];for(let m=b;m<k;m+=h)this._trace(G(m,e),t,o,n,l,u,!0).forEach(A=>{w.push(A)});return w},O.prototype._eval=function(r,e,t,o,n,l){this.currSandbox._$_parentProperty=l,this.currSandbox._$_parent=n,this.currSandbox._$_property=t,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;const u=r.includes("@path");u&&(this.currSandbox._$_path=O.toPathString(o.concat([t])));const f=this.currEval+"Script:"+r;if(!O.cache[f]){let d=r.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(u&&(d=d.replaceAll("@path","_$_path")),this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)O.cache[f]=new this.safeVm.Script(d);else if(this.currEval==="native")O.cache[f]=new this.vm.Script(d);else if(typeof this.currEval=="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const h=this.currEval;O.cache[f]=new h(d)}else if(typeof this.currEval=="function")O.cache[f]={runInNewContext:h=>this.currEval(d,h)};else throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return O.cache[f].runInNewContext(this.currSandbox)}catch(d){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+d.message+": "+r)}},O.cache={},O.toPathString=function(r){const e=r,t=e.length;let o="$";for(let n=1;n<t;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(o+=/^[0-9*]+$/u.test(e[n])?"["+e[n]+"]":"['"+e[n]+"']");return o},O.toPointer=function(r){const e=r,t=e.length;let o="";for(let n=1;n<t;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(o+="/"+e[n].toString().replaceAll("~","~0").replaceAll("/","~1"));return o},O.toPathArray=function(r){const{cache:e}=O;if(e[r])return e[r].concat();const t=[],n=r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,function(l,u){return"[#"+(t.push(u)-1)+"]"}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,function(l,u){return"['"+u.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"}).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,function(l,u){return";"+u.split("").join(";")+";"}).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map(function(l){const u=l.match(/#(\d+)/u);return!u||!u[1]?l:t[u[1]]});return e[r]=n,e[r].concat()},O.prototype.safeVm={Script:le};const ue=function(r,e,t){const o=r.length;for(let n=0;n<o;n++){const l=r[n];t(l)&&e.push(r.splice(n--,1)[0])}};class de{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const o=Object.keys(e),n=[];ue(o,n,h=>typeof e[h]=="function");const l=o.map(h=>e[h]);t=n.reduce((h,b)=>{let k=e[b].toString();return/function/u.test(k)||(k="function "+k),"var "+b+"="+k+";"+h},"")+t,!/(['"])use strict\1/u.test(t)&&!o.includes("arguments")&&(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const f=t.lastIndexOf(";"),d=f!==-1?t.slice(0,f+1)+" return "+t.slice(f+1):" return "+t;return new Function(...o,d)(...l)}}O.prototype.vm={Script:de};const he={class:"json-node"},fe={key:0,class:"json-node__container"},pe={class:"json-node__line"},ye={key:2,class:"json-node__colon"},ge=["title"],Ee={key:3,class:"json-node__collapsed"},me={key:4,class:"json-node__comma"},be={key:0,class:"json-node__children"},_e={class:"json-node__children-content"},xe={class:"json-node__line json-node__closing-bracket"},ke={class:"json-node__bracket"},Oe={key:0,class:"json-node__comma"},Ce={key:1,class:"json-node__primitive"},we={key:2,class:"json-node__colon"},Ae=["title"],Se={key:0,class:"json-node__comma"},Ne=s.defineComponent({name:"JsonNode",__name:"JsonNode",props:{value:{},keyName:{},level:{},path:{default:""},expanded:{},isLast:{type:Boolean,default:!1}},emits:["update:value","toggle-expand","copy","update:key"],setup(r,{emit:e}){s.useCssVars(p=>({"1f6d5aa6":p.level}));const t=r,o=e,n=s.ref(!1),l=s.ref(!1),u=s.ref(""),f=s.ref(""),d=p=>{if(!/^-?\d+(\.\d+)?$/.test(p))return!1;const _=Number(p);return!Number.isSafeInteger(_)||p.length>15},h=s.computed(()=>t.value!==null&&typeof t.value=="object"),b=s.computed(()=>Array.isArray(t.value)),k=s.computed(()=>t.path?t.path:t.keyName?t.keyName:"root"),w=s.computed(()=>t.expanded.has(k.value)),m=s.computed(()=>t.keyName),S=s.computed(()=>b.value?"[":"{"),A=s.computed(()=>b.value?"]":"}"),D=s.computed(()=>{if(!t.value)return"";const _=Object.keys(t.value).length;return b.value?_>0?` ${_} items `:" ":_>0?` ${_} keys `:" "}),P=s.computed(()=>{const p=typeof t.value;return t.value===null?"json-node__value--null":p==="boolean"?"json-node__value--boolean":p==="number"?"json-node__value--number":p==="string"?d(t.value)?"json-node__value--number":"json-node__value--string":""}),F=s.computed(()=>l.value?f.value:t.value===null?"null":typeof t.value=="boolean"||typeof t.value=="number"?String(t.value):typeof t.value=="string"?d(t.value)?t.value:`"${t.value}"`:String(t.value)),K=s.computed(()=>"Click to edit, double-click to copy"),U=p=>t.level===0?p:k.value?`${k.value}.${p}`:p,X=p=>{const _=Object.keys(t.value);return _.indexOf(p)===_.length-1},L=()=>{o("toggle-expand",k.value)},M=()=>{t.level!==0&&(n.value=!0,u.value=t.keyName,s.nextTick(()=>{const p=document.querySelectorAll(".json-node__key-input"),_=p[p.length-1];_&&(_.focus(),_.select())}))},H=()=>{h.value||(l.value=!0,typeof t.value=="string"&&d(t.value)||typeof t.value=="string"?f.value=t.value:f.value=String(t.value),s.nextTick(()=>{const p=document.querySelectorAll(".json-node__value-input"),_=p[p.length-1];_&&(_.focus(),_.select())}))},R=()=>{if(t.level===0||!n.value)return;const p=u.value.trim();if(!p){$();return}if(p===t.keyName){n.value=!1;return}n.value=!1,o("update:key",k.value,p)},Q=()=>{try{let p;const _=f.value.trim();if(_==="null")p=null;else if(_==="true"||_==="false")p=_==="true";else if(!isNaN(Number(_))&&_!==""){const a=Number(_);!Number.isSafeInteger(a)||_.length>15?p=_:p=a}else p=f.value;o("update:value",k.value,p),l.value=!1}catch(p){console.error("Failed to parse value:",p),l.value=!1}},$=()=>{n.value=!1,u.value=t.keyName},Y=()=>{l.value=!1,typeof t.value=="string"&&d(t.value)||typeof t.value=="string"?f.value=t.value:f.value=String(t.value)};return(p,_)=>{const a=s.resolveComponent("JsonNode",!0);return s.openBlock(),s.createElementBlock("div",he,[h.value?(s.openBlock(),s.createElementBlock("div",fe,[s.createElementVNode("div",pe,[p.keyName&&!n.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"json-node__key",onClick:M,title:"Click to edit key"},' "'+s.toDisplayString(m.value)+'" ',1)):s.createCommentVNode("",!0),p.keyName&&n.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:1,"onUpdate:modelValue":_[0]||(_[0]=c=>u.value=c),onKeyup:[s.withKeys(R,["enter"]),s.withKeys($,["escape"])],onBlur:R,class:"json-node__key-input"},null,544)),[[s.vModelText,u.value]]):s.createCommentVNode("",!0),p.keyName?(s.openBlock(),s.createElementBlock("span",ye,": ")):s.createCommentVNode("",!0),s.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:L,title:w.value?"Click to collapse":"Click to expand"},s.toDisplayString(S.value),9,ge),w.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Ee,[s.createTextVNode(s.toDisplayString(D.value)+" ",1),s.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:L},s.toDisplayString(A.value),1)])),!w.value&&!p.isLast?(s.openBlock(),s.createElementBlock("span",me,",")):s.createCommentVNode("",!0)]),w.value?(s.openBlock(),s.createElementBlock("div",be,[s.createElementVNode("div",_e,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(p.value,(c,E)=>(s.openBlock(),s.createElementBlock("div",{key:E,class:"json-node__child"},[s.createVNode(a,{value:c,"key-name":b.value?"":String(E),level:p.level+1,path:U(String(E)),expanded:p.expanded,"onUpdate:value":_[1]||(_[1]=(y,g)=>p.$emit("update:value",y,g)),onToggleExpand:_[2]||(_[2]=y=>p.$emit("toggle-expand",y)),onCopy:_[3]||(_[3]=y=>p.$emit("copy",y)),"onUpdate:key":_[4]||(_[4]=(y,g)=>p.$emit("update:key",y,g)),"is-last":X(String(E))},null,8,["value","key-name","level","path","expanded","is-last"])]))),128))]),s.createElementVNode("div",xe,[s.createElementVNode("span",ke,s.toDisplayString(A.value),1),p.isLast?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Oe,","))])])):s.createCommentVNode("",!0)])):(s.openBlock(),s.createElementBlock("div",Ce,[p.keyName&&!n.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"json-node__key",onClick:M,title:"Click to edit key"},' "'+s.toDisplayString(m.value)+'" ',1)):s.createCommentVNode("",!0),p.keyName&&n.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:1,"onUpdate:modelValue":_[5]||(_[5]=c=>u.value=c),onKeyup:[s.withKeys(R,["enter"]),s.withKeys($,["escape"])],onBlur:R,class:"json-node__key-input"},null,544)),[[s.vModelText,u.value]]):s.createCommentVNode("",!0),p.keyName?(s.openBlock(),s.createElementBlock("span",we,": ")):s.createCommentVNode("",!0),l.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",{key:3,class:s.normalizeClass(["json-node__value",P.value]),onClick:H,onDblclick:_[6]||(_[6]=c=>p.$emit("copy",p.value)),title:K.value},[s.createTextVNode(s.toDisplayString(F.value),1),p.isLast?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Se,","))],42,Ae)),l.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:4,"onUpdate:modelValue":_[7]||(_[7]=c=>f.value=c),onKeyup:[s.withKeys(Q,["enter"]),s.withKeys(Y,["escape"])],onBlur:Q,class:"json-node__value-input"},null,544)),[[s.vModelText,f.value]]):s.createCommentVNode("",!0)]))])}}}),W=(r,e)=>{const t=r.__vccOpts||r;for(const[o,n]of e)t[o]=n;return t},ve=W(Ne,[["__scopeId","data-v-fdfd4b42"]]),Pe={class:"json-format"},Be={key:0,class:"json-format__toolbar"},De={class:"json-format__actions"},je=["disabled"],Ie=["disabled"],Te=["disabled"],$e=["disabled"],Re={class:"json-format__info"},Ve={key:0,class:"json-format__status json-format__status--success"},Ue={key:1,class:"json-format__status json-format__status--error"},Le={class:"json-format__content"},Me={key:0,class:"json-format__error"},Fe={key:1,class:"json-format__error"},Ke={key:2,class:"json-format__viewer"},Z=W(s.defineComponent({name:"JsonFormat",__name:"index",props:{modelValue:{default:""},readonly:{type:Boolean,default:!1},maxDepth:{default:10},showToolbar:{type:Boolean,default:!0}},emits:["update:modelValue","copy-success","copy-error","expand-all","collapse-all","compress"],setup(r,{expose:e,emit:t}){const o=r,n=t,l=s.ref(null),u=s.ref(""),f=s.ref(new Set),d=s.ref(null),h=s.ref(""),b=s.computed(()=>u.value===""),k=s.computed(()=>h.value?null:d.value!==null?d.value:l.value),w=a=>{if(!a.trim()){l.value=null,u.value="",d.value=null,h.value="";return}try{let c=a;c=c.replace(/:\s*(\d{16,})\s*([,}])/g,': "$1"$2'),c=c.replace(/:\s*(\d+\.\d*?0+)\s*([,}])/g,': "$1"$2'),l.value=JSON.parse(c),u.value="",d.value=null,h.value="",s.nextTick(()=>{k.value!==null&&U()})}catch(c){u.value=c instanceof Error?c.message:"Unknown parsing error",l.value=null,d.value=null,h.value=""}},m=a=>{if(!a||!a.expression.trim()){S();return}if(!l.value){h.value="No valid JSON data to filter";return}try{let c;if(a.type==="jsonpath")c=O({path:a.expression,json:l.value}),c.length===1&&a.expression.includes("$[")===!1&&!a.expression.endsWith("[*]")?d.value=c[0]:d.value=c;else if(a.type==="js")c=new Function("data",`
|
|
3
|
+
try {
|
|
4
|
+
return ${a.expression};
|
|
5
|
+
} catch (error) {
|
|
6
|
+
throw new Error('JavaScript expression error: ' + error.message);
|
|
7
|
+
}
|
|
8
|
+
`)(l.value),d.value=c;else throw new Error(`Unsupported filter type: ${a.type}`);h.value="",s.nextTick(()=>{U()})}catch(c){h.value=c instanceof Error?c.message:"Filter execution error",d.value=null}},S=()=>{d.value=null,h.value=""};s.watch(()=>o.modelValue,a=>{w(a)},{immediate:!0});const A=a=>{if(!/^-?\d+(\.\d+)?$/.test(a))return!1;const c=Number(a);return!Number.isSafeInteger(c)||a.length>15},D=(a,c,E)=>JSON.stringify(a,(y,g)=>{if(typeof g=="string"&&A(g))return`__BIG_NUMBER__${g}__BIG_NUMBER__`;if(typeof g=="string"&&/^-?\d+(\.\d+)?$/.test(g)){const x=Number(g);if(Number.isSafeInteger(x)&&x.toString()===g)return x;if(!Number.isNaN(x)&&isFinite(x)&&g.includes("."))return x.toString()===g?x:g;if(!Number.isNaN(x)&&isFinite(x))return x}return c&&typeof c=="function"?c(y,g):g},E).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g,"$1"),P=(a,c)=>{if(!o.readonly)try{const E=F(l.value,a,c),y=D(E,null,2);n("update:modelValue",y)}catch(E){console.error("Failed to update JSON:",E)}},F=(a,c,E)=>{if(!c||c==="root")return E;const y=c.split("."),g=$(a,y.slice(0,-1));let x=g;for(let v=0;v<y.length-1;v++){const j=y[v];j!=="root"&&(Array.isArray(x)?x=x[parseInt(j)]:x=x[j])}const N=y[y.length-1];return N==="root"?E:(Array.isArray(x)?x[parseInt(N)]=E:x[N]=E,g)},K=a=>{f.value.has(a)?f.value.delete(a):f.value.add(a)},U=()=>{const a=new Set,c=(E,y="")=>{E!==null&&typeof E=="object"&&(a.add(y||"root"),Array.isArray(E)?E.forEach((g,x)=>{const N=y?`${y}.${x}`:`${x}`;c(g,N)}):Object.keys(E).forEach(g=>{const x=y?`${y}.${g}`:g;c(E[g],x)}))};c(k.value),f.value=a,n("expand-all")},X=()=>{f.value=new Set(["root"]),n("collapse-all")},L=async()=>{if(b.value)try{const a=k.value,E=JSON.stringify(a,null,2).replace(/"(\d{16,})"/g,"$1");await navigator.clipboard.writeText(E),n("copy-success",E)}catch(a){console.error("Failed to copy JSON:",a),n("copy-error",a instanceof Error?a:new Error("Failed to copy JSON"))}},M=()=>{if(b.value)try{const a=k.value,c=D(a);n("update:modelValue",c),n("compress",c)}catch(a){console.error("Failed to compress JSON:",a)}},H=async a=>{try{let c;typeof a=="string"&&A(a)?c=a:typeof a=="string"?c=`"${a}"`:c=JSON.stringify(a),await navigator.clipboard.writeText(c)}catch(c){console.error("Failed to copy value:",c)}},R=(a,c)=>{if(!o.readonly)try{const E=Q(l.value,a,c),y=D(E,null,2);n("update:modelValue",y),_(a,c)}catch(E){console.error("Failed to rename key:",E)}},Q=(a,c,E)=>{if(!c||c==="root")return a;const y=c.split("."),g=$(a,y.slice(0,-1));if(y.length===1){const v=y[0];return g&&typeof g=="object"&&!Array.isArray(g)?Y(g,v,E):g}let x=g;for(let v=0;v<y.length-1;v++){const j=y[v];Array.isArray(x)?x=x[parseInt(j)]:x=x[j]}const N=y[y.length-1];if(!Array.isArray(x)&&x&&typeof x=="object"){const v=Y(x,N,E),j=y.slice(0,-1);j.length>0&&p(g,j,v)}return g},$=(a,c)=>{if(c.length===0)return a;if(Array.isArray(a)){const E=[...a],y=c[0],g=parseInt(y);return c.length===1||(E[g]=$(a[g],c.slice(1))),E}else if(a&&typeof a=="object"){const E={...a},y=c[0];return c.length===1||(E[y]=$(a[y],c.slice(1))),E}return a},Y=(a,c,E)=>{if(!a||typeof a!="object"||Array.isArray(a))return a;const y=Object.keys(a),g={};for(const x of y)x===c?g[E]=a[x]:g[x]=a[x];return g},p=(a,c,E)=>{let y=a;for(let x=0;x<c.length-1;x++){const N=c[x];Array.isArray(y)?y=y[parseInt(N)]:y=y[N]}const g=c[c.length-1];Array.isArray(y)?y[parseInt(g)]=E:y[g]=E},_=(a,c)=>{const E=new Set;f.value.forEach(y=>{if(y===a){const g=a.split(".");g[g.length-1]=c,E.add(g.join("."))}else if(y.startsWith(a+".")){const g=a.split(".");g[g.length-1]=c;const x=g.join("."),N=y.substring(a.length);E.add(x+N)}else E.add(y)}),f.value=E};return e({copyJson:L,compressSource:M,expandAll:U,collapseAll:X,toggleExpand:K,updateValue:P,updateKey:R,filter:m,clearFilter:S,isValidJson:()=>b.value,getParsedJson:()=>l.value,getFilteredJson:()=>d.value,getExpandedNodes:()=>f.value,getParseError:()=>u.value,getFilterError:()=>h.value,parseJson:a=>w(a),copyValue:a=>H(a)}),(a,c)=>(s.openBlock(),s.createElementBlock("div",Pe,[a.showToolbar?(s.openBlock(),s.createElementBlock("div",Be,[s.createElementVNode("div",De,[s.createElementVNode("button",{class:"json-format__btn json-format__btn--primary",onClick:L,disabled:!b.value,title:"Copy JSON"}," 📋 Copy ",8,je),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:U,disabled:!b.value,title:"Expand All"}," ⬇️ Expand All ",8,Ie),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:X,disabled:!b.value,title:"Collapse All"}," ➡️ Collapse All ",8,Te),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:M,disabled:!b.value,title:"Compress JSON"}," 📦 Compress ",8,$e)]),s.createElementVNode("div",Re,[b.value?(s.openBlock(),s.createElementBlock("span",Ve," ✅ Valid JSON ")):(s.openBlock(),s.createElementBlock("span",Ue," ❌ Invalid JSON "))])])):s.createCommentVNode("",!0),s.createElementVNode("div",Le,[b.value?h.value?(s.openBlock(),s.createElementBlock("div",Fe,[c[1]||(c[1]=s.createElementVNode("h4",null,"Filter Error:",-1)),s.createElementVNode("pre",null,s.toDisplayString(h.value),1)])):(s.openBlock(),s.createElementBlock("div",Ke,[s.createVNode(ve,{value:k.value,"key-name":"",level:0,expanded:f.value,"is-last":!0,"onUpdate:value":P,onToggleExpand:K,onCopy:H,"onUpdate:key":R},null,8,["value","expanded"])])):(s.openBlock(),s.createElementBlock("div",Me,[c[0]||(c[0]=s.createElementVNode("h4",null,"JSON Parse Error:",-1)),s.createElementVNode("pre",null,s.toDisplayString(u.value),1)]))])]))}}),[["__scopeId","data-v-c212b38f"]]),Xe=[Z],He={install:r=>{Xe.forEach(e=>{const t=e.name||e.__name||"UnknownComponent";r.component(t,e)})}};I.JsonFormat=Z,I.default=He,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lone-format",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Vue 3 component library for formatting with tree-shaking support",
|
|
6
6
|
"main": "./dist/lone-format.umd.cjs",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@types/json-bigint": "^1.0.4",
|
|
37
|
-
"json-bigint": "^1.0.0"
|
|
37
|
+
"json-bigint": "^1.0.0",
|
|
38
|
+
"jsonpath-plus": "^10.3.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"vue": ">=3.0.0"
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"prettier": "^3.6.2",
|
|
48
49
|
"typescript": "~5.8.3",
|
|
49
50
|
"vite": "^7.0.4",
|
|
51
|
+
"vite-plugin-dts": "^4.5.4",
|
|
50
52
|
"vitepress": "^1.6.3",
|
|
51
53
|
"vue-tsc": "^2.2.12"
|
|
52
54
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { PropType as __PropType } from 'vue';
|
|
2
|
-
declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
-
value: {
|
|
4
|
-
type: __PropType<any>;
|
|
5
|
-
required: true;
|
|
6
|
-
};
|
|
7
|
-
keyName: {
|
|
8
|
-
type: __PropType<string>;
|
|
9
|
-
required: true;
|
|
10
|
-
};
|
|
11
|
-
level: {
|
|
12
|
-
type: __PropType<number>;
|
|
13
|
-
required: true;
|
|
14
|
-
};
|
|
15
|
-
path: {
|
|
16
|
-
type: __PropType<string>;
|
|
17
|
-
required: false;
|
|
18
|
-
default: string;
|
|
19
|
-
};
|
|
20
|
-
expanded: {
|
|
21
|
-
type: __PropType<Set<string>>;
|
|
22
|
-
required: true;
|
|
23
|
-
};
|
|
24
|
-
isLast: {
|
|
25
|
-
type: __PropType<boolean>;
|
|
26
|
-
required: false;
|
|
27
|
-
default: boolean;
|
|
28
|
-
};
|
|
29
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "toggle-expand" | "copy" | "update:key")[], "update:value" | "toggle-expand" | "copy" | "update:key", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
30
|
-
value: {
|
|
31
|
-
type: __PropType<any>;
|
|
32
|
-
required: true;
|
|
33
|
-
};
|
|
34
|
-
keyName: {
|
|
35
|
-
type: __PropType<string>;
|
|
36
|
-
required: true;
|
|
37
|
-
};
|
|
38
|
-
level: {
|
|
39
|
-
type: __PropType<number>;
|
|
40
|
-
required: true;
|
|
41
|
-
};
|
|
42
|
-
path: {
|
|
43
|
-
type: __PropType<string>;
|
|
44
|
-
required: false;
|
|
45
|
-
default: string;
|
|
46
|
-
};
|
|
47
|
-
expanded: {
|
|
48
|
-
type: __PropType<Set<string>>;
|
|
49
|
-
required: true;
|
|
50
|
-
};
|
|
51
|
-
isLast: {
|
|
52
|
-
type: __PropType<boolean>;
|
|
53
|
-
required: false;
|
|
54
|
-
default: boolean;
|
|
55
|
-
};
|
|
56
|
-
}>> & Readonly<{
|
|
57
|
-
"onUpdate:value"?: (...args: any[]) => any;
|
|
58
|
-
"onToggle-expand"?: (...args: any[]) => any;
|
|
59
|
-
onCopy?: (...args: any[]) => any;
|
|
60
|
-
"onUpdate:key"?: (...args: any[]) => any;
|
|
61
|
-
}>, {
|
|
62
|
-
path: string;
|
|
63
|
-
isLast: boolean;
|
|
64
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
|
-
export default _sfc_main;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { PropType as __PropType } from 'vue';
|
|
2
|
-
declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
-
modelValue: {
|
|
4
|
-
type: __PropType<string>;
|
|
5
|
-
required: true;
|
|
6
|
-
default: string;
|
|
7
|
-
};
|
|
8
|
-
readonly: {
|
|
9
|
-
type: __PropType<boolean>;
|
|
10
|
-
required: false;
|
|
11
|
-
default: boolean;
|
|
12
|
-
};
|
|
13
|
-
maxDepth: {
|
|
14
|
-
type: __PropType<number>;
|
|
15
|
-
required: false;
|
|
16
|
-
default: number;
|
|
17
|
-
};
|
|
18
|
-
showToolbar: {
|
|
19
|
-
type: __PropType<boolean>;
|
|
20
|
-
required: false;
|
|
21
|
-
default: boolean;
|
|
22
|
-
};
|
|
23
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "copy-success" | "copy-error" | "expand-all" | "collapse-all")[], "update:modelValue" | "copy-success" | "copy-error" | "expand-all" | "collapse-all", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: __PropType<string>;
|
|
26
|
-
required: true;
|
|
27
|
-
default: string;
|
|
28
|
-
};
|
|
29
|
-
readonly: {
|
|
30
|
-
type: __PropType<boolean>;
|
|
31
|
-
required: false;
|
|
32
|
-
default: boolean;
|
|
33
|
-
};
|
|
34
|
-
maxDepth: {
|
|
35
|
-
type: __PropType<number>;
|
|
36
|
-
required: false;
|
|
37
|
-
default: number;
|
|
38
|
-
};
|
|
39
|
-
showToolbar: {
|
|
40
|
-
type: __PropType<boolean>;
|
|
41
|
-
required: false;
|
|
42
|
-
default: boolean;
|
|
43
|
-
};
|
|
44
|
-
}>> & Readonly<{
|
|
45
|
-
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
46
|
-
"onCopy-success"?: (...args: any[]) => any;
|
|
47
|
-
"onCopy-error"?: (...args: any[]) => any;
|
|
48
|
-
"onExpand-all"?: (...args: any[]) => any;
|
|
49
|
-
"onCollapse-all"?: (...args: any[]) => any;
|
|
50
|
-
}>, {
|
|
51
|
-
modelValue: string;
|
|
52
|
-
readonly: boolean;
|
|
53
|
-
maxDepth: number;
|
|
54
|
-
showToolbar: boolean;
|
|
55
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
56
|
-
export default _sfc_main;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JsonFormat 组件暴露的方法接口
|
|
3
|
-
*/
|
|
4
|
-
export interface JsonFormatExposed {
|
|
5
|
-
copyJson: () => Promise<void>;
|
|
6
|
-
expandAll: () => void;
|
|
7
|
-
collapseAll: () => void;
|
|
8
|
-
toggleExpand: (path: string) => void;
|
|
9
|
-
updateValue: (path: string, newValue: any) => void;
|
|
10
|
-
updateKey: (oldPath: string, newKey: string) => void;
|
|
11
|
-
isValidJson: () => boolean;
|
|
12
|
-
getParsedJson: () => any;
|
|
13
|
-
getExpandedNodes: () => Set<string>;
|
|
14
|
-
getParseError: () => string;
|
|
15
|
-
parseJson: (jsonString: string) => void;
|
|
16
|
-
copyValue: (value: any) => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* JsonFormat 组件的 Props 接口
|
|
20
|
-
*/
|
|
21
|
-
export interface JsonFormatProps {
|
|
22
|
-
modelValue: string;
|
|
23
|
-
readonly?: boolean;
|
|
24
|
-
maxDepth?: number;
|
|
25
|
-
showToolbar?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* JsonFormat 组件的事件接口
|
|
29
|
-
*/
|
|
30
|
-
export interface JsonFormatEmits {
|
|
31
|
-
'update:modelValue': [value: string];
|
|
32
|
-
'copy-success': [value: string];
|
|
33
|
-
'copy-error': [error: Error];
|
|
34
|
-
'expand-all': [];
|
|
35
|
-
'collapse-all': [];
|
|
36
|
-
}
|