FLUJOS/VISUALIZACION/node_modules/tomlify-j0.4/dist/tomlify.min.js
2025-11-07 00:06:12 +01:00

1 line
No EOL
6.6 KiB
JavaScript
Executable file

(function(){"use strict";var r=function(r,e){if(0===r.length)return"";for(var n="",i=0,u=r.length;i<u;i++)if(t(r[i])&&r[i])n+=(n?".":"")+d(r[i]);else{if(!a(r[i]))return!1;e||(n+=(n?".":"")+"["+r[i]+"]")}return n||!1},e=function(e,n){return(r(e)||"<root>")+": "+n},n=function(r){return Object.prototype.toString.call(r)};n.Boolean=n(!1),n.String=n(""),n.Number=n(0),n.Array=n([]),n.Date=n(new Date(0));var t=function(r){return"string"==typeof r},a=function(r){return"number"==typeof r},i=Array.isArray||function(r){return n(r)===n.Array},u=function(r){return n(r)===n.Date},o=function(r){return null!==r&&"object"==typeof r&&!(i(r)||u(r))},l=function(r){if(r.length<2)return!1;for(var e=n(r[0]),t=1,a=r.length;t<a;t++)if(null!=r[t]&&n(r[t])!==e)return!0;return!1},f=function(r){if(r.length<1)return!1;for(var e=0,n=r.length;e<n;e++)if(o(r[e]))return!0;return!1},p=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},c=function(r){var e=function(r,n){if(!i(r)&&!o(r))return!1;if(-1!==n.indexOf(r))return!0;n.push(r);for(var t in r)if(p(r,t)){var a=n.length;if(e(r[t],n))return!0;n.splice(a)}return!1};return e(r,[])},s=function(r,e,n){return n?"true":"false"},h=function(r,e,n){return"object"==typeof JSON&&JSON?JSON.stringify(n):'"'+String(n).replace(/[\x00-\x1F"\\]/g,function(r){switch(r){case'"':case"\\":return"\\"+r;case"\t":return"\\t";case"\n":return"\\n";case"\r":return"\\r";case"\b":return"\\b";case"\f":return"\\f";default:var e=r.charCodeAt(0).toString(16);return"\\u"+"0000".substr(e.length)+e}})+'"'},v=function(r,n,t){if(!isFinite(t))throw new Error(e(r.path,"Number must be finite."));var a;return a=(Number.isInteger?Number.isInteger(t):Math.floor(t)===t)?t.toFixed(1):String(t),a=a.replace(/([eE])(\d)/,"$1+$2"),/[.eE]/.test(a)?a:a+".0"},b=function(r,n,a){if(l(a))throw new Error(e(r.path,"Array cannot contain values of different types."));var i=r.table;r.table=a;var u=[],o=r.inPair;f(a)&&(r.inPair=!0);for(var p=0,c=a.length;p<c;p++){r.path.push(p);var s=w(r,p,a[p]);t(s)&&u.push(s),r.path.pop()}return r.inPair=o,r.table=i,!r.inPair&&u.length>0&&r.space?"[\n"+T(u.join(",\n"),1,r.space)+"\n]":"["+u.join(", ")+"]"},y=function(r,n,t){if(!isFinite(t.getTime()))throw new Error(e(r.path,"Invalid Date"));return t.toISOString()},g=function(r,n,a){var i=r.table;r.table=a;var u=r.inPair;r.inPair=!0;var o=[],l=Object.keys(a);r.sort&&l.sort(r.sort);for(var f=0,c=l.length;f<c;f++){var s=l[f];if(p(a,s)&&null!=a[s]){if(!s)throw new Error(e(r.path,"Key cannot be an empty string."));r.path.push(s);var h=w(r,s,a[s]);t(h)&&o.push(d(s)+" = "+h),r.path.pop()}}return r.inPair=u,r.table=i,"{"+o.join(", ")+"}"},w=function(r,a,i){if(r.replace){var u=r.replace.call(E(r),a,i);if(t(u))return u;if(null==u)return null;if(!1!==u)throw new Error(e(r.path,"Replacer must return a string, false, null or undefined."))}switch(n(i)){case n.Boolean:return s(0,0,i);case n.String:return h(0,0,i);case n.Number:return v(r,0,i);case n.Array:return b(r,0,i);case n.Date:return y(r,0,i);default:return null==i?null:g(r,0,i)}},m=function(r,e){return w({path:[],table:{"":r},inPair:!1,inTableArray:!1,sort:e.sort,replace:e.replace,level:0,space:P(e.space)},"",r)},d=function(r){return!!r&&(/^[a-zA-Z0-9\-_]+$/.test(r)?r:h(0,0,r))},A=function(r,n,a){var i=d(n);if(!i)throw new Error(e(r.path,"Key cannot be an empty string."));var u=w(r,n,a);return t(u)?i+" = "+u:null},E=function(r){return{path:r.path.slice(0),table:r.table}},j=function(r,n,a){if(r.replace){var i=r.replace.call(E(r),n,a);if(t(i))return d(n)+" = "+i;if(null==i)return null;if(!1!==i)throw new Error(e(r.path,"Replacer must return a string, false, null or undefined."))}return!1},O=function(r,e,n,a){var u;if(!(r.replace&&0===r.path.length&&(u=j(r,e,n),t(u)&&r.lines.push(u),!1!==u)||a(r,e,n))){var l=r.table;if(r.table=n,i(n)){h=r.inTableArray;r.inTableArray=f(n);for(var c=0,s=n.length;c<s;c++)r.path.push(c),O(r,c,n[c],a),r.path.pop();r.inTableArray=h}else if(o(n)){var h=r.inTableArray;r.inTableArray=!1;var v=[],b=Object.keys(n);r.sort&&b.sort(r.sort);for(var c=0,s=b.length;c<s;c++){d=b[c];if(p(n,d)){var y=n[d],g=r.path.length>0&&(i(y)?f(y):o(y));i(y)&&f(y)?v.push([!0,d,y,g]):o(y)?v.push([!1,d,y,g]):(r.path.push(d),O(r,d,y,a),r.path.pop())}}if(b=null,r.replace)for(var c=0,s=v.length;c<s;c++)if((l=v[c])[0]){if(r.path.push(l[1]),!1!==(u=j(r,l[1],l[2]))){t(u)&&r.lines.push(T(u,r.level,r.space)),l[2]=null,r.path.pop();continue}for(var w=l[2],m=0,d=w.length;m<d;m++){var E=w[m];if(r.path.push(m),u=j(r,m,E),r.path.pop(),!1!==u){if(null==u){w[m]=null;continue}u=A(r,l[1],l[2]),t(u)&&r.lines.push(T(u,r.level,r.space)),l[2]=null;break}}r.path.pop()}else r.path.push(l[1]),!1!==(u=j(r,l[1],l[2]))&&(t(u)&&r.lines.push(T(u,r.level,r.space)),l[2]=null),r.path.pop();for(var c=0,s=v.length;c<s;c++)null!=(l=v[c])[2]&&(r.path.push(l[1]),l[3]&&r.level++,O(r,l[1],l[2],a),l[3]&&r.level--,r.path.pop());r.inTableArray=h}r.table=l}},S=function(r,e){if(r.repeat)return r.repeat(e);for(var n="",t="";e>0;)t+=t||r,1&e&&(n+=t),e>>>=1;return n},T=function(r,e,n){var t=S(n,e);return r.replace(/^(?!$)/gm,t)},P=function(r){return t(r)?r:a(r)&&r>=0&&isFinite(r)&&Math.floor(r)===r?S(" ",r):""},N=function(r,e){if(null==r)throw new Error("Undefined or null cannot be stringified.");if(c(r))throw new Error("Converting circular structure to TOML.");if(null!=e&&"object"!=typeof e)throw new Error("Options must be an object.");if(null!=e.replace&&"function"!=typeof e.replace)throw new Error("Replacer must be a function.");if(null!=e.sort&&"function"!=typeof e.sort)throw new Error("Compare function for sorting must be a function.")},x=function(e,n){var a=[];return O({path:[],table:{"":e},inPair:!1,inTableArray:!1,replace:n.replace,sort:n.sort,level:0,space:P(n.space),lines:a},"",e,function(e,n,u){var l=null;if(o(u))""!==n&&(a.length>0&&a.push(""),l=e.inTableArray?"[["+r(e.path,!0)+"]]":"["+r(e.path,!0)+"]",a.push(T(l,e.level,e.space)));else{if(!i(u))return t(n)&&(l=A(e,n,u),t(l)&&a.push(T(l,e.level,e.space))),!0;if(!t(n))return!0;f(u)||(l=A(e,n,u),t(l)&&a.push(T(l,e.level,e.space)))}}),a.join("\n")},D={};D.toToml=function(r,e){if(!o(r))throw new Error("An object other than Array or Date is expected.");return e=null!=e?e:{},N(r,e),x(r,e)},D.toKey=function(e,n){if(t(e)){if(!(a=d(e)))throw new Error("Key cannot be an empty string.");return a}if(i(e)){var a=r(e,n);if(!1===a)throw new Error("Key path must consist of non-empty string(s).");return a}throw new Error("Invalid Arguments for tomlify.toKey({String | Array})")},D.toValue=function(r,e){return e=null!=e?e:{},N(r,e),m(r,e)},null!=("undefined"!=typeof module&&null!==module?module.exports:void 0)?module.exports=D:"function"==typeof define&&define.amd?define([],function(){return D}):this.tomlify=D}).call(this);