(()=>{var __webpack_modules__={1528:e=>{e.exports=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]},3222:(e,t,n)=>{"use strict";var r=n(1528),i={nul:0,control:0};function o(e,t){return 0===e?t.nul:e<32||e>=127&&e<160?t.control:function(e){var t,n=0,i=r.length-1;if(er[i][1])return!1;for(;i>=n;)if(t=Math.floor((n+i)/2),e>r[t][1])n=t+1;else{if(!(e=4352&&(e<=4447||9001==e||9002==e||e>=11904&&e<=42191&&12351!=e||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141))}e.exports=function(e){return function(e,t){if("string"!=typeof e)return o(e,t);for(var n=0,r=0;r{const r=n(4285);class i extends Error{}function o(e,t=null){if(!e)throw t||(t="Assertion error"),new i(t)}class s{constructor(e,t,n,r,i,o,s){this.delim=e,this.policy=t,this.stop_on_warning=n,this.first_defective_line=null,this.records=r?[]:null,this.collect_records=r,this.num_records_parsed=0,this.fields_info=new Map,this.first_trailing_space_line=null,this.detect_trailing_spaces=o,this.preserve_quotes_and_whitespaces=i,this.min_num_fields_for_autodetection=s}consume(e,t){let[n,i]=r.smart_split(e,this.delim,this.policy,this.preserve_quotes_and_whitespaces);if(i&&(null===this.first_defective_line&&(this.first_defective_line=t),this.stop_on_warning))return!1;if(this.detect_trailing_spaces&&null===this.first_trailing_space_line)for(let e of n)!e.length||" "!=e.charAt(0)&&" "!=e.charAt(e.length-1)||(this.first_trailing_space_line=t);if(!this.fields_info.has(n.length)&&(this.fields_info.set(n.length,this.num_records_parsed),-1!=this.min_num_fields_for_autodetection)){if(n.length1)return!1}return this.collect_records&&this.records.push(n),this.num_records_parsed+=1,!0}}e.exports.parse_document_records=function(e,t,n,i=null,a=!1,l=-1,u=!0,_=!1,c=!1,f=-1){let p=e.lineCount,h=0,d=new r.MultilineRecordAggregator(i),g=new s(t,n,a,u,_,c,f),m=[];for(let t=0;t=p&&""==r){u&&m.push({record_num:g.num_records_parsed,comment_text:r});break}let o=null;if("quoted_rfc"==n){if(d.add_line(r),d.has_comment_line){h=t+1,d.reset(),u&&m.push({record_num:g.num_records_parsed,comment_text:r});continue}if(!d.has_full_record)continue;o=d.get_full_line("\n"),d.reset()}else{if(i&&r.startsWith(i)){h=t+1,u&&m.push({record_num:g.num_records_parsed,comment_text:r});continue}o=r}if(!g.consume(o,h))return[g.records,g.num_records_parsed,g.fields_info,g.first_defective_line,g.first_trailing_space_line,m];if(h=t+1,-1!==l&&g.num_records_parsed>=l)return[g.records,g.num_records_parsed,g.fields_info,g.first_defective_line,g.first_trailing_space_line,m]}return d.is_inside_multiline_record()&&(o("quoted_rfc"==n),g.consume(d.get_full_line("\n"),h)),[g.records,g.num_records_parsed,g.fields_info,g.first_defective_line,g.first_trailing_space_line,m]},e.exports.assert=o},8075:(e,t,n)=>{"use strict";var r=n(453),i=n(487),o=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&o(e,".prototype.")>-1?i(n):n}},487:(e,t,n)=>{"use strict";var r=n(6743),i=n(453),o=n(6897),s=n(9675),a=i("%Function.prototype.apply%"),l=i("%Function.prototype.call%"),u=i("%Reflect.apply%",!0)||r.call(l,a),_=n(655),c=i("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new s("a function is required");var t=u(r,l,arguments);return o(t,1+c(0,e.length-(arguments.length-1)),!0)};var f=function(){return u(r,a,arguments)};_?_(e.exports,"apply",{value:f}):e.exports.apply=f},41:(e,t,n)=>{"use strict";var r=n(655),i=n(8068),o=n(9675),s=n(5795);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,_=arguments.length>6&&arguments[6],c=!!s&&s(e,t);if(r)r(e,t,{configurable:null===u&&c?c.configurable:!u,enumerable:null===a&&c?c.enumerable:!a,value:n,writable:null===l&&c?c.writable:!l});else{if(!_&&(a||l||u))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},655:(e,t,n)=>{"use strict";var r=n(453)("%Object.defineProperty%",!0)||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}e.exports=r},1237:e=>{"use strict";e.exports=EvalError},9383:e=>{"use strict";e.exports=Error},9290:e=>{"use strict";e.exports=RangeError},9538:e=>{"use strict";e.exports=ReferenceError},8068:e=>{"use strict";e.exports=SyntaxError},9675:e=>{"use strict";e.exports=TypeError},5345:e=>{"use strict";e.exports=URIError},2682:(e,t,n)=>{"use strict";var r=n(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){if(!r(t))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=n),"[object Array]"===i.call(e)?function(e,t,n){for(var r=0,i=e.length;r{"use strict";var t=Object.prototype.toString,n=Math.max,r=function(e,t){for(var n=[],r=0;r{"use strict";var r=n(9353);e.exports=Function.prototype.bind||r},453:(e,t,n)=>{"use strict";var r,i=n(9383),o=n(1237),s=n(9290),a=n(9538),l=n(8068),u=n(9675),_=n(5345),c=Function,f=function(e){try{return c('"use strict"; return ('+e+").constructor;")()}catch(e){}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch(e){p=null}var h=function(){throw new u},d=p?function(){try{return h}catch(e){try{return p(arguments,"callee").get}catch(e){return h}}}():h,g=n(4039)(),m=n(24)(),y=Object.getPrototypeOf||(m?function(e){return e.__proto__}:null),b={},w="undefined"!=typeof Uint8Array&&y?y(Uint8Array):r,x={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":g&&y?y([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":b,"%AsyncGenerator%":b,"%AsyncGeneratorFunction%":b,"%AsyncIteratorPrototype%":b,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?r:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":o,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":c,"%GeneratorFunction%":b,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":g&&y?y(y([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&g&&y?y((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&g&&y?y((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":g&&y?y(""[Symbol.iterator]()):r,"%Symbol%":g?Symbol:r,"%SyntaxError%":l,"%ThrowTypeError%":d,"%TypedArray%":w,"%TypeError%":u,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":_,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet};if(y)try{null.error}catch(e){var v=y(y(e));x["%Error.prototype%"]=v}var E=function e(t){var n;if("%AsyncFunction%"===t)n=f("async function () {}");else if("%GeneratorFunction%"===t)n=f("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=f("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&y&&(n=y(i.prototype))}return x[t]=n,n},R={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},S=n(6743),O=n(9957),A=S.call(Function.call,Array.prototype.concat),q=S.call(Function.apply,Array.prototype.splice),I=S.call(Function.call,String.prototype.replace),P=S.call(Function.call,String.prototype.slice),T=S.call(Function.call,RegExp.prototype.exec),j=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,k=/\\(\\)?/g,N=function(e,t){var n,r=e;if(O(R,r)&&(r="%"+(n=R[r])[0]+"%"),O(x,r)){var i=x[r];if(i===b&&(i=E(r)),void 0===i&&!t)throw new u("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:i}}throw new l("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new u('"allowMissing" argument must be a boolean');if(null===T(/^%?[^%]*%?$/,e))throw new l("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=P(e,0,1),n=P(e,-1);if("%"===t&&"%"!==n)throw new l("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new l("invalid intrinsic syntax, expected opening `%`");var r=[];return I(e,j,(function(e,t,n,i){r[r.length]=n?I(i,k,"$1"):t||e})),r}(e),r=n.length>0?n[0]:"",i=N("%"+r+"%",t),o=i.name,s=i.value,a=!1,_=i.alias;_&&(r=_[0],q(n,A([0,1],_)));for(var c=1,f=!0;c=n.length){var m=p(s,h);s=(f=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:s[h]}else f=O(s,h),s=s[h];f&&!a&&(x[o]=s)}}return s}},5795:(e,t,n)=>{"use strict";var r=n(453)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},592:(e,t,n)=>{"use strict";var r=n(655),i=function(){return!!r};i.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=i},24:e=>{"use strict";var t={__proto__:null,foo:{}},n=Object;e.exports=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof n)}},4039:(e,t,n)=>{"use strict";var r="undefined"!=typeof Symbol&&Symbol,i=n(1333);e.exports=function(){return"function"==typeof r&&"function"==typeof Symbol&&"symbol"==typeof r("foo")&&"symbol"==typeof Symbol("bar")&&i()}},1333:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},9092:(e,t,n)=>{"use strict";var r=n(1333);e.exports=function(){return r()&&!!Symbol.toStringTag}},9957:(e,t,n)=>{"use strict";var r=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=n(6743);e.exports=o.call(r,i)},6698:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},7244:(e,t,n)=>{"use strict";var r=n(9092)(),i=n(8075)("Object.prototype.toString"),o=function(e){return!(r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===i(e)},s=function(e){return!!o(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==i(e)&&"[object Function]"===i(e.callee)},a=function(){return o(arguments)}();o.isLegacyArguments=s,e.exports=a?o:s},9600:e=>{"use strict";var t,n,r=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{t=Object.defineProperty({},"length",{get:function(){throw n}}),n={},i((function(){throw 42}),null,t)}catch(e){e!==n&&(i=null)}else i=null;var o=/^\s*class\b/,s=function(e){try{var t=r.call(e);return o.test(t)}catch(e){return!1}},a=function(e){try{return!s(e)&&(r.call(e),!0)}catch(e){return!1}},l=Object.prototype.toString,u="function"==typeof Symbol&&!!Symbol.toStringTag,_=!(0 in[,]),c=function(){return!1};if("object"==typeof document){var f=document.all;l.call(f)===l.call(document.all)&&(c=function(e){if((_||!e)&&(void 0===e||"object"==typeof e))try{var t=l.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}e.exports=i?function(e){if(c(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{i(e,null,t)}catch(e){if(e!==n)return!1}return!s(e)&&a(e)}:function(e){if(c(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(u)return a(e);if(s(e))return!1;var t=l.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&a(e)}},8184:(e,t,n)=>{"use strict";var r,i=Object.prototype.toString,o=Function.prototype.toString,s=/^\s*(?:function)?\*/,a=n(9092)(),l=Object.getPrototypeOf;e.exports=function(e){if("function"!=typeof e)return!1;if(s.test(o.call(e)))return!0;if(!a)return"[object GeneratorFunction]"===i.call(e);if(!l)return!1;if(void 0===r){var t=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch(e){}}();r=!!t&&l(t)}return l(e)===r}},5680:(e,t,n)=>{"use strict";var r=n(5767);e.exports=function(e){return!!r(e)}},6578:e=>{"use strict";e.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606:e=>{var t,n,r=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var a,l=[],u=!1,_=-1;function c(){u&&a&&(u=!1,a.length?l=a.concat(l):_=-1,l.length&&f())}function f(){if(!u){var e=s(c);u=!0;for(var t=l.length;t;){for(a=l,l=[];++_1)for(var n=1;n{"use strict";var r=n(453),i=n(41),o=n(592)(),s=n(5795),a=n(9675),l=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new a("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||l(t)!==t)throw new a("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,u=!0;if("length"in e&&s){var _=s(e,"length");_&&!_.configurable&&(r=!1),_&&!_.writable&&(u=!1)}return(r||u||!n)&&(o?i(e,"length",t,!0,!0):i(e,"length",t)),e}},1135:e=>{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},9032:(e,t,n)=>{"use strict";var r=n(7244),i=n(8184),o=n(5767),s=n(5680);function a(e){return e.call.bind(e)}var l="undefined"!=typeof BigInt,u="undefined"!=typeof Symbol,_=a(Object.prototype.toString),c=a(Number.prototype.valueOf),f=a(String.prototype.valueOf),p=a(Boolean.prototype.valueOf);if(l)var h=a(BigInt.prototype.valueOf);if(u)var d=a(Symbol.prototype.valueOf);function g(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function m(e){return"[object Map]"===_(e)}function y(e){return"[object Set]"===_(e)}function b(e){return"[object WeakMap]"===_(e)}function w(e){return"[object WeakSet]"===_(e)}function x(e){return"[object ArrayBuffer]"===_(e)}function v(e){return"undefined"!=typeof ArrayBuffer&&(x.working?x(e):e instanceof ArrayBuffer)}function E(e){return"[object DataView]"===_(e)}function R(e){return"undefined"!=typeof DataView&&(E.working?E(e):e instanceof DataView)}t.isArgumentsObject=r,t.isGeneratorFunction=i,t.isTypedArray=s,t.isPromise=function(e){return"undefined"!=typeof Promise&&e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch},t.isArrayBufferView=function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):s(e)||R(e)},t.isUint8Array=function(e){return"Uint8Array"===o(e)},t.isUint8ClampedArray=function(e){return"Uint8ClampedArray"===o(e)},t.isUint16Array=function(e){return"Uint16Array"===o(e)},t.isUint32Array=function(e){return"Uint32Array"===o(e)},t.isInt8Array=function(e){return"Int8Array"===o(e)},t.isInt16Array=function(e){return"Int16Array"===o(e)},t.isInt32Array=function(e){return"Int32Array"===o(e)},t.isFloat32Array=function(e){return"Float32Array"===o(e)},t.isFloat64Array=function(e){return"Float64Array"===o(e)},t.isBigInt64Array=function(e){return"BigInt64Array"===o(e)},t.isBigUint64Array=function(e){return"BigUint64Array"===o(e)},m.working="undefined"!=typeof Map&&m(new Map),t.isMap=function(e){return"undefined"!=typeof Map&&(m.working?m(e):e instanceof Map)},y.working="undefined"!=typeof Set&&y(new Set),t.isSet=function(e){return"undefined"!=typeof Set&&(y.working?y(e):e instanceof Set)},b.working="undefined"!=typeof WeakMap&&b(new WeakMap),t.isWeakMap=function(e){return"undefined"!=typeof WeakMap&&(b.working?b(e):e instanceof WeakMap)},w.working="undefined"!=typeof WeakSet&&w(new WeakSet),t.isWeakSet=function(e){return w(e)},x.working="undefined"!=typeof ArrayBuffer&&x(new ArrayBuffer),t.isArrayBuffer=v,E.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&E(new DataView(new ArrayBuffer(1),0,1)),t.isDataView=R;var S="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(e){return"[object SharedArrayBuffer]"===_(e)}function A(e){return void 0!==S&&(void 0===O.working&&(O.working=O(new S)),O.working?O(e):e instanceof S)}function q(e){return g(e,c)}function I(e){return g(e,f)}function P(e){return g(e,p)}function T(e){return l&&g(e,h)}function j(e){return u&&g(e,d)}t.isSharedArrayBuffer=A,t.isAsyncFunction=function(e){return"[object AsyncFunction]"===_(e)},t.isMapIterator=function(e){return"[object Map Iterator]"===_(e)},t.isSetIterator=function(e){return"[object Set Iterator]"===_(e)},t.isGeneratorObject=function(e){return"[object Generator]"===_(e)},t.isWebAssemblyCompiledModule=function(e){return"[object WebAssembly.Module]"===_(e)},t.isNumberObject=q,t.isStringObject=I,t.isBooleanObject=P,t.isBigIntObject=T,t.isSymbolObject=j,t.isBoxedPrimitive=function(e){return q(e)||I(e)||P(e)||T(e)||j(e)},t.isAnyArrayBuffer=function(e){return"undefined"!=typeof Uint8Array&&(v(e)||A(e))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(t,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})}))},537:(e,t,n)=>{var r=n(5606),i=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),a=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(n)?r.showHidden=n:n&&t._extend(r,n),w(r.showHidden)&&(r.showHidden=!1),w(r.depth)&&(r.depth=2),w(r.colors)&&(r.colors=!1),w(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=_),f(r,e,r.depth)}function _(e,t){var n=u.styles[t];return n?"["+u.colors[n][0]+"m"+e+"["+u.colors[n][1]+"m":e}function c(e,t){return e}function f(e,n,r){if(e.customInspect&&n&&S(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return b(i)||(i=f(e,i,r)),i}var o=function(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return y(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,n);if(o)return o;var s=Object.keys(n),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),R(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return p(n);if(0===s.length){if(S(n)){var l=n.name?": "+n.name:"";return e.stylize("[Function"+l+"]","special")}if(x(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return e.stylize(Date.prototype.toString.call(n),"date");if(R(n))return p(n)}var u,_="",c=!1,v=["{","}"];return d(n)&&(c=!0,v=["[","]"]),S(n)&&(_=" [Function"+(n.name?": "+n.name:"")+"]"),x(n)&&(_=" "+RegExp.prototype.toString.call(n)),E(n)&&(_=" "+Date.prototype.toUTCString.call(n)),R(n)&&(_=" "+p(n)),0!==s.length||c&&0!=n.length?r<0?x(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),u=c?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,_,v)):v[0]+_+v[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,l;if((l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(a=e.stylize("[Setter]","special")),I(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(l.value)<0?(a=m(n)?f(e,l.value,null):f(e,l.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").slice(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function y(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return void 0===e}function x(e){return v(e)&&"[object RegExp]"===O(e)}function v(e){return"object"==typeof e&&null!==e}function E(e){return v(e)&&"[object Date]"===O(e)}function R(e){return v(e)&&("[object Error]"===O(e)||e instanceof Error)}function S(e){return"function"==typeof e}function O(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!s[e])if(a.test(e)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=n(9032),t.isArray=d,t.isBoolean=g,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=y,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=w,t.isRegExp=x,t.types.isRegExp=x,t.isObject=v,t.isDate=E,t.types.isDate=E,t.isError=R,t.types.isNativeError=R,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(1135);var q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),q[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(6698),t._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var P="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(P&&e[P]){var t;if("function"!=typeof(t=e[P]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,P,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o{"use strict";var r=n(2682),i=n(9209),o=n(487),s=n(8075),a=n(5795),l=s("Object.prototype.toString"),u=n(9092)(),_="undefined"==typeof globalThis?n.g:globalThis,c=i(),f=s("String.prototype.slice"),p=Object.getPrototypeOf,h=s("Array.prototype.indexOf",!0)||function(e,t){for(var n=0;n-1?t:"Object"===t&&function(e){var t=!1;return r(d,(function(n,r){if(!t)try{n(e),t=f(r,1)}catch(e){}})),t}(e)}return a?function(e){var t=!1;return r(d,(function(n,r){if(!t)try{"$"+n(e)===r&&(t=f(r,1))}catch(e){}})),t}(e):null}},785:(e,t,n)=>{var r=n(5606);const i=n(2196),o=n(9175),s=n(7507),a=n(9022),l=n(6945),u=n(4285),_=n(3568),c=n(3222),f=-1,p=/^([0-9]+)(\.[0-9]+)?$/,h="quoted_rfc",d="quoted",g=1;class m extends Error{}function y(e,t=null){if(!e)throw t||(t="Assertion error"),new m(t)}function b(e,t,n,r){let i=r?c(e):e.length;if(n.has_wide_chars=n.has_wide_chars||i!=e.length,n.max_total_length=Math.max(n.max_total_length,i),n.max_int_length==f)return;let o=p.exec(e);if(null===o)return void(!t&&e.length&&(n.max_int_length=f,n.max_fractional_length=f));let s=o[1].length;n.max_int_length=Math.max(n.max_int_length,s);let a=void 0===o[2]?0:o[2].length;n.max_fractional_length=Math.max(n.max_fractional_length,a)}function w(e,t,n,r){e=e.trim();let i=n.has_wide_chars?c(e):e.length;if(n.max_int_length==f){let t=Math.max(n.max_total_length-i,0);return r?e:e+" ".repeat(t+g)}if(t&&null===p.exec(e)){let t=Math.max(n.max_total_length-i,0);return r?e:e+" ".repeat(t+g)}let o=e.indexOf("."),s=-1==o?e.length:o,a=-1==o?0:e.length-o,l=Math.max(n.max_int_length-s,0),u=Math.max(n.max_fractional_length-a),_=r?"":" ".repeat(u+g);return" ".repeat(l)+e+_}function x(e,t,n,r,i){let o=w(e,t,n,i);return r&&(o=" ".repeat(n.start_offset)+o),o}class v{constructor(e,t){this.records=e,this.comments=t,this.nr=0,this.next_comment=0}get_next(){if(this.has_comments_left()&&(!this.has_records_left()||this.comments[this.next_comment].record_num<=this.nr)){let e=[null,this.comments[this.next_comment].comment_text];return this.next_comment+=1,e}if(this.has_records_left()){let e=[this.records[this.nr],null];return this.nr+=1,e}return[null,null]}has_comments_left(){return this.next_comment=this.records.length)return null;let e=this.records[this.next_record_index];return this.next_record_index+=1,e}async get_record(){return 0==this.NR&&this.has_header&&this.do_get_record(),this.NR+=1,this.do_get_record()}get_warnings(){let e=[];return null!==this.first_defective_line&&e.push(`Inconsistent double quote escaping in ${this.table_name} table. E.g. at line ${this.first_defective_line}`),this.fields_info.size>1&&e.push(function(e,t){let[n,r,i,o]=a.sample_first_two_inconsistent_records(t),s=`Number of fields in "${e}" table is not consistent: `;return s+=`e.g. record ${n+1} -> ${r} fields, record ${i+1} -> ${o} fields`,s}(this.table_name,this.fields_info)),e}}class A extends a.RBQLOutputWriter{constructor(e,t){if(super(),this.delim=e,this.policy=t,this.header_len=null,this.null_in_output=!1,this.delim_in_simple_output=!1,this.output_lines=[],"simple"==t)this.polymorphic_join=this.simple_join;else if("quoted"==t)this.polymorphic_join=this.quoted_join;else if("quoted_rfc"==t)this.polymorphic_join=this.quoted_join_rfc;else if("monocolumn"==t)this.polymorphic_join=this.mono_join;else{if("whitespace"!=t)throw new S("Unknown output csv policy");this.polymorphic_join=this.simple_join}}set_header(e){null!==e&&(this.header_len=e.length,this.write(e))}quoted_join(e){let t=this.delim;return e.map((function(e){return u.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return u.rfc_quote_field(String(e),t)})).join(this.delim)}mono_join(e){if(e.length>1)throw new S('Unable to use "Monocolumn" output format: some records have more than one field');return e[0]}simple_join(e){var t=e.join(this.delim);return-1!=e.join("").indexOf(this.delim)&&(this.delim_in_simple_output=!0),t}normalize_fields(e){for(var t=0;ti&&r+1{i||(i=!0,r.close(),s(e))})),r.on("error",(e=>{a(e)})),l},e.exports.rbql_query_web=async function(e,t,n,r,i,o,s,l,u=null){let _=new q,c=new O(t,n,r,l,u),f=new A(i,o);return await a.query(e,c,f,s,_,""),f.output_lines},e.exports.rbql_query_node=async function(e,t,n,u,_,c,f,p,h,d,g=!1,m=null,y="",b=null){let w=null,x=null;b&&b.bulk_read&&n?x=n:w=null===n?r.stdin:o.createReadStream(n);let[v,E]=null===c?[r.stdout,!1]:[o.createWriteStream(c),!0];if('"'==u&&"quoted"==_)throw new S('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==h&&(h="binary"),!l.is_ascii(t)&&"binary"==h)throw new S("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(l.is_ascii(u)&&l.is_ascii(f)||"binary"!=h))throw new S("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let R=s.join(i.homedir(),".rbql_init_source.js");""==y&&o.existsSync(R)&&(y=l.read_user_init_code(R));let O=n?s.dirname(n):null,A=new I(e,O,u,_,h,g,m,b),q=new l.CSVRecordIterator(w,x,h,u,_,g,m),P=new l.CSVWriter(v,E,h,f,p);await a.query(t,q,P,d,A,y),A.get_warnings(d)},e.exports.get_header_line=function(e,t){const n=e.lineCount;for(let r=0;r=n.length);t++){let s=!1,l=e[t].split("\n");for(let u=0;u0&&(i.push(a.join(r)),a=[],s=!0);let _=t+1==e.length||l.length>1&&u+10&&(c.push(r.join(t)),r=[]);let n=i[e].trim();n.length!=i[e].length&&(f=!0),r.push(n)}}c.push(r.join(t))}return f?[c.join("\n"),null]:[null,null]},e.exports.calc_column_stats=function(e,t,n,r,i){let[o,s,a,l,u,c]=_.parse_document_records(e,t,n,r,!0,-1,!0,!0);if(null!==l)return[null,l+1,null,null];let p=[],h=!0,d=!1;for(let e of o){for(let t=0;t1&&(p[t].max_int_length=f,p[t].max_fractional_length=f);for(let e of r)b(e.trim(),h,p[t],d)}h=!1}return[p,null,o,c]},e.exports.adjust_column_stats=function(e,t){let n=[];for(let r of e){if(r.max_int_length<=0&&(r.max_int_length=-1,r.max_fractional_length=-1),r.max_int_length>0&&(r.max_int_length+r.max_fractional_length>r.max_total_length&&(r.max_total_length=r.max_int_length+r.max_fractional_length),r.max_total_length-r.max_fractional_length>r.max_int_length&&(r.max_int_length=r.max_total_length-r.max_fractional_length),r.max_total_length!=r.max_int_length+r.max_fractional_length))return null;let e=n.length?n[n.length-1]:null;r.start_offset=null===e?0:e.start_offset+e.max_total_length+g+t,n.push(r)}return n},e.exports.update_subcomponent_stats=b,e.exports.align_field=w,e.exports.rfc_align_field=x,e.exports.assert=y,e.exports.get_field_by_line_position=k,e.exports.get_cursor_position_info=function(e,t,n,r,i,o){return null===r?null:r==h?function(e,t,n,r,i){let o=new e.Range(Math.max(i.line-20,0),0,i.line+20,0),s=j(e,t,n,r,o),a=null;for(let e of s)if(e.hasOwnProperty("comment_range"))e.comment_range.contains(i)&&(a={is_comment:!0});else for(let t=0;t250&&(t[e]=t[e].substr(0,250)+"###UI_STRING_TRIM_MARKER###")}t.preview_records=f,t.actual_start_record=e.requested_start_record},e.exports.parse_document_range_rfc=j,e.exports.sample_first_two_inconsistent_records=a.sample_first_two_inconsistent_records,e.exports.is_opening_rfc_line=T,e.exports.show_lint_status_bar_button=function(e,t,n,r){const i="#f44242";let o=`${n}.${r}`;if(!t.lint_results.has(o))return;var s=t.lint_results.get(o);t.lint_status_bar_button||(t.lint_status_bar_button=e.window.createStatusBarItem(e.StatusBarAlignment.Left)),t.lint_status_bar_button.text="CSVLint";let l="";if(s.is_processing)t.lint_status_bar_button.color="#A0A0A0",t.lint_status_bar_button.text="$(clock) CSVLint",l="Processing";else if(Number.isInteger(s.first_defective_line))l=`Error. Line ${s.first_defective_line} has formatting error: double quote chars are not consistent`,t.lint_status_bar_button.color=i,t.lint_status_bar_button.text="$(error) CSVLint";else if(s.fields_info&&s.fields_info.size>1){let[e,n,r,o]=a.sample_first_two_inconsistent_records(s.fields_info);l=`Error. Number of fields is not consistent: e.g. record ${e+1} has ${n} fields, and record ${r+1} has ${o} fields`,t.lint_status_bar_button.color=i,t.lint_status_bar_button.text="$(error) CSVLint"}else Number.isInteger(s.first_trailing_space_line)?(l=`Leading/Trailing spaces detected: e.g. at line ${s.first_trailing_space_line+1}. Run "Shrink" command to remove them`,t.lint_status_bar_button.color="#ffff28",t.lint_status_bar_button.text="$(alert) CSVLint"):(y(s.is_ok),t.lint_status_bar_button.color="#62f442",t.lint_status_bar_button.text="$(pass) CSVLint",l="OK");t.lint_status_bar_button.tooltip=l+"\nClick to recheck",t.lint_status_bar_button.command="rainbow-csv.CSVLint",t.lint_status_bar_button.show()},e.exports.get_cursor_position_if_unambiguous=function(e){let t=e.selections;if(!t||1!=t.length)return null;let n=t[0],r=n.active;return r.isEqual(n.anchor)?r:null},e.exports.RecordCommentMerger=v,e.exports.generate_column_edit_selections=function(e,t,n,r,i,o,s){let[a,l,u,c,f,p]=_.parse_document_records(t,n,r,i,!0,-1,!0,!0);if(null!==c)return[null,`Unable to enter column edit mode: quoting error at line ${c+1}`,null];if(a.length+p.length!=t.lineCount)return[null,"Column edit mode is not supported for files with multiline fields",null];let g=0,m=[],b=null,w=new v(a,p);for(;w.has_entries_left();){let[t,i]=w.get_next();if(y(null===i!=(null===t)),null!==t){if(s>=t.length)return[null,`Line ${g+1} doesn't have field number ${s+1}`,null];let i=t.slice(0,s).join("").length+s*n.length,a=t.slice(0,s+1).join("").length+s*n.length,l=t.join(n);b||"ce_before"!=o||r!=d&&r!=h||-1==l.substring(i-2,i+2).indexOf('"')||(b=`Be careful, cursor at line ${g+1} has a double quote is in proximity.`),b||"ce_after"!=o||r!=d&&r!=h||-1==l.substring(a-2,a+2).indexOf('"')||(b=`Be careful, cursor at line ${g+1} has a double quote is in proximity.`),b||"ce_select"!=o||i!=a||(b=`Be careful, Field ${s+1} at line ${g+1} is empty.`);let u=new e.Position(g,i),_=new e.Position(g,a);"ce_before"==o&&m.push(new e.Selection(u,u)),"ce_after"==o&&m.push(new e.Selection(_,_)),"ce_select"==o&&m.push(new e.Selection(u,_))}g+=1}return[m,null,b]}},4285:e=>{let t='"((?:[^"]*"")*[^"]*)"',n=new RegExp("^"+t),r=new RegExp("^ *"+t+" *");function i(e,t,i,o,s,a){var l=!1;let u=e.substring(s),_=(o?r:n).exec(u);if(null!==_){let n=_[0].length;if(s+n==e.length||e[s+n]==t)return i?a.push(_[0]):a.push(_[1].replace(/""/g,'"')),[s+n+1,!1];l=!0}var c=e.indexOf(t,s);-1==c&&(c=e.length);var f=e.substring(s,c);return l=l||-1!=f.indexOf('"'),a.push(f),[c+1,l]}function o(e,t,n=!1){if(-1==e.indexOf('"'))return[e.split(t),!1];var r=[],o=0,s=!1;let a=" "!=t;for(;o1,this.has_full_record}is_inside_multiline_record(){return this.rfc_line_buffer.length&&!this.has_full_record}get_full_line(e){return this.rfc_line_buffer.join(e)}get_num_lines_in_record(){return this.rfc_line_buffer.length}reset(){this.rfc_line_buffer=[],this.has_full_record=!1,this.has_comment_line=!1}}},9022:(__unused_webpack_module,exports)=>{(function(exports){class RbqlParsingError extends Error{}class RbqlRuntimeError extends Error{}class AssertionError extends Error{}class RbqlIOHandlingError extends Error{}class InternalBadFieldError extends Error{constructor(e,...t){super(...t),this.bad_idx=e}}function assert(e,t=null){if(!e)throw t||(t="Assertion error"),new AssertionError(t)}function replace_all(e,t,n){return e.split(t).join(n)}class RBQLContext{constructor(e,t,n,r){this.query_text=e,this.input_iterator=t,this.writer=n,this.user_init_code=r,this.unnest_list=null,this.top_count=null,this.like_regex_cache=new Map,this.sort_key_expression=null,this.aggregation_stage=0,this.aggregation_key_expression=null,this.functional_aggregators=[],this.join_map_impl=null,this.join_map=null,this.lhs_join_var_expression=null,this.where_expression=null,this.select_expression=null,this.update_expressions=null,this.variables_init_code=null}}var query_context=null;const wrong_aggregation_usage_error="Usage of RBQL aggregation functions inside JavaScript expressions is not allowed, see the docs",RBQL_VERSION="0.27.0";function check_if_brackets_match(e,t){return"["==e&&"]"==t||"("==e&&")"==t||"{"==e&&"}"==t}function parse_root_bracket_level_text_spans(e){let t=[],n=0,r=[];for(let i=0;ie.trim())),t}function unquote_string(e){return!e||e.length<2?null:"'"==e[0]&&"'"==e[e.length-1]?e.substring(1,e.length-1).replace(/\\'/g,"'").replace(/\\\\/g,"\\"):'"'==e[0]&&'"'==e[e.length-1]?e.substring(1,e.length-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function column_info_from_text_span(e,t){e=e.trim();let n="__RBQL_INTERNAL_STAR",r=/^[_a-zA-Z][_a-zA-Z0-9]*$/.exec(e),i=/^([ab])\.([_a-zA-Z][_a-zA-Z0-9]*)$/.exec(e),o=/^([ab])\[([0-9]+)\]$/.exec(e),s=/^([ab])\[___RBQL_STRING_LITERAL([0-9]+)___\]$/.exec(e),a=/^(.*) (as|AS) +([a-zA-Z][a-zA-Z0-9_]*) *$/.exec(e);if(null!==a)return{table_name:null,column_index:null,column_name:null,is_star:!1,alias_name:a[3]};if(null!==r){if(e==n)return{table_name:null,column_index:null,column_name:null,is_star:!0,alias_name:null};if(e.startsWith("___RBQL_STRING_LITERAL"))return null;let t=/^([ab])([0-9]+)$/.exec(e);return null!==t?{table_name:t[1],column_index:parseInt(t[2])-1,column_name:null,is_star:!1,alias_name:null}:{table_name:null,column_index:null,column_name:e,is_star:!1,alias_name:null}}if(null!==i){let e=i[1],t=i[2];return t==n?{table_name:e,column_index:null,column_name:null,is_star:!0,alias_name:null}:{table_name:null,column_index:null,column_name:t,is_star:!1,alias_name:null}}if(null!=o)return{table_name:o[1],column_index:parseInt(o[2])-1,column_name:null,is_star:!1,alias_name:null};if(null!=s){s[1];let e=s[2];if(ecolumn_info_from_text_span(e,t)))}function stable_compare(e,t){for(var n=0;n=this.top_count||(await this.subwriter.write(e),this.NW+=1,0))}async finish(){await this.subwriter.finish()}}class UniqWriter{constructor(e){this.subwriter=e,this.seen=new Set}async write(e){return!add_to_set(this.seen,JSON.stringify(e))||!!await this.subwriter.write(e)}async finish(){await this.subwriter.finish()}}class UniqCountWriter{constructor(e){this.subwriter=e,this.records=new Map}async write(e){var t=JSON.stringify(e),n=this.records.get(t);return n?n[0]+=1:this.records.set(t,[1,e]),!0}async finish(){for(var[e,t]of this.records){let[e,n]=t;if(n.unshift(e),!await this.subwriter.write(n))break}await this.subwriter.finish()}}class SortedWriter{constructor(e,t){this.subwriter=e,this.reverse_sort=t,this.unsorted_entries=[]}async write(e){return this.unsorted_entries.push(e),!0}async finish(){var e=this.unsorted_entries;e.sort(stable_compare),this.reverse_sort&&e.reverse();for(var t=0;te instanceof UnnestMarker));for(var o=0;oo+e)),r.slice(0,e).concat(i).concat(r.slice(e+1)).join("\n")+"\n"}assert(!1)}function generate_main_loop_code(e){let t=null!==e.select_expression,n=null!==e.join_map,r=null===e.where_expression?"true":e.where_expression,i=null===e.aggregation_key_expression?"null":e.aggregation_key_expression,o=null===e.sort_key_expression?"null":e.sort_key_expression,s=embed_code(MAIN_LOOP_BODY,"__USER_INIT_CODE__",e.user_init_code);return t?(n?(s=embed_code(embed_code(s,"__CODE__",PROCESS_SELECT_JOIN),"__CODE__",PROCESS_SELECT_COMMON),s=embed_expression(s,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):s=embed_code(embed_code(s,"__CODE__",PROCESS_SELECT_SIMPLE),"__CODE__",PROCESS_SELECT_COMMON),s=embed_code(s,"__RBQLMP__variables_init_code",e.variables_init_code),s=embed_expression(s,"__RBQLMP__select_expression",e.select_expression),s=embed_expression(s,"__RBQLMP__where_expression",r),s=embed_expression(s,"__RBQLMP__aggregation_key_expression",i),s=embed_expression(s,"__RBQLMP__sort_key_expression",o)):(n?(s=embed_code(s,"__CODE__",PROCESS_UPDATE_JOIN),s=embed_expression(s,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):s=embed_code(s,"__CODE__",PROCESS_UPDATE_SIMPLE),s=embed_code(s,"__RBQLMP__variables_init_code",e.variables_init_code),s=embed_code(s,"__RBQLMP__update_expressions",e.update_expressions),s=embed_expression(s,"__RBQLMP__where_expression",r)),"(async () => {"+s+"})()"}async function compile_and_run(query_context){let main_loop_body=generate_main_loop_code(query_context);try{let main_loop_promise=eval(main_loop_body);await main_loop_promise}catch(e){if(e instanceof SyntaxError){let t=query_context.query_text.toLowerCase();if(-1!=t.indexOf(" having "))throw new SyntaxError(e.message+'\nRBQL doesn\'t support "HAVING" keyword');if(-1!=t.indexOf(" like "))throw new SyntaxError(e.message+"\nRBQL doesn't support \"LIKE\" operator, use like() function instead e.g. ... WHERE like(a1, 'foo%bar') ... ");if(-1!=t.indexOf(" from "))throw new SyntaxError(e.message+'\nTip: If input table is defined by the environment, RBQL query should not have "FROM" keyword');if(e&&e.message&&-1!=String(e.message).toLowerCase().indexOf("unexpected identifier")){if(-1!=t.indexOf(" and "))throw new SyntaxError(e.message+"\nDid you use 'and' keyword in your query?\nJavaScript backend doesn't support 'and' keyword, use '&&' operator instead!");if(-1!=t.indexOf(" or "))throw new SyntaxError(e.message+"\nDid you use 'or' keyword in your query?\nJavaScript backend doesn't support 'or' keyword, use '||' operator instead!")}}if(e&&e.message&&-1!=e.message.indexOf("Received an instance of RBQLAggregationToken"))throw new RbqlParsingError(wrong_aggregation_usage_error);throw e}}const GROUP_BY="GROUP BY",UPDATE="UPDATE",SELECT="SELECT",JOIN="JOIN",INNER_JOIN="INNER JOIN",LEFT_JOIN="LEFT JOIN",LEFT_OUTER_JOIN="LEFT OUTER JOIN",STRICT_LEFT_JOIN="STRICT LEFT JOIN",ORDER_BY="ORDER BY",WHERE="WHERE",LIMIT="LIMIT",EXCEPT="EXCEPT",WITH="WITH";function get_ambiguous_error_msg(e){return`Ambiguous variable name: "${e}" is present both in input and in join tables`}function get_all_matches(e,t){var n=[];let r=null;for(;null!==(r=e.exec(t));)n.push(r);return n}function str_strip(e){return e.replace(/^ +| +$/g,"")}function strip_comments(e){return(e=e.trim()).startsWith("//")?"":e}function combine_string_literals(e,t){for(var n=0;ne[1]));for(let e of o){let o=n.indexOf(e);if(-1==o)throw new RbqlParsingError(`Unable to find column "${e}" in ${"a"==t?"input":"join"} ${r}`);i[`${t}.${e}`]={initialize:!0,index:o}}}function map_variables_directly(e,t,n){for(let r=0;r1)throw new RbqlParsingError(`More than one "${o}" statements found`);assert(1==s.length);var a=s[0],l=a[0];n.push([a.index,a.index+l.length,o]);break}}return n.sort((function(e,t){return e[0]-t[0]})),n}function separate_actions(e){e=str_strip(e);var t={};let n=/^(.*) *[Ww][Ii][Tt][Hh] *\(([a-z]{4,20})\) *$/.exec(e);null!==n&&(e=n[1],t[WITH]=n[2]);for(var r=locate_statements(e),i=0;ie-t)),[null===r?null:select_except(r,o),`select_except(record_a, [${o.join(",")}])`]}class HashJoinMap{constructor(e,t){this.max_record_len=0,this.hash_map=new Map,this.record_iterator=e,this.nr=0,1==t.length?(this.key_index=t[0],this.key_indices=null,this.polymorphic_get_key=this.get_single_key):(this.key_index=null,this.key_indices=t,this.polymorphic_get_key=this.get_multi_key)}get_single_key(e,t){if(this.key_index>=t.length)throw new RbqlRuntimeError(`No field with index ${this.key_index+1} at record ${this.nr} in "B" table`);return-1===this.key_index?this.nr:t[this.key_index]}get_multi_key(e,t){let n=[];for(let e of this.key_indices){if(e>=t.length)throw new RbqlRuntimeError(`No field with index ${e+1} at record ${this.nr} in "B" table`);n.push(-1===e?this.nr:t[e])}return JSON.stringify(n)}async build(){for(;;){let e=await this.record_iterator.get_record();if(null===e)break;this.nr+=1;let t=e.length;this.max_record_len=Math.max(this.max_record_len,t);let n=this.polymorphic_get_key(this.nr,e),r=this.hash_map.get(n);void 0===r?this.hash_map.set(n,[[this.nr,t,e]]):r.push([this.nr,t,e])}}get_join_records(e){let t=this.hash_map.get(e);return void 0===t?[]:t}get_warnings(){return this.record_iterator.get_warnings()}}function cleanup_query(e){return e.split("\n").map(strip_comments).filter((e=>e.length)).join(" ").replace(/;+$/g,"")}function remove_redundant_table_name(e){return e=str_strip(e.replace(/ +from +a(?: +|$)/gi," ")),str_strip(e.replace(/^ *update +a +set /gi,"update "))}function select_output_header(e,t,n){null===e&&assert(null===t);let r=!1,i=!1;for(let e of n)r=r||null!==e&&e.is_star,i=i||null!==e&&null!==e.alias_name;if(null===e){if(r&&i)throw new RbqlParsingError("Using both * (star) and AS alias in the same query is not allowed for input tables without header");if(!i)return null;e=[],t=[]}null===t&&(t=[]);let o=[];for(let r of n)null===r?o.push("col"+(o.length+1)):r.is_star?null===r.table_name?o=o.concat(e).concat(t):"a"===r.table_name?o=o.concat(e):"b"===r.table_name&&(o=o.concat(t)):null!==r.column_name?o.push(r.column_name):null!==r.alias_name?o.push(r.alias_name):null!==r.column_index?"a"==r.table_name&&r.column_index1);let[n,r]=t[0],[i,o]=t[1];return[r,n,o,i]}function make_inconsistent_num_fields_warning(e,t){let[n,r,i,o]=sample_first_two_inconsistent_records(t),s=`Number of fields in "${e}" table is not consistent: `;return s+=`e.g. record ${n} -> ${r} fields, record ${i} -> ${o} fields`,s}class RBQLInputIterator{constructor(){}stop(){throw new Error("Unable to call the interface method")}async get_variables_map(e){throw new Error("Unable to call the interface method")}async get_record(){throw new Error("Unable to call the interface method")}handle_query_modifier(){}get_warnings(){return[]}async get_header(){return null}}class RBQLOutputWriter{constructor(){}async write(e){throw new Error("Unable to call the interface method")}async finish(){}get_warnings(){return[]}set_header(){}}class RBQLTableRegistry{constructor(){}get_iterator_by_table_id(e){throw new Error("Unable to call the interface method")}get_warnings(){return[]}}class TableIterator extends RBQLInputIterator{constructor(e,t=null,n=!0,r="a"){super(),this.table=e,this.column_names=t,this.normalize_column_names=n,this.variable_prefix=r,this.nr=0,this.fields_info=new Map,this.stopped=!1}stop(){this.stopped=!0}async get_variables_map(e){let t=new Object;if(parse_basic_variables(e,this.variable_prefix,t),parse_array_variables(e,this.variable_prefix,t),null!==this.column_names){if(this.table.length&&this.column_names.length!=this.table[0].length)throw new RbqlIOHandlingError("List of column names and table records have different lengths");this.normalize_column_names?(parse_dictionary_variables(e,this.variable_prefix,this.column_names,t),parse_attribute_variables(e,this.variable_prefix,this.column_names,"column names list",t)):map_variables_directly(e,this.column_names,t)}return t}async get_record(){if(this.stopped)return null;if(this.nr>=this.table.length)return null;let e=this.table[this.nr];this.nr+=1;let t=e.length;return this.fields_info.has(t)||this.fields_info.set(t,this.nr),e}get_warnings(){return this.fields_info.size>1?[make_inconsistent_num_fields_warning("input",this.fields_info)]:[]}async get_header(){return this.column_names}}class TableWriter extends RBQLOutputWriter{constructor(e){super(),this.table=e,this.header=null}async write(e){return this.table.push(e),!0}set_header(e){this.header=e}}class SingleTableRegistry extends RBQLTableRegistry{constructor(e,t=null,n=!0,r="b"){super(),this.table=e,this.table_id=r,this.column_names=t,this.normalize_column_names=n}get_iterator_by_table_id(e){if(e.toLowerCase()!==this.table_id)throw new RbqlIOHandlingError(`Unable to find join table: "${e}"`);return new TableIterator(this.table,this.column_names,this.normalize_column_names,"b")}}async function shallow_parse_input_query(e,t,n,r){e=cleanup_query(e);var[i,o]=separate_string_literals(e),s=separate_actions(i=remove_redundant_table_name(i));s.hasOwnProperty(WITH)&&t.handle_query_modifier(s[WITH]);var a=await t.get_variables_map(e);if(s.hasOwnProperty(ORDER_BY)&&s.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY" is not allowed in "UPDATE" queries');if(s.hasOwnProperty(GROUP_BY)){if(s.hasOwnProperty(ORDER_BY)||s.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY", "UPDATE" and "DISTINCT" keywords are not allowed in aggregate queries');r.aggregation_key_expression="["+combine_string_literals(s[GROUP_BY].text,o)+"]",r.aggregation_stage=1}let l=await t.get_header(),u=null,_=null;if(s.hasOwnProperty(JOIN)){var[c,f]=parse_join_expression(s[JOIN].text);if(null===n)throw new RbqlParsingError("JOIN operations are not supported by the application");let t=n.get_iterator_by_table_id(c);if(!t)throw new RbqlParsingError(`Unable to find join table: "${c}"`);if(s.hasOwnProperty(WITH)&&t.handle_query_modifier(s[WITH]),u=await t.get_variables_map(e),_=await t.get_header(),null===l&&null!==_)throw new RbqlIOHandlingError("Inconsistent modes: Input table doesn't have a header while the Join table has a header");if(null!==l&&null===_)throw new RbqlIOHandlingError("Inconsistent modes: Input table has a header while the Join table doesn't have a header");let[i,p]=resolve_join_variables(a,u,f,o),h={JOIN:InnerJoiner,"INNER JOIN":InnerJoiner,"LEFT JOIN":LeftJoiner,"LEFT OUTER JOIN":LeftJoiner,"STRICT LEFT JOIN":StrictLeftJoiner}[s[JOIN].join_subtype];r.lhs_join_var_expression=1==i.length?i[0]:"JSON.stringify(["+i.join(",")+"])",r.join_map_impl=new HashJoinMap(t,p),await r.join_map_impl.build(),r.join_map=new h(r.join_map_impl)}if(r.variables_init_code=combine_string_literals(generate_init_statements(i,a,u," ".repeat(4)),o),s.hasOwnProperty(WHERE)){var p=s[WHERE].text;if(/[^>{var r=n(5606);const i=n(8364),o=n(9135),s=n(1820),a=n(537),l=n(9022),u=n(4285),_="Unable to decode input table as UTF-8. Use binary (latin-1) encoding instead";class c extends Error{}class f extends Error{}function p(e,t=null){if(!e)throw t||(t="Assertion error"),new f(t)}function h(e){return/^[\x00-\x7F]*$/.test(e)}function d(e){return i.readFileSync(e,"utf-8")}function g(e,t){var n,r="~"===(n=t).charAt(0)?s.join(o.homedir(),n.slice(1)):n;if(i.existsSync(r))return r;if(e&&!s.isAbsolute(r)&&(r=s.join(e,r),i.existsSync(r)))return r;var a=function(e,t){for(var n=function(e){var t=null;try{t=i.readFileSync(e,"utf-8")}catch(e){return[]}for(var n=t.split("\n"),r=[],o=0;o1&&i.existsSync(a[1])?a[1]:null}class m{constructor(){this.push_stack=[],this.pull_stack=[]}enqueue(e){this.push_stack.push(e)}dequeue(){if(!this.pull_stack.length){if(!this.push_stack.length)return null;this.pull_stack=this.push_stack,this.pull_stack.reverse(),this.push_stack=[]}return this.pull_stack.pop()}}class y extends l.RBQLInputIterator{constructor(e,t,n,r,i,o=!1,s=null,l="input",_="a"){super(),this.stream=e,this.csv_path=t,p(null===this.stream!=(null===this.csv_path)),this.encoding=n,this.delim=r,this.policy=i,this.has_header=o,this.first_record=null,this.first_record_should_be_emitted=!o,this.header_preread_complete=!1,this.table_name=l,this.variable_prefix=_,this.comment_prefix=s,this.decoder=null,"utf-8"==n&&null===this.csv_path&&(this.decoder=new a.TextDecoder(n,{fatal:!0,stream:!0})),this.input_exhausted=!1,this.started=!1,this.utf8_bom_removed=!1,this.first_defective_line=null,this.fields_info=new Map,this.NR=0,this.NL=0,this.line_aggregator=new u.MultilineRecordAggregator(s),this.partially_decoded_line="",this.partially_decoded_line_ends_with_cr=!1,this.resolve_current_record=null,this.reject_current_record=null,this.current_exception=null,this.produced_records_queue=new m,this.process_line_polymorphic="quoted_rfc"==i?this.process_partial_rfc_record_line:this.process_record_line_simple}handle_query_modifier(e){-1!=["header","headers"].indexOf(e)&&(this.has_header=!0,this.first_record_should_be_emitted=!1),-1!=["noheader","noheaders"].indexOf(e)&&(this.has_header=!1,this.first_record_should_be_emitted=!0)}reset_external_callbacks(){this.reject_current_record=null,this.resolve_current_record=null}try_propagate_exception(){if(this.current_exception&&this.reject_current_record){let e=this.reject_current_record,t=this.current_exception;this.reset_external_callbacks(),this.current_exception=null,e(t)}}store_or_propagate_exception(e){null===this.current_exception&&(this.current_exception=e),this.try_propagate_exception()}async preread_first_record(){this.header_preread_complete||(this.first_record=await this.get_record(),this.header_preread_complete=!0,null!==this.first_record&&(this.stream&&this.stream.pause(),this.first_record=this.first_record.slice()))}async get_variables_map(e){let t=new Object;return l.parse_basic_variables(e,this.variable_prefix,t),l.parse_array_variables(e,this.variable_prefix,t),await this.preread_first_record(),this.has_header&&this.first_record&&(l.parse_attribute_variables(e,this.variable_prefix,this.first_record,"CSV header line",t),l.parse_dictionary_variables(e,this.variable_prefix,this.first_record,t)),t}async get_header(){return await this.preread_first_record(),this.has_header?this.first_record:null}try_resolve_next_record(){if(this.try_propagate_exception(),null===this.resolve_current_record)return;let e=null;if(this.first_record_should_be_emitted&&this.header_preread_complete?(this.first_record_should_be_emitted=!1,e=this.first_record):e=this.produced_records_queue.dequeue(),null===e&&!this.input_exhausted)return;let t=this.resolve_current_record;this.reset_external_callbacks(),t(e)}async get_record(){this.started||await this.start(),this.stream&&this.stream.isPaused()&&this.stream.resume();let e=this,t=new Promise((function(t,n){e.resolve_current_record=t,e.reject_current_record=n}));return this.try_resolve_next_record(),t}async get_all_records(e=null){let t=[];for(;;){let n=await this.get_record();if(null===n)break;if(t.push(n),e&&t.length>=e){this.stop();break}}return t}process_record_line_simple(e){this.comment_prefix&&e.startsWith(this.comment_prefix)||this.process_record_line(e)}process_record_line(e){this.NR+=1;var[t,n]=u.smart_split(e,this.delim,this.policy,!1);n&&null===this.first_defective_line&&(this.first_defective_line=this.NL,"quoted_rfc"==this.policy&&this.store_or_propagate_exception(new c(`Inconsistent double quote escaping in ${this.table_name} table at record ${this.NR}, line ${this.NL}`)));let r=t.length;this.fields_info.has(r)||this.fields_info.set(r,this.NR),this.produced_records_queue.enqueue(t),this.try_resolve_next_record()}process_partial_rfc_record_line(e){this.line_aggregator.add_line(e),this.line_aggregator.has_comment_line?this.line_aggregator.reset():this.line_aggregator.has_full_record&&(this.process_record_line(this.line_aggregator.get_full_line("\n")),this.line_aggregator.reset())}process_line(e){if(this.NL+=1,1===this.NL){var t=function(e,t){return"binary"==t&&e.length>=3&&239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)?e.substring(3):"utf-8"==t&&e.length>=1&&65279===e.charCodeAt(0)?e.substring(1):e}(e,this.encoding);t!=e&&(e=t,this.utf8_bom_removed=!0)}this.process_line_polymorphic(e)}process_data_stream_chunk(e){let t=null;if(this.decoder)try{t=this.decoder.decode(e)}catch(e){return void(e instanceof TypeError?this.store_or_propagate_exception(new c(_)):this.store_or_propagate_exception(e))}else t=e.toString(this.encoding);let n=t.length&&"\n"==t[0]&&this.partially_decoded_line_ends_with_cr?1:0;this.partially_decoded_line_ends_with_cr=t.length&&"\r"==t[t.length-1];let r=u.split_lines(t);r[0]=this.partially_decoded_line+r[0],p(0==n||0==r[0].length),this.partially_decoded_line=r.pop();for(let e=n;e{r?n(r):(e.process_data_bulk(i),t())}))}))}this.stream.on("data",(e=>{this.process_data_stream_chunk(e)})),this.stream.on("end",(()=>{this.process_data_stream_end()}))}}get_warnings(){let e=[];return null!==this.first_defective_line&&e.push(`Inconsistent double quote escaping in ${this.table_name} table. E.g. at line ${this.first_defective_line}`),this.utf8_bom_removed&&e.push(`UTF-8 Byte Order Mark (BOM) was found and skipped in ${this.table_name} table`),this.fields_info.size>1&&e.push(function(e,t){let[n,r,i,o]=l.sample_first_two_inconsistent_records(t),s=`Number of fields in "${e}" table is not consistent: `;return s+=`e.g. record ${n} -> ${r} fields, record ${i} -> ${o} fields`,s}(this.table_name,this.fields_info)),e}}class b extends l.RBQLOutputWriter{constructor(e,t,n,r,i,o="\n"){if(super(),this.stream=e,this.encoding=n,n&&this.stream.setDefaultEncoding(n),this.stream.on("error",(e=>{this.store_first_error(e)})),this.delim=r,this.policy=i,this.line_separator=o,this.sub_array_delim="|"==r?";":"|",this.close_stream_on_finish=t,this.null_in_output=!1,this.delim_in_simple_output=!1,this.header_len=null,this.first_error=null,"simple"==i)this.polymorphic_join=this.simple_join;else if("quoted"==i)this.polymorphic_join=this.quoted_join;else if("quoted_rfc"==i)this.polymorphic_join=this.quoted_join_rfc;else if("monocolumn"==i)this.polymorphic_join=this.mono_join;else{if("whitespace"!=i)throw new c("Unknown output csv policy");this.polymorphic_join=this.simple_join}}store_first_error(e){null===this.first_error&&(this.first_error=e)}set_header(e){null!==e&&(this.header_len=e.length,this.write(e))}quoted_join(e){let t=this.delim;return e.map((function(e){return u.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return u.rfc_quote_field(String(e),t)})).join(this.delim)}mono_join(e){if(e.length>1)throw new c('Unable to use "Monocolumn" output format: some records have more than one field');return e[0]}simple_join(e){var t=e.join(this.delim);return-1!=e.join("").indexOf(this.delim)&&(this.delim_in_simple_output=!0),t}normalize_fields(e){for(var t=0;t{i()})):setTimeout((()=>{i()}),0)}))}get_warnings(){let e=[];return this.null_in_output&&e.push("null values in output were replaced by empty strings"),this.delim_in_simple_output&&e.push("Some output fields contain separator"),e}}class w extends l.RBQLTableRegistry{constructor(e,t,n,r,i=!1,o=null,s=null){super(),this.input_file_dir=e,this.delim=t,this.policy=n,this.encoding=r,this.has_header=i,this.comment_prefix=o,this.stream=null,this.record_iterator=null,this.options=s,this.bulk_input_path=null,this.table_path=null}get_iterator_by_table_id(e){if(this.table_path=g(this.input_file_dir,e),null===this.table_path)throw new c(`Unable to find join table "${e}"`);return this.options&&this.options.bulk_read?this.bulk_input_path=this.table_path:this.stream=i.createReadStream(this.table_path),this.record_iterator=new y(this.stream,this.bulk_input_path,this.encoding,this.delim,this.policy,this.has_header,this.comment_prefix,e,"b"),this.record_iterator}get_warnings(e){this.record_iterator&&this.has_header&&e.push(`The first record in JOIN file ${s.basename(this.table_path)} was also treated as header (and skipped)`)}}e.exports.is_ascii=h,e.exports.CSVRecordIterator=y,e.exports.CSVWriter=b,e.exports.FileSystemCSVRegistry=w,e.exports.interpret_named_csv_format=function(e){if("monocolumn"==(e=e.toLowerCase()))return["","monocolumn"];if("csv"==e)return[",","quoted"];if("tsv"==e)return["\t","simple"];throw new c(`Unknown format name: "${e}"`)},e.exports.read_user_init_code=d,e.exports.query_csv=async function(e,t,n,a,u,_,f,p,g,m=!1,x=null,v="",E=null){let R=null,S=null;E&&E.bulk_read&&t?S=t:R=null===t?r.stdin:i.createReadStream(t);let[O,A]=null===u?[r.stdout,!1]:[i.createWriteStream(u),!0];if('"'==n&&"quoted"==a)throw new c('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==p&&(p="binary"),!h(e)&&"binary"==p)throw new c("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(h(n)&&h(_)||"binary"!=p))throw new c("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let q=s.join(o.homedir(),".rbql_init_source.js");""==v&&i.existsSync(q)&&(v=d(q));let I=t?s.dirname(t):null,P=new w(I,n,a,p,m,x,E),T=new y(R,S,p,n,a,m,x),j=new b(O,A,p,_,f);await l.query(e,T,j,g,P,v),P.get_warnings(g)},e.exports.RecordQueue=m,e.exports.exception_to_error_info=l.exception_to_error_info},1398:e=>{"use strict";e.exports=require("vscode")},8364:()=>{},9135:()=>{},1820:()=>{},6510:()=>{},9175:()=>{},2196:()=>{},7507:()=>{},7560:()=>{},9209:(e,t,n)=>{"use strict";var r=n(6578),i="undefined"==typeof globalThis?n.g:globalThis;e.exports=function(){for(var e=[],t=0;t{var e=__webpack_exports__;const t=__webpack_require__(1398),n=__webpack_require__(7507),r=__webpack_require__(9175),i=__webpack_require__(2196),o=__webpack_require__(6510),s=__webpack_require__(3568),a=__webpack_require__(4285);var l=null,u=null;function _(){return null===u&&(u=__webpack_require__(785)),u}const c=void 0===i.homedir;var f=null;const p=100,h="vscode_rbql_scratch";var d=new Set,g=new Map,m=new Map,y=new Set,b=null,w=null,x=null,v=null,E=null,R=null,S=null,O=null,A=null,q=new Map,I=null,P=null,T=null,j=null,k=null,N=null,C=null,L=null,M=null,B=null;let U=null,$=null,D=null,F=null;const W="plaintext",J="dynamic csv",Q="quoted",z="whitespace",V="quoted_rfc",G="simple";let H={lint_results:new Map,lint_status_bar_button:null,dynamic_document_dialects:new Map,custom_comment_prefixes:new Map,original_language_ids:new Map,reenable_rainbow_language_infos:new Map,autodetection_stoplist:new Set,autodetection_temporarily_disabled_for_rbql:!1,dynamic_dialect_for_next_request:null,logging_enabled:!1,logging_next_context_id:1};const Y={csv:[",",Q],tsv:["\t",G],"csv (semicolon)":[";",Q],"csv (pipe)":["|",G],"csv (whitespace)":[" ",z],[J]:[null,null]},Z="comment",X=["rainbow1","rainbow2","rainbow3","rainbow4","rainbow5","rainbow6","rainbow7","rainbow8","rainbow9","rainbow10"],K=X.concat([Z]),ee=new t.SemanticTokensLegend(K);function te(e){return e&&e.uri&&e.fileName&&function(e){return e&&e.uri&&-1!=["file","untitled","vscode-test-web"].indexOf(e.uri.scheme)}(e)}function ne(e){return te(e)&&Y.hasOwnProperty(e.languageId)}function re(e,t){return{delim:e,policy:t}}function ie(e){return"dynamic_dialect:"+e}async function oe(e,t,n){await de(ie(t),n),e.dynamic_document_dialects.set(t,n)}function se(e){if(H.dynamic_document_dialects.has(e))return H.dynamic_document_dialects.get(e);let t=he(ie(e),null);return t&&t.hasOwnProperty("delim")&&t.hasOwnProperty("policy")?(H.dynamic_document_dialects.set(e,t),t):null}function ae(e){return e?e.toLowerCase():e}function le(e){for(let t in Y)if(Y.hasOwnProperty(t)&&Y[t][0]==e)return Y[t][1];return G}function ue(e,t){for(let n in Y)if(Y.hasOwnProperty(n)&&Y[n][0]==e&&Y[n][1]==t)return n;return J}let _e={"rbql_client.js":null,"contrib/textarea-caret-position/index.js":null,"rbql_suggest.js":null,"rbql_logo.svg":null,"rbql_client.html":null,"dialect_select.html":null,"dialect_select.js":null,"rbql mock/rbql_mock.py":null,"rbql_core/vscode_rbql.py":null};function ce(e){var n=t.window;n&&n.showErrorMessage(e)}function fe(e){return new Promise((t=>setTimeout(t,e)))}async function pe(e,t){e.report({message:t}),await fe(0)}function he(e,t){if(T){var n=T.get(e);if(null!=n)return n}return t}async function de(e,t){return!(!T||!e||(await T.update(e,t),0))}async function ge(e,n,r){let i=new t.Range(0,0,n.lineCount,0),o=n.validateRange(i);await e.edit((e=>e.replace(o,r)))}function me(e){return"rbql_header_info:"+e}function ye(e){return"rbql_with_headers:"+e}function be(e,n,r=null){return r||(r=t.workspace.getConfiguration("rainbow_csv")),r?r.get(e):n}class we{constructor(e,t=null){this.context_name=e,this.logging_enabled=H.logging_enabled,this.context_id=null===t?H.logging_next_context_id:t,H.logging_next_context_id+=1}log_doc_event(e,t=null){if(this.logging_enabled)try{let n=`CID:${this.context_id}, ${this.context_name}:${e}`;t?(n=`${n}, doc_lang:${t.languageId}`,t.uri&&(n=`${n}, doc_uri:${t.uri.toString(!0)}`)):n=`${n}, no_doc:1`,A.info(n)}catch(e){return void console.error(`Rainbow CSV: Unexpected log failure. ${this.context_name}:${this.event_name}`)}}log_simple_event(e){if(this.logging_enabled)try{let t=`CID:${this.context_id}, ${this.context_name}:${e}`;A.info(t)}catch(e){return void console.error(`Rainbow CSV: Unexpected log failure. ${this.context_name}:${this.event_name}`)}}}function xe(e,t,n,r){let[i,o]=_().get_header_line(e,r);return o?a.smart_split(o,t,n,!1)[0]:null}function ve(e,t,n,r){var i=e.fileName;if(i){let e=he(me(i),null);if(null!==e&&null!==e.header)return e.header}return xe(e,t,n,r)}function Ee(e){let t=e.languageId,n=null,r=null,i="";if(i=H.custom_comment_prefixes.has(e.fileName)?H.custom_comment_prefixes.get(e.fileName):be("comment_prefix",""),t!=J&&Y.hasOwnProperty(t))return[n,r]=Y[t],[n,r,i];let o=null;return t==J&&(o=se(e.fileName)),o?[o.delim,o.policy,i]:[null,null,null]}class Re{constructor(){}async provideDocumentSymbols(e){let[n,r,i]=Ee(e);if(!r)return null;let o=null;var s=e.fileName;if(s){let e=he(me(s),null);null!==e&&null!==e.header_line_num&&(o=e.header_line_num)}if(null===o&&(o=_().get_header_line(e,i)[0]),null===o||o>=e.lineCount-1)return null;let a=new t.Range(o,0,e.lineCount-1,65535);a=e.validateRange(a);let l=new t.Range(o,0,o,65535);if(!a.contains(l))return;let u=t.SymbolKind.File;return[new t.DocumentSymbol("data","",u,a,l)]}}function Se(e=!1){if(!be("enable_sticky_header",!1))return void(null!==F&&(F.dispose(),F=null));if(null!==F&&e&&(F.dispose(),F=null),null!==F)return;let n=new Re,r=[];for(let e in Y)Y.hasOwnProperty(e)&&r.push({language:e});F=t.languages.registerDocumentSymbolProvider(r,n)}function Oe(){let e=new gt;null!==$&&$.dispose();let n={language:J};$=t.languages.registerDocumentRangeSemanticTokensProvider(n,e,ee)}function Ae(){let e=new mt;null!==D&&D.dispose();let n=[];for(let e in Y)Y.hasOwnProperty(e)&&e!=J&&n.push({language:e});D=t.languages.registerDocumentRangeSemanticTokensProvider(n,e,ee)}async function qe(e=null){let n=new we("choose_dynamic_separator");n.log_doc_event("starting",i);let r=je();if(!r)return;var i=ke(r);if(!te(i))return;let o=function(e,t){if(!e||!t)return"";let n=e.selection;return n?n.start.line!=n.end.line?"":t.lineAt(n.start.line).text.substring(n.start.character,n.end.character):""}(r,i);P||(P=await yt("dialect_select.html")),(k=t.window.createWebviewPanel("rainbow-dialect-select","Choose CSV Dialect",t.ViewColumn.Beside,{enableScripts:!0})).webview.html=it(k,P,["dialect_select.js"]),k.webview.onDidReceiveMessage((function(r){!async function(e,n,r,i,o,s){if(r){if("dialect_handshake"==r.msg_type){let e={msg_type:"dialect_handshake",selected_separator:i};s&&s.integration_test&&(e.integration_test=!0),await n.webview.postMessage(e)}if("apply_dialect"==r.msg_type){let i=r.delim,s=r.policy,a=r.comment_prefix;if("whitespace"==s&&" "!=i)return void ce("Selected policy can only be used with whitespace separator");if("double_escape"==s&&'"'==i)return void ce("Double quote separator in incompatible with double quote escape policy");if(!i)return void ce("Separator is empty");if(-1==[G,V,Q,z].indexOf(s))return void ce("Selected policy is empty or not supported");n.dispose(),await oe(H,e.fileName,re(i,s)),H.custom_comment_prefixes.set(e.fileName,a),e.languageId==J&&Ne(e)?await Ie(e,o):await t.languages.setTextDocumentLanguage(e,J)}}}(i,k,r,o,n,e)}))}async function Ie(e,r){if(r.log_doc_event("start enable-rainbow-features-if-csv",e),!ne(e))return void r.log_simple_event("abort enable-rainbow-features-if-csv: non-rainbow dialect");v&&v.hide();var i=e.languageId;i==J&&null!=H.dynamic_dialect_for_next_request&&(await oe(H,e.fileName,H.dynamic_dialect_for_next_request),H.dynamic_dialect_for_next_request=null);let[o,s,a]=Ee(e);if(!o||!s)return r.log_simple_event("abort enable-rainbow-features-if-csv: missing delim or policy"),Pe(),S||(S=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),S.text="Choose Separator...",S.tooltip="Click to choose Dynamic CSV separator",S.command="rainbow-csv.RainbowSeparator",void S.show();a&&t.languages.setLanguageConfiguration(i,{comments:{lineComment:a}}),i==J&&Oe(),function(e){S&&S.hide(),_().show_lint_status_bar_button(t,H,e.fileName,e.languageId),b||(b=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),b.text="Query",b.tooltip="Click to run SQL-like RBQL query",b.command="rainbow-csv.RBQL",b.show(),Ce(e.fileName),x||(x=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),x.text="Rainbow OFF",x.tooltip="Click to restore original file type and syntax",x.command="rainbow-csv.RainbowSeparatorOff",x.show(),function(e){let r=g.get(ae(e));if(!r||-1!=r.indexOf(h))return;let i=n.basename(r);E||(E=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),E.text="Copy Back",E.tooltip=`Copy to parent table: ${i}`,E.command="rainbow-csv.CopyBack",E.show()}(e.fileName),Le(),be("enable_cursor_position_info",!1)&&(C=t.window.onDidChangeTextEditorSelection(_t))}(e),await Me(e,!1),r.log_simple_event("finish enable-rainbow-features-if-csv")}function Pe(){let e=[H.lint_status_bar_button,b,x,E,w,R,S,v];for(let t=0;t=1e4)return void ce("Multicursor column edit works only for files smaller than 10000 lines.");let l=_().get_cursor_position_info(t,r,i,o,s,a).column_number,[u,c,f]=_().generate_column_edit_selections(t,r,i,o,s,e,l);null===c?(f&&t.window.showWarningMessage(f),n.selections=u,await t.window.showTextDocument(r)):ce(c)}async function et(){let e=je(),n=ke(e);if(!ne(n))return;let[r,i,o]=Ee(n);if(null===i)return;let s={location:t.ProgressLocation.Window,title:"Rainbow CSV"};await t.window.withProgress(s,(async s=>{await pe(s,"Preparing");let[a,l]=_().shrink_columns(n,r,i,o);l?ce(`Unable to shrink: Inconsistent double quotes at line ${l}`):(d.delete(n.fileName),Ce(n.fileName),null!==a?(await pe(s,"Shrinking columns"),await ge(e,n,a)):t.window.showWarningMessage("No trailing whitespaces found, skipping"))}))}async function tt(){let e=je(),n=ke(e);if(!ne(n))return;let[r,i,o]=Ee(n);if(null===i)return;let s={location:t.ProgressLocation.Window,title:"Rainbow CSV"};await t.window.withProgress(s,(async s=>{await pe(s,"Calculating column statistics");let a=be("double_width_alignment",!0),[l,u,c,f]=_().calc_column_stats(n,r,i,o,a);if(u)return void ce(`Unable to align: Inconsistent double quotes at line ${u}`);if(l=_().adjust_column_stats(l,r.length),null===l)return void ce("Unable to allign: Internal Rainbow CSV Error");await pe(s,"Preparing final alignment");let p=_().align_columns(c,f,l,r);await pe(s,"Aligning columns");let h=be("align_in_scratch_file",!1),g=n.uri&&"untitled"==n.uri.scheme;if(h&&!g){let e={content:p,language:n.languageId},r=await t.workspace.openTextDocument(e);d.add(r.fileName),await t.window.showTextDocument(r),Ce(r.fileName)}else await ge(e,n,p),d.add(n.fileName),Ce(n.fileName)}))}async function nt(){if(c)return void ce("This command is currently unavailable in web mode.");let e=ke();if(!e)return;let n=e.fileName,r=g.get(ae(n));if(!r)return;let i=await t.workspace.openTextDocument(r),o=await t.window.showTextDocument(i);await async function(e,t){let n=e.getText(),r=ke(t);r&&await ge(t,r,n)}(e,o)}async function rt(e,o,s=null){let u=o.msg_type;if("handshake"==u){var f={msg_type:"handshake",backend_language:he("rbql_backend_language","js"),encoding:he("rbql_encoding","utf-8")};_().sample_preview_records_from_context(O,f,p,m);let t=Fe(O.input_document_path);q.has(t)&&(f.last_query=q.get(t));let n=he("rbql_query_history",[]);f.query_history=n,f.policy=O.policy,f.with_headers=O.with_headers,f.header_for_ui=O.header_for_ui,f.is_web_ext=c,s&&(f.integration_test_language=s.rbql_backend,f.integration_test_query=s.rbql_query,f.integration_test_with_headers=s.with_headers||!1,f.integration_test_delay=s.integration_test_delay||2e3),await e.postMessage(f)}if("fetch_table_header"==u)try{let t=o.table_id,r=o.encoding,i=O.input_document_path?n.dirname(O.input_document_path):null,s=_().find_table_path(T,i,t);if(!s)return;let l=await _().read_header(s,r);if(!l)return;let[u,c]=a.smart_split(l,O.delim,O.policy,!1);c||e.postMessage({msg_type:"fetch_table_header_response",header_for_ui:u})}catch(e){console.error("Unable to get join table header: "+String(e))}if("update_query"==u){let e=o.query;if(!e)return;O.input_document_path&&q.set(Fe(O.input_document_path),e)}if("with_headers_change"==u&&(O.with_headers=o.with_headers,O.input_document_path&&await de(ye(O.input_document_path),O.with_headers)),"navigate"==u){var h=o.direction;"backward"==h?O.requested_start_record-=p:"forward"==h?O.requested_start_record+=p:"begin"==h?O.requested_start_record=0:"end"==h&&(O.requested_start_record=O.input_document.lineCount);let t={msg_type:"navigate"};_().sample_preview_records_from_context(O,t,p,m),await e.postMessage(t)}if("run"==u){let r=o.query,s=o.backend_language,a=o.encoding,u=o.output_dialect,f=o.with_headers;await async function(e){let t=he("rbql_query_history",[]),n=t.indexOf(e);-1!=n?t.splice(n,1):t.length>=20&&t.splice(0,1),t.push(e),await de("rbql_query_history",t)}(r),await async function(e,r,o,s,a,u,f){let p=new we("run-rbql-query");p.log_simple_event("start"),q.set(Fe(r),a);let h=["python3","python"],[d,m,y]=[O.delim,O.policy,O.comment_prefix],[b,w]=[d,m];"csv"==u&&([b,w]=[",",Q]),"tsv"==u&&([b,w]=["\t",G]),O.output_delim=b,O.output_policy=w;let x=c?null:n.join(function(e){let t=be("rbql_output_dir","TMP");return"TMP"==t?i.tmpdir():"INPUT"==t?n.dirname(e):t}(r),function(e,t){var r=n.basename(e),i=n.extname(r),o={"\t":".tsv",",":".csv"},s=".txt";o.hasOwnProperty(t)?s=o[t]:i.length>1&&(s=i);let a=r+s;return a==r&&(a+=".txt"),a}(r,b));if(a.startsWith("test ")){p.log_simple_event("test mode");let t=[_e["rbql mock/rbql_mock.py"],a],n=await Je(h,t,p);return console.log(JSON.stringify(n)),n.hasOwnProperty("error_type")||n.hasOwnProperty("error_msg")?void await Qe(e,n.error_type,n.error_msg):void await Qe(e,null,null)}if("js"==s){p.log_simple_event("using js backend");let n=[],i=null,s=ue(b,w);try{if(c){p.log_simple_event("using web mode");let r={content:(await _().rbql_query_web(a,O.input_document,d,m,b,w,n,f,y)).join("\n"),language:s};s==J&&(H.dynamic_dialect_for_next_request=re(b,w)),H.autodetection_temporarily_disabled_for_rbql=!0,i=await t.workspace.openTextDocument(r),await Qe(e,null,null),await async function(e,n){try{await t.window.showTextDocument(e)}catch(e){return void ce("Unable to open RBQL result document")}await $e(n)}(i,n),H.dynamic_dialect_for_next_request=null,H.autodetection_temporarily_disabled_for_rbql=!1,p.log_simple_event("finished OK")}else{p.log_simple_event("using electron mode");let l={bulk_read:!0};await _().rbql_query_node(T,a,r,d,m,x,b,w,o,n,f,y,"",l),g.set(ae(x),r),s==J&&(H.dynamic_dialect_for_next_request=re(b,w)),H.autodetection_temporarily_disabled_for_rbql=!0,i=await t.workspace.openTextDocument(x),await Qe(e,null,null),await De(i,b,w,n),H.dynamic_dialect_for_next_request=null,H.autodetection_temporarily_disabled_for_rbql=!1,p.log_simple_event("finished OK")}}catch(t){let[n,r]=(null===l&&(l=__webpack_require__(6945)),l).exception_to_error_info(t);return p.log_simple_event("finished with error"),void await Qe(e,n,r)}}else{if(p.log_simple_event("using python backend"),c)return void await Qe(e,"Input error","Python backend for RBQL is not supported in web version, please use JavaScript backend.");let n=Buffer.from(a,"utf-8").toString("base64");y||(y="");let i=[_e["rbql_core/vscode_rbql.py"],n,r,d,m,x,b,w,y,o];f&&i.push("--with_headers");let s=await Je(h,i,p);if(s.hasOwnProperty("error_type")||s.hasOwnProperty("error_msg"))return p.log_simple_event("finished with error"),void await Qe(e,s.error_type,s.error_msg);p.log_simple_event("finished OK"),await Qe(e,null,null),H.autodetection_stoplist.add(x),g.set(ae(x),r),H.autodetection_temporarily_disabled_for_rbql=!0;let l=ue(b,w),u=await t.workspace.openTextDocument(x);H.autodetection_temporarily_disabled_for_rbql=!1,l==J&&(H.dynamic_dialect_for_next_request=re(b,w)),await De(u,b,w,s.warnings),H.dynamic_dialect_for_next_request=null}}(e,O.input_document_path,a,s,r,u,f)}if("edit_udf"==u){if(c)return void await Qe(e,"Input error","UDFs are currently not supported in web version");let s=null,a="";"js"==o.backend_language?(s=n.join(i.homedir(),".rbql_init_source.js"),a=_().get_default_js_udf_content()):(s=n.join(i.homedir(),".rbql_init_source.py"),a=_().get_default_python_udf_content()),r.existsSync(s)||r.writeFileSync(s,a);let l=await t.workspace.openTextDocument(s);await t.window.showTextDocument(l)}"global_param_change"==u&&await de(o.key,o.value)}function it(e,n,r){for(const i of r){let r=null;r=c?_e[i]:e.webview.asWebviewUri(t.Uri.file(_e[i])),n=n.replace(`src="${i}"`,`src="${r}"`)}return n}async function ot(e=null){let o=t.window;if(!o)return;let s=o.activeTextEditor;if(!s)return;let a=s.document;if(!a)return;let l=a.uri;if(!l)return;if("file"!=l.scheme&&"untitled"!=l.scheme&&!c)return;if("file"==l.scheme&&a.isDirty&&!c)return void ce("Unable to run RBQL: file has unsaved changes");let u=null;if("untitled"!=l.scheme||c)u=a.fileName;else{let e=a.getText(),t=String(Math.floor(1e6*Math.random()));u=n.join(i.tmpdir(),`${h}_${t}.txt`),r.writeFileSync(u,e)}if(!u)return void ce("Unable to run RBQL for this file");let[_,f,p]=Ee(a);null===f&&(f="monocolumn",_="monocolumn");let d=be("rbql_with_headers_by_default",!1),g=he(ye(u),d),m=xe(a,_,f,p);O={input_document:a,input_document_path:u,requested_start_record:0,delim:_,policy:f,comment_prefix:p,with_headers:g,header_for_ui:m},j=t.window.createWebviewPanel("rbql-console","RBQL Console",t.ViewColumn.Active,{enableScripts:!0}),I||(I=await yt("rbql_client.html")),j.webview.html=it(j,I,["contrib/textarea-caret-position/index.js","rbql_suggest.js","rbql_client.js","rbql_logo.svg"]),j.webview.onDidReceiveMessage((function(t){rt(j.webview,t,e)}))}function st(e,t,n){let[r,i,o]=["csv",",",Q],s=0,a=e.getText();if(!a)return[r,i,o];for(let e of t){if(" "==e||"."==e)continue;let t=0;for(let r=0;rs){let n=le(e),a=ue(e,n);[r,i,o]=[a,e,n],s=t}}return[r,i,o]}async function at(e,t,n,r,i=null){let o=new we("autodetection",i);if(o.log_doc_event("starting...",r),n.autodetection_temporarily_disabled_for_rbql)return o.log_simple_event("abort: disabled for rbql"),[r,!1];if(!te(r))return o.log_simple_event("abort: ineligible doc"),[r,!1];if(!be("enable_separator_autodetection",!1,t))return o.log_simple_event("abort: disabled in config"),[r,!1];var a=r.fileName,l=r.languageId;if(n.autodetection_stoplist.has(a))return o.log_simple_event("abort: doc path in stoplist"),[r,!1];let u=(a.endsWith(".csv")||a.endsWith(".CSV"))&&"csv"==l;if(l!=W&&!u)return o.log_simple_event("abort: ineligible original language id"),[r,!1];let _=be("autodetect_separators",[],t).map((e=>"TAB"===e?"\t":e));if(!Y.hasOwnProperty(l)&&L&&L.file_path===a&&Math.abs(Date.now()-L.timestamp)<1e3)return o.log_simple_event("abort: recent doc language switch prevention"),[r,!1];let c=be("comment_prefix","",t)||"#";o.log_simple_event("starting standard dialect autodetection...");let[f,p,h,d]=function(e,t,n,r){let i=[];for(let e of n){let t=le(e),n=ue(e,t);n&&t&&(i.push([n,e,t]),","!=e&&";"!=e||i.push([J,e,V]))}let o=be("csv_lint_detect_trailing_spaces",!1,e),a=be("autodetection_min_line_count",10,e);if(t.lineCount=f+1&&(f=w,[l,u,_]=[n,i,p],c=y)}return[l,u,_,c]}(t,r,_,c);if(f?n.lint_results.set(`${a}.${f}`,{is_ok:!0,first_trailing_space_line:d}):!f&&u&&(o.log_simple_event("starting frequency-based dialect autodetection..."),[f,p,h]=st(r,_,1e4)),!f)return o.log_simple_event("abort: content-based autodetection did not detect anything"),[r,!1];if(f==J&&await oe(n,a,re(p,h)),f==l)return o.log_simple_event("abort: autodetected dialect matches the original one"),[r,!1];Ve(a,l,n.original_language_ids),o.log_simple_event(`autodetection successful - switching from ${l} to ${f}`);let g=await e.languages.setTextDocumentLanguage(r,f);return o.log_doc_event("after language switch",g),[g,!0]}async function lt(e){if(!e)return;N&&(N.dispose(),N=null);let n=new we("handle_first_edit_for_an_empty_doc");n.log_doc_event("starting",e.document),await at(t,t.workspace.getConfiguration("rainbow_csv"),H,e.document,n.context_id)}async function ut(e){let t=new we("handle_editor_switch"),n=ke(e);t.log_doc_event("editor switch",n),Te(n,t),await Ie(n,t)}function _t(e){null!==U&&clearTimeout(U),U=setTimeout((()=>{!Le()&&R&&R.hide()}),10)}async function ct(e){let n=new we("handle_doc_open");if(n.log_doc_event("opening doc",e),!te(e))return void n.log_simple_event("abort: ineligible doc");if(be("enable_separator_autodetection",!1)&&null===N&&e.isUntitled&&e.lineCount<=1)return N=t.workspace.onDidChangeTextDocument(lt),void n.log_simple_event("creating empty doc subscription");let r=!1;[e,r]=await at(t,t.workspace.getConfiguration("rainbow_csv"),H,e,n.context_id),n.log_doc_event(`after autodetection. filetype changed: ${r}`,e),Ne(e)&&(n.log_simple_event("active doc - enabling features"),Te(e,n),await Ie(e,n)),n.log_simple_event("finishing")}async function ft(e){let t=new we("handle_doc_close");if(t.log_doc_event("closing doc",e),!ne(e))return t.log_simple_event("abort: non rainbow doc"),void(L=null);L={file_path:e.fileName,timestamp:Date.now()},Ne(e)&&(t.log_simple_event("disabling ui elements"),Pe()),t.log_simple_event("finalizing")}async function pt(e){let t=H.logging_enabled;H.logging_enabled=be("enable_debug_logging",!1),H.logging_enabled&&!t&&new we("config change").log_simple_event("logging enabled"),Se()}async function ht(e,o){if(c)return void ce("This command is currently unavailable in web mode.");var s=e.fsPath;if(!s||!r.existsSync(s))return void t.window.showErrorMessage("Invalid file");var a=1024e3,l=r.statSync(s).size;if(l<=a){t.window.showWarningMessage("Rainbow CSV: The file is not big enough, showing the full file instead. Use this preview for files larger than 1MB");let e=await t.workspace.openTextDocument(s);return void await t.window.showTextDocument(e)}let u=n.basename(s);const _=n.join(i.tmpdir(),`.rb_csv_preview.${o}.${u}`);r.open(s,"r",((e,n)=>{if(e)return console.log(e.message),void t.window.showErrorMessage("Unable to preview file");var i=Buffer.alloc(a);let s="head"==o?0:Math.max(l-a,0);r.read(n,i,0,a,s,(function(e,n){if(e)return console.log(e.message),void t.window.showErrorMessage("Unable to preview file");const s=i.toString();let a=null;a="head"==o?s.substr(0,s.lastIndexOf(s.includes("\r\n")?"\r\n":"\n")):s.substr(s.indexOf("\n")+1),r.writeFileSync(_,a),t.workspace.openTextDocument(_).then((e=>t.window.showTextDocument(e)))}))}))}function dt(e,n){let r=t.languages.registerHoverProvider(e,{provideHover:(e,n,r)=>function(e,n,r,i){if(!be("enable_tooltip",!1))return;let[o,s,a]=Ee(e),l=_().get_cursor_position_info(t,e,o,s,a,r);if(!l||i.isCancellationRequested)return null;let u=be("enable_tooltip_column_names",!1),c=ve(e,o,s,a);if(!c)return null;let[f,p]=_().format_cursor_position_info(l,c,u,!0,25),h=new t.MarkdownString;return h.appendText(p),new t.Hover(h)}(e,0,n,r)});n.subscriptions.push(r)}class gt{constructor(){}async provideDocumentRangeSemanticTokens(e,n,r){let[i,o,s]=Ee(e);if(!o||e.languageId!=J)return null;let a=_().parse_document_range(t,e,i,o,s,n);const l=new t.SemanticTokensBuilder(ee);for(let e of a)if(e.hasOwnProperty("comment_range"))l.push(e.comment_range,Z);else for(let t=0;t