Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sql-formatter-plus

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-formatter-plus - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

dist/sql-formatter.min.js

@@ -1,1 +0,1 @@

!function(e){var E={};function t(r){if(E[r])return E[r].exports;var n=E[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=E,t.d=function(e,E,r){t.o(e,E)||Object.defineProperty(e,E,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,E){if(1&E&&(e=t(e)),8&E)return e;if(4&E&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&E&&"string"!=typeof e)for(var n in e)t.d(r,n,function(E){return e[E]}.bind(null,n));return r},t.n=function(e){var E=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(E,"a",E),E},t.o=function(e,E){return Object.prototype.hasOwnProperty.call(e,E)},t.p="",t(t.s=72)}([function(e,E,t){var r=t(13),n="object"==typeof self&&self&&self.Object===Object&&self,T=r||n||Function("return this")();e.exports=T},function(e,E,t){var r=t(9),n=t(35),T=t(36),R="[object Null]",N="[object Undefined]",o=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?N:R:o&&o in Object(e)?n(e):T(e)}},function(e,E){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,E,t){var r=t(64),n=t(67);e.exports=function(e,E){var t=n(e,E);return r(t)?t:void 0}},function(e,E,t){var r=t(25),n=t(52),T=t(54),R=t(55),N=t(10),o=/\s+$/;e.exports=function(e,E,t){if((e=N(e))&&(t||void 0===E))return e.replace(o,"");if(!e||!(E=r(E)))return e;var A=R(e),I=T(A,R(E))+1;return n(A,0,I).join("")}},function(e,E,t){var r=t(10),n=/[\\^$.*+?()[\]{}|]/g,T=RegExp(n.source);e.exports=function(e){return(e=r(e))&&T.test(e)?e.replace(n,"\\$&"):e}},function(e,E,t){var r=t(12),n=t(14);e.exports=function(e){return null!=e&&n(e.length)&&!r(e)}},function(e,E){e.exports=function(e){var E=typeof e;return null!=e&&("object"==E||"function"==E)}},function(e,E){var t=Array.isArray;e.exports=t},function(e,E,t){var r=t(0).Symbol;e.exports=r},function(e,E,t){var r=t(25);e.exports=function(e){return null==e?"":r(e)}},function(e,E,t){var r=t(31),n=t(32),T=t(33);e.exports=function(e,E,t){return E==E?T(e,E,t):r(e,n,t)}},function(e,E,t){var r=t(1),n=t(7),T="[object AsyncFunction]",R="[object Function]",N="[object GeneratorFunction]",o="[object Proxy]";e.exports=function(e){if(!n(e))return!1;var E=r(e);return E==R||E==N||E==T||E==o}},function(e,E,t){(function(E){var t="object"==typeof E&&E&&E.Object===Object&&E;e.exports=t}).call(this,t(34))},function(e,E){var t=9007199254740991;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=t}},function(e,E,t){var r=t(38);e.exports=function(e){var E=r(e),t=E%1;return E==E?t?E-t:E:0}},function(e,E,t){var r=t(1),n=t(2),T="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||n(e)&&r(e)==T}},function(e,E){e.exports=function(e,E){for(var t=-1,r=null==e?0:e.length,n=Array(r);++t<r;)n[t]=E(e[t],t,e);return n}},function(e,E,t){var r=t(45),n=t(2),T=Object.prototype,R=T.hasOwnProperty,N=T.propertyIsEnumerable,o=r(function(){return arguments}())?r:function(e){return n(e)&&R.call(e,"callee")&&!N.call(e,"callee")};e.exports=o},function(e,E,t){(function(e){var r=t(0),n=t(46),T=E&&!E.nodeType&&E,R=T&&"object"==typeof e&&e&&!e.nodeType&&e,N=R&&R.exports===T?r.Buffer:void 0,o=(N?N.isBuffer:void 0)||n;e.exports=o}).call(this,t(20)(e))},function(e,E){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,E){var t=9007199254740991,r=/^(?:0|[1-9]\d*)$/;e.exports=function(e,E){var n=typeof e;return!!(E=null==E?t:E)&&("number"==n||"symbol"!=n&&r.test(e))&&e>-1&&e%1==0&&e<E}},function(e,E,t){var r=t(47),n=t(48),T=t(49),R=T&&T.isTypedArray,N=R?n(R):r;e.exports=N},function(e,E,t){var r=t(24),n=t(50),T=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return n(e);var E=[];for(var t in Object(e))T.call(e,t)&&"constructor"!=t&&E.push(t);return E}},function(e,E){var t=Object.prototype;e.exports=function(e){var E=e&&e.constructor;return e===("function"==typeof E&&E.prototype||t)}},function(e,E,t){var r=t(9),n=t(17),T=t(8),R=t(16),N=1/0,o=r?r.prototype:void 0,A=o?o.toString:void 0;e.exports=function e(E){if("string"==typeof E)return E;if(T(E))return n(E,e)+"";if(R(E))return A?A.call(E):"";var t=E+"";return"0"==t&&1/E==-N?"-0":t}},function(e,E){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,E,t){var r=t(11),n=t(6),T=t(37),R=t(15),N=t(40),o=Math.max;e.exports=function(e,E,t,A){e=n(e)?e:N(e),t=t&&!A?R(t):0;var I=e.length;return t<0&&(t=o(I+t,0)),T(e)?t<=I&&e.indexOf(E,t)>-1:!!I&&r(e,E,t)>-1}},function(e,E,t){var r=t(59),n=t(60),T=t(15),R=t(10);e.exports=function(e,E,t){return E=(t?n(e,E,t):void 0===E)?1:T(E),r(R(e),E)}},function(e,E){e.exports=function(e){var E=null==e?0:e.length;return E?e[E-1]:void 0}},function(e,E,t){var r=t(23),n=t(62),T=t(18),R=t(8),N=t(6),o=t(19),A=t(24),I=t(22),O="[object Map]",i="[object Set]",S=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(N(e)&&(R(e)||"string"==typeof e||"function"==typeof e.splice||o(e)||I(e)||T(e)))return!e.length;var E=n(e);if(E==O||E==i)return!e.size;if(A(e))return!r(e).length;for(var t in e)if(S.call(e,t))return!1;return!0}},function(e,E){e.exports=function(e,E,t,r){for(var n=e.length,T=t+(r?1:-1);r?T--:++T<n;)if(E(e[T],T,e))return T;return-1}},function(e,E){e.exports=function(e){return e!=e}},function(e,E){e.exports=function(e,E,t){for(var r=t-1,n=e.length;++r<n;)if(e[r]===E)return r;return-1}},function(e,E){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,E,t){var r=t(9),n=Object.prototype,T=n.hasOwnProperty,R=n.toString,N=r?r.toStringTag:void 0;e.exports=function(e){var E=T.call(e,N),t=e[N];try{e[N]=void 0;var r=!0}catch(e){}var n=R.call(e);return r&&(E?e[N]=t:delete e[N]),n}},function(e,E){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},function(e,E,t){var r=t(1),n=t(8),T=t(2),R="[object String]";e.exports=function(e){return"string"==typeof e||!n(e)&&T(e)&&r(e)==R}},function(e,E,t){var r=t(39),n=1/0,T=17976931348623157e292;e.exports=function(e){return e?(e=r(e))===n||e===-n?(e<0?-1:1)*T:e==e?e:0:0===e?e:0}},function(e,E,t){var r=t(7),n=t(16),T=NaN,R=/^\s+|\s+$/g,N=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,A=/^0o[0-7]+$/i,I=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(n(e))return T;if(r(e)){var E="function"==typeof e.valueOf?e.valueOf():e;e=r(E)?E+"":E}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(R,"");var t=o.test(e);return t||A.test(e)?I(e.slice(2),t?2:8):N.test(e)?T:+e}},function(e,E,t){var r=t(41),n=t(42);e.exports=function(e){return null==e?[]:r(e,n(e))}},function(e,E,t){var r=t(17);e.exports=function(e,E){return r(E,(function(E){return e[E]}))}},function(e,E,t){var r=t(43),n=t(23),T=t(6);e.exports=function(e){return T(e)?r(e):n(e)}},function(e,E,t){var r=t(44),n=t(18),T=t(8),R=t(19),N=t(21),o=t(22),A=Object.prototype.hasOwnProperty;e.exports=function(e,E){var t=T(e),I=!t&&n(e),O=!t&&!I&&R(e),i=!t&&!I&&!O&&o(e),S=t||I||O||i,s=S?r(e.length,String):[],L=s.length;for(var C in e)!E&&!A.call(e,C)||S&&("length"==C||O&&("offset"==C||"parent"==C)||i&&("buffer"==C||"byteLength"==C||"byteOffset"==C)||N(C,L))||s.push(C);return s}},function(e,E){e.exports=function(e,E){for(var t=-1,r=Array(e);++t<e;)r[t]=E(t);return r}},function(e,E,t){var r=t(1),n=t(2),T="[object Arguments]";e.exports=function(e){return n(e)&&r(e)==T}},function(e,E){e.exports=function(){return!1}},function(e,E,t){var r=t(1),n=t(14),T=t(2),R={};R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R["[object Arguments]"]=R["[object Array]"]=R["[object ArrayBuffer]"]=R["[object Boolean]"]=R["[object DataView]"]=R["[object Date]"]=R["[object Error]"]=R["[object Function]"]=R["[object Map]"]=R["[object Number]"]=R["[object Object]"]=R["[object RegExp]"]=R["[object Set]"]=R["[object String]"]=R["[object WeakMap]"]=!1,e.exports=function(e){return T(e)&&n(e.length)&&!!R[r(e)]}},function(e,E){e.exports=function(e){return function(E){return e(E)}}},function(e,E,t){(function(e){var r=t(13),n=E&&!E.nodeType&&E,T=n&&"object"==typeof e&&e&&!e.nodeType&&e,R=T&&T.exports===n&&r.process,N=function(){try{var e=T&&T.require&&T.require("util").types;return e||R&&R.binding&&R.binding("util")}catch(e){}}();e.exports=N}).call(this,t(20)(e))},function(e,E,t){var r=t(51)(Object.keys,Object);e.exports=r},function(e,E){e.exports=function(e,E){return function(t){return e(E(t))}}},function(e,E,t){var r=t(53);e.exports=function(e,E,t){var n=e.length;return t=void 0===t?n:t,!E&&t>=n?e:r(e,E,t)}},function(e,E){e.exports=function(e,E,t){var r=-1,n=e.length;E<0&&(E=-E>n?0:n+E),(t=t>n?n:t)<0&&(t+=n),n=E>t?0:t-E>>>0,E>>>=0;for(var T=Array(n);++r<n;)T[r]=e[r+E];return T}},function(e,E,t){var r=t(11);e.exports=function(e,E){for(var t=e.length;t--&&r(E,e[t],0)>-1;);return t}},function(e,E,t){var r=t(56),n=t(57),T=t(58);e.exports=function(e){return n(e)?T(e):r(e)}},function(e,E){e.exports=function(e){return e.split("")}},function(e,E){var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");e.exports=function(e){return t.test(e)}},function(e,E){var t="[\\ud800-\\udfff]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",T="[^\\ud800-\\udfff]",R="(?:\\ud83c[\\udde6-\\uddff]){2}",N="[\\ud800-\\udbff][\\udc00-\\udfff]",o="(?:"+r+"|"+n+")"+"?",A="[\\ufe0e\\ufe0f]?"+o+("(?:\\u200d(?:"+[T,R,N].join("|")+")[\\ufe0e\\ufe0f]?"+o+")*"),I="(?:"+[T+r+"?",r,R,N,t].join("|")+")",O=RegExp(n+"(?="+n+")|"+I+A,"g");e.exports=function(e){return e.match(O)||[]}},function(e,E){var t=9007199254740991,r=Math.floor;e.exports=function(e,E){var n="";if(!e||E<1||E>t)return n;do{E%2&&(n+=e),(E=r(E/2))&&(e+=e)}while(E);return n}},function(e,E,t){var r=t(61),n=t(6),T=t(21),R=t(7);e.exports=function(e,E,t){if(!R(t))return!1;var N=typeof E;return!!("number"==N?n(t)&&T(E,t.length):"string"==N&&E in t)&&r(t[E],e)}},function(e,E){e.exports=function(e,E){return e===E||e!=e&&E!=E}},function(e,E,t){var r=t(63),n=t(68),T=t(69),R=t(70),N=t(71),o=t(1),A=t(26),I=A(r),O=A(n),i=A(T),S=A(R),s=A(N),L=o;(r&&"[object DataView]"!=L(new r(new ArrayBuffer(1)))||n&&"[object Map]"!=L(new n)||T&&"[object Promise]"!=L(T.resolve())||R&&"[object Set]"!=L(new R)||N&&"[object WeakMap]"!=L(new N))&&(L=function(e){var E=o(e),t="[object Object]"==E?e.constructor:void 0,r=t?A(t):"";if(r)switch(r){case I:return"[object DataView]";case O:return"[object Map]";case i:return"[object Promise]";case S:return"[object Set]";case s:return"[object WeakMap]"}return E}),e.exports=L},function(e,E,t){var r=t(3)(t(0),"DataView");e.exports=r},function(e,E,t){var r=t(12),n=t(65),T=t(7),R=t(26),N=/^\[object .+?Constructor\]$/,o=Function.prototype,A=Object.prototype,I=o.toString,O=A.hasOwnProperty,i=RegExp("^"+I.call(O).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!T(e)||n(e))&&(r(e)?i:N).test(R(e))}},function(e,E,t){var r,n=t(66),T=(r=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!T&&T in e}},function(e,E,t){var r=t(0)["__core-js_shared__"];e.exports=r},function(e,E){e.exports=function(e,E){return null==e?void 0:e[E]}},function(e,E,t){var r=t(3)(t(0),"Map");e.exports=r},function(e,E,t){var r=t(3)(t(0),"Promise");e.exports=r},function(e,E,t){var r=t(3)(t(0),"Set");e.exports=r},function(e,E,t){var r=t(3)(t(0),"WeakMap");e.exports=r},function(e,E,t){"use strict";t.r(E);var r=t(27),n=t.n(r),T=t(4),R=t.n(T),N={WHITESPACE:"whitespace",WORD:"word",STRING:"string",RESERVED:"reserved",RESERVED_TOPLEVEL:"reserved-toplevel",RESERVED_NEWLINE:"reserved-newline",OPERATOR:"operator",OPEN_PAREN:"open-paren",CLOSE_PAREN:"close-paren",LINE_COMMENT:"line-comment",BLOCK_COMMENT:"block-comment",NUMBER:"number",PLACEHOLDER:"placeholder"},o=t(28),A=t.n(o),I=t(29),O=t.n(I);const i="top-level",S="block-level";class s{constructor(e){this.indent=e||" ",this.indentTypes=[]}getIndent(){return A()(this.indent,this.indentTypes.length)}increaseToplevel(){this.indentTypes.push(i)}increaseBlockLevel(){this.indentTypes.push(S)}decreaseTopLevel(){O()(this.indentTypes)===i&&this.indentTypes.pop()}decreaseBlockLevel(){for(;this.indentTypes.length>0;){if(this.indentTypes.pop()!==i)break}}}const L=50;class C{constructor(){this.level=0}beginIfPossible(e,E){0===this.level&&this.isInlineBlock(e,E)?this.level=1:this.level>0?this.level++:this.level=0}end(){this.level--}isActive(){return this.level>0}isInlineBlock(e,E){let t=0,r=0;for(let n=E;n<e.length;n++){const E=e[n];if((t+=E.value.length)>L)return!1;if(E.type===N.OPEN_PAREN)r++;else if(E.type===N.CLOSE_PAREN&&0===--r)return!0;if(this.isForbiddenToken(E))return!1}return!1}isForbiddenToken({type:e,value:E}){return e===N.RESERVED_TOPLEVEL||e===N.RESERVED_NEWLINE||e===N.COMMENT||e===N.BLOCK_COMMENT||";"===E}}class u{constructor(e){this.params=e,this.index=0}get({key:e,value:E}){return this.params?e?this.params[e]:this.params[this.index++]:E}}class a{constructor(e,E){this.cfg=e||{},this.indentation=new s(this.cfg.indent),this.inlineBlock=new C,this.params=new u(this.cfg.params),this.tokenizer=E,this.previousReservedWord={},this.tokens=[],this.index=0}format(e){return this.tokens=this.tokenizer.tokenize(e),this.getFormattedQueryFromTokens().trim()}getFormattedQueryFromTokens(){let e="";return this.tokens.forEach((E,t)=>{this.index=t,E.type===N.WHITESPACE||(E.type===N.LINE_COMMENT?e=this.formatLineComment(E,e):E.type===N.BLOCK_COMMENT?e=this.formatBlockComment(E,e):E.type===N.RESERVED_TOPLEVEL?(e=this.formatToplevelReservedWord(E,e),this.previousReservedWord=E):E.type===N.RESERVED_NEWLINE?(e=this.formatNewlineReservedWord(E,e),this.previousReservedWord=E):E.type===N.RESERVED?(e=this.formatWithSpaces(E,e),this.previousReservedWord=E):e=E.type===N.OPEN_PAREN?this.formatOpeningParentheses(E,e):E.type===N.CLOSE_PAREN?this.formatClosingParentheses(E,e):E.type===N.PLACEHOLDER?this.formatPlaceholder(E,e):","===E.value?this.formatComma(E,e):":"===E.value?this.formatWithSpaceAfter(E,e):"."===E.value?this.formatWithoutSpaces(E,e):";"===E.value?this.formatQuerySeparator(E,e):this.formatWithSpaces(E,e))}),e}formatLineComment(e,E){return this.addNewline(E+e.value)}formatBlockComment(e,E){return this.addNewline(this.addNewline(E)+this.indentComment(e.value))}indentComment(e){return e.replace(/\n/gu,"\n"+this.indentation.getIndent())}formatToplevelReservedWord(e,E){return this.indentation.decreaseTopLevel(),E=this.addNewline(E),this.indentation.increaseToplevel(),E+=this.equalizeWhitespace(this.formatReservedWord(e.value)),this.addNewline(E)}formatNewlineReservedWord(e,E){return this.addNewline(E)+this.equalizeWhitespace(this.formatReservedWord(e.value))+" "}equalizeWhitespace(e){return e.replace(/\s+/gu," ")}formatOpeningParentheses(e,E){const t=[N.WHITESPACE,N.OPEN_PAREN,N.LINE_COMMENT];return n()(t,this.previousToken().type)||(E=R()(E)),E+=e.value,this.inlineBlock.beginIfPossible(this.tokens,this.index),this.inlineBlock.isActive()||(this.indentation.increaseBlockLevel(),E=this.addNewline(E)),E}formatClosingParentheses(e,E){return this.inlineBlock.isActive()?(this.inlineBlock.end(),this.formatWithSpaceAfter(e,E)):(this.indentation.decreaseBlockLevel(),this.formatWithSpaces(e,this.addNewline(E)))}formatPlaceholder(e,E){return E+this.params.get(e)+" "}formatComma(e,E){return E=this.trimTrailingWhitespace(E)+e.value+" ",this.inlineBlock.isActive()?E:/^LIMIT$/iu.test(this.previousReservedWord.value)?E:this.addNewline(E)}formatWithSpaceAfter(e,E){return this.trimTrailingWhitespace(E)+e.value+" "}formatWithoutSpaces(e,E){return this.trimTrailingWhitespace(E)+e.value}formatWithSpaces(e,E){return E+("reserved"===e.type?this.formatReservedWord(e.value):e.value)+" "}formatReservedWord(e){return this.cfg.uppercase?e.toUpperCase():e}formatQuerySeparator(e,E){return this.indentation.decreaseTopLevel(),this.trimTrailingWhitespace(E)+e.value+"\n"}addNewline(e){return R()(e)+"\n"+this.indentation.getIndent()}trimTrailingWhitespace(e){return this.previousNonWhitespaceToken().type===N.LINE_COMMENT?R()(e)+"\n":R()(e)}previousNonWhitespaceToken(){let e=1;for(;this.previousToken(e).type===N.WHITESPACE;)e++;return this.previousToken(e)}previousToken(e=1){return this.tokens[this.index-e]||{}}}var c=t(30),l=t.n(c),P=t(5),p=t.n(P);class D{constructor(e){this.WHITESPACE_REGEX=/^(\s+)/u,this.NUMBER_REGEX=/^((-\s*)?[0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)\b/u,this.OPERATOR_REGEX=/^(!=|<>|==|<=|>=|!<|!>|\|\||::|->>|->|~~\*|~~|!~~\*|!~~|~\*|!~\*|!~|.)/u,this.BLOCK_COMMENT_REGEX=/^(\/\*[^]*?(?:\*\/|$))/u,this.LINE_COMMENT_REGEX=this.createLineCommentRegex(e.lineCommentTypes),this.RESERVED_TOPLEVEL_REGEX=this.createReservedWordRegex(e.reservedToplevelWords),this.RESERVED_NEWLINE_REGEX=this.createReservedWordRegex(e.reservedNewlineWords),this.RESERVED_PLAIN_REGEX=this.createReservedWordRegex(e.reservedWords),this.WORD_REGEX=this.createWordRegex(e.specialWordChars),this.STRING_REGEX=this.createStringRegex(e.stringTypes),this.OPEN_PAREN_REGEX=this.createParenRegex(e.openParens),this.CLOSE_PAREN_REGEX=this.createParenRegex(e.closeParens),this.INDEXED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.indexedPlaceholderTypes,"[0-9]*"),this.IDENT_NAMED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.namedPlaceholderTypes,"[a-zA-Z0-9._$]+"),this.STRING_NAMED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.namedPlaceholderTypes,this.createStringPattern(e.stringTypes))}createLineCommentRegex(e){return new RegExp(`^((?:${e.map(e=>p()(e)).join("|")}).*?(?:\r\n|\r|\n|$))`,"u")}createReservedWordRegex(e){const E=e.join("|").replace(/ /gu,"\\s+");return new RegExp(`^(${E})\\b`,"iu")}createWordRegex(e=[]){return new RegExp(`^([\\p{Alphabetic}\\p{Mark}\\p{Decimal_Number}\\p{Connector_Punctuation}\\p{Join_Control}${e.join("")}]+)`,"u")}createStringRegex(e){return new RegExp("^("+this.createStringPattern(e)+")","u")}createStringPattern(e){const E={"``":"((`[^`]*($|`))+)","[]":"((\\[[^\\]]*($|\\]))(\\][^\\]]*($|\\]))*)",'""':'(("[^"\\\\]*(?:\\\\.[^"\\\\]*)*("|$))+)',"''":"(('[^'\\\\]*(?:\\\\.[^'\\\\]*)*('|$))+)","N''":"((N'[^N'\\\\]*(?:\\\\.[^N'\\\\]*)*('|$))+)"};return e.map(e=>E[e]).join("|")}createParenRegex(e){return new RegExp("^("+e.map(e=>this.escapeParen(e)).join("|")+")","iu")}escapeParen(e){return 1===e.length?p()(e):"\\b"+e+"\\b"}createPlaceholderRegex(e,E){if(l()(e))return!1;const t=e.map(p.a).join("|");return new RegExp(`^((?:${t})(?:${E}))`,"u")}tokenize(e){if(!e)return[];const E=[];let t;for(;e.length;)t=this.getNextToken(e,t),e=e.substring(t.value.length),E.push(t);return E}getNextToken(e,E){return this.getWhitespaceToken(e)||this.getCommentToken(e)||this.getStringToken(e)||this.getOpenParenToken(e)||this.getCloseParenToken(e)||this.getPlaceholderToken(e)||this.getNumberToken(e)||this.getReservedWordToken(e,E)||this.getWordToken(e)||this.getOperatorToken(e)}getWhitespaceToken(e){return this.getTokenOnFirstMatch({input:e,type:N.WHITESPACE,regex:this.WHITESPACE_REGEX})}getCommentToken(e){return this.getLineCommentToken(e)||this.getBlockCommentToken(e)}getLineCommentToken(e){return this.getTokenOnFirstMatch({input:e,type:N.LINE_COMMENT,regex:this.LINE_COMMENT_REGEX})}getBlockCommentToken(e){return this.getTokenOnFirstMatch({input:e,type:N.BLOCK_COMMENT,regex:this.BLOCK_COMMENT_REGEX})}getStringToken(e){return this.getTokenOnFirstMatch({input:e,type:N.STRING,regex:this.STRING_REGEX})}getOpenParenToken(e){return this.getTokenOnFirstMatch({input:e,type:N.OPEN_PAREN,regex:this.OPEN_PAREN_REGEX})}getCloseParenToken(e){return this.getTokenOnFirstMatch({input:e,type:N.CLOSE_PAREN,regex:this.CLOSE_PAREN_REGEX})}getPlaceholderToken(e){return this.getIdentNamedPlaceholderToken(e)||this.getStringNamedPlaceholderToken(e)||this.getIndexedPlaceholderToken(e)}getIdentNamedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.IDENT_NAMED_PLACEHOLDER_REGEX,parseKey:e=>e.slice(1)})}getStringNamedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.STRING_NAMED_PLACEHOLDER_REGEX,parseKey:e=>this.getEscapedPlaceholderKey({key:e.slice(2,-1),quoteChar:e.slice(-1)})})}getIndexedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.INDEXED_PLACEHOLDER_REGEX,parseKey:e=>e.slice(1)})}getPlaceholderTokenWithKey({input:e,regex:E,parseKey:t}){const r=this.getTokenOnFirstMatch({input:e,regex:E,type:N.PLACEHOLDER});return r&&(r.key=t(r.value)),r}getEscapedPlaceholderKey({key:e,quoteChar:E}){return e.replace(new RegExp(p()("\\"+E),"gu"),E)}getNumberToken(e){return this.getTokenOnFirstMatch({input:e,type:N.NUMBER,regex:this.NUMBER_REGEX})}getOperatorToken(e){return this.getTokenOnFirstMatch({input:e,type:N.OPERATOR,regex:this.OPERATOR_REGEX})}getReservedWordToken(e,E){if(!E||!E.value||"."!==E.value)return this.getToplevelReservedToken(e)||this.getNewlineReservedToken(e)||this.getPlainReservedToken(e)}getToplevelReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:N.RESERVED_TOPLEVEL,regex:this.RESERVED_TOPLEVEL_REGEX})}getNewlineReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:N.RESERVED_NEWLINE,regex:this.RESERVED_NEWLINE_REGEX})}getPlainReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:N.RESERVED,regex:this.RESERVED_PLAIN_REGEX})}getWordToken(e){return this.getTokenOnFirstMatch({input:e,type:N.WORD,regex:this.WORD_REGEX})}getTokenOnFirstMatch({input:e,type:E,regex:t}){const r=e.match(t);if(r)return{type:E,value:r[1]}}}const f=["ABS","ACTIVATE","ALIAS","ALL","ALLOCATE","ALLOW","ALTER","ANY","ARE","ARRAY","AS","ASC","ASENSITIVE","ASSOCIATE","ASUTIME","ASYMMETRIC","AT","ATOMIC","ATTRIBUTES","AUDIT","AUTHORIZATION","AUX","AUXILIARY","AVG","BEFORE","BEGIN","BETWEEN","BIGINT","BINARY","BLOB","BOOLEAN","BOTH","BUFFERPOOL","BY","CACHE","CALL","CALLED","CAPTURE","CARDINALITY","CASCADED","CASE","CAST","CCSID","CEIL","CEILING","CHAR","CHARACTER","CHARACTER_LENGTH","CHAR_LENGTH","CHECK","CLOB","CLONE","CLOSE","CLUSTER","COALESCE","COLLATE","COLLECT","COLLECTION","COLLID","COLUMN","COMMENT","COMMIT","CONCAT","CONDITION","CONNECT","CONNECTION","CONSTRAINT","CONTAINS","CONTINUE","CONVERT","CORR","CORRESPONDING","COUNT","COUNT_BIG","COVAR_POP","COVAR_SAMP","CREATE","CROSS","CUBE","CUME_DIST","CURRENT","CURRENT_DATE","CURRENT_DEFAULT_TRANSFORM_GROUP","CURRENT_LC_CTYPE","CURRENT_PATH","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_SERVER","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","CURRENT_TRANSFORM_GROUP_FOR_TYPE","CURRENT_USER","CURSOR","CYCLE","DATA","DATABASE","DATAPARTITIONNAME","DATAPARTITIONNUM","DATE","DAY","DAYS","DB2GENERAL","DB2GENRL","DB2SQL","DBINFO","DBPARTITIONNAME","DBPARTITIONNUM","DEALLOCATE","DEC","DECIMAL","DECLARE","DEFAULT","DEFAULTS","DEFINITION","DELETE","DENSERANK","DENSE_RANK","DEREF","DESCRIBE","DESCRIPTOR","DETERMINISTIC","DIAGNOSTICS","DISABLE","DISALLOW","DISCONNECT","DISTINCT","DO","DOCUMENT","DOUBLE","DROP","DSSIZE","DYNAMIC","EACH","EDITPROC","ELEMENT","ELSE","ELSEIF","ENABLE","ENCODING","ENCRYPTION","END","END-EXEC","ENDING","ERASE","ESCAPE","EVERY","EXCEPTION","EXCLUDING","EXCLUSIVE","EXEC","EXECUTE","EXISTS","EXIT","EXP","EXPLAIN","EXTENDED","EXTERNAL","EXTRACT","FALSE","FENCED","FETCH","FIELDPROC","FILE","FILTER","FINAL","FIRST","FLOAT","FLOOR","FOR","FOREIGN","FREE","FULL","FUNCTION","FUSION","GENERAL","GENERATED","GET","GLOBAL","GOTO","GRANT","GRAPHIC","GROUP","GROUPING","HANDLER","HASH","HASHED_VALUE","HINT","HOLD","HOUR","HOURS","IDENTITY","IF","IMMEDIATE","IN","INCLUDING","INCLUSIVE","INCREMENT","INDEX","INDICATOR","INDICATORS","INF","INFINITY","INHERIT","INNER","INOUT","INSENSITIVE","INSERT","INT","INTEGER","INTEGRITY","INTERSECTION","INTERVAL","INTO","IS","ISOBID","ISOLATION","ITERATE","JAR","JAVA","KEEP","KEY","LABEL","LANGUAGE","LARGE","LATERAL","LC_CTYPE","LEADING","LEAVE","LEFT","LIKE","LINKTYPE","LN","LOCAL","LOCALDATE","LOCALE","LOCALTIME","LOCALTIMESTAMP","LOCATOR","LOCATORS","LOCK","LOCKMAX","LOCKSIZE","LONG","LOOP","LOWER","MAINTAINED","MATCH","MATERIALIZED","MAX","MAXVALUE","MEMBER","MERGE","METHOD","MICROSECOND","MICROSECONDS","MIN","MINUTE","MINUTES","MINVALUE","MOD","MODE","MODIFIES","MODULE","MONTH","MONTHS","MULTISET","NAN","NATIONAL","NATURAL","NCHAR","NCLOB","NEW","NEW_TABLE","NEXTVAL","NO","NOCACHE","NOCYCLE","NODENAME","NODENUMBER","NOMAXVALUE","NOMINVALUE","NONE","NOORDER","NORMALIZE","NORMALIZED","NOT","NULL","NULLIF","NULLS","NUMERIC","NUMPARTS","OBID","OCTET_LENGTH","OF","OFFSET","OLD","OLD_TABLE","ON","ONLY","OPEN","OPTIMIZATION","OPTIMIZE","OPTION","ORDER","OUT","OUTER","OVER","OVERLAPS","OVERLAY","OVERRIDING","PACKAGE","PADDED","PAGESIZE","PARAMETER","PART","PARTITION","PARTITIONED","PARTITIONING","PARTITIONS","PASSWORD","PATH","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","PIECESIZE","PLAN","POSITION","POWER","PRECISION","PREPARE","PREVVAL","PRIMARY","PRIQTY","PRIVILEGES","PROCEDURE","PROGRAM","PSID","PUBLIC","QUERY","QUERYNO","RANGE","RANK","READ","READS","REAL","RECOVERY","RECURSIVE","REF","REFERENCES","REFERENCING","REFRESH","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","RELEASE","RENAME","REPEAT","RESET","RESIGNAL","RESTART","RESTRICT","RESULT","RESULT_SET_LOCATOR","RETURN","RETURNS","REVOKE","RIGHT","ROLE","ROLLBACK","ROLLUP","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_HALF_UP","ROUND_UP","ROUTINE","ROW","ROWNUMBER","ROWS","ROWSET","ROW_NUMBER","RRN","RUN","SAVEPOINT","SCHEMA","SCOPE","SCRATCHPAD","SCROLL","SEARCH","SECOND","SECONDS","SECQTY","SECURITY","SENSITIVE","SEQUENCE","SESSION","SESSION_USER","SIGNAL","SIMILAR","SIMPLE","SMALLINT","SNAN","SOME","SOURCE","SPECIFIC","SPECIFICTYPE","SQL","SQLEXCEPTION","SQLID","SQLSTATE","SQLWARNING","SQRT","STACKED","STANDARD","START","STARTING","STATEMENT","STATIC","STATMENT","STAY","STDDEV_POP","STDDEV_SAMP","STOGROUP","STORES","STYLE","SUBMULTISET","SUBSTRING","SUM","SUMMARY","SYMMETRIC","SYNONYM","SYSFUN","SYSIBM","SYSPROC","SYSTEM","SYSTEM_USER","TABLE","TABLESAMPLE","TABLESPACE","THEN","TIME","TIMESTAMP","TIMEZONE_HOUR","TIMEZONE_MINUTE","TO","TRAILING","TRANSACTION","TRANSLATE","TRANSLATION","TREAT","TRIGGER","TRIM","TRUE","TRUNCATE","TYPE","UESCAPE","UNDO","UNIQUE","UNKNOWN","UNNEST","UNTIL","UPPER","USAGE","USER","USING","VALIDPROC","VALUE","VARCHAR","VARIABLE","VARIANT","VARYING","VAR_POP","VAR_SAMP","VCAT","VERSION","VIEW","VOLATILE","VOLUMES","WHEN","WHENEVER","WHILE","WIDTH_BUCKET","WINDOW","WITH","WITHIN","WITHOUT","WLM","WRITE","XMLELEMENT","XMLEXISTS","XMLNAMESPACES","YEAR","YEARS"],U=["ADD","AFTER","ALTER COLUMN","ALTER TABLE","DELETE FROM","EXCEPT","FETCH FIRST","FROM","GROUP BY","GO","HAVING","INSERT INTO","INTERSECT","LIMIT","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UPDATE","VALUES","WHERE"],M=["AND","CROSS JOIN","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN"];let h;class d{constructor(e){this.cfg=e}format(e){return h||(h=new D({reservedWords:f,reservedToplevelWords:U,reservedNewlineWords:M,stringTypes:['""',"''","``","[]"],openParens:["("],closeParens:[")"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:[":"],lineCommentTypes:["--"],specialWordChars:["#","@"]})),new a(this.cfg,h).format(e)}}const _=["ALL","ALTER","ANALYZE","AND","ANY","ARRAY","AS","ASC","BEGIN","BETWEEN","BINARY","BOOLEAN","BREAK","BUCKET","BUILD","BY","CALL","CASE","CAST","CLUSTER","COLLATE","COLLECTION","COMMIT","CONNECT","CONTINUE","CORRELATE","COVER","CREATE","DATABASE","DATASET","DATASTORE","DECLARE","DECREMENT","DELETE","DERIVED","DESC","DESCRIBE","DISTINCT","DO","DROP","EACH","ELEMENT","ELSE","END","EVERY","EXCEPT","EXCLUDE","EXECUTE","EXISTS","EXPLAIN","FALSE","FETCH","FIRST","FLATTEN","FOR","FORCE","FROM","FUNCTION","GRANT","GROUP","GSI","HAVING","IF","IGNORE","ILIKE","IN","INCLUDE","INCREMENT","INDEX","INFER","INLINE","INNER","INSERT","INTERSECT","INTO","IS","JOIN","KEY","KEYS","KEYSPACE","KNOWN","LAST","LEFT","LET","LETTING","LIKE","LIMIT","LSM","MAP","MAPPING","MATCHED","MATERIALIZED","MERGE","MINUS","MISSING","NAMESPACE","NEST","NOT","NULL","NUMBER","OBJECT","OFFSET","ON","OPTION","OR","ORDER","OUTER","OVER","PARSE","PARTITION","PASSWORD","PATH","POOL","PREPARE","PRIMARY","PRIVATE","PRIVILEGE","PROCEDURE","PUBLIC","RAW","REALM","REDUCE","RENAME","RETURN","RETURNING","REVOKE","RIGHT","ROLE","ROLLBACK","SATISFIES","SCHEMA","SELECT","SELF","SEMI","SET","SHOW","SOME","START","STATISTICS","STRING","SYSTEM","THEN","TO","TRANSACTION","TRIGGER","TRUE","TRUNCATE","UNDER","UNION","UNIQUE","UNKNOWN","UNNEST","UNSET","UPDATE","UPSERT","USE","USER","USING","VALIDATE","VALUE","VALUED","VALUES","VIA","VIEW","WHEN","WHERE","WHILE","WITH","WITHIN","WORK","XOR"],v=["DELETE FROM","EXCEPT ALL","EXCEPT","EXPLAIN DELETE FROM","EXPLAIN UPDATE","EXPLAIN UPSERT","FROM","GROUP BY","HAVING","INFER","INSERT INTO","INTERSECT ALL","INTERSECT","LET","LIMIT","MERGE","NEST","ORDER BY","PREPARE","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UNION","UNNEST","UPDATE","UPSERT","USE KEYS","VALUES","WHERE"],G=["AND","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","XOR"];let g;class F{constructor(e){this.cfg=e}format(e){return g||(g=new D({reservedWords:_,reservedToplevelWords:v,reservedNewlineWords:G,stringTypes:['""',"''","``"],openParens:["(","[","{"],closeParens:[")","]","}"],namedPlaceholderTypes:["$"],lineCommentTypes:["#","--"]})),new a(this.cfg,g).format(e)}}const B=["A","ACCESSIBLE","AGENT","AGGREGATE","ALL","ALTER","ANY","ARRAY","AS","ASC","AT","ATTRIBUTE","AUTHID","AVG","BETWEEN","BFILE_BASE","BINARY_INTEGER","BINARY","BLOB_BASE","BLOCK","BODY","BOOLEAN","BOTH","BOUND","BULK","BY","BYTE","C","CALL","CALLING","CASCADE","CASE","CHAR_BASE","CHAR","CHARACTER","CHARSET","CHARSETFORM","CHARSETID","CHECK","CLOB_BASE","CLONE","CLOSE","CLUSTER","CLUSTERS","COALESCE","COLAUTH","COLLECT","COLUMNS","COMMENT","COMMIT","COMMITTED","COMPILED","COMPRESS","CONNECT","CONSTANT","CONSTRUCTOR","CONTEXT","CONTINUE","CONVERT","COUNT","CRASH","CREATE","CREDENTIAL","CURRENT","CURRVAL","CURSOR","CUSTOMDATUM","DANGLING","DATA","DATE_BASE","DATE","DAY","DECIMAL","DEFAULT","DEFINE","DELETE","DESC","DETERMINISTIC","DIRECTORY","DISTINCT","DO","DOUBLE","DROP","DURATION","ELEMENT","ELSIF","EMPTY","ESCAPE","EXCEPTIONS","EXCLUSIVE","EXECUTE","EXISTS","EXIT","EXTENDS","EXTERNAL","EXTRACT","FALSE","FETCH","FINAL","FIRST","FIXED","FLOAT","FOR","FORALL","FORCE","FROM","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HASH","HEAP","HIDDEN","HOUR","IDENTIFIED","IF","IMMEDIATE","IN","INCLUDING","INDEX","INDEXES","INDICATOR","INDICES","INFINITE","INSTANTIABLE","INT","INTEGER","INTERFACE","INTERVAL","INTO","INVALIDATE","IS","ISOLATION","JAVA","LANGUAGE","LARGE","LEADING","LENGTH","LEVEL","LIBRARY","LIKE","LIKE2","LIKE4","LIKEC","LIMITED","LOCAL","LOCK","LONG","MAP","MAX","MAXLEN","MEMBER","MERGE","MIN","MINUS","MINUTE","MLSLABEL","MOD","MODE","MONTH","MULTISET","NAME","NAN","NATIONAL","NATIVE","NATURAL","NATURALN","NCHAR","NEW","NEXTVAL","NOCOMPRESS","NOCOPY","NOT","NOWAIT","NULL","NULLIF","NUMBER_BASE","NUMBER","OBJECT","OCICOLL","OCIDATE","OCIDATETIME","OCIDURATION","OCIINTERVAL","OCILOBLOCATOR","OCINUMBER","OCIRAW","OCIREF","OCIREFCURSOR","OCIROWID","OCISTRING","OCITYPE","OF","OLD","ON","ONLY","OPAQUE","OPEN","OPERATOR","OPTION","ORACLE","ORADATA","ORDER","ORGANIZATION","ORLANY","ORLVARY","OTHERS","OUT","OVERLAPS","OVERRIDING","PACKAGE","PARALLEL_ENABLE","PARAMETER","PARAMETERS","PARENT","PARTITION","PASCAL","PCTFREE","PIPE","PIPELINED","PLS_INTEGER","PLUGGABLE","POSITIVE","POSITIVEN","PRAGMA","PRECISION","PRIOR","PRIVATE","PROCEDURE","PUBLIC","RAISE","RANGE","RAW","READ","REAL","RECORD","REF","REFERENCE","RELEASE","RELIES_ON","REM","REMAINDER","RENAME","RESOURCE","RESULT_CACHE","RESULT","RETURN","RETURNING","REVERSE","REVOKE","ROLLBACK","ROW","ROWID","ROWNUM","ROWTYPE","SAMPLE","SAVE","SAVEPOINT","SB1","SB2","SB4","SECOND","SEGMENT","SELF","SEPARATE","SEQUENCE","SERIALIZABLE","SHARE","SHORT","SIZE_T","SIZE","SMALLINT","SOME","SPACE","SPARSE","SQL","SQLCODE","SQLDATA","SQLERRM","SQLNAME","SQLSTATE","STANDARD","START","STATIC","STDDEV","STORED","STRING","STRUCT","STYLE","SUBMULTISET","SUBPARTITION","SUBSTITUTABLE","SUBTYPE","SUCCESSFUL","SUM","SYNONYM","SYSDATE","TABAUTH","TABLE","TDO","THE","THEN","TIME","TIMESTAMP","TIMEZONE_ABBR","TIMEZONE_HOUR","TIMEZONE_MINUTE","TIMEZONE_REGION","TO","TRAILING","TRANSACTION","TRANSACTIONAL","TRIGGER","TRUE","TRUSTED","TYPE","UB1","UB2","UB4","UID","UNDER","UNIQUE","UNPLUG","UNSIGNED","UNTRUSTED","USE","USER","USING","VALIDATE","VALIST","VALUE","VARCHAR","VARCHAR2","VARIABLE","VARIANCE","VARRAY","VARYING","VIEW","VIEWS","VOID","WHENEVER","WHILE","WITH","WORK","WRAPPED","WRITE","YEAR","ZONE"],H=["ADD","ALTER COLUMN","ALTER TABLE","BEGIN","CONNECT BY","DECLARE","DELETE FROM","DELETE","END","EXCEPT","EXCEPTION","FETCH FIRST","FROM","GROUP BY","HAVING","INSERT INTO","INSERT","INTERSECT","LIMIT","LOOP","MODIFY","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","START WITH","UNION ALL","UNION","UPDATE","VALUES","WHERE"],W=["AND","CROSS APPLY","CROSS JOIN","ELSE","END","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER APPLY","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","WHEN","XOR"];let y;class m{constructor(e){this.cfg=e}format(e){return y||(y=new D({reservedWords:B,reservedToplevelWords:H,reservedNewlineWords:W,stringTypes:['""',"N''","''","``"],openParens:["(","CASE"],closeParens:[")","END"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:[":"],lineCommentTypes:["--"],specialWordChars:["_","$","#",".","@"]})),new a(this.cfg,y).format(e)}}const V=["ACCESSIBLE","ACTION","AGAINST","AGGREGATE","ALGORITHM","ALL","ALTER","ANALYSE","ANALYZE","AS","ASC","AUTOCOMMIT","AUTO_INCREMENT","BACKUP","BEGIN","BETWEEN","BINLOG","BOTH","CASCADE","CASE","CHANGE","CHANGED","CHARACTER SET","CHARSET","CHECK","CHECKSUM","COLLATE","COLLATION","COLUMN","COLUMNS","COMMENT","COMMIT","COMMITTED","COMPRESSED","CONCURRENT","CONSTRAINT","CONTAINS","CONVERT","CREATE","CROSS","CURRENT_TIMESTAMP","DATABASE","DATABASES","DAY","DAY_HOUR","DAY_MINUTE","DAY_SECOND","DEFAULT","DEFINER","DELAYED","DELETE","DESC","DESCRIBE","DETERMINISTIC","DISTINCT","DISTINCTROW","DIV","DO","DROP","DUMPFILE","DUPLICATE","DYNAMIC","ELSE","ENCLOSED","END","ENGINE","ENGINES","ENGINE_TYPE","ESCAPE","ESCAPED","EVENTS","EXEC","EXECUTE","EXISTS","EXPLAIN","EXTENDED","FAST","FETCH","FIELDS","FILE","FIRST","FIXED","FLUSH","FOR","FORCE","FOREIGN","FULL","FULLTEXT","FUNCTION","GLOBAL","GRANT","GRANTS","GROUP_CONCAT","HEAP","HIGH_PRIORITY","HOSTS","HOUR","HOUR_MINUTE","HOUR_SECOND","IDENTIFIED","IF","IFNULL","IGNORE","IN","INDEX","INDEXES","INFILE","INSERT","INSERT_ID","INSERT_METHOD","INTERVAL","INTO","INVOKER","IS","ISOLATION","KEY","KEYS","KILL","LAST_INSERT_ID","LEADING","LEVEL","LIKE","LINEAR","LINES","LOAD","LOCAL","LOCK","LOCKS","LOGS","LOW_PRIORITY","MARIA","MASTER","MASTER_CONNECT_RETRY","MASTER_HOST","MASTER_LOG_FILE","MATCH","MAX_CONNECTIONS_PER_HOUR","MAX_QUERIES_PER_HOUR","MAX_ROWS","MAX_UPDATES_PER_HOUR","MAX_USER_CONNECTIONS","MEDIUM","MERGE","MINUTE","MINUTE_SECOND","MIN_ROWS","MODE","MODIFY","MONTH","MRG_MYISAM","MYISAM","NAMES","NATURAL","NOT","NOW()","NULL","OFFSET","ON DELETE","ON UPDATE","ON","ONLY","OPEN","OPTIMIZE","OPTION","OPTIONALLY","OUTFILE","PACK_KEYS","PAGE","PARTIAL","PARTITION","PARTITIONS","PASSWORD","PRIMARY","PRIVILEGES","PROCEDURE","PROCESS","PROCESSLIST","PURGE","QUICK","RAID0","RAID_CHUNKS","RAID_CHUNKSIZE","RAID_TYPE","RANGE","READ","READ_ONLY","READ_WRITE","REFERENCES","REGEXP","RELOAD","RENAME","REPAIR","REPEATABLE","REPLACE","REPLICATION","RESET","RESTORE","RESTRICT","RETURN","RETURNS","REVOKE","RLIKE","ROLLBACK","ROW","ROWS","ROW_FORMAT","SECOND","SECURITY","SEPARATOR","SERIALIZABLE","SESSION","SHARE","SHOW","SHUTDOWN","SLAVE","SONAME","SOUNDS","SQL","SQL_AUTO_IS_NULL","SQL_BIG_RESULT","SQL_BIG_SELECTS","SQL_BIG_TABLES","SQL_BUFFER_RESULT","SQL_CACHE","SQL_CALC_FOUND_ROWS","SQL_LOG_BIN","SQL_LOG_OFF","SQL_LOG_UPDATE","SQL_LOW_PRIORITY_UPDATES","SQL_MAX_JOIN_SIZE","SQL_NO_CACHE","SQL_QUOTE_SHOW_CREATE","SQL_SAFE_UPDATES","SQL_SELECT_LIMIT","SQL_SLAVE_SKIP_COUNTER","SQL_SMALL_RESULT","SQL_WARNINGS","START","STARTING","STATUS","STOP","STORAGE","STRAIGHT_JOIN","STRING","STRIPED","SUPER","TABLE","TABLES","TEMPORARY","TERMINATED","THEN","TO","TRAILING","TRANSACTIONAL","TRUE","TRUNCATE","TYPE","TYPES","UNCOMMITTED","UNIQUE","UNLOCK","UNSIGNED","USAGE","USE","USING","VARIABLES","VIEW","WHEN","WITH","WORK","WRITE","YEAR_MONTH"],x=["ADD","AFTER","ALTER COLUMN","ALTER TABLE","DELETE FROM","EXCEPT","FETCH FIRST","FROM","GROUP BY","GO","HAVING","INSERT INTO","INSERT","INTERSECT","LIMIT","MODIFY","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UNION","UPDATE","VALUES","WHERE"],Y=["AND","CROSS APPLY","CROSS JOIN","ELSE","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER APPLY","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","WHEN","XOR"];let b;class X{constructor(e){this.cfg=e}format(e){return b||(b=new D({reservedWords:V,reservedToplevelWords:x,reservedNewlineWords:Y,stringTypes:['""',"N''","''","``","[]"],openParens:["(","CASE"],closeParens:[")","END"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:["@",":"],lineCommentTypes:["#","--"]})),new a(this.cfg,b).format(e)}}t.d(E,"format",(function(){return k}));const k=(e,E={})=>{switch(E.language){case"db2":return new d(E).format(e);case"n1ql":return new F(E).format(e);case"pl/sql":return new m(E).format(e);case"sql":case void 0:return new X(E).format(e);default:throw Error(`Unsupported SQL dialect: ${E.language}`)}};E.default={format:k}}]);
!function(e){var E={};function t(r){if(E[r])return E[r].exports;var n=E[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=E,t.d=function(e,E,r){t.o(e,E)||Object.defineProperty(e,E,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,E){if(1&E&&(e=t(e)),8&E)return e;if(4&E&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&E&&"string"!=typeof e)for(var n in e)t.d(r,n,function(E){return e[E]}.bind(null,n));return r},t.n=function(e){var E=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(E,"a",E),E},t.o=function(e,E){return Object.prototype.hasOwnProperty.call(e,E)},t.p="",t(t.s=64)}([function(e,E,t){var r=t(10),n="object"==typeof self&&self&&self.Object===Object&&self,T=r||n||Function("return this")();e.exports=T},function(e,E,t){var r=t(8),n=t(33),T=t(34),R="[object Null]",N="[object Undefined]",A=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?N:R:A&&A in Object(e)?n(e):T(e)}},function(e,E){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,E,t){var r=t(56),n=t(59);e.exports=function(e,E){var t=n(e,E);return r(t)?t:void 0}},function(e,E,t){var r=t(22),n=/[\\^$.*+?()[\]{}|]/g,T=RegExp(n.source);e.exports=function(e){return(e=r(e))&&T.test(e)?e.replace(n,"\\$&"):e}},function(e,E,t){var r=t(9),n=t(11);e.exports=function(e){return null!=e&&n(e.length)&&!r(e)}},function(e,E){e.exports=function(e){var E=typeof e;return null!=e&&("object"==E||"function"==E)}},function(e,E){var t=Array.isArray;e.exports=t},function(e,E,t){var r=t(0).Symbol;e.exports=r},function(e,E,t){var r=t(1),n=t(6),T="[object AsyncFunction]",R="[object Function]",N="[object GeneratorFunction]",A="[object Proxy]";e.exports=function(e){if(!n(e))return!1;var E=r(e);return E==R||E==N||E==T||E==A}},function(e,E,t){(function(E){var t="object"==typeof E&&E&&E.Object===Object&&E;e.exports=t}).call(this,t(32))},function(e,E){var t=9007199254740991;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=t}},function(e,E,t){var r=t(36);e.exports=function(e){var E=r(e),t=E%1;return E==E?t?E-t:E:0}},function(e,E,t){var r=t(1),n=t(2),T="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||n(e)&&r(e)==T}},function(e,E){e.exports=function(e,E){for(var t=-1,r=null==e?0:e.length,n=Array(r);++t<r;)n[t]=E(e[t],t,e);return n}},function(e,E,t){var r=t(43),n=t(2),T=Object.prototype,R=T.hasOwnProperty,N=T.propertyIsEnumerable,A=r(function(){return arguments}())?r:function(e){return n(e)&&R.call(e,"callee")&&!N.call(e,"callee")};e.exports=A},function(e,E,t){(function(e){var r=t(0),n=t(44),T=E&&!E.nodeType&&E,R=T&&"object"==typeof e&&e&&!e.nodeType&&e,N=R&&R.exports===T?r.Buffer:void 0,A=(N?N.isBuffer:void 0)||n;e.exports=A}).call(this,t(17)(e))},function(e,E){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,E){var t=9007199254740991,r=/^(?:0|[1-9]\d*)$/;e.exports=function(e,E){var n=typeof e;return!!(E=null==E?t:E)&&("number"==n||"symbol"!=n&&r.test(e))&&e>-1&&e%1==0&&e<E}},function(e,E,t){var r=t(45),n=t(46),T=t(47),R=T&&T.isTypedArray,N=R?n(R):r;e.exports=N},function(e,E,t){var r=t(21),n=t(48),T=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return n(e);var E=[];for(var t in Object(e))T.call(e,t)&&"constructor"!=t&&E.push(t);return E}},function(e,E){var t=Object.prototype;e.exports=function(e){var E=e&&e.constructor;return e===("function"==typeof E&&E.prototype||t)}},function(e,E,t){var r=t(53);e.exports=function(e){return null==e?"":r(e)}},function(e,E){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,E,t){var r=t(28),n=t(5),T=t(35),R=t(12),N=t(38),A=Math.max;e.exports=function(e,E,t,o){e=n(e)?e:N(e),t=t&&!o?R(t):0;var I=e.length;return t<0&&(t=A(I+t,0)),T(e)?t<=I&&e.indexOf(E,t)>-1:!!I&&r(e,E,t)>-1}},function(e,E,t){var r=t(50),n=t(51),T=t(12),R=t(22);e.exports=function(e,E,t){return E=(t?n(e,E,t):void 0===E)?1:T(E),r(R(e),E)}},function(e,E){e.exports=function(e){var E=null==e?0:e.length;return E?e[E-1]:void 0}},function(e,E,t){var r=t(20),n=t(54),T=t(15),R=t(7),N=t(5),A=t(16),o=t(21),I=t(19),O="[object Map]",S="[object Set]",i=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(N(e)&&(R(e)||"string"==typeof e||"function"==typeof e.splice||A(e)||I(e)||T(e)))return!e.length;var E=n(e);if(E==O||E==S)return!e.size;if(o(e))return!r(e).length;for(var t in e)if(i.call(e,t))return!1;return!0}},function(e,E,t){var r=t(29),n=t(30),T=t(31);e.exports=function(e,E,t){return E==E?T(e,E,t):r(e,n,t)}},function(e,E){e.exports=function(e,E,t,r){for(var n=e.length,T=t+(r?1:-1);r?T--:++T<n;)if(E(e[T],T,e))return T;return-1}},function(e,E){e.exports=function(e){return e!=e}},function(e,E){e.exports=function(e,E,t){for(var r=t-1,n=e.length;++r<n;)if(e[r]===E)return r;return-1}},function(e,E){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,E,t){var r=t(8),n=Object.prototype,T=n.hasOwnProperty,R=n.toString,N=r?r.toStringTag:void 0;e.exports=function(e){var E=T.call(e,N),t=e[N];try{e[N]=void 0;var r=!0}catch(e){}var n=R.call(e);return r&&(E?e[N]=t:delete e[N]),n}},function(e,E){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},function(e,E,t){var r=t(1),n=t(7),T=t(2),R="[object String]";e.exports=function(e){return"string"==typeof e||!n(e)&&T(e)&&r(e)==R}},function(e,E,t){var r=t(37),n=1/0,T=17976931348623157e292;e.exports=function(e){return e?(e=r(e))===n||e===-n?(e<0?-1:1)*T:e==e?e:0:0===e?e:0}},function(e,E,t){var r=t(6),n=t(13),T=NaN,R=/^\s+|\s+$/g,N=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,o=/^0o[0-7]+$/i,I=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(n(e))return T;if(r(e)){var E="function"==typeof e.valueOf?e.valueOf():e;e=r(E)?E+"":E}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(R,"");var t=A.test(e);return t||o.test(e)?I(e.slice(2),t?2:8):N.test(e)?T:+e}},function(e,E,t){var r=t(39),n=t(40);e.exports=function(e){return null==e?[]:r(e,n(e))}},function(e,E,t){var r=t(14);e.exports=function(e,E){return r(E,(function(E){return e[E]}))}},function(e,E,t){var r=t(41),n=t(20),T=t(5);e.exports=function(e){return T(e)?r(e):n(e)}},function(e,E,t){var r=t(42),n=t(15),T=t(7),R=t(16),N=t(18),A=t(19),o=Object.prototype.hasOwnProperty;e.exports=function(e,E){var t=T(e),I=!t&&n(e),O=!t&&!I&&R(e),S=!t&&!I&&!O&&A(e),i=t||I||O||S,L=i?r(e.length,String):[],s=L.length;for(var C in e)!E&&!o.call(e,C)||i&&("length"==C||O&&("offset"==C||"parent"==C)||S&&("buffer"==C||"byteLength"==C||"byteOffset"==C)||N(C,s))||L.push(C);return L}},function(e,E){e.exports=function(e,E){for(var t=-1,r=Array(e);++t<e;)r[t]=E(t);return r}},function(e,E,t){var r=t(1),n=t(2),T="[object Arguments]";e.exports=function(e){return n(e)&&r(e)==T}},function(e,E){e.exports=function(){return!1}},function(e,E,t){var r=t(1),n=t(11),T=t(2),R={};R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R["[object Arguments]"]=R["[object Array]"]=R["[object ArrayBuffer]"]=R["[object Boolean]"]=R["[object DataView]"]=R["[object Date]"]=R["[object Error]"]=R["[object Function]"]=R["[object Map]"]=R["[object Number]"]=R["[object Object]"]=R["[object RegExp]"]=R["[object Set]"]=R["[object String]"]=R["[object WeakMap]"]=!1,e.exports=function(e){return T(e)&&n(e.length)&&!!R[r(e)]}},function(e,E){e.exports=function(e){return function(E){return e(E)}}},function(e,E,t){(function(e){var r=t(10),n=E&&!E.nodeType&&E,T=n&&"object"==typeof e&&e&&!e.nodeType&&e,R=T&&T.exports===n&&r.process,N=function(){try{var e=T&&T.require&&T.require("util").types;return e||R&&R.binding&&R.binding("util")}catch(e){}}();e.exports=N}).call(this,t(17)(e))},function(e,E,t){var r=t(49)(Object.keys,Object);e.exports=r},function(e,E){e.exports=function(e,E){return function(t){return e(E(t))}}},function(e,E){var t=9007199254740991,r=Math.floor;e.exports=function(e,E){var n="";if(!e||E<1||E>t)return n;do{E%2&&(n+=e),(E=r(E/2))&&(e+=e)}while(E);return n}},function(e,E,t){var r=t(52),n=t(5),T=t(18),R=t(6);e.exports=function(e,E,t){if(!R(t))return!1;var N=typeof E;return!!("number"==N?n(t)&&T(E,t.length):"string"==N&&E in t)&&r(t[E],e)}},function(e,E){e.exports=function(e,E){return e===E||e!=e&&E!=E}},function(e,E,t){var r=t(8),n=t(14),T=t(7),R=t(13),N=1/0,A=r?r.prototype:void 0,o=A?A.toString:void 0;e.exports=function e(E){if("string"==typeof E)return E;if(T(E))return n(E,e)+"";if(R(E))return o?o.call(E):"";var t=E+"";return"0"==t&&1/E==-N?"-0":t}},function(e,E,t){var r=t(55),n=t(60),T=t(61),R=t(62),N=t(63),A=t(1),o=t(23),I=o(r),O=o(n),S=o(T),i=o(R),L=o(N),s=A;(r&&"[object DataView]"!=s(new r(new ArrayBuffer(1)))||n&&"[object Map]"!=s(new n)||T&&"[object Promise]"!=s(T.resolve())||R&&"[object Set]"!=s(new R)||N&&"[object WeakMap]"!=s(new N))&&(s=function(e){var E=A(e),t="[object Object]"==E?e.constructor:void 0,r=t?o(t):"";if(r)switch(r){case I:return"[object DataView]";case O:return"[object Map]";case S:return"[object Promise]";case i:return"[object Set]";case L:return"[object WeakMap]"}return E}),e.exports=s},function(e,E,t){var r=t(3)(t(0),"DataView");e.exports=r},function(e,E,t){var r=t(9),n=t(57),T=t(6),R=t(23),N=/^\[object .+?Constructor\]$/,A=Function.prototype,o=Object.prototype,I=A.toString,O=o.hasOwnProperty,S=RegExp("^"+I.call(O).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!T(e)||n(e))&&(r(e)?S:N).test(R(e))}},function(e,E,t){var r,n=t(58),T=(r=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!T&&T in e}},function(e,E,t){var r=t(0)["__core-js_shared__"];e.exports=r},function(e,E){e.exports=function(e,E){return null==e?void 0:e[E]}},function(e,E,t){var r=t(3)(t(0),"Map");e.exports=r},function(e,E,t){var r=t(3)(t(0),"Promise");e.exports=r},function(e,E,t){var r=t(3)(t(0),"Set");e.exports=r},function(e,E,t){var r=t(3)(t(0),"WeakMap");e.exports=r},function(e,E,t){"use strict";t.r(E);var r=t(24),n=t.n(r),T={WHITESPACE:"whitespace",WORD:"word",STRING:"string",RESERVED:"reserved",RESERVED_TOPLEVEL:"reserved-toplevel",RESERVED_NEWLINE:"reserved-newline",OPERATOR:"operator",OPEN_PAREN:"open-paren",CLOSE_PAREN:"close-paren",LINE_COMMENT:"line-comment",BLOCK_COMMENT:"block-comment",NUMBER:"number",PLACEHOLDER:"placeholder"},R=t(25),N=t.n(R),A=t(26),o=t.n(A);const I="top-level",O="block-level";class S{constructor(e){this.indent=e||" ",this.indentTypes=[]}getIndent(){return N()(this.indent,this.indentTypes.length)}increaseToplevel(){this.indentTypes.push(I)}increaseBlockLevel(){this.indentTypes.push(O)}decreaseTopLevel(){o()(this.indentTypes)===I&&this.indentTypes.pop()}decreaseBlockLevel(){for(;this.indentTypes.length>0;){if(this.indentTypes.pop()!==I)break}}}const i=50;class L{constructor(){this.level=0}beginIfPossible(e,E){0===this.level&&this.isInlineBlock(e,E)?this.level=1:this.level>0?this.level++:this.level=0}end(){this.level--}isActive(){return this.level>0}isInlineBlock(e,E){let t=0,r=0;for(let n=E;n<e.length;n++){const E=e[n];if((t+=E.value.length)>i)return!1;if(E.type===T.OPEN_PAREN)r++;else if(E.type===T.CLOSE_PAREN&&0===--r)return!0;if(this.isForbiddenToken(E))return!1}return!1}isForbiddenToken({type:e,value:E}){return e===T.RESERVED_TOPLEVEL||e===T.RESERVED_NEWLINE||e===T.COMMENT||e===T.BLOCK_COMMENT||";"===E}}class s{constructor(e){this.params=e,this.index=0}get({key:e,value:E}){return this.params?e?this.params[e]:this.params[this.index++]:E}}const C=e=>e.replace(/[ \t]+$/u,"");class a{constructor(e,E){this.cfg=e||{},this.indentation=new S(this.cfg.indent),this.inlineBlock=new L,this.params=new s(this.cfg.params),this.tokenizer=E,this.previousReservedWord={},this.tokens=[],this.index=0}format(e){return this.tokens=this.tokenizer.tokenize(e),this.getFormattedQueryFromTokens().trim()}getFormattedQueryFromTokens(){let e="";return this.tokens.forEach((E,t)=>{this.index=t,E.type===T.WHITESPACE||(E.type===T.LINE_COMMENT?e=this.formatLineComment(E,e):E.type===T.BLOCK_COMMENT?e=this.formatBlockComment(E,e):E.type===T.RESERVED_TOPLEVEL?(e=this.formatToplevelReservedWord(E,e),this.previousReservedWord=E):E.type===T.RESERVED_NEWLINE?(e=this.formatNewlineReservedWord(E,e),this.previousReservedWord=E):E.type===T.RESERVED?(e=this.formatWithSpaces(E,e),this.previousReservedWord=E):e=E.type===T.OPEN_PAREN?this.formatOpeningParentheses(E,e):E.type===T.CLOSE_PAREN?this.formatClosingParentheses(E,e):E.type===T.PLACEHOLDER?this.formatPlaceholder(E,e):","===E.value?this.formatComma(E,e):":"===E.value?this.formatWithSpaceAfter(E,e):"."===E.value?this.formatWithoutSpaces(E,e):";"===E.value?this.formatQuerySeparator(E,e):this.formatWithSpaces(E,e))}),e}formatLineComment(e,E){return this.addNewline(E+e.value)}formatBlockComment(e,E){return this.addNewline(this.addNewline(E)+this.indentComment(e.value))}indentComment(e){return e.replace(/\n/gu,"\n"+this.indentation.getIndent())}formatToplevelReservedWord(e,E){return this.indentation.decreaseTopLevel(),E=this.addNewline(E),this.indentation.increaseToplevel(),E+=this.equalizeWhitespace(this.formatReservedWord(e.value)),this.addNewline(E)}formatNewlineReservedWord(e,E){return this.addNewline(E)+this.equalizeWhitespace(this.formatReservedWord(e.value))+" "}equalizeWhitespace(e){return e.replace(/\s+/gu," ")}formatOpeningParentheses(e,E){const t=[T.WHITESPACE,T.OPEN_PAREN,T.LINE_COMMENT];return n()(t,this.previousToken().type)||(E=C(E)),E+=e.value,this.inlineBlock.beginIfPossible(this.tokens,this.index),this.inlineBlock.isActive()||(this.indentation.increaseBlockLevel(),E=this.addNewline(E)),E}formatClosingParentheses(e,E){return this.inlineBlock.isActive()?(this.inlineBlock.end(),this.formatWithSpaceAfter(e,E)):(this.indentation.decreaseBlockLevel(),this.formatWithSpaces(e,this.addNewline(E)))}formatPlaceholder(e,E){return E+this.params.get(e)+" "}formatComma(e,E){return E=C(E)+e.value+" ",this.inlineBlock.isActive()?E:/^LIMIT$/iu.test(this.previousReservedWord.value)?E:this.addNewline(E)}formatWithSpaceAfter(e,E){return C(E)+e.value+" "}formatWithoutSpaces(e,E){return C(E)+e.value}formatWithSpaces(e,E){return E+("reserved"===e.type?this.formatReservedWord(e.value):e.value)+" "}formatReservedWord(e){return this.cfg.uppercase?e.toUpperCase():e}formatQuerySeparator(e,E){return this.indentation.decreaseTopLevel(),C(E)+e.value+"\n".repeat(this.cfg.linesBetweenQueries||1)}addNewline(e){return(e=C(e)).endsWith("\n")||(e+="\n"),e+this.indentation.getIndent()}previousNonWhitespaceToken(){let e=1;for(;this.previousToken(e).type===T.WHITESPACE;)e++;return this.previousToken(e)}previousToken(e=1){return this.tokens[this.index-e]||{}}}var c=t(27),u=t.n(c),l=t(4),P=t.n(l);class D{constructor(e){this.WHITESPACE_REGEX=/^(\s+)/u,this.NUMBER_REGEX=/^((-\s*)?[0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)\b/u,this.OPERATOR_REGEX=/^(!=|<>|==|<=|>=|!<|!>|\|\||::|->>|->|~~\*|~~|!~~\*|!~~|~\*|!~\*|!~|.)/u,this.BLOCK_COMMENT_REGEX=/^(\/\*[^]*?(?:\*\/|$))/u,this.LINE_COMMENT_REGEX=this.createLineCommentRegex(e.lineCommentTypes),this.RESERVED_TOPLEVEL_REGEX=this.createReservedWordRegex(e.reservedToplevelWords),this.RESERVED_NEWLINE_REGEX=this.createReservedWordRegex(e.reservedNewlineWords),this.RESERVED_PLAIN_REGEX=this.createReservedWordRegex(e.reservedWords),this.WORD_REGEX=this.createWordRegex(e.specialWordChars),this.STRING_REGEX=this.createStringRegex(e.stringTypes),this.OPEN_PAREN_REGEX=this.createParenRegex(e.openParens),this.CLOSE_PAREN_REGEX=this.createParenRegex(e.closeParens),this.INDEXED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.indexedPlaceholderTypes,"[0-9]*"),this.IDENT_NAMED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.namedPlaceholderTypes,"[a-zA-Z0-9._$]+"),this.STRING_NAMED_PLACEHOLDER_REGEX=this.createPlaceholderRegex(e.namedPlaceholderTypes,this.createStringPattern(e.stringTypes))}createLineCommentRegex(e){return new RegExp(`^((?:${e.map(e=>P()(e)).join("|")}).*?(?:\r\n|\r|\n|$))`,"u")}createReservedWordRegex(e){const E=e.join("|").replace(/ /gu,"\\s+");return new RegExp(`^(${E})\\b`,"iu")}createWordRegex(e=[]){return new RegExp(`^([\\p{Alphabetic}\\p{Mark}\\p{Decimal_Number}\\p{Connector_Punctuation}\\p{Join_Control}${e.join("")}]+)`,"u")}createStringRegex(e){return new RegExp("^("+this.createStringPattern(e)+")","u")}createStringPattern(e){const E={"``":"((`[^`]*($|`))+)","[]":"((\\[[^\\]]*($|\\]))(\\][^\\]]*($|\\]))*)",'""':'(("[^"\\\\]*(?:\\\\.[^"\\\\]*)*("|$))+)',"''":"(('[^'\\\\]*(?:\\\\.[^'\\\\]*)*('|$))+)","N''":"((N'[^N'\\\\]*(?:\\\\.[^N'\\\\]*)*('|$))+)"};return e.map(e=>E[e]).join("|")}createParenRegex(e){return new RegExp("^("+e.map(e=>this.escapeParen(e)).join("|")+")","iu")}escapeParen(e){return 1===e.length?P()(e):"\\b"+e+"\\b"}createPlaceholderRegex(e,E){if(u()(e))return!1;const t=e.map(P.a).join("|");return new RegExp(`^((?:${t})(?:${E}))`,"u")}tokenize(e){if(!e)return[];const E=[];let t;for(;e.length;)t=this.getNextToken(e,t),e=e.substring(t.value.length),E.push(t);return E}getNextToken(e,E){return this.getWhitespaceToken(e)||this.getCommentToken(e)||this.getStringToken(e)||this.getOpenParenToken(e)||this.getCloseParenToken(e)||this.getPlaceholderToken(e)||this.getNumberToken(e)||this.getReservedWordToken(e,E)||this.getWordToken(e)||this.getOperatorToken(e)}getWhitespaceToken(e){return this.getTokenOnFirstMatch({input:e,type:T.WHITESPACE,regex:this.WHITESPACE_REGEX})}getCommentToken(e){return this.getLineCommentToken(e)||this.getBlockCommentToken(e)}getLineCommentToken(e){return this.getTokenOnFirstMatch({input:e,type:T.LINE_COMMENT,regex:this.LINE_COMMENT_REGEX})}getBlockCommentToken(e){return this.getTokenOnFirstMatch({input:e,type:T.BLOCK_COMMENT,regex:this.BLOCK_COMMENT_REGEX})}getStringToken(e){return this.getTokenOnFirstMatch({input:e,type:T.STRING,regex:this.STRING_REGEX})}getOpenParenToken(e){return this.getTokenOnFirstMatch({input:e,type:T.OPEN_PAREN,regex:this.OPEN_PAREN_REGEX})}getCloseParenToken(e){return this.getTokenOnFirstMatch({input:e,type:T.CLOSE_PAREN,regex:this.CLOSE_PAREN_REGEX})}getPlaceholderToken(e){return this.getIdentNamedPlaceholderToken(e)||this.getStringNamedPlaceholderToken(e)||this.getIndexedPlaceholderToken(e)}getIdentNamedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.IDENT_NAMED_PLACEHOLDER_REGEX,parseKey:e=>e.slice(1)})}getStringNamedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.STRING_NAMED_PLACEHOLDER_REGEX,parseKey:e=>this.getEscapedPlaceholderKey({key:e.slice(2,-1),quoteChar:e.slice(-1)})})}getIndexedPlaceholderToken(e){return this.getPlaceholderTokenWithKey({input:e,regex:this.INDEXED_PLACEHOLDER_REGEX,parseKey:e=>e.slice(1)})}getPlaceholderTokenWithKey({input:e,regex:E,parseKey:t}){const r=this.getTokenOnFirstMatch({input:e,regex:E,type:T.PLACEHOLDER});return r&&(r.key=t(r.value)),r}getEscapedPlaceholderKey({key:e,quoteChar:E}){return e.replace(new RegExp(P()("\\"+E),"gu"),E)}getNumberToken(e){return this.getTokenOnFirstMatch({input:e,type:T.NUMBER,regex:this.NUMBER_REGEX})}getOperatorToken(e){return this.getTokenOnFirstMatch({input:e,type:T.OPERATOR,regex:this.OPERATOR_REGEX})}getReservedWordToken(e,E){if(!E||!E.value||"."!==E.value)return this.getToplevelReservedToken(e)||this.getNewlineReservedToken(e)||this.getPlainReservedToken(e)}getToplevelReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:T.RESERVED_TOPLEVEL,regex:this.RESERVED_TOPLEVEL_REGEX})}getNewlineReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:T.RESERVED_NEWLINE,regex:this.RESERVED_NEWLINE_REGEX})}getPlainReservedToken(e){return this.getTokenOnFirstMatch({input:e,type:T.RESERVED,regex:this.RESERVED_PLAIN_REGEX})}getWordToken(e){return this.getTokenOnFirstMatch({input:e,type:T.WORD,regex:this.WORD_REGEX})}getTokenOnFirstMatch({input:e,type:E,regex:t}){const r=e.match(t);if(r)return{type:E,value:r[1]}}}const U=["ABS","ACTIVATE","ALIAS","ALL","ALLOCATE","ALLOW","ALTER","ANY","ARE","ARRAY","AS","ASC","ASENSITIVE","ASSOCIATE","ASUTIME","ASYMMETRIC","AT","ATOMIC","ATTRIBUTES","AUDIT","AUTHORIZATION","AUX","AUXILIARY","AVG","BEFORE","BEGIN","BETWEEN","BIGINT","BINARY","BLOB","BOOLEAN","BOTH","BUFFERPOOL","BY","CACHE","CALL","CALLED","CAPTURE","CARDINALITY","CASCADED","CASE","CAST","CCSID","CEIL","CEILING","CHAR","CHARACTER","CHARACTER_LENGTH","CHAR_LENGTH","CHECK","CLOB","CLONE","CLOSE","CLUSTER","COALESCE","COLLATE","COLLECT","COLLECTION","COLLID","COLUMN","COMMENT","COMMIT","CONCAT","CONDITION","CONNECT","CONNECTION","CONSTRAINT","CONTAINS","CONTINUE","CONVERT","CORR","CORRESPONDING","COUNT","COUNT_BIG","COVAR_POP","COVAR_SAMP","CREATE","CROSS","CUBE","CUME_DIST","CURRENT","CURRENT_DATE","CURRENT_DEFAULT_TRANSFORM_GROUP","CURRENT_LC_CTYPE","CURRENT_PATH","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_SERVER","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","CURRENT_TRANSFORM_GROUP_FOR_TYPE","CURRENT_USER","CURSOR","CYCLE","DATA","DATABASE","DATAPARTITIONNAME","DATAPARTITIONNUM","DATE","DAY","DAYS","DB2GENERAL","DB2GENRL","DB2SQL","DBINFO","DBPARTITIONNAME","DBPARTITIONNUM","DEALLOCATE","DEC","DECIMAL","DECLARE","DEFAULT","DEFAULTS","DEFINITION","DELETE","DENSERANK","DENSE_RANK","DEREF","DESCRIBE","DESCRIPTOR","DETERMINISTIC","DIAGNOSTICS","DISABLE","DISALLOW","DISCONNECT","DISTINCT","DO","DOCUMENT","DOUBLE","DROP","DSSIZE","DYNAMIC","EACH","EDITPROC","ELEMENT","ELSE","ELSEIF","ENABLE","ENCODING","ENCRYPTION","END","END-EXEC","ENDING","ERASE","ESCAPE","EVERY","EXCEPTION","EXCLUDING","EXCLUSIVE","EXEC","EXECUTE","EXISTS","EXIT","EXP","EXPLAIN","EXTENDED","EXTERNAL","EXTRACT","FALSE","FENCED","FETCH","FIELDPROC","FILE","FILTER","FINAL","FIRST","FLOAT","FLOOR","FOR","FOREIGN","FREE","FULL","FUNCTION","FUSION","GENERAL","GENERATED","GET","GLOBAL","GOTO","GRANT","GRAPHIC","GROUP","GROUPING","HANDLER","HASH","HASHED_VALUE","HINT","HOLD","HOUR","HOURS","IDENTITY","IF","IMMEDIATE","IN","INCLUDING","INCLUSIVE","INCREMENT","INDEX","INDICATOR","INDICATORS","INF","INFINITY","INHERIT","INNER","INOUT","INSENSITIVE","INSERT","INT","INTEGER","INTEGRITY","INTERSECTION","INTERVAL","INTO","IS","ISOBID","ISOLATION","ITERATE","JAR","JAVA","KEEP","KEY","LABEL","LANGUAGE","LARGE","LATERAL","LC_CTYPE","LEADING","LEAVE","LEFT","LIKE","LINKTYPE","LN","LOCAL","LOCALDATE","LOCALE","LOCALTIME","LOCALTIMESTAMP","LOCATOR","LOCATORS","LOCK","LOCKMAX","LOCKSIZE","LONG","LOOP","LOWER","MAINTAINED","MATCH","MATERIALIZED","MAX","MAXVALUE","MEMBER","MERGE","METHOD","MICROSECOND","MICROSECONDS","MIN","MINUTE","MINUTES","MINVALUE","MOD","MODE","MODIFIES","MODULE","MONTH","MONTHS","MULTISET","NAN","NATIONAL","NATURAL","NCHAR","NCLOB","NEW","NEW_TABLE","NEXTVAL","NO","NOCACHE","NOCYCLE","NODENAME","NODENUMBER","NOMAXVALUE","NOMINVALUE","NONE","NOORDER","NORMALIZE","NORMALIZED","NOT","NULL","NULLIF","NULLS","NUMERIC","NUMPARTS","OBID","OCTET_LENGTH","OF","OFFSET","OLD","OLD_TABLE","ON","ONLY","OPEN","OPTIMIZATION","OPTIMIZE","OPTION","ORDER","OUT","OUTER","OVER","OVERLAPS","OVERLAY","OVERRIDING","PACKAGE","PADDED","PAGESIZE","PARAMETER","PART","PARTITION","PARTITIONED","PARTITIONING","PARTITIONS","PASSWORD","PATH","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","PIECESIZE","PLAN","POSITION","POWER","PRECISION","PREPARE","PREVVAL","PRIMARY","PRIQTY","PRIVILEGES","PROCEDURE","PROGRAM","PSID","PUBLIC","QUERY","QUERYNO","RANGE","RANK","READ","READS","REAL","RECOVERY","RECURSIVE","REF","REFERENCES","REFERENCING","REFRESH","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","RELEASE","RENAME","REPEAT","RESET","RESIGNAL","RESTART","RESTRICT","RESULT","RESULT_SET_LOCATOR","RETURN","RETURNS","REVOKE","RIGHT","ROLE","ROLLBACK","ROLLUP","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_HALF_UP","ROUND_UP","ROUTINE","ROW","ROWNUMBER","ROWS","ROWSET","ROW_NUMBER","RRN","RUN","SAVEPOINT","SCHEMA","SCOPE","SCRATCHPAD","SCROLL","SEARCH","SECOND","SECONDS","SECQTY","SECURITY","SENSITIVE","SEQUENCE","SESSION","SESSION_USER","SIGNAL","SIMILAR","SIMPLE","SMALLINT","SNAN","SOME","SOURCE","SPECIFIC","SPECIFICTYPE","SQL","SQLEXCEPTION","SQLID","SQLSTATE","SQLWARNING","SQRT","STACKED","STANDARD","START","STARTING","STATEMENT","STATIC","STATMENT","STAY","STDDEV_POP","STDDEV_SAMP","STOGROUP","STORES","STYLE","SUBMULTISET","SUBSTRING","SUM","SUMMARY","SYMMETRIC","SYNONYM","SYSFUN","SYSIBM","SYSPROC","SYSTEM","SYSTEM_USER","TABLE","TABLESAMPLE","TABLESPACE","THEN","TIME","TIMESTAMP","TIMEZONE_HOUR","TIMEZONE_MINUTE","TO","TRAILING","TRANSACTION","TRANSLATE","TRANSLATION","TREAT","TRIGGER","TRIM","TRUE","TRUNCATE","TYPE","UESCAPE","UNDO","UNIQUE","UNKNOWN","UNNEST","UNTIL","UPPER","USAGE","USER","USING","VALIDPROC","VALUE","VARCHAR","VARIABLE","VARIANT","VARYING","VAR_POP","VAR_SAMP","VCAT","VERSION","VIEW","VOLATILE","VOLUMES","WHEN","WHENEVER","WHILE","WIDTH_BUCKET","WINDOW","WITH","WITHIN","WITHOUT","WLM","WRITE","XMLELEMENT","XMLEXISTS","XMLNAMESPACES","YEAR","YEARS"],p=["ADD","AFTER","ALTER COLUMN","ALTER TABLE","DELETE FROM","EXCEPT","FETCH FIRST","FROM","GROUP BY","GO","HAVING","INSERT INTO","INTERSECT","LIMIT","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UPDATE","VALUES","WHERE"],M=["AND","CROSS JOIN","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN"];let h;class f{constructor(e){this.cfg=e}format(e){return h||(h=new D({reservedWords:U,reservedToplevelWords:p,reservedNewlineWords:M,stringTypes:['""',"''","``","[]"],openParens:["("],closeParens:[")"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:[":"],lineCommentTypes:["--"],specialWordChars:["#","@"]})),new a(this.cfg,h).format(e)}}const d=["ALL","ALTER","ANALYZE","AND","ANY","ARRAY","AS","ASC","BEGIN","BETWEEN","BINARY","BOOLEAN","BREAK","BUCKET","BUILD","BY","CALL","CASE","CAST","CLUSTER","COLLATE","COLLECTION","COMMIT","CONNECT","CONTINUE","CORRELATE","COVER","CREATE","DATABASE","DATASET","DATASTORE","DECLARE","DECREMENT","DELETE","DERIVED","DESC","DESCRIBE","DISTINCT","DO","DROP","EACH","ELEMENT","ELSE","END","EVERY","EXCEPT","EXCLUDE","EXECUTE","EXISTS","EXPLAIN","FALSE","FETCH","FIRST","FLATTEN","FOR","FORCE","FROM","FUNCTION","GRANT","GROUP","GSI","HAVING","IF","IGNORE","ILIKE","IN","INCLUDE","INCREMENT","INDEX","INFER","INLINE","INNER","INSERT","INTERSECT","INTO","IS","JOIN","KEY","KEYS","KEYSPACE","KNOWN","LAST","LEFT","LET","LETTING","LIKE","LIMIT","LSM","MAP","MAPPING","MATCHED","MATERIALIZED","MERGE","MINUS","MISSING","NAMESPACE","NEST","NOT","NULL","NUMBER","OBJECT","OFFSET","ON","OPTION","OR","ORDER","OUTER","OVER","PARSE","PARTITION","PASSWORD","PATH","POOL","PREPARE","PRIMARY","PRIVATE","PRIVILEGE","PROCEDURE","PUBLIC","RAW","REALM","REDUCE","RENAME","RETURN","RETURNING","REVOKE","RIGHT","ROLE","ROLLBACK","SATISFIES","SCHEMA","SELECT","SELF","SEMI","SET","SHOW","SOME","START","STATISTICS","STRING","SYSTEM","THEN","TO","TRANSACTION","TRIGGER","TRUE","TRUNCATE","UNDER","UNION","UNIQUE","UNKNOWN","UNNEST","UNSET","UPDATE","UPSERT","USE","USER","USING","VALIDATE","VALUE","VALUED","VALUES","VIA","VIEW","WHEN","WHERE","WHILE","WITH","WITHIN","WORK","XOR"],_=["DELETE FROM","EXCEPT ALL","EXCEPT","EXPLAIN DELETE FROM","EXPLAIN UPDATE","EXPLAIN UPSERT","FROM","GROUP BY","HAVING","INFER","INSERT INTO","INTERSECT ALL","INTERSECT","LET","LIMIT","MERGE","NEST","ORDER BY","PREPARE","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UNION","UNNEST","UPDATE","UPSERT","USE KEYS","VALUES","WHERE"],G=["AND","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","XOR"];let v;class g{constructor(e){this.cfg=e}format(e){return v||(v=new D({reservedWords:d,reservedToplevelWords:_,reservedNewlineWords:G,stringTypes:['""',"''","``"],openParens:["(","[","{"],closeParens:[")","]","}"],namedPlaceholderTypes:["$"],lineCommentTypes:["#","--"]})),new a(this.cfg,v).format(e)}}const F=["A","ACCESSIBLE","AGENT","AGGREGATE","ALL","ALTER","ANY","ARRAY","AS","ASC","AT","ATTRIBUTE","AUTHID","AVG","BETWEEN","BFILE_BASE","BINARY_INTEGER","BINARY","BLOB_BASE","BLOCK","BODY","BOOLEAN","BOTH","BOUND","BULK","BY","BYTE","C","CALL","CALLING","CASCADE","CASE","CHAR_BASE","CHAR","CHARACTER","CHARSET","CHARSETFORM","CHARSETID","CHECK","CLOB_BASE","CLONE","CLOSE","CLUSTER","CLUSTERS","COALESCE","COLAUTH","COLLECT","COLUMNS","COMMENT","COMMIT","COMMITTED","COMPILED","COMPRESS","CONNECT","CONSTANT","CONSTRUCTOR","CONTEXT","CONTINUE","CONVERT","COUNT","CRASH","CREATE","CREDENTIAL","CURRENT","CURRVAL","CURSOR","CUSTOMDATUM","DANGLING","DATA","DATE_BASE","DATE","DAY","DECIMAL","DEFAULT","DEFINE","DELETE","DESC","DETERMINISTIC","DIRECTORY","DISTINCT","DO","DOUBLE","DROP","DURATION","ELEMENT","ELSIF","EMPTY","ESCAPE","EXCEPTIONS","EXCLUSIVE","EXECUTE","EXISTS","EXIT","EXTENDS","EXTERNAL","EXTRACT","FALSE","FETCH","FINAL","FIRST","FIXED","FLOAT","FOR","FORALL","FORCE","FROM","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HASH","HEAP","HIDDEN","HOUR","IDENTIFIED","IF","IMMEDIATE","IN","INCLUDING","INDEX","INDEXES","INDICATOR","INDICES","INFINITE","INSTANTIABLE","INT","INTEGER","INTERFACE","INTERVAL","INTO","INVALIDATE","IS","ISOLATION","JAVA","LANGUAGE","LARGE","LEADING","LENGTH","LEVEL","LIBRARY","LIKE","LIKE2","LIKE4","LIKEC","LIMITED","LOCAL","LOCK","LONG","MAP","MAX","MAXLEN","MEMBER","MERGE","MIN","MINUS","MINUTE","MLSLABEL","MOD","MODE","MONTH","MULTISET","NAME","NAN","NATIONAL","NATIVE","NATURAL","NATURALN","NCHAR","NEW","NEXTVAL","NOCOMPRESS","NOCOPY","NOT","NOWAIT","NULL","NULLIF","NUMBER_BASE","NUMBER","OBJECT","OCICOLL","OCIDATE","OCIDATETIME","OCIDURATION","OCIINTERVAL","OCILOBLOCATOR","OCINUMBER","OCIRAW","OCIREF","OCIREFCURSOR","OCIROWID","OCISTRING","OCITYPE","OF","OLD","ON","ONLY","OPAQUE","OPEN","OPERATOR","OPTION","ORACLE","ORADATA","ORDER","ORGANIZATION","ORLANY","ORLVARY","OTHERS","OUT","OVERLAPS","OVERRIDING","PACKAGE","PARALLEL_ENABLE","PARAMETER","PARAMETERS","PARENT","PARTITION","PASCAL","PCTFREE","PIPE","PIPELINED","PLS_INTEGER","PLUGGABLE","POSITIVE","POSITIVEN","PRAGMA","PRECISION","PRIOR","PRIVATE","PROCEDURE","PUBLIC","RAISE","RANGE","RAW","READ","REAL","RECORD","REF","REFERENCE","RELEASE","RELIES_ON","REM","REMAINDER","RENAME","RESOURCE","RESULT_CACHE","RESULT","RETURN","RETURNING","REVERSE","REVOKE","ROLLBACK","ROW","ROWID","ROWNUM","ROWTYPE","SAMPLE","SAVE","SAVEPOINT","SB1","SB2","SB4","SECOND","SEGMENT","SELF","SEPARATE","SEQUENCE","SERIALIZABLE","SHARE","SHORT","SIZE_T","SIZE","SMALLINT","SOME","SPACE","SPARSE","SQL","SQLCODE","SQLDATA","SQLERRM","SQLNAME","SQLSTATE","STANDARD","START","STATIC","STDDEV","STORED","STRING","STRUCT","STYLE","SUBMULTISET","SUBPARTITION","SUBSTITUTABLE","SUBTYPE","SUCCESSFUL","SUM","SYNONYM","SYSDATE","TABAUTH","TABLE","TDO","THE","THEN","TIME","TIMESTAMP","TIMEZONE_ABBR","TIMEZONE_HOUR","TIMEZONE_MINUTE","TIMEZONE_REGION","TO","TRAILING","TRANSACTION","TRANSACTIONAL","TRIGGER","TRUE","TRUSTED","TYPE","UB1","UB2","UB4","UID","UNDER","UNIQUE","UNPLUG","UNSIGNED","UNTRUSTED","USE","USER","USING","VALIDATE","VALIST","VALUE","VARCHAR","VARCHAR2","VARIABLE","VARIANCE","VARRAY","VARYING","VIEW","VIEWS","VOID","WHENEVER","WHILE","WITH","WORK","WRAPPED","WRITE","YEAR","ZONE"],B=["ADD","ALTER COLUMN","ALTER TABLE","BEGIN","CONNECT BY","DECLARE","DELETE FROM","DELETE","END","EXCEPT","EXCEPTION","FETCH FIRST","FROM","GROUP BY","HAVING","INSERT INTO","INSERT","INTERSECT","LIMIT","LOOP","MODIFY","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","START WITH","UNION ALL","UNION","UPDATE","VALUES","WHERE"],H=["AND","CROSS APPLY","CROSS JOIN","ELSE","END","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER APPLY","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","WHEN","XOR"];let y;class W{constructor(e){this.cfg=e}format(e){return y||(y=new D({reservedWords:F,reservedToplevelWords:B,reservedNewlineWords:H,stringTypes:['""',"N''","''","``"],openParens:["(","CASE"],closeParens:[")","END"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:[":"],lineCommentTypes:["--"],specialWordChars:["_","$","#",".","@"]})),new a(this.cfg,y).format(e)}}const m=["ACCESSIBLE","ACTION","AGAINST","AGGREGATE","ALGORITHM","ALL","ALTER","ANALYSE","ANALYZE","AS","ASC","AUTOCOMMIT","AUTO_INCREMENT","BACKUP","BEGIN","BETWEEN","BINLOG","BOTH","CASCADE","CASE","CHANGE","CHANGED","CHARACTER SET","CHARSET","CHECK","CHECKSUM","COLLATE","COLLATION","COLUMN","COLUMNS","COMMENT","COMMIT","COMMITTED","COMPRESSED","CONCURRENT","CONSTRAINT","CONTAINS","CONVERT","CREATE","CROSS","CURRENT_TIMESTAMP","DATABASE","DATABASES","DAY","DAY_HOUR","DAY_MINUTE","DAY_SECOND","DEFAULT","DEFINER","DELAYED","DELETE","DESC","DESCRIBE","DETERMINISTIC","DISTINCT","DISTINCTROW","DIV","DO","DROP","DUMPFILE","DUPLICATE","DYNAMIC","ELSE","ENCLOSED","END","ENGINE","ENGINES","ENGINE_TYPE","ESCAPE","ESCAPED","EVENTS","EXEC","EXECUTE","EXISTS","EXPLAIN","EXTENDED","FAST","FETCH","FIELDS","FILE","FIRST","FIXED","FLUSH","FOR","FORCE","FOREIGN","FULL","FULLTEXT","FUNCTION","GLOBAL","GRANT","GRANTS","GROUP_CONCAT","HEAP","HIGH_PRIORITY","HOSTS","HOUR","HOUR_MINUTE","HOUR_SECOND","IDENTIFIED","IF","IFNULL","IGNORE","IN","INDEX","INDEXES","INFILE","INSERT","INSERT_ID","INSERT_METHOD","INTERVAL","INTO","INVOKER","IS","ISOLATION","KEY","KEYS","KILL","LAST_INSERT_ID","LEADING","LEVEL","LIKE","LINEAR","LINES","LOAD","LOCAL","LOCK","LOCKS","LOGS","LOW_PRIORITY","MARIA","MASTER","MASTER_CONNECT_RETRY","MASTER_HOST","MASTER_LOG_FILE","MATCH","MAX_CONNECTIONS_PER_HOUR","MAX_QUERIES_PER_HOUR","MAX_ROWS","MAX_UPDATES_PER_HOUR","MAX_USER_CONNECTIONS","MEDIUM","MERGE","MINUTE","MINUTE_SECOND","MIN_ROWS","MODE","MODIFY","MONTH","MRG_MYISAM","MYISAM","NAMES","NATURAL","NOT","NOW()","NULL","OFFSET","ON DELETE","ON UPDATE","ON","ONLY","OPEN","OPTIMIZE","OPTION","OPTIONALLY","OUTFILE","PACK_KEYS","PAGE","PARTIAL","PARTITION","PARTITIONS","PASSWORD","PRIMARY","PRIVILEGES","PROCEDURE","PROCESS","PROCESSLIST","PURGE","QUICK","RAID0","RAID_CHUNKS","RAID_CHUNKSIZE","RAID_TYPE","RANGE","READ","READ_ONLY","READ_WRITE","REFERENCES","REGEXP","RELOAD","RENAME","REPAIR","REPEATABLE","REPLACE","REPLICATION","RESET","RESTORE","RESTRICT","RETURN","RETURNS","REVOKE","RLIKE","ROLLBACK","ROW","ROWS","ROW_FORMAT","SECOND","SECURITY","SEPARATOR","SERIALIZABLE","SESSION","SHARE","SHOW","SHUTDOWN","SLAVE","SONAME","SOUNDS","SQL","SQL_AUTO_IS_NULL","SQL_BIG_RESULT","SQL_BIG_SELECTS","SQL_BIG_TABLES","SQL_BUFFER_RESULT","SQL_CACHE","SQL_CALC_FOUND_ROWS","SQL_LOG_BIN","SQL_LOG_OFF","SQL_LOG_UPDATE","SQL_LOW_PRIORITY_UPDATES","SQL_MAX_JOIN_SIZE","SQL_NO_CACHE","SQL_QUOTE_SHOW_CREATE","SQL_SAFE_UPDATES","SQL_SELECT_LIMIT","SQL_SLAVE_SKIP_COUNTER","SQL_SMALL_RESULT","SQL_WARNINGS","START","STARTING","STATUS","STOP","STORAGE","STRAIGHT_JOIN","STRING","STRIPED","SUPER","TABLE","TABLES","TEMPORARY","TERMINATED","THEN","TO","TRAILING","TRANSACTIONAL","TRUE","TRUNCATE","TYPE","TYPES","UNCOMMITTED","UNIQUE","UNLOCK","UNSIGNED","USAGE","USE","USING","VARIABLES","VIEW","WHEN","WITH","WORK","WRITE","YEAR_MONTH"],V=["ADD","AFTER","ALTER COLUMN","ALTER TABLE","DELETE FROM","EXCEPT","FETCH FIRST","FROM","GROUP BY","GO","HAVING","INSERT INTO","INSERT","INTERSECT","LIMIT","MODIFY","ORDER BY","SELECT","SET CURRENT SCHEMA","SET SCHEMA","SET","UNION ALL","UNION","UPDATE","VALUES","WHERE"],x=["AND","CROSS APPLY","CROSS JOIN","ELSE","INNER JOIN","JOIN","LEFT JOIN","LEFT OUTER JOIN","OR","OUTER APPLY","OUTER JOIN","RIGHT JOIN","RIGHT OUTER JOIN","WHEN","XOR"];let Y;class b{constructor(e){this.cfg=e}format(e){return Y||(Y=new D({reservedWords:m,reservedToplevelWords:V,reservedNewlineWords:x,stringTypes:['""',"N''","''","``","[]"],openParens:["(","CASE"],closeParens:[")","END"],indexedPlaceholderTypes:["?"],namedPlaceholderTypes:["@",":"],lineCommentTypes:["#","--"]})),new a(this.cfg,Y).format(e)}}t.d(E,"format",(function(){return X}));const X=(e,E={})=>{switch(E.language){case"db2":return new f(E).format(e);case"n1ql":return new g(E).format(e);case"pl/sql":return new W(E).format(e);case"sql":case void 0:return new b(E).format(e);default:throw Error(`Unsupported SQL dialect: ${E.language}`)}};E.default={format:X}}]);

@@ -10,4 +10,2 @@ "use strict";

var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
var _tokenTypes = _interopRequireDefault(require("./tokenTypes"));

@@ -29,2 +27,6 @@

var trimSpacesEnd = function trimSpacesEnd(str) {
return str.replace(/[\t ]+$/, '');
};
var Formatter =

@@ -35,4 +37,7 @@ /*#__PURE__*/

* @param {Object} cfg
* @param {Object} cfg.indent
* @param {Object} cfg.params
* @param {String} cfg.language
* @param {String} cfg.indent
* @param {Bool} cfg.uppercase
* @param {Integer} cfg.linesBetweenQueries
* @param {Object} cfg.params
* @param {Tokenizer} tokenizer

@@ -154,3 +159,3 @@ */

if (!(0, _includes["default"])(preserveWhitespaceFor, this.previousToken().type)) {
query = (0, _trimEnd["default"])(query);
query = trimSpacesEnd(query);
}

@@ -189,3 +194,3 @@

value: function formatComma(token, query) {
query = this.trimTrailingWhitespace(query) + token.value + ' ';
query = trimSpacesEnd(query) + token.value + ' ';

@@ -203,3 +208,3 @@ if (this.inlineBlock.isActive()) {

value: function formatWithSpaceAfter(token, query) {
return this.trimTrailingWhitespace(query) + token.value + ' ';
return trimSpacesEnd(query) + token.value + ' ';
}

@@ -209,3 +214,3 @@ }, {

value: function formatWithoutSpaces(token, query) {
return this.trimTrailingWhitespace(query) + token.value;
return trimSpacesEnd(query) + token.value;
}

@@ -227,3 +232,3 @@ }, {

this.indentation.decreaseTopLevel();
return this.trimTrailingWhitespace(query) + token.value + '\n';
return trimSpacesEnd(query) + token.value + '\n'.repeat(this.cfg.linesBetweenQueries || 1);
}

@@ -233,14 +238,7 @@ }, {

value: function addNewline(query) {
return (0, _trimEnd["default"])(query) + '\n' + this.indentation.getIndent();
query = trimSpacesEnd(query);
if (!query.endsWith('\n')) query += '\n';
return query + this.indentation.getIndent();
}
}, {
key: "trimTrailingWhitespace",
value: function trimTrailingWhitespace(query) {
if (this.previousNonWhitespaceToken().type === _tokenTypes["default"].LINE_COMMENT) {
return (0, _trimEnd["default"])(query) + '\n';
} else {
return (0, _trimEnd["default"])(query);
}
}
}, {
key: "previousNonWhitespaceToken",

@@ -247,0 +245,0 @@ value: function previousNonWhitespaceToken() {

@@ -26,2 +26,3 @@ "use strict";

* @param {Bool} cfg.uppercase Converts keywords to uppercase
* @param {Integer} cfg.linesBetweenQueries How many line breaks between queries
* @param {Object} cfg.params Collection of params for placeholder replacement

@@ -28,0 +29,0 @@ * @return {String}

{
"name": "sql-formatter-plus",
"version": "1.2.0",
"version": "1.3.0",
"description": "Formats whitespaces in a SQL query to make it more readable",

@@ -45,3 +45,2 @@ "license": "MIT",

"@babel/polyfill": "^7.6.0",
"dedent": "^0.7.0",
"lodash": "^4.17.15"

@@ -55,2 +54,3 @@ },

"babel-plugin-add-module-exports": "^1.0.2",
"dedent": "^0.7.0",
"eslint": "^6.6.0",

@@ -57,0 +57,0 @@ "eslint-config-adpyke-es6": "^1.4.13",

@@ -15,2 +15,3 @@ # SQL Formatter Plus

- Convert keywords to uppercase with the `uppercase` config option
- Configurable number of line breaks between queries with the `linesBetweenQueries` config option

@@ -54,3 +55,4 @@ **SQL Formatter** is a JavaScript library for pretty-printing SQL queries.

indent: ' ', // Defaults to two spaces,
uppercase: true // Defaults to false
uppercase: true, // Defaults to false
linesBetweenQueries: 2 // Defaults to 1
});

@@ -57,0 +59,0 @@ ```

import includes from 'lodash/includes';
import trimEnd from 'lodash/trimEnd';
import tokenTypes from './tokenTypes';

@@ -8,7 +7,12 @@ import Indentation from './Indentation';

const trimSpacesEnd = str => str.replace(/[ \t]+$/u, '');
export default class Formatter {
/**
* @param {Object} cfg
* @param {Object} cfg.indent
* @param {Object} cfg.params
* @param {String} cfg.language
* @param {String} cfg.indent
* @param {Bool} cfg.uppercase
* @param {Integer} cfg.linesBetweenQueries
* @param {Object} cfg.params
* @param {Tokenizer} tokenizer

@@ -126,3 +130,3 @@ */

if (!includes(preserveWhitespaceFor, this.previousToken().type)) {
query = trimEnd(query);
query = trimSpacesEnd(query);
}

@@ -157,3 +161,3 @@ query += token.value;

formatComma(token, query) {
query = this.trimTrailingWhitespace(query) + token.value + ' ';
query = trimSpacesEnd(query) + token.value + ' ';

@@ -170,7 +174,7 @@ if (this.inlineBlock.isActive()) {

formatWithSpaceAfter(token, query) {
return this.trimTrailingWhitespace(query) + token.value + ' ';
return trimSpacesEnd(query) + token.value + ' ';
}
formatWithoutSpaces(token, query) {
return this.trimTrailingWhitespace(query) + token.value;
return trimSpacesEnd(query) + token.value;
}

@@ -189,17 +193,11 @@

this.indentation.decreaseTopLevel();
return this.trimTrailingWhitespace(query) + token.value + '\n';
return trimSpacesEnd(query) + token.value + '\n'.repeat(this.cfg.linesBetweenQueries || 1);
}
addNewline(query) {
return trimEnd(query) + '\n' + this.indentation.getIndent();
query = trimSpacesEnd(query);
if (!query.endsWith('\n')) query += '\n';
return query + this.indentation.getIndent();
}
trimTrailingWhitespace(query) {
if (this.previousNonWhitespaceToken().type === tokenTypes.LINE_COMMENT) {
return trimEnd(query) + '\n';
} else {
return trimEnd(query);
}
}
previousNonWhitespaceToken() {

@@ -206,0 +204,0 @@ let n = 1;

@@ -14,2 +14,3 @@ import Db2Formatter from './languages/Db2Formatter';

* @param {Bool} cfg.uppercase Converts keywords to uppercase
* @param {Integer} cfg.linesBetweenQueries How many line breaks between queries
* @param {Object} cfg.params Collection of params for placeholder replacement

@@ -16,0 +17,0 @@ * @return {String}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc