diff --git a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js index b3342e233..03a4e20ca 100644 --- a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js +++ b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js @@ -7679,25 +7679,32 @@ function formatUiValue(value, options = {}) { const numeric = typeof value === "number" ? value : Number(value); if (!Number.isFinite(numeric)) return String(value); - const format = String(options.format || "").toLowerCase(); - const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || options.type === "ratio"; + const format = String(options.format || "").trim().toLowerCase(); + const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || !format && !options.style && !options.currency && options.type === "ratio"; + const decimalPattern = format.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/); + const namedPrecision = format.match(/^(?:decimal|percent|usd)_(\d+)$/); + const precision = decimalPattern ? (decimalPattern[1] || "").length : namedPrecision ? Number(namedPrecision[1]) : undefined; + const maximumFractionDigits = options.maximumFractionDigits ?? (precision === undefined ? percent || options.compact ? 1 : 2 : Math.min(precision, 20)); + const minimumFractionDigits = precision === undefined ? undefined : Math.min(decimalPattern ? (decimalPattern[1] || "").replaceAll("#", "").length : precision, maximumFractionDigits); if (percent) { const scaled = options.style === "percent" ? numeric : Math.abs(numeric) <= 1 ? numeric * 100 : numeric; return scaled.toLocaleString(undefined, { - maximumFractionDigits: options.maximumFractionDigits ?? 1, + maximumFractionDigits, + minimumFractionDigits, style: options.style === "percent" ? "percent" : "decimal" }) + (options.style === "percent" ? "" : "%"); } const currency = options.style === "currency" || options.currency || format.includes("$") || format.includes("usd") || format.includes("currency") || format.includes("dollar"); return numeric.toLocaleString(undefined, { currency: currency ? options.currency || "USD" : undefined, - maximumFractionDigits: options.maximumFractionDigits ?? 2, + maximumFractionDigits, + minimumFractionDigits, notation: options.compact ? "compact" : "standard", style: currency ? "currency" : "decimal" }); } function formatUiCompact(value, options = {}) { - return formatUiValue(value, { ...options, compact: true, maximumFractionDigits: options.maximumFractionDigits ?? 1 }); + return formatUiValue(value, { ...options, compact: true }); } function normalizeFilterValue(value) { return String(value ?? ""); diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js index b3342e233..03a4e20ca 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js @@ -7679,25 +7679,32 @@ function formatUiValue(value, options = {}) { const numeric = typeof value === "number" ? value : Number(value); if (!Number.isFinite(numeric)) return String(value); - const format = String(options.format || "").toLowerCase(); - const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || options.type === "ratio"; + const format = String(options.format || "").trim().toLowerCase(); + const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || !format && !options.style && !options.currency && options.type === "ratio"; + const decimalPattern = format.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/); + const namedPrecision = format.match(/^(?:decimal|percent|usd)_(\d+)$/); + const precision = decimalPattern ? (decimalPattern[1] || "").length : namedPrecision ? Number(namedPrecision[1]) : undefined; + const maximumFractionDigits = options.maximumFractionDigits ?? (precision === undefined ? percent || options.compact ? 1 : 2 : Math.min(precision, 20)); + const minimumFractionDigits = precision === undefined ? undefined : Math.min(decimalPattern ? (decimalPattern[1] || "").replaceAll("#", "").length : precision, maximumFractionDigits); if (percent) { const scaled = options.style === "percent" ? numeric : Math.abs(numeric) <= 1 ? numeric * 100 : numeric; return scaled.toLocaleString(undefined, { - maximumFractionDigits: options.maximumFractionDigits ?? 1, + maximumFractionDigits, + minimumFractionDigits, style: options.style === "percent" ? "percent" : "decimal" }) + (options.style === "percent" ? "" : "%"); } const currency = options.style === "currency" || options.currency || format.includes("$") || format.includes("usd") || format.includes("currency") || format.includes("dollar"); return numeric.toLocaleString(undefined, { currency: currency ? options.currency || "USD" : undefined, - maximumFractionDigits: options.maximumFractionDigits ?? 2, + maximumFractionDigits, + minimumFractionDigits, notation: options.compact ? "compact" : "standard", style: currency ? "currency" : "decimal" }); } function formatUiCompact(value, options = {}) { - return formatUiValue(value, { ...options, compact: true, maximumFractionDigits: options.maximumFractionDigits ?? 1 }); + return formatUiValue(value, { ...options, compact: true }); } function normalizeFilterValue(value) { return String(value ?? ""); diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js index ff2975390..d3decea16 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js @@ -81,25 +81,32 @@ function formatUiValue(value, options = {}) { const numeric = typeof value === "number" ? value : Number(value); if (!Number.isFinite(numeric)) return String(value); - const format = String(options.format || "").toLowerCase(); - const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || options.type === "ratio"; + const format = String(options.format || "").trim().toLowerCase(); + const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || !format && !options.style && !options.currency && options.type === "ratio"; + const decimalPattern = format.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/); + const namedPrecision = format.match(/^(?:decimal|percent|usd)_(\d+)$/); + const precision = decimalPattern ? (decimalPattern[1] || "").length : namedPrecision ? Number(namedPrecision[1]) : undefined; + const maximumFractionDigits = options.maximumFractionDigits ?? (precision === undefined ? percent || options.compact ? 1 : 2 : Math.min(precision, 20)); + const minimumFractionDigits = precision === undefined ? undefined : Math.min(decimalPattern ? (decimalPattern[1] || "").replaceAll("#", "").length : precision, maximumFractionDigits); if (percent) { const scaled = options.style === "percent" ? numeric : Math.abs(numeric) <= 1 ? numeric * 100 : numeric; return scaled.toLocaleString(undefined, { - maximumFractionDigits: options.maximumFractionDigits ?? 1, + maximumFractionDigits, + minimumFractionDigits, style: options.style === "percent" ? "percent" : "decimal" }) + (options.style === "percent" ? "" : "%"); } const currency = options.style === "currency" || options.currency || format.includes("$") || format.includes("usd") || format.includes("currency") || format.includes("dollar"); return numeric.toLocaleString(undefined, { currency: currency ? options.currency || "USD" : undefined, - maximumFractionDigits: options.maximumFractionDigits ?? 2, + maximumFractionDigits, + minimumFractionDigits, notation: options.compact ? "compact" : "standard", style: currency ? "currency" : "decimal" }); } function formatUiCompact(value, options = {}) { - return formatUiValue(value, { ...options, compact: true, maximumFractionDigits: options.maximumFractionDigits ?? 1 }); + return formatUiValue(value, { ...options, compact: true }); } function normalizeFilterValue(value) { return String(value ?? ""); diff --git a/sidemantic-rs/src/bin/sidemantic-server.rs b/sidemantic-rs/src/bin/sidemantic-server.rs index a143c8236..88c2803cb 100644 --- a/sidemantic-rs/src/bin/sidemantic-server.rs +++ b/sidemantic-rs/src/bin/sidemantic-server.rs @@ -1363,6 +1363,9 @@ fn metric_json(metric: &Metric) -> JsonValue { if let Some(format) = &metric.format { entry.insert("format".to_string(), json!(format)); } + if let Some(value_format_name) = &metric.value_format_name { + entry.insert("value_format_name".to_string(), json!(value_format_name)); + } if let Some(description) = &metric.description { entry.insert("description".to_string(), json!(description)); } @@ -1553,3 +1556,22 @@ mod security_tests { } } } + +#[cfg(test)] +mod metadata_tests { + use super::*; + + #[test] + fn metric_metadata_preserves_explicit_and_named_formats() { + let mut metric = Metric::new("aov"); + assert!(metric_json(&metric).get("value_format_name").is_none()); + metric.value_format_name = Some("usd".into()); + let named = metric_json(&metric); + assert_eq!(named["value_format_name"], "usd"); + assert!(named.get("format").is_none()); + metric.format = Some("#,##0.00".into()); + let explicit = metric_json(&metric); + assert_eq!(explicit["format"], "#,##0.00"); + assert_eq!(explicit["value_format_name"], "usd"); + } +} diff --git a/sidemantic-rs/ui/assets/index-Bh-YPoVm.js b/sidemantic-rs/ui/assets/index-C0Mo4KDV.js similarity index 73% rename from sidemantic-rs/ui/assets/index-Bh-YPoVm.js rename to sidemantic-rs/ui/assets/index-C0Mo4KDV.js index 50774e24c..284d946fb 100644 --- a/sidemantic-rs/ui/assets/index-Bh-YPoVm.js +++ b/sidemantic-rs/ui/assets/index-C0Mo4KDV.js @@ -37,7 +37,7 @@ var ib=Object.defineProperty;var ob=(n,e,t)=>e in n?ib(n,e,{enumerable:!0,config `+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{te=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?O(r):""}function re(r){switch(r.tag){case 5:return O(r.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return r=he(r.type,!1),r;case 11:return r=he(r.type.render,!1),r;case 1:return r=he(r.type,!0),r;default:return""}}function pe(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case D:return"Portal";case W:return"Profiler";case G:return"StrictMode";case X:return"Suspense";case oe:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case $:return(r.displayName||"Context")+".Consumer";case Y:return(r._context.displayName||"Context")+".Provider";case ee:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ae:return s=r.displayName||null,s!==null?s:pe(r.type)||"Memo";case se:s=r._payload,r=r._init;try{return pe(r(s))}catch{}}return null}function Ce(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(s);case 8:return s===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Be(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Be(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,p=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,p.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function Es(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Be(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function Et(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function sr(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function us(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function ce(r,s){s=s.checked,s!=null&&R(r,"checked",s,!1)}function Te(r,s){ce(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?Ct(r,s.type,o):s.hasOwnProperty("defaultValue")&&Ct(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function Ct(r,s,o){(s!=="number"||Et(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function ir(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ds.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Cr(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Fr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},na=["Webkit","ms","Moz","O"];Object.keys(Fr).forEach(function(r){na.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Fr[s]=Fr[r]})});function ye(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Fr.hasOwnProperty(r)&&Fr[r]?(""+s).trim():s+"px"}function vt(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=ye(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var Us=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function rn(r,s){if(s){if(Us[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function Ps(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yi=null;function fs(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var vc=null,$s=null,zs=null;function wf(r){if(r=yo(r)){if(typeof vc!="function")throw Error(t(280));var s=r.stateNode;s&&(s=ja(s),vc(r.stateNode,r.type,s))}}function Sf(r){$s?zs?zs.push(r):zs=[r]:$s=r}function _f(){if($s){var r=$s,s=zs;if(zs=$s=null,wf(r),s)for(r=0;r>>=0,r===0?32:31-(w0(r)/S0|0)|0}var aa=64,la=4194304;function qi(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function ca(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,p=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=qi(S):(p&=y,p!==0&&(l=qi(p)))}else y=o&~d,y!==0?l=qi(y):p!==0&&(l=qi(p));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,p=s&-s,d>=p||d===16&&(p&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function Zi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-wn(s),r[s]=o}function k0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=oo),qf=" ",Zf=!1;function Xf(r,s){switch(r){case"keyup":return ex.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eh(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Hs=!1;function nx(r,s){switch(r){case"compositionend":return eh(s);case"keypress":return s.which!==32?null:(Zf=!0,qf);case"textInput":return r=s.data,r===qf&&Zf?null:r;default:return null}}function rx(r,s){if(Hs)return r==="compositionend"||!Ec&&Xf(r,s)?(r=Hf(),pa=Cc=Er=null,Hs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=ah(o)}}function ch(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?ch(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function uh(){for(var r=window,s=Et();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=Et(r.document)}return s}function Uc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function fx(r){var s=uh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&ch(o.ownerDocument.documentElement,o)){if(l!==null&&Uc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,p=Math.min(l.start,d);l=l.end===void 0?p:Math.min(l.end,d),!r.extend&&p>l&&(d=l,l=p,p=d),d=lh(o,p);var y=lh(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),p>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Gs=null,Pc=null,uo=null,$c=!1;function dh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;$c||Gs==null||Gs!==Et(l)||(l=Gs,"selectionStart"in l&&Uc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),uo&&co(uo,l)||(uo=l,l=Sa(Pc,"onSelect"),0qs||(r.current=Xc[qs],Xc[qs]=null,qs--)}function qe(r,s){qs++,Xc[qs]=r.current,r.current=s}var Pr={},jt=Ur(Pr),Rt=Ur(!1),ms=Pr;function Zs(r,s){var o=r.type.contextTypes;if(!o)return Pr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},p;for(p in o)d[p]=s[p];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function ka(){et(Rt),et(jt)}function kh(r,s,o){if(jt.current!==Pr)throw Error(t(168));qe(jt,s),qe(Rt,o)}function Ih(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ce(r)||"Unknown",d));return H({},o,l)}function Ia(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Pr,ms=jt.current,qe(jt,r),qe(Rt,Rt.current),!0}function Mh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Ih(r,s,ms),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(jt),qe(jt,r)):et(Rt),qe(Rt,o)}var ar=null,Ma=!1,eu=!1;function Dh(r){ar===null?ar=[r]:ar.push(r)}function Nx(r){Ma=!0,Dh(r)}function $r(){if(!eu&&ar!==null){eu=!0;var r=0,s=Ge;try{var o=ar;for(Ge=1;r>=y,d-=y,lr=1<<32-wn(s)+d|o<Me?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,U[Me],Z);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze,ve=wt}if(Me===U.length)return o(E,ve),rt&&gs(E,Me),fe;if(ve===null){for(;MeMe?(wt=ve,ve=null):wt=ve.sibling;var Jr=K(E,ve,ze.value,Z);if(Jr===null){ve===null&&(ve=wt);break}r&&ve&&Jr.alternate===null&&s(E,ve),k=p(Jr,k,Me),ge===null?fe=Jr:ge.sibling=Jr,ge=Jr,ve=wt}if(ze.done)return o(E,ve),rt&&gs(E,Me),fe;if(ve===null){for(;!ze.done;Me++,ze=U.next())ze=q(E,ze.value,Z),ze!==null&&(k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze);return rt&&gs(E,Me),fe}for(ve=l(E,ve);!ze.done;Me++,ze=U.next())ze=ie(ve,E,Me,ze.value,Z),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?Me:ze.key),k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(sb){return s(E,sb)}),rt&&gs(E,Me),fe}function ut(E,k,U,Z){if(typeof U=="object"&&U!==null&&U.type===L&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case B:e:{for(var fe=U.key,ge=k;ge!==null;){if(ge.key===fe){if(fe=U.type,fe===L){if(ge.tag===7){o(E,ge.sibling),k=d(ge,U.props.children),k.return=E,E=k;break e}}else if(ge.elementType===fe||typeof fe=="object"&&fe!==null&&fe.$$typeof===se&&Bh(fe)===ge.type){o(E,ge.sibling),k=d(ge,U.props),k.ref=go(E,ge,U),k.return=E,E=k;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}U.type===L?(k=js(U.props.children,E.mode,Z,U.key),k.return=E,E=k):(Z=nl(U.type,U.key,U.props,null,E.mode,Z),Z.ref=go(E,k,U),Z.return=E,E=Z)}return y(E);case D:e:{for(ge=U.key;k!==null;){if(k.key===ge)if(k.tag===4&&k.stateNode.containerInfo===U.containerInfo&&k.stateNode.implementation===U.implementation){o(E,k.sibling),k=d(k,U.children||[]),k.return=E,E=k;break e}else{o(E,k);break}else s(E,k);k=k.sibling}k=qu(U,E.mode,Z),k.return=E,E=k}return y(E);case se:return ge=U._init,ut(E,k,ge(U._payload),Z)}if(Un(U))return ue(E,k,U,Z);if(Q(U))return de(E,k,U,Z);Oa(E,U)}return typeof U=="string"&&U!==""||typeof U=="number"?(U=""+U,k!==null&&k.tag===6?(o(E,k.sibling),k=d(k,U),k.return=E,E=k):(o(E,k),k=Ju(U,E.mode,Z),k.return=E,E=k),y(E)):o(E,k)}return ut}var ni=Eh(!0),Rh=Eh(!1),Ta=Ur(null),Aa=null,ri=null,ou=null;function au(){ou=ri=Aa=null}function lu(r){var s=Ta.current;et(Ta),r._currentValue=s}function cu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function si(r,s){Aa=r,ou=ri=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function an(r){var s=r._currentValue;if(ou!==r)if(r={context:r,memoizedValue:s,next:null},ri===null){if(Aa===null)throw Error(t(308));ri=r,Aa.dependencies={lanes:0,firstContext:r}}else ri=ri.next=r;return s}var vs=null;function uu(r){vs===null?vs=[r]:vs.push(r)}function Lh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,uu(s)):(o.next=d.next,d.next=o),s.interleaved=o,ur(r,l)}function ur(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var zr=!1;function du(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Uh(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function dr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Vr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,ur(r,o)}return d=l.interleaved,d===null?(s.next=s,uu(l)):(s.next=d.next,d.next=s),l.interleaved=s,ur(r,o)}function Ba(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,jc(r,o)}}function Ph(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,p=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};p===null?d=p=y:p=p.next=y,o=o.next}while(o!==null);p===null?d=p=s:p=p.next=s}else d=p=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:p,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ea(r,s,o,l){var d=r.updateQueue;zr=!1;var p=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,z=j.next;j.next=null,y===null?p=z:y.next=z,y=j;var J=r.alternate;J!==null&&(J=J.updateQueue,S=J.lastBaseUpdate,S!==y&&(S===null?J.firstBaseUpdate=z:S.next=z,J.lastBaseUpdate=j))}if(p!==null){var q=d.baseState;y=0,J=z=j=null,S=p;do{var K=S.lane,ie=S.eventTime;if((l&K)===K){J!==null&&(J=J.next={eventTime:ie,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,ie=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){q=ue.call(ie,q,K);break e}q=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(ie,q,K):ue,K==null)break e;q=H({},q,K);break e;case 2:zr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else ie={eventTime:ie,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},J===null?(z=J=ie,j=q):J=J.next=ie,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(J===null&&(j=q),d.baseState=j,d.firstBaseUpdate=z,d.lastBaseUpdate=J,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else p===null&&(d.shared.lanes=0);ws|=y,r.lanes=y,r.memoizedState=q}}function $h(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=yu.transition;yu.transition={};try{r(!1),s()}finally{Ge=o,yu.transition=l}}function op(){return ln().memoizedState}function Mx(r,s,o){var l=Yr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},ap(r))lp(s,o);else if(o=Lh(r,s,o,l),o!==null){var d=Ot();In(o,r,l,d),cp(o,s,l)}}function Dx(r,s,o){var l=Yr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(ap(r))lp(s,d);else{var p=r.alternate;if(r.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var y=s.lastRenderedState,S=p(y,o);if(d.hasEagerState=!0,d.eagerState=S,Sn(S,y)){var j=s.interleaved;j===null?(d.next=d,uu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Lh(r,s,d,l),o!==null&&(d=Ot(),In(o,r,l,d),cp(o,s,l))}}function ap(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function lp(r,s){wo=Ua=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function cp(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,jc(r,o)}}var za={readContext:an,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Cx={readContext:an,useCallback:function(r,s){return Vn().memoizedState=[r,s===void 0?null:s],r},useContext:an,useEffect:Zh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Pa(4194308,4,tp.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Pa(4194308,4,r,s)},useInsertionEffect:function(r,s){return Pa(4,2,r,s)},useMemo:function(r,s){var o=Vn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Vn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Mx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Vn();return r={current:r},s.memoizedState=r},useState:Jh,useDebugValue:_u,useDeferredValue:function(r){return Vn().memoizedState=r},useTransition:function(){var r=Jh(!1),s=r[0];return r=Ix.bind(null,r[1]),Vn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Vn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(bs&30)!==0||Hh(l,s,o)}d.memoizedState=o;var p={value:o,getSnapshot:s};return d.queue=p,Zh(Yh.bind(null,l,p,r),[r]),l.flags|=2048,No(9,Gh.bind(null,l,p,o,s),void 0,null),o},useId:function(){var r=Vn(),s=bt.identifierPrefix;if(rt){var o=cr,l=lr;o=(l&~(1<<32-wn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=So++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[$n]=s,r[mo]=l,Dp(r,s,!1,!1),s.stateNode=r;e:{switch(y=Ps(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;dci&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304)}else{if(!l)if(r=Ra(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),jo(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!rt)return It(s),null}else 2*ct()-p.renderingStartTime>ci&&o!==1073741824&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304);p.isBackwards?(y.sibling=s.child,s.child=y):(o=p.last,o!==null?o.sibling=y:s.child=y,p.last=y)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(It(s),null);case 22:case 23:return Yu(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(It(s),s.subtreeFlags&6&&(s.flags|=8192)):It(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Lx(r,s){switch(nu(s),s.tag){case 1:return Lt(s.type)&&ka(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ii(),et(Rt),et(jt),mu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return hu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));ti()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ii(),null;case 10:return lu(s.type._context),null;case 22:case 23:return Yu(),null;case 24:return null;default:return null}}var Ga=!1,Mt=!1,Ux=typeof WeakSet=="function"?WeakSet:Set,le=null;function ai(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Bu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Op=!1;function Px(r,s){if(Yc=fa,r=uh(),Uc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{o.nodeType,p.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,z=0,J=0,q=r,K=null;t:for(;;){for(var ie;q!==o||d!==0&&q.nodeType!==3||(S=y+d),q!==p||l!==0&&q.nodeType!==3||(j=y+l),q.nodeType===3&&(y+=q.nodeValue.length),(ie=q.firstChild)!==null;)K=q,q=ie;for(;;){if(q===r)break t;if(K===o&&++z===d&&(S=y),K===p&&++J===l&&(j=y),(ie=q.nextSibling)!==null)break;q=K,K=q.parentNode}q=ie}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(Qc={focusedElem:r,selectionRange:o},fa=!1,le=s;le!==null;)if(s=le,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,le=r;else for(;le!==null;){s=le;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,k=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:Nn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var U=s.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Z){lt(s,s.return,Z)}if(r=s.sibling,r!==null){r.return=s.return,le=r;break}le=s.return}return ue=Op,Op=!1,ue}function ko(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var p=d.destroy;d.destroy=void 0,p!==void 0&&Bu(s,o,p)}d=d.next}while(d!==l)}}function Ya(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Eu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Tp(r){var s=r.alternate;s!==null&&(r.alternate=null,Tp(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[$n],delete s[mo],delete s[Zc],delete s[Sx],delete s[_x])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ap(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ap(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Ru(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Na));else if(l!==4&&(r=r.child,r!==null))for(Ru(r,s,o),r=r.sibling;r!==null;)Ru(r,s,o),r=r.sibling}function Lu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for(Lu(r,s,o),r=r.sibling;r!==null;)Lu(r,s,o),r=r.sibling}var _t=null,jn=!1;function Wr(r,s,o){for(o=o.child;o!==null;)Ep(r,s,o),o=o.sibling}function Ep(r,s,o){if(Pn&&typeof Pn.onCommitFiberUnmount=="function")try{Pn.onCommitFiberUnmount(oa,o)}catch{}switch(o.tag){case 5:Mt||ai(o,s);case 6:var l=_t,d=jn;_t=null,Wr(r,s,o),_t=l,jn=d,_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):_t.removeChild(o.stateNode));break;case 18:_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?qc(r.parentNode,o):r.nodeType===1&&qc(r,o),ro(r)):qc(_t,o.stateNode));break;case 4:l=_t,d=jn,_t=o.stateNode.containerInfo,jn=!0,Wr(r,s,o),_t=l,jn=d;break;case 0:case 11:case 14:case 15:if(!Mt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var p=d,y=p.destroy;p=p.tag,y!==void 0&&((p&2)!==0||(p&4)!==0)&&Bu(o,s,y),d=d.next}while(d!==l)}Wr(r,s,o);break;case 1:if(!Mt&&(ai(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Wr(r,s,o);break;case 21:Wr(r,s,o);break;case 22:o.mode&1?(Mt=(l=Mt)||o.memoizedState!==null,Wr(r,s,o),Mt=l):Wr(r,s,o);break;default:Wr(r,s,o)}}function Rp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Ux),s.forEach(function(l){var d=Kx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function kn(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~p}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zx(l/1960))-l,10r?16:r,Gr===null)var l=!1;else{if(r=Gr,Gr=null,Za=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,le=r.current;le!==null;){var p=le,y=p.child;if((le.flags&16)!==0){var S=p.deletions;if(S!==null){for(var j=0;jct()-$u?_s(r,0):Pu|=o),$t(r,s)}function Jp(r,s){s===0&&((r.mode&1)===0?s=1:(s=la,la<<=1,(la&130023424)===0&&(la=4194304)));var o=Ot();r=ur(r,s),r!==null&&(Zi(r,s,o),$t(r,o))}function Qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),Jp(r,o)}function Kx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),Jp(r,o)}var qp;qp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ex(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Ch(s,Ca,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Ha(r,s),r=s.pendingProps;var d=Zs(s,jt.current);si(s,o),d=vu(null,s,l,r,d,o);var p=xu();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(p=!0,Ia(s)):p=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,du(s),d.updater=Va,s.stateNode=d,d._reactInternals=s,ju(s,l,r,o),s=Du(null,s,l,!0,p,o)):(s.tag=0,rt&&p&&tu(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Ha(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=qx(l),r=Nn(l,r),d){case 0:s=Mu(null,s,l,r,o);break e;case 1:s=_p(null,s,l,r,o);break e;case 11:s=vp(null,s,l,r,o);break e;case 14:s=xp(null,s,l,Nn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Mu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),_p(r,s,l,d,o);case 3:e:{if(Np(s),r===null)throw Error(t(387));l=s.pendingProps,p=s.memoizedState,d=p.element,Uh(r,s),Ea(s,l,null,o);var y=s.memoizedState;if(l=y.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){d=oi(Error(t(423)),s),s=jp(r,s,l,o,d);break e}else if(l!==d){d=oi(Error(t(424)),s),s=jp(r,s,l,o,d);break e}else for(qt=Lr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,_n=null,o=Rh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ti(),l===d){s=fr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return zh(s),r===null&&su(s),l=s.type,d=s.pendingProps,p=r!==null?r.memoizedProps:null,y=d.children,Kc(l,d)?y=null:p!==null&&Kc(l,p)&&(s.flags|=32),Sp(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&su(s),null;case 13:return kp(r,s,o);case 4:return fu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=ni(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),vp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,p=s.memoizedProps,y=d.value,qe(Ta,l._currentValue),l._currentValue=y,p!==null)if(Sn(p.value,y)){if(p.children===d.children&&!Rt.current){s=fr(r,s,o);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){y=p.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(p.tag===1){j=dr(-1,o&-o),j.tag=2;var z=p.updateQueue;if(z!==null){z=z.shared;var J=z.pending;J===null?j.next=j:(j.next=J.next,J.next=j),z.pending=j}}p.lanes|=o,j=p.alternate,j!==null&&(j.lanes|=o),cu(p.return,o,s),S.lanes|=o;break}j=j.next}}else if(p.tag===10)y=p.type===s.type?null:p.child;else if(p.tag===18){if(y=p.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),cu(y,o,s),y=p.sibling}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===s){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,si(s,o),d=an(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=Nn(l,s.pendingProps),d=Nn(l.type,d),xp(r,s,l,d,o);case 15:return bp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Ha(r,s),s.tag=1,Lt(l)?(r=!0,Ia(s)):r=!1,si(s,o),dp(s,l,d),ju(s,l,d,o),Du(null,s,l,!0,r,o);case 19:return Mp(r,s,o);case 22:return wp(r,s,o)}throw Error(t(156,s.tag))};function Zp(r,s){return Ff(r,s)}function Jx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(r,s,o,l){return new Jx(r,s,o,l)}function Ku(r){return r=r.prototype,!(!r||!r.isReactComponent)}function qx(r){if(typeof r=="function")return Ku(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ee)return 11;if(r===ae)return 14}return 2}function Kr(r,s){var o=r.alternate;return o===null?(o=un(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function nl(r,s,o,l,d,p){var y=2;if(l=r,typeof r=="function")Ku(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return js(o.children,d,p,s);case G:y=8,d|=8;break;case W:return r=un(12,o,s,d|2),r.elementType=W,r.lanes=p,r;case X:return r=un(13,o,s,d),r.elementType=X,r.lanes=p,r;case oe:return r=un(19,o,s,d),r.elementType=oe,r.lanes=p,r;case ne:return rl(o,d,p,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Y:y=10;break e;case $:y=9;break e;case ee:y=11;break e;case ae:y=14;break e;case se:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=un(y,o,s,d),s.elementType=r,s.type=l,s.lanes=p,s}function js(r,s,o,l){return r=un(7,r,l,s),r.lanes=o,r}function rl(r,s,o,l){return r=un(22,r,l,s),r.elementType=ne,r.lanes=o,r.stateNode={isHidden:!1},r}function Ju(r,s,o){return r=un(6,r,null,s),r.lanes=o,r}function qu(r,s,o){return s=un(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function Zx(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Nc(0),this.expirationTimes=Nc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nc(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Zu(r,s,o,l,d,p,y,S,j){return r=new Zx(r,s,o,S,j),s===1?(s=1,p===!0&&(s|=8)):s=0,p=un(3,null,null,s),r.current=p,p.stateNode=r,p.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},du(p),r}function Xx(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),sd.exports=fb(),sd.exports}var fm;function pb(){if(fm)return ul;fm=1;var n=hb();return ul.createRoot=n.createRoot,ul.hydrateRoot=n.hydrateRoot,ul}var mb=pb();function Sr(n){return n.split(".").at(-1)||n}function Fn(n,e){const t=Sr(n);if(e.filter(a=>Sr(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const er="\0__null__";function yb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wy(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").toLowerCase();if(e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||e.type==="ratio")return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:e.maximumFractionDigits??1,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const c=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:e.maximumFractionDigits??2,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function gb(n,e={}){return wy(n,{...e,compact:!0,maximumFractionDigits:e.maximumFractionDigits??1})}function vb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function rs(n){return n===er||n===""?"—":n}function Le(n){return yb(n)}function pt(n,e={}){return wy(n,e)}function Gt(n,e={}){return gb(n,e)}function Sy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function xb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function bb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Sy(i)}}function wb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Sy(t)}}function _y(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Qn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Sb(n){if(n.mode==="contains")return`contains ${Qn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${rs(e[0])}`:e.length<=2?`${t} ${e.map(rs).join(", ")}`:`${t} ${e.length} values`}const ad=n=>n.public!==!1,Ny=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function jy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Ny.test(t.name))}function _b(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(h=>h.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const h of a){const[m]=h.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const h of e)h.metrics.some(m=>m.name===c)&&t.add(h.name);return t}function ky(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of _b(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Nb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,type:h.type||"categorical",granularity:h.granularity,supportedGranularities:h.supported_granularities,format:h.format})),c=(i.metrics??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,agg:h.agg,type:h.type,format:h.format})),f=jy(a,i.default_time_dimension);return{name:i.name,label:Le(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ad).map(i=>({ref:i.name,name:i.name,ownerModel:ky(i,e),baseMetric:i.base_metric,label:i.label||Le(i.name),description:i.description,type:i.type,format:i.format}));return{models:e,graphMetrics:t,dialect:n.dialect}}function jb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m),type:Ny.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m)})),h=jy(c);return{name:a.name,label:Le(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:h,defaultGrain:(h==null?void 0:h.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:ky(a,t),baseMetric:a.base_metric,label:Le(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function kb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function Di(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function Oe(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function h(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(h,m)}g((i=i.apply(n,e||[])).next())})}function hm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Zn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),h("next"),h("throw"),h("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function h(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,V){c.push([w,C,T,V])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function wl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function _i(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof hm=="function"?hm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(h,m){f=n[c](f),a(h,m,f.done,f.value)})}}function a(c,f,h,m){Promise.resolve(m).then(function(g){c({value:g,done:h})},f)}}const Ib=new TextDecoder("utf-8"),Id=n=>Ib.decode(n),Mb=new TextEncoder,Vd=n=>Mb.encode(n),Db=n=>typeof n=="number",Cb=n=>typeof n=="boolean",Tt=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Wo=n=>En(n)&&Tt(n.then),dc=n=>En(n)&&Tt(n[Symbol.iterator]),Wd=n=>En(n)&&Tt(n[Symbol.asyncIterator]),Md=n=>En(n)&&En(n.schema),Iy=n=>En(n)&&"done"in n&&"value"in n,My=n=>En(n)&&Tt(n.stat)&&Db(n.fd),Dy=n=>En(n)&&Hd(n.body),Cy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Hd=n=>En(n)&&Tt(n.cancel)&&Tt(n.getReader)&&!Cy(n),Fy=n=>En(n)&&Tt(n.read)&&Tt(n.pipe)&&Cb(n.readable)&&!Cy(n),Fb=n=>En(n)&&Tt(n.clear)&&Tt(n.bytes)&&Tt(n.position)&&Tt(n.setPosition)&&Tt(n.capacity)&&Tt(n.getBufferIdentifier)&&Tt(n.createLong),Gd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ob(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,h,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,h=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),mm=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Dd=n=>(n.next(),n);function*Tb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?t(e):dc(e)?e:t(e);return yield*Dd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Ab=n=>Tb(Uint8Array,n);function Oy(n,e){return Zn(this,arguments,function*(){if(Wo(e))return yield Ae(yield Ae(yield*wl(_i(Oy(n,yield Ae(e))))));const i=function(f){return Zn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(Dd((function*(h){let m=null;do m=h.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?i(e):dc(e)?a(e):Wd(e)?e:i(e);return yield Ae(yield*wl(_i(Dd((function(f){return Zn(this,arguments,function*(){let h=null;do h=yield Ae(f.next(yield yield Ae(Ke(n,h))));while(!h.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Bb=n=>Oy(Uint8Array,n);function Eb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Rb(n){let e,t=!1,i=[],a,c,f,h=0;function m(){return c==="peek"?tr(i,f)[0]:([a,i,h]=tr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Ab(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-h)?g.next():g.next(f-h),!e&&a.byteLength>0&&(i.push(a),h+=a.byteLength),e||f<=h)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h0&&(a.push(Pe(c)),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Oe(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Oe(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const ld=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function $b(n){return Zn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,h,m=0,g=[],v;function x(){return f==="peek"?tr(g,h)[0]:([v,g,m]=tr(g,h),v)}if({cmd:f,size:h}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=ld(n,"end"),t[1]=ld(n,"error");do{if(t[2]=ld(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(h-m)?(v=Pe(n.read(h-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||h<=m)do({cmd:f,size:h}=yield yield Ae(x()));while(h{for(const[V,P]of w)n.off(V,P);try{const V=n.destroy;V&&V.call(n,_),_=void 0}catch(V){_=V||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Dt;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var xn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(xn||(xn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var nr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(nr||(nr={}));const cd=2,Kn=4,br=4,He=4,es=new Int32Array(2),ym=new Float32Array(es.buffer),gm=new Float64Array(es.buffer),fl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Cd||(Cd={}));let Ci=class Ty{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ty(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ym[0]=t,this.writeInt32(e,es[0])}writeFloat64(e,t){gm[0]=t,this.writeInt32(e,es[fl?0:1]),this.writeInt32(e+4,es[fl?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*cd;this.addInt16(c);let f=0;const h=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Kn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let Nm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let hn=class Il{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new wr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Il).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Gn=class mr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Fi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new hn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Fi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return mr.startSchema(e),mr.addEndianness(e,t),mr.addFields(e,i),mr.addCustomMetadata(e,a),mr.addFeatures(e,c),mr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var M;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(M||(M={}));var gr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(gr||(gr={}));const zb=void 0;function Ho(n){if(n===null)return"null";if(n===zb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Ho(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Ly(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Vb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Vb]=!0;Ln.prototype.toJSON=function(){return`"${Yo(this)}"`};Ln.prototype.valueOf=function(n){return Uy(this,n)};Ln.prototype.toString=function(){return Yo(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return Uy(this);case"string":return Yo(this);case"default":return Gb(this)}return Yo(this)};function Ni(...n){return Ln.apply(this,n)}function ji(...n){return Ln.apply(this,n)}function Go(...n){return Ln.apply(this,n)}Object.setPrototypeOf(Ni.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ji.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Go.prototype,Object.create(Uint32Array.prototype));Object.assign(Ni.prototype,Ln.prototype,{constructor:Ni,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ji.prototype,Ln.prototype,{constructor:ji,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Go.prototype,Ln.prototype,{constructor:Go,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Wb=BigInt(4294967296)*BigInt(4294967296),Hb=Wb-BigInt(1);function Uy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),h=c&&f.at(-1)&BigInt(1)<=0)return ud(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ss extends me{constructor(){super(M.Null)}toString(){return"Null"}}$y=Symbol.toStringTag;ss[$y]=(n=>n[Symbol.toStringTag]="Null")(ss.prototype);class Cs extends me{constructor(e,t){super(M.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}zy=Symbol.toStringTag;Cs[zy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Cs.prototype);class Qo extends Cs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});class Al extends me{constructor(e){super(M.Float),this.precision=e}get ArrayType(){switch(this.precision){case Dt.HALF:return Uint16Array;case Dt.SINGLE:return Float32Array;case Dt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Vy=Symbol.toStringTag;Al[Vy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Al.prototype);class Bl extends me{constructor(){super(M.Binary)}toString(){return"Binary"}}Wy=Symbol.toStringTag;Bl[Wy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Bl.prototype);class El extends me{constructor(){super(M.LargeBinary)}toString(){return"LargeBinary"}}Hy=Symbol.toStringTag;El[Hy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(El.prototype);class Rl extends me{constructor(){super(M.Utf8)}toString(){return"Utf8"}}Gy=Symbol.toStringTag;Rl[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Rl.prototype);class Ll extends me{constructor(){super(M.LargeUtf8)}toString(){return"LargeUtf8"}}Yy=Symbol.toStringTag;Ll[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(Ll.prototype);class Ul extends me{constructor(){super(M.Bool)}toString(){return"Bool"}}Qy=Symbol.toStringTag;Ul[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Ul.prototype);class Pl extends me{constructor(e,t,i=128){super(M.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Ky=Symbol.toStringTag;Pl[Ky]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Pl.prototype);class $l extends me{constructor(e){super(M.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${xn[this.unit]}>`}get ArrayType(){return this.unit===xn.DAY?Int32Array:BigInt64Array}}Jy=Symbol.toStringTag;$l[Jy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))($l.prototype);class zl extends me{constructor(e,t){super(M.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}qy=Symbol.toStringTag;zl[qy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(zl.prototype);class Vl extends me{constructor(e,t){super(M.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Zy=Symbol.toStringTag;Vl[Zy]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Vl.prototype);class Wl extends me{constructor(e){super(M.Interval),this.unit=e}toString(){return`Interval<${nr[this.unit]}>`}}Xy=Symbol.toStringTag;Wl[Xy]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Wl.prototype);class Hl extends me{constructor(e){super(M.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}eg=Symbol.toStringTag;Hl[eg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Hl.prototype);class Gl extends me{constructor(e){super(M.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}tg=Symbol.toStringTag;Gl[tg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Gl.prototype);class At extends me{constructor(e){super(M.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ng=Symbol.toStringTag;At[ng]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(At.prototype);class Yl extends me{constructor(e,t,i){super(M.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}rg=Symbol.toStringTag;Yl[rg]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(Yl.prototype);class Ql extends me{constructor(e){super(M.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}sg=Symbol.toStringTag;Ql[sg]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Ql.prototype);class Kl extends me{constructor(e,t){super(M.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ig=Symbol.toStringTag;Kl[ig]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Kl.prototype);class Jl extends me{constructor(e,t=!1){var i,a,c;if(super(M.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const h=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];h&&(h.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}og=Symbol.toStringTag;Jl[og]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(Jl.prototype);const Yb=(n=>()=>++n)(-1);class Oi extends me{constructor(e,t,i,a){super(M.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Yb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ag=Symbol.toStringTag;Oi[ag]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Oi.prototype);function vr(n){const e=n;switch(n.typeId){case M.Decimal:return n.bitWidth/32;case M.Interval:return 1+e.unit;case M.FixedSizeList:return e.listSize;case M.FixedSizeBinary:return e.byteWidth;default:return 1}}class Ue{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return xi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Qb(n,e,t=!0){return typeof e=="number"?xi(n,e,t):typeof e=="string"&&e in M?xi(n,M[e],t):e&&e instanceof me?xi(n,jm(e),t):e!=null&&e.type&&e.type instanceof me?xi(n,jm(e.type),t):xi(n,M.NONE,t)}function xi(n,e,t=!0){let i=null;switch(e){case M.Null:i=n.visitNull;break;case M.Bool:i=n.visitBool;break;case M.Int:i=n.visitInt;break;case M.Int8:i=n.visitInt8||n.visitInt;break;case M.Int16:i=n.visitInt16||n.visitInt;break;case M.Int32:i=n.visitInt32||n.visitInt;break;case M.Int64:i=n.visitInt64||n.visitInt;break;case M.Uint8:i=n.visitUint8||n.visitInt;break;case M.Uint16:i=n.visitUint16||n.visitInt;break;case M.Uint32:i=n.visitUint32||n.visitInt;break;case M.Uint64:i=n.visitUint64||n.visitInt;break;case M.Float:i=n.visitFloat;break;case M.Float16:i=n.visitFloat16||n.visitFloat;break;case M.Float32:i=n.visitFloat32||n.visitFloat;break;case M.Float64:i=n.visitFloat64||n.visitFloat;break;case M.Utf8:i=n.visitUtf8;break;case M.LargeUtf8:i=n.visitLargeUtf8;break;case M.Binary:i=n.visitBinary;break;case M.LargeBinary:i=n.visitLargeBinary;break;case M.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case M.Date:i=n.visitDate;break;case M.DateDay:i=n.visitDateDay||n.visitDate;break;case M.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case M.Timestamp:i=n.visitTimestamp;break;case M.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case M.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case M.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case M.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case M.Time:i=n.visitTime;break;case M.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case M.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case M.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case M.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case M.Decimal:i=n.visitDecimal;break;case M.List:i=n.visitList;break;case M.Struct:i=n.visitStruct;break;case M.Union:i=n.visitUnion;break;case M.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case M.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case M.Dictionary:i=n.visitDictionary;break;case M.Interval:i=n.visitInterval;break;case M.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case M.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case M.Duration:i=n.visitDuration;break;case M.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case M.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case M.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case M.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case M.FixedSizeList:i=n.visitFixedSizeList;break;case M.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${M[e]}'`)}function jm(n){switch(n.typeId){case M.Null:return M.Null;case M.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?M.Int8:M.Uint8;case 16:return t?M.Int16:M.Uint16;case 32:return t?M.Int32:M.Uint32;case 64:return t?M.Int64:M.Uint64}return M.Int}case M.Float:switch(n.precision){case Dt.HALF:return M.Float16;case Dt.SINGLE:return M.Float32;case Dt.DOUBLE:return M.Float64}return M.Float;case M.Binary:return M.Binary;case M.LargeBinary:return M.LargeBinary;case M.Utf8:return M.Utf8;case M.LargeUtf8:return M.LargeUtf8;case M.Bool:return M.Bool;case M.Decimal:return M.Decimal;case M.Time:switch(n.unit){case _e.SECOND:return M.TimeSecond;case _e.MILLISECOND:return M.TimeMillisecond;case _e.MICROSECOND:return M.TimeMicrosecond;case _e.NANOSECOND:return M.TimeNanosecond}return M.Time;case M.Timestamp:switch(n.unit){case _e.SECOND:return M.TimestampSecond;case _e.MILLISECOND:return M.TimestampMillisecond;case _e.MICROSECOND:return M.TimestampMicrosecond;case _e.NANOSECOND:return M.TimestampNanosecond}return M.Timestamp;case M.Date:switch(n.unit){case xn.DAY:return M.DateDay;case xn.MILLISECOND:return M.DateMillisecond}return M.Date;case M.Interval:switch(n.unit){case nr.DAY_TIME:return M.IntervalDayTime;case nr.YEAR_MONTH:return M.IntervalYearMonth}return M.Interval;case M.Duration:switch(n.unit){case _e.SECOND:return M.DurationSecond;case _e.MILLISECOND:return M.DurationMillisecond;case _e.MICROSECOND:return M.DurationMicrosecond;case _e.NANOSECOND:return M.DurationNanosecond}return M.Duration;case M.Map:return M.Map;case M.List:return M.List;case M.Struct:return M.Struct;case M.Union:switch(n.mode){case Yt.Dense:return M.DenseUnion;case Yt.Sparse:return M.SparseUnion}return M.Union;case M.FixedSizeBinary:return M.FixedSizeBinary;case M.FixedSizeList:return M.FixedSizeList;case M.Dictionary:return M.Dictionary}throw new Error(`Unrecognized type '${M[n.typeId]}'`)}Ue.prototype.visitInt8=null;Ue.prototype.visitInt16=null;Ue.prototype.visitInt32=null;Ue.prototype.visitInt64=null;Ue.prototype.visitUint8=null;Ue.prototype.visitUint16=null;Ue.prototype.visitUint32=null;Ue.prototype.visitUint64=null;Ue.prototype.visitFloat16=null;Ue.prototype.visitFloat32=null;Ue.prototype.visitFloat64=null;Ue.prototype.visitDateDay=null;Ue.prototype.visitDateMillisecond=null;Ue.prototype.visitTimestampSecond=null;Ue.prototype.visitTimestampMillisecond=null;Ue.prototype.visitTimestampMicrosecond=null;Ue.prototype.visitTimestampNanosecond=null;Ue.prototype.visitTimeSecond=null;Ue.prototype.visitTimeMillisecond=null;Ue.prototype.visitTimeMicrosecond=null;Ue.prototype.visitTimeNanosecond=null;Ue.prototype.visitDenseUnion=null;Ue.prototype.visitSparseUnion=null;Ue.prototype.visitIntervalDayTime=null;Ue.prototype.visitIntervalYearMonth=null;Ue.prototype.visitDuration=null;Ue.prototype.visitDurationSecond=null;Ue.prototype.visitDurationMillisecond=null;Ue.prototype.visitDurationMicrosecond=null;Ue.prototype.visitDurationNanosecond=null;const lg=new Float64Array(1),di=new Uint32Array(lg.buffer);function cg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Kb(n){if(n!==n)return 32256;lg[0]=n;const e=(di[1]&2147483648)>>16&65535;let t=di[1]&2146435072,i=0;return t>=1089470464?di[0]>0?t=31744:(t=(t&2080374784)>>16,i=(di[1]&1048575)>>10):t<=1056964608?(i=1048576+(di[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(di[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Ue{}function Ie(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Jb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},ug=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Qd=({values:n},e,t)=>{n[e]=t},dg=({values:n},e,t)=>{n[e]=Kb(t)},Zb=(n,e,t)=>{switch(n.type.precision){case Dt.HALF:return dg(n,e,t);case Dt.SINGLE:case Dt.DOUBLE:return Qd(n,e,t)}},fg=({values:n},e,t)=>{Jb(n,e,t.valueOf())},hg=({values:n},e,t)=>{n[e]=BigInt(t)},Xb=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},pg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,i),mg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,Vd(i)),ew=(n,e,t)=>{n.type.unit===xn.DAY?fg(n,e,t):hg(n,e,t)},yg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},gg=({values:n},e,t)=>{n[e]=BigInt(t)},vg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},tw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return yg(n,e,t);case _e.MILLISECOND:return gg(n,e,t);case _e.MICROSECOND:return vg(n,e,t);case _e.NANOSECOND:return xg(n,e,t)}},bg=({values:n},e,t)=>{n[e]=t},wg=({values:n},e,t)=>{n[e]=t},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},nw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return bg(n,e,t);case _e.MILLISECOND:return wg(n,e,t);case _e.MICROSECOND:return Sg(n,e,t);case _e.NANOSECOND:return _g(n,e,t)}},rw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},sw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=bn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,h=a[e],m=a[e+1];h{const i=n.children[0],{valueOffsets:a}=n,c=bn.getVisitFn(i);let{[e]:f,[e+1]:h}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=h)break},ow=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),aw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),uw=(n,e,t)=>{const i=n.type.children.map(c=>bn.getVisitFn(c.type)),a=t instanceof Map?lw(e,t):t instanceof Je?aw(e,t):Array.isArray(t)?ow(e,t):cw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},dw=(n,e,t)=>{n.type.mode===Yt.Dense?Ng(n,e,t):jg(n,e,t)},Ng=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,n.valueOffsets[e],t)},jg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,e,t)},fw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},hw=(n,e,t)=>{n.type.unit===nr.DAY_TIME?kg(n,e,t):Ig(n,e,t)},kg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Ig=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Mg=({values:n},e,t)=>{n[e]=t},Dg=({values:n},e,t)=>{n[e]=t},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},pw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Mg(n,e,t);case _e.MILLISECOND:return Dg(n,e,t);case _e.MICROSECOND:return Cg(n,e,t);case _e.NANOSECOND:return Fg(n,e,t)}},mw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=bn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,h=e*i;++f`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new yw(this[On],this[ki])}}class yw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[ki]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(bn.visit(e[On].children[a],e[ki],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Ue{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const vw=(n,e)=>864e5*n[e],xw=(n,e)=>null,Og=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},bw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<vw(n,e),Ag=({values:n},e)=>tt(n[e]),as=({stride:n,values:e},t)=>e[n*t],ww=({stride:n,values:e},t)=>cg(e[n*t]),Bg=({values:n},e)=>n[e],Sw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Eg=({values:n,valueOffsets:e},t)=>Og(n,e,t),Rg=({values:n,valueOffsets:e},t)=>{const i=Og(n,e,t);return i!==null?Id(i):null},_w=({values:n},e)=>n[e],Nw=({type:n,values:e},t)=>n.precision!==Dt.HALF?e[t]:cg(e[t]),jw=(n,e)=>n.type.unit===xn.DAY?Tg(n,e):Ag(n,e),Lg=({values:n},e)=>1e3*tt(n[e]),Ug=({values:n},e)=>tt(n[e]),Pg=({values:n},e)=>Ly(n[e],BigInt(1e3)),$g=({values:n},e)=>Ly(n[e],BigInt(1e6)),kw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Lg(n,e);case _e.MILLISECOND:return Ug(n,e);case _e.MICROSECOND:return Pg(n,e);case _e.NANOSECOND:return $g(n,e)}},zg=({values:n},e)=>n[e],Vg=({values:n},e)=>n[e],Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Iw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return zg(n,e);case _e.MILLISECOND:return Vg(n,e);case _e.MICROSECOND:return Wg(n,e);case _e.NANOSECOND:return Hg(n,e)}},Mw=({values:n,stride:e},t)=>Yd.decimal(n.subarray(e*t,e*(t+1))),Dw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Cw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new Jd(f.slice(a,c-a))},Fw=(n,e)=>new Kd(n,e),Ow=(n,e)=>n.type.mode===Yt.Dense?Gg(n,e):Yg(n,e),Gg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Yg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Tw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Aw=(n,e)=>n.type.unit===nr.DAY_TIME?Qg(n,e):Kg(n,e),Qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Kg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Jg=({values:n},e)=>n[e],qg=({values:n},e)=>n[e],Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],Bw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Jg(n,e);case _e.MILLISECOND:return qg(n,e);case _e.MICROSECOND:return Zg(n,e);case _e.NANOSECOND:return Xg(n,e)}},Ew=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(xw);xe.prototype.visitBool=je(bw);xe.prototype.visitInt=je(_w);xe.prototype.visitInt8=je(as);xe.prototype.visitInt16=je(as);xe.prototype.visitInt32=je(as);xe.prototype.visitInt64=je(Bg);xe.prototype.visitUint8=je(as);xe.prototype.visitUint16=je(as);xe.prototype.visitUint32=je(as);xe.prototype.visitUint64=je(Bg);xe.prototype.visitFloat=je(Nw);xe.prototype.visitFloat16=je(ww);xe.prototype.visitFloat32=je(as);xe.prototype.visitFloat64=je(as);xe.prototype.visitUtf8=je(Rg);xe.prototype.visitLargeUtf8=je(Rg);xe.prototype.visitBinary=je(Eg);xe.prototype.visitLargeBinary=je(Eg);xe.prototype.visitFixedSizeBinary=je(Sw);xe.prototype.visitDate=je(jw);xe.prototype.visitDateDay=je(Tg);xe.prototype.visitDateMillisecond=je(Ag);xe.prototype.visitTimestamp=je(kw);xe.prototype.visitTimestampSecond=je(Lg);xe.prototype.visitTimestampMillisecond=je(Ug);xe.prototype.visitTimestampMicrosecond=je(Pg);xe.prototype.visitTimestampNanosecond=je($g);xe.prototype.visitTime=je(Iw);xe.prototype.visitTimeSecond=je(zg);xe.prototype.visitTimeMillisecond=je(Vg);xe.prototype.visitTimeMicrosecond=je(Wg);xe.prototype.visitTimeNanosecond=je(Hg);xe.prototype.visitDecimal=je(Mw);xe.prototype.visitList=je(Dw);xe.prototype.visitStruct=je(Fw);xe.prototype.visitUnion=je(Ow);xe.prototype.visitDenseUnion=je(Gg);xe.prototype.visitSparseUnion=je(Yg);xe.prototype.visitDictionary=je(Tw);xe.prototype.visitInterval=je(Aw);xe.prototype.visitIntervalDayTime=je(Qg);xe.prototype.visitIntervalYearMonth=je(Kg);xe.prototype.visitDuration=je(Bw);xe.prototype.visitDurationSecond=je(Jg);xe.prototype.visitDurationMillisecond=je(qg);xe.prototype.visitDurationMicrosecond=je(Zg);xe.prototype.visitDurationNanosecond=je(Xg);xe.prototype.visitFixedSizeList=je(Ew);xe.prototype.visitMap=je(Cw);const Qt=new xe,bi=Symbol.for("keys"),Ii=Symbol.for("vals"),wi=Symbol.for("kKeysAsStrings"),Td=Symbol.for("_kKeysAsStrings");class Jd{constructor(e){return this[bi]=new Je([e.children[0]]).memoize(),this[Ii]=e.children[1],new Proxy(this,new Lw)}get[wi](){return this[Td]||(this[Td]=Array.from(this[bi].toArray(),String))}[Symbol.iterator](){return new Rw(this[bi],this[Ii])}get size(){return this[bi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[bi],t=this[Ii],i={};for(let a=-1,c=e.length;++a`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Rw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Lw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[wi]}has(e,t){return e[wi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[wi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[wi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ii),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[wi].indexOf(t);return a!==-1?(bn.visit(Reflect.get(e,Ii),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(Jd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ii]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Td]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let km;function ev(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const qd=(n,e)=>n<0?e+n:n,Im=n=>n!==n;function Li(n){if(typeof n!=="object"||n===null)return Im(n)?Im:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Eb(n,t):!1:n instanceof Map?Pw(n):Array.isArray(n)?Uw(n):n instanceof Je?$w(n):zw(n,!0)}function Uw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Vw(n,t);case Map:return Mm(n,t,t.keys());case Jd:case Kd:case Object:case void 0:return Mm(n,t,e||Object.keys(t))}return t instanceof Je?Ww(n,t):!1}}function Vw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Dm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ad(new Zd(t,n,e,null,tv)).subarray(0,i)),a}return t}function Ad(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Zd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Gw(n,a>>3,i-a>>3)}function Gw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=dd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=dd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=dd(c.getUint8(a)),a+=1;return i}function dd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Yw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,h)=>f+h.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Yw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],h){this.type=e,this.children=f,this.dictionary=h,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=vr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+h+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Dm(f,h,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,h=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,h*e,h*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===M.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Dm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[gr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[gr.TYPE])&&(f[gr.TYPE]=c.subarray(e,e+t)),(c=f[gr.OFFSET])&&(f[gr.OFFSET]=c.subarray(e,e+t+1))||(c=f[gr.DATA])&&(f[gr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Ue{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:h=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,h,[void 0,void 0,void 0,c],a);const m=Oo(e.valueOffsets);return new Ye(t,i,f,h,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:h=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}}const Qw=new Vo;function Re(n){return Qw.visit(n)}class Cm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function nv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function rv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function sv(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(h);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(h.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function Xd(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function qw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Zd(t,n.offset+(e||0),n.length,t,tv)){if(!a)return i;++i}return-1}function De(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case M.Union:break;case M.Dictionary:break;default:return qw(n,t)}const i=Qt.getVisitFn(n),a=Li(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Cm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new Zw(f)})}class Zw{constructor(e){this.vector=e,this.index=0}next(){return this.indexh.data):e;if(c.length===0||c.some(h=>!(h instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:h,set:m,indexOf:g}=cv[f.typeId],v=c[0];this.isValid=x=>ef(v,x),this.get=x=>h(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,uv[f.typeId]),this._offsets=rv(c);break}this.data=c,this.type=f,this.stride=vr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Kw(this.data)}get nullCount(){return nv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${M[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return tf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(ev(this,e,t,({data:i,_offsets:a},c,f)=>sv(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case M.Int:case M.Float:case M.Decimal:case M.Time:case M.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:h,length:m})=>(f.array.set(h.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new Xl(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new Xl(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}lv=Symbol.toStringTag;Je[lv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(M).map(t=>M[t]).filter(t=>typeof t=="number"&&t!==M.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=bn.getVisitFnByTypeId(t),c=Zl.getVisitFnByTypeId(t);cv[t]={get:i,set:a,indexOf:c},uv[t]=Object.create(n,{isValid:{value:ql(ef)},get:{value:ql(Qt.getVisitFnByTypeId(t))},set:{value:iv(bn.getVisitFnByTypeId(t))},indexOf:{value:ov(Zl.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class Xl extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const h=c[f];if(h!==void 0)return h;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,h){i.call(this,f,h),c[f]=h}}),Object.defineProperty(this,"slice",{value:(f,h)=>new Xl(a.call(this,f,h))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ed{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Gn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Rd(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=hl(hl(new Map,this.metadata),t.metadata),c=t.fields.filter(h=>{const m=i.findIndex(g=>g.name===h.name);return~m?(i[m]=h.clone({metadata:hl(hl(new Map,i[m].metadata),h.metadata)}))&&!1:!0}),f=Rd(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function hl(n,e){return new Map([...n||new Map,...e||new Map])}function Rd(n,e=new Map){for(let t=-1,i=n.length;++t0&&Rd(c.children,e)}return e}var Xw=Ay,e1=Ci;class nf{static decode(e){e=new e1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new t1(i,t)}static encode(e){const t=new Xw,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ti.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ti.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return pn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return pn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Oe(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Oe(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class r1 extends n1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Id(this.toUint8Array(!0)):this.toUint8Array(!1).then(Id)}toUint8Array(e=!1){return e?tr(this._values)[0]:Oe(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let h=0;try{for(var m=!0,g=_i(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),h+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return tr(f,h)[0]})}}class ec{constructor(e){e&&(this.source=new s1(pn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Ai{constructor(e){e instanceof Ai?this.source=e.source:e instanceof r1?this.source=new ks(pn.fromAsyncIterable(e)):Fy(e)?this.source=new ks(pn.fromNodeStream(e)):Hd(e)?this.source=new ks(pn.fromDOMStream(e)):Dy(e)?this.source=new ks(pn.fromDOMStream(e.body)):dc(e)?this.source=new ks(pn.fromIterable(e)):Wo(e)?this.source=new ks(pn.fromAsyncIterable(e)):Wd(e)&&(this.source=new ks(pn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class s1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class ks{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Oe(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Oe(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Oe(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Om extends ec{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Si(this.buffer[3])} ${Si(this.buffer[2])} ${Si(this.buffer[1])} ${Si(this.buffer[0])}`}static multiply(e,t){return new Yn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Yn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Yn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Yn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Yn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class o1 extends hv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ad(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===xn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Yn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?a1(i[t]):me.isBool(e)?Ad(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Vd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function a1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Ue{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Bs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function hc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function l1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function sf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function qo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function Zo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function c1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function u1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function of(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&is.compareManyFields(n.children,e.children)}function d1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&is.visit(n.indices,e.indices)&&is.visit(n.dictionary,e.dictionary)}function af(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function f1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Bs;Se.prototype.visitBool=Bs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=hc;Se.prototype.visitFloat16=hc;Se.prototype.visitFloat32=hc;Se.prototype.visitFloat64=hc;Se.prototype.visitUtf8=Bs;Se.prototype.visitLargeUtf8=Bs;Se.prototype.visitBinary=Bs;Se.prototype.visitLargeBinary=Bs;Se.prototype.visitFixedSizeBinary=l1;Se.prototype.visitDate=sf;Se.prototype.visitDateDay=sf;Se.prototype.visitDateMillisecond=sf;Se.prototype.visitTimestamp=qo;Se.prototype.visitTimestampSecond=qo;Se.prototype.visitTimestampMillisecond=qo;Se.prototype.visitTimestampMicrosecond=qo;Se.prototype.visitTimestampNanosecond=qo;Se.prototype.visitTime=Zo;Se.prototype.visitTimeSecond=Zo;Se.prototype.visitTimeMillisecond=Zo;Se.prototype.visitTimeMicrosecond=Zo;Se.prototype.visitTimeNanosecond=Zo;Se.prototype.visitDecimal=Bs;Se.prototype.visitList=c1;Se.prototype.visitStruct=u1;Se.prototype.visitUnion=of;Se.prototype.visitDenseUnion=of;Se.prototype.visitSparseUnion=of;Se.prototype.visitDictionary=d1;Se.prototype.visitInterval=af;Se.prototype.visitIntervalDayTime=af;Se.prototype.visitIntervalYearMonth=af;Se.prototype.visitDuration=Xo;Se.prototype.visitDurationSecond=Xo;Se.prototype.visitDurationMillisecond=Xo;Se.prototype.visitDurationMicrosecond=Xo;Se.prototype.visitDurationNanosecond=Xo;Se.prototype.visitFixedSizeList=f1;Se.prototype.visitMap=h1;const is=new Se;function p1(n,e){return is.compareSchemas(n,e)}function fd(n,e){return m1(n,e.map(t=>t.data.concat()))}function m1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,h=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,h=-1;++h0&&(i[c++]=Re({type:new At(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function y1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let h=-1,m=i.length;++h=e)v===e?t[h]=g:(t[h]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[h].unshift(g.slice(e,v-e))));else{const x=n[h];n[h]=x.clone({nullable:!0}),t[h]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Re({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var pv;class gn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof gn)return m.batches;if(m instanceof Ye){if(m.type instanceof At)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=fd(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},h=e.flatMap(m=>f(m));if(a=(i=a??((t=h[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of h){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!p1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=h,this._offsets=c??rv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=nv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?tf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+p.stack}return{value:r,source:s,stack:d,digest:null}}function ku(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Iu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Tx=typeof WeakMap=="function"?WeakMap:Map;function hp(r,s,o){o=dr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Ja||(Ja=!0,zu=l),Iu(r,s)},o}function pp(r,s,o){o=dr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Iu(r,s)}}var p=r.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(o.callback=function(){Iu(r,s),typeof l!="function"&&(Hr===null?Hr=new Set([this]):Hr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function mp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Tx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Yx.bind(null,r,s,o),s.then(r,r))}function yp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function gp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=dr(-1,1),s.tag=2,Vr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Ax=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Rh(s,null,o,l):ni(s,r.child,o,l)}function vp(r,s,o,l,d){o=o.render;var p=s.ref;return si(s,d),l=vu(r,s,o,l,p,d),o=xu(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,fr(r,s,d)):(rt&&o&&tu(s),s.flags|=1,Ft(r,s,l,d),s.child)}function xp(r,s,o,l,d){if(r===null){var p=o.type;return typeof p=="function"&&!Ku(p)&&p.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=p,bp(r,s,p,l,d)):(r=nl(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(p=r.child,(r.lanes&d)===0){var y=p.memoizedProps;if(o=o.compare,o=o!==null?o:co,o(y,l)&&r.ref===s.ref)return fr(r,s,d)}return s.flags|=1,r=Kr(p,l),r.ref=s.ref,r.return=s,s.child=r}function bp(r,s,o,l,d){if(r!==null){var p=r.memoizedProps;if(co(p,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=p,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,fr(r,s,d)}return Mu(r,s,o,l,d)}function wp(r,s,o){var l=s.pendingProps,d=l.children,p=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(li,Zt),Zt|=o;else{if((o&1073741824)===0)return r=p!==null?p.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(li,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=p!==null?p.baseLanes:o,qe(li,Zt),Zt|=l}else p!==null?(l=p.baseLanes|o,s.memoizedState=null):l=o,qe(li,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function Sp(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Mu(r,s,o,l,d){var p=Lt(o)?ms:jt.current;return p=Zs(s,p),si(s,d),o=vu(r,s,o,l,p,d),l=xu(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,fr(r,s,d)):(rt&&l&&tu(s),s.flags|=1,Ft(r,s,o,d),s.child)}function _p(r,s,o,l,d){if(Lt(o)){var p=!0;Ia(s)}else p=!1;if(si(s,d),s.stateNode===null)Ha(r,s),dp(s,o,l),ju(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,z=o.contextType;typeof z=="object"&&z!==null?z=an(z):(z=Lt(o)?ms:jt.current,z=Zs(s,z));var J=o.getDerivedStateFromProps,q=typeof J=="function"||typeof y.getSnapshotBeforeUpdate=="function";q||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==z)&&fp(s,y,l,z),zr=!1;var K=s.memoizedState;y.state=K,Ea(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||zr?(typeof J=="function"&&(Nu(s,o,J,l),j=s.memoizedState),(S=zr||up(s,o,S,l,K,j,z))?(q||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=z,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Uh(r,s),S=s.memoizedProps,z=s.type===s.elementType?S:Nn(s.type,S),y.props=z,q=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=an(j):(j=Lt(o)?ms:jt.current,j=Zs(s,j));var ie=o.getDerivedStateFromProps;(J=typeof ie=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==q||K!==j)&&fp(s,y,l,j),zr=!1,K=s.memoizedState,y.state=K,Ea(s,l,y,d);var ue=s.memoizedState;S!==q||K!==ue||Rt.current||zr?(typeof ie=="function"&&(Nu(s,o,ie,l),ue=s.memoizedState),(z=zr||up(s,o,z,l,K,ue,j)||!1)?(J||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=z):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Du(r,s,o,l,p,d)}function Du(r,s,o,l,d,p){Sp(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Mh(s,o,!1),fr(r,s,p);l=s.stateNode,Ax.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=ni(s,r.child,null,p),s.child=ni(s,null,S,p)):Ft(r,s,S,p),s.memoizedState=l.state,d&&Mh(s,o,!0),s.child}function Np(r){var s=r.stateNode;s.pendingContext?kh(r,s.pendingContext,s.pendingContext!==s.context):s.context&&kh(r,s.context,!1),fu(r,s.containerInfo)}function jp(r,s,o,l,d){return ti(),iu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Cu={dehydrated:null,treeContext:null,retryLane:0};function Fu(r){return{baseLanes:r,cachePool:null,transitions:null}}function kp(r,s,o){var l=s.pendingProps,d=it.current,p=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(p=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return su(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,p?(l=s.mode,p=s.child,y={mode:"hidden",children:y},(l&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=y):p=rl(y,l,0,null),r=js(r,l,o,null),p.return=s,r.return=s,p.sibling=r,s.child=p,s.child.memoizedState=Fu(o),s.memoizedState=Cu,r):Ou(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Bx(r,s,y,l,S,d,o);if(p){p=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Kr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?p=Kr(S,p):(p=js(p,y,o,null),p.flags|=2),p.return=s,l.return=s,l.sibling=p,s.child=l,l=p,p=s.child,y=r.child.memoizedState,y=y===null?Fu(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},p.memoizedState=y,p.childLanes=r.childLanes&~o,s.memoizedState=Cu,l}return p=r.child,r=p.sibling,l=Kr(p,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Ou(r,s){return s=rl({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Wa(r,s,o,l){return l!==null&&iu(l),ni(s,r.child,null,o),r=Ou(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Bx(r,s,o,l,d,p,y){if(o)return s.flags&256?(s.flags&=-257,l=ku(Error(t(422))),Wa(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(p=l.fallback,d=s.mode,l=rl({mode:"visible",children:l.children},d,0,null),p=js(p,d,y,null),p.flags|=2,l.return=s,p.return=s,l.sibling=p,s.child=l,(s.mode&1)!==0&&ni(s,r.child,null,y),s.child.memoizedState=Fu(y),s.memoizedState=Cu,p);if((s.mode&1)===0)return Wa(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,p=Error(t(419)),l=ku(p,l,void 0),Wa(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==p.retryLane&&(p.retryLane=d,ur(r,d),In(l,r,d,-1))}return Qu(),l=ku(Error(t(421))),Wa(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=Qx.bind(null,r),d._reactRetry=s,null):(r=p.treeContext,qt=Lr(d.nextSibling),Jt=s,rt=!0,_n=null,r!==null&&(sn[on++]=lr,sn[on++]=cr,sn[on++]=ys,lr=r.id,cr=r.overflow,ys=s),s=Ou(s,l.children),s.flags|=4096,s)}function Ip(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),cu(r.return,s,o)}function Tu(r,s,o,l,d){var p=r.memoizedState;p===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=l,p.tail=o,p.tailMode=d)}function Mp(r,s,o){var l=s.pendingProps,d=l.revealOrder,p=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ip(r,o,s);else if(r.tag===19)Ip(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Ra(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Tu(s,!1,d,o,p);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Ra(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Tu(s,!0,o,null,p);break;case"together":Tu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Ha(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function fr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),ws|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Kr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Kr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function Ex(r,s,o){switch(s.tag){case 3:Np(s),ti();break;case 5:zh(s);break;case 1:Lt(s.type)&&Ia(s);break;case 4:fu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ta,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?kp(r,s,o):(qe(it,it.current&1),r=fr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Mp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,wp(r,s,o)}return fr(r,s,o)}var Dp,Au,Cp,Fp;Dp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Au=function(){},Cp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,xs(zn.current);var p=null;switch(o){case"input":d=sr(r,d),l=sr(r,l),p=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),p=[];break;case"textarea":d=Rs(r,d),l=Rs(r,l),p=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Na)}rn(o,l);var y;o=null;for(z in d)if(!l.hasOwnProperty(z)&&d.hasOwnProperty(z)&&d[z]!=null)if(z==="style"){var S=d[z];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else z!=="dangerouslySetInnerHTML"&&z!=="children"&&z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&z!=="autoFocus"&&(a.hasOwnProperty(z)?p||(p=[]):(p=p||[]).push(z,null));for(z in l){var j=l[z];if(S=d!=null?d[z]:void 0,l.hasOwnProperty(z)&&j!==S&&(j!=null||S!=null))if(z==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(p||(p=[]),p.push(z,o)),o=j;else z==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(p=p||[]).push(z,j)):z==="children"?typeof j!="string"&&typeof j!="number"||(p=p||[]).push(z,""+j):z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&(a.hasOwnProperty(z)?(j!=null&&z==="onScroll"&&Xe("scroll",r),p||S===j||(p=[])):(p=p||[]).push(z,j))}o&&(p=p||[]).push("style",o);var z=p;(s.updateQueue=z)&&(s.flags|=4)}},Fp=function(r,s,o,l){o!==l&&(s.flags|=4)};function jo(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function It(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function Rx(r,s,o){var l=s.pendingProps;switch(nu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(s),null;case 1:return Lt(s.type)&&ka(),It(s),null;case 3:return l=s.stateNode,ii(),et(Rt),et(jt),mu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Fa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,_n!==null&&(Hu(_n),_n=null))),Au(r,s),It(s),null;case 5:hu(s);var d=xs(bo.current);if(o=s.type,r!==null&&s.stateNode!=null)Cp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return It(s),null}if(r=xs(zn.current),Fa(s)){l=s.stateNode,o=s.type;var p=s.memoizedProps;switch(l[$n]=s,l[mo]=p,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[$n]=s,r[mo]=l,Dp(r,s,!1,!1),s.stateNode=r;e:{switch(y=Ps(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;dci&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304)}else{if(!l)if(r=Ra(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),jo(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!rt)return It(s),null}else 2*ct()-p.renderingStartTime>ci&&o!==1073741824&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304);p.isBackwards?(y.sibling=s.child,s.child=y):(o=p.last,o!==null?o.sibling=y:s.child=y,p.last=y)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(It(s),null);case 22:case 23:return Yu(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(It(s),s.subtreeFlags&6&&(s.flags|=8192)):It(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Lx(r,s){switch(nu(s),s.tag){case 1:return Lt(s.type)&&ka(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ii(),et(Rt),et(jt),mu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return hu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));ti()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ii(),null;case 10:return lu(s.type._context),null;case 22:case 23:return Yu(),null;case 24:return null;default:return null}}var Ga=!1,Mt=!1,Ux=typeof WeakSet=="function"?WeakSet:Set,le=null;function ai(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Bu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Op=!1;function Px(r,s){if(Yc=fa,r=uh(),Uc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{o.nodeType,p.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,z=0,J=0,q=r,K=null;t:for(;;){for(var ie;q!==o||d!==0&&q.nodeType!==3||(S=y+d),q!==p||l!==0&&q.nodeType!==3||(j=y+l),q.nodeType===3&&(y+=q.nodeValue.length),(ie=q.firstChild)!==null;)K=q,q=ie;for(;;){if(q===r)break t;if(K===o&&++z===d&&(S=y),K===p&&++J===l&&(j=y),(ie=q.nextSibling)!==null)break;q=K,K=q.parentNode}q=ie}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(Qc={focusedElem:r,selectionRange:o},fa=!1,le=s;le!==null;)if(s=le,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,le=r;else for(;le!==null;){s=le;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,k=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:Nn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var U=s.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Z){lt(s,s.return,Z)}if(r=s.sibling,r!==null){r.return=s.return,le=r;break}le=s.return}return ue=Op,Op=!1,ue}function ko(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var p=d.destroy;d.destroy=void 0,p!==void 0&&Bu(s,o,p)}d=d.next}while(d!==l)}}function Ya(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Eu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Tp(r){var s=r.alternate;s!==null&&(r.alternate=null,Tp(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[$n],delete s[mo],delete s[Zc],delete s[Sx],delete s[_x])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ap(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ap(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Ru(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Na));else if(l!==4&&(r=r.child,r!==null))for(Ru(r,s,o),r=r.sibling;r!==null;)Ru(r,s,o),r=r.sibling}function Lu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for(Lu(r,s,o),r=r.sibling;r!==null;)Lu(r,s,o),r=r.sibling}var _t=null,jn=!1;function Wr(r,s,o){for(o=o.child;o!==null;)Ep(r,s,o),o=o.sibling}function Ep(r,s,o){if(Pn&&typeof Pn.onCommitFiberUnmount=="function")try{Pn.onCommitFiberUnmount(oa,o)}catch{}switch(o.tag){case 5:Mt||ai(o,s);case 6:var l=_t,d=jn;_t=null,Wr(r,s,o),_t=l,jn=d,_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):_t.removeChild(o.stateNode));break;case 18:_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?qc(r.parentNode,o):r.nodeType===1&&qc(r,o),ro(r)):qc(_t,o.stateNode));break;case 4:l=_t,d=jn,_t=o.stateNode.containerInfo,jn=!0,Wr(r,s,o),_t=l,jn=d;break;case 0:case 11:case 14:case 15:if(!Mt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var p=d,y=p.destroy;p=p.tag,y!==void 0&&((p&2)!==0||(p&4)!==0)&&Bu(o,s,y),d=d.next}while(d!==l)}Wr(r,s,o);break;case 1:if(!Mt&&(ai(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Wr(r,s,o);break;case 21:Wr(r,s,o);break;case 22:o.mode&1?(Mt=(l=Mt)||o.memoizedState!==null,Wr(r,s,o),Mt=l):Wr(r,s,o);break;default:Wr(r,s,o)}}function Rp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Ux),s.forEach(function(l){var d=Kx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function kn(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~p}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zx(l/1960))-l,10r?16:r,Gr===null)var l=!1;else{if(r=Gr,Gr=null,Za=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,le=r.current;le!==null;){var p=le,y=p.child;if((le.flags&16)!==0){var S=p.deletions;if(S!==null){for(var j=0;jct()-$u?_s(r,0):Pu|=o),$t(r,s)}function Jp(r,s){s===0&&((r.mode&1)===0?s=1:(s=la,la<<=1,(la&130023424)===0&&(la=4194304)));var o=Ot();r=ur(r,s),r!==null&&(Zi(r,s,o),$t(r,o))}function Qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),Jp(r,o)}function Kx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),Jp(r,o)}var qp;qp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ex(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Ch(s,Ca,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Ha(r,s),r=s.pendingProps;var d=Zs(s,jt.current);si(s,o),d=vu(null,s,l,r,d,o);var p=xu();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(p=!0,Ia(s)):p=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,du(s),d.updater=Va,s.stateNode=d,d._reactInternals=s,ju(s,l,r,o),s=Du(null,s,l,!0,p,o)):(s.tag=0,rt&&p&&tu(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Ha(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=qx(l),r=Nn(l,r),d){case 0:s=Mu(null,s,l,r,o);break e;case 1:s=_p(null,s,l,r,o);break e;case 11:s=vp(null,s,l,r,o);break e;case 14:s=xp(null,s,l,Nn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Mu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),_p(r,s,l,d,o);case 3:e:{if(Np(s),r===null)throw Error(t(387));l=s.pendingProps,p=s.memoizedState,d=p.element,Uh(r,s),Ea(s,l,null,o);var y=s.memoizedState;if(l=y.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){d=oi(Error(t(423)),s),s=jp(r,s,l,o,d);break e}else if(l!==d){d=oi(Error(t(424)),s),s=jp(r,s,l,o,d);break e}else for(qt=Lr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,_n=null,o=Rh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ti(),l===d){s=fr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return zh(s),r===null&&su(s),l=s.type,d=s.pendingProps,p=r!==null?r.memoizedProps:null,y=d.children,Kc(l,d)?y=null:p!==null&&Kc(l,p)&&(s.flags|=32),Sp(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&su(s),null;case 13:return kp(r,s,o);case 4:return fu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=ni(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),vp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,p=s.memoizedProps,y=d.value,qe(Ta,l._currentValue),l._currentValue=y,p!==null)if(Sn(p.value,y)){if(p.children===d.children&&!Rt.current){s=fr(r,s,o);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){y=p.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(p.tag===1){j=dr(-1,o&-o),j.tag=2;var z=p.updateQueue;if(z!==null){z=z.shared;var J=z.pending;J===null?j.next=j:(j.next=J.next,J.next=j),z.pending=j}}p.lanes|=o,j=p.alternate,j!==null&&(j.lanes|=o),cu(p.return,o,s),S.lanes|=o;break}j=j.next}}else if(p.tag===10)y=p.type===s.type?null:p.child;else if(p.tag===18){if(y=p.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),cu(y,o,s),y=p.sibling}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===s){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,si(s,o),d=an(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=Nn(l,s.pendingProps),d=Nn(l.type,d),xp(r,s,l,d,o);case 15:return bp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Ha(r,s),s.tag=1,Lt(l)?(r=!0,Ia(s)):r=!1,si(s,o),dp(s,l,d),ju(s,l,d,o),Du(null,s,l,!0,r,o);case 19:return Mp(r,s,o);case 22:return wp(r,s,o)}throw Error(t(156,s.tag))};function Zp(r,s){return Ff(r,s)}function Jx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(r,s,o,l){return new Jx(r,s,o,l)}function Ku(r){return r=r.prototype,!(!r||!r.isReactComponent)}function qx(r){if(typeof r=="function")return Ku(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ee)return 11;if(r===ae)return 14}return 2}function Kr(r,s){var o=r.alternate;return o===null?(o=un(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function nl(r,s,o,l,d,p){var y=2;if(l=r,typeof r=="function")Ku(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return js(o.children,d,p,s);case G:y=8,d|=8;break;case W:return r=un(12,o,s,d|2),r.elementType=W,r.lanes=p,r;case X:return r=un(13,o,s,d),r.elementType=X,r.lanes=p,r;case oe:return r=un(19,o,s,d),r.elementType=oe,r.lanes=p,r;case ne:return rl(o,d,p,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Y:y=10;break e;case $:y=9;break e;case ee:y=11;break e;case ae:y=14;break e;case se:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=un(y,o,s,d),s.elementType=r,s.type=l,s.lanes=p,s}function js(r,s,o,l){return r=un(7,r,l,s),r.lanes=o,r}function rl(r,s,o,l){return r=un(22,r,l,s),r.elementType=ne,r.lanes=o,r.stateNode={isHidden:!1},r}function Ju(r,s,o){return r=un(6,r,null,s),r.lanes=o,r}function qu(r,s,o){return s=un(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function Zx(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Nc(0),this.expirationTimes=Nc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nc(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Zu(r,s,o,l,d,p,y,S,j){return r=new Zx(r,s,o,S,j),s===1?(s=1,p===!0&&(s|=8)):s=0,p=un(3,null,null,s),r.current=p,p.stateNode=r,p.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},du(p),r}function Xx(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),sd.exports=fb(),sd.exports}var fm;function pb(){if(fm)return ul;fm=1;var n=hb();return ul.createRoot=n.createRoot,ul.hydrateRoot=n.hydrateRoot,ul}var mb=pb();function Sr(n){return n.split(".").at(-1)||n}function Fn(n,e){const t=Sr(n);if(e.filter(a=>Sr(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const er="\0__null__";function yb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wy(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),h=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(h===void 0?a||e.compact?1:2:Math.min(h,20)),g=h===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:h,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function gb(n,e={}){return wy(n,{...e,compact:!0})}function vb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function rs(n){return n===er||n===""?"—":n}function Le(n){return yb(n)}function pt(n,e={}){return wy(n,e)}function Gt(n,e={}){return gb(n,e)}function Sy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function xb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function bb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Sy(i)}}function wb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Sy(t)}}function _y(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Qn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Sb(n){if(n.mode==="contains")return`contains ${Qn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${rs(e[0])}`:e.length<=2?`${t} ${e.map(rs).join(", ")}`:`${t} ${e.length} values`}const ad=n=>n.public!==!1,Ny=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function jy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Ny.test(t.name))}function _b(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(h=>h.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const h of a){const[m]=h.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const h of e)h.metrics.some(m=>m.name===c)&&t.add(h.name);return t}function ky(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of _b(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Nb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,type:h.type||"categorical",granularity:h.granularity,supportedGranularities:h.supported_granularities,format:h.format??h.value_format_name})),c=(i.metrics??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,agg:h.agg,type:h.type,format:h.format??h.value_format_name})),f=jy(a,i.default_time_dimension);return{name:i.name,label:Le(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ad).map(i=>({ref:i.name,name:i.name,ownerModel:ky(i,e),baseMetric:i.base_metric,label:i.label||Le(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function jb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m),type:Ny.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m)})),h=jy(c);return{name:a.name,label:Le(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:h,defaultGrain:(h==null?void 0:h.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:ky(a,t),baseMetric:a.base_metric,label:Le(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function kb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function Di(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function Oe(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function h(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(h,m)}g((i=i.apply(n,e||[])).next())})}function hm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Zn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),h("next"),h("throw"),h("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function h(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,V){c.push([w,C,T,V])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function wl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function _i(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof hm=="function"?hm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(h,m){f=n[c](f),a(h,m,f.done,f.value)})}}function a(c,f,h,m){Promise.resolve(m).then(function(g){c({value:g,done:h})},f)}}const Ib=new TextDecoder("utf-8"),Id=n=>Ib.decode(n),Mb=new TextEncoder,Vd=n=>Mb.encode(n),Db=n=>typeof n=="number",Cb=n=>typeof n=="boolean",Tt=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Wo=n=>En(n)&&Tt(n.then),dc=n=>En(n)&&Tt(n[Symbol.iterator]),Wd=n=>En(n)&&Tt(n[Symbol.asyncIterator]),Md=n=>En(n)&&En(n.schema),Iy=n=>En(n)&&"done"in n&&"value"in n,My=n=>En(n)&&Tt(n.stat)&&Db(n.fd),Dy=n=>En(n)&&Hd(n.body),Cy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Hd=n=>En(n)&&Tt(n.cancel)&&Tt(n.getReader)&&!Cy(n),Fy=n=>En(n)&&Tt(n.read)&&Tt(n.pipe)&&Cb(n.readable)&&!Cy(n),Fb=n=>En(n)&&Tt(n.clear)&&Tt(n.bytes)&&Tt(n.position)&&Tt(n.setPosition)&&Tt(n.capacity)&&Tt(n.getBufferIdentifier)&&Tt(n.createLong),Gd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ob(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,h,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,h=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),mm=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Dd=n=>(n.next(),n);function*Tb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?t(e):dc(e)?e:t(e);return yield*Dd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Ab=n=>Tb(Uint8Array,n);function Oy(n,e){return Zn(this,arguments,function*(){if(Wo(e))return yield Ae(yield Ae(yield*wl(_i(Oy(n,yield Ae(e))))));const i=function(f){return Zn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(Dd((function*(h){let m=null;do m=h.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?i(e):dc(e)?a(e):Wd(e)?e:i(e);return yield Ae(yield*wl(_i(Dd((function(f){return Zn(this,arguments,function*(){let h=null;do h=yield Ae(f.next(yield yield Ae(Ke(n,h))));while(!h.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Bb=n=>Oy(Uint8Array,n);function Eb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Rb(n){let e,t=!1,i=[],a,c,f,h=0;function m(){return c==="peek"?tr(i,f)[0]:([a,i,h]=tr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Ab(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-h)?g.next():g.next(f-h),!e&&a.byteLength>0&&(i.push(a),h+=a.byteLength),e||f<=h)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h0&&(a.push(Pe(c)),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Oe(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Oe(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const ld=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function $b(n){return Zn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,h,m=0,g=[],v;function x(){return f==="peek"?tr(g,h)[0]:([v,g,m]=tr(g,h),v)}if({cmd:f,size:h}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=ld(n,"end"),t[1]=ld(n,"error");do{if(t[2]=ld(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(h-m)?(v=Pe(n.read(h-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||h<=m)do({cmd:f,size:h}=yield yield Ae(x()));while(h{for(const[V,P]of w)n.off(V,P);try{const V=n.destroy;V&&V.call(n,_),_=void 0}catch(V){_=V||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Dt;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var xn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(xn||(xn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var nr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(nr||(nr={}));const cd=2,Kn=4,br=4,He=4,es=new Int32Array(2),ym=new Float32Array(es.buffer),gm=new Float64Array(es.buffer),fl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Cd||(Cd={}));let Ci=class Ty{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ty(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ym[0]=t,this.writeInt32(e,es[0])}writeFloat64(e,t){gm[0]=t,this.writeInt32(e,es[fl?0:1]),this.writeInt32(e+4,es[fl?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*cd;this.addInt16(c);let f=0;const h=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Kn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let Nm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let hn=class Il{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new wr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Il).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Gn=class mr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Fi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new hn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Fi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return mr.startSchema(e),mr.addEndianness(e,t),mr.addFields(e,i),mr.addCustomMetadata(e,a),mr.addFeatures(e,c),mr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var M;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(M||(M={}));var gr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(gr||(gr={}));const zb=void 0;function Ho(n){if(n===null)return"null";if(n===zb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Ho(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Ly(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Vb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Vb]=!0;Ln.prototype.toJSON=function(){return`"${Yo(this)}"`};Ln.prototype.valueOf=function(n){return Uy(this,n)};Ln.prototype.toString=function(){return Yo(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return Uy(this);case"string":return Yo(this);case"default":return Gb(this)}return Yo(this)};function Ni(...n){return Ln.apply(this,n)}function ji(...n){return Ln.apply(this,n)}function Go(...n){return Ln.apply(this,n)}Object.setPrototypeOf(Ni.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ji.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Go.prototype,Object.create(Uint32Array.prototype));Object.assign(Ni.prototype,Ln.prototype,{constructor:Ni,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ji.prototype,Ln.prototype,{constructor:ji,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Go.prototype,Ln.prototype,{constructor:Go,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Wb=BigInt(4294967296)*BigInt(4294967296),Hb=Wb-BigInt(1);function Uy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),h=c&&f.at(-1)&BigInt(1)<=0)return ud(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ss extends me{constructor(){super(M.Null)}toString(){return"Null"}}$y=Symbol.toStringTag;ss[$y]=(n=>n[Symbol.toStringTag]="Null")(ss.prototype);class Cs extends me{constructor(e,t){super(M.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}zy=Symbol.toStringTag;Cs[zy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Cs.prototype);class Qo extends Cs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});class Al extends me{constructor(e){super(M.Float),this.precision=e}get ArrayType(){switch(this.precision){case Dt.HALF:return Uint16Array;case Dt.SINGLE:return Float32Array;case Dt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Vy=Symbol.toStringTag;Al[Vy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Al.prototype);class Bl extends me{constructor(){super(M.Binary)}toString(){return"Binary"}}Wy=Symbol.toStringTag;Bl[Wy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Bl.prototype);class El extends me{constructor(){super(M.LargeBinary)}toString(){return"LargeBinary"}}Hy=Symbol.toStringTag;El[Hy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(El.prototype);class Rl extends me{constructor(){super(M.Utf8)}toString(){return"Utf8"}}Gy=Symbol.toStringTag;Rl[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Rl.prototype);class Ll extends me{constructor(){super(M.LargeUtf8)}toString(){return"LargeUtf8"}}Yy=Symbol.toStringTag;Ll[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(Ll.prototype);class Ul extends me{constructor(){super(M.Bool)}toString(){return"Bool"}}Qy=Symbol.toStringTag;Ul[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Ul.prototype);class Pl extends me{constructor(e,t,i=128){super(M.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Ky=Symbol.toStringTag;Pl[Ky]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Pl.prototype);class $l extends me{constructor(e){super(M.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${xn[this.unit]}>`}get ArrayType(){return this.unit===xn.DAY?Int32Array:BigInt64Array}}Jy=Symbol.toStringTag;$l[Jy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))($l.prototype);class zl extends me{constructor(e,t){super(M.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}qy=Symbol.toStringTag;zl[qy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(zl.prototype);class Vl extends me{constructor(e,t){super(M.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Zy=Symbol.toStringTag;Vl[Zy]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Vl.prototype);class Wl extends me{constructor(e){super(M.Interval),this.unit=e}toString(){return`Interval<${nr[this.unit]}>`}}Xy=Symbol.toStringTag;Wl[Xy]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Wl.prototype);class Hl extends me{constructor(e){super(M.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}eg=Symbol.toStringTag;Hl[eg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Hl.prototype);class Gl extends me{constructor(e){super(M.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}tg=Symbol.toStringTag;Gl[tg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Gl.prototype);class At extends me{constructor(e){super(M.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ng=Symbol.toStringTag;At[ng]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(At.prototype);class Yl extends me{constructor(e,t,i){super(M.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}rg=Symbol.toStringTag;Yl[rg]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(Yl.prototype);class Ql extends me{constructor(e){super(M.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}sg=Symbol.toStringTag;Ql[sg]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Ql.prototype);class Kl extends me{constructor(e,t){super(M.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ig=Symbol.toStringTag;Kl[ig]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Kl.prototype);class Jl extends me{constructor(e,t=!1){var i,a,c;if(super(M.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const h=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];h&&(h.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}og=Symbol.toStringTag;Jl[og]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(Jl.prototype);const Yb=(n=>()=>++n)(-1);class Oi extends me{constructor(e,t,i,a){super(M.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Yb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ag=Symbol.toStringTag;Oi[ag]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Oi.prototype);function vr(n){const e=n;switch(n.typeId){case M.Decimal:return n.bitWidth/32;case M.Interval:return 1+e.unit;case M.FixedSizeList:return e.listSize;case M.FixedSizeBinary:return e.byteWidth;default:return 1}}class Ue{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return xi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Qb(n,e,t=!0){return typeof e=="number"?xi(n,e,t):typeof e=="string"&&e in M?xi(n,M[e],t):e&&e instanceof me?xi(n,jm(e),t):e!=null&&e.type&&e.type instanceof me?xi(n,jm(e.type),t):xi(n,M.NONE,t)}function xi(n,e,t=!0){let i=null;switch(e){case M.Null:i=n.visitNull;break;case M.Bool:i=n.visitBool;break;case M.Int:i=n.visitInt;break;case M.Int8:i=n.visitInt8||n.visitInt;break;case M.Int16:i=n.visitInt16||n.visitInt;break;case M.Int32:i=n.visitInt32||n.visitInt;break;case M.Int64:i=n.visitInt64||n.visitInt;break;case M.Uint8:i=n.visitUint8||n.visitInt;break;case M.Uint16:i=n.visitUint16||n.visitInt;break;case M.Uint32:i=n.visitUint32||n.visitInt;break;case M.Uint64:i=n.visitUint64||n.visitInt;break;case M.Float:i=n.visitFloat;break;case M.Float16:i=n.visitFloat16||n.visitFloat;break;case M.Float32:i=n.visitFloat32||n.visitFloat;break;case M.Float64:i=n.visitFloat64||n.visitFloat;break;case M.Utf8:i=n.visitUtf8;break;case M.LargeUtf8:i=n.visitLargeUtf8;break;case M.Binary:i=n.visitBinary;break;case M.LargeBinary:i=n.visitLargeBinary;break;case M.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case M.Date:i=n.visitDate;break;case M.DateDay:i=n.visitDateDay||n.visitDate;break;case M.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case M.Timestamp:i=n.visitTimestamp;break;case M.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case M.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case M.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case M.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case M.Time:i=n.visitTime;break;case M.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case M.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case M.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case M.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case M.Decimal:i=n.visitDecimal;break;case M.List:i=n.visitList;break;case M.Struct:i=n.visitStruct;break;case M.Union:i=n.visitUnion;break;case M.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case M.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case M.Dictionary:i=n.visitDictionary;break;case M.Interval:i=n.visitInterval;break;case M.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case M.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case M.Duration:i=n.visitDuration;break;case M.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case M.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case M.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case M.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case M.FixedSizeList:i=n.visitFixedSizeList;break;case M.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${M[e]}'`)}function jm(n){switch(n.typeId){case M.Null:return M.Null;case M.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?M.Int8:M.Uint8;case 16:return t?M.Int16:M.Uint16;case 32:return t?M.Int32:M.Uint32;case 64:return t?M.Int64:M.Uint64}return M.Int}case M.Float:switch(n.precision){case Dt.HALF:return M.Float16;case Dt.SINGLE:return M.Float32;case Dt.DOUBLE:return M.Float64}return M.Float;case M.Binary:return M.Binary;case M.LargeBinary:return M.LargeBinary;case M.Utf8:return M.Utf8;case M.LargeUtf8:return M.LargeUtf8;case M.Bool:return M.Bool;case M.Decimal:return M.Decimal;case M.Time:switch(n.unit){case _e.SECOND:return M.TimeSecond;case _e.MILLISECOND:return M.TimeMillisecond;case _e.MICROSECOND:return M.TimeMicrosecond;case _e.NANOSECOND:return M.TimeNanosecond}return M.Time;case M.Timestamp:switch(n.unit){case _e.SECOND:return M.TimestampSecond;case _e.MILLISECOND:return M.TimestampMillisecond;case _e.MICROSECOND:return M.TimestampMicrosecond;case _e.NANOSECOND:return M.TimestampNanosecond}return M.Timestamp;case M.Date:switch(n.unit){case xn.DAY:return M.DateDay;case xn.MILLISECOND:return M.DateMillisecond}return M.Date;case M.Interval:switch(n.unit){case nr.DAY_TIME:return M.IntervalDayTime;case nr.YEAR_MONTH:return M.IntervalYearMonth}return M.Interval;case M.Duration:switch(n.unit){case _e.SECOND:return M.DurationSecond;case _e.MILLISECOND:return M.DurationMillisecond;case _e.MICROSECOND:return M.DurationMicrosecond;case _e.NANOSECOND:return M.DurationNanosecond}return M.Duration;case M.Map:return M.Map;case M.List:return M.List;case M.Struct:return M.Struct;case M.Union:switch(n.mode){case Yt.Dense:return M.DenseUnion;case Yt.Sparse:return M.SparseUnion}return M.Union;case M.FixedSizeBinary:return M.FixedSizeBinary;case M.FixedSizeList:return M.FixedSizeList;case M.Dictionary:return M.Dictionary}throw new Error(`Unrecognized type '${M[n.typeId]}'`)}Ue.prototype.visitInt8=null;Ue.prototype.visitInt16=null;Ue.prototype.visitInt32=null;Ue.prototype.visitInt64=null;Ue.prototype.visitUint8=null;Ue.prototype.visitUint16=null;Ue.prototype.visitUint32=null;Ue.prototype.visitUint64=null;Ue.prototype.visitFloat16=null;Ue.prototype.visitFloat32=null;Ue.prototype.visitFloat64=null;Ue.prototype.visitDateDay=null;Ue.prototype.visitDateMillisecond=null;Ue.prototype.visitTimestampSecond=null;Ue.prototype.visitTimestampMillisecond=null;Ue.prototype.visitTimestampMicrosecond=null;Ue.prototype.visitTimestampNanosecond=null;Ue.prototype.visitTimeSecond=null;Ue.prototype.visitTimeMillisecond=null;Ue.prototype.visitTimeMicrosecond=null;Ue.prototype.visitTimeNanosecond=null;Ue.prototype.visitDenseUnion=null;Ue.prototype.visitSparseUnion=null;Ue.prototype.visitIntervalDayTime=null;Ue.prototype.visitIntervalYearMonth=null;Ue.prototype.visitDuration=null;Ue.prototype.visitDurationSecond=null;Ue.prototype.visitDurationMillisecond=null;Ue.prototype.visitDurationMicrosecond=null;Ue.prototype.visitDurationNanosecond=null;const lg=new Float64Array(1),di=new Uint32Array(lg.buffer);function cg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Kb(n){if(n!==n)return 32256;lg[0]=n;const e=(di[1]&2147483648)>>16&65535;let t=di[1]&2146435072,i=0;return t>=1089470464?di[0]>0?t=31744:(t=(t&2080374784)>>16,i=(di[1]&1048575)>>10):t<=1056964608?(i=1048576+(di[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(di[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Ue{}function Ie(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Jb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},ug=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Qd=({values:n},e,t)=>{n[e]=t},dg=({values:n},e,t)=>{n[e]=Kb(t)},Zb=(n,e,t)=>{switch(n.type.precision){case Dt.HALF:return dg(n,e,t);case Dt.SINGLE:case Dt.DOUBLE:return Qd(n,e,t)}},fg=({values:n},e,t)=>{Jb(n,e,t.valueOf())},hg=({values:n},e,t)=>{n[e]=BigInt(t)},Xb=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},pg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,i),mg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,Vd(i)),ew=(n,e,t)=>{n.type.unit===xn.DAY?fg(n,e,t):hg(n,e,t)},yg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},gg=({values:n},e,t)=>{n[e]=BigInt(t)},vg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},tw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return yg(n,e,t);case _e.MILLISECOND:return gg(n,e,t);case _e.MICROSECOND:return vg(n,e,t);case _e.NANOSECOND:return xg(n,e,t)}},bg=({values:n},e,t)=>{n[e]=t},wg=({values:n},e,t)=>{n[e]=t},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},nw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return bg(n,e,t);case _e.MILLISECOND:return wg(n,e,t);case _e.MICROSECOND:return Sg(n,e,t);case _e.NANOSECOND:return _g(n,e,t)}},rw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},sw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=bn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,h=a[e],m=a[e+1];h{const i=n.children[0],{valueOffsets:a}=n,c=bn.getVisitFn(i);let{[e]:f,[e+1]:h}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=h)break},ow=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),aw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),uw=(n,e,t)=>{const i=n.type.children.map(c=>bn.getVisitFn(c.type)),a=t instanceof Map?lw(e,t):t instanceof Je?aw(e,t):Array.isArray(t)?ow(e,t):cw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},dw=(n,e,t)=>{n.type.mode===Yt.Dense?Ng(n,e,t):jg(n,e,t)},Ng=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,n.valueOffsets[e],t)},jg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,e,t)},fw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},hw=(n,e,t)=>{n.type.unit===nr.DAY_TIME?kg(n,e,t):Ig(n,e,t)},kg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Ig=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Mg=({values:n},e,t)=>{n[e]=t},Dg=({values:n},e,t)=>{n[e]=t},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},pw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Mg(n,e,t);case _e.MILLISECOND:return Dg(n,e,t);case _e.MICROSECOND:return Cg(n,e,t);case _e.NANOSECOND:return Fg(n,e,t)}},mw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=bn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,h=e*i;++f`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new yw(this[On],this[ki])}}class yw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[ki]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(bn.visit(e[On].children[a],e[ki],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Ue{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const vw=(n,e)=>864e5*n[e],xw=(n,e)=>null,Og=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},bw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<vw(n,e),Ag=({values:n},e)=>tt(n[e]),as=({stride:n,values:e},t)=>e[n*t],ww=({stride:n,values:e},t)=>cg(e[n*t]),Bg=({values:n},e)=>n[e],Sw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Eg=({values:n,valueOffsets:e},t)=>Og(n,e,t),Rg=({values:n,valueOffsets:e},t)=>{const i=Og(n,e,t);return i!==null?Id(i):null},_w=({values:n},e)=>n[e],Nw=({type:n,values:e},t)=>n.precision!==Dt.HALF?e[t]:cg(e[t]),jw=(n,e)=>n.type.unit===xn.DAY?Tg(n,e):Ag(n,e),Lg=({values:n},e)=>1e3*tt(n[e]),Ug=({values:n},e)=>tt(n[e]),Pg=({values:n},e)=>Ly(n[e],BigInt(1e3)),$g=({values:n},e)=>Ly(n[e],BigInt(1e6)),kw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Lg(n,e);case _e.MILLISECOND:return Ug(n,e);case _e.MICROSECOND:return Pg(n,e);case _e.NANOSECOND:return $g(n,e)}},zg=({values:n},e)=>n[e],Vg=({values:n},e)=>n[e],Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Iw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return zg(n,e);case _e.MILLISECOND:return Vg(n,e);case _e.MICROSECOND:return Wg(n,e);case _e.NANOSECOND:return Hg(n,e)}},Mw=({values:n,stride:e},t)=>Yd.decimal(n.subarray(e*t,e*(t+1))),Dw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Cw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new Jd(f.slice(a,c-a))},Fw=(n,e)=>new Kd(n,e),Ow=(n,e)=>n.type.mode===Yt.Dense?Gg(n,e):Yg(n,e),Gg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Yg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Tw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Aw=(n,e)=>n.type.unit===nr.DAY_TIME?Qg(n,e):Kg(n,e),Qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Kg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Jg=({values:n},e)=>n[e],qg=({values:n},e)=>n[e],Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],Bw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Jg(n,e);case _e.MILLISECOND:return qg(n,e);case _e.MICROSECOND:return Zg(n,e);case _e.NANOSECOND:return Xg(n,e)}},Ew=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(xw);xe.prototype.visitBool=je(bw);xe.prototype.visitInt=je(_w);xe.prototype.visitInt8=je(as);xe.prototype.visitInt16=je(as);xe.prototype.visitInt32=je(as);xe.prototype.visitInt64=je(Bg);xe.prototype.visitUint8=je(as);xe.prototype.visitUint16=je(as);xe.prototype.visitUint32=je(as);xe.prototype.visitUint64=je(Bg);xe.prototype.visitFloat=je(Nw);xe.prototype.visitFloat16=je(ww);xe.prototype.visitFloat32=je(as);xe.prototype.visitFloat64=je(as);xe.prototype.visitUtf8=je(Rg);xe.prototype.visitLargeUtf8=je(Rg);xe.prototype.visitBinary=je(Eg);xe.prototype.visitLargeBinary=je(Eg);xe.prototype.visitFixedSizeBinary=je(Sw);xe.prototype.visitDate=je(jw);xe.prototype.visitDateDay=je(Tg);xe.prototype.visitDateMillisecond=je(Ag);xe.prototype.visitTimestamp=je(kw);xe.prototype.visitTimestampSecond=je(Lg);xe.prototype.visitTimestampMillisecond=je(Ug);xe.prototype.visitTimestampMicrosecond=je(Pg);xe.prototype.visitTimestampNanosecond=je($g);xe.prototype.visitTime=je(Iw);xe.prototype.visitTimeSecond=je(zg);xe.prototype.visitTimeMillisecond=je(Vg);xe.prototype.visitTimeMicrosecond=je(Wg);xe.prototype.visitTimeNanosecond=je(Hg);xe.prototype.visitDecimal=je(Mw);xe.prototype.visitList=je(Dw);xe.prototype.visitStruct=je(Fw);xe.prototype.visitUnion=je(Ow);xe.prototype.visitDenseUnion=je(Gg);xe.prototype.visitSparseUnion=je(Yg);xe.prototype.visitDictionary=je(Tw);xe.prototype.visitInterval=je(Aw);xe.prototype.visitIntervalDayTime=je(Qg);xe.prototype.visitIntervalYearMonth=je(Kg);xe.prototype.visitDuration=je(Bw);xe.prototype.visitDurationSecond=je(Jg);xe.prototype.visitDurationMillisecond=je(qg);xe.prototype.visitDurationMicrosecond=je(Zg);xe.prototype.visitDurationNanosecond=je(Xg);xe.prototype.visitFixedSizeList=je(Ew);xe.prototype.visitMap=je(Cw);const Qt=new xe,bi=Symbol.for("keys"),Ii=Symbol.for("vals"),wi=Symbol.for("kKeysAsStrings"),Td=Symbol.for("_kKeysAsStrings");class Jd{constructor(e){return this[bi]=new Je([e.children[0]]).memoize(),this[Ii]=e.children[1],new Proxy(this,new Lw)}get[wi](){return this[Td]||(this[Td]=Array.from(this[bi].toArray(),String))}[Symbol.iterator](){return new Rw(this[bi],this[Ii])}get size(){return this[bi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[bi],t=this[Ii],i={};for(let a=-1,c=e.length;++a`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Rw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Lw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[wi]}has(e,t){return e[wi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[wi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[wi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ii),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[wi].indexOf(t);return a!==-1?(bn.visit(Reflect.get(e,Ii),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(Jd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ii]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Td]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let km;function ev(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const qd=(n,e)=>n<0?e+n:n,Im=n=>n!==n;function Li(n){if(typeof n!=="object"||n===null)return Im(n)?Im:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Eb(n,t):!1:n instanceof Map?Pw(n):Array.isArray(n)?Uw(n):n instanceof Je?$w(n):zw(n,!0)}function Uw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Vw(n,t);case Map:return Mm(n,t,t.keys());case Jd:case Kd:case Object:case void 0:return Mm(n,t,e||Object.keys(t))}return t instanceof Je?Ww(n,t):!1}}function Vw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Dm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ad(new Zd(t,n,e,null,tv)).subarray(0,i)),a}return t}function Ad(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Zd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Gw(n,a>>3,i-a>>3)}function Gw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=dd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=dd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=dd(c.getUint8(a)),a+=1;return i}function dd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Yw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,h)=>f+h.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Yw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],h){this.type=e,this.children=f,this.dictionary=h,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=vr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+h+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Dm(f,h,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,h=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,h*e,h*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===M.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Dm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[gr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[gr.TYPE])&&(f[gr.TYPE]=c.subarray(e,e+t)),(c=f[gr.OFFSET])&&(f[gr.OFFSET]=c.subarray(e,e+t+1))||(c=f[gr.DATA])&&(f[gr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Ue{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:h=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,h,[void 0,void 0,void 0,c],a);const m=Oo(e.valueOffsets);return new Ye(t,i,f,h,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:h=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}}const Qw=new Vo;function Re(n){return Qw.visit(n)}class Cm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function nv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function rv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function sv(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(h);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(h.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function Xd(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function qw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Zd(t,n.offset+(e||0),n.length,t,tv)){if(!a)return i;++i}return-1}function De(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case M.Union:break;case M.Dictionary:break;default:return qw(n,t)}const i=Qt.getVisitFn(n),a=Li(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Cm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new Zw(f)})}class Zw{constructor(e){this.vector=e,this.index=0}next(){return this.indexh.data):e;if(c.length===0||c.some(h=>!(h instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:h,set:m,indexOf:g}=cv[f.typeId],v=c[0];this.isValid=x=>ef(v,x),this.get=x=>h(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,uv[f.typeId]),this._offsets=rv(c);break}this.data=c,this.type=f,this.stride=vr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Kw(this.data)}get nullCount(){return nv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${M[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return tf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(ev(this,e,t,({data:i,_offsets:a},c,f)=>sv(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case M.Int:case M.Float:case M.Decimal:case M.Time:case M.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:h,length:m})=>(f.array.set(h.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new Xl(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new Xl(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}lv=Symbol.toStringTag;Je[lv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(M).map(t=>M[t]).filter(t=>typeof t=="number"&&t!==M.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=bn.getVisitFnByTypeId(t),c=Zl.getVisitFnByTypeId(t);cv[t]={get:i,set:a,indexOf:c},uv[t]=Object.create(n,{isValid:{value:ql(ef)},get:{value:ql(Qt.getVisitFnByTypeId(t))},set:{value:iv(bn.getVisitFnByTypeId(t))},indexOf:{value:ov(Zl.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class Xl extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const h=c[f];if(h!==void 0)return h;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,h){i.call(this,f,h),c[f]=h}}),Object.defineProperty(this,"slice",{value:(f,h)=>new Xl(a.call(this,f,h))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ed{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Gn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Rd(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=hl(hl(new Map,this.metadata),t.metadata),c=t.fields.filter(h=>{const m=i.findIndex(g=>g.name===h.name);return~m?(i[m]=h.clone({metadata:hl(hl(new Map,i[m].metadata),h.metadata)}))&&!1:!0}),f=Rd(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function hl(n,e){return new Map([...n||new Map,...e||new Map])}function Rd(n,e=new Map){for(let t=-1,i=n.length;++t0&&Rd(c.children,e)}return e}var Xw=Ay,e1=Ci;class nf{static decode(e){e=new e1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new t1(i,t)}static encode(e){const t=new Xw,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ti.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ti.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return pn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return pn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Oe(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Oe(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class r1 extends n1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Id(this.toUint8Array(!0)):this.toUint8Array(!1).then(Id)}toUint8Array(e=!1){return e?tr(this._values)[0]:Oe(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let h=0;try{for(var m=!0,g=_i(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),h+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return tr(f,h)[0]})}}class ec{constructor(e){e&&(this.source=new s1(pn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Ai{constructor(e){e instanceof Ai?this.source=e.source:e instanceof r1?this.source=new ks(pn.fromAsyncIterable(e)):Fy(e)?this.source=new ks(pn.fromNodeStream(e)):Hd(e)?this.source=new ks(pn.fromDOMStream(e)):Dy(e)?this.source=new ks(pn.fromDOMStream(e.body)):dc(e)?this.source=new ks(pn.fromIterable(e)):Wo(e)?this.source=new ks(pn.fromAsyncIterable(e)):Wd(e)&&(this.source=new ks(pn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class s1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class ks{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Oe(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Oe(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Oe(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Om extends ec{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Si(this.buffer[3])} ${Si(this.buffer[2])} ${Si(this.buffer[1])} ${Si(this.buffer[0])}`}static multiply(e,t){return new Yn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Yn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Yn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Yn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Yn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class o1 extends hv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ad(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===xn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Yn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?a1(i[t]):me.isBool(e)?Ad(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Vd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function a1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Ue{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Bs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function hc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function l1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function sf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function qo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function Zo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function c1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function u1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function of(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&is.compareManyFields(n.children,e.children)}function d1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&is.visit(n.indices,e.indices)&&is.visit(n.dictionary,e.dictionary)}function af(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function f1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Bs;Se.prototype.visitBool=Bs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=hc;Se.prototype.visitFloat16=hc;Se.prototype.visitFloat32=hc;Se.prototype.visitFloat64=hc;Se.prototype.visitUtf8=Bs;Se.prototype.visitLargeUtf8=Bs;Se.prototype.visitBinary=Bs;Se.prototype.visitLargeBinary=Bs;Se.prototype.visitFixedSizeBinary=l1;Se.prototype.visitDate=sf;Se.prototype.visitDateDay=sf;Se.prototype.visitDateMillisecond=sf;Se.prototype.visitTimestamp=qo;Se.prototype.visitTimestampSecond=qo;Se.prototype.visitTimestampMillisecond=qo;Se.prototype.visitTimestampMicrosecond=qo;Se.prototype.visitTimestampNanosecond=qo;Se.prototype.visitTime=Zo;Se.prototype.visitTimeSecond=Zo;Se.prototype.visitTimeMillisecond=Zo;Se.prototype.visitTimeMicrosecond=Zo;Se.prototype.visitTimeNanosecond=Zo;Se.prototype.visitDecimal=Bs;Se.prototype.visitList=c1;Se.prototype.visitStruct=u1;Se.prototype.visitUnion=of;Se.prototype.visitDenseUnion=of;Se.prototype.visitSparseUnion=of;Se.prototype.visitDictionary=d1;Se.prototype.visitInterval=af;Se.prototype.visitIntervalDayTime=af;Se.prototype.visitIntervalYearMonth=af;Se.prototype.visitDuration=Xo;Se.prototype.visitDurationSecond=Xo;Se.prototype.visitDurationMillisecond=Xo;Se.prototype.visitDurationMicrosecond=Xo;Se.prototype.visitDurationNanosecond=Xo;Se.prototype.visitFixedSizeList=f1;Se.prototype.visitMap=h1;const is=new Se;function p1(n,e){return is.compareSchemas(n,e)}function fd(n,e){return m1(n,e.map(t=>t.data.concat()))}function m1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,h=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,h=-1;++h0&&(i[c++]=Re({type:new At(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function y1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let h=-1,m=i.length;++h=e)v===e?t[h]=g:(t[h]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[h].unshift(g.slice(e,v-e))));else{const x=n[h];n[h]=x.clone({nullable:!0}),t[h]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Re({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var pv;class gn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof gn)return m.batches;if(m instanceof Ye){if(m.type instanceof At)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=fd(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},h=e.flatMap(m=>f(m));if(a=(i=a??((t=h[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of h){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!p1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=h,this._offsets=c??rv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=nv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?tf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} ]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new gn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=ev({length:this.numRows},e,t);const a=sv(this.data,this._offsets,e,t);return new gn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Re({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],h[e]]=[f,t],[i,a]=fd(i,h)}return new gn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new gn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((h,m,g)=>{const[v,x]=h,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),h},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((h,m)=>[m,a[m]]).map(([h,m])=>m===void 0?this.getChildAt(h):e.getChildAt(m)),...i.map(h=>e.getChildAt(h))].filter(Boolean);return new gn(...fd(c,f))}}pv=Symbol.toStringTag;gn[pv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=ql(ef),n.get=ql(Qt.getVisitFn(M.Struct)),n.set=iv(bn.getVisitFn(M.Struct)),n.indexOf=ov(Zl.getVisitFn(M.Struct)),"Table"))(gn.prototype);var mv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Re({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(t=>Re({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Tm(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),h=Re({type:new At(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Tm(f,h.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=yv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(qd(e,this.numRows))}set(e,t){return bn.visit(this.data,e,t)}indexOf(e,t){return Zl.visit(this.data,e,t)}[Symbol.iterator](){return tf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new gn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&eh.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Re({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Re({type:new At(t.fields),length:this.numRows,children:i});return new zo(t,a)}};mv=Symbol.toStringTag;Tn[mv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Tm(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[h,m]of n.fields.entries()){const g=e[h];(!g||g.length!==t)&&(a[h]=m.clone({nullable:!0}),c[h]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Re({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Re({type:new At(a),length:t,children:c})]}function yv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cRe({type:a.type})),i=Re({type:new At(e.fields),nullCount:0,children:t});super(e,i)}}let qr=class Hn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Hn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Hn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Hn.startMessage(e),Hn.addVersion(e,t),Hn.addHeaderType(e,i),Hn.addHeader(e,a),Hn.addBodyLength(e,c),Hn.addCustomMetadata(e,f),Hn.endMessage(e)}};class g1 extends Ue{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return _m.startNull(t),_m.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return Jn.startFloatingPoint(t),Jn.addPrecision(t,e.precision),Jn.endFloatingPoint(t)}visitBinary(e,t){return vm.startBinary(t),vm.endBinary(t)}visitLargeBinary(e,t){return bm.startLargeBinary(t),bm.endLargeBinary(t)}visitBool(e,t){return xm.startBool(t),xm.endBool(t)}visitUtf8(e,t){return Nm.startUtf8(t),Nm.endUtf8(t)}visitLargeUtf8(e,t){return wm.startLargeUtf8(t),wm.endLargeUtf8(t)}visitDecimal(e,t){return pi.startDecimal(t),pi.addScale(t,e.scale),pi.addPrecision(t,e.precision),pi.addBitWidth(t,e.bitWidth),pi.endDecimal(t)}visitDate(e,t){return Sl.startDate(t),Sl.addUnit(t,e.unit),Sl.endDate(t)}visitTime(e,t){return mn.startTime(t),mn.addUnit(t,e.unit),mn.addBitWidth(t,e.bitWidth),mn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return yn.startTimestamp(t),yn.addUnit(t,e.unit),i!==void 0&&yn.addTimezone(t,i),yn.endTimestamp(t)}visitInterval(e,t){return qn.startInterval(t),qn.addUnit(t,e.unit),qn.endInterval(t)}visitDuration(e,t){return _l.startDuration(t),_l.addUnit(t,e.unit),_l.endDuration(t)}visitList(e,t){return Sm.startList(t),Sm.endList(t)}visitStruct(e,t){return Is.startStruct_(t),Is.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return wr.startDictionaryEncoding(t),wr.addId(t,BigInt(e.id)),wr.addIsOrdered(t,e.isOrdered),i!==void 0&&wr.addIndexType(t,i),wr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Nl.startFixedSizeBinary(t),Nl.addByteWidth(t,e.byteWidth),Nl.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return jl.startFixedSizeList(t),jl.addListSize(t,e.listSize),jl.endFixedSizeList(t)}visitMap(e,t){return kl.startMap(t),kl.addKeysSorted(t,e.keysSorted),kl.endMap(t)}}const hd=new g1;function v1(n,e=new Map){return new We(b1(n,e),Ml(n.metadata),e)}function vv(n){return new Rn(n.count,xv(n.columns),bv(n.columns))}function x1(n){return new kr(vv(n.data),n.id,n.isDelta)}function b1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Am(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function xv(n){return(n||[]).reduce((e,t)=>[...e,new Ui(t.count,w1(t.VALIDITY)),...xv(t.children)],[])}function bv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function S1(n,e){let t,i,a,c,f,h;return!e||!(c=n.dictionary)?(f=Em(n,Am(n,e)),a=new nt(n.name,f,n.nullable,Ml(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Qo,h=new Oi(e.get(t),i,t,c.isOrdered),a=new nt(n.name,h,n.nullable,Ml(n.metadata))):(i=(i=c.indexType)?Bm(i):new Qo,e.set(t,f=Em(n,Am(n,e))),h=new Oi(f,i,t,c.isOrdered),a=new nt(n.name,h,n.nullable,Ml(n.metadata))),a||null}function Ml(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Cs(n.isSigned,n.bitWidth)}function Em(n,e){const t=n.type.name;switch(t){case"NONE":return new ss;case"null":return new ss;case"binary":return new Bl;case"largebinary":return new El;case"utf8":return new Rl;case"largeutf8":return new Ll;case"bool":return new Ul;case"list":return new Gl((e||[])[0]);case"struct":return new At(e||[]);case"struct_":return new At(e||[])}switch(t){case"int":{const i=n.type;return new Cs(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Al(Dt[i.precision])}case"decimal":{const i=n.type;return new Pl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new $l(xn[i.unit])}case"time":{const i=n.type;return new zl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Vl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Wl(nr[i.unit])}case"duration":{const i=n.type;return new Hl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new Yl(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Ql(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Kl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new Jl((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var _1=Ay,N1=Ci;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=j1(e,t),i}static decode(e){e=new N1(Pe(e));const t=qr.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=k1(t,c),f}static encode(e){const t=new _1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),qr.startMessage(t),qr.addVersion(t,ht.V5),qr.addHeader(t,i),qr.addHeaderType(t,e.headerType),qr.addBodyLength(t,BigInt(e.bodyLength)),qr.finishMessageBuffer(t,qr.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ui{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function j1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function k1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Gn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new yr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new fi),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=R1;nt.decode=B1;nt.fromJSON=S1;We.encode=E1;We.decode=I1;We.fromJSON=v1;Rn.encode=L1;Rn.decode=M1;Rn.fromJSON=vv;kr.encode=U1;kr.decode=D1;kr.fromJSON=x1;Ui.encode=P1;Ui.decode=F1;_r.encode=$1;_r.decode=C1;function I1(n,e=new Map,t=ht.V5){const i=A1(n,e);return new We(i,Dl(n),e,t)}function M1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),O1(n),T1(n,e))}function D1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function C1(n){return new _r(n.offset(),n.length())}function F1(n){return new Ui(n.length(),n.nullCount())}function O1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Gn.startFieldsVector(n,t.length);const i=Gn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Gn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const h=n.createString(`${c}`),m=n.createString(`${f}`);return gt.startKeyValue(n),gt.addKey(n,h),gt.addValue(n,m),gt.endKeyValue(n)})):-1;return Gn.startSchema(n),Gn.addFields(n,i),Gn.addEndianness(n,z1?Fi.Little:Fi.Big),a!==-1&&Gn.addCustomMetadata(n,a),Gn.endSchema(n)}function R1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=hd.visit(c,n),i=hd.visit(c.dictionary,n)):i=hd.visit(c,n);const h=(c.children||[]).map(v=>nt.encode(n,v)),m=hn.createChildrenVector(n,h),g=e.metadata&&e.metadata.size>0?hn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return gt.startKeyValue(n),gt.addKey(n,b),gt.addValue(n,w),gt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),hn.startField(n),hn.addType(n,i),hn.addTypeType(n,f),hn.addChildren(n,m),hn.addNullable(n,!!e.nullable),t!==-1&&hn.addName(n,t),a!==-1&&hn.addDictionary(n,a),g!==-1&&hn.addCustomMetadata(n,g),hn.endField(n)}function L1(n,e){const t=e.nodes||[],i=e.buffers||[];yr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ui.encode(n,f);const a=n.endVector();yr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return yr.startRecordBatch(n),yr.addLength(n,BigInt(e.length)),yr.addNodes(n,a),yr.addBuffers(n,c),yr.endRecordBatch(n)}function U1(n,e){const t=Rn.encode(n,e.data);return fi.startDictionaryBatch(n),fi.addId(n,BigInt(e.id)),fi.addIsDelta(n,e.isDelta),fi.addData(n,t),fi.endDictionaryBatch(n)}function P1(n,e){return Ry.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function $1(n,e){return Ey.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const z1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),lf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,cf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,wv=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Sv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class _v{constructor(e){this.source=e instanceof ec?e:new ec(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(lf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(lf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(cf(e));return i}}const pc=4,Ld="ARROW1",nc=new Uint8Array(Ld.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return pn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return pn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Md(e)?K1(e):My(e)?Z1(e):Wo(e)?Oe(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Dy(e)||Hd(e)||Fy(e)||Wd(e)?q1(new Ai(e)):J1(new ec(e))}static readAll(e){return e instanceof jr?e.isSync()?Pm(e):$m(e):Md(e)||ArrayBuffer.isView(e)||dc(e)||Iy(e)?Pm(e):$m(e)}}class rc extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(this[Symbol.iterator]())))})}}class sc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Oe(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,h=_i(this),m;m=yield h.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=h.return)&&(yield i.call(h))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class jv extends rc{constructor(e){super(e),this._impl=e}}class G1 extends sc{constructor(e){super(e),this._impl=e}}class kv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Re({type:new At(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,h=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(h&&a?h.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new hv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class ic extends kv{constructor(e,t){super(t),this._reader=Md(e)?new W1(this._handle=e):new _v(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Mv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class oc extends kv{constructor(e,t){super(t),this._reader=new V1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Oe(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Oe(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Mv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Oe(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Oe(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Oe(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Oe(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Iv extends ic{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Om?e:new Om(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),h=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,h)}}}_readFooter(){const{_handle:e}=this,t=e.size-Nv,i=e.readInt32(t),a=e.readAt(t-i,i);return nf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Oe(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Oe(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Oe(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),h=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,h)}}})}_readFooter(){return Oe(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-Nv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return nf.decode(a)})}_readNextMessageAndValidate(e){return Oe(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?uf(e)?new jv(new Iv(n.read())):new rc(new ic(n)):new rc(new ic((function*(){})()))}function q1(n){return Oe(this,void 0,void 0,function*(){const e=yield n.peek(ea+7&-8);return e&&e.byteLength>=4?uf(e)?new jv(new Iv(yield n.read())):new sc(new oc(n)):new sc(new oc((function(){return Zn(this,arguments,function*(){})})()))})}function Z1(n){return Oe(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new tc(n,e);return e>=H1&&uf(yield t.readAt(0,ea+7&-8))?new G1(new Y1(t)):new sc(new oc(t))})}function Dv(n){const e=jr.from(n);return Wo(e)?e.then(t=>Dv(t)):e.isAsync()?e.readAll().then(t=>new gn(t)):new gn(e.readAll())}function X1(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function eS(n){const e=Dv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,h;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(h=t.interactions)==null?void 0:h.select;return{...t,query:{...i,metrics:Zr(i.metrics)??[],dimensions:Zr(i.dimensions),filters:Zr(i.filters),segments:Zr(i.segments),order_by:Zr(i.order_by),orderBy:Zr(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:Zr(a.fields)}:a,select:typeof c=="object"?{...c,fields:Zr(c.fields)}:c}:void 0}})}))}}const nS="application/vnd.apache.arrow.stream";class rS{constructor(e){Mn(this,"active",0);Mn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function sS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class iS{constructor(e={}){Mn(this,"baseUrl");Mn(this,"token");Mn(this,"sessionToken");Mn(this,"transport");Mn(this,"usePreaggregations");Mn(this,"gate");Mn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new rS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return sS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Nb(await t.json());try{return kb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return jb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?tS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:nS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=eS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Cv({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:h}){const[m,g]=I.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=I.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=I.useId(),w=I.useRef(null),_=I.useRef(null),C=f&&v;return I.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),V=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",V),()=>T.removeEventListener("change",V)},[]),I.useEffect(()=>{h&&!m&&x(!0)},[h,m]),I.useEffect(()=>{if(!m||!v)return;const T=_.current,V=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var R,F;return(F=(R=w.current)==null?void 0:R.querySelector("button"))==null?void 0:F.focus()});function P(R){var L;if(R.key==="Escape"){R.preventDefault(),x(!1);return}if(R.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const B=F[0],D=F[F.length-1];R.shiftKey&&document.activeElement===B?(R.preventDefault(),D.focus()):!R.shiftKey&&document.activeElement===D&&(R.preventDefault(),B.focus())}return document.addEventListener("keydown",P,!0),()=>{document.body.style.overflow=V,document.removeEventListener("keydown",P,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-x-auto border-b border-line bg-surface px-3 py-2 md:h-9 md:flex-nowrap md:py-0",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function oS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const aS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function pl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function ml(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function lS(n,e){const t=n.split("__").at(-1);return t&&aS.has(t)?t:e}function cS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function uS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Fs(n,e,t){var F,B,D,L,G,W,Y;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find($=>$.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=pl(a.query.dimensions),f=pl(a.query.metrics),h=f.map($=>{var ee;return(ee=n.graphMetrics.find(X=>X.ref===$))==null?void 0:ee.ownerModel}).find($=>!!$),m=((F=f.find($=>$.includes(".")))==null?void 0:F.split(".")[0])??h??((B=c.find($=>$.includes(".")))==null?void 0:B.split(".")[0]),g=n.models.find($=>$.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap($=>$.metrics),...Di(n,g.name)],x=f.map($=>v.find(ee=>ee.ref===$)).filter($=>!!$),b=c.map($=>ml(n,$)).filter(($,ee,X)=>!!$&&X.findIndex(oe=>(oe==null?void 0:oe.ref)===($==null?void 0:$.ref))===ee),w=(D=a.encoding)==null?void 0:D.y,C=(Array.isArray(w)?w:w?[w]:[]).find($=>x.some(ee=>ee.ref===$))??((L=x[0])==null?void 0:L.ref)??((G=g.metrics[0])==null?void 0:G.ref)??"",T=(W=a.encoding)==null?void 0:W.x,V=(T&&((Y=ml(n,T))==null?void 0:Y.type)==="time"?T:void 0)??c.find($=>{var ee;return((ee=ml(n,$))==null?void 0:ee.type)==="time"}),P=g.defaultGrain??"month",R=V?ml(n,V):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:R,selectedMetric:C,grain:V?lS(V,P):P,filters:pl(a.query.filters),segments:pl(a.query.segments),usePreaggregations:uS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??cS(e)}}const Ud=["second","minute","hour","day","week","month","quarter","year"];function dS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Ud.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Ud.filter(i=>i===e||t.includes(i)):t}function Mi(n){return n.toISOString().slice(0,10)}function df(n){return n.slice(0,10)}function Ei(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function Os(n){return new Date(`${df(n)}T00:00:00Z`)}function Ko(n,e){const t=Os(n);return t.setUTCDate(t.getUTCDate()+e),Mi(t)}function fS(n){return Math.round((Os(n.to).getTime()-Os(n.from).getTime())/864e5)+1}function hS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ei(n.from)),f=Date.parse(Ei(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=fS(n),t=Ko(n.from,-1);return{from:Ko(t,-(e-1)),to:t}}function zm(n){if(n.includes("T")){const f=new Date(Ei(n)),h=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(h,m+1,0)).getUTCDate();return new Date(Date.UTC(h,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=Os(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return Mi(new Date(Date.UTC(t,i,Math.min(a,c))))}function pS(n){return{from:zm(n.from),to:zm(n.to)}}function mS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Fv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ri(n,e=new Date){const t=Mi(e);return{from:Ko(t,-(n-1)),to:t}}function yS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${Ko(e.to,1)}' as date)`]}function Vm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ei(e))-Date.parse(Ei(n)))/f)}const i=Os(n),a=Os(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function pd(n,e){return new Date(Date.parse(Ei(n))+e).toISOString().slice(0,19)}function gS(n,e){const t=df(n),i=Os(t);switch(e){case"second":return pd(n,1e3);case"minute":return pd(n,6e4);case"hour":return pd(n,36e5);case"day":return t;case"week":return Ko(n,6);case"month":return Mi(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return Mi(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return Mi(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function ff(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function hf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function mc(n){return hf(n.models.flatMap(e=>e.dimensions))}function Wm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Qn(n,t)}function vS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Ov(n,e,t){const i=Qn(`%${vS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function xS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(er),f=e.values.filter(m=>m!==er);let h=null;if(f.length===1)h=`${n} ${a?"!=":"="} ${Wm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Wm(g,t,i)).join(", ");h=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return h&&m.push(h),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return h&&m.push(h),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return h?`(${h} OR ${n} IS NULL)`:null}function Tv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||ff(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Ov(a,c.pattern??"",e.dialect));continue}const h=xS(a,c,f,e.dialect);h&&t.push(h)}return t}function Ts(n,e={}){const t=Tv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...yS(e.timeRef,e.range)),t}function md(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const bS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Hm(n,e,t,i,a,c,f=!1){const h=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[h],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${h} ${g?"DESC":"ASC"}`],...!m||g?{limit:bS[t]??2e3}:{}}}function Gm(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function wS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function SS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function _S(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function NS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function yl(n,e,t){const i={...n};return ff(t)?delete i[e]:i[e]=t,i}function jS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=NS(a,e.value);return{...n,filters:yl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:yl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:yl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:yl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ri(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ri(e.initial.datePreset):e.initial.dateRange};default:return n}}function kS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Av(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=Di(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Bv(n,e,t){const i=Fs(n,e,t),a=(i==null?void 0:i.model)??kS(n),c=(i==null?void 0:i.selectedMetric)??Av(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ri(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,pivotDims:[],pivotMetrics:[]}}function IS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),h=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:h?n.grain:e.grain}}const MS=["home","explore","pivot"],DS=new Set(Ud),CS=new Set(["none","pctTotal","delta","deltaPct"]),FS=new Set(["off","previous","year","custom"]),OS="none",TS="previous",AS="UTC";function BS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function yd(n){if(n)try{return JSON.parse(n)}catch{return}}function ac(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function gl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const ES=new Set(["include","exclude","contains"]);function RS(n){if(ac(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!ES.has(e.mode))return null;const t=e.mode,i=ac(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return ff(c)?null:c}function LS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=RS(i);a&&(e[t]=a)}return e}function US(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function PS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==AS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==OS&&e.set("ctx",n.contextColumn),n.comparison!==TS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(US(n.filters))),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function $S(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&MS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const h=t.get("metric");h&&(i.selectedMetric=h);const m=t.get("grain");m&&DS.has(m)&&(i.grain=m);const g=t.get("tz");BS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ri(e.datePreset));const b=t.get("range"),w=Fv.find(B=>`${B.days}d`===b);gl(v)&&gl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ri(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&CS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&FS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),V=t.get("cto");i.comparison==="custom"&&gl(T)&&gl(V)&&Date.parse(T)<=Date.parse(V)&&(i.comparisonRange={from:T,to:V});const P=LS(yd(t.get("filters")));P&&(i.filters=P);const R=yd(t.get("pdims"));ac(R)&&(i.pivotDims=R);const F=yd(t.get("pmetrics"));return ac(F)&&(i.pivotMetrics=F),i}const Ev=I.createContext(null);function Ym(n){const e=PS(n);return e?`?${e}`:""}function Qm(n,e,t,i){const a=$S(n,i),c=Fs(e,t,a.dashboardTab);return c?IS(a,c,n):a}const Km=n=>n.startsWith("?")?n.slice(1):n;function zS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=I.useMemo(()=>Bv(n,t),[n,t]),[h,m]=I.useReducer(jS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Qm(b,n,t,f)}),g=I.useRef(i);I.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Km(i)!==Km(Ym(h))&&m({type:"hydrate",state:Qm(i,n,t,f)}))},[i,h,n,t,f]);const v=I.useRef(a);v.current=a,I.useEffect(()=>{const b=Ym(h),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[h]);const x=I.useMemo(()=>({state:h,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[h,n,e,f,t]);return u.jsx(Ev.Provider,{value:x,children:c})}function ls(){const n=I.useContext(Ev);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Ms={active:0,listeners:new Set};function Rv(){for(const n of Ms.listeners)n()}function VS(){Ms.active+=1,Rv()}function WS(){Ms.active=Math.max(0,Ms.active-1),Rv()}function Lv(){return I.useSyncExternalStore(n=>(Ms.listeners.add(n),()=>Ms.listeners.delete(n)),()=>Ms.active>0,()=>!1)}const HS=80;function Bn(n,e){const[t,i]=I.useState({loading:!1}),a=I.useRef(0),c=e?JSON.stringify(e):null;return I.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const h=setTimeout(()=>{VS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>WS())},HS);return()=>clearTimeout(h)},[c,n]),{...t,queryKey:c??void 0}}const GS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],YS=50,Jm=200;function qm(n,e){const[t,i]=I.useState(n);return I.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function Uv({dim:n,model:e,onClose:t}){var H,N;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:h}=ls(),m=I.useMemo(()=>Fs(f,h,i.dashboardTab),[f,h,i.dashboardTab]),g=i.filters[n.ref],[v,x]=I.useState((g==null?void 0:g.mode)??"include"),b=I.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=I.useRef(null),_=I.useRef(null),C=I.useId(),[T,V]=I.useState(""),P=qm(T,Jm),R=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,B]=I.useState(R),D=qm(F,Jm);I.useEffect(()=>{var te;const O=document.activeElement;return(te=_.current)==null||te.focus(),()=>{var he;return(he=O==null?void 0:O.focus)==null?void 0:he.call(O)}},[]),I.useEffect(()=>{function O(he){he.key==="Escape"&&(he.stopPropagation(),t())}function te(he){w.current&&!w.current.contains(he.target)&&t()}return document.addEventListener("keydown",O,!0),document.addEventListener("mousedown",te,!0),()=>{document.removeEventListener("keydown",O,!0),document.removeEventListener("mousedown",te,!0)}},[t]),I.useEffect(()=>{v==="contains"&&D!==R&&a({type:"setFilterPattern",dim:n.ref,pattern:D})},[D,v,n.ref,a]);const L=((H=m==null?void 0:m.timeDimension)==null?void 0:H.ref)??((N=e.timeDimension)==null?void 0:N.ref),G=I.useMemo(()=>mc(f),[f]),W=I.useMemo(()=>{const O=[...(m==null?void 0:m.filters)??[],...Ts(i.filters,{timeRef:L,range:i.dateRange,excludeDim:n.ref,types:G,dialect:f.dialect})];return P.trim()&&O.push(Ov(n.ref,P.trim(),f.dialect)),O},[m,i.filters,L,i.dateRange,n.ref,P,G,f.dialect]),Y=v!=="contains",{result:$,loading:ee,error:X}=Bn(c,Y?wS(n.ref,W,YS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),oe=Sr(n.ref),ae=I.useMemo(()=>$?$.rows.map(O=>{const te=O[oe];return te==null?er:String(te)}):[],[$,oe]),se=!!$&&$.rows.length>0&&!$.columns.includes(oe),ne=Y&&(ee||se);function A(O){x(O),g&&a({type:"setFilterMode",dim:n.ref,mode:O}),O==="contains"&&B(R)}function Q(O){var pe;if(O.key!=="Tab")return;const te=(pe=w.current)==null?void 0:pe.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!te||te.length===0)return;const he=te[0],re=te[te.length-1];O.shiftKey&&document.activeElement===he?(O.preventDefault(),re.focus()):!O.shiftKey&&document.activeElement===re&&(O.preventDefault(),he.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:Q,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:GS.map(({mode:O,label:te})=>u.jsx("button",{type:"button","aria-pressed":v===O,onClick:()=>A(O),className:`px-1.5 py-1 text-center ${v===O?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:te},O))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:O=>B(O.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:O=>V(O.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:X?u.jsx("p",{className:"px-1 py-2 text-danger",children:X}):ne?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(O=>u.jsx("div",{className:"skeleton h-4 w-full"},O))}):ae.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ae.map(O=>{const te=b.has(O);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:te,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:O,mode:v}),className:"size-3 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 truncate text-ink",children:rs(O)})]},O)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function QS({model:n}){const e=n.dimensions.filter(m=>m.type!=="time"),[t,i]=I.useState(!1),[a,c]=I.useState(null),f=I.useRef(null);I.useEffect(()=>{if(!t)return;function m(v){v.key==="Escape"&&h()}function g(v){a||f.current&&!f.current.contains(v.target)&&h()}return document.addEventListener("keydown",m,!0),document.addEventListener("mousedown",g,!0),()=>{document.removeEventListener("keydown",m,!0),document.removeEventListener("mousedown",g,!0)}},[t,a]);function h(){i(!1),c(null)}return e.length===0?null:u.jsxs("span",{ref:f,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":t,onClick:()=>t?h():i(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),t&&!a?u.jsx("div",{role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 z-50 mt-1 max-h-64 w-48 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:e.map(m=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>c(m),className:"block w-full truncate px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:m.label},m.ref))}):null,t&&a?u.jsx(Uv,{dim:a,model:n,onClose:h}):null]})}function gd(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Zm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function KS({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function JS(){const{state:n,dispatch:e,catalog:t}=ls(),i=t.models.find(h=>h.name===n.model),a=Di(t,n.model),c=n.view==="pivot",f=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:h=>{var v,x;const m=t.models.find(b=>b.name===h.target.value),g=((v=m==null?void 0:m.metrics[0])==null?void 0:v.ref)??((x=Di(t,h.target.value)[0])==null?void 0:x.ref)??"";e({type:"setModel",model:h.target.value,metric:g,grain:(m==null?void 0:m.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(h=>u.jsx("option",{value:h.name,children:h.label},h.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(h=>u.jsx(Zm,{metric:h,selected:c?f.includes(h.ref):n.selectedMetric===h.ref,multiple:c,onSelect:()=>e(c?{type:"setPivotMetrics",metrics:gd(f,h.ref)}:{type:"setMetric",metric:h.ref})},h.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(h=>u.jsx(Zm,{metric:h,selected:c?f.includes(h.ref):n.selectedMetric===h.ref,multiple:c,onSelect:()=>e(c?{type:"setPivotMetrics",metrics:gd(f,h.ref)}:{type:"setMetric",metric:h.ref})},h.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),c?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(h=>u.jsx(KS,{dimension:h,selected:n.pivotDims.includes(h.ref),onSelect:()=>e({type:"setPivotDims",dims:gd(n.pivotDims,h.ref)})},h.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(h=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:h.description,children:[u.jsx("span",{className:"truncate",children:h.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:h.type==="time"?"time":""})]},h.ref))})]})]})}class qS extends I.Component{constructor(){super(...arguments);Mn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const ZS=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Pv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=I.useRef(null),[h,m]=I.useState((n==null?void 0:n.from)??""),[g,v]=I.useState((n==null?void 0:n.to)??""),[x,b]=I.useState((a==null?void 0:a.from)??""),[w,_]=I.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,B){t(F,B),C()}function V(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const P=n?`${n.from} → ${n.to}`:"All time",R=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:P}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Fv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ri(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:h,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!h||!g,onClick:()=>T({from:h,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${R?"opacity-50":""}`,children:ZS.map(F=>u.jsx("button",{type:"button",disabled:R,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>V(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!R?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function Pd(n){const[e,t]=I.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(h=>!h),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",Sb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(Uv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function $d({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Le(a)},a))})]})}const XS=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let vl=null;function Xm(){if(vl)return vl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return vl=[...new Set(["UTC",...n])].sort(),vl}function e_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function t_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],h=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${h}:${m}`}catch{return""}}const ey="__search__";function n_({timezone:n,disabled:e,onChange:t}){const i=I.useId(),[a,c]=I.useState(!1),[f,h]=I.useState(""),m=I.useMemo(()=>{const b=new Set(XS);return n&&b.add(n),[...b]},[n]),g=I.useMemo(()=>a?Xm():[],[a]);function v(b){const w=b.trim();e_(w)&&(t(w),c(!1),h(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{h(b.target.value),Xm().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),h(""))},onBlur:()=>{c(!1),h("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=t_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ey?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ey,children:"Search…"})]})]})}function r_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const s_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Pi({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:h=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=I.useState(0),[w,_]=I.useState(""),C=I.useMemo(()=>{const D=w.trim().toLowerCase();return!m||!D?e:e.filter(L=>n.some(G=>String(L[G.key]??"").toLowerCase().includes(D)))},[e,n,w,m]),{paginate:T,pageCount:V,safePage:P,start:R,visibleRows:F}=vb(C,x,h);I.useEffect(()=>{b(0)},[e,h,i,a,w]);const B=g&&n.some(D=>g[D.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:D=>_(D.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(D=>{const L=i===D.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${D.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:D.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(D.key),"aria-label":`Sort by ${D.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:D.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:D.label,children:D.label})},D.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((D,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(G=>{const W=f(G,D[G.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${G.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:W,children:W})},G.key)})},R+L))}),B&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(D=>{const L=g==null?void 0:g[D.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},D.key);const G=r_(C,D.key,L),W=L==="count"?G.toLocaleString():Number.isFinite(G)?f(D,G):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${D.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:s_[L]}),W]},D.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[R+1,"–",Math.min(R+h,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:P===0,onClick:()=>b(D=>Math.max(0,D-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:P>=V-1,onClick:()=>b(D=>Math.min(V-1,D+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function i_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function o_(){var P,R;const[n,e]=I.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=ls(),f=i.models.find(F=>F.name===t.model),h=I.useMemo(()=>Fs(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(h==null?void 0:h.dimensions)??(f==null?void 0:f.dimensions)??[],g=i_(m,t.pivotDims),v=((P=h==null?void 0:h.timeDimension)==null?void 0:P.ref)??((R=f==null?void 0:f.timeDimension)==null?void 0:R.ref),x=I.useMemo(()=>mc(i),[i]),b=I.useMemo(()=>[...(h==null?void 0:h.filters)??[],...Ts(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[h,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?_S({dimensions:g,metrics:[]},b,50,h==null?void 0:h.segments,h==null?void 0:h.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),V=[...g.map(F=>{var B;return{key:Sr(F),label:((B=m.find(D=>D.ref===F))==null?void 0:B.label)??Le(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):V.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Pi,{columns:V,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,B)=>B==null||B===""?"—":String(B)})}):null]})}function pf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function yc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(pf,{tone:"loading",title:n,message:e})}function Xn({title:n="No results",message:e}){return u.jsx(pf,{tone:"muted",title:n,message:e})}function $i({title:n="Query failed",message:e}){return u.jsx(pf,{tone:"danger",title:n,message:e})}function vd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const $v="sidemantic-theme";function mf(){var e;const n=localStorage.getItem($v);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function zv(n){document.documentElement.dataset.theme=n}function a_(){zv(mf())}function l_(){const n=mf()==="dark"?"light":"dark";return localStorage.setItem($v,n),zv(n),n}function Jo(){const[n,e]=I.useState(mf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(l_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Vv({view:n,onChange:e}){const t=I.useRef(null);function i(a){const c=Math.max(0,To.findIndex(h=>h.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var h,m;return(m=(h=t.current)==null?void 0:h.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Wv="dashboard_filters",Hv="dashboard_ranges",Gv="dashboard_filter_sources",Yv="dashboard_range_sources",Qv="dashboard_chart_filters",Kv="dashboard_chart_ranges";function c_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function yf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function u_(n){return(n.query.dimensions??[]).find(e=>yf(n,e))}function d_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function lc(n){return n==null?er:String(n)}function f_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function xr(n,e){const t=Sr(n),i=f_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function h_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function p_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&yf(n,c[0])))}function m_(n,e,t){return[e,...t].some(i=>yf(n,i))}const y_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ds(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return y_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Jv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Ds(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function qv(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function Zv(n,e,t){const i=Ds(n);if(i){const a=qv(e.to,i.grain);return a?`${i.baseDimension} >= ${Qn(e.from,t)} AND ${i.baseDimension} < ${Qn(a,t)}`:`${i.baseDimension} >= ${Qn(e.from,t)} AND ${i.baseDimension} <= ${Qn(e.to,t)}`}return`${n} >= ${Qn(e.from,t)} AND ${n} <= ${Qn(e.to,t)}`}function g_(n,e,t,i){const a=Ds(n);return a?e===er?[`${a.baseDimension} IS NULL`]:[Zv(n,{from:e,to:e},i)]:Tv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function cc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function gf(n,e,t){var f,h,m,g,v;const i=((h=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:h.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=cc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function v_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,V,P;const h=gf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Jv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(h.filters).flatMap(([R,F])=>g_(R,F,i,f)),...Object.entries(h.ranges).map(([R,F])=>Zv(R,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((P=(V=n.defaults)==null?void 0:V.query)==null?void 0:P.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ty(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function ny(n,e){const t=ty(e.from);if(!t)return null;const i=Ds(n);if(!i){const f=ty(e.to);return f?{from:t,to:f}:null}const a=qv(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function x_(n,e,t,i={},a){var F,B,D;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",h=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((B=h[0])==null?void 0:B.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=gf(n,e,t),x=Object.entries(v.filters).flatMap(([L,G])=>{const W=Ds(L);return W?[{dimension:L,value:G,baseDimension:W.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,G])=>{const W=Ds(L);return W?G===er?[[W.baseDimension,[G]]]:[]:[[L,[G]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((D=e.encoding)==null?void 0:D.x)??h[0],C=x.find(({baseDimension:L,value:G})=>G!==er&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),V=[_,...T].find((L,G,W)=>{if(!L||W.indexOf(L)!==G||!v.ranges[L])return!1;const Y=Ds(L);return((i[L]??(Y?i[Y.baseDimension]:void 0))==="time"||!!Y)&&(!g||L.startsWith(`${g}.`))}),P=V?v.ranges[V]:void 0,R=C?ny(C.dimension,{from:C.value,to:C.value}):V&&P?ny(V,P):null;return R&&(w.set("from",R.from),w.set("to",R.to)),`/explore?${w}`}function b_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const h=i.map(b=>lc(c[b])),m=JSON.stringify(h),g=h.length?h.map(rs).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:h,data:[]},x=lc(c[e]);v.data.push({label:rs(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function w_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const h of n){if(h[e]==null)continue;const m=String(h[e]),g=Number(h[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>lc(h[_])),x=JSON.stringify(v),b=v.length?v.map(rs).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(h=>({label:h.label,points:a.map(m=>({x:m,y:h.values.get(m)??Number.NaN}))}))}function vf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function uc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function Xv(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=vf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function e0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function t0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function n0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[cc(n,t),new Set(t.query.dimensions??[])])))}function S_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,h,m,g,v,x;try{f=JSON.parse(t.get(Wv)??"{}")}catch{f={}}try{h=JSON.parse(t.get(Hv)??"{}")}catch{h={}}try{m=JSON.parse(t.get(Gv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Yv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Kv)??"{}")}catch{x={}}const b=t0(e),w=n0(e);return{tab:c,filters:vf(f,b),ranges:xf(h,b),filterSources:uc(m,b),rangeSources:uc(g,b),chartFilters:Xv(v,w),chartRanges:e0(x,w)}}function __(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Wv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Hv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Gv,JSON.stringify(i)),Object.keys(a).length&&t.set(Yv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Kv,JSON.stringify(n.chartRanges)),t.toString()}function r0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function N_(n){try{const e=JSON.parse(localStorage.getItem(r0(n))??"[]");if(!Array.isArray(e))return[];const t=t0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",h=n0(n);return[{name:a.name,state:{tab:f,filters:vf(c.filters,t),ranges:xf(c.ranges,t),filterSources:uc(c.filterSources,t),rangeSources:uc(c.rangeSources,t),chartFilters:Xv(c.chartFilters,h),chartRanges:e0(c.chartRanges,h)}}]})}catch{return[]}}function j_(n,e){try{return localStorage.setItem(r0(n),JSON.stringify(e)),!0}catch{return!1}}function ry(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function k_(n,e){return[n.map(ry).join(","),...e.map(t=>n.map(i=>ry(t[i])).join(","))].join(`\r diff --git a/sidemantic-rs/ui/index.html b/sidemantic-rs/ui/index.html index 08a6970c2..655ef9384 100644 --- a/sidemantic-rs/ui/index.html +++ b/sidemantic-rs/ui/index.html @@ -4,7 +4,7 @@ Sidemantic - + diff --git a/sidemantic/core/introspection.py b/sidemantic/core/introspection.py index 08c9223a6..7ac566aa8 100644 --- a/sidemantic/core/introspection.py +++ b/sidemantic/core/introspection.py @@ -110,6 +110,8 @@ def _describe_dimension(dimension: Any, warnings: list[dict[str, Any]], model: M info["label"] = dimension.label if dimension.format: info["format"] = dimension.format + if dimension.value_format_name: + info["value_format_name"] = dimension.value_format_name if dimension.meta: info["meta"] = dimension.meta return _drop_none(info) @@ -142,6 +144,8 @@ def _describe_metric( info["label"] = metric.label if metric.format: info["format"] = metric.format + if metric.value_format_name: + info["value_format_name"] = metric.value_format_name if metric.meta: info["meta"] = metric.meta result = _drop_none(info) diff --git a/sidemantic/ui/static/assets/index-Bh-YPoVm.js b/sidemantic/ui/static/assets/index-C0Mo4KDV.js similarity index 73% rename from sidemantic/ui/static/assets/index-Bh-YPoVm.js rename to sidemantic/ui/static/assets/index-C0Mo4KDV.js index 50774e24c..284d946fb 100644 --- a/sidemantic/ui/static/assets/index-Bh-YPoVm.js +++ b/sidemantic/ui/static/assets/index-C0Mo4KDV.js @@ -37,7 +37,7 @@ var ib=Object.defineProperty;var ob=(n,e,t)=>e in n?ib(n,e,{enumerable:!0,config `+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{te=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?O(r):""}function re(r){switch(r.tag){case 5:return O(r.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return r=he(r.type,!1),r;case 11:return r=he(r.type.render,!1),r;case 1:return r=he(r.type,!0),r;default:return""}}function pe(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case D:return"Portal";case W:return"Profiler";case G:return"StrictMode";case X:return"Suspense";case oe:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case $:return(r.displayName||"Context")+".Consumer";case Y:return(r._context.displayName||"Context")+".Provider";case ee:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ae:return s=r.displayName||null,s!==null?s:pe(r.type)||"Memo";case se:s=r._payload,r=r._init;try{return pe(r(s))}catch{}}return null}function Ce(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(s);case 8:return s===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Be(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Be(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,p=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,p.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function Es(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Be(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function Et(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function sr(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function us(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function ce(r,s){s=s.checked,s!=null&&R(r,"checked",s,!1)}function Te(r,s){ce(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?Ct(r,s.type,o):s.hasOwnProperty("defaultValue")&&Ct(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function Ct(r,s,o){(s!=="number"||Et(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function ir(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ds.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Cr(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Fr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},na=["Webkit","ms","Moz","O"];Object.keys(Fr).forEach(function(r){na.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Fr[s]=Fr[r]})});function ye(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Fr.hasOwnProperty(r)&&Fr[r]?(""+s).trim():s+"px"}function vt(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=ye(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var Us=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function rn(r,s){if(s){if(Us[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function Ps(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yi=null;function fs(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var vc=null,$s=null,zs=null;function wf(r){if(r=yo(r)){if(typeof vc!="function")throw Error(t(280));var s=r.stateNode;s&&(s=ja(s),vc(r.stateNode,r.type,s))}}function Sf(r){$s?zs?zs.push(r):zs=[r]:$s=r}function _f(){if($s){var r=$s,s=zs;if(zs=$s=null,wf(r),s)for(r=0;r>>=0,r===0?32:31-(w0(r)/S0|0)|0}var aa=64,la=4194304;function qi(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function ca(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,p=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=qi(S):(p&=y,p!==0&&(l=qi(p)))}else y=o&~d,y!==0?l=qi(y):p!==0&&(l=qi(p));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,p=s&-s,d>=p||d===16&&(p&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function Zi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-wn(s),r[s]=o}function k0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=oo),qf=" ",Zf=!1;function Xf(r,s){switch(r){case"keyup":return ex.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eh(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Hs=!1;function nx(r,s){switch(r){case"compositionend":return eh(s);case"keypress":return s.which!==32?null:(Zf=!0,qf);case"textInput":return r=s.data,r===qf&&Zf?null:r;default:return null}}function rx(r,s){if(Hs)return r==="compositionend"||!Ec&&Xf(r,s)?(r=Hf(),pa=Cc=Er=null,Hs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=ah(o)}}function ch(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?ch(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function uh(){for(var r=window,s=Et();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=Et(r.document)}return s}function Uc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function fx(r){var s=uh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&ch(o.ownerDocument.documentElement,o)){if(l!==null&&Uc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,p=Math.min(l.start,d);l=l.end===void 0?p:Math.min(l.end,d),!r.extend&&p>l&&(d=l,l=p,p=d),d=lh(o,p);var y=lh(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),p>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Gs=null,Pc=null,uo=null,$c=!1;function dh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;$c||Gs==null||Gs!==Et(l)||(l=Gs,"selectionStart"in l&&Uc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),uo&&co(uo,l)||(uo=l,l=Sa(Pc,"onSelect"),0qs||(r.current=Xc[qs],Xc[qs]=null,qs--)}function qe(r,s){qs++,Xc[qs]=r.current,r.current=s}var Pr={},jt=Ur(Pr),Rt=Ur(!1),ms=Pr;function Zs(r,s){var o=r.type.contextTypes;if(!o)return Pr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},p;for(p in o)d[p]=s[p];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function ka(){et(Rt),et(jt)}function kh(r,s,o){if(jt.current!==Pr)throw Error(t(168));qe(jt,s),qe(Rt,o)}function Ih(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ce(r)||"Unknown",d));return H({},o,l)}function Ia(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Pr,ms=jt.current,qe(jt,r),qe(Rt,Rt.current),!0}function Mh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Ih(r,s,ms),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(jt),qe(jt,r)):et(Rt),qe(Rt,o)}var ar=null,Ma=!1,eu=!1;function Dh(r){ar===null?ar=[r]:ar.push(r)}function Nx(r){Ma=!0,Dh(r)}function $r(){if(!eu&&ar!==null){eu=!0;var r=0,s=Ge;try{var o=ar;for(Ge=1;r>=y,d-=y,lr=1<<32-wn(s)+d|o<Me?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,U[Me],Z);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze,ve=wt}if(Me===U.length)return o(E,ve),rt&&gs(E,Me),fe;if(ve===null){for(;MeMe?(wt=ve,ve=null):wt=ve.sibling;var Jr=K(E,ve,ze.value,Z);if(Jr===null){ve===null&&(ve=wt);break}r&&ve&&Jr.alternate===null&&s(E,ve),k=p(Jr,k,Me),ge===null?fe=Jr:ge.sibling=Jr,ge=Jr,ve=wt}if(ze.done)return o(E,ve),rt&&gs(E,Me),fe;if(ve===null){for(;!ze.done;Me++,ze=U.next())ze=q(E,ze.value,Z),ze!==null&&(k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze);return rt&&gs(E,Me),fe}for(ve=l(E,ve);!ze.done;Me++,ze=U.next())ze=ie(ve,E,Me,ze.value,Z),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?Me:ze.key),k=p(ze,k,Me),ge===null?fe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(sb){return s(E,sb)}),rt&&gs(E,Me),fe}function ut(E,k,U,Z){if(typeof U=="object"&&U!==null&&U.type===L&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case B:e:{for(var fe=U.key,ge=k;ge!==null;){if(ge.key===fe){if(fe=U.type,fe===L){if(ge.tag===7){o(E,ge.sibling),k=d(ge,U.props.children),k.return=E,E=k;break e}}else if(ge.elementType===fe||typeof fe=="object"&&fe!==null&&fe.$$typeof===se&&Bh(fe)===ge.type){o(E,ge.sibling),k=d(ge,U.props),k.ref=go(E,ge,U),k.return=E,E=k;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}U.type===L?(k=js(U.props.children,E.mode,Z,U.key),k.return=E,E=k):(Z=nl(U.type,U.key,U.props,null,E.mode,Z),Z.ref=go(E,k,U),Z.return=E,E=Z)}return y(E);case D:e:{for(ge=U.key;k!==null;){if(k.key===ge)if(k.tag===4&&k.stateNode.containerInfo===U.containerInfo&&k.stateNode.implementation===U.implementation){o(E,k.sibling),k=d(k,U.children||[]),k.return=E,E=k;break e}else{o(E,k);break}else s(E,k);k=k.sibling}k=qu(U,E.mode,Z),k.return=E,E=k}return y(E);case se:return ge=U._init,ut(E,k,ge(U._payload),Z)}if(Un(U))return ue(E,k,U,Z);if(Q(U))return de(E,k,U,Z);Oa(E,U)}return typeof U=="string"&&U!==""||typeof U=="number"?(U=""+U,k!==null&&k.tag===6?(o(E,k.sibling),k=d(k,U),k.return=E,E=k):(o(E,k),k=Ju(U,E.mode,Z),k.return=E,E=k),y(E)):o(E,k)}return ut}var ni=Eh(!0),Rh=Eh(!1),Ta=Ur(null),Aa=null,ri=null,ou=null;function au(){ou=ri=Aa=null}function lu(r){var s=Ta.current;et(Ta),r._currentValue=s}function cu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function si(r,s){Aa=r,ou=ri=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function an(r){var s=r._currentValue;if(ou!==r)if(r={context:r,memoizedValue:s,next:null},ri===null){if(Aa===null)throw Error(t(308));ri=r,Aa.dependencies={lanes:0,firstContext:r}}else ri=ri.next=r;return s}var vs=null;function uu(r){vs===null?vs=[r]:vs.push(r)}function Lh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,uu(s)):(o.next=d.next,d.next=o),s.interleaved=o,ur(r,l)}function ur(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var zr=!1;function du(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Uh(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function dr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Vr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,ur(r,o)}return d=l.interleaved,d===null?(s.next=s,uu(l)):(s.next=d.next,d.next=s),l.interleaved=s,ur(r,o)}function Ba(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,jc(r,o)}}function Ph(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,p=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};p===null?d=p=y:p=p.next=y,o=o.next}while(o!==null);p===null?d=p=s:p=p.next=s}else d=p=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:p,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ea(r,s,o,l){var d=r.updateQueue;zr=!1;var p=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,z=j.next;j.next=null,y===null?p=z:y.next=z,y=j;var J=r.alternate;J!==null&&(J=J.updateQueue,S=J.lastBaseUpdate,S!==y&&(S===null?J.firstBaseUpdate=z:S.next=z,J.lastBaseUpdate=j))}if(p!==null){var q=d.baseState;y=0,J=z=j=null,S=p;do{var K=S.lane,ie=S.eventTime;if((l&K)===K){J!==null&&(J=J.next={eventTime:ie,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,ie=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){q=ue.call(ie,q,K);break e}q=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(ie,q,K):ue,K==null)break e;q=H({},q,K);break e;case 2:zr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else ie={eventTime:ie,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},J===null?(z=J=ie,j=q):J=J.next=ie,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(J===null&&(j=q),d.baseState=j,d.firstBaseUpdate=z,d.lastBaseUpdate=J,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else p===null&&(d.shared.lanes=0);ws|=y,r.lanes=y,r.memoizedState=q}}function $h(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=yu.transition;yu.transition={};try{r(!1),s()}finally{Ge=o,yu.transition=l}}function op(){return ln().memoizedState}function Mx(r,s,o){var l=Yr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},ap(r))lp(s,o);else if(o=Lh(r,s,o,l),o!==null){var d=Ot();In(o,r,l,d),cp(o,s,l)}}function Dx(r,s,o){var l=Yr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(ap(r))lp(s,d);else{var p=r.alternate;if(r.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var y=s.lastRenderedState,S=p(y,o);if(d.hasEagerState=!0,d.eagerState=S,Sn(S,y)){var j=s.interleaved;j===null?(d.next=d,uu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Lh(r,s,d,l),o!==null&&(d=Ot(),In(o,r,l,d),cp(o,s,l))}}function ap(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function lp(r,s){wo=Ua=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function cp(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,jc(r,o)}}var za={readContext:an,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Cx={readContext:an,useCallback:function(r,s){return Vn().memoizedState=[r,s===void 0?null:s],r},useContext:an,useEffect:Zh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Pa(4194308,4,tp.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Pa(4194308,4,r,s)},useInsertionEffect:function(r,s){return Pa(4,2,r,s)},useMemo:function(r,s){var o=Vn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Vn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Mx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Vn();return r={current:r},s.memoizedState=r},useState:Jh,useDebugValue:_u,useDeferredValue:function(r){return Vn().memoizedState=r},useTransition:function(){var r=Jh(!1),s=r[0];return r=Ix.bind(null,r[1]),Vn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Vn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(bs&30)!==0||Hh(l,s,o)}d.memoizedState=o;var p={value:o,getSnapshot:s};return d.queue=p,Zh(Yh.bind(null,l,p,r),[r]),l.flags|=2048,No(9,Gh.bind(null,l,p,o,s),void 0,null),o},useId:function(){var r=Vn(),s=bt.identifierPrefix;if(rt){var o=cr,l=lr;o=(l&~(1<<32-wn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=So++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[$n]=s,r[mo]=l,Dp(r,s,!1,!1),s.stateNode=r;e:{switch(y=Ps(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;dci&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304)}else{if(!l)if(r=Ra(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),jo(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!rt)return It(s),null}else 2*ct()-p.renderingStartTime>ci&&o!==1073741824&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304);p.isBackwards?(y.sibling=s.child,s.child=y):(o=p.last,o!==null?o.sibling=y:s.child=y,p.last=y)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(It(s),null);case 22:case 23:return Yu(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(It(s),s.subtreeFlags&6&&(s.flags|=8192)):It(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Lx(r,s){switch(nu(s),s.tag){case 1:return Lt(s.type)&&ka(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ii(),et(Rt),et(jt),mu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return hu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));ti()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ii(),null;case 10:return lu(s.type._context),null;case 22:case 23:return Yu(),null;case 24:return null;default:return null}}var Ga=!1,Mt=!1,Ux=typeof WeakSet=="function"?WeakSet:Set,le=null;function ai(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Bu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Op=!1;function Px(r,s){if(Yc=fa,r=uh(),Uc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{o.nodeType,p.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,z=0,J=0,q=r,K=null;t:for(;;){for(var ie;q!==o||d!==0&&q.nodeType!==3||(S=y+d),q!==p||l!==0&&q.nodeType!==3||(j=y+l),q.nodeType===3&&(y+=q.nodeValue.length),(ie=q.firstChild)!==null;)K=q,q=ie;for(;;){if(q===r)break t;if(K===o&&++z===d&&(S=y),K===p&&++J===l&&(j=y),(ie=q.nextSibling)!==null)break;q=K,K=q.parentNode}q=ie}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(Qc={focusedElem:r,selectionRange:o},fa=!1,le=s;le!==null;)if(s=le,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,le=r;else for(;le!==null;){s=le;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,k=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:Nn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var U=s.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Z){lt(s,s.return,Z)}if(r=s.sibling,r!==null){r.return=s.return,le=r;break}le=s.return}return ue=Op,Op=!1,ue}function ko(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var p=d.destroy;d.destroy=void 0,p!==void 0&&Bu(s,o,p)}d=d.next}while(d!==l)}}function Ya(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Eu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Tp(r){var s=r.alternate;s!==null&&(r.alternate=null,Tp(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[$n],delete s[mo],delete s[Zc],delete s[Sx],delete s[_x])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ap(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ap(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Ru(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Na));else if(l!==4&&(r=r.child,r!==null))for(Ru(r,s,o),r=r.sibling;r!==null;)Ru(r,s,o),r=r.sibling}function Lu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for(Lu(r,s,o),r=r.sibling;r!==null;)Lu(r,s,o),r=r.sibling}var _t=null,jn=!1;function Wr(r,s,o){for(o=o.child;o!==null;)Ep(r,s,o),o=o.sibling}function Ep(r,s,o){if(Pn&&typeof Pn.onCommitFiberUnmount=="function")try{Pn.onCommitFiberUnmount(oa,o)}catch{}switch(o.tag){case 5:Mt||ai(o,s);case 6:var l=_t,d=jn;_t=null,Wr(r,s,o),_t=l,jn=d,_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):_t.removeChild(o.stateNode));break;case 18:_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?qc(r.parentNode,o):r.nodeType===1&&qc(r,o),ro(r)):qc(_t,o.stateNode));break;case 4:l=_t,d=jn,_t=o.stateNode.containerInfo,jn=!0,Wr(r,s,o),_t=l,jn=d;break;case 0:case 11:case 14:case 15:if(!Mt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var p=d,y=p.destroy;p=p.tag,y!==void 0&&((p&2)!==0||(p&4)!==0)&&Bu(o,s,y),d=d.next}while(d!==l)}Wr(r,s,o);break;case 1:if(!Mt&&(ai(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Wr(r,s,o);break;case 21:Wr(r,s,o);break;case 22:o.mode&1?(Mt=(l=Mt)||o.memoizedState!==null,Wr(r,s,o),Mt=l):Wr(r,s,o);break;default:Wr(r,s,o)}}function Rp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Ux),s.forEach(function(l){var d=Kx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function kn(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~p}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zx(l/1960))-l,10r?16:r,Gr===null)var l=!1;else{if(r=Gr,Gr=null,Za=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,le=r.current;le!==null;){var p=le,y=p.child;if((le.flags&16)!==0){var S=p.deletions;if(S!==null){for(var j=0;jct()-$u?_s(r,0):Pu|=o),$t(r,s)}function Jp(r,s){s===0&&((r.mode&1)===0?s=1:(s=la,la<<=1,(la&130023424)===0&&(la=4194304)));var o=Ot();r=ur(r,s),r!==null&&(Zi(r,s,o),$t(r,o))}function Qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),Jp(r,o)}function Kx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),Jp(r,o)}var qp;qp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ex(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Ch(s,Ca,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Ha(r,s),r=s.pendingProps;var d=Zs(s,jt.current);si(s,o),d=vu(null,s,l,r,d,o);var p=xu();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(p=!0,Ia(s)):p=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,du(s),d.updater=Va,s.stateNode=d,d._reactInternals=s,ju(s,l,r,o),s=Du(null,s,l,!0,p,o)):(s.tag=0,rt&&p&&tu(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Ha(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=qx(l),r=Nn(l,r),d){case 0:s=Mu(null,s,l,r,o);break e;case 1:s=_p(null,s,l,r,o);break e;case 11:s=vp(null,s,l,r,o);break e;case 14:s=xp(null,s,l,Nn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Mu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),_p(r,s,l,d,o);case 3:e:{if(Np(s),r===null)throw Error(t(387));l=s.pendingProps,p=s.memoizedState,d=p.element,Uh(r,s),Ea(s,l,null,o);var y=s.memoizedState;if(l=y.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){d=oi(Error(t(423)),s),s=jp(r,s,l,o,d);break e}else if(l!==d){d=oi(Error(t(424)),s),s=jp(r,s,l,o,d);break e}else for(qt=Lr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,_n=null,o=Rh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ti(),l===d){s=fr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return zh(s),r===null&&su(s),l=s.type,d=s.pendingProps,p=r!==null?r.memoizedProps:null,y=d.children,Kc(l,d)?y=null:p!==null&&Kc(l,p)&&(s.flags|=32),Sp(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&su(s),null;case 13:return kp(r,s,o);case 4:return fu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=ni(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),vp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,p=s.memoizedProps,y=d.value,qe(Ta,l._currentValue),l._currentValue=y,p!==null)if(Sn(p.value,y)){if(p.children===d.children&&!Rt.current){s=fr(r,s,o);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){y=p.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(p.tag===1){j=dr(-1,o&-o),j.tag=2;var z=p.updateQueue;if(z!==null){z=z.shared;var J=z.pending;J===null?j.next=j:(j.next=J.next,J.next=j),z.pending=j}}p.lanes|=o,j=p.alternate,j!==null&&(j.lanes|=o),cu(p.return,o,s),S.lanes|=o;break}j=j.next}}else if(p.tag===10)y=p.type===s.type?null:p.child;else if(p.tag===18){if(y=p.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),cu(y,o,s),y=p.sibling}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===s){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,si(s,o),d=an(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=Nn(l,s.pendingProps),d=Nn(l.type,d),xp(r,s,l,d,o);case 15:return bp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Ha(r,s),s.tag=1,Lt(l)?(r=!0,Ia(s)):r=!1,si(s,o),dp(s,l,d),ju(s,l,d,o),Du(null,s,l,!0,r,o);case 19:return Mp(r,s,o);case 22:return wp(r,s,o)}throw Error(t(156,s.tag))};function Zp(r,s){return Ff(r,s)}function Jx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(r,s,o,l){return new Jx(r,s,o,l)}function Ku(r){return r=r.prototype,!(!r||!r.isReactComponent)}function qx(r){if(typeof r=="function")return Ku(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ee)return 11;if(r===ae)return 14}return 2}function Kr(r,s){var o=r.alternate;return o===null?(o=un(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function nl(r,s,o,l,d,p){var y=2;if(l=r,typeof r=="function")Ku(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return js(o.children,d,p,s);case G:y=8,d|=8;break;case W:return r=un(12,o,s,d|2),r.elementType=W,r.lanes=p,r;case X:return r=un(13,o,s,d),r.elementType=X,r.lanes=p,r;case oe:return r=un(19,o,s,d),r.elementType=oe,r.lanes=p,r;case ne:return rl(o,d,p,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Y:y=10;break e;case $:y=9;break e;case ee:y=11;break e;case ae:y=14;break e;case se:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=un(y,o,s,d),s.elementType=r,s.type=l,s.lanes=p,s}function js(r,s,o,l){return r=un(7,r,l,s),r.lanes=o,r}function rl(r,s,o,l){return r=un(22,r,l,s),r.elementType=ne,r.lanes=o,r.stateNode={isHidden:!1},r}function Ju(r,s,o){return r=un(6,r,null,s),r.lanes=o,r}function qu(r,s,o){return s=un(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function Zx(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Nc(0),this.expirationTimes=Nc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nc(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Zu(r,s,o,l,d,p,y,S,j){return r=new Zx(r,s,o,S,j),s===1?(s=1,p===!0&&(s|=8)):s=0,p=un(3,null,null,s),r.current=p,p.stateNode=r,p.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},du(p),r}function Xx(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),sd.exports=fb(),sd.exports}var fm;function pb(){if(fm)return ul;fm=1;var n=hb();return ul.createRoot=n.createRoot,ul.hydrateRoot=n.hydrateRoot,ul}var mb=pb();function Sr(n){return n.split(".").at(-1)||n}function Fn(n,e){const t=Sr(n);if(e.filter(a=>Sr(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const er="\0__null__";function yb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wy(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").toLowerCase();if(e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||e.type==="ratio")return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:e.maximumFractionDigits??1,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const c=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:e.maximumFractionDigits??2,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function gb(n,e={}){return wy(n,{...e,compact:!0,maximumFractionDigits:e.maximumFractionDigits??1})}function vb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function rs(n){return n===er||n===""?"—":n}function Le(n){return yb(n)}function pt(n,e={}){return wy(n,e)}function Gt(n,e={}){return gb(n,e)}function Sy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function xb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function bb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Sy(i)}}function wb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Sy(t)}}function _y(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Qn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Sb(n){if(n.mode==="contains")return`contains ${Qn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${rs(e[0])}`:e.length<=2?`${t} ${e.map(rs).join(", ")}`:`${t} ${e.length} values`}const ad=n=>n.public!==!1,Ny=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function jy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Ny.test(t.name))}function _b(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(h=>h.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const h of a){const[m]=h.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const h of e)h.metrics.some(m=>m.name===c)&&t.add(h.name);return t}function ky(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of _b(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Nb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,type:h.type||"categorical",granularity:h.granularity,supportedGranularities:h.supported_granularities,format:h.format})),c=(i.metrics??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,agg:h.agg,type:h.type,format:h.format})),f=jy(a,i.default_time_dimension);return{name:i.name,label:Le(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ad).map(i=>({ref:i.name,name:i.name,ownerModel:ky(i,e),baseMetric:i.base_metric,label:i.label||Le(i.name),description:i.description,type:i.type,format:i.format}));return{models:e,graphMetrics:t,dialect:n.dialect}}function jb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m),type:Ny.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m)})),h=jy(c);return{name:a.name,label:Le(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:h,defaultGrain:(h==null?void 0:h.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:ky(a,t),baseMetric:a.base_metric,label:Le(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function kb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function Di(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function Oe(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function h(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(h,m)}g((i=i.apply(n,e||[])).next())})}function hm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Zn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),h("next"),h("throw"),h("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function h(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,V){c.push([w,C,T,V])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function wl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function _i(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof hm=="function"?hm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(h,m){f=n[c](f),a(h,m,f.done,f.value)})}}function a(c,f,h,m){Promise.resolve(m).then(function(g){c({value:g,done:h})},f)}}const Ib=new TextDecoder("utf-8"),Id=n=>Ib.decode(n),Mb=new TextEncoder,Vd=n=>Mb.encode(n),Db=n=>typeof n=="number",Cb=n=>typeof n=="boolean",Tt=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Wo=n=>En(n)&&Tt(n.then),dc=n=>En(n)&&Tt(n[Symbol.iterator]),Wd=n=>En(n)&&Tt(n[Symbol.asyncIterator]),Md=n=>En(n)&&En(n.schema),Iy=n=>En(n)&&"done"in n&&"value"in n,My=n=>En(n)&&Tt(n.stat)&&Db(n.fd),Dy=n=>En(n)&&Hd(n.body),Cy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Hd=n=>En(n)&&Tt(n.cancel)&&Tt(n.getReader)&&!Cy(n),Fy=n=>En(n)&&Tt(n.read)&&Tt(n.pipe)&&Cb(n.readable)&&!Cy(n),Fb=n=>En(n)&&Tt(n.clear)&&Tt(n.bytes)&&Tt(n.position)&&Tt(n.setPosition)&&Tt(n.capacity)&&Tt(n.getBufferIdentifier)&&Tt(n.createLong),Gd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ob(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,h,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,h=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),mm=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Dd=n=>(n.next(),n);function*Tb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?t(e):dc(e)?e:t(e);return yield*Dd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Ab=n=>Tb(Uint8Array,n);function Oy(n,e){return Zn(this,arguments,function*(){if(Wo(e))return yield Ae(yield Ae(yield*wl(_i(Oy(n,yield Ae(e))))));const i=function(f){return Zn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(Dd((function*(h){let m=null;do m=h.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?i(e):dc(e)?a(e):Wd(e)?e:i(e);return yield Ae(yield*wl(_i(Dd((function(f){return Zn(this,arguments,function*(){let h=null;do h=yield Ae(f.next(yield yield Ae(Ke(n,h))));while(!h.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Bb=n=>Oy(Uint8Array,n);function Eb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Rb(n){let e,t=!1,i=[],a,c,f,h=0;function m(){return c==="peek"?tr(i,f)[0]:([a,i,h]=tr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Ab(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-h)?g.next():g.next(f-h),!e&&a.byteLength>0&&(i.push(a),h+=a.byteLength),e||f<=h)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h0&&(a.push(Pe(c)),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Oe(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Oe(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const ld=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function $b(n){return Zn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,h,m=0,g=[],v;function x(){return f==="peek"?tr(g,h)[0]:([v,g,m]=tr(g,h),v)}if({cmd:f,size:h}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=ld(n,"end"),t[1]=ld(n,"error");do{if(t[2]=ld(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(h-m)?(v=Pe(n.read(h-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||h<=m)do({cmd:f,size:h}=yield yield Ae(x()));while(h{for(const[V,P]of w)n.off(V,P);try{const V=n.destroy;V&&V.call(n,_),_=void 0}catch(V){_=V||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Dt;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var xn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(xn||(xn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var nr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(nr||(nr={}));const cd=2,Kn=4,br=4,He=4,es=new Int32Array(2),ym=new Float32Array(es.buffer),gm=new Float64Array(es.buffer),fl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Cd||(Cd={}));let Ci=class Ty{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ty(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ym[0]=t,this.writeInt32(e,es[0])}writeFloat64(e,t){gm[0]=t,this.writeInt32(e,es[fl?0:1]),this.writeInt32(e+4,es[fl?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*cd;this.addInt16(c);let f=0;const h=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Kn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let Nm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let hn=class Il{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new wr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Il).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Gn=class mr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Fi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new hn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Fi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return mr.startSchema(e),mr.addEndianness(e,t),mr.addFields(e,i),mr.addCustomMetadata(e,a),mr.addFeatures(e,c),mr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var M;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(M||(M={}));var gr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(gr||(gr={}));const zb=void 0;function Ho(n){if(n===null)return"null";if(n===zb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Ho(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Ly(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Vb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Vb]=!0;Ln.prototype.toJSON=function(){return`"${Yo(this)}"`};Ln.prototype.valueOf=function(n){return Uy(this,n)};Ln.prototype.toString=function(){return Yo(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return Uy(this);case"string":return Yo(this);case"default":return Gb(this)}return Yo(this)};function Ni(...n){return Ln.apply(this,n)}function ji(...n){return Ln.apply(this,n)}function Go(...n){return Ln.apply(this,n)}Object.setPrototypeOf(Ni.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ji.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Go.prototype,Object.create(Uint32Array.prototype));Object.assign(Ni.prototype,Ln.prototype,{constructor:Ni,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ji.prototype,Ln.prototype,{constructor:ji,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Go.prototype,Ln.prototype,{constructor:Go,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Wb=BigInt(4294967296)*BigInt(4294967296),Hb=Wb-BigInt(1);function Uy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),h=c&&f.at(-1)&BigInt(1)<=0)return ud(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ss extends me{constructor(){super(M.Null)}toString(){return"Null"}}$y=Symbol.toStringTag;ss[$y]=(n=>n[Symbol.toStringTag]="Null")(ss.prototype);class Cs extends me{constructor(e,t){super(M.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}zy=Symbol.toStringTag;Cs[zy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Cs.prototype);class Qo extends Cs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});class Al extends me{constructor(e){super(M.Float),this.precision=e}get ArrayType(){switch(this.precision){case Dt.HALF:return Uint16Array;case Dt.SINGLE:return Float32Array;case Dt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Vy=Symbol.toStringTag;Al[Vy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Al.prototype);class Bl extends me{constructor(){super(M.Binary)}toString(){return"Binary"}}Wy=Symbol.toStringTag;Bl[Wy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Bl.prototype);class El extends me{constructor(){super(M.LargeBinary)}toString(){return"LargeBinary"}}Hy=Symbol.toStringTag;El[Hy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(El.prototype);class Rl extends me{constructor(){super(M.Utf8)}toString(){return"Utf8"}}Gy=Symbol.toStringTag;Rl[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Rl.prototype);class Ll extends me{constructor(){super(M.LargeUtf8)}toString(){return"LargeUtf8"}}Yy=Symbol.toStringTag;Ll[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(Ll.prototype);class Ul extends me{constructor(){super(M.Bool)}toString(){return"Bool"}}Qy=Symbol.toStringTag;Ul[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Ul.prototype);class Pl extends me{constructor(e,t,i=128){super(M.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Ky=Symbol.toStringTag;Pl[Ky]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Pl.prototype);class $l extends me{constructor(e){super(M.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${xn[this.unit]}>`}get ArrayType(){return this.unit===xn.DAY?Int32Array:BigInt64Array}}Jy=Symbol.toStringTag;$l[Jy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))($l.prototype);class zl extends me{constructor(e,t){super(M.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}qy=Symbol.toStringTag;zl[qy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(zl.prototype);class Vl extends me{constructor(e,t){super(M.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Zy=Symbol.toStringTag;Vl[Zy]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Vl.prototype);class Wl extends me{constructor(e){super(M.Interval),this.unit=e}toString(){return`Interval<${nr[this.unit]}>`}}Xy=Symbol.toStringTag;Wl[Xy]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Wl.prototype);class Hl extends me{constructor(e){super(M.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}eg=Symbol.toStringTag;Hl[eg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Hl.prototype);class Gl extends me{constructor(e){super(M.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}tg=Symbol.toStringTag;Gl[tg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Gl.prototype);class At extends me{constructor(e){super(M.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ng=Symbol.toStringTag;At[ng]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(At.prototype);class Yl extends me{constructor(e,t,i){super(M.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}rg=Symbol.toStringTag;Yl[rg]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(Yl.prototype);class Ql extends me{constructor(e){super(M.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}sg=Symbol.toStringTag;Ql[sg]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Ql.prototype);class Kl extends me{constructor(e,t){super(M.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ig=Symbol.toStringTag;Kl[ig]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Kl.prototype);class Jl extends me{constructor(e,t=!1){var i,a,c;if(super(M.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const h=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];h&&(h.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}og=Symbol.toStringTag;Jl[og]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(Jl.prototype);const Yb=(n=>()=>++n)(-1);class Oi extends me{constructor(e,t,i,a){super(M.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Yb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ag=Symbol.toStringTag;Oi[ag]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Oi.prototype);function vr(n){const e=n;switch(n.typeId){case M.Decimal:return n.bitWidth/32;case M.Interval:return 1+e.unit;case M.FixedSizeList:return e.listSize;case M.FixedSizeBinary:return e.byteWidth;default:return 1}}class Ue{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return xi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Qb(n,e,t=!0){return typeof e=="number"?xi(n,e,t):typeof e=="string"&&e in M?xi(n,M[e],t):e&&e instanceof me?xi(n,jm(e),t):e!=null&&e.type&&e.type instanceof me?xi(n,jm(e.type),t):xi(n,M.NONE,t)}function xi(n,e,t=!0){let i=null;switch(e){case M.Null:i=n.visitNull;break;case M.Bool:i=n.visitBool;break;case M.Int:i=n.visitInt;break;case M.Int8:i=n.visitInt8||n.visitInt;break;case M.Int16:i=n.visitInt16||n.visitInt;break;case M.Int32:i=n.visitInt32||n.visitInt;break;case M.Int64:i=n.visitInt64||n.visitInt;break;case M.Uint8:i=n.visitUint8||n.visitInt;break;case M.Uint16:i=n.visitUint16||n.visitInt;break;case M.Uint32:i=n.visitUint32||n.visitInt;break;case M.Uint64:i=n.visitUint64||n.visitInt;break;case M.Float:i=n.visitFloat;break;case M.Float16:i=n.visitFloat16||n.visitFloat;break;case M.Float32:i=n.visitFloat32||n.visitFloat;break;case M.Float64:i=n.visitFloat64||n.visitFloat;break;case M.Utf8:i=n.visitUtf8;break;case M.LargeUtf8:i=n.visitLargeUtf8;break;case M.Binary:i=n.visitBinary;break;case M.LargeBinary:i=n.visitLargeBinary;break;case M.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case M.Date:i=n.visitDate;break;case M.DateDay:i=n.visitDateDay||n.visitDate;break;case M.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case M.Timestamp:i=n.visitTimestamp;break;case M.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case M.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case M.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case M.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case M.Time:i=n.visitTime;break;case M.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case M.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case M.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case M.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case M.Decimal:i=n.visitDecimal;break;case M.List:i=n.visitList;break;case M.Struct:i=n.visitStruct;break;case M.Union:i=n.visitUnion;break;case M.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case M.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case M.Dictionary:i=n.visitDictionary;break;case M.Interval:i=n.visitInterval;break;case M.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case M.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case M.Duration:i=n.visitDuration;break;case M.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case M.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case M.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case M.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case M.FixedSizeList:i=n.visitFixedSizeList;break;case M.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${M[e]}'`)}function jm(n){switch(n.typeId){case M.Null:return M.Null;case M.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?M.Int8:M.Uint8;case 16:return t?M.Int16:M.Uint16;case 32:return t?M.Int32:M.Uint32;case 64:return t?M.Int64:M.Uint64}return M.Int}case M.Float:switch(n.precision){case Dt.HALF:return M.Float16;case Dt.SINGLE:return M.Float32;case Dt.DOUBLE:return M.Float64}return M.Float;case M.Binary:return M.Binary;case M.LargeBinary:return M.LargeBinary;case M.Utf8:return M.Utf8;case M.LargeUtf8:return M.LargeUtf8;case M.Bool:return M.Bool;case M.Decimal:return M.Decimal;case M.Time:switch(n.unit){case _e.SECOND:return M.TimeSecond;case _e.MILLISECOND:return M.TimeMillisecond;case _e.MICROSECOND:return M.TimeMicrosecond;case _e.NANOSECOND:return M.TimeNanosecond}return M.Time;case M.Timestamp:switch(n.unit){case _e.SECOND:return M.TimestampSecond;case _e.MILLISECOND:return M.TimestampMillisecond;case _e.MICROSECOND:return M.TimestampMicrosecond;case _e.NANOSECOND:return M.TimestampNanosecond}return M.Timestamp;case M.Date:switch(n.unit){case xn.DAY:return M.DateDay;case xn.MILLISECOND:return M.DateMillisecond}return M.Date;case M.Interval:switch(n.unit){case nr.DAY_TIME:return M.IntervalDayTime;case nr.YEAR_MONTH:return M.IntervalYearMonth}return M.Interval;case M.Duration:switch(n.unit){case _e.SECOND:return M.DurationSecond;case _e.MILLISECOND:return M.DurationMillisecond;case _e.MICROSECOND:return M.DurationMicrosecond;case _e.NANOSECOND:return M.DurationNanosecond}return M.Duration;case M.Map:return M.Map;case M.List:return M.List;case M.Struct:return M.Struct;case M.Union:switch(n.mode){case Yt.Dense:return M.DenseUnion;case Yt.Sparse:return M.SparseUnion}return M.Union;case M.FixedSizeBinary:return M.FixedSizeBinary;case M.FixedSizeList:return M.FixedSizeList;case M.Dictionary:return M.Dictionary}throw new Error(`Unrecognized type '${M[n.typeId]}'`)}Ue.prototype.visitInt8=null;Ue.prototype.visitInt16=null;Ue.prototype.visitInt32=null;Ue.prototype.visitInt64=null;Ue.prototype.visitUint8=null;Ue.prototype.visitUint16=null;Ue.prototype.visitUint32=null;Ue.prototype.visitUint64=null;Ue.prototype.visitFloat16=null;Ue.prototype.visitFloat32=null;Ue.prototype.visitFloat64=null;Ue.prototype.visitDateDay=null;Ue.prototype.visitDateMillisecond=null;Ue.prototype.visitTimestampSecond=null;Ue.prototype.visitTimestampMillisecond=null;Ue.prototype.visitTimestampMicrosecond=null;Ue.prototype.visitTimestampNanosecond=null;Ue.prototype.visitTimeSecond=null;Ue.prototype.visitTimeMillisecond=null;Ue.prototype.visitTimeMicrosecond=null;Ue.prototype.visitTimeNanosecond=null;Ue.prototype.visitDenseUnion=null;Ue.prototype.visitSparseUnion=null;Ue.prototype.visitIntervalDayTime=null;Ue.prototype.visitIntervalYearMonth=null;Ue.prototype.visitDuration=null;Ue.prototype.visitDurationSecond=null;Ue.prototype.visitDurationMillisecond=null;Ue.prototype.visitDurationMicrosecond=null;Ue.prototype.visitDurationNanosecond=null;const lg=new Float64Array(1),di=new Uint32Array(lg.buffer);function cg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Kb(n){if(n!==n)return 32256;lg[0]=n;const e=(di[1]&2147483648)>>16&65535;let t=di[1]&2146435072,i=0;return t>=1089470464?di[0]>0?t=31744:(t=(t&2080374784)>>16,i=(di[1]&1048575)>>10):t<=1056964608?(i=1048576+(di[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(di[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Ue{}function Ie(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Jb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},ug=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Qd=({values:n},e,t)=>{n[e]=t},dg=({values:n},e,t)=>{n[e]=Kb(t)},Zb=(n,e,t)=>{switch(n.type.precision){case Dt.HALF:return dg(n,e,t);case Dt.SINGLE:case Dt.DOUBLE:return Qd(n,e,t)}},fg=({values:n},e,t)=>{Jb(n,e,t.valueOf())},hg=({values:n},e,t)=>{n[e]=BigInt(t)},Xb=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},pg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,i),mg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,Vd(i)),ew=(n,e,t)=>{n.type.unit===xn.DAY?fg(n,e,t):hg(n,e,t)},yg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},gg=({values:n},e,t)=>{n[e]=BigInt(t)},vg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},tw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return yg(n,e,t);case _e.MILLISECOND:return gg(n,e,t);case _e.MICROSECOND:return vg(n,e,t);case _e.NANOSECOND:return xg(n,e,t)}},bg=({values:n},e,t)=>{n[e]=t},wg=({values:n},e,t)=>{n[e]=t},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},nw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return bg(n,e,t);case _e.MILLISECOND:return wg(n,e,t);case _e.MICROSECOND:return Sg(n,e,t);case _e.NANOSECOND:return _g(n,e,t)}},rw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},sw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=bn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,h=a[e],m=a[e+1];h{const i=n.children[0],{valueOffsets:a}=n,c=bn.getVisitFn(i);let{[e]:f,[e+1]:h}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=h)break},ow=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),aw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),uw=(n,e,t)=>{const i=n.type.children.map(c=>bn.getVisitFn(c.type)),a=t instanceof Map?lw(e,t):t instanceof Je?aw(e,t):Array.isArray(t)?ow(e,t):cw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},dw=(n,e,t)=>{n.type.mode===Yt.Dense?Ng(n,e,t):jg(n,e,t)},Ng=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,n.valueOffsets[e],t)},jg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,e,t)},fw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},hw=(n,e,t)=>{n.type.unit===nr.DAY_TIME?kg(n,e,t):Ig(n,e,t)},kg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Ig=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Mg=({values:n},e,t)=>{n[e]=t},Dg=({values:n},e,t)=>{n[e]=t},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},pw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Mg(n,e,t);case _e.MILLISECOND:return Dg(n,e,t);case _e.MICROSECOND:return Cg(n,e,t);case _e.NANOSECOND:return Fg(n,e,t)}},mw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=bn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,h=e*i;++f`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new yw(this[On],this[ki])}}class yw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[ki]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(bn.visit(e[On].children[a],e[ki],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Ue{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const vw=(n,e)=>864e5*n[e],xw=(n,e)=>null,Og=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},bw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<vw(n,e),Ag=({values:n},e)=>tt(n[e]),as=({stride:n,values:e},t)=>e[n*t],ww=({stride:n,values:e},t)=>cg(e[n*t]),Bg=({values:n},e)=>n[e],Sw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Eg=({values:n,valueOffsets:e},t)=>Og(n,e,t),Rg=({values:n,valueOffsets:e},t)=>{const i=Og(n,e,t);return i!==null?Id(i):null},_w=({values:n},e)=>n[e],Nw=({type:n,values:e},t)=>n.precision!==Dt.HALF?e[t]:cg(e[t]),jw=(n,e)=>n.type.unit===xn.DAY?Tg(n,e):Ag(n,e),Lg=({values:n},e)=>1e3*tt(n[e]),Ug=({values:n},e)=>tt(n[e]),Pg=({values:n},e)=>Ly(n[e],BigInt(1e3)),$g=({values:n},e)=>Ly(n[e],BigInt(1e6)),kw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Lg(n,e);case _e.MILLISECOND:return Ug(n,e);case _e.MICROSECOND:return Pg(n,e);case _e.NANOSECOND:return $g(n,e)}},zg=({values:n},e)=>n[e],Vg=({values:n},e)=>n[e],Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Iw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return zg(n,e);case _e.MILLISECOND:return Vg(n,e);case _e.MICROSECOND:return Wg(n,e);case _e.NANOSECOND:return Hg(n,e)}},Mw=({values:n,stride:e},t)=>Yd.decimal(n.subarray(e*t,e*(t+1))),Dw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Cw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new Jd(f.slice(a,c-a))},Fw=(n,e)=>new Kd(n,e),Ow=(n,e)=>n.type.mode===Yt.Dense?Gg(n,e):Yg(n,e),Gg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Yg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Tw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Aw=(n,e)=>n.type.unit===nr.DAY_TIME?Qg(n,e):Kg(n,e),Qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Kg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Jg=({values:n},e)=>n[e],qg=({values:n},e)=>n[e],Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],Bw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Jg(n,e);case _e.MILLISECOND:return qg(n,e);case _e.MICROSECOND:return Zg(n,e);case _e.NANOSECOND:return Xg(n,e)}},Ew=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(xw);xe.prototype.visitBool=je(bw);xe.prototype.visitInt=je(_w);xe.prototype.visitInt8=je(as);xe.prototype.visitInt16=je(as);xe.prototype.visitInt32=je(as);xe.prototype.visitInt64=je(Bg);xe.prototype.visitUint8=je(as);xe.prototype.visitUint16=je(as);xe.prototype.visitUint32=je(as);xe.prototype.visitUint64=je(Bg);xe.prototype.visitFloat=je(Nw);xe.prototype.visitFloat16=je(ww);xe.prototype.visitFloat32=je(as);xe.prototype.visitFloat64=je(as);xe.prototype.visitUtf8=je(Rg);xe.prototype.visitLargeUtf8=je(Rg);xe.prototype.visitBinary=je(Eg);xe.prototype.visitLargeBinary=je(Eg);xe.prototype.visitFixedSizeBinary=je(Sw);xe.prototype.visitDate=je(jw);xe.prototype.visitDateDay=je(Tg);xe.prototype.visitDateMillisecond=je(Ag);xe.prototype.visitTimestamp=je(kw);xe.prototype.visitTimestampSecond=je(Lg);xe.prototype.visitTimestampMillisecond=je(Ug);xe.prototype.visitTimestampMicrosecond=je(Pg);xe.prototype.visitTimestampNanosecond=je($g);xe.prototype.visitTime=je(Iw);xe.prototype.visitTimeSecond=je(zg);xe.prototype.visitTimeMillisecond=je(Vg);xe.prototype.visitTimeMicrosecond=je(Wg);xe.prototype.visitTimeNanosecond=je(Hg);xe.prototype.visitDecimal=je(Mw);xe.prototype.visitList=je(Dw);xe.prototype.visitStruct=je(Fw);xe.prototype.visitUnion=je(Ow);xe.prototype.visitDenseUnion=je(Gg);xe.prototype.visitSparseUnion=je(Yg);xe.prototype.visitDictionary=je(Tw);xe.prototype.visitInterval=je(Aw);xe.prototype.visitIntervalDayTime=je(Qg);xe.prototype.visitIntervalYearMonth=je(Kg);xe.prototype.visitDuration=je(Bw);xe.prototype.visitDurationSecond=je(Jg);xe.prototype.visitDurationMillisecond=je(qg);xe.prototype.visitDurationMicrosecond=je(Zg);xe.prototype.visitDurationNanosecond=je(Xg);xe.prototype.visitFixedSizeList=je(Ew);xe.prototype.visitMap=je(Cw);const Qt=new xe,bi=Symbol.for("keys"),Ii=Symbol.for("vals"),wi=Symbol.for("kKeysAsStrings"),Td=Symbol.for("_kKeysAsStrings");class Jd{constructor(e){return this[bi]=new Je([e.children[0]]).memoize(),this[Ii]=e.children[1],new Proxy(this,new Lw)}get[wi](){return this[Td]||(this[Td]=Array.from(this[bi].toArray(),String))}[Symbol.iterator](){return new Rw(this[bi],this[Ii])}get size(){return this[bi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[bi],t=this[Ii],i={};for(let a=-1,c=e.length;++a`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Rw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Lw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[wi]}has(e,t){return e[wi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[wi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[wi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ii),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[wi].indexOf(t);return a!==-1?(bn.visit(Reflect.get(e,Ii),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(Jd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ii]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Td]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let km;function ev(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const qd=(n,e)=>n<0?e+n:n,Im=n=>n!==n;function Li(n){if(typeof n!=="object"||n===null)return Im(n)?Im:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Eb(n,t):!1:n instanceof Map?Pw(n):Array.isArray(n)?Uw(n):n instanceof Je?$w(n):zw(n,!0)}function Uw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Vw(n,t);case Map:return Mm(n,t,t.keys());case Jd:case Kd:case Object:case void 0:return Mm(n,t,e||Object.keys(t))}return t instanceof Je?Ww(n,t):!1}}function Vw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Dm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ad(new Zd(t,n,e,null,tv)).subarray(0,i)),a}return t}function Ad(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Zd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Gw(n,a>>3,i-a>>3)}function Gw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=dd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=dd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=dd(c.getUint8(a)),a+=1;return i}function dd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Yw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,h)=>f+h.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Yw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],h){this.type=e,this.children=f,this.dictionary=h,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=vr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+h+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Dm(f,h,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,h=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,h*e,h*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===M.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Dm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[gr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[gr.TYPE])&&(f[gr.TYPE]=c.subarray(e,e+t)),(c=f[gr.OFFSET])&&(f[gr.OFFSET]=c.subarray(e,e+t+1))||(c=f[gr.DATA])&&(f[gr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Ue{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:h=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,h,[void 0,void 0,void 0,c],a);const m=Oo(e.valueOffsets);return new Ye(t,i,f,h,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:h=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}}const Qw=new Vo;function Re(n){return Qw.visit(n)}class Cm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function nv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function rv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function sv(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(h);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(h.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function Xd(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function qw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Zd(t,n.offset+(e||0),n.length,t,tv)){if(!a)return i;++i}return-1}function De(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case M.Union:break;case M.Dictionary:break;default:return qw(n,t)}const i=Qt.getVisitFn(n),a=Li(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Cm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new Zw(f)})}class Zw{constructor(e){this.vector=e,this.index=0}next(){return this.indexh.data):e;if(c.length===0||c.some(h=>!(h instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:h,set:m,indexOf:g}=cv[f.typeId],v=c[0];this.isValid=x=>ef(v,x),this.get=x=>h(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,uv[f.typeId]),this._offsets=rv(c);break}this.data=c,this.type=f,this.stride=vr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Kw(this.data)}get nullCount(){return nv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${M[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return tf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(ev(this,e,t,({data:i,_offsets:a},c,f)=>sv(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case M.Int:case M.Float:case M.Decimal:case M.Time:case M.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:h,length:m})=>(f.array.set(h.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new Xl(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new Xl(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}lv=Symbol.toStringTag;Je[lv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(M).map(t=>M[t]).filter(t=>typeof t=="number"&&t!==M.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=bn.getVisitFnByTypeId(t),c=Zl.getVisitFnByTypeId(t);cv[t]={get:i,set:a,indexOf:c},uv[t]=Object.create(n,{isValid:{value:ql(ef)},get:{value:ql(Qt.getVisitFnByTypeId(t))},set:{value:iv(bn.getVisitFnByTypeId(t))},indexOf:{value:ov(Zl.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class Xl extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const h=c[f];if(h!==void 0)return h;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,h){i.call(this,f,h),c[f]=h}}),Object.defineProperty(this,"slice",{value:(f,h)=>new Xl(a.call(this,f,h))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ed{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Gn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Rd(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=hl(hl(new Map,this.metadata),t.metadata),c=t.fields.filter(h=>{const m=i.findIndex(g=>g.name===h.name);return~m?(i[m]=h.clone({metadata:hl(hl(new Map,i[m].metadata),h.metadata)}))&&!1:!0}),f=Rd(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function hl(n,e){return new Map([...n||new Map,...e||new Map])}function Rd(n,e=new Map){for(let t=-1,i=n.length;++t0&&Rd(c.children,e)}return e}var Xw=Ay,e1=Ci;class nf{static decode(e){e=new e1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new t1(i,t)}static encode(e){const t=new Xw,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ti.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ti.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return pn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return pn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Oe(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Oe(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class r1 extends n1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Id(this.toUint8Array(!0)):this.toUint8Array(!1).then(Id)}toUint8Array(e=!1){return e?tr(this._values)[0]:Oe(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let h=0;try{for(var m=!0,g=_i(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),h+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return tr(f,h)[0]})}}class ec{constructor(e){e&&(this.source=new s1(pn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Ai{constructor(e){e instanceof Ai?this.source=e.source:e instanceof r1?this.source=new ks(pn.fromAsyncIterable(e)):Fy(e)?this.source=new ks(pn.fromNodeStream(e)):Hd(e)?this.source=new ks(pn.fromDOMStream(e)):Dy(e)?this.source=new ks(pn.fromDOMStream(e.body)):dc(e)?this.source=new ks(pn.fromIterable(e)):Wo(e)?this.source=new ks(pn.fromAsyncIterable(e)):Wd(e)&&(this.source=new ks(pn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class s1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class ks{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Oe(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Oe(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Oe(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Om extends ec{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Si(this.buffer[3])} ${Si(this.buffer[2])} ${Si(this.buffer[1])} ${Si(this.buffer[0])}`}static multiply(e,t){return new Yn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Yn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Yn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Yn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Yn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class o1 extends hv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ad(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===xn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Yn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?a1(i[t]):me.isBool(e)?Ad(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Vd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function a1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Ue{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Bs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function hc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function l1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function sf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function qo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function Zo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function c1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function u1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function of(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&is.compareManyFields(n.children,e.children)}function d1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&is.visit(n.indices,e.indices)&&is.visit(n.dictionary,e.dictionary)}function af(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function f1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Bs;Se.prototype.visitBool=Bs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=hc;Se.prototype.visitFloat16=hc;Se.prototype.visitFloat32=hc;Se.prototype.visitFloat64=hc;Se.prototype.visitUtf8=Bs;Se.prototype.visitLargeUtf8=Bs;Se.prototype.visitBinary=Bs;Se.prototype.visitLargeBinary=Bs;Se.prototype.visitFixedSizeBinary=l1;Se.prototype.visitDate=sf;Se.prototype.visitDateDay=sf;Se.prototype.visitDateMillisecond=sf;Se.prototype.visitTimestamp=qo;Se.prototype.visitTimestampSecond=qo;Se.prototype.visitTimestampMillisecond=qo;Se.prototype.visitTimestampMicrosecond=qo;Se.prototype.visitTimestampNanosecond=qo;Se.prototype.visitTime=Zo;Se.prototype.visitTimeSecond=Zo;Se.prototype.visitTimeMillisecond=Zo;Se.prototype.visitTimeMicrosecond=Zo;Se.prototype.visitTimeNanosecond=Zo;Se.prototype.visitDecimal=Bs;Se.prototype.visitList=c1;Se.prototype.visitStruct=u1;Se.prototype.visitUnion=of;Se.prototype.visitDenseUnion=of;Se.prototype.visitSparseUnion=of;Se.prototype.visitDictionary=d1;Se.prototype.visitInterval=af;Se.prototype.visitIntervalDayTime=af;Se.prototype.visitIntervalYearMonth=af;Se.prototype.visitDuration=Xo;Se.prototype.visitDurationSecond=Xo;Se.prototype.visitDurationMillisecond=Xo;Se.prototype.visitDurationMicrosecond=Xo;Se.prototype.visitDurationNanosecond=Xo;Se.prototype.visitFixedSizeList=f1;Se.prototype.visitMap=h1;const is=new Se;function p1(n,e){return is.compareSchemas(n,e)}function fd(n,e){return m1(n,e.map(t=>t.data.concat()))}function m1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,h=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,h=-1;++h0&&(i[c++]=Re({type:new At(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function y1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let h=-1,m=i.length;++h=e)v===e?t[h]=g:(t[h]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[h].unshift(g.slice(e,v-e))));else{const x=n[h];n[h]=x.clone({nullable:!0}),t[h]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Re({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var pv;class gn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof gn)return m.batches;if(m instanceof Ye){if(m.type instanceof At)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=fd(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},h=e.flatMap(m=>f(m));if(a=(i=a??((t=h[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of h){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!p1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=h,this._offsets=c??rv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=nv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?tf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+p.stack}return{value:r,source:s,stack:d,digest:null}}function ku(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Iu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Tx=typeof WeakMap=="function"?WeakMap:Map;function hp(r,s,o){o=dr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Ja||(Ja=!0,zu=l),Iu(r,s)},o}function pp(r,s,o){o=dr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Iu(r,s)}}var p=r.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(o.callback=function(){Iu(r,s),typeof l!="function"&&(Hr===null?Hr=new Set([this]):Hr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function mp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Tx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Yx.bind(null,r,s,o),s.then(r,r))}function yp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function gp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=dr(-1,1),s.tag=2,Vr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Ax=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Rh(s,null,o,l):ni(s,r.child,o,l)}function vp(r,s,o,l,d){o=o.render;var p=s.ref;return si(s,d),l=vu(r,s,o,l,p,d),o=xu(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,fr(r,s,d)):(rt&&o&&tu(s),s.flags|=1,Ft(r,s,l,d),s.child)}function xp(r,s,o,l,d){if(r===null){var p=o.type;return typeof p=="function"&&!Ku(p)&&p.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=p,bp(r,s,p,l,d)):(r=nl(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(p=r.child,(r.lanes&d)===0){var y=p.memoizedProps;if(o=o.compare,o=o!==null?o:co,o(y,l)&&r.ref===s.ref)return fr(r,s,d)}return s.flags|=1,r=Kr(p,l),r.ref=s.ref,r.return=s,s.child=r}function bp(r,s,o,l,d){if(r!==null){var p=r.memoizedProps;if(co(p,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=p,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,fr(r,s,d)}return Mu(r,s,o,l,d)}function wp(r,s,o){var l=s.pendingProps,d=l.children,p=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(li,Zt),Zt|=o;else{if((o&1073741824)===0)return r=p!==null?p.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(li,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=p!==null?p.baseLanes:o,qe(li,Zt),Zt|=l}else p!==null?(l=p.baseLanes|o,s.memoizedState=null):l=o,qe(li,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function Sp(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Mu(r,s,o,l,d){var p=Lt(o)?ms:jt.current;return p=Zs(s,p),si(s,d),o=vu(r,s,o,l,p,d),l=xu(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,fr(r,s,d)):(rt&&l&&tu(s),s.flags|=1,Ft(r,s,o,d),s.child)}function _p(r,s,o,l,d){if(Lt(o)){var p=!0;Ia(s)}else p=!1;if(si(s,d),s.stateNode===null)Ha(r,s),dp(s,o,l),ju(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,z=o.contextType;typeof z=="object"&&z!==null?z=an(z):(z=Lt(o)?ms:jt.current,z=Zs(s,z));var J=o.getDerivedStateFromProps,q=typeof J=="function"||typeof y.getSnapshotBeforeUpdate=="function";q||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==z)&&fp(s,y,l,z),zr=!1;var K=s.memoizedState;y.state=K,Ea(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||zr?(typeof J=="function"&&(Nu(s,o,J,l),j=s.memoizedState),(S=zr||up(s,o,S,l,K,j,z))?(q||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=z,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Uh(r,s),S=s.memoizedProps,z=s.type===s.elementType?S:Nn(s.type,S),y.props=z,q=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=an(j):(j=Lt(o)?ms:jt.current,j=Zs(s,j));var ie=o.getDerivedStateFromProps;(J=typeof ie=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==q||K!==j)&&fp(s,y,l,j),zr=!1,K=s.memoizedState,y.state=K,Ea(s,l,y,d);var ue=s.memoizedState;S!==q||K!==ue||Rt.current||zr?(typeof ie=="function"&&(Nu(s,o,ie,l),ue=s.memoizedState),(z=zr||up(s,o,z,l,K,ue,j)||!1)?(J||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=z):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Du(r,s,o,l,p,d)}function Du(r,s,o,l,d,p){Sp(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Mh(s,o,!1),fr(r,s,p);l=s.stateNode,Ax.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=ni(s,r.child,null,p),s.child=ni(s,null,S,p)):Ft(r,s,S,p),s.memoizedState=l.state,d&&Mh(s,o,!0),s.child}function Np(r){var s=r.stateNode;s.pendingContext?kh(r,s.pendingContext,s.pendingContext!==s.context):s.context&&kh(r,s.context,!1),fu(r,s.containerInfo)}function jp(r,s,o,l,d){return ti(),iu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Cu={dehydrated:null,treeContext:null,retryLane:0};function Fu(r){return{baseLanes:r,cachePool:null,transitions:null}}function kp(r,s,o){var l=s.pendingProps,d=it.current,p=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(p=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return su(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,p?(l=s.mode,p=s.child,y={mode:"hidden",children:y},(l&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=y):p=rl(y,l,0,null),r=js(r,l,o,null),p.return=s,r.return=s,p.sibling=r,s.child=p,s.child.memoizedState=Fu(o),s.memoizedState=Cu,r):Ou(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Bx(r,s,y,l,S,d,o);if(p){p=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Kr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?p=Kr(S,p):(p=js(p,y,o,null),p.flags|=2),p.return=s,l.return=s,l.sibling=p,s.child=l,l=p,p=s.child,y=r.child.memoizedState,y=y===null?Fu(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},p.memoizedState=y,p.childLanes=r.childLanes&~o,s.memoizedState=Cu,l}return p=r.child,r=p.sibling,l=Kr(p,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Ou(r,s){return s=rl({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Wa(r,s,o,l){return l!==null&&iu(l),ni(s,r.child,null,o),r=Ou(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Bx(r,s,o,l,d,p,y){if(o)return s.flags&256?(s.flags&=-257,l=ku(Error(t(422))),Wa(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(p=l.fallback,d=s.mode,l=rl({mode:"visible",children:l.children},d,0,null),p=js(p,d,y,null),p.flags|=2,l.return=s,p.return=s,l.sibling=p,s.child=l,(s.mode&1)!==0&&ni(s,r.child,null,y),s.child.memoizedState=Fu(y),s.memoizedState=Cu,p);if((s.mode&1)===0)return Wa(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,p=Error(t(419)),l=ku(p,l,void 0),Wa(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==p.retryLane&&(p.retryLane=d,ur(r,d),In(l,r,d,-1))}return Qu(),l=ku(Error(t(421))),Wa(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=Qx.bind(null,r),d._reactRetry=s,null):(r=p.treeContext,qt=Lr(d.nextSibling),Jt=s,rt=!0,_n=null,r!==null&&(sn[on++]=lr,sn[on++]=cr,sn[on++]=ys,lr=r.id,cr=r.overflow,ys=s),s=Ou(s,l.children),s.flags|=4096,s)}function Ip(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),cu(r.return,s,o)}function Tu(r,s,o,l,d){var p=r.memoizedState;p===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=l,p.tail=o,p.tailMode=d)}function Mp(r,s,o){var l=s.pendingProps,d=l.revealOrder,p=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ip(r,o,s);else if(r.tag===19)Ip(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Ra(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Tu(s,!1,d,o,p);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Ra(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Tu(s,!0,o,null,p);break;case"together":Tu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Ha(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function fr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),ws|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Kr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Kr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function Ex(r,s,o){switch(s.tag){case 3:Np(s),ti();break;case 5:zh(s);break;case 1:Lt(s.type)&&Ia(s);break;case 4:fu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ta,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?kp(r,s,o):(qe(it,it.current&1),r=fr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Mp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,wp(r,s,o)}return fr(r,s,o)}var Dp,Au,Cp,Fp;Dp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Au=function(){},Cp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,xs(zn.current);var p=null;switch(o){case"input":d=sr(r,d),l=sr(r,l),p=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),p=[];break;case"textarea":d=Rs(r,d),l=Rs(r,l),p=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Na)}rn(o,l);var y;o=null;for(z in d)if(!l.hasOwnProperty(z)&&d.hasOwnProperty(z)&&d[z]!=null)if(z==="style"){var S=d[z];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else z!=="dangerouslySetInnerHTML"&&z!=="children"&&z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&z!=="autoFocus"&&(a.hasOwnProperty(z)?p||(p=[]):(p=p||[]).push(z,null));for(z in l){var j=l[z];if(S=d!=null?d[z]:void 0,l.hasOwnProperty(z)&&j!==S&&(j!=null||S!=null))if(z==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(p||(p=[]),p.push(z,o)),o=j;else z==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(p=p||[]).push(z,j)):z==="children"?typeof j!="string"&&typeof j!="number"||(p=p||[]).push(z,""+j):z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&(a.hasOwnProperty(z)?(j!=null&&z==="onScroll"&&Xe("scroll",r),p||S===j||(p=[])):(p=p||[]).push(z,j))}o&&(p=p||[]).push("style",o);var z=p;(s.updateQueue=z)&&(s.flags|=4)}},Fp=function(r,s,o,l){o!==l&&(s.flags|=4)};function jo(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function It(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function Rx(r,s,o){var l=s.pendingProps;switch(nu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(s),null;case 1:return Lt(s.type)&&ka(),It(s),null;case 3:return l=s.stateNode,ii(),et(Rt),et(jt),mu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Fa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,_n!==null&&(Hu(_n),_n=null))),Au(r,s),It(s),null;case 5:hu(s);var d=xs(bo.current);if(o=s.type,r!==null&&s.stateNode!=null)Cp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return It(s),null}if(r=xs(zn.current),Fa(s)){l=s.stateNode,o=s.type;var p=s.memoizedProps;switch(l[$n]=s,l[mo]=p,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[$n]=s,r[mo]=l,Dp(r,s,!1,!1),s.stateNode=r;e:{switch(y=Ps(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;dci&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304)}else{if(!l)if(r=Ra(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),jo(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!rt)return It(s),null}else 2*ct()-p.renderingStartTime>ci&&o!==1073741824&&(s.flags|=128,l=!0,jo(p,!1),s.lanes=4194304);p.isBackwards?(y.sibling=s.child,s.child=y):(o=p.last,o!==null?o.sibling=y:s.child=y,p.last=y)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(It(s),null);case 22:case 23:return Yu(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(It(s),s.subtreeFlags&6&&(s.flags|=8192)):It(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Lx(r,s){switch(nu(s),s.tag){case 1:return Lt(s.type)&&ka(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ii(),et(Rt),et(jt),mu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return hu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));ti()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ii(),null;case 10:return lu(s.type._context),null;case 22:case 23:return Yu(),null;case 24:return null;default:return null}}var Ga=!1,Mt=!1,Ux=typeof WeakSet=="function"?WeakSet:Set,le=null;function ai(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Bu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Op=!1;function Px(r,s){if(Yc=fa,r=uh(),Uc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{o.nodeType,p.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,z=0,J=0,q=r,K=null;t:for(;;){for(var ie;q!==o||d!==0&&q.nodeType!==3||(S=y+d),q!==p||l!==0&&q.nodeType!==3||(j=y+l),q.nodeType===3&&(y+=q.nodeValue.length),(ie=q.firstChild)!==null;)K=q,q=ie;for(;;){if(q===r)break t;if(K===o&&++z===d&&(S=y),K===p&&++J===l&&(j=y),(ie=q.nextSibling)!==null)break;q=K,K=q.parentNode}q=ie}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(Qc={focusedElem:r,selectionRange:o},fa=!1,le=s;le!==null;)if(s=le,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,le=r;else for(;le!==null;){s=le;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,k=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:Nn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var U=s.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Z){lt(s,s.return,Z)}if(r=s.sibling,r!==null){r.return=s.return,le=r;break}le=s.return}return ue=Op,Op=!1,ue}function ko(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var p=d.destroy;d.destroy=void 0,p!==void 0&&Bu(s,o,p)}d=d.next}while(d!==l)}}function Ya(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Eu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Tp(r){var s=r.alternate;s!==null&&(r.alternate=null,Tp(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[$n],delete s[mo],delete s[Zc],delete s[Sx],delete s[_x])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ap(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ap(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Ru(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Na));else if(l!==4&&(r=r.child,r!==null))for(Ru(r,s,o),r=r.sibling;r!==null;)Ru(r,s,o),r=r.sibling}function Lu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for(Lu(r,s,o),r=r.sibling;r!==null;)Lu(r,s,o),r=r.sibling}var _t=null,jn=!1;function Wr(r,s,o){for(o=o.child;o!==null;)Ep(r,s,o),o=o.sibling}function Ep(r,s,o){if(Pn&&typeof Pn.onCommitFiberUnmount=="function")try{Pn.onCommitFiberUnmount(oa,o)}catch{}switch(o.tag){case 5:Mt||ai(o,s);case 6:var l=_t,d=jn;_t=null,Wr(r,s,o),_t=l,jn=d,_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):_t.removeChild(o.stateNode));break;case 18:_t!==null&&(jn?(r=_t,o=o.stateNode,r.nodeType===8?qc(r.parentNode,o):r.nodeType===1&&qc(r,o),ro(r)):qc(_t,o.stateNode));break;case 4:l=_t,d=jn,_t=o.stateNode.containerInfo,jn=!0,Wr(r,s,o),_t=l,jn=d;break;case 0:case 11:case 14:case 15:if(!Mt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var p=d,y=p.destroy;p=p.tag,y!==void 0&&((p&2)!==0||(p&4)!==0)&&Bu(o,s,y),d=d.next}while(d!==l)}Wr(r,s,o);break;case 1:if(!Mt&&(ai(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Wr(r,s,o);break;case 21:Wr(r,s,o);break;case 22:o.mode&1?(Mt=(l=Mt)||o.memoizedState!==null,Wr(r,s,o),Mt=l):Wr(r,s,o);break;default:Wr(r,s,o)}}function Rp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Ux),s.forEach(function(l){var d=Kx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function kn(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~p}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zx(l/1960))-l,10r?16:r,Gr===null)var l=!1;else{if(r=Gr,Gr=null,Za=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,le=r.current;le!==null;){var p=le,y=p.child;if((le.flags&16)!==0){var S=p.deletions;if(S!==null){for(var j=0;jct()-$u?_s(r,0):Pu|=o),$t(r,s)}function Jp(r,s){s===0&&((r.mode&1)===0?s=1:(s=la,la<<=1,(la&130023424)===0&&(la=4194304)));var o=Ot();r=ur(r,s),r!==null&&(Zi(r,s,o),$t(r,o))}function Qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),Jp(r,o)}function Kx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),Jp(r,o)}var qp;qp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ex(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Ch(s,Ca,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Ha(r,s),r=s.pendingProps;var d=Zs(s,jt.current);si(s,o),d=vu(null,s,l,r,d,o);var p=xu();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(p=!0,Ia(s)):p=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,du(s),d.updater=Va,s.stateNode=d,d._reactInternals=s,ju(s,l,r,o),s=Du(null,s,l,!0,p,o)):(s.tag=0,rt&&p&&tu(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Ha(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=qx(l),r=Nn(l,r),d){case 0:s=Mu(null,s,l,r,o);break e;case 1:s=_p(null,s,l,r,o);break e;case 11:s=vp(null,s,l,r,o);break e;case 14:s=xp(null,s,l,Nn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Mu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),_p(r,s,l,d,o);case 3:e:{if(Np(s),r===null)throw Error(t(387));l=s.pendingProps,p=s.memoizedState,d=p.element,Uh(r,s),Ea(s,l,null,o);var y=s.memoizedState;if(l=y.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){d=oi(Error(t(423)),s),s=jp(r,s,l,o,d);break e}else if(l!==d){d=oi(Error(t(424)),s),s=jp(r,s,l,o,d);break e}else for(qt=Lr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,_n=null,o=Rh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ti(),l===d){s=fr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return zh(s),r===null&&su(s),l=s.type,d=s.pendingProps,p=r!==null?r.memoizedProps:null,y=d.children,Kc(l,d)?y=null:p!==null&&Kc(l,p)&&(s.flags|=32),Sp(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&su(s),null;case 13:return kp(r,s,o);case 4:return fu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=ni(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),vp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,p=s.memoizedProps,y=d.value,qe(Ta,l._currentValue),l._currentValue=y,p!==null)if(Sn(p.value,y)){if(p.children===d.children&&!Rt.current){s=fr(r,s,o);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){y=p.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(p.tag===1){j=dr(-1,o&-o),j.tag=2;var z=p.updateQueue;if(z!==null){z=z.shared;var J=z.pending;J===null?j.next=j:(j.next=J.next,J.next=j),z.pending=j}}p.lanes|=o,j=p.alternate,j!==null&&(j.lanes|=o),cu(p.return,o,s),S.lanes|=o;break}j=j.next}}else if(p.tag===10)y=p.type===s.type?null:p.child;else if(p.tag===18){if(y=p.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),cu(y,o,s),y=p.sibling}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===s){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,si(s,o),d=an(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=Nn(l,s.pendingProps),d=Nn(l.type,d),xp(r,s,l,d,o);case 15:return bp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:Nn(l,d),Ha(r,s),s.tag=1,Lt(l)?(r=!0,Ia(s)):r=!1,si(s,o),dp(s,l,d),ju(s,l,d,o),Du(null,s,l,!0,r,o);case 19:return Mp(r,s,o);case 22:return wp(r,s,o)}throw Error(t(156,s.tag))};function Zp(r,s){return Ff(r,s)}function Jx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(r,s,o,l){return new Jx(r,s,o,l)}function Ku(r){return r=r.prototype,!(!r||!r.isReactComponent)}function qx(r){if(typeof r=="function")return Ku(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ee)return 11;if(r===ae)return 14}return 2}function Kr(r,s){var o=r.alternate;return o===null?(o=un(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function nl(r,s,o,l,d,p){var y=2;if(l=r,typeof r=="function")Ku(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return js(o.children,d,p,s);case G:y=8,d|=8;break;case W:return r=un(12,o,s,d|2),r.elementType=W,r.lanes=p,r;case X:return r=un(13,o,s,d),r.elementType=X,r.lanes=p,r;case oe:return r=un(19,o,s,d),r.elementType=oe,r.lanes=p,r;case ne:return rl(o,d,p,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Y:y=10;break e;case $:y=9;break e;case ee:y=11;break e;case ae:y=14;break e;case se:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=un(y,o,s,d),s.elementType=r,s.type=l,s.lanes=p,s}function js(r,s,o,l){return r=un(7,r,l,s),r.lanes=o,r}function rl(r,s,o,l){return r=un(22,r,l,s),r.elementType=ne,r.lanes=o,r.stateNode={isHidden:!1},r}function Ju(r,s,o){return r=un(6,r,null,s),r.lanes=o,r}function qu(r,s,o){return s=un(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function Zx(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Nc(0),this.expirationTimes=Nc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nc(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Zu(r,s,o,l,d,p,y,S,j){return r=new Zx(r,s,o,S,j),s===1?(s=1,p===!0&&(s|=8)):s=0,p=un(3,null,null,s),r.current=p,p.stateNode=r,p.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},du(p),r}function Xx(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),sd.exports=fb(),sd.exports}var fm;function pb(){if(fm)return ul;fm=1;var n=hb();return ul.createRoot=n.createRoot,ul.hydrateRoot=n.hydrateRoot,ul}var mb=pb();function Sr(n){return n.split(".").at(-1)||n}function Fn(n,e){const t=Sr(n);if(e.filter(a=>Sr(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const er="\0__null__";function yb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wy(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),h=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(h===void 0?a||e.compact?1:2:Math.min(h,20)),g=h===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:h,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function gb(n,e={}){return wy(n,{...e,compact:!0})}function vb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function rs(n){return n===er||n===""?"—":n}function Le(n){return yb(n)}function pt(n,e={}){return wy(n,e)}function Gt(n,e={}){return gb(n,e)}function Sy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function xb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function bb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Sy(i)}}function wb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Sy(t)}}function _y(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Qn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Sb(n){if(n.mode==="contains")return`contains ${Qn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${rs(e[0])}`:e.length<=2?`${t} ${e.map(rs).join(", ")}`:`${t} ${e.length} values`}const ad=n=>n.public!==!1,Ny=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function jy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Ny.test(t.name))}function _b(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(h=>h.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const h of a){const[m]=h.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const h of e)h.metrics.some(m=>m.name===c)&&t.add(h.name);return t}function ky(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of _b(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Nb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,type:h.type||"categorical",granularity:h.granularity,supportedGranularities:h.supported_granularities,format:h.format??h.value_format_name})),c=(i.metrics??[]).filter(ad).map(h=>({ref:`${i.name}.${h.name}`,name:h.name,model:i.name,label:h.label||Le(h.name),description:h.description,agg:h.agg,type:h.type,format:h.format??h.value_format_name})),f=jy(a,i.default_time_dimension);return{name:i.name,label:Le(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ad).map(i=>({ref:i.name,name:i.name,ownerModel:ky(i,e),baseMetric:i.base_metric,label:i.label||Le(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function jb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m),type:Ny.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Le(m)})),h=jy(c);return{name:a.name,label:Le(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:h,defaultGrain:(h==null?void 0:h.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:ky(a,t),baseMetric:a.base_metric,label:Le(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function kb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function Di(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function Oe(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function h(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(h,m)}g((i=i.apply(n,e||[])).next())})}function hm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Zn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),h("next"),h("throw"),h("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function h(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,V){c.push([w,C,T,V])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function wl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function _i(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof hm=="function"?hm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(h,m){f=n[c](f),a(h,m,f.done,f.value)})}}function a(c,f,h,m){Promise.resolve(m).then(function(g){c({value:g,done:h})},f)}}const Ib=new TextDecoder("utf-8"),Id=n=>Ib.decode(n),Mb=new TextEncoder,Vd=n=>Mb.encode(n),Db=n=>typeof n=="number",Cb=n=>typeof n=="boolean",Tt=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Wo=n=>En(n)&&Tt(n.then),dc=n=>En(n)&&Tt(n[Symbol.iterator]),Wd=n=>En(n)&&Tt(n[Symbol.asyncIterator]),Md=n=>En(n)&&En(n.schema),Iy=n=>En(n)&&"done"in n&&"value"in n,My=n=>En(n)&&Tt(n.stat)&&Db(n.fd),Dy=n=>En(n)&&Hd(n.body),Cy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Hd=n=>En(n)&&Tt(n.cancel)&&Tt(n.getReader)&&!Cy(n),Fy=n=>En(n)&&Tt(n.read)&&Tt(n.pipe)&&Cb(n.readable)&&!Cy(n),Fb=n=>En(n)&&Tt(n.clear)&&Tt(n.bytes)&&Tt(n.position)&&Tt(n.setPosition)&&Tt(n.capacity)&&Tt(n.getBufferIdentifier)&&Tt(n.createLong),Gd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ob(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,h,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,h=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),mm=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Dd=n=>(n.next(),n);function*Tb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?t(e):dc(e)?e:t(e);return yield*Dd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Ab=n=>Tb(Uint8Array,n);function Oy(n,e){return Zn(this,arguments,function*(){if(Wo(e))return yield Ae(yield Ae(yield*wl(_i(Oy(n,yield Ae(e))))));const i=function(f){return Zn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(Dd((function*(h){let m=null;do m=h.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Gd?i(e):dc(e)?a(e):Wd(e)?e:i(e);return yield Ae(yield*wl(_i(Dd((function(f){return Zn(this,arguments,function*(){let h=null;do h=yield Ae(f.next(yield yield Ae(Ke(n,h))));while(!h.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Bb=n=>Oy(Uint8Array,n);function Eb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Rb(n){let e,t=!1,i=[],a,c,f,h=0;function m(){return c==="peek"?tr(i,f)[0]:([a,i,h]=tr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Ab(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-h)?g.next():g.next(f-h),!e&&a.byteLength>0&&(i.push(a),h+=a.byteLength),e||f<=h)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h0&&(a.push(Pe(c)),m+=c.byteLength),t||h<=m)do({cmd:f,size:h}=yield yield Ae(g()));while(h{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Oe(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Oe(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const ld=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function $b(n){return Zn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,h,m=0,g=[],v;function x(){return f==="peek"?tr(g,h)[0]:([v,g,m]=tr(g,h),v)}if({cmd:f,size:h}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=ld(n,"end"),t[1]=ld(n,"error");do{if(t[2]=ld(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(h-m)?(v=Pe(n.read(h-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||h<=m)do({cmd:f,size:h}=yield yield Ae(x()));while(h{for(const[V,P]of w)n.off(V,P);try{const V=n.destroy;V&&V.call(n,_),_=void 0}catch(V){_=V||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Dt;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Dt||(Dt={}));var xn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(xn||(xn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var nr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(nr||(nr={}));const cd=2,Kn=4,br=4,He=4,es=new Int32Array(2),ym=new Float32Array(es.buffer),gm=new Float64Array(es.buffer),fl=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Cd||(Cd={}));let Ci=class Ty{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ty(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ym[0]=t,this.writeInt32(e,es[0])}writeFloat64(e,t){gm[0]=t,this.writeInt32(e,es[fl?0:1]),this.writeInt32(e+4,es[fl?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*cd;this.addInt16(c);let f=0;const h=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Kn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let Nm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let hn=class Il{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Il).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new wr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Il).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Gn=class mr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new mr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Fi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new hn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Fi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return mr.startSchema(e),mr.addEndianness(e,t),mr.addFields(e,i),mr.addCustomMetadata(e,a),mr.addFeatures(e,c),mr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var M;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(M||(M={}));var gr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(gr||(gr={}));const zb=void 0;function Ho(n){if(n===null)return"null";if(n===zb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Ho(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Ly(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Vb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Vb]=!0;Ln.prototype.toJSON=function(){return`"${Yo(this)}"`};Ln.prototype.valueOf=function(n){return Uy(this,n)};Ln.prototype.toString=function(){return Yo(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return Uy(this);case"string":return Yo(this);case"default":return Gb(this)}return Yo(this)};function Ni(...n){return Ln.apply(this,n)}function ji(...n){return Ln.apply(this,n)}function Go(...n){return Ln.apply(this,n)}Object.setPrototypeOf(Ni.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ji.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Go.prototype,Object.create(Uint32Array.prototype));Object.assign(Ni.prototype,Ln.prototype,{constructor:Ni,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ji.prototype,Ln.prototype,{constructor:ji,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Go.prototype,Ln.prototype,{constructor:Go,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Wb=BigInt(4294967296)*BigInt(4294967296),Hb=Wb-BigInt(1);function Uy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),h=c&&f.at(-1)&BigInt(1)<=0)return ud(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ss extends me{constructor(){super(M.Null)}toString(){return"Null"}}$y=Symbol.toStringTag;ss[$y]=(n=>n[Symbol.toStringTag]="Null")(ss.prototype);class Cs extends me{constructor(e,t){super(M.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}zy=Symbol.toStringTag;Cs[zy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Cs.prototype);class Qo extends Cs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});class Al extends me{constructor(e){super(M.Float),this.precision=e}get ArrayType(){switch(this.precision){case Dt.HALF:return Uint16Array;case Dt.SINGLE:return Float32Array;case Dt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Vy=Symbol.toStringTag;Al[Vy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Al.prototype);class Bl extends me{constructor(){super(M.Binary)}toString(){return"Binary"}}Wy=Symbol.toStringTag;Bl[Wy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Bl.prototype);class El extends me{constructor(){super(M.LargeBinary)}toString(){return"LargeBinary"}}Hy=Symbol.toStringTag;El[Hy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(El.prototype);class Rl extends me{constructor(){super(M.Utf8)}toString(){return"Utf8"}}Gy=Symbol.toStringTag;Rl[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))(Rl.prototype);class Ll extends me{constructor(){super(M.LargeUtf8)}toString(){return"LargeUtf8"}}Yy=Symbol.toStringTag;Ll[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(Ll.prototype);class Ul extends me{constructor(){super(M.Bool)}toString(){return"Bool"}}Qy=Symbol.toStringTag;Ul[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Ul.prototype);class Pl extends me{constructor(e,t,i=128){super(M.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Ky=Symbol.toStringTag;Pl[Ky]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Pl.prototype);class $l extends me{constructor(e){super(M.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${xn[this.unit]}>`}get ArrayType(){return this.unit===xn.DAY?Int32Array:BigInt64Array}}Jy=Symbol.toStringTag;$l[Jy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))($l.prototype);class zl extends me{constructor(e,t){super(M.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}qy=Symbol.toStringTag;zl[qy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(zl.prototype);class Vl extends me{constructor(e,t){super(M.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Zy=Symbol.toStringTag;Vl[Zy]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Vl.prototype);class Wl extends me{constructor(e){super(M.Interval),this.unit=e}toString(){return`Interval<${nr[this.unit]}>`}}Xy=Symbol.toStringTag;Wl[Xy]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Wl.prototype);class Hl extends me{constructor(e){super(M.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}eg=Symbol.toStringTag;Hl[eg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Hl.prototype);class Gl extends me{constructor(e){super(M.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}tg=Symbol.toStringTag;Gl[tg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Gl.prototype);class At extends me{constructor(e){super(M.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ng=Symbol.toStringTag;At[ng]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(At.prototype);class Yl extends me{constructor(e,t,i){super(M.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}rg=Symbol.toStringTag;Yl[rg]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(Yl.prototype);class Ql extends me{constructor(e){super(M.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}sg=Symbol.toStringTag;Ql[sg]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Ql.prototype);class Kl extends me{constructor(e,t){super(M.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ig=Symbol.toStringTag;Kl[ig]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Kl.prototype);class Jl extends me{constructor(e,t=!1){var i,a,c;if(super(M.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const h=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];h&&(h.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}og=Symbol.toStringTag;Jl[og]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(Jl.prototype);const Yb=(n=>()=>++n)(-1);class Oi extends me{constructor(e,t,i,a){super(M.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Yb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ag=Symbol.toStringTag;Oi[ag]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Oi.prototype);function vr(n){const e=n;switch(n.typeId){case M.Decimal:return n.bitWidth/32;case M.Interval:return 1+e.unit;case M.FixedSizeList:return e.listSize;case M.FixedSizeBinary:return e.byteWidth;default:return 1}}class Ue{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return xi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Qb(n,e,t=!0){return typeof e=="number"?xi(n,e,t):typeof e=="string"&&e in M?xi(n,M[e],t):e&&e instanceof me?xi(n,jm(e),t):e!=null&&e.type&&e.type instanceof me?xi(n,jm(e.type),t):xi(n,M.NONE,t)}function xi(n,e,t=!0){let i=null;switch(e){case M.Null:i=n.visitNull;break;case M.Bool:i=n.visitBool;break;case M.Int:i=n.visitInt;break;case M.Int8:i=n.visitInt8||n.visitInt;break;case M.Int16:i=n.visitInt16||n.visitInt;break;case M.Int32:i=n.visitInt32||n.visitInt;break;case M.Int64:i=n.visitInt64||n.visitInt;break;case M.Uint8:i=n.visitUint8||n.visitInt;break;case M.Uint16:i=n.visitUint16||n.visitInt;break;case M.Uint32:i=n.visitUint32||n.visitInt;break;case M.Uint64:i=n.visitUint64||n.visitInt;break;case M.Float:i=n.visitFloat;break;case M.Float16:i=n.visitFloat16||n.visitFloat;break;case M.Float32:i=n.visitFloat32||n.visitFloat;break;case M.Float64:i=n.visitFloat64||n.visitFloat;break;case M.Utf8:i=n.visitUtf8;break;case M.LargeUtf8:i=n.visitLargeUtf8;break;case M.Binary:i=n.visitBinary;break;case M.LargeBinary:i=n.visitLargeBinary;break;case M.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case M.Date:i=n.visitDate;break;case M.DateDay:i=n.visitDateDay||n.visitDate;break;case M.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case M.Timestamp:i=n.visitTimestamp;break;case M.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case M.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case M.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case M.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case M.Time:i=n.visitTime;break;case M.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case M.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case M.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case M.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case M.Decimal:i=n.visitDecimal;break;case M.List:i=n.visitList;break;case M.Struct:i=n.visitStruct;break;case M.Union:i=n.visitUnion;break;case M.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case M.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case M.Dictionary:i=n.visitDictionary;break;case M.Interval:i=n.visitInterval;break;case M.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case M.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case M.Duration:i=n.visitDuration;break;case M.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case M.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case M.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case M.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case M.FixedSizeList:i=n.visitFixedSizeList;break;case M.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${M[e]}'`)}function jm(n){switch(n.typeId){case M.Null:return M.Null;case M.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?M.Int8:M.Uint8;case 16:return t?M.Int16:M.Uint16;case 32:return t?M.Int32:M.Uint32;case 64:return t?M.Int64:M.Uint64}return M.Int}case M.Float:switch(n.precision){case Dt.HALF:return M.Float16;case Dt.SINGLE:return M.Float32;case Dt.DOUBLE:return M.Float64}return M.Float;case M.Binary:return M.Binary;case M.LargeBinary:return M.LargeBinary;case M.Utf8:return M.Utf8;case M.LargeUtf8:return M.LargeUtf8;case M.Bool:return M.Bool;case M.Decimal:return M.Decimal;case M.Time:switch(n.unit){case _e.SECOND:return M.TimeSecond;case _e.MILLISECOND:return M.TimeMillisecond;case _e.MICROSECOND:return M.TimeMicrosecond;case _e.NANOSECOND:return M.TimeNanosecond}return M.Time;case M.Timestamp:switch(n.unit){case _e.SECOND:return M.TimestampSecond;case _e.MILLISECOND:return M.TimestampMillisecond;case _e.MICROSECOND:return M.TimestampMicrosecond;case _e.NANOSECOND:return M.TimestampNanosecond}return M.Timestamp;case M.Date:switch(n.unit){case xn.DAY:return M.DateDay;case xn.MILLISECOND:return M.DateMillisecond}return M.Date;case M.Interval:switch(n.unit){case nr.DAY_TIME:return M.IntervalDayTime;case nr.YEAR_MONTH:return M.IntervalYearMonth}return M.Interval;case M.Duration:switch(n.unit){case _e.SECOND:return M.DurationSecond;case _e.MILLISECOND:return M.DurationMillisecond;case _e.MICROSECOND:return M.DurationMicrosecond;case _e.NANOSECOND:return M.DurationNanosecond}return M.Duration;case M.Map:return M.Map;case M.List:return M.List;case M.Struct:return M.Struct;case M.Union:switch(n.mode){case Yt.Dense:return M.DenseUnion;case Yt.Sparse:return M.SparseUnion}return M.Union;case M.FixedSizeBinary:return M.FixedSizeBinary;case M.FixedSizeList:return M.FixedSizeList;case M.Dictionary:return M.Dictionary}throw new Error(`Unrecognized type '${M[n.typeId]}'`)}Ue.prototype.visitInt8=null;Ue.prototype.visitInt16=null;Ue.prototype.visitInt32=null;Ue.prototype.visitInt64=null;Ue.prototype.visitUint8=null;Ue.prototype.visitUint16=null;Ue.prototype.visitUint32=null;Ue.prototype.visitUint64=null;Ue.prototype.visitFloat16=null;Ue.prototype.visitFloat32=null;Ue.prototype.visitFloat64=null;Ue.prototype.visitDateDay=null;Ue.prototype.visitDateMillisecond=null;Ue.prototype.visitTimestampSecond=null;Ue.prototype.visitTimestampMillisecond=null;Ue.prototype.visitTimestampMicrosecond=null;Ue.prototype.visitTimestampNanosecond=null;Ue.prototype.visitTimeSecond=null;Ue.prototype.visitTimeMillisecond=null;Ue.prototype.visitTimeMicrosecond=null;Ue.prototype.visitTimeNanosecond=null;Ue.prototype.visitDenseUnion=null;Ue.prototype.visitSparseUnion=null;Ue.prototype.visitIntervalDayTime=null;Ue.prototype.visitIntervalYearMonth=null;Ue.prototype.visitDuration=null;Ue.prototype.visitDurationSecond=null;Ue.prototype.visitDurationMillisecond=null;Ue.prototype.visitDurationMicrosecond=null;Ue.prototype.visitDurationNanosecond=null;const lg=new Float64Array(1),di=new Uint32Array(lg.buffer);function cg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Kb(n){if(n!==n)return 32256;lg[0]=n;const e=(di[1]&2147483648)>>16&65535;let t=di[1]&2146435072,i=0;return t>=1089470464?di[0]>0?t=31744:(t=(t&2080374784)>>16,i=(di[1]&1048575)>>10):t<=1056964608?(i=1048576+(di[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(di[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Ue{}function Ie(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Jb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},ug=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Qd=({values:n},e,t)=>{n[e]=t},dg=({values:n},e,t)=>{n[e]=Kb(t)},Zb=(n,e,t)=>{switch(n.type.precision){case Dt.HALF:return dg(n,e,t);case Dt.SINGLE:case Dt.DOUBLE:return Qd(n,e,t)}},fg=({values:n},e,t)=>{Jb(n,e,t.valueOf())},hg=({values:n},e,t)=>{n[e]=BigInt(t)},Xb=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},pg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,i),mg=({values:n,valueOffsets:e},t,i)=>ug(n,e,t,Vd(i)),ew=(n,e,t)=>{n.type.unit===xn.DAY?fg(n,e,t):hg(n,e,t)},yg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},gg=({values:n},e,t)=>{n[e]=BigInt(t)},vg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},tw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return yg(n,e,t);case _e.MILLISECOND:return gg(n,e,t);case _e.MICROSECOND:return vg(n,e,t);case _e.NANOSECOND:return xg(n,e,t)}},bg=({values:n},e,t)=>{n[e]=t},wg=({values:n},e,t)=>{n[e]=t},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},nw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return bg(n,e,t);case _e.MILLISECOND:return wg(n,e,t);case _e.MICROSECOND:return Sg(n,e,t);case _e.NANOSECOND:return _g(n,e,t)}},rw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},sw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=bn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,h=a[e],m=a[e+1];h{const i=n.children[0],{valueOffsets:a}=n,c=bn.getVisitFn(i);let{[e]:f,[e+1]:h}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=h)break},ow=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),aw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),uw=(n,e,t)=>{const i=n.type.children.map(c=>bn.getVisitFn(c.type)),a=t instanceof Map?lw(e,t):t instanceof Je?aw(e,t):Array.isArray(t)?ow(e,t):cw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},dw=(n,e,t)=>{n.type.mode===Yt.Dense?Ng(n,e,t):jg(n,e,t)},Ng=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,n.valueOffsets[e],t)},jg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];bn.visit(a,e,t)},fw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},hw=(n,e,t)=>{n.type.unit===nr.DAY_TIME?kg(n,e,t):Ig(n,e,t)},kg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Ig=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Mg=({values:n},e,t)=>{n[e]=t},Dg=({values:n},e,t)=>{n[e]=t},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},pw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Mg(n,e,t);case _e.MILLISECOND:return Dg(n,e,t);case _e.MICROSECOND:return Cg(n,e,t);case _e.NANOSECOND:return Fg(n,e,t)}},mw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=bn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,h=e*i;++f`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new yw(this[On],this[ki])}}class yw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[ki]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(bn.visit(e[On].children[a],e[ki],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Ue{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const vw=(n,e)=>864e5*n[e],xw=(n,e)=>null,Og=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},bw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<vw(n,e),Ag=({values:n},e)=>tt(n[e]),as=({stride:n,values:e},t)=>e[n*t],ww=({stride:n,values:e},t)=>cg(e[n*t]),Bg=({values:n},e)=>n[e],Sw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Eg=({values:n,valueOffsets:e},t)=>Og(n,e,t),Rg=({values:n,valueOffsets:e},t)=>{const i=Og(n,e,t);return i!==null?Id(i):null},_w=({values:n},e)=>n[e],Nw=({type:n,values:e},t)=>n.precision!==Dt.HALF?e[t]:cg(e[t]),jw=(n,e)=>n.type.unit===xn.DAY?Tg(n,e):Ag(n,e),Lg=({values:n},e)=>1e3*tt(n[e]),Ug=({values:n},e)=>tt(n[e]),Pg=({values:n},e)=>Ly(n[e],BigInt(1e3)),$g=({values:n},e)=>Ly(n[e],BigInt(1e6)),kw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Lg(n,e);case _e.MILLISECOND:return Ug(n,e);case _e.MICROSECOND:return Pg(n,e);case _e.NANOSECOND:return $g(n,e)}},zg=({values:n},e)=>n[e],Vg=({values:n},e)=>n[e],Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Iw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return zg(n,e);case _e.MILLISECOND:return Vg(n,e);case _e.MICROSECOND:return Wg(n,e);case _e.NANOSECOND:return Hg(n,e)}},Mw=({values:n,stride:e},t)=>Yd.decimal(n.subarray(e*t,e*(t+1))),Dw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Cw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new Jd(f.slice(a,c-a))},Fw=(n,e)=>new Kd(n,e),Ow=(n,e)=>n.type.mode===Yt.Dense?Gg(n,e):Yg(n,e),Gg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Yg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Tw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Aw=(n,e)=>n.type.unit===nr.DAY_TIME?Qg(n,e):Kg(n,e),Qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Kg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Jg=({values:n},e)=>n[e],qg=({values:n},e)=>n[e],Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],Bw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Jg(n,e);case _e.MILLISECOND:return qg(n,e);case _e.MICROSECOND:return Zg(n,e);case _e.NANOSECOND:return Xg(n,e)}},Ew=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(xw);xe.prototype.visitBool=je(bw);xe.prototype.visitInt=je(_w);xe.prototype.visitInt8=je(as);xe.prototype.visitInt16=je(as);xe.prototype.visitInt32=je(as);xe.prototype.visitInt64=je(Bg);xe.prototype.visitUint8=je(as);xe.prototype.visitUint16=je(as);xe.prototype.visitUint32=je(as);xe.prototype.visitUint64=je(Bg);xe.prototype.visitFloat=je(Nw);xe.prototype.visitFloat16=je(ww);xe.prototype.visitFloat32=je(as);xe.prototype.visitFloat64=je(as);xe.prototype.visitUtf8=je(Rg);xe.prototype.visitLargeUtf8=je(Rg);xe.prototype.visitBinary=je(Eg);xe.prototype.visitLargeBinary=je(Eg);xe.prototype.visitFixedSizeBinary=je(Sw);xe.prototype.visitDate=je(jw);xe.prototype.visitDateDay=je(Tg);xe.prototype.visitDateMillisecond=je(Ag);xe.prototype.visitTimestamp=je(kw);xe.prototype.visitTimestampSecond=je(Lg);xe.prototype.visitTimestampMillisecond=je(Ug);xe.prototype.visitTimestampMicrosecond=je(Pg);xe.prototype.visitTimestampNanosecond=je($g);xe.prototype.visitTime=je(Iw);xe.prototype.visitTimeSecond=je(zg);xe.prototype.visitTimeMillisecond=je(Vg);xe.prototype.visitTimeMicrosecond=je(Wg);xe.prototype.visitTimeNanosecond=je(Hg);xe.prototype.visitDecimal=je(Mw);xe.prototype.visitList=je(Dw);xe.prototype.visitStruct=je(Fw);xe.prototype.visitUnion=je(Ow);xe.prototype.visitDenseUnion=je(Gg);xe.prototype.visitSparseUnion=je(Yg);xe.prototype.visitDictionary=je(Tw);xe.prototype.visitInterval=je(Aw);xe.prototype.visitIntervalDayTime=je(Qg);xe.prototype.visitIntervalYearMonth=je(Kg);xe.prototype.visitDuration=je(Bw);xe.prototype.visitDurationSecond=je(Jg);xe.prototype.visitDurationMillisecond=je(qg);xe.prototype.visitDurationMicrosecond=je(Zg);xe.prototype.visitDurationNanosecond=je(Xg);xe.prototype.visitFixedSizeList=je(Ew);xe.prototype.visitMap=je(Cw);const Qt=new xe,bi=Symbol.for("keys"),Ii=Symbol.for("vals"),wi=Symbol.for("kKeysAsStrings"),Td=Symbol.for("_kKeysAsStrings");class Jd{constructor(e){return this[bi]=new Je([e.children[0]]).memoize(),this[Ii]=e.children[1],new Proxy(this,new Lw)}get[wi](){return this[Td]||(this[Td]=Array.from(this[bi].toArray(),String))}[Symbol.iterator](){return new Rw(this[bi],this[Ii])}get size(){return this[bi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[bi],t=this[Ii],i={};for(let a=-1,c=e.length;++a`${Ho(e)}: ${Ho(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Rw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Lw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[wi]}has(e,t){return e[wi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[wi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[wi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ii),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[wi].indexOf(t);return a!==-1?(bn.visit(Reflect.get(e,Ii),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(Jd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ii]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Td]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let km;function ev(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const qd=(n,e)=>n<0?e+n:n,Im=n=>n!==n;function Li(n){if(typeof n!=="object"||n===null)return Im(n)?Im:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Eb(n,t):!1:n instanceof Map?Pw(n):Array.isArray(n)?Uw(n):n instanceof Je?$w(n):zw(n,!0)}function Uw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Vw(n,t);case Map:return Mm(n,t,t.keys());case Jd:case Kd:case Object:case void 0:return Mm(n,t,e||Object.keys(t))}return t instanceof Je?Ww(n,t):!1}}function Vw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Dm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ad(new Zd(t,n,e,null,tv)).subarray(0,i)),a}return t}function Ad(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Zd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Gw(n,a>>3,i-a>>3)}function Gw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=dd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=dd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=dd(c.getUint8(a)),a+=1;return i}function dd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Yw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,h)=>f+h.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Yw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],h){this.type=e,this.children=f,this.dictionary=h,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=vr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+h+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Dm(f,h,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,h=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,h*e,h*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===M.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Dm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[gr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[gr.TYPE])&&(f[gr.TYPE]=c.subarray(e,e+t)),(c=f[gr.OFFSET])&&(f[gr.OFFSET]=c.subarray(e,e+t+1))||(c=f[gr.DATA])&&(f[gr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Ue{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=mm(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:h=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,h,[void 0,void 0,void 0,c],a);const m=Oo(e.valueOffsets);return new Ye(t,i,f,h,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:h=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/vr(t),["nullCount"]:h=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,h,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Oo(e.valueOffsets),{["length"]:h=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,h,m,[f,void 0,c],[a])}}const Qw=new Vo;function Re(n){return Qw.visit(n)}class Cm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function nv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function rv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function sv(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(h);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(h.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function Xd(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function qw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Zd(t,n.offset+(e||0),n.length,t,tv)){if(!a)return i;++i}return-1}function De(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case M.Union:break;case M.Dictionary:break;default:return qw(n,t)}const i=Qt.getVisitFn(n),a=Li(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Cm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new Zw(f)})}class Zw{constructor(e){this.vector=e,this.index=0}next(){return this.indexh.data):e;if(c.length===0||c.some(h=>!(h instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:h,set:m,indexOf:g}=cv[f.typeId],v=c[0];this.isValid=x=>ef(v,x),this.get=x=>h(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,uv[f.typeId]),this._offsets=rv(c);break}this.data=c,this.type=f,this.stride=vr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Kw(this.data)}get nullCount(){return nv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${M[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return tf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(ev(this,e,t,({data:i,_offsets:a},c,f)=>sv(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case M.Int:case M.Float:case M.Decimal:case M.Time:case M.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:h,length:m})=>(f.array.set(h.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new Xl(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new Xl(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}lv=Symbol.toStringTag;Je[lv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(M).map(t=>M[t]).filter(t=>typeof t=="number"&&t!==M.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=bn.getVisitFnByTypeId(t),c=Zl.getVisitFnByTypeId(t);cv[t]={get:i,set:a,indexOf:c},uv[t]=Object.create(n,{isValid:{value:ql(ef)},get:{value:ql(Qt.getVisitFnByTypeId(t))},set:{value:iv(bn.getVisitFnByTypeId(t))},indexOf:{value:ov(Zl.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class Xl extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const h=c[f];if(h!==void 0)return h;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,h){i.call(this,f,h),c[f]=h}}),Object.defineProperty(this,"slice",{value:(f,h)=>new Xl(a.call(this,f,h))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ed{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Gn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Ed).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Rd(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=hl(hl(new Map,this.metadata),t.metadata),c=t.fields.filter(h=>{const m=i.findIndex(g=>g.name===h.name);return~m?(i[m]=h.clone({metadata:hl(hl(new Map,i[m].metadata),h.metadata)}))&&!1:!0}),f=Rd(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function hl(n,e){return new Map([...n||new Map,...e||new Map])}function Rd(n,e=new Map){for(let t=-1,i=n.length;++t0&&Rd(c.children,e)}return e}var Xw=Ay,e1=Ci;class nf{static decode(e){e=new e1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new t1(i,t)}static encode(e){const t=new Xw,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ti.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ti.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return pn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return pn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Oe(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Oe(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class r1 extends n1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Id(this.toUint8Array(!0)):this.toUint8Array(!1).then(Id)}toUint8Array(e=!1){return e?tr(this._values)[0]:Oe(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let h=0;try{for(var m=!0,g=_i(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),h+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return tr(f,h)[0]})}}class ec{constructor(e){e&&(this.source=new s1(pn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Ai{constructor(e){e instanceof Ai?this.source=e.source:e instanceof r1?this.source=new ks(pn.fromAsyncIterable(e)):Fy(e)?this.source=new ks(pn.fromNodeStream(e)):Hd(e)?this.source=new ks(pn.fromDOMStream(e)):Dy(e)?this.source=new ks(pn.fromDOMStream(e.body)):dc(e)?this.source=new ks(pn.fromIterable(e)):Wo(e)?this.source=new ks(pn.fromAsyncIterable(e)):Wd(e)&&(this.source=new ks(pn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class s1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class ks{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Oe(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Oe(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Oe(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Oe(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Oe(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Om extends ec{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Si(this.buffer[3])} ${Si(this.buffer[2])} ${Si(this.buffer[1])} ${Si(this.buffer[0])}`}static multiply(e,t){return new Yn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Yn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Yn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Yn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Yn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class o1 extends hv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ad(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===xn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Yn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?a1(i[t]):me.isBool(e)?Ad(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Vd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function a1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Ue{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Bs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function hc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function l1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function sf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function qo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function Zo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function c1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function u1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function of(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&is.compareManyFields(n.children,e.children)}function d1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&is.visit(n.indices,e.indices)&&is.visit(n.dictionary,e.dictionary)}function af(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function f1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&is.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Bs;Se.prototype.visitBool=Bs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=hc;Se.prototype.visitFloat16=hc;Se.prototype.visitFloat32=hc;Se.prototype.visitFloat64=hc;Se.prototype.visitUtf8=Bs;Se.prototype.visitLargeUtf8=Bs;Se.prototype.visitBinary=Bs;Se.prototype.visitLargeBinary=Bs;Se.prototype.visitFixedSizeBinary=l1;Se.prototype.visitDate=sf;Se.prototype.visitDateDay=sf;Se.prototype.visitDateMillisecond=sf;Se.prototype.visitTimestamp=qo;Se.prototype.visitTimestampSecond=qo;Se.prototype.visitTimestampMillisecond=qo;Se.prototype.visitTimestampMicrosecond=qo;Se.prototype.visitTimestampNanosecond=qo;Se.prototype.visitTime=Zo;Se.prototype.visitTimeSecond=Zo;Se.prototype.visitTimeMillisecond=Zo;Se.prototype.visitTimeMicrosecond=Zo;Se.prototype.visitTimeNanosecond=Zo;Se.prototype.visitDecimal=Bs;Se.prototype.visitList=c1;Se.prototype.visitStruct=u1;Se.prototype.visitUnion=of;Se.prototype.visitDenseUnion=of;Se.prototype.visitSparseUnion=of;Se.prototype.visitDictionary=d1;Se.prototype.visitInterval=af;Se.prototype.visitIntervalDayTime=af;Se.prototype.visitIntervalYearMonth=af;Se.prototype.visitDuration=Xo;Se.prototype.visitDurationSecond=Xo;Se.prototype.visitDurationMillisecond=Xo;Se.prototype.visitDurationMicrosecond=Xo;Se.prototype.visitDurationNanosecond=Xo;Se.prototype.visitFixedSizeList=f1;Se.prototype.visitMap=h1;const is=new Se;function p1(n,e){return is.compareSchemas(n,e)}function fd(n,e){return m1(n,e.map(t=>t.data.concat()))}function m1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,h=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,h=-1;++h0&&(i[c++]=Re({type:new At(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function y1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let h=-1,m=i.length;++h=e)v===e?t[h]=g:(t[h]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[h].unshift(g.slice(e,v-e))));else{const x=n[h];n[h]=x.clone({nullable:!0}),t[h]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Re({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var pv;class gn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof gn)return m.batches;if(m instanceof Ye){if(m.type instanceof At)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=fd(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},h=e.flatMap(m=>f(m));if(a=(i=a??((t=h[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of h){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!p1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=h,this._offsets=c??rv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=nv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(qd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?tf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} ]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new gn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=ev({length:this.numRows},e,t);const a=sv(this.data,this._offsets,e,t);return new gn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Re({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],h[e]]=[f,t],[i,a]=fd(i,h)}return new gn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new gn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((h,m,g)=>{const[v,x]=h,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),h},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((h,m)=>[m,a[m]]).map(([h,m])=>m===void 0?this.getChildAt(h):e.getChildAt(m)),...i.map(h=>e.getChildAt(h))].filter(Boolean);return new gn(...fd(c,f))}}pv=Symbol.toStringTag;gn[pv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=ql(ef),n.get=ql(Qt.getVisitFn(M.Struct)),n.set=iv(bn.getVisitFn(M.Struct)),n.indexOf=ov(Zl.getVisitFn(M.Struct)),"Table"))(gn.prototype);var mv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Re({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(t=>Re({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Tm(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),h=Re({type:new At(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Tm(f,h.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=yv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(qd(e,this.numRows))}set(e,t){return bn.visit(this.data,e,t)}indexOf(e,t){return Zl.visit(this.data,e,t)}[Symbol.iterator](){return tf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new gn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&eh.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Re({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Re({type:new At(t.fields),length:this.numRows,children:i});return new zo(t,a)}};mv=Symbol.toStringTag;Tn[mv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Tm(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[h,m]of n.fields.entries()){const g=e[h];(!g||g.length!==t)&&(a[h]=m.clone({nullable:!0}),c[h]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Re({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Re({type:new At(a),length:t,children:c})]}function yv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cRe({type:a.type})),i=Re({type:new At(e.fields),nullCount:0,children:t});super(e,i)}}let qr=class Hn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Hn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Hn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new gt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Hn.startMessage(e),Hn.addVersion(e,t),Hn.addHeaderType(e,i),Hn.addHeader(e,a),Hn.addBodyLength(e,c),Hn.addCustomMetadata(e,f),Hn.endMessage(e)}};class g1 extends Ue{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return _m.startNull(t),_m.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return Jn.startFloatingPoint(t),Jn.addPrecision(t,e.precision),Jn.endFloatingPoint(t)}visitBinary(e,t){return vm.startBinary(t),vm.endBinary(t)}visitLargeBinary(e,t){return bm.startLargeBinary(t),bm.endLargeBinary(t)}visitBool(e,t){return xm.startBool(t),xm.endBool(t)}visitUtf8(e,t){return Nm.startUtf8(t),Nm.endUtf8(t)}visitLargeUtf8(e,t){return wm.startLargeUtf8(t),wm.endLargeUtf8(t)}visitDecimal(e,t){return pi.startDecimal(t),pi.addScale(t,e.scale),pi.addPrecision(t,e.precision),pi.addBitWidth(t,e.bitWidth),pi.endDecimal(t)}visitDate(e,t){return Sl.startDate(t),Sl.addUnit(t,e.unit),Sl.endDate(t)}visitTime(e,t){return mn.startTime(t),mn.addUnit(t,e.unit),mn.addBitWidth(t,e.bitWidth),mn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return yn.startTimestamp(t),yn.addUnit(t,e.unit),i!==void 0&&yn.addTimezone(t,i),yn.endTimestamp(t)}visitInterval(e,t){return qn.startInterval(t),qn.addUnit(t,e.unit),qn.endInterval(t)}visitDuration(e,t){return _l.startDuration(t),_l.addUnit(t,e.unit),_l.endDuration(t)}visitList(e,t){return Sm.startList(t),Sm.endList(t)}visitStruct(e,t){return Is.startStruct_(t),Is.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return wr.startDictionaryEncoding(t),wr.addId(t,BigInt(e.id)),wr.addIsOrdered(t,e.isOrdered),i!==void 0&&wr.addIndexType(t,i),wr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Nl.startFixedSizeBinary(t),Nl.addByteWidth(t,e.byteWidth),Nl.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return jl.startFixedSizeList(t),jl.addListSize(t,e.listSize),jl.endFixedSizeList(t)}visitMap(e,t){return kl.startMap(t),kl.addKeysSorted(t,e.keysSorted),kl.endMap(t)}}const hd=new g1;function v1(n,e=new Map){return new We(b1(n,e),Ml(n.metadata),e)}function vv(n){return new Rn(n.count,xv(n.columns),bv(n.columns))}function x1(n){return new kr(vv(n.data),n.id,n.isDelta)}function b1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Am(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function xv(n){return(n||[]).reduce((e,t)=>[...e,new Ui(t.count,w1(t.VALIDITY)),...xv(t.children)],[])}function bv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function S1(n,e){let t,i,a,c,f,h;return!e||!(c=n.dictionary)?(f=Em(n,Am(n,e)),a=new nt(n.name,f,n.nullable,Ml(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Qo,h=new Oi(e.get(t),i,t,c.isOrdered),a=new nt(n.name,h,n.nullable,Ml(n.metadata))):(i=(i=c.indexType)?Bm(i):new Qo,e.set(t,f=Em(n,Am(n,e))),h=new Oi(f,i,t,c.isOrdered),a=new nt(n.name,h,n.nullable,Ml(n.metadata))),a||null}function Ml(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Cs(n.isSigned,n.bitWidth)}function Em(n,e){const t=n.type.name;switch(t){case"NONE":return new ss;case"null":return new ss;case"binary":return new Bl;case"largebinary":return new El;case"utf8":return new Rl;case"largeutf8":return new Ll;case"bool":return new Ul;case"list":return new Gl((e||[])[0]);case"struct":return new At(e||[]);case"struct_":return new At(e||[])}switch(t){case"int":{const i=n.type;return new Cs(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Al(Dt[i.precision])}case"decimal":{const i=n.type;return new Pl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new $l(xn[i.unit])}case"time":{const i=n.type;return new zl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Vl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Wl(nr[i.unit])}case"duration":{const i=n.type;return new Hl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new Yl(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Ql(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Kl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new Jl((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var _1=Ay,N1=Ci;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=j1(e,t),i}static decode(e){e=new N1(Pe(e));const t=qr.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=k1(t,c),f}static encode(e){const t=new _1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),qr.startMessage(t),qr.addVersion(t,ht.V5),qr.addHeader(t,i),qr.addHeaderType(t,e.headerType),qr.addBodyLength(t,BigInt(e.bodyLength)),qr.finishMessageBuffer(t,qr.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ui{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function j1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function k1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Gn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new yr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new fi),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=R1;nt.decode=B1;nt.fromJSON=S1;We.encode=E1;We.decode=I1;We.fromJSON=v1;Rn.encode=L1;Rn.decode=M1;Rn.fromJSON=vv;kr.encode=U1;kr.decode=D1;kr.fromJSON=x1;Ui.encode=P1;Ui.decode=F1;_r.encode=$1;_r.decode=C1;function I1(n,e=new Map,t=ht.V5){const i=A1(n,e);return new We(i,Dl(n),e,t)}function M1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),O1(n),T1(n,e))}function D1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function C1(n){return new _r(n.offset(),n.length())}function F1(n){return new Ui(n.length(),n.nullCount())}function O1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Gn.startFieldsVector(n,t.length);const i=Gn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Gn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const h=n.createString(`${c}`),m=n.createString(`${f}`);return gt.startKeyValue(n),gt.addKey(n,h),gt.addValue(n,m),gt.endKeyValue(n)})):-1;return Gn.startSchema(n),Gn.addFields(n,i),Gn.addEndianness(n,z1?Fi.Little:Fi.Big),a!==-1&&Gn.addCustomMetadata(n,a),Gn.endSchema(n)}function R1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=hd.visit(c,n),i=hd.visit(c.dictionary,n)):i=hd.visit(c,n);const h=(c.children||[]).map(v=>nt.encode(n,v)),m=hn.createChildrenVector(n,h),g=e.metadata&&e.metadata.size>0?hn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return gt.startKeyValue(n),gt.addKey(n,b),gt.addValue(n,w),gt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),hn.startField(n),hn.addType(n,i),hn.addTypeType(n,f),hn.addChildren(n,m),hn.addNullable(n,!!e.nullable),t!==-1&&hn.addName(n,t),a!==-1&&hn.addDictionary(n,a),g!==-1&&hn.addCustomMetadata(n,g),hn.endField(n)}function L1(n,e){const t=e.nodes||[],i=e.buffers||[];yr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ui.encode(n,f);const a=n.endVector();yr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return yr.startRecordBatch(n),yr.addLength(n,BigInt(e.length)),yr.addNodes(n,a),yr.addBuffers(n,c),yr.endRecordBatch(n)}function U1(n,e){const t=Rn.encode(n,e.data);return fi.startDictionaryBatch(n),fi.addId(n,BigInt(e.id)),fi.addIsDelta(n,e.isDelta),fi.addData(n,t),fi.endDictionaryBatch(n)}function P1(n,e){return Ry.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function $1(n,e){return Ey.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const z1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),lf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,cf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,wv=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Sv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class _v{constructor(e){this.source=e instanceof ec?e:new ec(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(lf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(lf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(cf(e));return i}}const pc=4,Ld="ARROW1",nc=new Uint8Array(Ld.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return pn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return pn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Md(e)?K1(e):My(e)?Z1(e):Wo(e)?Oe(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Dy(e)||Hd(e)||Fy(e)||Wd(e)?q1(new Ai(e)):J1(new ec(e))}static readAll(e){return e instanceof jr?e.isSync()?Pm(e):$m(e):Md(e)||ArrayBuffer.isView(e)||dc(e)||Iy(e)?Pm(e):$m(e)}}class rc extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Zn(this,arguments,function*(){yield Ae(yield*wl(_i(this[Symbol.iterator]())))})}}class sc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Oe(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,h=_i(this),m;m=yield h.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=h.return)&&(yield i.call(h))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class jv extends rc{constructor(e){super(e),this._impl=e}}class G1 extends sc{constructor(e){super(e),this._impl=e}}class kv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Re({type:new At(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,h=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(h&&a?h.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new hv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class ic extends kv{constructor(e,t){super(t),this._reader=Md(e)?new W1(this._handle=e):new _v(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Mv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class oc extends kv{constructor(e,t){super(t),this._reader=new V1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Oe(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Oe(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Mv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Oe(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Oe(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Oe(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Oe(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Iv extends ic{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Om?e:new Om(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),h=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,h)}}}_readFooter(){const{_handle:e}=this,t=e.size-Nv,i=e.readInt32(t),a=e.readAt(t-i,i);return nf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Oe(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Oe(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Oe(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),h=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,h)}}})}_readFooter(){return Oe(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-Nv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return nf.decode(a)})}_readNextMessageAndValidate(e){return Oe(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?uf(e)?new jv(new Iv(n.read())):new rc(new ic(n)):new rc(new ic((function*(){})()))}function q1(n){return Oe(this,void 0,void 0,function*(){const e=yield n.peek(ea+7&-8);return e&&e.byteLength>=4?uf(e)?new jv(new Iv(yield n.read())):new sc(new oc(n)):new sc(new oc((function(){return Zn(this,arguments,function*(){})})()))})}function Z1(n){return Oe(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new tc(n,e);return e>=H1&&uf(yield t.readAt(0,ea+7&-8))?new G1(new Y1(t)):new sc(new oc(t))})}function Dv(n){const e=jr.from(n);return Wo(e)?e.then(t=>Dv(t)):e.isAsync()?e.readAll().then(t=>new gn(t)):new gn(e.readAll())}function X1(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function eS(n){const e=Dv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,h;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(h=t.interactions)==null?void 0:h.select;return{...t,query:{...i,metrics:Zr(i.metrics)??[],dimensions:Zr(i.dimensions),filters:Zr(i.filters),segments:Zr(i.segments),order_by:Zr(i.order_by),orderBy:Zr(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:Zr(a.fields)}:a,select:typeof c=="object"?{...c,fields:Zr(c.fields)}:c}:void 0}})}))}}const nS="application/vnd.apache.arrow.stream";class rS{constructor(e){Mn(this,"active",0);Mn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function sS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class iS{constructor(e={}){Mn(this,"baseUrl");Mn(this,"token");Mn(this,"sessionToken");Mn(this,"transport");Mn(this,"usePreaggregations");Mn(this,"gate");Mn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new rS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return sS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Nb(await t.json());try{return kb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return jb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?tS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:nS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=eS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Cv({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:h}){const[m,g]=I.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=I.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=I.useId(),w=I.useRef(null),_=I.useRef(null),C=f&&v;return I.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),V=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",V),()=>T.removeEventListener("change",V)},[]),I.useEffect(()=>{h&&!m&&x(!0)},[h,m]),I.useEffect(()=>{if(!m||!v)return;const T=_.current,V=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var R,F;return(F=(R=w.current)==null?void 0:R.querySelector("button"))==null?void 0:F.focus()});function P(R){var L;if(R.key==="Escape"){R.preventDefault(),x(!1);return}if(R.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const B=F[0],D=F[F.length-1];R.shiftKey&&document.activeElement===B?(R.preventDefault(),D.focus()):!R.shiftKey&&document.activeElement===D&&(R.preventDefault(),B.focus())}return document.addEventListener("keydown",P,!0),()=>{document.body.style.overflow=V,document.removeEventListener("keydown",P,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-x-auto border-b border-line bg-surface px-3 py-2 md:h-9 md:flex-nowrap md:py-0",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function oS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const aS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function pl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function ml(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function lS(n,e){const t=n.split("__").at(-1);return t&&aS.has(t)?t:e}function cS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function uS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Fs(n,e,t){var F,B,D,L,G,W,Y;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find($=>$.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=pl(a.query.dimensions),f=pl(a.query.metrics),h=f.map($=>{var ee;return(ee=n.graphMetrics.find(X=>X.ref===$))==null?void 0:ee.ownerModel}).find($=>!!$),m=((F=f.find($=>$.includes(".")))==null?void 0:F.split(".")[0])??h??((B=c.find($=>$.includes(".")))==null?void 0:B.split(".")[0]),g=n.models.find($=>$.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap($=>$.metrics),...Di(n,g.name)],x=f.map($=>v.find(ee=>ee.ref===$)).filter($=>!!$),b=c.map($=>ml(n,$)).filter(($,ee,X)=>!!$&&X.findIndex(oe=>(oe==null?void 0:oe.ref)===($==null?void 0:$.ref))===ee),w=(D=a.encoding)==null?void 0:D.y,C=(Array.isArray(w)?w:w?[w]:[]).find($=>x.some(ee=>ee.ref===$))??((L=x[0])==null?void 0:L.ref)??((G=g.metrics[0])==null?void 0:G.ref)??"",T=(W=a.encoding)==null?void 0:W.x,V=(T&&((Y=ml(n,T))==null?void 0:Y.type)==="time"?T:void 0)??c.find($=>{var ee;return((ee=ml(n,$))==null?void 0:ee.type)==="time"}),P=g.defaultGrain??"month",R=V?ml(n,V):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:R,selectedMetric:C,grain:V?lS(V,P):P,filters:pl(a.query.filters),segments:pl(a.query.segments),usePreaggregations:uS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??cS(e)}}const Ud=["second","minute","hour","day","week","month","quarter","year"];function dS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Ud.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Ud.filter(i=>i===e||t.includes(i)):t}function Mi(n){return n.toISOString().slice(0,10)}function df(n){return n.slice(0,10)}function Ei(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function Os(n){return new Date(`${df(n)}T00:00:00Z`)}function Ko(n,e){const t=Os(n);return t.setUTCDate(t.getUTCDate()+e),Mi(t)}function fS(n){return Math.round((Os(n.to).getTime()-Os(n.from).getTime())/864e5)+1}function hS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ei(n.from)),f=Date.parse(Ei(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=fS(n),t=Ko(n.from,-1);return{from:Ko(t,-(e-1)),to:t}}function zm(n){if(n.includes("T")){const f=new Date(Ei(n)),h=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(h,m+1,0)).getUTCDate();return new Date(Date.UTC(h,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=Os(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return Mi(new Date(Date.UTC(t,i,Math.min(a,c))))}function pS(n){return{from:zm(n.from),to:zm(n.to)}}function mS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Fv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ri(n,e=new Date){const t=Mi(e);return{from:Ko(t,-(n-1)),to:t}}function yS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${Ko(e.to,1)}' as date)`]}function Vm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ei(e))-Date.parse(Ei(n)))/f)}const i=Os(n),a=Os(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function pd(n,e){return new Date(Date.parse(Ei(n))+e).toISOString().slice(0,19)}function gS(n,e){const t=df(n),i=Os(t);switch(e){case"second":return pd(n,1e3);case"minute":return pd(n,6e4);case"hour":return pd(n,36e5);case"day":return t;case"week":return Ko(n,6);case"month":return Mi(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return Mi(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return Mi(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function ff(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function hf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function mc(n){return hf(n.models.flatMap(e=>e.dimensions))}function Wm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Qn(n,t)}function vS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Ov(n,e,t){const i=Qn(`%${vS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function xS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(er),f=e.values.filter(m=>m!==er);let h=null;if(f.length===1)h=`${n} ${a?"!=":"="} ${Wm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Wm(g,t,i)).join(", ");h=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return h&&m.push(h),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return h&&m.push(h),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return h?`(${h} OR ${n} IS NULL)`:null}function Tv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||ff(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Ov(a,c.pattern??"",e.dialect));continue}const h=xS(a,c,f,e.dialect);h&&t.push(h)}return t}function Ts(n,e={}){const t=Tv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...yS(e.timeRef,e.range)),t}function md(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const bS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Hm(n,e,t,i,a,c,f=!1){const h=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[h],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${h} ${g?"DESC":"ASC"}`],...!m||g?{limit:bS[t]??2e3}:{}}}function Gm(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function wS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function SS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function _S(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function NS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function yl(n,e,t){const i={...n};return ff(t)?delete i[e]:i[e]=t,i}function jS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=NS(a,e.value);return{...n,filters:yl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:yl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:yl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:yl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ri(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ri(e.initial.datePreset):e.initial.dateRange};default:return n}}function kS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Av(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=Di(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Bv(n,e,t){const i=Fs(n,e,t),a=(i==null?void 0:i.model)??kS(n),c=(i==null?void 0:i.selectedMetric)??Av(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ri(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,pivotDims:[],pivotMetrics:[]}}function IS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),h=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:h?n.grain:e.grain}}const MS=["home","explore","pivot"],DS=new Set(Ud),CS=new Set(["none","pctTotal","delta","deltaPct"]),FS=new Set(["off","previous","year","custom"]),OS="none",TS="previous",AS="UTC";function BS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function yd(n){if(n)try{return JSON.parse(n)}catch{return}}function ac(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function gl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const ES=new Set(["include","exclude","contains"]);function RS(n){if(ac(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!ES.has(e.mode))return null;const t=e.mode,i=ac(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return ff(c)?null:c}function LS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=RS(i);a&&(e[t]=a)}return e}function US(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function PS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==AS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==OS&&e.set("ctx",n.contextColumn),n.comparison!==TS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(US(n.filters))),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function $S(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&MS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const h=t.get("metric");h&&(i.selectedMetric=h);const m=t.get("grain");m&&DS.has(m)&&(i.grain=m);const g=t.get("tz");BS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ri(e.datePreset));const b=t.get("range"),w=Fv.find(B=>`${B.days}d`===b);gl(v)&&gl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ri(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&CS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&FS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),V=t.get("cto");i.comparison==="custom"&&gl(T)&&gl(V)&&Date.parse(T)<=Date.parse(V)&&(i.comparisonRange={from:T,to:V});const P=LS(yd(t.get("filters")));P&&(i.filters=P);const R=yd(t.get("pdims"));ac(R)&&(i.pivotDims=R);const F=yd(t.get("pmetrics"));return ac(F)&&(i.pivotMetrics=F),i}const Ev=I.createContext(null);function Ym(n){const e=PS(n);return e?`?${e}`:""}function Qm(n,e,t,i){const a=$S(n,i),c=Fs(e,t,a.dashboardTab);return c?IS(a,c,n):a}const Km=n=>n.startsWith("?")?n.slice(1):n;function zS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=I.useMemo(()=>Bv(n,t),[n,t]),[h,m]=I.useReducer(jS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Qm(b,n,t,f)}),g=I.useRef(i);I.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Km(i)!==Km(Ym(h))&&m({type:"hydrate",state:Qm(i,n,t,f)}))},[i,h,n,t,f]);const v=I.useRef(a);v.current=a,I.useEffect(()=>{const b=Ym(h),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[h]);const x=I.useMemo(()=>({state:h,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[h,n,e,f,t]);return u.jsx(Ev.Provider,{value:x,children:c})}function ls(){const n=I.useContext(Ev);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Ms={active:0,listeners:new Set};function Rv(){for(const n of Ms.listeners)n()}function VS(){Ms.active+=1,Rv()}function WS(){Ms.active=Math.max(0,Ms.active-1),Rv()}function Lv(){return I.useSyncExternalStore(n=>(Ms.listeners.add(n),()=>Ms.listeners.delete(n)),()=>Ms.active>0,()=>!1)}const HS=80;function Bn(n,e){const[t,i]=I.useState({loading:!1}),a=I.useRef(0),c=e?JSON.stringify(e):null;return I.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const h=setTimeout(()=>{VS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>WS())},HS);return()=>clearTimeout(h)},[c,n]),{...t,queryKey:c??void 0}}const GS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],YS=50,Jm=200;function qm(n,e){const[t,i]=I.useState(n);return I.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function Uv({dim:n,model:e,onClose:t}){var H,N;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:h}=ls(),m=I.useMemo(()=>Fs(f,h,i.dashboardTab),[f,h,i.dashboardTab]),g=i.filters[n.ref],[v,x]=I.useState((g==null?void 0:g.mode)??"include"),b=I.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=I.useRef(null),_=I.useRef(null),C=I.useId(),[T,V]=I.useState(""),P=qm(T,Jm),R=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,B]=I.useState(R),D=qm(F,Jm);I.useEffect(()=>{var te;const O=document.activeElement;return(te=_.current)==null||te.focus(),()=>{var he;return(he=O==null?void 0:O.focus)==null?void 0:he.call(O)}},[]),I.useEffect(()=>{function O(he){he.key==="Escape"&&(he.stopPropagation(),t())}function te(he){w.current&&!w.current.contains(he.target)&&t()}return document.addEventListener("keydown",O,!0),document.addEventListener("mousedown",te,!0),()=>{document.removeEventListener("keydown",O,!0),document.removeEventListener("mousedown",te,!0)}},[t]),I.useEffect(()=>{v==="contains"&&D!==R&&a({type:"setFilterPattern",dim:n.ref,pattern:D})},[D,v,n.ref,a]);const L=((H=m==null?void 0:m.timeDimension)==null?void 0:H.ref)??((N=e.timeDimension)==null?void 0:N.ref),G=I.useMemo(()=>mc(f),[f]),W=I.useMemo(()=>{const O=[...(m==null?void 0:m.filters)??[],...Ts(i.filters,{timeRef:L,range:i.dateRange,excludeDim:n.ref,types:G,dialect:f.dialect})];return P.trim()&&O.push(Ov(n.ref,P.trim(),f.dialect)),O},[m,i.filters,L,i.dateRange,n.ref,P,G,f.dialect]),Y=v!=="contains",{result:$,loading:ee,error:X}=Bn(c,Y?wS(n.ref,W,YS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),oe=Sr(n.ref),ae=I.useMemo(()=>$?$.rows.map(O=>{const te=O[oe];return te==null?er:String(te)}):[],[$,oe]),se=!!$&&$.rows.length>0&&!$.columns.includes(oe),ne=Y&&(ee||se);function A(O){x(O),g&&a({type:"setFilterMode",dim:n.ref,mode:O}),O==="contains"&&B(R)}function Q(O){var pe;if(O.key!=="Tab")return;const te=(pe=w.current)==null?void 0:pe.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!te||te.length===0)return;const he=te[0],re=te[te.length-1];O.shiftKey&&document.activeElement===he?(O.preventDefault(),re.focus()):!O.shiftKey&&document.activeElement===re&&(O.preventDefault(),he.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:Q,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:GS.map(({mode:O,label:te})=>u.jsx("button",{type:"button","aria-pressed":v===O,onClick:()=>A(O),className:`px-1.5 py-1 text-center ${v===O?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:te},O))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:O=>B(O.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:O=>V(O.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:X?u.jsx("p",{className:"px-1 py-2 text-danger",children:X}):ne?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(O=>u.jsx("div",{className:"skeleton h-4 w-full"},O))}):ae.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ae.map(O=>{const te=b.has(O);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:te,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:O,mode:v}),className:"size-3 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 truncate text-ink",children:rs(O)})]},O)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function QS({model:n}){const e=n.dimensions.filter(m=>m.type!=="time"),[t,i]=I.useState(!1),[a,c]=I.useState(null),f=I.useRef(null);I.useEffect(()=>{if(!t)return;function m(v){v.key==="Escape"&&h()}function g(v){a||f.current&&!f.current.contains(v.target)&&h()}return document.addEventListener("keydown",m,!0),document.addEventListener("mousedown",g,!0),()=>{document.removeEventListener("keydown",m,!0),document.removeEventListener("mousedown",g,!0)}},[t,a]);function h(){i(!1),c(null)}return e.length===0?null:u.jsxs("span",{ref:f,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":t,onClick:()=>t?h():i(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),t&&!a?u.jsx("div",{role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 z-50 mt-1 max-h-64 w-48 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:e.map(m=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>c(m),className:"block w-full truncate px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:m.label},m.ref))}):null,t&&a?u.jsx(Uv,{dim:a,model:n,onClose:h}):null]})}function gd(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Zm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function KS({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function JS(){const{state:n,dispatch:e,catalog:t}=ls(),i=t.models.find(h=>h.name===n.model),a=Di(t,n.model),c=n.view==="pivot",f=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:h=>{var v,x;const m=t.models.find(b=>b.name===h.target.value),g=((v=m==null?void 0:m.metrics[0])==null?void 0:v.ref)??((x=Di(t,h.target.value)[0])==null?void 0:x.ref)??"";e({type:"setModel",model:h.target.value,metric:g,grain:(m==null?void 0:m.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(h=>u.jsx("option",{value:h.name,children:h.label},h.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(h=>u.jsx(Zm,{metric:h,selected:c?f.includes(h.ref):n.selectedMetric===h.ref,multiple:c,onSelect:()=>e(c?{type:"setPivotMetrics",metrics:gd(f,h.ref)}:{type:"setMetric",metric:h.ref})},h.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(h=>u.jsx(Zm,{metric:h,selected:c?f.includes(h.ref):n.selectedMetric===h.ref,multiple:c,onSelect:()=>e(c?{type:"setPivotMetrics",metrics:gd(f,h.ref)}:{type:"setMetric",metric:h.ref})},h.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),c?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(h=>u.jsx(KS,{dimension:h,selected:n.pivotDims.includes(h.ref),onSelect:()=>e({type:"setPivotDims",dims:gd(n.pivotDims,h.ref)})},h.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(h=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:h.description,children:[u.jsx("span",{className:"truncate",children:h.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:h.type==="time"?"time":""})]},h.ref))})]})]})}class qS extends I.Component{constructor(){super(...arguments);Mn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const ZS=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Pv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=I.useRef(null),[h,m]=I.useState((n==null?void 0:n.from)??""),[g,v]=I.useState((n==null?void 0:n.to)??""),[x,b]=I.useState((a==null?void 0:a.from)??""),[w,_]=I.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,B){t(F,B),C()}function V(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const P=n?`${n.from} → ${n.to}`:"All time",R=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:P}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Fv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ri(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:h,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!h||!g,onClick:()=>T({from:h,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${R?"opacity-50":""}`,children:ZS.map(F=>u.jsx("button",{type:"button",disabled:R,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>V(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!R?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function Pd(n){const[e,t]=I.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(h=>!h),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",Sb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(Uv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function $d({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Le(a)},a))})]})}const XS=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let vl=null;function Xm(){if(vl)return vl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return vl=[...new Set(["UTC",...n])].sort(),vl}function e_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function t_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],h=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${h}:${m}`}catch{return""}}const ey="__search__";function n_({timezone:n,disabled:e,onChange:t}){const i=I.useId(),[a,c]=I.useState(!1),[f,h]=I.useState(""),m=I.useMemo(()=>{const b=new Set(XS);return n&&b.add(n),[...b]},[n]),g=I.useMemo(()=>a?Xm():[],[a]);function v(b){const w=b.trim();e_(w)&&(t(w),c(!1),h(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{h(b.target.value),Xm().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),h(""))},onBlur:()=>{c(!1),h("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=t_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ey?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ey,children:"Search…"})]})]})}function r_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const s_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Pi({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:h=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=I.useState(0),[w,_]=I.useState(""),C=I.useMemo(()=>{const D=w.trim().toLowerCase();return!m||!D?e:e.filter(L=>n.some(G=>String(L[G.key]??"").toLowerCase().includes(D)))},[e,n,w,m]),{paginate:T,pageCount:V,safePage:P,start:R,visibleRows:F}=vb(C,x,h);I.useEffect(()=>{b(0)},[e,h,i,a,w]);const B=g&&n.some(D=>g[D.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:D=>_(D.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(D=>{const L=i===D.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${D.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:D.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(D.key),"aria-label":`Sort by ${D.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:D.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:D.label,children:D.label})},D.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((D,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(G=>{const W=f(G,D[G.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${G.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:W,children:W})},G.key)})},R+L))}),B&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(D=>{const L=g==null?void 0:g[D.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},D.key);const G=r_(C,D.key,L),W=L==="count"?G.toLocaleString():Number.isFinite(G)?f(D,G):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${D.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:s_[L]}),W]},D.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[R+1,"–",Math.min(R+h,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:P===0,onClick:()=>b(D=>Math.max(0,D-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:P>=V-1,onClick:()=>b(D=>Math.min(V-1,D+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function i_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function o_(){var P,R;const[n,e]=I.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=ls(),f=i.models.find(F=>F.name===t.model),h=I.useMemo(()=>Fs(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(h==null?void 0:h.dimensions)??(f==null?void 0:f.dimensions)??[],g=i_(m,t.pivotDims),v=((P=h==null?void 0:h.timeDimension)==null?void 0:P.ref)??((R=f==null?void 0:f.timeDimension)==null?void 0:R.ref),x=I.useMemo(()=>mc(i),[i]),b=I.useMemo(()=>[...(h==null?void 0:h.filters)??[],...Ts(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[h,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?_S({dimensions:g,metrics:[]},b,50,h==null?void 0:h.segments,h==null?void 0:h.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),V=[...g.map(F=>{var B;return{key:Sr(F),label:((B=m.find(D=>D.ref===F))==null?void 0:B.label)??Le(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):V.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Pi,{columns:V,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,B)=>B==null||B===""?"—":String(B)})}):null]})}function pf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function yc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(pf,{tone:"loading",title:n,message:e})}function Xn({title:n="No results",message:e}){return u.jsx(pf,{tone:"muted",title:n,message:e})}function $i({title:n="Query failed",message:e}){return u.jsx(pf,{tone:"danger",title:n,message:e})}function vd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const $v="sidemantic-theme";function mf(){var e;const n=localStorage.getItem($v);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function zv(n){document.documentElement.dataset.theme=n}function a_(){zv(mf())}function l_(){const n=mf()==="dark"?"light":"dark";return localStorage.setItem($v,n),zv(n),n}function Jo(){const[n,e]=I.useState(mf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(l_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Vv({view:n,onChange:e}){const t=I.useRef(null);function i(a){const c=Math.max(0,To.findIndex(h=>h.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var h,m;return(m=(h=t.current)==null?void 0:h.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Wv="dashboard_filters",Hv="dashboard_ranges",Gv="dashboard_filter_sources",Yv="dashboard_range_sources",Qv="dashboard_chart_filters",Kv="dashboard_chart_ranges";function c_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function yf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function u_(n){return(n.query.dimensions??[]).find(e=>yf(n,e))}function d_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function lc(n){return n==null?er:String(n)}function f_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function xr(n,e){const t=Sr(n),i=f_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function h_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function p_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&yf(n,c[0])))}function m_(n,e,t){return[e,...t].some(i=>yf(n,i))}const y_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ds(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return y_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Jv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Ds(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function qv(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function Zv(n,e,t){const i=Ds(n);if(i){const a=qv(e.to,i.grain);return a?`${i.baseDimension} >= ${Qn(e.from,t)} AND ${i.baseDimension} < ${Qn(a,t)}`:`${i.baseDimension} >= ${Qn(e.from,t)} AND ${i.baseDimension} <= ${Qn(e.to,t)}`}return`${n} >= ${Qn(e.from,t)} AND ${n} <= ${Qn(e.to,t)}`}function g_(n,e,t,i){const a=Ds(n);return a?e===er?[`${a.baseDimension} IS NULL`]:[Zv(n,{from:e,to:e},i)]:Tv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function cc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function gf(n,e,t){var f,h,m,g,v;const i=((h=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:h.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=cc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function v_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,V,P;const h=gf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Jv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(h.filters).flatMap(([R,F])=>g_(R,F,i,f)),...Object.entries(h.ranges).map(([R,F])=>Zv(R,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((P=(V=n.defaults)==null?void 0:V.query)==null?void 0:P.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ty(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function ny(n,e){const t=ty(e.from);if(!t)return null;const i=Ds(n);if(!i){const f=ty(e.to);return f?{from:t,to:f}:null}const a=qv(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function x_(n,e,t,i={},a){var F,B,D;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",h=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((B=h[0])==null?void 0:B.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=gf(n,e,t),x=Object.entries(v.filters).flatMap(([L,G])=>{const W=Ds(L);return W?[{dimension:L,value:G,baseDimension:W.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,G])=>{const W=Ds(L);return W?G===er?[[W.baseDimension,[G]]]:[]:[[L,[G]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((D=e.encoding)==null?void 0:D.x)??h[0],C=x.find(({baseDimension:L,value:G})=>G!==er&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),V=[_,...T].find((L,G,W)=>{if(!L||W.indexOf(L)!==G||!v.ranges[L])return!1;const Y=Ds(L);return((i[L]??(Y?i[Y.baseDimension]:void 0))==="time"||!!Y)&&(!g||L.startsWith(`${g}.`))}),P=V?v.ranges[V]:void 0,R=C?ny(C.dimension,{from:C.value,to:C.value}):V&&P?ny(V,P):null;return R&&(w.set("from",R.from),w.set("to",R.to)),`/explore?${w}`}function b_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const h=i.map(b=>lc(c[b])),m=JSON.stringify(h),g=h.length?h.map(rs).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:h,data:[]},x=lc(c[e]);v.data.push({label:rs(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function w_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const h of n){if(h[e]==null)continue;const m=String(h[e]),g=Number(h[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>lc(h[_])),x=JSON.stringify(v),b=v.length?v.map(rs).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(h=>({label:h.label,points:a.map(m=>({x:m,y:h.values.get(m)??Number.NaN}))}))}function vf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function uc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function Xv(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=vf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function e0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function t0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function n0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[cc(n,t),new Set(t.query.dimensions??[])])))}function S_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,h,m,g,v,x;try{f=JSON.parse(t.get(Wv)??"{}")}catch{f={}}try{h=JSON.parse(t.get(Hv)??"{}")}catch{h={}}try{m=JSON.parse(t.get(Gv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Yv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Kv)??"{}")}catch{x={}}const b=t0(e),w=n0(e);return{tab:c,filters:vf(f,b),ranges:xf(h,b),filterSources:uc(m,b),rangeSources:uc(g,b),chartFilters:Xv(v,w),chartRanges:e0(x,w)}}function __(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Wv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Hv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Gv,JSON.stringify(i)),Object.keys(a).length&&t.set(Yv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Kv,JSON.stringify(n.chartRanges)),t.toString()}function r0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function N_(n){try{const e=JSON.parse(localStorage.getItem(r0(n))??"[]");if(!Array.isArray(e))return[];const t=t0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",h=n0(n);return[{name:a.name,state:{tab:f,filters:vf(c.filters,t),ranges:xf(c.ranges,t),filterSources:uc(c.filterSources,t),rangeSources:uc(c.rangeSources,t),chartFilters:Xv(c.chartFilters,h),chartRanges:e0(c.chartRanges,h)}}]})}catch{return[]}}function j_(n,e){try{return localStorage.setItem(r0(n),JSON.stringify(e)),!0}catch{return!1}}function ry(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function k_(n,e){return[n.map(ry).join(","),...e.map(t=>n.map(i=>ry(t[i])).join(","))].join(`\r diff --git a/sidemantic/ui/static/index.html b/sidemantic/ui/static/index.html index 08a6970c2..655ef9384 100644 --- a/sidemantic/ui/static/index.html +++ b/sidemantic/ui/static/index.html @@ -4,7 +4,7 @@ Sidemantic - + diff --git a/sidemantic/widget/static/widget.js b/sidemantic/widget/static/widget.js index 978651e65..5c56b0e38 100644 --- a/sidemantic/widget/static/widget.js +++ b/sidemantic/widget/static/widget.js @@ -1,20 +1,20 @@ -var _w=Object.defineProperty;var fi=(t,e)=>{for(var n in e)_w(t,n,{get:e[n],enumerable:!0})};function Yp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function X(t){return this instanceof X?(this.v=t,this):new X(t)}function Tt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(S){return Promise.resolve(S).then(v,d)}}function a(v,S){r[v]&&(i[v]=function(I){return new Promise(function(Y,h){s.push([v,I,Y,h])>1||l(v,I)})},S&&(i[v]=S(i[v])))}function l(v,S){try{u(r[v](S))}catch(I){y(s[0][3],I)}}function u(v){v.value instanceof X?Promise.resolve(v.value.v).then(c,d):y(s[0][2],v)}function c(v){l("next",v)}function d(v){l("throw",v)}function y(v,S){v(S),s.shift(),s.length&&l(s[0][0],s[0][1])}}function es(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:X(t[i](o)),done:!1}:s?s(o):o}:s}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hp=="function"?Hp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Ft,memcpy:()=>uo,rebaseValueOffsets:()=>il,toArrayBufferView:()=>Z,toArrayBufferViewAsyncIterator:()=>on,toArrayBufferViewIterator:()=>On,toBigInt64Array:()=>rl,toBigUint64Array:()=>Tw,toFloat32Array:()=>Ow,toFloat32ArrayAsyncIterator:()=>Hw,toFloat32ArrayIterator:()=>Uw,toFloat64Array:()=>Fw,toFloat64ArrayAsyncIterator:()=>Yw,toFloat64ArrayIterator:()=>Rw,toInt16Array:()=>Bw,toInt16ArrayAsyncIterator:()=>zw,toInt16ArrayIterator:()=>Aw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>Vw,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Iw,toInt8ArrayAsyncIterator:()=>jw,toInt8ArrayIterator:()=>kw,toUint16Array:()=>Dw,toUint16ArrayAsyncIterator:()=>$w,toUint16ArrayIterator:()=>Mw,toUint32Array:()=>Nw,toUint32ArrayAsyncIterator:()=>Ww,toUint32ArrayIterator:()=>Cw,toUint8Array:()=>V,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>Ew,toUint8ClampedArrayAsyncIterator:()=>Kw,toUint8ClampedArrayIterator:()=>Pw});var ww=new TextDecoder("utf-8"),ao=t=>ww.decode(t),Sw=new TextEncoder,Tn=t=>Sw.encode(t);var bw=t=>typeof t=="number",Kp=t=>typeof t=="boolean",Ue=t=>typeof t=="function",ct=t=>t!=null&&Object(t)===t,Ot=t=>ct(t)&&Ue(t.then);var sn=t=>ct(t)&&Ue(t[Symbol.iterator]),$t=t=>ct(t)&&Ue(t[Symbol.asyncIterator]),Za=t=>ct(t)&&ct(t.schema);var Ja=t=>ct(t)&&"done"in t&&"value"in t;var qa=t=>ct(t)&&Ue(t.stat)&&bw(t.fd);var el=t=>ct(t)&&lo(t.body),tl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Qp=t=>ct(t)&&Ue(t.abort)&&Ue(t.getWriter)&&!tl(t),lo=t=>ct(t)&&Ue(t.cancel)&&Ue(t.getReader)&&!tl(t),Gp=t=>ct(t)&&Ue(t.end)&&Ue(t.write)&&Kp(t.writable)&&!tl(t),nl=t=>ct(t)&&Ue(t.read)&&Ue(t.pipe)&&Kp(t.readable)&&!tl(t),Xp=t=>ct(t)&&Ue(t.clear)&&Ue(t.bytes)&&Ue(t.position)&&Ue(t.setPosition)&&Ue(t.capacity)&&Ue(t.getBufferIdentifier)&&Ue(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function xw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+d.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lZ(Int8Array,t),Bw=t=>Z(Int16Array,t),di=t=>Z(Int32Array,t),rl=t=>Z(BigInt64Array,t),V=t=>Z(Uint8Array,t),Dw=t=>Z(Uint16Array,t),Nw=t=>Z(Uint32Array,t),Tw=t=>Z(BigUint64Array,t),Ow=t=>Z(Float32Array,t),Fw=t=>Z(Float64Array,t),Ew=t=>Z(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*On(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):sn(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield Z(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var kw=t=>On(Int8Array,t),Aw=t=>On(Int16Array,t),Lw=t=>On(Int32Array,t),df=t=>On(Uint8Array,t),Mw=t=>On(Uint16Array,t),Cw=t=>On(Uint32Array,t),Uw=t=>On(Float32Array,t),Rw=t=>On(Float64Array,t),Pw=t=>On(Uint8ClampedArray,t);function on(t,e){return Tt(this,arguments,function*(){if(Ot(e))return yield X(yield X(yield*es(rn(on(t,yield X(e))))));let r=function(o){return Tt(this,arguments,function*(){yield yield X(yield X(o))})},i=function(o){return Tt(this,arguments,function*(){yield X(yield*es(rn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):sn(e)?i(e):$t(e)?e:r(e);return yield X(yield*es(rn(cf((function(o){return Tt(this,arguments,function*(){let a=null;do a=yield X(o.next(yield yield X(Z(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield X(new t)})}var jw=t=>on(Int8Array,t),zw=t=>on(Int16Array,t),Vw=t=>on(Int32Array,t),hf=t=>on(Uint8Array,t),$w=t=>on(Uint16Array,t),Ww=t=>on(Uint32Array,t),Hw=t=>on(Float32Array,t),Yw=t=>on(Float64Array,t),Kw=t=>on(Uint8ClampedArray,t);function il(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Qw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Ft(r,o)[0]:([i,r,a]=Ft(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield X(u()));while(a0&&(i.push(V(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield X(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return O(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return O(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=V(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Zw(t){return Tt(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function d(){return o==="peek"?Ft(u,a)[0]:([c,u,l]=Ft(u,a),c)}if({cmd:o,size:a}=(yield yield X(null))||{cmd:"read",size:0},t.isTTY)return yield yield X(new Uint8Array(0)),yield X(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield X(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=V(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield X(d()));while(a{for(let[h,f]of v)t.off(h,f);try{let h=t.destroy;h&&h.call(t,S),S=void 0}catch(h){S=h||S}finally{S!=null?Y(S):I()}})}})}var le;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(le||(le={}));var de;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(de||(de={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var Fe;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Fe||(Fe={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var We;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(We||(We={}));var Fn=new Int32Array(2),ol=new Float32Array(Fn.buffer),al=new Float64Array(Fn.buffer),ts=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var co;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(co||(co={}));var Et=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){ol[0]=n,this.writeInt32(e,Fn[0])}writeFloat64(e,n){al[0]=n,this.writeInt32(e,Fn[ts?0:1]),this.writeInt32(e+4,Fn[ts?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var bo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new En).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var gt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Er.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,Er.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var q;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(q||(q={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var cn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(cn||(cn={}));var Uf={};fi(Uf,{clampRange:()=>Do,createElementComparator:()=>Vr,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>fn});function fn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>fn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Io,bigNumToBigInt:()=>Jp,bigNumToNumber:()=>Sf,bigNumToString:()=>os,isArrowBigNumSymbol:()=>Zp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Zp=Symbol.for("isArrowBigNum");function dn(t,...e){return e.length===0?Object.setPrototypeOf(Z(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}dn.prototype[Zp]=!0;dn.prototype.toJSON=function(){return`"${os(this)}"`};dn.prototype.valueOf=function(t){return Sf(this,t)};dn.prototype.toString=function(){return os(this)};dn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return os(this);case"default":return Jp(this)}return os(this)};function is(...t){return dn.apply(this,t)}function ss(...t){return dn.apply(this,t)}function xo(...t){return dn.apply(this,t)}Object.setPrototypeOf(is.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ss.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(xo.prototype,Object.create(Uint32Array.prototype));Object.assign(is.prototype,dn.prototype,{constructor:is,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ss.prototype,dn.prototype,{constructor:ss,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(xo.prototype,dn.prototype,{constructor:xo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jw=BigInt(4294967296)*BigInt(4294967296),qw=Jw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(F.prototype);var ft=class extends F{constructor(){super(p.Null)}toString(){return"Null"}};em=Symbol.toStringTag;ft[em]=(t=>t[Symbol.toStringTag]="Null")(ft.prototype);var Pe=class extends F{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};tm=Symbol.toStringTag;Pe[tm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Pe.prototype);var cl=class extends Pe{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},fl=class extends Pe{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},An=class extends Pe{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},dl=class extends Pe{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},hl=class extends Pe{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},pl=class extends Pe{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ml=class extends Pe{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yl=class extends Pe{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(cl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(fl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(An.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(dl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(hl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(yl.prototype,"ArrayType",{value:BigUint64Array});var Ht=class extends F{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};nm=Symbol.toStringTag;Ht[nm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Ht.prototype);var gl=class extends Ht{constructor(){super(ce.HALF)}},vl=class extends Ht{constructor(){super(ce.SINGLE)}},_l=class extends Ht{constructor(){super(ce.DOUBLE)}};Object.defineProperty(gl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vl.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float64Array});var Qn=class extends F{constructor(){super(p.Binary)}toString(){return"Binary"}};rm=Symbol.toStringTag;Qn[rm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Qn.prototype);var Gn=class extends F{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};im=Symbol.toStringTag;Gn[im]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Gn.prototype);var Xn=class extends F{constructor(){super(p.Utf8)}toString(){return"Utf8"}};sm=Symbol.toStringTag;Xn[sm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Xn.prototype);var Zn=class extends F{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};om=Symbol.toStringTag;Zn[om]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(Zn.prototype);var Jn=class extends F{constructor(){super(p.Bool)}toString(){return"Bool"}};am=Symbol.toStringTag;Jn[am]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Jn.prototype);var qn=class extends F{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lm=Symbol.toStringTag;qn[lm]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(qn.prototype);var er=class extends F{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Fe[this.unit]}>`}get ArrayType(){return this.unit===Fe.DAY?Int32Array:BigInt64Array}};um=Symbol.toStringTag;er[um]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(er.prototype);var tr=class extends F{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};cm=Symbol.toStringTag;tr[cm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(tr.prototype);var nr=class extends F{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};fm=Symbol.toStringTag;nr[fm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(nr.prototype);var rr=class extends F{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${We[this.unit]}>`}};dm=Symbol.toStringTag;rr[dm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(rr.prototype);var ir=class extends F{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};hm=Symbol.toStringTag;ir[hm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(ir.prototype);var hn=class extends F{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};pm=Symbol.toStringTag;hn[pm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(hn.prototype);var he=class extends F{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};mm=Symbol.toStringTag;he[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(he.prototype);var pn=class extends F{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};ym=Symbol.toStringTag;pn[ym]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(pn.prototype);var sr=class extends F{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};gm=Symbol.toStringTag;sr[gm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(sr.prototype);var mn=class extends F{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};vm=Symbol.toStringTag;mn[vm]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(mn.prototype);var yn=class extends F{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(yn.prototype);var eS=(t=>()=>++t)(-1),At=class extends F{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?eS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};wm=Symbol.toStringTag;At[wm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(At.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var C=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return tS(this,e,n)}getVisitFnByTypeId(e,n=!0){return as(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function tS(t,e,n=!0){return typeof e=="number"?as(t,e,n):typeof e=="string"&&e in p?as(t,p[e],n):e&&e instanceof F?as(t,Sm(e),n):e?.type&&e.type instanceof F?as(t,Sm(e.type),n):as(t,p.NONE,n)}function as(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function Sm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case Fe.DAY:return p.DateDay;case Fe.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case We.DAY_TIME:return p.IntervalDayTime;case We.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case de.Dense:return p.DenseUnion;case de.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}C.prototype.visitInt8=null;C.prototype.visitInt16=null;C.prototype.visitInt32=null;C.prototype.visitInt64=null;C.prototype.visitUint8=null;C.prototype.visitUint16=null;C.prototype.visitUint32=null;C.prototype.visitUint64=null;C.prototype.visitFloat16=null;C.prototype.visitFloat32=null;C.prototype.visitFloat64=null;C.prototype.visitDateDay=null;C.prototype.visitDateMillisecond=null;C.prototype.visitTimestampSecond=null;C.prototype.visitTimestampMillisecond=null;C.prototype.visitTimestampMicrosecond=null;C.prototype.visitTimestampNanosecond=null;C.prototype.visitTimeSecond=null;C.prototype.visitTimeMillisecond=null;C.prototype.visitTimeMicrosecond=null;C.prototype.visitTimeNanosecond=null;C.prototype.visitDenseUnion=null;C.prototype.visitSparseUnion=null;C.prototype.visitIntervalDayTime=null;C.prototype.visitIntervalYearMonth=null;C.prototype.visitDuration=null;C.prototype.visitDurationSecond=null;C.prototype.visitDurationMillisecond=null;C.prototype.visitDurationMicrosecond=null;C.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Bo,uint16ToFloat64:()=>wl});var bm=new Float64Array(1),ls=new Uint32Array(bm.buffer);function wl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Bo(t){if(t!==t)return 32256;bm[0]=t;let e=(ls[1]&2147483648)>>16&65535,n=ls[1]&2146435072,r=0;return n>=1089470464?ls[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ls[1]&1048575)>>10):n<=1056964608?(r=1048576+(ls[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ls[1]&1048575)+512>>10),e|n|r&65535}var z=class extends C{};function H(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var nS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},xm=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Im=({values:t},e,n)=>{t[e]=Bo(n)},iS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Im(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},Sl=({values:t},e,n)=>{nS(t,e,n.valueOf())},bl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Bm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,r),Dm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,Tn(r)),Df=(t,e,n)=>{t.type.unit===Fe.DAY?Sl(t,e,n):bl(t,e,n)},xl=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Il=({values:t},e,n)=>{t[e]=BigInt(n)},Bl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return xl(t,e,n);case k.MILLISECOND:return Il(t,e,n);case k.MICROSECOND:return Bl(t,e,n);case k.NANOSECOND:return Dl(t,e,n)}},Nl=({values:t},e,n)=>{t[e]=n},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},Fl=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Nl(t,e,n);case k.MILLISECOND:return Tl(t,e,n);case k.MICROSECOND:return Ol(t,e,n);case k.NANOSECOND:return Fl(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},sS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},aS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),fS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?uS(e,n):n instanceof ee?lS(e,n):Array.isArray(n)?aS(e,n):cS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},dS=(t,e,n)=>{t.type.mode===de.Dense?Nm(t,e,n):Tm(t,e,n)},Nm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},hS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ff=(t,e,n)=>{t.type.unit===We.DAY_TIME?El(t,e,n):kl(t,e,n)},El=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},kl=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Al=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Ml=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ef=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Al(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Ml(t,e,n);case k.NANOSECOND:return Cl(t,e,n)}},pS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[gn],this[us])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[gn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[gn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[gn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Le.visit(e[gn].children[r],e[us]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[gn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[gn].children[i],e[us],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var U=class extends C{};function $(t){return(e,n)=>e.getValid(n)?t(e,n):null}var mS=(t,e)=>864e5*t[e],yS=(t,e)=>null,Om=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},gS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<mS(t,e),Em=({values:t},e)=>ne(t[e]),jr=({stride:t,values:e},n)=>e[t*n],vS=({stride:t,values:e},n)=>wl(e[t*n]),km=({values:t},e)=>t[e],_S=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Am=({values:t,valueOffsets:e},n)=>Om(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Om(t,e,n);return r!==null?ao(r):null},wS=({values:t},e)=>t[e],SS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:wl(e[n]),bS=(t,e)=>t.type.unit===Fe.DAY?Fm(t,e):Em(t,e),Mm=({values:t},e)=>1e3*ne(t[e]),Cm=({values:t},e)=>ne(t[e]),Um=({values:t},e)=>_f(t[e],BigInt(1e3)),Rm=({values:t},e)=>_f(t[e],BigInt(1e6)),xS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Mm(t,e);case k.MILLISECOND:return Cm(t,e);case k.MICROSECOND:return Um(t,e);case k.NANOSECOND:return Rm(t,e)}},Pm=({values:t},e)=>t[e],jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Pm(t,e);case k.MILLISECOND:return jm(t,e);case k.MICROSECOND:return zm(t,e);case k.NANOSECOND:return Vm(t,e)}},BS=({values:t,stride:e},n)=>Io.decimal(t.subarray(e*n,e*(n+1))),DS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new ee([l])},NS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Ln(o.slice(i,s-i))},TS=(t,e)=>new Pr(t,e),OS=(t,e)=>t.type.mode===de.Dense?$m(t,e):Wm(t,e),$m=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Le.visit(r,t.valueOffsets[e])},Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Le.visit(r,e)},FS=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},ES=(t,e)=>t.type.unit===We.DAY_TIME?Hm(t,e):Ym(t,e),Hm=({values:t},e)=>t.subarray(2*e,2*(e+1)),Ym=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Km=({values:t},e)=>t[e],Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],kS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Km(t,e);case k.MILLISECOND:return Qm(t,e);case k.MICROSECOND:return Gm(t,e);case k.NANOSECOND:return Xm(t,e)}},AS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new ee([s])};U.prototype.visitNull=$(yS);U.prototype.visitBool=$(gS);U.prototype.visitInt=$(wS);U.prototype.visitInt8=$(jr);U.prototype.visitInt16=$(jr);U.prototype.visitInt32=$(jr);U.prototype.visitInt64=$(km);U.prototype.visitUint8=$(jr);U.prototype.visitUint16=$(jr);U.prototype.visitUint32=$(jr);U.prototype.visitUint64=$(km);U.prototype.visitFloat=$(SS);U.prototype.visitFloat16=$(vS);U.prototype.visitFloat32=$(jr);U.prototype.visitFloat64=$(jr);U.prototype.visitUtf8=$(Lm);U.prototype.visitLargeUtf8=$(Lm);U.prototype.visitBinary=$(Am);U.prototype.visitLargeBinary=$(Am);U.prototype.visitFixedSizeBinary=$(_S);U.prototype.visitDate=$(bS);U.prototype.visitDateDay=$(Fm);U.prototype.visitDateMillisecond=$(Em);U.prototype.visitTimestamp=$(xS);U.prototype.visitTimestampSecond=$(Mm);U.prototype.visitTimestampMillisecond=$(Cm);U.prototype.visitTimestampMicrosecond=$(Um);U.prototype.visitTimestampNanosecond=$(Rm);U.prototype.visitTime=$(IS);U.prototype.visitTimeSecond=$(Pm);U.prototype.visitTimeMillisecond=$(jm);U.prototype.visitTimeMicrosecond=$(zm);U.prototype.visitTimeNanosecond=$(Vm);U.prototype.visitDecimal=$(BS);U.prototype.visitList=$(DS);U.prototype.visitStruct=$(TS);U.prototype.visitUnion=$(OS);U.prototype.visitDenseUnion=$($m);U.prototype.visitSparseUnion=$(Wm);U.prototype.visitDictionary=$(FS);U.prototype.visitInterval=$(ES);U.prototype.visitIntervalDayTime=$(Hm);U.prototype.visitIntervalYearMonth=$(Ym);U.prototype.visitDuration=$(kS);U.prototype.visitDurationSecond=$(Km);U.prototype.visitDurationMillisecond=$(Qm);U.prototype.visitDurationMicrosecond=$(Gm);U.prototype.visitDurationNanosecond=$(Xm);U.prototype.visitFixedSizeList=$(AS);U.prototype.visitMap=$(NS);var Le=new U;var zr=Symbol.for("keys"),fs=Symbol.for("vals"),cs=Symbol.for("kKeysAsStrings"),Lf=Symbol.for("_kKeysAsStrings"),Ln=class{constructor(e){return this[zr]=new ee([e.children[0]]).memoize(),this[fs]=e.children[1],new Proxy(this,new Cf)}get[cs](){return this[Lf]||(this[Lf]=Array.from(this[zr].toArray(),String))}[Symbol.iterator](){return new Mf(this[zr],this[fs])}get size(){return this[zr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[zr],n=this[fs],r={};for(let i=-1,s=e.length;++i`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Mf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Le.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cs]}has(e,n){return e[cs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[cs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[cs].indexOf(n);if(r!==-1){let i=Le.visit(Reflect.get(e,fs),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[cs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,fs),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Ln.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[zr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[fs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Zm;function Do(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,Jm=t=>t!==t;function Vr(t){if(typeof t!=="object"||t===null)return Jm(t)?Jm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?MS(t):Array.isArray(t)?LS(t):t instanceof ee?CS(t):US(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return RS(t,n);case Map:return qm(t,n,n.keys());case Ln:case Pr:case Object:case void 0:return qm(t,n,e||Object.keys(n))}return n instanceof ee?PS(t,n):!1}}function RS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ey,getBool:()=>Pl,packBools:()=>gi,popcnt_array:()=>ty,popcnt_bit_range:()=>No,popcnt_uint32:()=>Rl,setBool:()=>jS,truncateBitmap:()=>yi});function Pl(t,e,n,r){return(n&1<>r}function jS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,Pl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return No(t,e,i)+No(t,r,n)+ty(t,i>>3,r-i>>3)}function ty(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Rl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Rl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Rl(s.getUint8(i)),i+=1;return r}function Rl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var zS=-1,se=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return F.isSparseUnion(e)?this.children.some(n=>n.nullable):F.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(F.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=zS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-No(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(F.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===de.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[c];r=(d&u)!==0,s[c]=n?d|u:d&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[cn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[cn.TYPE])&&(o[cn.TYPE]=s.subarray(e,e+n)),(s=o[cn.OFFSET])&&(o[cn.OFFSET]=s.subarray(e,e+n+1))||(s=o[cn.DATA])&&(o[cn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};se.prototype.children=Object.freeze([]);var Pf=class t extends C{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new se(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=V(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Z(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(F.isSparseUnion(n))return new se(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new se(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.indices.ArrayType,e.data),{["dictionary"]:o=new ee([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=V(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}},VS=new Pf;function Q(t){return VS.visit(t)}var To=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function jl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function zl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function Vl(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),d=Math.min(r-l,u);i.push(a.slice(c,d-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function WS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,Pl)){if(!i)return r;++r}return-1}function G(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return WS(t,n)}let r=Le.getVisitFn(t),i=Vr(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new To(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof se)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=sy[o.typeId],c=s[0];this.isValid=d=>Oo(c,d),this.get=d=>a(c,d),this.set=(d,y)=>l(c,d,y),this.indexOf=d=>u(c,d),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,oy[o.typeId]),this._offsets=zl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ny(this.data)}get nullCount(){return jl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return hs.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(Do(this,e,n,({data:r,_offsets:i},s,o)=>Vl(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return F.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(F.isDictionary(this.type)){let e=new Hl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Hl(this)}unmemoize(){if(F.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};iy=Symbol.toStringTag;ee[iy]=(t=>{t.type=F.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Le.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);sy[n]={get:r,set:i,indexOf:s},oy[n]=Object.create(t,{isValid:{value:ds(Oo)},get:{value:ds(Le.getVisitFnByTypeId(n))},set:{value:$l(Xe.getVisitFnByTypeId(n))},indexOf:{value:Wl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(ee.prototype);var Hl=class t extends ee{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new ee(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ay(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` +var _w=Object.defineProperty;var fi=(t,e)=>{for(var n in e)_w(t,n,{get:e[n],enumerable:!0})};function Yp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function X(t){return this instanceof X?(this.v=t,this):new X(t)}function Tt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(S){return Promise.resolve(S).then(v,d)}}function a(v,S){r[v]&&(i[v]=function(I){return new Promise(function(Y,h){s.push([v,I,Y,h])>1||l(v,I)})},S&&(i[v]=S(i[v])))}function l(v,S){try{u(r[v](S))}catch(I){y(s[0][3],I)}}function u(v){v.value instanceof X?Promise.resolve(v.value.v).then(c,d):y(s[0][2],v)}function c(v){l("next",v)}function d(v){l("throw",v)}function y(v,S){v(S),s.shift(),s.length&&l(s[0][0],s[0][1])}}function es(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:X(t[i](o)),done:!1}:s?s(o):o}:s}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hp=="function"?Hp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Et,memcpy:()=>uo,rebaseValueOffsets:()=>il,toArrayBufferView:()=>Z,toArrayBufferViewAsyncIterator:()=>on,toArrayBufferViewIterator:()=>On,toBigInt64Array:()=>rl,toBigUint64Array:()=>Tw,toFloat32Array:()=>Ow,toFloat32ArrayAsyncIterator:()=>Hw,toFloat32ArrayIterator:()=>Uw,toFloat64Array:()=>Ew,toFloat64ArrayAsyncIterator:()=>Yw,toFloat64ArrayIterator:()=>Rw,toInt16Array:()=>Bw,toInt16ArrayAsyncIterator:()=>zw,toInt16ArrayIterator:()=>Aw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>Vw,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Iw,toInt8ArrayAsyncIterator:()=>jw,toInt8ArrayIterator:()=>kw,toUint16Array:()=>Dw,toUint16ArrayAsyncIterator:()=>$w,toUint16ArrayIterator:()=>Mw,toUint32Array:()=>Nw,toUint32ArrayAsyncIterator:()=>Ww,toUint32ArrayIterator:()=>Cw,toUint8Array:()=>V,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>Fw,toUint8ClampedArrayAsyncIterator:()=>Kw,toUint8ClampedArrayIterator:()=>Pw});var ww=new TextDecoder("utf-8"),ao=t=>ww.decode(t),Sw=new TextEncoder,Tn=t=>Sw.encode(t);var bw=t=>typeof t=="number",Kp=t=>typeof t=="boolean",Ue=t=>typeof t=="function",ct=t=>t!=null&&Object(t)===t,Ot=t=>ct(t)&&Ue(t.then);var sn=t=>ct(t)&&Ue(t[Symbol.iterator]),$t=t=>ct(t)&&Ue(t[Symbol.asyncIterator]),Za=t=>ct(t)&&ct(t.schema);var Ja=t=>ct(t)&&"done"in t&&"value"in t;var qa=t=>ct(t)&&Ue(t.stat)&&bw(t.fd);var el=t=>ct(t)&&lo(t.body),tl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Qp=t=>ct(t)&&Ue(t.abort)&&Ue(t.getWriter)&&!tl(t),lo=t=>ct(t)&&Ue(t.cancel)&&Ue(t.getReader)&&!tl(t),Gp=t=>ct(t)&&Ue(t.end)&&Ue(t.write)&&Kp(t.writable)&&!tl(t),nl=t=>ct(t)&&Ue(t.read)&&Ue(t.pipe)&&Kp(t.readable)&&!tl(t),Xp=t=>ct(t)&&Ue(t.clear)&&Ue(t.bytes)&&Ue(t.position)&&Ue(t.setPosition)&&Ue(t.capacity)&&Ue(t.getBufferIdentifier)&&Ue(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function xw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+d.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lZ(Int8Array,t),Bw=t=>Z(Int16Array,t),di=t=>Z(Int32Array,t),rl=t=>Z(BigInt64Array,t),V=t=>Z(Uint8Array,t),Dw=t=>Z(Uint16Array,t),Nw=t=>Z(Uint32Array,t),Tw=t=>Z(BigUint64Array,t),Ow=t=>Z(Float32Array,t),Ew=t=>Z(Float64Array,t),Fw=t=>Z(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*On(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):sn(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield Z(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var kw=t=>On(Int8Array,t),Aw=t=>On(Int16Array,t),Lw=t=>On(Int32Array,t),df=t=>On(Uint8Array,t),Mw=t=>On(Uint16Array,t),Cw=t=>On(Uint32Array,t),Uw=t=>On(Float32Array,t),Rw=t=>On(Float64Array,t),Pw=t=>On(Uint8ClampedArray,t);function on(t,e){return Tt(this,arguments,function*(){if(Ot(e))return yield X(yield X(yield*es(rn(on(t,yield X(e))))));let r=function(o){return Tt(this,arguments,function*(){yield yield X(yield X(o))})},i=function(o){return Tt(this,arguments,function*(){yield X(yield*es(rn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):sn(e)?i(e):$t(e)?e:r(e);return yield X(yield*es(rn(cf((function(o){return Tt(this,arguments,function*(){let a=null;do a=yield X(o.next(yield yield X(Z(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield X(new t)})}var jw=t=>on(Int8Array,t),zw=t=>on(Int16Array,t),Vw=t=>on(Int32Array,t),hf=t=>on(Uint8Array,t),$w=t=>on(Uint16Array,t),Ww=t=>on(Uint32Array,t),Hw=t=>on(Float32Array,t),Yw=t=>on(Float64Array,t),Kw=t=>on(Uint8ClampedArray,t);function il(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Qw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Et(r,o)[0]:([i,r,a]=Et(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield X(u()));while(a0&&(i.push(V(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield X(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return O(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return O(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=V(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Zw(t){return Tt(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function d(){return o==="peek"?Et(u,a)[0]:([c,u,l]=Et(u,a),c)}if({cmd:o,size:a}=(yield yield X(null))||{cmd:"read",size:0},t.isTTY)return yield yield X(new Uint8Array(0)),yield X(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield X(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=V(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield X(d()));while(a{for(let[h,f]of v)t.off(h,f);try{let h=t.destroy;h&&h.call(t,S),S=void 0}catch(h){S=h||S}finally{S!=null?Y(S):I()}})}})}var le;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(le||(le={}));var de;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(de||(de={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var Ee;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Ee||(Ee={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var We;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(We||(We={}));var En=new Int32Array(2),ol=new Float32Array(En.buffer),al=new Float64Array(En.buffer),ts=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var co;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(co||(co={}));var Ft=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){ol[0]=n,this.writeInt32(e,En[0])}writeFloat64(e,n){al[0]=n,this.writeInt32(e,En[ts?0:1]),this.writeInt32(e+4,En[ts?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var bo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Fn).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var gt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Fr.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,Fr.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var q;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(q||(q={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var cn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(cn||(cn={}));var Uf={};fi(Uf,{clampRange:()=>Do,createElementComparator:()=>Vr,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>fn});function fn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>fn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Io,bigNumToBigInt:()=>Jp,bigNumToNumber:()=>Sf,bigNumToString:()=>os,isArrowBigNumSymbol:()=>Zp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Zp=Symbol.for("isArrowBigNum");function dn(t,...e){return e.length===0?Object.setPrototypeOf(Z(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}dn.prototype[Zp]=!0;dn.prototype.toJSON=function(){return`"${os(this)}"`};dn.prototype.valueOf=function(t){return Sf(this,t)};dn.prototype.toString=function(){return os(this)};dn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return os(this);case"default":return Jp(this)}return os(this)};function is(...t){return dn.apply(this,t)}function ss(...t){return dn.apply(this,t)}function xo(...t){return dn.apply(this,t)}Object.setPrototypeOf(is.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ss.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(xo.prototype,Object.create(Uint32Array.prototype));Object.assign(is.prototype,dn.prototype,{constructor:is,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ss.prototype,dn.prototype,{constructor:ss,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(xo.prototype,dn.prototype,{constructor:xo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jw=BigInt(4294967296)*BigInt(4294967296),qw=Jw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(E.prototype);var ft=class extends E{constructor(){super(p.Null)}toString(){return"Null"}};em=Symbol.toStringTag;ft[em]=(t=>t[Symbol.toStringTag]="Null")(ft.prototype);var Pe=class extends E{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};tm=Symbol.toStringTag;Pe[tm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Pe.prototype);var cl=class extends Pe{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},fl=class extends Pe{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},An=class extends Pe{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},dl=class extends Pe{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},hl=class extends Pe{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},pl=class extends Pe{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ml=class extends Pe{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yl=class extends Pe{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(cl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(fl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(An.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(dl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(hl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(yl.prototype,"ArrayType",{value:BigUint64Array});var Ht=class extends E{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};nm=Symbol.toStringTag;Ht[nm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Ht.prototype);var gl=class extends Ht{constructor(){super(ce.HALF)}},vl=class extends Ht{constructor(){super(ce.SINGLE)}},_l=class extends Ht{constructor(){super(ce.DOUBLE)}};Object.defineProperty(gl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vl.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float64Array});var Qn=class extends E{constructor(){super(p.Binary)}toString(){return"Binary"}};rm=Symbol.toStringTag;Qn[rm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Qn.prototype);var Gn=class extends E{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};im=Symbol.toStringTag;Gn[im]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Gn.prototype);var Xn=class extends E{constructor(){super(p.Utf8)}toString(){return"Utf8"}};sm=Symbol.toStringTag;Xn[sm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Xn.prototype);var Zn=class extends E{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};om=Symbol.toStringTag;Zn[om]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(Zn.prototype);var Jn=class extends E{constructor(){super(p.Bool)}toString(){return"Bool"}};am=Symbol.toStringTag;Jn[am]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Jn.prototype);var qn=class extends E{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lm=Symbol.toStringTag;qn[lm]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(qn.prototype);var er=class extends E{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Ee[this.unit]}>`}get ArrayType(){return this.unit===Ee.DAY?Int32Array:BigInt64Array}};um=Symbol.toStringTag;er[um]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(er.prototype);var tr=class extends E{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};cm=Symbol.toStringTag;tr[cm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(tr.prototype);var nr=class extends E{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};fm=Symbol.toStringTag;nr[fm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(nr.prototype);var rr=class extends E{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${We[this.unit]}>`}};dm=Symbol.toStringTag;rr[dm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(rr.prototype);var ir=class extends E{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};hm=Symbol.toStringTag;ir[hm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(ir.prototype);var hn=class extends E{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};pm=Symbol.toStringTag;hn[pm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(hn.prototype);var he=class extends E{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};mm=Symbol.toStringTag;he[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(he.prototype);var pn=class extends E{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};ym=Symbol.toStringTag;pn[ym]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(pn.prototype);var sr=class extends E{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};gm=Symbol.toStringTag;sr[gm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(sr.prototype);var mn=class extends E{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};vm=Symbol.toStringTag;mn[vm]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(mn.prototype);var yn=class extends E{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(yn.prototype);var eS=(t=>()=>++t)(-1),At=class extends E{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?eS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};wm=Symbol.toStringTag;At[wm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(At.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var C=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return tS(this,e,n)}getVisitFnByTypeId(e,n=!0){return as(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function tS(t,e,n=!0){return typeof e=="number"?as(t,e,n):typeof e=="string"&&e in p?as(t,p[e],n):e&&e instanceof E?as(t,Sm(e),n):e?.type&&e.type instanceof E?as(t,Sm(e.type),n):as(t,p.NONE,n)}function as(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function Sm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case Ee.DAY:return p.DateDay;case Ee.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case We.DAY_TIME:return p.IntervalDayTime;case We.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case de.Dense:return p.DenseUnion;case de.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}C.prototype.visitInt8=null;C.prototype.visitInt16=null;C.prototype.visitInt32=null;C.prototype.visitInt64=null;C.prototype.visitUint8=null;C.prototype.visitUint16=null;C.prototype.visitUint32=null;C.prototype.visitUint64=null;C.prototype.visitFloat16=null;C.prototype.visitFloat32=null;C.prototype.visitFloat64=null;C.prototype.visitDateDay=null;C.prototype.visitDateMillisecond=null;C.prototype.visitTimestampSecond=null;C.prototype.visitTimestampMillisecond=null;C.prototype.visitTimestampMicrosecond=null;C.prototype.visitTimestampNanosecond=null;C.prototype.visitTimeSecond=null;C.prototype.visitTimeMillisecond=null;C.prototype.visitTimeMicrosecond=null;C.prototype.visitTimeNanosecond=null;C.prototype.visitDenseUnion=null;C.prototype.visitSparseUnion=null;C.prototype.visitIntervalDayTime=null;C.prototype.visitIntervalYearMonth=null;C.prototype.visitDuration=null;C.prototype.visitDurationSecond=null;C.prototype.visitDurationMillisecond=null;C.prototype.visitDurationMicrosecond=null;C.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Bo,uint16ToFloat64:()=>wl});var bm=new Float64Array(1),ls=new Uint32Array(bm.buffer);function wl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Bo(t){if(t!==t)return 32256;bm[0]=t;let e=(ls[1]&2147483648)>>16&65535,n=ls[1]&2146435072,r=0;return n>=1089470464?ls[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ls[1]&1048575)>>10):n<=1056964608?(r=1048576+(ls[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ls[1]&1048575)+512>>10),e|n|r&65535}var z=class extends C{};function H(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var nS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},xm=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Im=({values:t},e,n)=>{t[e]=Bo(n)},iS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Im(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},Sl=({values:t},e,n)=>{nS(t,e,n.valueOf())},bl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Bm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,r),Dm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,Tn(r)),Df=(t,e,n)=>{t.type.unit===Ee.DAY?Sl(t,e,n):bl(t,e,n)},xl=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Il=({values:t},e,n)=>{t[e]=BigInt(n)},Bl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return xl(t,e,n);case k.MILLISECOND:return Il(t,e,n);case k.MICROSECOND:return Bl(t,e,n);case k.NANOSECOND:return Dl(t,e,n)}},Nl=({values:t},e,n)=>{t[e]=n},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},El=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Nl(t,e,n);case k.MILLISECOND:return Tl(t,e,n);case k.MICROSECOND:return Ol(t,e,n);case k.NANOSECOND:return El(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},sS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},aS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),fS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?uS(e,n):n instanceof ee?lS(e,n):Array.isArray(n)?aS(e,n):cS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},dS=(t,e,n)=>{t.type.mode===de.Dense?Nm(t,e,n):Tm(t,e,n)},Nm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},hS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ef=(t,e,n)=>{t.type.unit===We.DAY_TIME?Fl(t,e,n):kl(t,e,n)},Fl=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},kl=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Al=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Ml=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ff=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Al(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Ml(t,e,n);case k.NANOSECOND:return Cl(t,e,n)}},pS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[gn],this[us])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[gn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[gn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[gn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Le.visit(e[gn].children[r],e[us]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[gn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[gn].children[i],e[us],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var U=class extends C{};function $(t){return(e,n)=>e.getValid(n)?t(e,n):null}var mS=(t,e)=>864e5*t[e],yS=(t,e)=>null,Om=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},gS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<mS(t,e),Fm=({values:t},e)=>ne(t[e]),jr=({stride:t,values:e},n)=>e[t*n],vS=({stride:t,values:e},n)=>wl(e[t*n]),km=({values:t},e)=>t[e],_S=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Am=({values:t,valueOffsets:e},n)=>Om(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Om(t,e,n);return r!==null?ao(r):null},wS=({values:t},e)=>t[e],SS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:wl(e[n]),bS=(t,e)=>t.type.unit===Ee.DAY?Em(t,e):Fm(t,e),Mm=({values:t},e)=>1e3*ne(t[e]),Cm=({values:t},e)=>ne(t[e]),Um=({values:t},e)=>_f(t[e],BigInt(1e3)),Rm=({values:t},e)=>_f(t[e],BigInt(1e6)),xS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Mm(t,e);case k.MILLISECOND:return Cm(t,e);case k.MICROSECOND:return Um(t,e);case k.NANOSECOND:return Rm(t,e)}},Pm=({values:t},e)=>t[e],jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Pm(t,e);case k.MILLISECOND:return jm(t,e);case k.MICROSECOND:return zm(t,e);case k.NANOSECOND:return Vm(t,e)}},BS=({values:t,stride:e},n)=>Io.decimal(t.subarray(e*n,e*(n+1))),DS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new ee([l])},NS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Ln(o.slice(i,s-i))},TS=(t,e)=>new Pr(t,e),OS=(t,e)=>t.type.mode===de.Dense?$m(t,e):Wm(t,e),$m=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Le.visit(r,t.valueOffsets[e])},Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Le.visit(r,e)},ES=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},FS=(t,e)=>t.type.unit===We.DAY_TIME?Hm(t,e):Ym(t,e),Hm=({values:t},e)=>t.subarray(2*e,2*(e+1)),Ym=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Km=({values:t},e)=>t[e],Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],kS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Km(t,e);case k.MILLISECOND:return Qm(t,e);case k.MICROSECOND:return Gm(t,e);case k.NANOSECOND:return Xm(t,e)}},AS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new ee([s])};U.prototype.visitNull=$(yS);U.prototype.visitBool=$(gS);U.prototype.visitInt=$(wS);U.prototype.visitInt8=$(jr);U.prototype.visitInt16=$(jr);U.prototype.visitInt32=$(jr);U.prototype.visitInt64=$(km);U.prototype.visitUint8=$(jr);U.prototype.visitUint16=$(jr);U.prototype.visitUint32=$(jr);U.prototype.visitUint64=$(km);U.prototype.visitFloat=$(SS);U.prototype.visitFloat16=$(vS);U.prototype.visitFloat32=$(jr);U.prototype.visitFloat64=$(jr);U.prototype.visitUtf8=$(Lm);U.prototype.visitLargeUtf8=$(Lm);U.prototype.visitBinary=$(Am);U.prototype.visitLargeBinary=$(Am);U.prototype.visitFixedSizeBinary=$(_S);U.prototype.visitDate=$(bS);U.prototype.visitDateDay=$(Em);U.prototype.visitDateMillisecond=$(Fm);U.prototype.visitTimestamp=$(xS);U.prototype.visitTimestampSecond=$(Mm);U.prototype.visitTimestampMillisecond=$(Cm);U.prototype.visitTimestampMicrosecond=$(Um);U.prototype.visitTimestampNanosecond=$(Rm);U.prototype.visitTime=$(IS);U.prototype.visitTimeSecond=$(Pm);U.prototype.visitTimeMillisecond=$(jm);U.prototype.visitTimeMicrosecond=$(zm);U.prototype.visitTimeNanosecond=$(Vm);U.prototype.visitDecimal=$(BS);U.prototype.visitList=$(DS);U.prototype.visitStruct=$(TS);U.prototype.visitUnion=$(OS);U.prototype.visitDenseUnion=$($m);U.prototype.visitSparseUnion=$(Wm);U.prototype.visitDictionary=$(ES);U.prototype.visitInterval=$(FS);U.prototype.visitIntervalDayTime=$(Hm);U.prototype.visitIntervalYearMonth=$(Ym);U.prototype.visitDuration=$(kS);U.prototype.visitDurationSecond=$(Km);U.prototype.visitDurationMillisecond=$(Qm);U.prototype.visitDurationMicrosecond=$(Gm);U.prototype.visitDurationNanosecond=$(Xm);U.prototype.visitFixedSizeList=$(AS);U.prototype.visitMap=$(NS);var Le=new U;var zr=Symbol.for("keys"),fs=Symbol.for("vals"),cs=Symbol.for("kKeysAsStrings"),Lf=Symbol.for("_kKeysAsStrings"),Ln=class{constructor(e){return this[zr]=new ee([e.children[0]]).memoize(),this[fs]=e.children[1],new Proxy(this,new Cf)}get[cs](){return this[Lf]||(this[Lf]=Array.from(this[zr].toArray(),String))}[Symbol.iterator](){return new Mf(this[zr],this[fs])}get size(){return this[zr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[zr],n=this[fs],r={};for(let i=-1,s=e.length;++i`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Mf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Le.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cs]}has(e,n){return e[cs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[cs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[cs].indexOf(n);if(r!==-1){let i=Le.visit(Reflect.get(e,fs),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[cs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,fs),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Ln.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[zr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[fs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Zm;function Do(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,Jm=t=>t!==t;function Vr(t){if(typeof t!=="object"||t===null)return Jm(t)?Jm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?MS(t):Array.isArray(t)?LS(t):t instanceof ee?CS(t):US(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return RS(t,n);case Map:return qm(t,n,n.keys());case Ln:case Pr:case Object:case void 0:return qm(t,n,e||Object.keys(n))}return n instanceof ee?PS(t,n):!1}}function RS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ey,getBool:()=>Pl,packBools:()=>gi,popcnt_array:()=>ty,popcnt_bit_range:()=>No,popcnt_uint32:()=>Rl,setBool:()=>jS,truncateBitmap:()=>yi});function Pl(t,e,n,r){return(n&1<>r}function jS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,Pl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return No(t,e,i)+No(t,r,n)+ty(t,i>>3,r-i>>3)}function ty(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Rl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Rl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Rl(s.getUint8(i)),i+=1;return r}function Rl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var zS=-1,se=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return E.isSparseUnion(e)?this.children.some(n=>n.nullable):E.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(E.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=zS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-No(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(E.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===de.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[c];r=(d&u)!==0,s[c]=n?d|u:d&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[cn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[cn.TYPE])&&(o[cn.TYPE]=s.subarray(e,e+n)),(s=o[cn.OFFSET])&&(o[cn.OFFSET]=s.subarray(e,e+n+1))||(s=o[cn.DATA])&&(o[cn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};se.prototype.children=Object.freeze([]);var Pf=class t extends C{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new se(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=V(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Z(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(E.isSparseUnion(n))return new se(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new se(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.indices.ArrayType,e.data),{["dictionary"]:o=new ee([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=Z(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=V(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}},VS=new Pf;function Q(t){return VS.visit(t)}var To=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function jl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function zl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function Vl(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),d=Math.min(r-l,u);i.push(a.slice(c,d-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function WS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,Pl)){if(!i)return r;++r}return-1}function G(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return WS(t,n)}let r=Le.getVisitFn(t),i=Vr(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new To(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof se)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=sy[o.typeId],c=s[0];this.isValid=d=>Oo(c,d),this.get=d=>a(c,d),this.set=(d,y)=>l(c,d,y),this.indexOf=d=>u(c,d),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,oy[o.typeId]),this._offsets=zl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ny(this.data)}get nullCount(){return jl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return hs.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(Do(this,e,n,({data:r,_offsets:i},s,o)=>Vl(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return E.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(E.isDictionary(this.type)){let e=new Hl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Hl(this)}unmemoize(){if(E.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};iy=Symbol.toStringTag;ee[iy]=(t=>{t.type=E.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Le.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);sy[n]={get:r,set:i,indexOf:s},oy[n]=Object.create(t,{isValid:{value:ds(Oo)},get:{value:ds(Le.getVisitFnByTypeId(n))},set:{value:$l(Xe.getVisitFnByTypeId(n))},indexOf:{value:Wl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(ee.prototype);var Hl=class t extends ee{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new ee(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ay(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` switch (x) {${n.map(r=>` case ${HS(r)}:`).join("")} return false; }`),t.length!==n.length&&(e=`if (x !== x) return false; ${e}`),new Function("x",`${e} -return true;`)}function HS(t){return typeof t!="bigint"?fn(t):`${fn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function ly(t,e=0){return t.length>=e?t.subarray(0,e):uo(new t.constructor(e),t,0)}var vn=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=ly(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=ly(this.buffer,e)}},ar=class extends vn{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ps=class extends ar{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ge=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ps,n&&n.length>0&&(this._isValid=ay(n))}toVector(){return new ee([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:d}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=d?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),Q({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ge.prototype.length=1;ge.prototype.stride=1;ge.prototype.children=null;ge.prototype.finished=!1;ge.prototype.nullValues=null;ge.prototype._isValid=()=>!0;var Me=class extends ge{constructor(e){super(e),this._values=new ar(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},vt=class extends ge{constructor(e){super(e),this._pendingLength=0,this._offsets=new ms(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Ln?n[zr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Mt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new gt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var ae=class t{constructor(e=[],n,r,i=le.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Yl(Yl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Yl(Yl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};ae.prototype.fields=null;ae.prototype.metadata=null;ae.prototype.dictionaries=null;var J=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};J.prototype.type=null;J.prototype.name=null;J.prototype.nullable=null;J.prototype.metadata=null;function Yl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var YS=hi,KS=Et,lr=class{static decode(e){e=new KS(V(e));let n=Mt.getRootAsFooter(e),r=ae.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new YS,r=ae.encode(n,e.schema);Mt.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())ur.encode(n,o);let i=n.endVector();Mt.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())ur.encode(n,o);let s=n.endVector();return Mt.startFooter(n),Mt.addSchema(n,r),Mt.addVersion(n,le.V5),Mt.addRecordBatches(n,i),Mt.addDictionaries(n,s),Mt.finishFooterBuffer(n,Mt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=le.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(pe);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return O(this,void 0,void 0,function*(){return yield this.abort(e),pe})}return(e){return O(this,void 0,void 0,function*(){return yield this.close(),pe})}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(pe)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Mn=class extends Kl{write(e){if((e=V(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ao(this.toUint8Array(!0)):this.toUint8Array(!1).then(ao)}toUint8Array(e=!1){return e?Ft(this._values)[0]:O(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=rn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Ft(o,a)[0]})}},Cn=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Yt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Mn?this.source=new cr(Ge.fromAsyncIterable(e)):nl(e)?this.source=new cr(Ge.fromNodeStream(e)):lo(e)?this.source=new cr(Ge.fromDOMStream(e)):el(e)?this.source=new cr(Ge.fromDOMStream(e.body)):sn(e)?this.source=new cr(Ge.fromIterable(e)):Ot(e)?this.source=new cr(Ge.fromAsyncIterable(e)):$t(e)&&(this.source=new cr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||pe)}return(e){return Object.create(this.source.return&&this.source.return(e)||pe)}},cr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return O(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return O(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return O(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var Eo=class extends Cn{constructor(e,n){super(),this.position=0,this.buffer=V(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eko,Int128:()=>Ao,Int64:()=>fr,Uint64:()=>Be});function ys(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var gs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ko=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ys(this.buffer[3])} ${ys(this.buffer[2])} ${ys(this.buffer[1])} ${ys(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Ql=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return Z(Uint8Array,Z(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return Z(Uint8Array,Z(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return F.isTimestamp(e)?Z(Uint8Array,fr.convertArray(r[n])):(F.isInt(e)||F.isTime(e))&&e.bitWidth===64||F.isDuration(e)?Z(Uint8Array,fr.convertArray(r[n])):F.isDate(e)&&e.unit===Fe.MILLISECOND?Z(Uint8Array,fr.convertArray(r[n])):F.isDecimal(e)?Z(Uint8Array,Ao.convertArray(r[n])):F.isBinary(e)||F.isLargeBinary(e)||F.isFixedSizeBinary(e)?QS(r[n]):F.isBool(e)?gi(r[n]):F.isUtf8(e)||F.isLargeUtf8(e)?Tn(r[n].join("")):Z(Uint8Array,Z(e.ArrayType,r[n].map(i=>+i)))}};function QS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var vs=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var _s=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Gl=class extends ge{constructor(e){super(e),this._values=new ps}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Me{};Si.prototype._setValue=Df;var Mo=class extends Si{};Mo.prototype._setValue=Sl;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Me{};Uo.prototype._setValue=Of;var Xl=class extends ge{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new At(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Ro=class extends Me{};Ro.prototype._setValue=Bf;var Zl=class extends ge{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new mn(this.type.listSize,new J(n,e.type,!0)),r}};var xi=class extends Me{setValue(e,n){this._values.set(e,n)}},Jl=class extends xi{setValue(e,n){super.setValue(e,Bo(n))}},ql=class extends xi{},eu=class extends xi{};var Ii=class extends Me{};Ii.prototype._setValue=Ff;var Po=class extends Ii{};Po.prototype._setValue=El;var jo=class extends Ii{};jo.prototype._setValue=kl;var dr=class extends Me{};dr.prototype._setValue=Ef;var zo=class extends dr{};zo.prototype._setValue=Al;var Vo=class extends dr{};Vo.prototype._setValue=Ll;var $o=class extends dr{};$o.prototype._setValue=Ml;var Wo=class extends dr{};Wo.prototype._setValue=Cl;var Kt=class extends Me{setValue(e,n){this._values.set(e,n)}},tu=class extends Kt{},nu=class extends Kt{},ru=class extends Kt{},iu=class extends Kt{},su=class extends Kt{},ou=class extends Kt{},au=class extends Kt{},lu=class extends Kt{};var uu=class extends vt{constructor(e){super(e),this._offsets=new ms(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new hn(new J(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new yn(new J(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var fu=class extends ge{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var du=class extends ge{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new he([...this.type.children,new J(n,e.type,!0)]),r}};var hr=class extends Me{};hr.prototype._setValue=Nf;var Ho=class extends hr{};Ho.prototype._setValue=xl;var Yo=class extends hr{};Yo.prototype._setValue=Il;var Ko=class extends hr{};Ko.prototype._setValue=Bl;var Qo=class extends hr{};Qo.prototype._setValue=Dl;var pr=class extends Me{};pr.prototype._setValue=Tf;var Go=class extends pr{};Go.prototype._setValue=Nl;var Xo=class extends pr{};Xo.prototype._setValue=Tl;var Zo=class extends pr{};Zo.prototype._setValue=Ol;var Jo=class extends pr{};Jo.prototype._setValue=Fl;var ws=class extends ge{constructor(e){super(e),this._typeIds=new ar(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new J(n,e.type)];return this.type=new pn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},hu=class extends ws{},pu=class extends ws{constructor(e){super(e),this._offsets=new ar(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var qo=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,Tn(n))}_flushPending(e,n){}};qo.prototype._flushPending=vs.prototype._flushPending;var ea=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,Tn(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var Qf=class extends C{visitNull(){return fu}visitBool(){return Gl}visitInt(){return Kt}visitInt8(){return tu}visitInt16(){return nu}visitInt32(){return ru}visitInt64(){return iu}visitUint8(){return su}visitUint16(){return ou}visitUint32(){return au}visitUint64(){return lu}visitFloat(){return xi}visitFloat16(){return Jl}visitFloat32(){return ql}visitFloat64(){return eu}visitUtf8(){return qo}visitLargeUtf8(){return ea}visitBinary(){return vs}visitLargeBinary(){return _s}visitFixedSizeBinary(){return Ro}visitDate(){return Si}visitDateDay(){return Mo}visitDateMillisecond(){return Co}visitTimestamp(){return hr}visitTimestampSecond(){return Ho}visitTimestampMillisecond(){return Yo}visitTimestampMicrosecond(){return Ko}visitTimestampNanosecond(){return Qo}visitTime(){return pr}visitTimeSecond(){return Go}visitTimeMillisecond(){return Xo}visitTimeMicrosecond(){return Zo}visitTimeNanosecond(){return Jo}visitDecimal(){return Uo}visitList(){return uu}visitStruct(){return du}visitUnion(){return ws}visitDenseUnion(){return pu}visitSparseUnion(){return hu}visitDictionary(){return Xl}visitInterval(){return Ii}visitIntervalDayTime(){return Po}visitIntervalYearMonth(){return jo}visitDuration(){return dr}visitDurationSecond(){return zo}visitDurationMillisecond(){return Vo}visitDurationMicrosecond(){return $o}visitDurationNanosecond(){return Wo}visitFixedSizeList(){return Zl}visitMap(){return cu}},uy=new Qf;var j=class extends C{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function dt(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||dt(t,e)}function mr(t,e){return t===e||dt(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function mu(t,e){return t===e||dt(t,e)&&t.precision===e.precision}function GS(t,e){return t===e||dt(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ta(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function na(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function XS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function ZS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||dt(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Un.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||dt(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Un.visit(t.indices,e.indices)&&Un.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ra(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function qS(t,e){return t===e||dt(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function eb(t,e){return t===e||dt(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}j.prototype.visitNull=Bi;j.prototype.visitBool=Bi;j.prototype.visitInt=mr;j.prototype.visitInt8=mr;j.prototype.visitInt16=mr;j.prototype.visitInt32=mr;j.prototype.visitInt64=mr;j.prototype.visitUint8=mr;j.prototype.visitUint16=mr;j.prototype.visitUint32=mr;j.prototype.visitUint64=mr;j.prototype.visitFloat=mu;j.prototype.visitFloat16=mu;j.prototype.visitFloat32=mu;j.prototype.visitFloat64=mu;j.prototype.visitUtf8=Bi;j.prototype.visitLargeUtf8=Bi;j.prototype.visitBinary=Bi;j.prototype.visitLargeBinary=Bi;j.prototype.visitFixedSizeBinary=GS;j.prototype.visitDate=Gf;j.prototype.visitDateDay=Gf;j.prototype.visitDateMillisecond=Gf;j.prototype.visitTimestamp=ta;j.prototype.visitTimestampSecond=ta;j.prototype.visitTimestampMillisecond=ta;j.prototype.visitTimestampMicrosecond=ta;j.prototype.visitTimestampNanosecond=ta;j.prototype.visitTime=na;j.prototype.visitTimeSecond=na;j.prototype.visitTimeMillisecond=na;j.prototype.visitTimeMicrosecond=na;j.prototype.visitTimeNanosecond=na;j.prototype.visitDecimal=Bi;j.prototype.visitList=XS;j.prototype.visitStruct=ZS;j.prototype.visitUnion=Xf;j.prototype.visitDenseUnion=Xf;j.prototype.visitSparseUnion=Xf;j.prototype.visitDictionary=JS;j.prototype.visitInterval=Zf;j.prototype.visitIntervalDayTime=Zf;j.prototype.visitIntervalYearMonth=Zf;j.prototype.visitDuration=ra;j.prototype.visitDurationSecond=ra;j.prototype.visitDurationMillisecond=ra;j.prototype.visitDurationMicrosecond=ra;j.prototype.visitDurationNanosecond=ra;j.prototype.visitFixedSizeList=qS;j.prototype.visitMap=eb;var Un=new j;function Di(t,e){return Un.compareSchemas(t,e)}function cy(t,e){return Un.compareFields(t,e)}function fy(t,e){return Un.visit(t,e)}function bi(t){let e=t.type,n=new(uy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function yu(t,e){return tb(t,e.map(n=>n.data.concat()))}function tb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((d,y)=>Math.max(d,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Q({type:new he(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(d=>new Ne(t,d))]}function nb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let d=t[a];t[a]=d.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Q({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var dy,_t=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new ae([]),this._offsets=[0],this;let i,s;e[0]instanceof ae&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Ne)return[l];if(l instanceof t)return l.batches;if(l instanceof se){if(l.type instanceof he)return[new Ne(new ae(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new ee([l[v]])),d=i??new ae(u.map((v,S)=>new J(String(v),c[S].type,c[S].nullable))),[,y]=yu(d,c);return y.length===0?[new Ne(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new ae([]),!(i instanceof ae))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Ne))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?hs.visit(new ee(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +return true;`)}function HS(t){return typeof t!="bigint"?fn(t):`${fn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function ly(t,e=0){return t.length>=e?t.subarray(0,e):uo(new t.constructor(e),t,0)}var vn=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=ly(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=ly(this.buffer,e)}},ar=class extends vn{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ps=class extends ar{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ge=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ps,n&&n.length>0&&(this._isValid=ay(n))}toVector(){return new ee([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:d}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=d?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),Q({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ge.prototype.length=1;ge.prototype.stride=1;ge.prototype.children=null;ge.prototype.finished=!1;ge.prototype.nullValues=null;ge.prototype._isValid=()=>!0;var Me=class extends ge{constructor(e){super(e),this._values=new ar(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},vt=class extends ge{constructor(e){super(e),this._pendingLength=0,this._offsets=new ms(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Ln?n[zr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Mt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new gt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var ae=class t{constructor(e=[],n,r,i=le.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Yl(Yl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Yl(Yl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};ae.prototype.fields=null;ae.prototype.metadata=null;ae.prototype.dictionaries=null;var J=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};J.prototype.type=null;J.prototype.name=null;J.prototype.nullable=null;J.prototype.metadata=null;function Yl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var YS=hi,KS=Ft,lr=class{static decode(e){e=new KS(V(e));let n=Mt.getRootAsFooter(e),r=ae.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new YS,r=ae.encode(n,e.schema);Mt.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())ur.encode(n,o);let i=n.endVector();Mt.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())ur.encode(n,o);let s=n.endVector();return Mt.startFooter(n),Mt.addSchema(n,r),Mt.addVersion(n,le.V5),Mt.addRecordBatches(n,i),Mt.addDictionaries(n,s),Mt.finishFooterBuffer(n,Mt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=le.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(pe);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return O(this,void 0,void 0,function*(){return yield this.abort(e),pe})}return(e){return O(this,void 0,void 0,function*(){return yield this.close(),pe})}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(pe)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Mn=class extends Kl{write(e){if((e=V(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ao(this.toUint8Array(!0)):this.toUint8Array(!1).then(ao)}toUint8Array(e=!1){return e?Et(this._values)[0]:O(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=rn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Et(o,a)[0]})}},Cn=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Yt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Mn?this.source=new cr(Ge.fromAsyncIterable(e)):nl(e)?this.source=new cr(Ge.fromNodeStream(e)):lo(e)?this.source=new cr(Ge.fromDOMStream(e)):el(e)?this.source=new cr(Ge.fromDOMStream(e.body)):sn(e)?this.source=new cr(Ge.fromIterable(e)):Ot(e)?this.source=new cr(Ge.fromAsyncIterable(e)):$t(e)&&(this.source=new cr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||pe)}return(e){return Object.create(this.source.return&&this.source.return(e)||pe)}},cr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return O(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return O(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return O(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var Fo=class extends Cn{constructor(e,n){super(),this.position=0,this.buffer=V(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eko,Int128:()=>Ao,Int64:()=>fr,Uint64:()=>Be});function ys(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var gs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ko=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ys(this.buffer[3])} ${ys(this.buffer[2])} ${ys(this.buffer[1])} ${ys(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Ql=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return Z(Uint8Array,Z(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return Z(Uint8Array,Z(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return E.isTimestamp(e)?Z(Uint8Array,fr.convertArray(r[n])):(E.isInt(e)||E.isTime(e))&&e.bitWidth===64||E.isDuration(e)?Z(Uint8Array,fr.convertArray(r[n])):E.isDate(e)&&e.unit===Ee.MILLISECOND?Z(Uint8Array,fr.convertArray(r[n])):E.isDecimal(e)?Z(Uint8Array,Ao.convertArray(r[n])):E.isBinary(e)||E.isLargeBinary(e)||E.isFixedSizeBinary(e)?QS(r[n]):E.isBool(e)?gi(r[n]):E.isUtf8(e)||E.isLargeUtf8(e)?Tn(r[n].join("")):Z(Uint8Array,Z(e.ArrayType,r[n].map(i=>+i)))}};function QS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var vs=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var _s=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Gl=class extends ge{constructor(e){super(e),this._values=new ps}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Me{};Si.prototype._setValue=Df;var Mo=class extends Si{};Mo.prototype._setValue=Sl;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Me{};Uo.prototype._setValue=Of;var Xl=class extends ge{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new At(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Ro=class extends Me{};Ro.prototype._setValue=Bf;var Zl=class extends ge{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new mn(this.type.listSize,new J(n,e.type,!0)),r}};var xi=class extends Me{setValue(e,n){this._values.set(e,n)}},Jl=class extends xi{setValue(e,n){super.setValue(e,Bo(n))}},ql=class extends xi{},eu=class extends xi{};var Ii=class extends Me{};Ii.prototype._setValue=Ef;var Po=class extends Ii{};Po.prototype._setValue=Fl;var jo=class extends Ii{};jo.prototype._setValue=kl;var dr=class extends Me{};dr.prototype._setValue=Ff;var zo=class extends dr{};zo.prototype._setValue=Al;var Vo=class extends dr{};Vo.prototype._setValue=Ll;var $o=class extends dr{};$o.prototype._setValue=Ml;var Wo=class extends dr{};Wo.prototype._setValue=Cl;var Kt=class extends Me{setValue(e,n){this._values.set(e,n)}},tu=class extends Kt{},nu=class extends Kt{},ru=class extends Kt{},iu=class extends Kt{},su=class extends Kt{},ou=class extends Kt{},au=class extends Kt{},lu=class extends Kt{};var uu=class extends vt{constructor(e){super(e),this._offsets=new ms(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new hn(new J(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new yn(new J(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var fu=class extends ge{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var du=class extends ge{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new he([...this.type.children,new J(n,e.type,!0)]),r}};var hr=class extends Me{};hr.prototype._setValue=Nf;var Ho=class extends hr{};Ho.prototype._setValue=xl;var Yo=class extends hr{};Yo.prototype._setValue=Il;var Ko=class extends hr{};Ko.prototype._setValue=Bl;var Qo=class extends hr{};Qo.prototype._setValue=Dl;var pr=class extends Me{};pr.prototype._setValue=Tf;var Go=class extends pr{};Go.prototype._setValue=Nl;var Xo=class extends pr{};Xo.prototype._setValue=Tl;var Zo=class extends pr{};Zo.prototype._setValue=Ol;var Jo=class extends pr{};Jo.prototype._setValue=El;var ws=class extends ge{constructor(e){super(e),this._typeIds=new ar(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new J(n,e.type)];return this.type=new pn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},hu=class extends ws{},pu=class extends ws{constructor(e){super(e),this._offsets=new ar(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var qo=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,Tn(n))}_flushPending(e,n){}};qo.prototype._flushPending=vs.prototype._flushPending;var ea=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,Tn(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var Qf=class extends C{visitNull(){return fu}visitBool(){return Gl}visitInt(){return Kt}visitInt8(){return tu}visitInt16(){return nu}visitInt32(){return ru}visitInt64(){return iu}visitUint8(){return su}visitUint16(){return ou}visitUint32(){return au}visitUint64(){return lu}visitFloat(){return xi}visitFloat16(){return Jl}visitFloat32(){return ql}visitFloat64(){return eu}visitUtf8(){return qo}visitLargeUtf8(){return ea}visitBinary(){return vs}visitLargeBinary(){return _s}visitFixedSizeBinary(){return Ro}visitDate(){return Si}visitDateDay(){return Mo}visitDateMillisecond(){return Co}visitTimestamp(){return hr}visitTimestampSecond(){return Ho}visitTimestampMillisecond(){return Yo}visitTimestampMicrosecond(){return Ko}visitTimestampNanosecond(){return Qo}visitTime(){return pr}visitTimeSecond(){return Go}visitTimeMillisecond(){return Xo}visitTimeMicrosecond(){return Zo}visitTimeNanosecond(){return Jo}visitDecimal(){return Uo}visitList(){return uu}visitStruct(){return du}visitUnion(){return ws}visitDenseUnion(){return pu}visitSparseUnion(){return hu}visitDictionary(){return Xl}visitInterval(){return Ii}visitIntervalDayTime(){return Po}visitIntervalYearMonth(){return jo}visitDuration(){return dr}visitDurationSecond(){return zo}visitDurationMillisecond(){return Vo}visitDurationMicrosecond(){return $o}visitDurationNanosecond(){return Wo}visitFixedSizeList(){return Zl}visitMap(){return cu}},uy=new Qf;var j=class extends C{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function dt(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||dt(t,e)}function mr(t,e){return t===e||dt(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function mu(t,e){return t===e||dt(t,e)&&t.precision===e.precision}function GS(t,e){return t===e||dt(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ta(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function na(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function XS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function ZS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||dt(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Un.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||dt(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Un.visit(t.indices,e.indices)&&Un.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ra(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function qS(t,e){return t===e||dt(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}function eb(t,e){return t===e||dt(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Un.compareManyFields(t.children,e.children)}j.prototype.visitNull=Bi;j.prototype.visitBool=Bi;j.prototype.visitInt=mr;j.prototype.visitInt8=mr;j.prototype.visitInt16=mr;j.prototype.visitInt32=mr;j.prototype.visitInt64=mr;j.prototype.visitUint8=mr;j.prototype.visitUint16=mr;j.prototype.visitUint32=mr;j.prototype.visitUint64=mr;j.prototype.visitFloat=mu;j.prototype.visitFloat16=mu;j.prototype.visitFloat32=mu;j.prototype.visitFloat64=mu;j.prototype.visitUtf8=Bi;j.prototype.visitLargeUtf8=Bi;j.prototype.visitBinary=Bi;j.prototype.visitLargeBinary=Bi;j.prototype.visitFixedSizeBinary=GS;j.prototype.visitDate=Gf;j.prototype.visitDateDay=Gf;j.prototype.visitDateMillisecond=Gf;j.prototype.visitTimestamp=ta;j.prototype.visitTimestampSecond=ta;j.prototype.visitTimestampMillisecond=ta;j.prototype.visitTimestampMicrosecond=ta;j.prototype.visitTimestampNanosecond=ta;j.prototype.visitTime=na;j.prototype.visitTimeSecond=na;j.prototype.visitTimeMillisecond=na;j.prototype.visitTimeMicrosecond=na;j.prototype.visitTimeNanosecond=na;j.prototype.visitDecimal=Bi;j.prototype.visitList=XS;j.prototype.visitStruct=ZS;j.prototype.visitUnion=Xf;j.prototype.visitDenseUnion=Xf;j.prototype.visitSparseUnion=Xf;j.prototype.visitDictionary=JS;j.prototype.visitInterval=Zf;j.prototype.visitIntervalDayTime=Zf;j.prototype.visitIntervalYearMonth=Zf;j.prototype.visitDuration=ra;j.prototype.visitDurationSecond=ra;j.prototype.visitDurationMillisecond=ra;j.prototype.visitDurationMicrosecond=ra;j.prototype.visitDurationNanosecond=ra;j.prototype.visitFixedSizeList=qS;j.prototype.visitMap=eb;var Un=new j;function Di(t,e){return Un.compareSchemas(t,e)}function cy(t,e){return Un.compareFields(t,e)}function fy(t,e){return Un.visit(t,e)}function bi(t){let e=t.type,n=new(uy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function yu(t,e){return tb(t,e.map(n=>n.data.concat()))}function tb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((d,y)=>Math.max(d,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Q({type:new he(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(d=>new Ne(t,d))]}function nb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let d=t[a];t[a]=d.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Q({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var dy,_t=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new ae([]),this._offsets=[0],this;let i,s;e[0]instanceof ae&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Ne)return[l];if(l instanceof t)return l.batches;if(l instanceof se){if(l.type instanceof he)return[new Ne(new ae(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new ee([l[v]])),d=i??new ae(u.map((v,S)=>new J(String(v),c[S].type,c[S].nullable))),[,y]=yu(d,c);return y.length===0?[new Ne(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new ae([]),!(i instanceof ae))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Ne))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?hs.visit(new ee(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){let n=this.schema,r=this.data.concat(e.flatMap(({data:i})=>i));return new t(n,r.map(i=>new Ne(n,i)))}slice(e,n){let r=this.schema;[e,n]=Do({length:this.numRows},e,n);let i=Vl(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Ne(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new ee(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=yu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,d]=a,y=n.findIndex(v=>v.name===l.name);return~y?d[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...yu(s,o))}};dy=Symbol.toStringTag;_t[dy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ds(Oo),t.get=ds(Le.getVisitFn(p.Struct)),t.set=$l(Xe.getVisitFn(p.Struct)),t.indexOf=Wl(vi.getVisitFn(p.Struct)),"Table"))(_t.prototype);var py,Ne=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof ae))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new he(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=e,!(this.data instanceof se))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=hy(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=J.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new ae(r),a=Q({type:new he(r),length:s,children:i,nullCount:0});[this.schema,this.data]=hy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=my(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Le.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return hs.visit(new ee([this.data]))}toArray(){return[...this]}concat(...e){return new _t(this.schema,[this,...e])}slice(e,n){let[r]=new ee([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,Q({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Q({type:new he(n.fields),length:this.numRows,children:r});return new t(n,i)}};py=Symbol.toStringTag;Ne[py]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ne.prototype);function hy(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Q({type:new he(i),length:n,children:s})]}function my(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sQ({type:i.type})),r=Q({type:new he(e.fields),nullCount:0,children:n});super(e,r)}};var _n=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):q.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,q.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends C{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return ln.startInt(n),ln.addBitWidth(n,e.bitWidth),ln.addIsSigned(n,e.isSigned),ln.endInt(n)}visitFloat(e,n){return Cr.startFloatingPoint(n),Cr.addPrecision(n,e.precision),Cr.endFloatingPoint(n)}visitBinary(e,n){return mo.startBinary(n),mo.endBinary(n)}visitLargeBinary(e,n){return go.startLargeBinary(n),go.endLargeBinary(n)}visitBool(e,n){return yo.startBool(n),yo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitLargeUtf8(e,n){return vo.startLargeUtf8(n),vo.endLargeUtf8(n)}visitDecimal(e,n){return kn.startDecimal(n),kn.addScale(n,e.scale),kn.addPrecision(n,e.precision),kn.addBitWidth(n,e.bitWidth),kn.endDecimal(n)}visitDate(e,n){return kr.startDate(n),kr.addUnit(n,e.unit),kr.endDate(n)}visitTime(e,n){return Yn.startTime(n),Yn.addUnit(n,e.unit),Yn.addBitWidth(n,e.bitWidth),Yn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Kn.startTimestamp(n),Kn.addUnit(n,e.unit),r!==void 0&&Kn.addTimezone(n,r),Kn.endTimestamp(n)}visitInterval(e,n){return Ur.startInterval(n),Ur.addUnit(n,e.unit),Ur.endInterval(n)}visitDuration(e,n){return Ar.startDuration(n),Ar.addUnit(n,e.unit),Ar.endDuration(n)}visitList(e,n){return _o.startList(n),_o.endList(n)}visitStruct(e,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(e,n){un.startTypeIdsVector(n,e.typeIds.length);let r=un.createTypeIdsVector(n,e.typeIds);return un.startUnion(n),un.addMode(n,e.mode),un.addTypeIds(n,r),un.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return En.startDictionaryEncoding(n),En.addId(n,BigInt(e.id)),En.addIsOrdered(n,e.isOrdered),r!==void 0&&En.addIndexType(n,r),En.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Lr.startFixedSizeBinary(n),Lr.addByteWidth(n,e.byteWidth),Lr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Mr.startFixedSizeList(n),Mr.addListSize(n,e.listSize),Mr.endFixedSizeList(n)}visitMap(e,n){return Rr.startMap(n),Rr.addKeysSorted(n,e.keysSorted),Rr.endMap(n)}},gu=new Jf;function _y(t,e=new Map){return new ae(ib(t,e),vu(t.metadata),e)}function qf(t){return new Ze(t.count,Sy(t.columns),by(t.columns))}function wy(t){return new St(qf(t.data),t.id,t.isDelta)}function ib(t,e){return(t.fields||[]).filter(Boolean).map(n=>J.fromJSON(n,e))}function yy(t,e){return(t.children||[]).filter(Boolean).map(n=>J.fromJSON(n,e))}function Sy(t){return(t||[]).reduce((e,n)=>[...e,new Qt(n.count,sb(n.VALIDITY)),...Sy(n.children)],[])}function by(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function xy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=vy(t,yy(t,e)),i=new J(t.name,o,t.nullable,vu(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?gy(r):new An,a=new At(e.get(n),r,n,s.isOrdered),i=new J(t.name,a,t.nullable,vu(t.metadata))):(r=(r=s.indexType)?gy(r):new An,e.set(n,o=vy(t,yy(t,e))),a=new At(o,r,n,s.isOrdered),i=new J(t.name,a,t.nullable,vu(t.metadata))),i||null}function vu(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function gy(t){return new Pe(t.isSigned,t.bitWidth)}function vy(t,e){let n=t.type.name;switch(n){case"NONE":return new ft;case"null":return new ft;case"binary":return new Qn;case"largebinary":return new Gn;case"utf8":return new Xn;case"largeutf8":return new Zn;case"bool":return new Jn;case"list":return new hn((e||[])[0]);case"struct":return new he(e||[]);case"struct_":return new he(e||[])}switch(n){case"int":{let r=t.type;return new Pe(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Ht(ce[r.precision])}case"decimal":{let r=t.type;return new qn(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new er(Fe[r.unit])}case"time":{let r=t.type;return new tr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new nr(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new rr(We[r.unit])}case"duration":{let r=t.type;return new ir(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new pn(de[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new sr(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new mn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new yn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ob=hi,ab=Et,bt=class t{static fromJSON(e,n){let r=new t(0,le.V5,n);return r._createHeader=lb(e,n),r}static decode(e){e=new ab(V(e));let n=_n.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=ub(n,s),o}static encode(e){let n=new ob,r=-1;return e.isSchema()?r=ae.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=St.encode(n,e.header())),_n.startMessage(n),_n.addVersion(n,le.V5),_n.addHeader(n,r),_n.addHeaderType(n,e.headerType),_n.addBodyLength(n,BigInt(e.bodyLength)),_n.finishMessageBuffer(n,_n.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof ae)return new t(0,le.V5,q.Schema,e);if(e instanceof Ze)return new t(n,le.V5,q.RecordBatch,e);if(e instanceof St)return new t(n,le.V5,q.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===q.Schema}isRecordBatch(){return this.headerType===q.RecordBatch}isDictionaryBatch(){return this.headerType===q.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},St=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},wt=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Qt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function lb(t,e){return(()=>{switch(e){case q.Schema:return ae.fromJSON(t);case q.RecordBatch:return Ze.fromJSON(t);case q.DictionaryBatch:return St.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${q[e]}, type: ${e} }`)})}function ub(t,e){return(()=>{switch(e){case q.Schema:return ae.decode(t.header(new gt),new Map,t.version());case q.RecordBatch:return Ze.decode(t.header(new kt),t.version());case q.DictionaryBatch:return St.decode(t.header(new Hn),t.version())}throw new Error(`Unrecognized Message type: { name: ${q[e]}, type: ${e} }`)})}J.encode=wb;J.decode=vb;J.fromJSON=xy;ae.encode=_b;ae.decode=cb;ae.fromJSON=_y;Ze.encode=Sb;Ze.decode=fb;Ze.fromJSON=qf;St.encode=bb;St.decode=db;St.fromJSON=wy;Qt.encode=xb;Qt.decode=pb;wt.encode=Ib;wt.decode=hb;function cb(t,e=new Map,n=le.V5){let r=gb(t,e);return new ae(r,_u(t),e,n)}function fb(t,e=le.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),mb(t),yb(t,e))}function db(t,e=le.V5){return new St(Ze.decode(t.data(),e),t.id(),t.isDelta())}function hb(t){return new wt(t.offset(),t.length())}function pb(t){return new Qt(t.length(),t.nullCount())}function mb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rJ.encode(t,s));gt.startFieldsVector(t,n.length);let r=gt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?gt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return Re.startKeyValue(t),Re.addKey(t,a),Re.addValue(t,l),Re.endKeyValue(t)})):-1;return gt.startSchema(t),gt.addFields(t,r),gt.addEndianness(t,Bb?Er.Little:Er.Big),i!==-1&>.addCustomMetadata(t,i),gt.endSchema(t)}function wb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;F.isDictionary(s)?(o=s.dictionary.typeId,i=gu.visit(s,t),r=gu.visit(s.dictionary,t)):r=gu.visit(s,t);let a=(s.children||[]).map(c=>J.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,d])=>{let y=t.createString(`${c}`),v=t.createString(`${d}`);return Re.startKeyValue(t),Re.addKey(t,y),Re.addValue(t,v),Re.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function Sb(t,e){let n=e.nodes||[],r=e.buffers||[];kt.startNodesVector(t,n.length);for(let o of n.slice().reverse())Qt.encode(t,o);let i=t.endVector();kt.startBuffersVector(t,r.length);for(let o of r.slice().reverse())wt.encode(t,o);let s=t.endVector();return kt.startRecordBatch(t),kt.addLength(t,BigInt(e.length)),kt.addNodes(t,i),kt.addBuffers(t,s),kt.endRecordBatch(t)}function bb(t,e){let n=Ze.encode(t,e.data);return Hn.startDictionaryBatch(t),Hn.addId(t,BigInt(e.id)),Hn.addIsDelta(t,e.isDelta),Hn.addData(t,n),Hn.endDictionaryBatch(t)}function xb(t,e){return rs.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Ib(t,e){return ns.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Bb=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${q[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${q[t]} Message is null or length 0.`,Ny=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Ty=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,Ss=class{constructor(e){this.source=e instanceof Cn?e:new Cn(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?pe:e.value===-1&&(e=this.readMetadataLength()).done?pe:(e=this.readMetadata(e.value)).done?pe:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=V(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=q.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},wu=4,ed="ARROW1",bs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Za(e)?Nb(e):qa(e)?Fb(e):Ot(e)?O(this,void 0,void 0,function*(){return yield t.from(yield e)}):el(e)||lo(e)||nl(e)||$t(e)?Ob(new Yt(e)):Tb(new Cn(e))}static readAll(e){return e instanceof t?e.isSync()?Fy(e):Ey(e):Za(e)||ArrayBuffer.isView(e)||sn(e)||Ja(e)?Fy(e):Ey(e)}},yr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Tt(this,arguments,function*(){yield X(yield*es(rn(this[Symbol.iterator]())))})}},Ti=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return O(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=rn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends yr{constructor(e){super(e),this._impl=e}},bu=class extends Ti{constructor(e){super(e),this._impl=e}},xu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=Q({type:new he(this.schema.fields),length:e.length,children:r});return new Ne(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new ee(u)):new ee(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Is=class extends xu{constructor(e,n){super(n),this._reader=Za(e)?new sa(this._handle=e):new Ss(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):pe}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):pe}next(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Bs=class extends xu{constructor(e,n){super(n),this._reader=new ia(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):pe})}return(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):pe})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Iu=class extends Is{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof Eo?e:new Eo(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(q.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(q.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return lr.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return O(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(q.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return O(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(q.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return lr.decode(i)})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Su(e)?new Oi(new Iu(t.read())):new yr(new Is(t)):new yr(new Is((function*(){})()))}function Ob(t){return O(this,void 0,void 0,function*(){let e=yield t.peek(xs+7&-8);return e&&e.byteLength>=4?Su(e)?new Oi(new Iu(yield t.read())):new Ti(new Bs(t)):new Ti(new Bs((function(){return Tt(this,arguments,function*(){})})()))})}function Fb(t){return O(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new $r(t,e);return e>=Oy&&Su(yield n.readAt(0,xs+7&-8))?new bu(new id(n)):new Ti(new Bs(n))})}var Se=class t extends C{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Ne?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof ee)return this.visitMany(e.data),this;let{type:n}=e;if(!F.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(F.isUnion(n))this.nodes.push(new Qt(r,0));else{let{nullCount:i}=e;F.isNull(n)||wn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Qt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function wn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new wt(this._byteLength,e)),this._byteLength+=e,this}function Eb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(wn.call(this,i),n.mode===de.Sparse)return od.call(this,t);if(n.mode===de.Dense){if(t.offset<=0)return wn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,d=-1;++d{let d=n.typeIds[c],y=a[d],v=l[d];return u.slice(y,Math.min(r,v))}))}}return this}function kb(t){let e;return t.nullCount>=t.length?wn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?wn.call(this,yi(t.offset,t.length,e)):wn.call(this,gi(t.values))}function gr(t){return wn.call(this,t.values.subarray(0,t.length*t.stride))}function Bu(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return wn.call(this,il(-i,e+1,r)),wn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return wn.call(this,il(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}Se.prototype.visitBool=kb;Se.prototype.visitInt=gr;Se.prototype.visitFloat=gr;Se.prototype.visitUtf8=Bu;Se.prototype.visitLargeUtf8=Bu;Se.prototype.visitBinary=Bu;Se.prototype.visitLargeBinary=Bu;Se.prototype.visitFixedSizeBinary=gr;Se.prototype.visitDate=gr;Se.prototype.visitTimestamp=gr;Se.prototype.visitTime=gr;Se.prototype.visitDecimal=gr;Se.prototype.visitList=ad;Se.prototype.visitStruct=od;Se.prototype.visitUnion=Eb;Se.prototype.visitInterval=gr;Se.prototype.visitDuration=gr;Se.prototype.visitFixedSizeList=ad;Se.prototype.visitMap=ad;var Fi=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Mn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ct(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ot(e)?e.then(n=>this.writeAll(n)):$t(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Mn?this._sink=e:(this._sink=new Mn,e&&Qp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Gp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof _t&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Ne&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Ne?e instanceof Ni||this._writeRecordBatch(e):e instanceof _t?this.writeAll(e.batches):sn(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=bt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===q.RecordBatch?this._recordBatchBlocks.push(new ur(a,e.bodyLength,this._position)):e.headerType===q.DictionaryBatch&&this._dictionaryBlocks.push(new ur(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=V(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(bt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=Se.assemble(e),o=new Ze(e.numRows,r,i),a=bt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=Se.assemble(new ee([e])),l=new Ze(e.length,s,o),u=new St(l,n,r),c=bt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):$t(e)?ud(r,e):ld(r,e)}},aa=class t extends Fi{static writeAll(e){let n=new t;return Ot(e)?e.then(r=>n.writeAll(r)):$t(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=lr.encode(new lr(e,le.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof _t&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return O(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=rn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function Ay(t,e){if($t(t))return Lb(t,e);if(sn(t))return Ab(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Ab(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return O(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return O(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Cy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Yp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:My;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:My}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},My=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Du(t,e){let n=new Mn,r=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Ct.from(n)).open(e)})}function o(a,l){return O(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Nu(t,e){let n=new this(t),r=new Yt(n),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function la(t){let e=Ct.from(t);return Ot(e)?e.then(n=>la(n)):e.isAsync()?e.readAll().then(n=>new _t(n)):new _t(e.readAll())}var Cb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:cy,compareTypes:fy});Ge.toDOMStream=Ay;ge.throughDOM=Cy;Ct.throughDOM=Du;Oi.throughDOM=Du;yr.throughDOM=Du;Fi.throughDOM=Nu;aa.throughDOM=Nu;oa.throughDOM=Nu;var Ub=Object.create,Rb=Object.getPrototypeOf,Vd=Object.defineProperty,Pb=Object.getOwnPropertyNames,jb=Object.prototype.hasOwnProperty;function zb(t){return this[t]}var Vb,$b,ye=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?Vb??=new WeakMap:$b??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Ub(Rb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of Pb(t))jb.call(o,a)||Vd(o,a,{get:zb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},so=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wb=t=>t;function Hb(t,e){this[t]=Wb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Hb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),bv={};Qh(bv,{Children:()=>Fv,Component:()=>Ev,Fragment:()=>kv,Profiler:()=>Av,PureComponent:()=>Lv,StrictMode:()=>Mv,Suspense:()=>Cv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Uv,act:()=>Rv,cloneElement:()=>Xb,createContext:()=>Zb,createElement:()=>Pv,createFactory:()=>Jb,createRef:()=>qb,forwardRef:()=>ex,isValidElement:()=>jv,lazy:()=>tx,memo:()=>nx,startTransition:()=>rx,unstable_act:()=>zv,useCallback:()=>ix,useContext:()=>sx,useDebugValue:()=>ox,useDeferredValue:()=>ax,useEffect:()=>lx,useId:()=>ux,useImperativeHandle:()=>cx,useInsertionEffect:()=>fx,useLayoutEffect:()=>dx,useMemo:()=>hx,useReducer:()=>px,useRef:()=>mx,useState:()=>yx,useSyncExternalStore:()=>gx,useTransition:()=>vx,version:()=>_x});function Yb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ds(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Uy(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function xv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{oo=Symbol.for("react.element"),Iv=Symbol.for("react.portal"),Py=Symbol.for("react.fragment"),jy=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),Dv=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),Vy=Symbol.for("react.suspense"),Tv=Symbol.for("react.memo"),Ov=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ds.prototype.isReactComponent={},Ds.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ds.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Uy.prototype=Ds.prototype,Ou=fd.prototype=new Uy,Ou.constructor=fd,Hd(Ou,Ds.prototype),Ou.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,cc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ia={transition:null},$y={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ia,ReactCurrentOwner:cc},Fv={map:Tu,forEach:function(t,e,n){Tu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Tu(t,function(){e++}),e},toArray:function(t){return Tu(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Ev=Ds,kv=Py,Av=zy,Lv=fd,Mv=jy,Cv=Vy,Uv=$y,Rv=Ry,Pv=xv,jv=$d,zv=Ry}),nn=so(function(t,e){wx(),e.exports=bv}),Sx=so(function(t){function e(T,M){var _=T.length;T.push(M);e:for(;0<_;){var N=_-1>>>1,te=T[N];if(0>>1;N<$e;){var ui=2*(N+1)-1,uf=T[ui],ci=ui+1,Xa=T[ci];if(0>i(uf,_))cii(Xa,uf)?(T[N]=Xa,T[ci]=_,N=ci):(T[N]=uf,T[ui]=_,N=ui);else if(cii(Xa,_))T[N]=Xa,T[ci]=_,N=ci;else break e}}return M}function i(T,M){var _=T.sortIndex-M.sortIndex;return _!==0?_:T.id-M.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,d=null,y=3,v=!1,S=!1,I=!1,Y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(T){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=T)r(u),M.sortIndex=M.expirationTime,e(l,M);else break;M=n(u)}}function g(T){if(I=!1,m(T),!S)if(n(l)!==null)S=!0,Ve(w);else{var M=n(u);M!==null&&Fr(g,M.startTime-T)}}function w(T,M){S=!1,I&&(I=!1,h(b),b=-1),v=!0;var _=y;try{for(m(M),d=n(l);d!==null&&(!(d.expirationTime>M)||T&&!ie());){var N=d.callback;if(typeof N=="function"){d.callback=null,y=d.priorityLevel;var te=N(d.expirationTime<=M);M=t.unstable_now(),typeof te=="function"?d.callback=te:d===n(l)&&r(l),m(M)}else r(l);d=n(l)}if(d!==null)var $e=!0;else{var ui=n(u);ui!==null&&Fr(g,ui.startTime-M),$e=!1}return $e}finally{d=null,y=_,v=!1}}var B=!1,D=null,b=-1,K=5,L=-1;function ie(){return!(t.unstable_now()-LT||125N?(T.sortIndex=_,e(u,T),n(l)===null&&T===n(u)&&(I?(h(b),b=-1):I=!0,Fr(g,_-N))):(T.sortIndex=te,e(l,T),S||v||(S=!0,Ve(w))),T},t.unstable_shouldYield=ie,t.unstable_wrapCallback=function(T){var M=y;return function(){var _=y;y=M;try{return T.apply(this,arguments)}finally{y=_}}}}),bx=so(function(t,e){var n=ye(Sx());e.exports=n}),Vv={};Qh(Vv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>G_,createPortal:()=>I1,createRoot:()=>B1,findDOMNode:()=>D1,flushSync:()=>N1,hydrate:()=>T1,hydrateRoot:()=>O1,render:()=>F1,unmountComponentAtNode:()=>E1,unstable_batchedUpdates:()=>X_,unstable_renderSubtreeIntoContainer:()=>k1,version:()=>A1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Ix(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ht(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=He.hasOwnProperty(e)?He[e]:null;(i!==null?i.type!==0:r||!(2i));return new t(n,r.map(i=>new Ne(n,i)))}slice(e,n){let r=this.schema;[e,n]=Do({length:this.numRows},e,n);let i=Vl(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Ne(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new ee(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=yu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,d]=a,y=n.findIndex(v=>v.name===l.name);return~y?d[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...yu(s,o))}};dy=Symbol.toStringTag;_t[dy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ds(Oo),t.get=ds(Le.getVisitFn(p.Struct)),t.set=$l(Xe.getVisitFn(p.Struct)),t.indexOf=Wl(vi.getVisitFn(p.Struct)),"Table"))(_t.prototype);var py,Ne=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof ae))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new he(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=e,!(this.data instanceof se))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=hy(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=J.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new ae(r),a=Q({type:new he(r),length:s,children:i,nullCount:0});[this.schema,this.data]=hy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=my(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Le.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return hs.visit(new ee([this.data]))}toArray(){return[...this]}concat(...e){return new _t(this.schema,[this,...e])}slice(e,n){let[r]=new ee([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,Q({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Q({type:new he(n.fields),length:this.numRows,children:r});return new t(n,i)}};py=Symbol.toStringTag;Ne[py]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ne.prototype);function hy(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Q({type:new he(i),length:n,children:s})]}function my(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sQ({type:i.type})),r=Q({type:new he(e.fields),nullCount:0,children:n});super(e,r)}};var _n=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):q.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new Re).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,q.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends C{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return ln.startInt(n),ln.addBitWidth(n,e.bitWidth),ln.addIsSigned(n,e.isSigned),ln.endInt(n)}visitFloat(e,n){return Cr.startFloatingPoint(n),Cr.addPrecision(n,e.precision),Cr.endFloatingPoint(n)}visitBinary(e,n){return mo.startBinary(n),mo.endBinary(n)}visitLargeBinary(e,n){return go.startLargeBinary(n),go.endLargeBinary(n)}visitBool(e,n){return yo.startBool(n),yo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitLargeUtf8(e,n){return vo.startLargeUtf8(n),vo.endLargeUtf8(n)}visitDecimal(e,n){return kn.startDecimal(n),kn.addScale(n,e.scale),kn.addPrecision(n,e.precision),kn.addBitWidth(n,e.bitWidth),kn.endDecimal(n)}visitDate(e,n){return kr.startDate(n),kr.addUnit(n,e.unit),kr.endDate(n)}visitTime(e,n){return Yn.startTime(n),Yn.addUnit(n,e.unit),Yn.addBitWidth(n,e.bitWidth),Yn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Kn.startTimestamp(n),Kn.addUnit(n,e.unit),r!==void 0&&Kn.addTimezone(n,r),Kn.endTimestamp(n)}visitInterval(e,n){return Ur.startInterval(n),Ur.addUnit(n,e.unit),Ur.endInterval(n)}visitDuration(e,n){return Ar.startDuration(n),Ar.addUnit(n,e.unit),Ar.endDuration(n)}visitList(e,n){return _o.startList(n),_o.endList(n)}visitStruct(e,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(e,n){un.startTypeIdsVector(n,e.typeIds.length);let r=un.createTypeIdsVector(n,e.typeIds);return un.startUnion(n),un.addMode(n,e.mode),un.addTypeIds(n,r),un.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return Fn.startDictionaryEncoding(n),Fn.addId(n,BigInt(e.id)),Fn.addIsOrdered(n,e.isOrdered),r!==void 0&&Fn.addIndexType(n,r),Fn.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Lr.startFixedSizeBinary(n),Lr.addByteWidth(n,e.byteWidth),Lr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Mr.startFixedSizeList(n),Mr.addListSize(n,e.listSize),Mr.endFixedSizeList(n)}visitMap(e,n){return Rr.startMap(n),Rr.addKeysSorted(n,e.keysSorted),Rr.endMap(n)}},gu=new Jf;function _y(t,e=new Map){return new ae(ib(t,e),vu(t.metadata),e)}function qf(t){return new Ze(t.count,Sy(t.columns),by(t.columns))}function wy(t){return new St(qf(t.data),t.id,t.isDelta)}function ib(t,e){return(t.fields||[]).filter(Boolean).map(n=>J.fromJSON(n,e))}function yy(t,e){return(t.children||[]).filter(Boolean).map(n=>J.fromJSON(n,e))}function Sy(t){return(t||[]).reduce((e,n)=>[...e,new Qt(n.count,sb(n.VALIDITY)),...Sy(n.children)],[])}function by(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function xy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=vy(t,yy(t,e)),i=new J(t.name,o,t.nullable,vu(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?gy(r):new An,a=new At(e.get(n),r,n,s.isOrdered),i=new J(t.name,a,t.nullable,vu(t.metadata))):(r=(r=s.indexType)?gy(r):new An,e.set(n,o=vy(t,yy(t,e))),a=new At(o,r,n,s.isOrdered),i=new J(t.name,a,t.nullable,vu(t.metadata))),i||null}function vu(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function gy(t){return new Pe(t.isSigned,t.bitWidth)}function vy(t,e){let n=t.type.name;switch(n){case"NONE":return new ft;case"null":return new ft;case"binary":return new Qn;case"largebinary":return new Gn;case"utf8":return new Xn;case"largeutf8":return new Zn;case"bool":return new Jn;case"list":return new hn((e||[])[0]);case"struct":return new he(e||[]);case"struct_":return new he(e||[])}switch(n){case"int":{let r=t.type;return new Pe(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Ht(ce[r.precision])}case"decimal":{let r=t.type;return new qn(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new er(Ee[r.unit])}case"time":{let r=t.type;return new tr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new nr(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new rr(We[r.unit])}case"duration":{let r=t.type;return new ir(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new pn(de[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new sr(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new mn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new yn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ob=hi,ab=Ft,bt=class t{static fromJSON(e,n){let r=new t(0,le.V5,n);return r._createHeader=lb(e,n),r}static decode(e){e=new ab(V(e));let n=_n.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=ub(n,s),o}static encode(e){let n=new ob,r=-1;return e.isSchema()?r=ae.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=St.encode(n,e.header())),_n.startMessage(n),_n.addVersion(n,le.V5),_n.addHeader(n,r),_n.addHeaderType(n,e.headerType),_n.addBodyLength(n,BigInt(e.bodyLength)),_n.finishMessageBuffer(n,_n.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof ae)return new t(0,le.V5,q.Schema,e);if(e instanceof Ze)return new t(n,le.V5,q.RecordBatch,e);if(e instanceof St)return new t(n,le.V5,q.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===q.Schema}isRecordBatch(){return this.headerType===q.RecordBatch}isDictionaryBatch(){return this.headerType===q.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},St=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},wt=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Qt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function lb(t,e){return(()=>{switch(e){case q.Schema:return ae.fromJSON(t);case q.RecordBatch:return Ze.fromJSON(t);case q.DictionaryBatch:return St.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${q[e]}, type: ${e} }`)})}function ub(t,e){return(()=>{switch(e){case q.Schema:return ae.decode(t.header(new gt),new Map,t.version());case q.RecordBatch:return Ze.decode(t.header(new kt),t.version());case q.DictionaryBatch:return St.decode(t.header(new Hn),t.version())}throw new Error(`Unrecognized Message type: { name: ${q[e]}, type: ${e} }`)})}J.encode=wb;J.decode=vb;J.fromJSON=xy;ae.encode=_b;ae.decode=cb;ae.fromJSON=_y;Ze.encode=Sb;Ze.decode=fb;Ze.fromJSON=qf;St.encode=bb;St.decode=db;St.fromJSON=wy;Qt.encode=xb;Qt.decode=pb;wt.encode=Ib;wt.decode=hb;function cb(t,e=new Map,n=le.V5){let r=gb(t,e);return new ae(r,_u(t),e,n)}function fb(t,e=le.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),mb(t),yb(t,e))}function db(t,e=le.V5){return new St(Ze.decode(t.data(),e),t.id(),t.isDelta())}function hb(t){return new wt(t.offset(),t.length())}function pb(t){return new Qt(t.length(),t.nullCount())}function mb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rJ.encode(t,s));gt.startFieldsVector(t,n.length);let r=gt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?gt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return Re.startKeyValue(t),Re.addKey(t,a),Re.addValue(t,l),Re.endKeyValue(t)})):-1;return gt.startSchema(t),gt.addFields(t,r),gt.addEndianness(t,Bb?Fr.Little:Fr.Big),i!==-1&>.addCustomMetadata(t,i),gt.endSchema(t)}function wb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;E.isDictionary(s)?(o=s.dictionary.typeId,i=gu.visit(s,t),r=gu.visit(s.dictionary,t)):r=gu.visit(s,t);let a=(s.children||[]).map(c=>J.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,d])=>{let y=t.createString(`${c}`),v=t.createString(`${d}`);return Re.startKeyValue(t),Re.addKey(t,y),Re.addValue(t,v),Re.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function Sb(t,e){let n=e.nodes||[],r=e.buffers||[];kt.startNodesVector(t,n.length);for(let o of n.slice().reverse())Qt.encode(t,o);let i=t.endVector();kt.startBuffersVector(t,r.length);for(let o of r.slice().reverse())wt.encode(t,o);let s=t.endVector();return kt.startRecordBatch(t),kt.addLength(t,BigInt(e.length)),kt.addNodes(t,i),kt.addBuffers(t,s),kt.endRecordBatch(t)}function bb(t,e){let n=Ze.encode(t,e.data);return Hn.startDictionaryBatch(t),Hn.addId(t,BigInt(e.id)),Hn.addIsDelta(t,e.isDelta),Hn.addData(t,n),Hn.endDictionaryBatch(t)}function xb(t,e){return rs.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Ib(t,e){return ns.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Bb=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${q[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${q[t]} Message is null or length 0.`,Ny=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Ty=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,Ss=class{constructor(e){this.source=e instanceof Cn?e:new Cn(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?pe:e.value===-1&&(e=this.readMetadataLength()).done?pe:(e=this.readMetadata(e.value)).done?pe:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=V(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=q.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},wu=4,ed="ARROW1",bs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Za(e)?Nb(e):qa(e)?Eb(e):Ot(e)?O(this,void 0,void 0,function*(){return yield t.from(yield e)}):el(e)||lo(e)||nl(e)||$t(e)?Ob(new Yt(e)):Tb(new Cn(e))}static readAll(e){return e instanceof t?e.isSync()?Ey(e):Fy(e):Za(e)||ArrayBuffer.isView(e)||sn(e)||Ja(e)?Ey(e):Fy(e)}},yr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Tt(this,arguments,function*(){yield X(yield*es(rn(this[Symbol.iterator]())))})}},Ti=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return O(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=rn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends yr{constructor(e){super(e),this._impl=e}},bu=class extends Ti{constructor(e){super(e),this._impl=e}},xu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=Q({type:new he(this.schema.fields),length:e.length,children:r});return new Ne(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new ee(u)):new ee(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Is=class extends xu{constructor(e,n){super(n),this._reader=Za(e)?new sa(this._handle=e):new Ss(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):pe}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):pe}next(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Bs=class extends xu{constructor(e,n){super(n),this._reader=new ia(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):pe})}return(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):pe})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Iu=class extends Is{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof Fo?e:new Fo(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(q.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(q.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return lr.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return O(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(q.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return O(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(q.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return lr.decode(i)})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Su(e)?new Oi(new Iu(t.read())):new yr(new Is(t)):new yr(new Is((function*(){})()))}function Ob(t){return O(this,void 0,void 0,function*(){let e=yield t.peek(xs+7&-8);return e&&e.byteLength>=4?Su(e)?new Oi(new Iu(yield t.read())):new Ti(new Bs(t)):new Ti(new Bs((function(){return Tt(this,arguments,function*(){})})()))})}function Eb(t){return O(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new $r(t,e);return e>=Oy&&Su(yield n.readAt(0,xs+7&-8))?new bu(new id(n)):new Ti(new Bs(n))})}var Se=class t extends C{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Ne?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof ee)return this.visitMany(e.data),this;let{type:n}=e;if(!E.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(E.isUnion(n))this.nodes.push(new Qt(r,0));else{let{nullCount:i}=e;E.isNull(n)||wn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Qt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function wn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new wt(this._byteLength,e)),this._byteLength+=e,this}function Fb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(wn.call(this,i),n.mode===de.Sparse)return od.call(this,t);if(n.mode===de.Dense){if(t.offset<=0)return wn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,d=-1;++d{let d=n.typeIds[c],y=a[d],v=l[d];return u.slice(y,Math.min(r,v))}))}}return this}function kb(t){let e;return t.nullCount>=t.length?wn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?wn.call(this,yi(t.offset,t.length,e)):wn.call(this,gi(t.values))}function gr(t){return wn.call(this,t.values.subarray(0,t.length*t.stride))}function Bu(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return wn.call(this,il(-i,e+1,r)),wn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return wn.call(this,il(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}Se.prototype.visitBool=kb;Se.prototype.visitInt=gr;Se.prototype.visitFloat=gr;Se.prototype.visitUtf8=Bu;Se.prototype.visitLargeUtf8=Bu;Se.prototype.visitBinary=Bu;Se.prototype.visitLargeBinary=Bu;Se.prototype.visitFixedSizeBinary=gr;Se.prototype.visitDate=gr;Se.prototype.visitTimestamp=gr;Se.prototype.visitTime=gr;Se.prototype.visitDecimal=gr;Se.prototype.visitList=ad;Se.prototype.visitStruct=od;Se.prototype.visitUnion=Fb;Se.prototype.visitInterval=gr;Se.prototype.visitDuration=gr;Se.prototype.visitFixedSizeList=ad;Se.prototype.visitMap=ad;var Ei=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Mn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ct(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ot(e)?e.then(n=>this.writeAll(n)):$t(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Mn?this._sink=e:(this._sink=new Mn,e&&Qp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Gp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof _t&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Ne&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Ne?e instanceof Ni||this._writeRecordBatch(e):e instanceof _t?this.writeAll(e.batches):sn(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=bt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===q.RecordBatch?this._recordBatchBlocks.push(new ur(a,e.bodyLength,this._position)):e.headerType===q.DictionaryBatch&&this._dictionaryBlocks.push(new ur(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=V(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(bt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=Se.assemble(e),o=new Ze(e.numRows,r,i),a=bt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=Se.assemble(new ee([e])),l=new Ze(e.length,s,o),u=new St(l,n,r),c=bt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):$t(e)?ud(r,e):ld(r,e)}},aa=class t extends Ei{static writeAll(e){let n=new t;return Ot(e)?e.then(r=>n.writeAll(r)):$t(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=lr.encode(new lr(e,le.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof _t&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return O(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=rn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function Ay(t,e){if($t(t))return Lb(t,e);if(sn(t))return Ab(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Ab(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return O(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return O(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Cy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Yp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:My;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:My}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},My=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Du(t,e){let n=new Mn,r=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Ct.from(n)).open(e)})}function o(a,l){return O(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Nu(t,e){let n=new this(t),r=new Yt(n),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function la(t){let e=Ct.from(t);return Ot(e)?e.then(n=>la(n)):e.isAsync()?e.readAll().then(n=>new _t(n)):new _t(e.readAll())}var Cb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:cy,compareTypes:fy});Ge.toDOMStream=Ay;ge.throughDOM=Cy;Ct.throughDOM=Du;Oi.throughDOM=Du;yr.throughDOM=Du;Ei.throughDOM=Nu;aa.throughDOM=Nu;oa.throughDOM=Nu;var Ub=Object.create,Rb=Object.getPrototypeOf,Vd=Object.defineProperty,Pb=Object.getOwnPropertyNames,jb=Object.prototype.hasOwnProperty;function zb(t){return this[t]}var Vb,$b,ye=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?Vb??=new WeakMap:$b??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Ub(Rb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of Pb(t))jb.call(o,a)||Vd(o,a,{get:zb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},so=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wb=t=>t;function Hb(t,e){this[t]=Wb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Hb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),bv={};Qh(bv,{Children:()=>Ev,Component:()=>Fv,Fragment:()=>kv,Profiler:()=>Av,PureComponent:()=>Lv,StrictMode:()=>Mv,Suspense:()=>Cv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Uv,act:()=>Rv,cloneElement:()=>Xb,createContext:()=>Zb,createElement:()=>Pv,createFactory:()=>Jb,createRef:()=>qb,forwardRef:()=>ex,isValidElement:()=>jv,lazy:()=>tx,memo:()=>nx,startTransition:()=>rx,unstable_act:()=>zv,useCallback:()=>ix,useContext:()=>sx,useDebugValue:()=>ox,useDeferredValue:()=>ax,useEffect:()=>lx,useId:()=>ux,useImperativeHandle:()=>cx,useInsertionEffect:()=>fx,useLayoutEffect:()=>dx,useMemo:()=>hx,useReducer:()=>px,useRef:()=>mx,useState:()=>yx,useSyncExternalStore:()=>gx,useTransition:()=>vx,version:()=>_x});function Yb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ds(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Uy(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function xv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{oo=Symbol.for("react.element"),Iv=Symbol.for("react.portal"),Py=Symbol.for("react.fragment"),jy=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),Dv=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),Vy=Symbol.for("react.suspense"),Tv=Symbol.for("react.memo"),Ov=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ds.prototype.isReactComponent={},Ds.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ds.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Uy.prototype=Ds.prototype,Ou=fd.prototype=new Uy,Ou.constructor=fd,Hd(Ou,Ds.prototype),Ou.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,cc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ia={transition:null},$y={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ia,ReactCurrentOwner:cc},Ev={map:Tu,forEach:function(t,e,n){Tu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Tu(t,function(){e++}),e},toArray:function(t){return Tu(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Fv=Ds,kv=Py,Av=zy,Lv=fd,Mv=jy,Cv=Vy,Uv=$y,Rv=Ry,Pv=xv,jv=$d,zv=Ry}),nn=so(function(t,e){wx(),e.exports=bv}),Sx=so(function(t){function e(T,M){var _=T.length;T.push(M);e:for(;0<_;){var N=_-1>>>1,te=T[N];if(0>>1;N<$e;){var ui=2*(N+1)-1,uf=T[ui],ci=ui+1,Xa=T[ci];if(0>i(uf,_))cii(Xa,uf)?(T[N]=Xa,T[ci]=_,N=ci):(T[N]=uf,T[ui]=_,N=ui);else if(cii(Xa,_))T[N]=Xa,T[ci]=_,N=ci;else break e}}return M}function i(T,M){var _=T.sortIndex-M.sortIndex;return _!==0?_:T.id-M.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,d=null,y=3,v=!1,S=!1,I=!1,Y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(T){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=T)r(u),M.sortIndex=M.expirationTime,e(l,M);else break;M=n(u)}}function g(T){if(I=!1,m(T),!S)if(n(l)!==null)S=!0,Ve(w);else{var M=n(u);M!==null&&Er(g,M.startTime-T)}}function w(T,M){S=!1,I&&(I=!1,h(b),b=-1),v=!0;var _=y;try{for(m(M),d=n(l);d!==null&&(!(d.expirationTime>M)||T&&!ie());){var N=d.callback;if(typeof N=="function"){d.callback=null,y=d.priorityLevel;var te=N(d.expirationTime<=M);M=t.unstable_now(),typeof te=="function"?d.callback=te:d===n(l)&&r(l),m(M)}else r(l);d=n(l)}if(d!==null)var $e=!0;else{var ui=n(u);ui!==null&&Er(g,ui.startTime-M),$e=!1}return $e}finally{d=null,y=_,v=!1}}var B=!1,D=null,b=-1,K=5,L=-1;function ie(){return!(t.unstable_now()-LT||125N?(T.sortIndex=_,e(u,T),n(l)===null&&T===n(u)&&(I?(h(b),b=-1):I=!0,Er(g,_-N))):(T.sortIndex=te,e(l,T),S||v||(S=!0,Ve(w))),T},t.unstable_shouldYield=ie,t.unstable_wrapCallback=function(T){var M=y;return function(){var _=y;y=M;try{return T.apply(this,arguments)}finally{y=_}}}}),bx=so(function(t,e){var n=ye(Sx());e.exports=n}),Vv={};Qh(Vv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>G_,createPortal:()=>I1,createRoot:()=>B1,findDOMNode:()=>D1,flushSync:()=>N1,hydrate:()=>T1,hydrateRoot:()=>O1,render:()=>E1,unmountComponentAtNode:()=>F1,unstable_batchedUpdates:()=>X_,unstable_renderSubtreeIntoContainer:()=>k1,version:()=>A1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Ix(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ht(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=He.hasOwnProperty(e)?He[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Fd=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?va(t):""}function Dx(t){switch(t.tag){case 5:return va(t.type);case 16:return va("Lazy");case 13:return va("Suspense");case 19:return va("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Ic:return"Profiler";case Jc:return"StrictMode";case Bc:return"Suspense";case Dc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case qc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ef:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case wr:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Nx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===Jc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function oi(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $v(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Tx(t){var e=$v(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Fu(t){t._valueTracker||(t._valueTracker=Tx(t))}function Wv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=$v(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function fc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return be({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Wy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=oi(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Hv(t,e);var n=oi(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,oi(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Hy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||fc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function $s(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(c_(t)/f_|0)|0}function _a(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function dc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=_a(a):(s&=o,s!==0&&(r=_a(s)))}else o=n&~i,o!==0?r=_a(o):s!==0&&(r=_a(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Qa(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-en(e),t[e]=n}function Ux(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tg(n)}}function h0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?h0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function p0(){for(var t=window,e=fc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Jx(t){var e=p0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&h0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=ng(n,s);var o=ng(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;nPs||(t.current=Lc[Ps],Lc[Ps]=null,Ps--)}function me(t,e){Ps++,Lc[Ps]=t.current,t.current=e}function Gs(t,e){var n=t.type.contextTypes;if(!n)return Nr;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(t){return t=t.childContextTypes,t!=null}function yc(){_e(yt),_e(tt)}function lg(t,e,n){if(tt.current!==Nr)throw Error(x(168));me(tt,e),me(yt,n)}function g0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Nx(t)||"Unknown",i));return be({},n,r)}function gc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Nr,ai=tt.current,me(tt,t),me(yt,yt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=g0(t,e,ai),r.__reactInternalMemoizedMergedChildContext=t,_e(yt),_e(tt),me(tt,t)):_e(yt),me(yt,n)}function v0(t){Sr===null?Sr=[t]:Sr.push(t)}function e1(t){sf=!0,v0(t)}function li(){if(!Rd&&Sr!==null){Rd=!0;var t=0,e=ue;try{var n=Sr;for(ue=1;t>=o,i-=o,Ir=1<<32-en(e)+i|n<b?(K=D,D=null):K=D.sibling;var L=y(h,D,m[b],g);if(L===null){D===null&&(D=K);break}t&&D&&L.alternate===null&&e(h,D),f=s(L,f,b),B===null?w=L:B.sibling=L,B=L,D=K}if(b===m.length)return n(h,D),Ie&&Li(h,b),w;if(D===null){for(;bb?(K=D,D=null):K=D.sibling;var ie=y(h,D,L.value,g);if(ie===null){D===null&&(D=K);break}t&&D&&ie.alternate===null&&e(h,D),f=s(ie,f,b),B===null?w=ie:B.sibling=ie,B=ie,D=K}if(L.done)return n(h,D),Ie&&Li(h,b),w;if(D===null){for(;!L.done;b++,L=m.next())L=d(h,L.value,g),L!==null&&(f=s(L,f,b),B===null?w=L:B.sibling=L,B=L);return Ie&&Li(h,b),w}for(D=r(h,D);!L.done;b++,L=m.next())L=v(D,h,b,L.value,g),L!==null&&(t&&L.alternate!==null&&D.delete(L.key===null?b:L.key),f=s(L,f,b),B===null?w=L:B.sibling=L,B=L);return t&&D.forEach(function(Qe){return e(h,Qe)}),Ie&&Li(h,b),w}function Y(h,f,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Sa:e:{for(var w=m.key,B=f;B!==null;){if(B.key===w){if(w=m.type,w===ji){if(B.tag===7){n(h,B.sibling),f=i(B,m.props.children),f.return=h,h=f;break e}}else if(B.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===wr&&dg(w)===B.type){n(h,B.sibling),f=i(B,m.props),f.ref=da(h,B,m),f.return=h,h=f;break e}n(h,B);break}else e(h,B);B=B.sibling}m.type===ji?(f=Yi(m.props.children,h.mode,g,m.key),f.return=h,h=f):(g=tc(m.type,m.key,m.props,null,h.mode,g),g.ref=da(h,f,m),g.return=h,h=g)}return o(h);case Pi:e:{for(B=m.key;f!==null;){if(f.key===B)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(h,f.sibling),f=i(f,m.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else e(h,f);f=f.sibling}f=Nd(m,h.mode,g),f.return=h,h=f}return o(h);case wr:return B=m._init,Y(h,f,B(m._payload),g)}if(Ls(m))return S(h,f,m,g);if(ua(m))return I(h,f,m,g);Cu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(h,f.sibling),f=i(f,m),f.return=h,h=f):(n(h,f),f=Dd(m,h.mode,g),f.return=h,h=f),o(h)):n(h,f)}return Y}function lp(){Cp=zs=Uc=null}function up(t){var e=Va.current;_e(Va),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ws(t,e){Uc=t,Cp=zs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Bt=!0),t.firstContext=null)}function Gt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},zs===null){if(Uc===null)throw Error(x(308));zs=t,Uc.dependencies={lanes:0,firstContext:t}}else zs=zs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function b0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Dr(t,r)}function Dr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function xr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ei(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Dr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Dr(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function pg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vc(t,e,n,r){var i=t.updateQueue;Kr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var S=t,I=a;switch(y=e,v=n,I.tag){case 1:if(S=I.payload,typeof S=="function"){d=S.call(v,d,y);break e}d=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=I.payload,y=typeof S=="function"?S.call(v,d,y):S,y==null)break e;d=be({},d,y);break e;case 2:Kr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=d):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=d}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ac.transition;ac.transition={};try{t(!1),e()}finally{ue=n,ac.transition=r}}function Ng(){return Jt().memoizedState}function n1(t,e,n){var r=Xr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},E0(t))k0(e,n);else if(n=b0(t,e,n,r),n!==null){var i=mt();In(n,t,r,i),A0(n,e,r)}}function r1(t,e,n){var r=Xr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(E0(t))k0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,tn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=b0(t,e,i,r),n!==null&&(i=mt(),In(n,t,r,i),A0(n,e,r))}}function E0(t){var e=t.alternate;return t===De||e!==null&&e===De}function k0(t,e){Fa=Rc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function A0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function bn(t,e){if(t&&t.defaultProps){e=be({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:be({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Tg(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ca(n,r)||!Ca(i,s):!0}function L0(t,e,n){var r=!1,i=Nr,s=e.contextType;return typeof s=="object"&&s!==null?s=Gt(s):(i=Dt(e)?ai:tt.current,r=e.contextTypes,s=(r=r!=null)?Gs(t,i):Nr),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ha,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Og(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ha.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Gt(s):(s=Dt(e)?ai:tt.current,i.context=Gs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ha.enqueueReplaceState(i,i.state,null),vc(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function Js(t,e){try{var n="",r=e;do n+=Dx(r),r=r.return;while(r);var i=n}catch(s){i=` +`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ed=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?va(t):""}function Dx(t){switch(t.tag){case 5:return va(t.type);case 16:return va("Lazy");case 13:return va("Suspense");case 19:return va("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Ic:return"Profiler";case Jc:return"StrictMode";case Bc:return"Suspense";case Dc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case qc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ef:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case wr:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Nx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===Jc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function oi(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $v(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Tx(t){var e=$v(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Eu(t){t._valueTracker||(t._valueTracker=Tx(t))}function Wv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=$v(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function fc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return be({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Wy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=oi(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Hv(t,e);var n=oi(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,oi(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Hy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||fc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function $s(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(c_(t)/f_|0)|0}function _a(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function dc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=_a(a):(s&=o,s!==0&&(r=_a(s)))}else o=n&~i,o!==0?r=_a(o):s!==0&&(r=_a(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Qa(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-en(e),t[e]=n}function Ux(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tg(n)}}function h0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?h0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function p0(){for(var t=window,e=fc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Jx(t){var e=p0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&h0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=ng(n,s);var o=ng(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;nPs||(t.current=Lc[Ps],Lc[Ps]=null,Ps--)}function me(t,e){Ps++,Lc[Ps]=t.current,t.current=e}function Gs(t,e){var n=t.type.contextTypes;if(!n)return Nr;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(t){return t=t.childContextTypes,t!=null}function yc(){_e(yt),_e(tt)}function lg(t,e,n){if(tt.current!==Nr)throw Error(x(168));me(tt,e),me(yt,n)}function g0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Nx(t)||"Unknown",i));return be({},n,r)}function gc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Nr,ai=tt.current,me(tt,t),me(yt,yt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=g0(t,e,ai),r.__reactInternalMemoizedMergedChildContext=t,_e(yt),_e(tt),me(tt,t)):_e(yt),me(yt,n)}function v0(t){Sr===null?Sr=[t]:Sr.push(t)}function e1(t){sf=!0,v0(t)}function li(){if(!Rd&&Sr!==null){Rd=!0;var t=0,e=ue;try{var n=Sr;for(ue=1;t>=o,i-=o,Ir=1<<32-en(e)+i|n<b?(K=D,D=null):K=D.sibling;var L=y(h,D,m[b],g);if(L===null){D===null&&(D=K);break}t&&D&&L.alternate===null&&e(h,D),f=s(L,f,b),B===null?w=L:B.sibling=L,B=L,D=K}if(b===m.length)return n(h,D),Ie&&Li(h,b),w;if(D===null){for(;bb?(K=D,D=null):K=D.sibling;var ie=y(h,D,L.value,g);if(ie===null){D===null&&(D=K);break}t&&D&&ie.alternate===null&&e(h,D),f=s(ie,f,b),B===null?w=ie:B.sibling=ie,B=ie,D=K}if(L.done)return n(h,D),Ie&&Li(h,b),w;if(D===null){for(;!L.done;b++,L=m.next())L=d(h,L.value,g),L!==null&&(f=s(L,f,b),B===null?w=L:B.sibling=L,B=L);return Ie&&Li(h,b),w}for(D=r(h,D);!L.done;b++,L=m.next())L=v(D,h,b,L.value,g),L!==null&&(t&&L.alternate!==null&&D.delete(L.key===null?b:L.key),f=s(L,f,b),B===null?w=L:B.sibling=L,B=L);return t&&D.forEach(function(Qe){return e(h,Qe)}),Ie&&Li(h,b),w}function Y(h,f,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Sa:e:{for(var w=m.key,B=f;B!==null;){if(B.key===w){if(w=m.type,w===ji){if(B.tag===7){n(h,B.sibling),f=i(B,m.props.children),f.return=h,h=f;break e}}else if(B.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===wr&&dg(w)===B.type){n(h,B.sibling),f=i(B,m.props),f.ref=da(h,B,m),f.return=h,h=f;break e}n(h,B);break}else e(h,B);B=B.sibling}m.type===ji?(f=Yi(m.props.children,h.mode,g,m.key),f.return=h,h=f):(g=tc(m.type,m.key,m.props,null,h.mode,g),g.ref=da(h,f,m),g.return=h,h=g)}return o(h);case Pi:e:{for(B=m.key;f!==null;){if(f.key===B)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(h,f.sibling),f=i(f,m.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else e(h,f);f=f.sibling}f=Nd(m,h.mode,g),f.return=h,h=f}return o(h);case wr:return B=m._init,Y(h,f,B(m._payload),g)}if(Ls(m))return S(h,f,m,g);if(ua(m))return I(h,f,m,g);Cu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(h,f.sibling),f=i(f,m),f.return=h,h=f):(n(h,f),f=Dd(m,h.mode,g),f.return=h,h=f),o(h)):n(h,f)}return Y}function lp(){Cp=zs=Uc=null}function up(t){var e=Va.current;_e(Va),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ws(t,e){Uc=t,Cp=zs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Bt=!0),t.firstContext=null)}function Gt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},zs===null){if(Uc===null)throw Error(x(308));zs=t,Uc.dependencies={lanes:0,firstContext:t}}else zs=zs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function b0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Dr(t,r)}function Dr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function xr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ei(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Dr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Dr(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function pg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vc(t,e,n,r){var i=t.updateQueue;Kr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var S=t,I=a;switch(y=e,v=n,I.tag){case 1:if(S=I.payload,typeof S=="function"){d=S.call(v,d,y);break e}d=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=I.payload,y=typeof S=="function"?S.call(v,d,y):S,y==null)break e;d=be({},d,y);break e;case 2:Kr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=d):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=d}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ac.transition;ac.transition={};try{t(!1),e()}finally{ue=n,ac.transition=r}}function Ng(){return Jt().memoizedState}function n1(t,e,n){var r=Xr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},F0(t))k0(e,n);else if(n=b0(t,e,n,r),n!==null){var i=mt();In(n,t,r,i),A0(n,e,r)}}function r1(t,e,n){var r=Xr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(F0(t))k0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,tn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=b0(t,e,i,r),n!==null&&(i=mt(),In(n,t,r,i),A0(n,e,r))}}function F0(t){var e=t.alternate;return t===De||e!==null&&e===De}function k0(t,e){Ea=Rc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function A0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function bn(t,e){if(t&&t.defaultProps){e=be({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:be({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Tg(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ca(n,r)||!Ca(i,s):!0}function L0(t,e,n){var r=!1,i=Nr,s=e.contextType;return typeof s=="object"&&s!==null?s=Gt(s):(i=Dt(e)?ai:tt.current,r=e.contextTypes,s=(r=r!=null)?Gs(t,i):Nr),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ha,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Og(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ha.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Gt(s):(s=Dt(e)?ai:tt.current,i.context=Gs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ha.enqueueReplaceState(i,i.state,null),vc(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function Js(t,e){try{var n="",r=e;do n+=Dx(r),r=r.return;while(r);var i=n}catch(s){i=` Error generating stack: `+s.message+` -`+s.stack}return{value:t,source:e,stack:i,digest:null}}function xd(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function fh(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}function M0(t,e,n){n=xr(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){jc||(jc=!0,Yh=r),fh(t,e)},n}function C0(t,e,n){n=xr(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){fh(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){fh(t,e),typeof r!="function"&&(si===null?si=new Set([this]):si.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Fg(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new z_;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=p1.bind(null,t,e,n),e.then(t,t))}function Eg(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function kg(t,e,n,r,i){return(t.mode&1)===0?(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=xr(-1,1),e.tag=2,ei(n,e,1))),n.lanes|=1),t):(t.flags|=65536,t.lanes=i,t)}function pt(t,e,n,r){e.child=t===null?Wh(e,null,n,r):Gi(e,t.child,n,r)}function Ag(t,e,n,r,i){n=n.render;var s=e.ref;return Ws(e,i),r=yp(t,e,n,r,s,i),n=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Tr(t,e,i)):(Ie&&n&&sp(e),e.flags|=1,pt(t,e,r,i),e.child)}function Lg(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!Sp(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,U0(t,e,s,r,i)):(t=tc(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,(t.lanes&i)===0){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Ca,n(o,r)&&t.ref===e.ref)return Tr(t,e,i)}return e.flags|=1,t=ti(s,r),t.ref=e.ref,t.return=e,e.child=t}function U0(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(Ca(s,r)&&t.ref===e.ref)if(Bt=!1,e.pendingProps=r=s,(t.lanes&i)!==0)(t.flags&131072)!==0&&(Bt=!0);else return e.lanes=t.lanes,Tr(t,e,i)}return dh(t,e,n,r,i)}function R0(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if((e.mode&1)===0)e.memoizedState={baseLanes:0,cachePool:null,transitions:null},me($i,Rt),Rt|=n;else{if((n&1073741824)===0)return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,me($i,Rt),Rt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,me($i,Rt),Rt|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,me($i,Rt),Rt|=r;return pt(t,e,i,n),e.child}function P0(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function dh(t,e,n,r,i){var s=Dt(n)?ai:tt.current;return s=Gs(e,s),Ws(e,i),n=yp(t,e,n,r,s,i),r=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Tr(t,e,i)):(Ie&&r&&sp(e),e.flags|=1,pt(t,e,n,i),e.child)}function Mg(t,e,n,r,i){if(Dt(n)){var s=!0;gc(e)}else s=!1;if(Ws(e,i),e.stateNode===null)ec(t,e),L0(e,n,r),ch(e,n,r,i),r=!0;else if(t===null){var{stateNode:o,memoizedProps:a}=e;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Gt(u):(u=Dt(n)?ai:tt.current,u=Gs(e,u));var c=n.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Og(e,o,r,u),Kr=!1;var y=e.memoizedState;o.state=y,vc(e,r,o,i),l=e.memoizedState,a!==r||y!==l||yt.current||Kr?(typeof c=="function"&&(uh(e,n,c,r),l=e.memoizedState),(a=Kr||Tg(e,n,a,r,y,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,x0(t,e),a=e.memoizedProps,u=e.type===e.elementType?a:bn(e.type,a),o.props=u,d=e.pendingProps,y=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=Gt(l):(l=Dt(n)?ai:tt.current,l=Gs(e,l));var v=n.getDerivedStateFromProps;(c=typeof v=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||y!==l)&&Og(e,o,r,l),Kr=!1,y=e.memoizedState,o.state=y,vc(e,r,o,i);var S=e.memoizedState;a!==d||y!==S||yt.current||Kr?(typeof v=="function"&&(uh(e,n,v,r),S=e.memoizedState),(u=Kr||Tg(e,n,u,r,y,S,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,S,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,S,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=S),o.props=r,o.state=S,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),r=!1)}return hh(t,e,n,r,s,i)}function hh(t,e,n,r,i,s){P0(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&ug(e,n,!1),Tr(t,e,s);r=e.stateNode,V_.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Gi(e,t.child,null,s),e.child=Gi(e,null,a,s)):pt(t,e,a,s),e.memoizedState=r.state,i&&ug(e,n,!0),e.child}function j0(t){var e=t.stateNode;e.pendingContext?lg(t,e.pendingContext,e.pendingContext!==e.context):e.context&&lg(t,e.context,!1),dp(t,e.containerInfo)}function Cg(t,e,n,r,i){return Xs(),ap(i),e.flags|=256,pt(t,e,n,r),e.child}function ph(t){return{baseLanes:t,cachePool:null,transitions:null}}function z0(t,e,n){var r=e.pendingProps,i=xe.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),me(xe,i&1),t===null)return oh(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((e.mode&1)===0?e.lanes=1:t.data==="$!"?e.lanes=8:e.lanes=1073741824,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},(r&1)===0&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Gc(o,r,0,null),t=Yi(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=ph(n),e.memoizedState=Pc,t):vp(e,o));if(i=t.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return i1(t,e,o,r,a,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,a=i.sibling;var l={mode:"hidden",children:r.children};return(o&1)===0&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=ti(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=ti(a,s):(s=Yi(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?ph(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=Pc,r}return s=t.child,t=s.sibling,r=ti(s,{mode:"visible",children:r.children}),(e.mode&1)===0&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function vp(t,e){return e=Gc({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Uu(t,e,n,r){return r!==null&&ap(r),Gi(e,t.child,null,n),t=vp(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function i1(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=xd(Error(x(422))),Uu(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=Gc({mode:"visible",children:r.children},i,0,null),s=Yi(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,(e.mode&1)!==0&&Gi(e,t.child,null,o),e.child.memoizedState=ph(o),e.memoizedState=Pc,s);if((e.mode&1)===0)return Uu(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(x(419)),r=xd(s,r,void 0),Uu(t,e,o,r)}if(a=(o&t.childLanes)!==0,Bt||a){if(r=Ke,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=(i&(r.suspendedLanes|o))!==0?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Dr(t,i),In(r,t,i,-1))}return wp(),r=xd(Error(x(421))),Uu(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=m1.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,jt=qr(i.nextSibling),zt=e,Ie=!0,Bn=null,t!==null&&(Pt[Xt++]=Ir,Pt[Xt++]=Br,Pt[Xt++]=Qi,Ir=t.id,Br=t.overflow,Qi=e),e=vp(e,r.children),e.flags|=4096,e)}function Ug(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),ah(t.return,e,n)}function Id(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function V0(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(pt(t,e,r.children,n),r=xe.current,(r&2)!==0)r=r&1|2,e.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Ug(t,n,e);else if(t.tag===19)Ug(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(me(xe,r),(e.mode&1)===0)e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&_c(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Id(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&_c(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Id(e,!0,n,null,s);break;case"together":Id(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ec(t,e){(e.mode&1)===0&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Tr(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Zi|=e.lanes,(n&e.childLanes)===0)return null;if(t!==null&&e.child!==t.child)throw Error(x(153));if(e.child!==null){for(t=e.child,n=ti(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ti(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function s1(t,e,n){switch(e.tag){case 3:j0(e),Xs();break;case 5:I0(e);break;case 1:Dt(e.type)&&gc(e);break;case 4:dp(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;me(Va,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(me(xe,xe.current&1),e.flags|=128,null):(n&e.child.childLanes)!==0?z0(t,e,n):(me(xe,xe.current&1),t=Tr(t,e,n),t!==null?t.sibling:null);me(xe,xe.current&1);break;case 19:if(r=(n&e.childLanes)!==0,(t.flags&128)!==0){if(r)return V0(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),me(xe,xe.current),r)break;return null;case 22:case 23:return e.lanes=0,R0(t,e,n)}return Tr(t,e,n)}function ha(t,e){if(!Ie)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function it(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function o1(t,e,n){var r=e.pendingProps;switch(op(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return it(e),null;case 1:return Dt(e.type)&&yc(),it(e),null;case 3:return r=e.stateNode,Zs(),_e(yt),_e(tt),pp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Mu(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&(e.flags&256)===0||(e.flags|=1024,Bn!==null&&(wh(Bn),Bn=null))),Hh(t,e),it(e),null;case 5:hp(e);var i=Ri(ro.current);if(n=e.type,t!==null&&e.stateNode!=null)W_(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(x(166));return it(e),null}if(t=Ri(Nn.current),Mu(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Dn]=e,r[to]=s,t=(e.mode&1)!==0,n){case"dialog":ve("cancel",r),ve("close",r);break;case"iframe":case"object":case"embed":ve("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Dn]=e,t[to]=r,$_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":ve("cancel",t),ve("close",t),i=r;break;case"iframe":case"object":case"embed":ve("load",t),i=r;break;case"video":case"audio":for(i=0;iio&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304)}else{if(!r)if(t=_c(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ha(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Ie)return it(e),null}else 2*Oe()-s.renderingStartTime>io&&n!==1073741824&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Oe(),e.sibling=null,n=xe.current,me(xe,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Rt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function a1(t,e){switch(op(e),e.tag){case 1:return Dt(e.type)&&yc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zs(),_e(yt),_e(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(_e(xe),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Xs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return _e(xe),null;case 4:return Zs(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function As(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Te(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Te(t,e,r)}}function l1(t,e){if(Vh=Oc,t=p0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,y=null;t:for(;;){for(var v;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)y=d,d=v;for(;;){if(d===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=d.nextSibling)!==null)break;d=y,y=d.parentNode}d=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Oc=!1,E=e;E!==null;)if(e=E,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,E=t;else for(;E!==null;){e=E;try{var S=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var{memoizedProps:I,memoizedState:Y}=S,h=e.stateNode,f=h.getSnapshotBeforeUpdate(e.elementType===e.type?I:bn(e.type,I),Y);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Te(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,E=t;break}E=e.return}return S=fv,fv=!1,S}function Ba(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Qc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function $0(t){var e=t.alternate;e!==null&&(t.alternate=null,$0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Dn],delete e[to],delete e[Ac],delete e[M_],delete e[C_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function W0(t){return t.tag===5||t.tag===3||t.tag===4}function Rg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||W0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Yr(t,e,n){for(n=n.child;n!==null;)H0(t,e,n),n=n.sibling}function H0(t,e,n){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(nf,n)}catch{}switch(n.tag){case 5:lt||As(n,e);case 6:var r=qe,i=xn;qe=null,Yr(t,e,n),qe=r,xn=i,qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ma(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=xn,qe=n.stateNode.containerInfo,xn=!0,Yr(t,e,n),qe=r,xn=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Yr(t,e,n);break;case 1:if(!lt&&(As(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Te(n,e,a)}Yr(t,e,n);break;case 21:Yr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Yr(t,e,n),lt=r):Yr(t,e,n);break;default:Yr(t,e,n)}}function Pg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Y_),e.forEach(function(r){var i=y1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Sn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Oe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*K_(r/1960))-r,10t?16:t,Jr===null)var r=!1;else{if(t=Jr,Jr=null,zc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,E=t.current;E!==null;){var s=E,o=s.child;if((E.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lOe()-Rp?Hi(t,0):Up|=n),Nt(t,e)}function q0(t,e){e===0&&((t.mode&1)===0?e=1:(e=zu,zu<<=1,(zu&130023424)===0&&(zu=4194304)));var n=mt();t=Dr(t,e),t!==null&&(Qa(t,e,n),Nt(t,n))}function m1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),q0(t,n)}function y1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),q0(t,n)}function e_(t,e){return Op(t,e)}function g1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qt(t,e,n,r){return new g1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function v1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qc)return 11;if(t===ef)return 14}return 2}function ti(t,e){var n=t.alternate;return n===null?(n=qt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case Jc:o=8,i|=8;break;case Ic:return t=qt(12,n,e,i|2),t.elementType=Ic,t.lanes=s,t;case Bc:return t=qt(13,n,e,i),t.elementType=Bc,t.lanes=s,t;case Dc:return t=qt(19,n,e,i),t.elementType=Dc,t.lanes=s,t;case Np:return Gc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case qc:o=11;break e;case ef:o=14;break e;case wr:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=qt(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=qt(7,t,r,e),t.lanes=n,t}function Gc(t,e,n,r){return t=qt(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=qt(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=qt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new _1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=qt(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function w1(t,e,n){var r=3{if(Kg=ye(nn(),1),xt=ye(bx(),1),Ip=new Set,Ys={},Pn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=Object.prototype.hasOwnProperty,r_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},He={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){He[t]=new ht(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];He[e]=new ht(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){He[t]=new ht(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){He[t]=new ht(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){He[t]=new ht(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){He[t]=new ht(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){He[t]=new ht(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){He[t]=new ht(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){He[t]=new ht(t,5,!1,t.toLowerCase(),null,!1,!1)}),Ru=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){He[t]=new ht(t,1,!1,t.toLowerCase(),null,!1,!1)}),He.xlinkHref=new ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){He[t]=new ht(t,1,!1,t.toLowerCase(),null,!0,!0)}),jn=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sa=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),Jc=Symbol.for("react.strict_mode"),Ic=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),qc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Dc=Symbol.for("react.suspense_list"),ef=Symbol.for("react.memo"),wr=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,be=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Pu=Pu||document.createElement("div"),Pu.innerHTML=""+e.valueOf().toString()+"",e=Pu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Qg=["Webkit","ms","Moz","O"],Object.keys(Ms).forEach(function(t){Qg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ms[e]=Ms[t]})}),i_=be({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),Pn)try{Ts={},Object.defineProperty(Ts,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Nh=!1}for(s_={onError:function(t){Da=!0,Nc=t}},Op=xt.unstable_scheduleCallback,Oh=xt.unstable_cancelCallback,o_=xt.unstable_shouldYield,a_=xt.unstable_requestPaint,Oe=xt.unstable_now,l_=xt.unstable_getCurrentPriorityLevel,tf=xt.unstable_ImmediatePriority,Fp=xt.unstable_UserBlockingPriority,ja=xt.unstable_NormalPriority,u_=xt.unstable_LowPriority,Ep=xt.unstable_IdlePriority,en=Math.clz32?Math.clz32:Lx,c_=Math.log,f_=Math.LN2,ba=[],qs=new Map,eo=new Map,br=[],m_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=jn.ReactCurrentBatchConfig,Ei={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Ut(Ei),Os=be({},Ei,{view:0,detail:0}),y_=Ut(Os),ma=be({},Os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pa&&(pa&&t.type==="mousemove"?(kd=t.screenX-pa.screenX,Ad=t.screenY-pa.screenY):Ad=kd=0,pa=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Eh=Ut(ma),Xg=be({},ma,{dataTransfer:0}),g_=Ut(Xg),Zg=be({},Os,{relatedTarget:0}),ic=Ut(Zg),Jg=be({},Ei,{animationName:0,elapsedTime:0,pseudoElement:0}),v_=Ut(Jg),qg=be({},Ei,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),__=Ut(qg),ev=be({},Ei,{data:0}),kh=Ut(ev),tv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},rv=be({},Os,{key:function(t){if(t.key){var e=tv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Zu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Zu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),S_=Ut(rv),iv=be({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Ut(iv),sv=be({},Os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),b_=Ut(sv),ov=be({},Ei,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Ut(ov),av=be({},ma,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),I_=Ut(av),B_=[9,13,27,32],Ec=Pn&&("CompositionEvent"in window),Pn&&("documentMode"in document)&&(ya=document.documentMode),D_=Pn&&("TextEvent"in window)&&!ya,Lp=Pn&&(!Ec||ya&&8=ya),Lh=" ",N_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},Pn&&(Pn?(Vu="oninput"in document,Vu||(Md=document.createElement("div"),Md.setAttribute("oninput","return;"),Vu=typeof Md.oninput=="function"),Ld=Vu):Ld=!1,T_=Ld&&(!document.documentMode||9=document.documentMode,Ci={animationend:ku("Animation","AnimationEnd"),animationiteration:ku("Animation","AnimationIteration"),animationstart:ku("Animation","AnimationStart"),transitionend:ku("Transition","TransitionEnd")},sc={},Uh={},Pn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Au("animationend"),Ph=Au("animationiteration"),jh=Au("animationstart"),zh=Au("transitionend"),Mp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Wu=0;Wu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Vv}),M1=so(function(t){var e=ye(Z_());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),J_={};Qh(J_,{Fragment:()=>rw,jsx:()=>iw,jsxs:()=>sw});function pv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)ew.call(e,r)&&!nw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:q_,type:t,key:s,ref:o,props:i,_owner:tw.current}}var mv,q_,yv,ew,tw,nw,rw,iw,sw,C1=Gh(()=>{mv=ye(nn(),1),q_=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),ew=Object.prototype.hasOwnProperty,tw=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nw={key:!0,ref:!0,__self:!0,__source:!0},rw=yv,iw=pv,sw=pv}),Or=so(function(t,e){C1(),e.exports=J_}),Zt=ye(nn(),1),U1=ye(M1(),1),R1=ye(Z_(),1),cL=ye(nn(),1);function Vc(t){return String(t||"").split(".").at(-1)}function jp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").toLowerCase();if(e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||e.type==="ratio")return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:e.maximumFractionDigits??1,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let s=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:s?e.currency||"USD":void 0,maximumFractionDigits:e.maximumFractionDigits??2,notation:e.compact?"compact":"standard",style:s?"currency":"decimal"})}function Ji(t){return String(t??"")}function ow(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function aw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var fL=ye(Or(),1);var P1=ye(nn(),1);function j1(t){return t.split(".").at(-1)||t}var $c="\0__null__";function Wc(t){return t===$c||t===""?"\u2014":t}function Pd(t,e={}){return jp(t,e)}function zp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${zp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Wc(e[0])}`:e.length<=2?`${n} ${e.map(Wc).join(", ")}`:`${n} ${e.length} values`}var at=ye(nn(),1);function V1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var $1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ku(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Qu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function W1(t,e){let n=t.split("__").at(-1);return n&&$1.has(n)?n:e}function H1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function Y1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function K1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Ku(i.query.dimensions),o=Ku(i.query.metrics),a=o.map(g=>t.graphMetrics.find(w=>w.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...V1(t,u.name)],d=o.map(g=>c.find(w=>w.ref===g)).filter(g=>!!g),y=s.map(g=>Qu(t,g)).filter((g,w,B)=>!!g&&B.findIndex(D=>D?.ref===g?.ref)===w),v=i.encoding?.y,I=(Array.isArray(v)?v:v?[v]:[]).find(g=>d.some(w=>w.ref===g))??d[0]?.ref??u.metrics[0]?.ref??"",Y=i.encoding?.x,h=(Y&&Qu(t,Y)?.type==="time"?Y:void 0)??s.find(g=>Qu(t,g)?.type==="time"),f=u.defaultGrain??"month",m=h?Qu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:d.length?d:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:I,grain:h?W1(h,f):f,filters:Ku(i.query.filters),segments:Ku(i.query.segments),usePreaggregations:Y1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??H1(e)}}var Q1=["second","minute","hour","day","week","month","quarter","year"];function G1(t){return t.toISOString().slice(0,10)}function X1(t){return t.slice(0,10)}function Z1(t){return new Date(`${X1(t)}T00:00:00Z`)}function J1(t,e){let n=Z1(t);return n.setUTCDate(n.getUTCDate()+e),G1(n)}function q1(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${J1(e.to,1)}' as date)`]}function eI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function tI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function nI(t){return tI(t.models.flatMap(e=>e.dimensions))}function gv(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return zp(t,n)}function rI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function lw(t,e,n){let r=zp(`%${rI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function iI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes($c),o=e.values.filter(l=>l!==$c),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${gv(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>gv(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function sI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||eI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(lw(r,i.pattern??"",e.dialect));continue}let o=iI(r,i,s,e.dialect);o&&n.push(o)}return n}function oI(t,e={}){let n=sI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...q1(e.timeRef,e.range)),n}function aI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var uw=ye(nn(),1),dL=new Set(Q1);var lI=uw.createContext(null);function uI(){let t=uw.useContext(lI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=ye(nn(),1),hL=ye(nn(),1),Hc={active:0,listeners:new Set};function cw(){for(let t of Hc.listeners)t()}function cI(){Hc.active+=1,cw()}function fI(){Hc.active=Math.max(0,Hc.active-1),cw()}var dI=80;function hI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{cI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>fI())},dI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var Ee=ye(Or(),1),pI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],mI=50,vv=200;function _v(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function yI({dim:t,model:e,onClose:n}){let{state:r,dispatch:i,backend:s,catalog:o,dashboard:a}=uI(),l=at.useMemo(()=>K1(o,a,r.dashboardTab),[o,a,r.dashboardTab]),u=r.filters[t.ref],[c,d]=at.useState(u?.mode??"include"),y=at.useMemo(()=>new Set(u?.mode!=="contains"?u?.values??[]:[]),[u]),v=at.useRef(null),S=at.useRef(null),I=at.useId(),[Y,h]=at.useState(""),f=_v(Y,vv),m=u?.mode==="contains"?u.pattern??"":"",[g,w]=at.useState(m),B=_v(g,vv);at.useEffect(()=>{let _=document.activeElement;return S.current?.focus(),()=>_?.focus?.()},[]),at.useEffect(()=>{function _(te){te.key==="Escape"&&(te.stopPropagation(),n())}function N(te){v.current&&!v.current.contains(te.target)&&n()}return document.addEventListener("keydown",_,!0),document.addEventListener("mousedown",N,!0),()=>{document.removeEventListener("keydown",_,!0),document.removeEventListener("mousedown",N,!0)}},[n]),at.useEffect(()=>{c==="contains"&&B!==m&&i({type:"setFilterPattern",dim:t.ref,pattern:B})},[B,c,t.ref,i]);let D=l?.timeDimension?.ref??e.timeDimension?.ref,b=at.useMemo(()=>nI(o),[o]),K=at.useMemo(()=>{let _=[...l?.filters??[],...oI(r.filters,{timeRef:D,range:r.dateRange,excludeDim:t.ref,types:b,dialect:o.dialect})];return f.trim()&&_.push(lw(t.ref,f.trim(),o.dialect)),_},[l,r.filters,D,r.dateRange,t.ref,f,b,o.dialect]),L=c!=="contains",{result:ie,loading:Qe,error:ke}=hI(s,L?aI(t.ref,K,mI,l?.segments,l?.usePreaggregations):null),we=j1(t.ref),Ae=at.useMemo(()=>ie?ie.rows.map(_=>{let N=_[we];return N==null?$c:String(N)}):[],[ie,we]),Ve=!!ie&&ie.rows.length>0&&!ie.columns.includes(we),Fr=L&&(Qe||Ve);function T(_){d(_),u&&i({type:"setFilterMode",dim:t.ref,mode:_}),_==="contains"&&w(m)}function M(_){if(_.key!=="Tab")return;let N=v.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!N||N.length===0)return;let te=N[0],$e=N[N.length-1];_.shiftKey&&document.activeElement===te?(_.preventDefault(),$e.focus()):!_.shiftKey&&document.activeElement===$e&&(_.preventDefault(),te.focus())}return Ee.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":I,onKeyDown:M,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[Ee.jsxs("div",{id:I,className:"mb-2 flex items-baseline justify-between gap-2",children:[Ee.jsx("span",{className:"truncate font-semibold text-ink",children:t.label}),Ee.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:n,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Ee.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:pI.map(({mode:_,label:N})=>Ee.jsx("button",{type:"button","aria-pressed":c===_,onClick:()=>T(_),className:`px-1.5 py-1 text-center ${c===_?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:N},_))}),c==="contains"?Ee.jsx("input",{ref:S,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:g,onChange:_=>w(_.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Ee.jsxs(Ee.Fragment,{children:[Ee.jsx("input",{ref:S,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:Y,onChange:_=>h(_.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Ee.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:ke?Ee.jsx("p",{className:"px-1 py-2 text-danger",children:ke}):Fr?Ee.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(_=>Ee.jsx("div",{className:"skeleton h-4 w-full"},_))}):Ae.length===0?Ee.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Ae.map(_=>{let N=y.has(_);return Ee.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Ee.jsx("input",{type:"checkbox",checked:N,onChange:()=>i({type:"toggleFilter",dim:t.ref,value:_,mode:c}),className:"size-3 accent-[var(--accent)]"}),Ee.jsx("span",{className:"min-w-0 truncate text-ink",children:Wc(_)})]},_)})})]}),Ee.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Ee.jsx("button",{type:"button",onClick:()=>i({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Ee.jsx("button",{type:"button",onClick:n,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}var zn=ye(Or(),1);function wv(t){let[e,n]=P1.useState(!1);if(!("dim"in t))return zn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[zn.jsxs("span",{className:"truncate",children:[zn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?zn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:r,model:i,filter:s,onRemove:o}=t;return zn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":r.ref,"data-mode":s.mode,children:[zn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[zn.jsxs("button",{type:"button","aria-label":`Edit filter ${r.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(a=>!a),className:"min-w-0 truncate text-left hover:text-ink",children:[zn.jsx("span",{className:"text-faint",children:r.label})," ",z1(s)]}),zn.jsx("button",{type:"button","aria-label":`Remove filter ${r.label}`,onClick:o,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?zn.jsx(yI,{dim:r,model:i,onClose:()=>n(!1)}):null]})}var Je=ye(Or(),1),gI={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function vI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:d=6,expanded:y=!1,onExpandedChange:v,containerRef:S}){let I=new Set(i),Y=y?r:r.slice(0,d),h=Math.max(1,...Y.map(w=>Math.abs(w.metric))),f=y||r.length>d,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:S,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(w=>Je.jsx("button",{type:"button",title:w.title,"aria-pressed":l===w.key,"data-context":w.key,"data-active":l===w.key||void 0,onClick:()=>c(w.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:w.label},w.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(w=>Je.jsx("div",{className:"skeleton h-5 w-full"},w))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):Y.map(w=>{let B=w.metric<0?"negative":"positive",D=I.has(w.value),b=`${Math.round(Math.abs(w.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":w.value,"data-selected":D||void 0,"data-tone":B,onClick:()=>a?.(w.value),"aria-pressed":D,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${B==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:b}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Wc(w.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(w.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":w.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${gI[w.context?.tone??"neutral"]}`,children:w.context?.label??"\u2014"}):null]},`${t}:${w.value}`)})}),f&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var _I=ye(nn(),1),vr=ye(nn(),1),pL=ye(nn(),1),wI=ye(Or(),1);function SI({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?wI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=ye(Or(),1);function bI({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=vr.useRef(null),l=vr.useId(),u=vr.useRef(null),c=vr.useRef(null),[d,y]=vr.useState(200),[v,S]=vr.useState(null),[I,Y]=vr.useState(null),[h,f]=vr.useState(null);vr.useEffect(()=>{let _=a.current;if(!_||typeof ResizeObserver>"u")return;let N=new ResizeObserver(te=>{for(let $e of te)y(Math.max(40,$e.contentRect.width))});return N.observe(_),()=>N.disconnect()},[]);let m=t.map((_,N)=>({index:N,value:_})).filter(_=>Number.isFinite(_.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${d} ${n}`});let g=3,w=Math.min(...m.map(_=>_.value)),D=Math.max(...m.map(_=>_.value))-w||1,b=m.map((_,N)=>({..._,x:g+N/(m.length-1)*(d-g*2),y:g+(1-(_.value-w)/D)*(n-g*2)})),K=b.map(({x:_,y:N})=>`${_.toFixed(1)},${N.toFixed(1)}`).join(" L "),L=`M ${b[0].x.toFixed(1)},${n-g} L ${K} L ${b.at(-1).x.toFixed(1)},${n-g} Z`,ie=b.at(-1),Qe=r||`Trend of ${m.length} points, latest ${i(ie.value)}`;function ke(_){let N=u.current?.getBoundingClientRect();return N?Math.max(g,Math.min(d-g,(_.clientX-N.left)/N.width*d)):g}function we(_){return Math.max(0,Math.min(b.length-1,Math.round((_-g)/(d-g*2)*(b.length-1))))}function Ae(_){let N=ke(_),te=we(N),$e=b[te];S(te),f({content:`${e?.[$e.index]?`${e[$e.index]}: `:""}${i($e.value)}`,x:_.clientX,y:_.clientY}),s?.({index:$e.index,label:e?.[$e.index],value:$e.value}),c.current!==null&&Y({a:c.current,b:N})}function Ve(_){if(!o||!e?.length)return;_.currentTarget.setPointerCapture(_.pointerId);let N=ke(_);c.current=N,Y({a:N,b:N})}function Fr(_){if(c.current===null||!o||!e?.length)return;_.currentTarget.hasPointerCapture(_.pointerId)&&_.currentTarget.releasePointerCapture(_.pointerId);let N=ke(_);if(Math.abs(N-c.current)>6){let te=b[we(Math.min(c.current,N))],$e=b[we(Math.max(c.current,N))];o({from:e[te.index],to:e[$e.index]})}c.current=null,Y(null)}function T(){S(null),f(null),s?.(null),c.current===null&&Y(null)}let M=v===null?null:b[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":Qe,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${d} ${n}`,preserveAspectRatio:"none",onPointerMove:Ae,onPointerDown:Ve,onPointerUp:Fr,onPointerCancel:T,onPointerLeave:T,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${K}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),I?st.jsx("rect",{x:Math.min(I.a,I.b),y:0,width:Math.abs(I.b-I.a),height:n,fill:"currentColor",opacity:.12}):null,M?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:M.x,x2:M.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:M.x,cy:M.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:ie.x,cy:ie.y,r:2.25,fill:"currentColor"})]}),st.jsx(SI,{tip:h})]})}var ot=ye(Or(),1),xI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},II={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function BI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:d,onSparkHover:y,onSparkBrush:v}){let[S,I]=_I.useState(null),Y=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),S?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:S.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):S?Pd(S.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${xI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:II[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",f=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(bI,{values:a,labels:l,onHover:m=>{I(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return d?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>d(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:Y}),f]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[Y,f]})}var mL=ye(Or(),1);var Gr=ye(Or(),1);function Vp({tone:t,title:e,message:n}){let r=t==="danger";return Gr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Gr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Gr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Gr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Gr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function DI({title:t="Loading",message:e="Loading metrics\u2026"}){return Gr.jsx(Vp,{tone:"loading",title:t,message:e})}function NI({title:t="No results",message:e}){return Gr.jsx(Vp,{tone:"muted",title:t,message:e})}function TI({title:t="Query failed",message:e}){return Gr.jsx(Vp,{tone:"danger",title:t,message:e})}var Sv=new WeakMap;function lf(t,e){let n=Sv.get(t);n||(t.replaceChildren(),n=U1.createRoot(t),Sv.set(t,n)),R1.flushSync(()=>n.render(e))}function OI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??Vc(e)}function fw(t,e){return typeof t=="function"?t(e):t}function FI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function EI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:FI(n)}}function dw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];lf(t,Zt.createElement(Zt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=Vc(s);return Zt.createElement(BI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:fw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function $p(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;lf(t,Zt.createElement(Zt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=EI({dimensions:[o],metrics:[n.metricRef],result:a}),u=OI(l),c=r===o;return Zt.createElement(vI,{key:o,dimension:o,title:s.label??Vc(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??Vc(n.metricRef),rows:u.map(d=>({value:Ji(d[zd(l,o)]),metric:Number(d[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:d=>jp(d,fw(n.valueFormat,{metric:n.metricRef,value:d})),onToggle:n.onSelect?d=>n.onSelect({dimension:o,value:d,row:u.find(y=>Ji(y[zd(l,o)])===d)}):void 0,onExpandedChange:n.expandable===!1?void 0:d=>{t.__sdmExpandedDim=d?o:void 0,$p(t,e,n)}})})))}function hw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return Zt.createElement(wv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(Zt.createElement(wv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));lf(t,i.length?Zt.createElement(Zt.Fragment,null,...i):r.emptyLabel?Zt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function pw(t,e){let n=e.kind==="error"?TI:e.kind==="loading"?DI:NI;lf(t,Zt.createElement(n,{message:e.message}))}function Wp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function mw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function yw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function gw(t,e){let n=mw(t),r=mw(e);if(!n||!r){let a=Wp(t),l=Wp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=yw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=yw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function kI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Dn]=e,t[to]=r,$_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":ve("cancel",t),ve("close",t),i=r;break;case"iframe":case"object":case"embed":ve("load",t),i=r;break;case"video":case"audio":for(i=0;iio&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304)}else{if(!r)if(t=_c(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ha(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Ie)return it(e),null}else 2*Oe()-s.renderingStartTime>io&&n!==1073741824&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Oe(),e.sibling=null,n=xe.current,me(xe,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Rt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function a1(t,e){switch(op(e),e.tag){case 1:return Dt(e.type)&&yc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zs(),_e(yt),_e(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(_e(xe),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Xs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return _e(xe),null;case 4:return Zs(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function As(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Te(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Te(t,e,r)}}function l1(t,e){if(Vh=Oc,t=p0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,y=null;t:for(;;){for(var v;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)y=d,d=v;for(;;){if(d===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=d.nextSibling)!==null)break;d=y,y=d.parentNode}d=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Oc=!1,F=e;F!==null;)if(e=F,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,F=t;else for(;F!==null;){e=F;try{var S=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var{memoizedProps:I,memoizedState:Y}=S,h=e.stateNode,f=h.getSnapshotBeforeUpdate(e.elementType===e.type?I:bn(e.type,I),Y);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Te(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,F=t;break}F=e.return}return S=fv,fv=!1,S}function Ba(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Qc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function $0(t){var e=t.alternate;e!==null&&(t.alternate=null,$0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Dn],delete e[to],delete e[Ac],delete e[M_],delete e[C_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function W0(t){return t.tag===5||t.tag===3||t.tag===4}function Rg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||W0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Yr(t,e,n){for(n=n.child;n!==null;)H0(t,e,n),n=n.sibling}function H0(t,e,n){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(nf,n)}catch{}switch(n.tag){case 5:lt||As(n,e);case 6:var r=qe,i=xn;qe=null,Yr(t,e,n),qe=r,xn=i,qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ma(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=xn,qe=n.stateNode.containerInfo,xn=!0,Yr(t,e,n),qe=r,xn=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Yr(t,e,n);break;case 1:if(!lt&&(As(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Te(n,e,a)}Yr(t,e,n);break;case 21:Yr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Yr(t,e,n),lt=r):Yr(t,e,n);break;default:Yr(t,e,n)}}function Pg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Y_),e.forEach(function(r){var i=y1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Sn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Oe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*K_(r/1960))-r,10t?16:t,Jr===null)var r=!1;else{if(t=Jr,Jr=null,zc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,F=t.current;F!==null;){var s=F,o=s.child;if((F.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lOe()-Rp?Hi(t,0):Up|=n),Nt(t,e)}function q0(t,e){e===0&&((t.mode&1)===0?e=1:(e=zu,zu<<=1,(zu&130023424)===0&&(zu=4194304)));var n=mt();t=Dr(t,e),t!==null&&(Qa(t,e,n),Nt(t,n))}function m1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),q0(t,n)}function y1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),q0(t,n)}function e_(t,e){return Op(t,e)}function g1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qt(t,e,n,r){return new g1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function v1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qc)return 11;if(t===ef)return 14}return 2}function ti(t,e){var n=t.alternate;return n===null?(n=qt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case Jc:o=8,i|=8;break;case Ic:return t=qt(12,n,e,i|2),t.elementType=Ic,t.lanes=s,t;case Bc:return t=qt(13,n,e,i),t.elementType=Bc,t.lanes=s,t;case Dc:return t=qt(19,n,e,i),t.elementType=Dc,t.lanes=s,t;case Np:return Gc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case qc:o=11;break e;case ef:o=14;break e;case wr:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=qt(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=qt(7,t,r,e),t.lanes=n,t}function Gc(t,e,n,r){return t=qt(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=qt(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=qt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new _1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=qt(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function w1(t,e,n){var r=3{if(Kg=ye(nn(),1),xt=ye(bx(),1),Ip=new Set,Ys={},Pn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=Object.prototype.hasOwnProperty,r_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},He={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){He[t]=new ht(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];He[e]=new ht(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){He[t]=new ht(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){He[t]=new ht(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){He[t]=new ht(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){He[t]=new ht(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){He[t]=new ht(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){He[t]=new ht(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){He[t]=new ht(t,5,!1,t.toLowerCase(),null,!1,!1)}),Ru=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ru,hd);He[e]=new ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){He[t]=new ht(t,1,!1,t.toLowerCase(),null,!1,!1)}),He.xlinkHref=new ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){He[t]=new ht(t,1,!1,t.toLowerCase(),null,!0,!0)}),jn=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sa=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),Jc=Symbol.for("react.strict_mode"),Ic=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),qc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Dc=Symbol.for("react.suspense_list"),ef=Symbol.for("react.memo"),wr=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,be=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Pu=Pu||document.createElement("div"),Pu.innerHTML=""+e.valueOf().toString()+"",e=Pu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Qg=["Webkit","ms","Moz","O"],Object.keys(Ms).forEach(function(t){Qg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ms[e]=Ms[t]})}),i_=be({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),Pn)try{Ts={},Object.defineProperty(Ts,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Nh=!1}for(s_={onError:function(t){Da=!0,Nc=t}},Op=xt.unstable_scheduleCallback,Oh=xt.unstable_cancelCallback,o_=xt.unstable_shouldYield,a_=xt.unstable_requestPaint,Oe=xt.unstable_now,l_=xt.unstable_getCurrentPriorityLevel,tf=xt.unstable_ImmediatePriority,Ep=xt.unstable_UserBlockingPriority,ja=xt.unstable_NormalPriority,u_=xt.unstable_LowPriority,Fp=xt.unstable_IdlePriority,en=Math.clz32?Math.clz32:Lx,c_=Math.log,f_=Math.LN2,ba=[],qs=new Map,eo=new Map,br=[],m_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=jn.ReactCurrentBatchConfig,Fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Ut(Fi),Os=be({},Fi,{view:0,detail:0}),y_=Ut(Os),ma=be({},Os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pa&&(pa&&t.type==="mousemove"?(kd=t.screenX-pa.screenX,Ad=t.screenY-pa.screenY):Ad=kd=0,pa=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Fh=Ut(ma),Xg=be({},ma,{dataTransfer:0}),g_=Ut(Xg),Zg=be({},Os,{relatedTarget:0}),ic=Ut(Zg),Jg=be({},Fi,{animationName:0,elapsedTime:0,pseudoElement:0}),v_=Ut(Jg),qg=be({},Fi,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),__=Ut(qg),ev=be({},Fi,{data:0}),kh=Ut(ev),tv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},rv=be({},Os,{key:function(t){if(t.key){var e=tv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Zu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Zu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),S_=Ut(rv),iv=be({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Ut(iv),sv=be({},Os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),b_=Ut(sv),ov=be({},Fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Ut(ov),av=be({},ma,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),I_=Ut(av),B_=[9,13,27,32],Fc=Pn&&("CompositionEvent"in window),Pn&&("documentMode"in document)&&(ya=document.documentMode),D_=Pn&&("TextEvent"in window)&&!ya,Lp=Pn&&(!Fc||ya&&8=ya),Lh=" ",N_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},Pn&&(Pn?(Vu="oninput"in document,Vu||(Md=document.createElement("div"),Md.setAttribute("oninput","return;"),Vu=typeof Md.oninput=="function"),Ld=Vu):Ld=!1,T_=Ld&&(!document.documentMode||9=document.documentMode,Ci={animationend:ku("Animation","AnimationEnd"),animationiteration:ku("Animation","AnimationIteration"),animationstart:ku("Animation","AnimationStart"),transitionend:ku("Transition","TransitionEnd")},sc={},Uh={},Pn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Au("animationend"),Ph=Au("animationiteration"),jh=Au("animationstart"),zh=Au("transitionend"),Mp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Wu=0;Wu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Vv}),M1=so(function(t){var e=ye(Z_());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),J_={};Qh(J_,{Fragment:()=>rw,jsx:()=>iw,jsxs:()=>sw});function pv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)ew.call(e,r)&&!nw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:q_,type:t,key:s,ref:o,props:i,_owner:tw.current}}var mv,q_,yv,ew,tw,nw,rw,iw,sw,C1=Gh(()=>{mv=ye(nn(),1),q_=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),ew=Object.prototype.hasOwnProperty,tw=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nw={key:!0,ref:!0,__self:!0,__source:!0},rw=yv,iw=pv,sw=pv}),Or=so(function(t,e){C1(),e.exports=J_}),Zt=ye(nn(),1),U1=ye(M1(),1),R1=ye(Z_(),1),cL=ye(nn(),1);function Vc(t){return String(t||"").split(".").at(-1)}function jp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").trim().toLowerCase(),i=e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||!r&&!e.style&&!e.currency&&e.type==="ratio",s=r.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),o=r.match(/^(?:decimal|percent|usd)_(\d+)$/),a=s?(s[1]||"").length:o?Number(o[1]):void 0,l=e.maximumFractionDigits??(a===void 0?i||e.compact?1:2:Math.min(a,20)),u=a===void 0?void 0:Math.min(s?(s[1]||"").replaceAll("#","").length:a,l);if(i)return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:l,minimumFractionDigits:u,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let c=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:l,minimumFractionDigits:u,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function Ji(t){return String(t??"")}function ow(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function aw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var fL=ye(Or(),1);var P1=ye(nn(),1);function j1(t){return t.split(".").at(-1)||t}var $c="\0__null__";function Wc(t){return t===$c||t===""?"\u2014":t}function Pd(t,e={}){return jp(t,e)}function zp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${zp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Wc(e[0])}`:e.length<=2?`${n} ${e.map(Wc).join(", ")}`:`${n} ${e.length} values`}var at=ye(nn(),1);function V1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var $1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ku(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Qu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function W1(t,e){let n=t.split("__").at(-1);return n&&$1.has(n)?n:e}function H1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function Y1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function K1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Ku(i.query.dimensions),o=Ku(i.query.metrics),a=o.map(g=>t.graphMetrics.find(w=>w.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...V1(t,u.name)],d=o.map(g=>c.find(w=>w.ref===g)).filter(g=>!!g),y=s.map(g=>Qu(t,g)).filter((g,w,B)=>!!g&&B.findIndex(D=>D?.ref===g?.ref)===w),v=i.encoding?.y,I=(Array.isArray(v)?v:v?[v]:[]).find(g=>d.some(w=>w.ref===g))??d[0]?.ref??u.metrics[0]?.ref??"",Y=i.encoding?.x,h=(Y&&Qu(t,Y)?.type==="time"?Y:void 0)??s.find(g=>Qu(t,g)?.type==="time"),f=u.defaultGrain??"month",m=h?Qu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:d.length?d:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:I,grain:h?W1(h,f):f,filters:Ku(i.query.filters),segments:Ku(i.query.segments),usePreaggregations:Y1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??H1(e)}}var Q1=["second","minute","hour","day","week","month","quarter","year"];function G1(t){return t.toISOString().slice(0,10)}function X1(t){return t.slice(0,10)}function Z1(t){return new Date(`${X1(t)}T00:00:00Z`)}function J1(t,e){let n=Z1(t);return n.setUTCDate(n.getUTCDate()+e),G1(n)}function q1(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${J1(e.to,1)}' as date)`]}function eI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function tI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function nI(t){return tI(t.models.flatMap(e=>e.dimensions))}function gv(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return zp(t,n)}function rI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function lw(t,e,n){let r=zp(`%${rI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function iI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes($c),o=e.values.filter(l=>l!==$c),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${gv(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>gv(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function sI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||eI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(lw(r,i.pattern??"",e.dialect));continue}let o=iI(r,i,s,e.dialect);o&&n.push(o)}return n}function oI(t,e={}){let n=sI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...q1(e.timeRef,e.range)),n}function aI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var uw=ye(nn(),1),dL=new Set(Q1);var lI=uw.createContext(null);function uI(){let t=uw.useContext(lI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=ye(nn(),1),hL=ye(nn(),1),Hc={active:0,listeners:new Set};function cw(){for(let t of Hc.listeners)t()}function cI(){Hc.active+=1,cw()}function fI(){Hc.active=Math.max(0,Hc.active-1),cw()}var dI=80;function hI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{cI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>fI())},dI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var Fe=ye(Or(),1),pI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],mI=50,vv=200;function _v(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function yI({dim:t,model:e,onClose:n}){let{state:r,dispatch:i,backend:s,catalog:o,dashboard:a}=uI(),l=at.useMemo(()=>K1(o,a,r.dashboardTab),[o,a,r.dashboardTab]),u=r.filters[t.ref],[c,d]=at.useState(u?.mode??"include"),y=at.useMemo(()=>new Set(u?.mode!=="contains"?u?.values??[]:[]),[u]),v=at.useRef(null),S=at.useRef(null),I=at.useId(),[Y,h]=at.useState(""),f=_v(Y,vv),m=u?.mode==="contains"?u.pattern??"":"",[g,w]=at.useState(m),B=_v(g,vv);at.useEffect(()=>{let _=document.activeElement;return S.current?.focus(),()=>_?.focus?.()},[]),at.useEffect(()=>{function _(te){te.key==="Escape"&&(te.stopPropagation(),n())}function N(te){v.current&&!v.current.contains(te.target)&&n()}return document.addEventListener("keydown",_,!0),document.addEventListener("mousedown",N,!0),()=>{document.removeEventListener("keydown",_,!0),document.removeEventListener("mousedown",N,!0)}},[n]),at.useEffect(()=>{c==="contains"&&B!==m&&i({type:"setFilterPattern",dim:t.ref,pattern:B})},[B,c,t.ref,i]);let D=l?.timeDimension?.ref??e.timeDimension?.ref,b=at.useMemo(()=>nI(o),[o]),K=at.useMemo(()=>{let _=[...l?.filters??[],...oI(r.filters,{timeRef:D,range:r.dateRange,excludeDim:t.ref,types:b,dialect:o.dialect})];return f.trim()&&_.push(lw(t.ref,f.trim(),o.dialect)),_},[l,r.filters,D,r.dateRange,t.ref,f,b,o.dialect]),L=c!=="contains",{result:ie,loading:Qe,error:ke}=hI(s,L?aI(t.ref,K,mI,l?.segments,l?.usePreaggregations):null),we=j1(t.ref),Ae=at.useMemo(()=>ie?ie.rows.map(_=>{let N=_[we];return N==null?$c:String(N)}):[],[ie,we]),Ve=!!ie&&ie.rows.length>0&&!ie.columns.includes(we),Er=L&&(Qe||Ve);function T(_){d(_),u&&i({type:"setFilterMode",dim:t.ref,mode:_}),_==="contains"&&w(m)}function M(_){if(_.key!=="Tab")return;let N=v.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!N||N.length===0)return;let te=N[0],$e=N[N.length-1];_.shiftKey&&document.activeElement===te?(_.preventDefault(),$e.focus()):!_.shiftKey&&document.activeElement===$e&&(_.preventDefault(),te.focus())}return Fe.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":I,onKeyDown:M,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[Fe.jsxs("div",{id:I,className:"mb-2 flex items-baseline justify-between gap-2",children:[Fe.jsx("span",{className:"truncate font-semibold text-ink",children:t.label}),Fe.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:n,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Fe.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:pI.map(({mode:_,label:N})=>Fe.jsx("button",{type:"button","aria-pressed":c===_,onClick:()=>T(_),className:`px-1.5 py-1 text-center ${c===_?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:N},_))}),c==="contains"?Fe.jsx("input",{ref:S,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:g,onChange:_=>w(_.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Fe.jsxs(Fe.Fragment,{children:[Fe.jsx("input",{ref:S,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:Y,onChange:_=>h(_.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Fe.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:ke?Fe.jsx("p",{className:"px-1 py-2 text-danger",children:ke}):Er?Fe.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(_=>Fe.jsx("div",{className:"skeleton h-4 w-full"},_))}):Ae.length===0?Fe.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Ae.map(_=>{let N=y.has(_);return Fe.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Fe.jsx("input",{type:"checkbox",checked:N,onChange:()=>i({type:"toggleFilter",dim:t.ref,value:_,mode:c}),className:"size-3 accent-[var(--accent)]"}),Fe.jsx("span",{className:"min-w-0 truncate text-ink",children:Wc(_)})]},_)})})]}),Fe.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Fe.jsx("button",{type:"button",onClick:()=>i({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Fe.jsx("button",{type:"button",onClick:n,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}var zn=ye(Or(),1);function wv(t){let[e,n]=P1.useState(!1);if(!("dim"in t))return zn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[zn.jsxs("span",{className:"truncate",children:[zn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?zn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:r,model:i,filter:s,onRemove:o}=t;return zn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":r.ref,"data-mode":s.mode,children:[zn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[zn.jsxs("button",{type:"button","aria-label":`Edit filter ${r.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(a=>!a),className:"min-w-0 truncate text-left hover:text-ink",children:[zn.jsx("span",{className:"text-faint",children:r.label})," ",z1(s)]}),zn.jsx("button",{type:"button","aria-label":`Remove filter ${r.label}`,onClick:o,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?zn.jsx(yI,{dim:r,model:i,onClose:()=>n(!1)}):null]})}var Je=ye(Or(),1),gI={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function vI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:d=6,expanded:y=!1,onExpandedChange:v,containerRef:S}){let I=new Set(i),Y=y?r:r.slice(0,d),h=Math.max(1,...Y.map(w=>Math.abs(w.metric))),f=y||r.length>d,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:S,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(w=>Je.jsx("button",{type:"button",title:w.title,"aria-pressed":l===w.key,"data-context":w.key,"data-active":l===w.key||void 0,onClick:()=>c(w.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:w.label},w.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(w=>Je.jsx("div",{className:"skeleton h-5 w-full"},w))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):Y.map(w=>{let B=w.metric<0?"negative":"positive",D=I.has(w.value),b=`${Math.round(Math.abs(w.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":w.value,"data-selected":D||void 0,"data-tone":B,onClick:()=>a?.(w.value),"aria-pressed":D,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${B==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:b}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Wc(w.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(w.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":w.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${gI[w.context?.tone??"neutral"]}`,children:w.context?.label??"\u2014"}):null]},`${t}:${w.value}`)})}),f&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var _I=ye(nn(),1),vr=ye(nn(),1),pL=ye(nn(),1),wI=ye(Or(),1);function SI({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?wI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=ye(Or(),1);function bI({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=vr.useRef(null),l=vr.useId(),u=vr.useRef(null),c=vr.useRef(null),[d,y]=vr.useState(200),[v,S]=vr.useState(null),[I,Y]=vr.useState(null),[h,f]=vr.useState(null);vr.useEffect(()=>{let _=a.current;if(!_||typeof ResizeObserver>"u")return;let N=new ResizeObserver(te=>{for(let $e of te)y(Math.max(40,$e.contentRect.width))});return N.observe(_),()=>N.disconnect()},[]);let m=t.map((_,N)=>({index:N,value:_})).filter(_=>Number.isFinite(_.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${d} ${n}`});let g=3,w=Math.min(...m.map(_=>_.value)),D=Math.max(...m.map(_=>_.value))-w||1,b=m.map((_,N)=>({..._,x:g+N/(m.length-1)*(d-g*2),y:g+(1-(_.value-w)/D)*(n-g*2)})),K=b.map(({x:_,y:N})=>`${_.toFixed(1)},${N.toFixed(1)}`).join(" L "),L=`M ${b[0].x.toFixed(1)},${n-g} L ${K} L ${b.at(-1).x.toFixed(1)},${n-g} Z`,ie=b.at(-1),Qe=r||`Trend of ${m.length} points, latest ${i(ie.value)}`;function ke(_){let N=u.current?.getBoundingClientRect();return N?Math.max(g,Math.min(d-g,(_.clientX-N.left)/N.width*d)):g}function we(_){return Math.max(0,Math.min(b.length-1,Math.round((_-g)/(d-g*2)*(b.length-1))))}function Ae(_){let N=ke(_),te=we(N),$e=b[te];S(te),f({content:`${e?.[$e.index]?`${e[$e.index]}: `:""}${i($e.value)}`,x:_.clientX,y:_.clientY}),s?.({index:$e.index,label:e?.[$e.index],value:$e.value}),c.current!==null&&Y({a:c.current,b:N})}function Ve(_){if(!o||!e?.length)return;_.currentTarget.setPointerCapture(_.pointerId);let N=ke(_);c.current=N,Y({a:N,b:N})}function Er(_){if(c.current===null||!o||!e?.length)return;_.currentTarget.hasPointerCapture(_.pointerId)&&_.currentTarget.releasePointerCapture(_.pointerId);let N=ke(_);if(Math.abs(N-c.current)>6){let te=b[we(Math.min(c.current,N))],$e=b[we(Math.max(c.current,N))];o({from:e[te.index],to:e[$e.index]})}c.current=null,Y(null)}function T(){S(null),f(null),s?.(null),c.current===null&&Y(null)}let M=v===null?null:b[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":Qe,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${d} ${n}`,preserveAspectRatio:"none",onPointerMove:Ae,onPointerDown:Ve,onPointerUp:Er,onPointerCancel:T,onPointerLeave:T,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${K}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),I?st.jsx("rect",{x:Math.min(I.a,I.b),y:0,width:Math.abs(I.b-I.a),height:n,fill:"currentColor",opacity:.12}):null,M?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:M.x,x2:M.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:M.x,cy:M.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:ie.x,cy:ie.y,r:2.25,fill:"currentColor"})]}),st.jsx(SI,{tip:h})]})}var ot=ye(Or(),1),xI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},II={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function BI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:d,onSparkHover:y,onSparkBrush:v}){let[S,I]=_I.useState(null),Y=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),S?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:S.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):S?Pd(S.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${xI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:II[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",f=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(bI,{values:a,labels:l,onHover:m=>{I(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return d?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>d(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:Y}),f]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[Y,f]})}var mL=ye(Or(),1);var Gr=ye(Or(),1);function Vp({tone:t,title:e,message:n}){let r=t==="danger";return Gr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Gr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Gr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Gr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Gr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function DI({title:t="Loading",message:e="Loading metrics\u2026"}){return Gr.jsx(Vp,{tone:"loading",title:t,message:e})}function NI({title:t="No results",message:e}){return Gr.jsx(Vp,{tone:"muted",title:t,message:e})}function TI({title:t="Query failed",message:e}){return Gr.jsx(Vp,{tone:"danger",title:t,message:e})}var Sv=new WeakMap;function lf(t,e){let n=Sv.get(t);n||(t.replaceChildren(),n=U1.createRoot(t),Sv.set(t,n)),R1.flushSync(()=>n.render(e))}function OI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??Vc(e)}function fw(t,e){return typeof t=="function"?t(e):t}function EI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function FI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:EI(n)}}function dw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];lf(t,Zt.createElement(Zt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=Vc(s);return Zt.createElement(BI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:fw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function $p(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;lf(t,Zt.createElement(Zt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=FI({dimensions:[o],metrics:[n.metricRef],result:a}),u=OI(l),c=r===o;return Zt.createElement(vI,{key:o,dimension:o,title:s.label??Vc(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??Vc(n.metricRef),rows:u.map(d=>({value:Ji(d[zd(l,o)]),metric:Number(d[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:d=>jp(d,fw(n.valueFormat,{metric:n.metricRef,value:d})),onToggle:n.onSelect?d=>n.onSelect({dimension:o,value:d,row:u.find(y=>Ji(y[zd(l,o)])===d)}):void 0,onExpandedChange:n.expandable===!1?void 0:d=>{t.__sdmExpandedDim=d?o:void 0,$p(t,e,n)}})})))}function hw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return Zt.createElement(wv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(Zt.createElement(wv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));lf(t,i.length?Zt.createElement(Zt.Fragment,null,...i):r.emptyLabel?Zt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function pw(t,e){let n=e.kind==="error"?TI:e.kind==="loading"?DI:NI;lf(t,Zt.createElement(n,{message:e.message}))}function Wp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function mw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function yw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function gw(t,e){let n=mw(t),r=mw(e);if(!n||!r){let a=Wp(t),l=Wp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=yw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=yw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function kI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r
diff --git a/tests/core/test_introspection.py b/tests/core/test_introspection.py new file mode 100644 index 000000000..b2c94740b --- /dev/null +++ b/tests/core/test_introspection.py @@ -0,0 +1,37 @@ +from sidemantic import Dimension, Metric, Model, SemanticLayer + + +def test_describe_preserves_explicit_and_named_formats(): + layer = SemanticLayer() + layer.add_model( + Model( + name="orders", + table="orders", + dimensions=[Dimension(name="amount", type="numeric", value_format_name="usd")], + metrics=[ + Metric(name="revenue", agg="sum", sql="amount", value_format_name="usd"), + Metric(name="count", agg="count"), + Metric( + name="aov", + type="ratio", + numerator="revenue", + denominator="count", + format="#,##0.00", + value_format_name="decimal_2", + ), + ], + ) + ) + layer.add_metric(Metric(name="global_revenue", type="derived", sql="orders.revenue", value_format_name="usd")) + + described = layer.describe_models() + orders = described["models"][0] + assert orders["dimensions"][0]["value_format_name"] == "usd" + revenue, count, aov = orders["metrics"] + assert revenue["value_format_name"] == "usd" + assert "format" not in revenue + assert "value_format_name" not in count + assert aov["format"] == "#,##0.00" + assert aov["value_format_name"] == "decimal_2" + global_revenue = next(metric for metric in described["metrics"] if metric["name"] == "global_revenue") + assert global_revenue["value_format_name"] == "usd" diff --git a/webapp/src/lib/catalog.test.ts b/webapp/src/lib/catalog.test.ts new file mode 100644 index 000000000..468bf4d1a --- /dev/null +++ b/webapp/src/lib/catalog.test.ts @@ -0,0 +1,29 @@ +import { expect, test } from "bun:test"; +import { buildCatalogFromDescribe } from "./catalog"; +import { formatCompact, formatValue } from "./format"; + +test("describe formats reach model and graph metric displays, with explicit formats taking precedence", () => { + const catalog = buildCatalogFromDescribe({ + models: [{ + name: "orders", + dimensions: [{ name: "amount", value_format_name: "usd" }], + metrics: [ + { name: "arppu", type: "ratio", value_format_name: "decimal_2" }, + { name: "arpu", type: "ratio", value_format_name: "percent", format: "#,##0.00" }, + { name: "aov", type: "ratio", value_format_name: "usd" }, + ], + }], + metrics: [ + { name: "aov", type: "ratio", value_format_name: "usd" }, + { name: "conversion", type: "ratio", value_format_name: "percent_2" }, + { name: "arpu", type: "ratio", value_format_name: "percent", format: "#,##0.00" }, + ], + }); + expect(formatValue(0.59, catalog.models[0].dimensions[0])).toBe("$0.59"); + expect(formatValue(160907.2, catalog.models[0].metrics[0])).toBe("160,907.20"); + expect(formatValue(0.59, catalog.models[0].metrics[1])).toBe("0.59"); + expect(formatValue(0.59, catalog.models[0].metrics[2])).toBe("$0.59"); + expect(formatCompact(160907.2, catalog.graphMetrics[0])).toBe("$160.9K"); + expect(formatValue(0.59, catalog.graphMetrics[1])).toBe("59.00%"); + expect(formatValue(0.59, catalog.graphMetrics[2])).toBe("0.59"); +}); diff --git a/webapp/src/lib/catalog.ts b/webapp/src/lib/catalog.ts index 43a6f3b8c..f9f8616ab 100644 --- a/webapp/src/lib/catalog.ts +++ b/webapp/src/lib/catalog.ts @@ -10,6 +10,7 @@ type DescribeDimension = { supported_granularities?: string[]; label?: string; format?: string; + value_format_name?: string; description?: string; public?: boolean; }; @@ -20,6 +21,7 @@ type DescribeMetric = { type?: string; label?: string; format?: string; + value_format_name?: string; description?: string; public?: boolean; sql?: string; @@ -116,7 +118,7 @@ export function buildCatalogFromDescribe(payload: DescribeResponse): Catalog { type: dim.type || "categorical", granularity: dim.granularity, supportedGranularities: dim.supported_granularities, - format: dim.format, + format: dim.format ?? dim.value_format_name, })); const metrics: CatalogMetric[] = (model.metrics ?? []).filter(isPublic).map((metric) => ({ ref: `${model.name}.${metric.name}`, @@ -126,7 +128,7 @@ export function buildCatalogFromDescribe(payload: DescribeResponse): Catalog { description: metric.description, agg: metric.agg, type: metric.type, - format: metric.format, + format: metric.format ?? metric.value_format_name, })); const timeDimension = pickTimeDimension(dimensions, model.default_time_dimension); return { @@ -149,7 +151,7 @@ export function buildCatalogFromDescribe(payload: DescribeResponse): Catalog { label: metric.label || labelize(metric.name), description: metric.description, type: metric.type, - format: metric.format, + format: metric.format ?? metric.value_format_name, })); return { models, graphMetrics, dialect: payload.dialect }; diff --git a/webapp/src/lib/uiCore.js b/webapp/src/lib/uiCore.js index a7db84e92..df5fb3049 100644 --- a/webapp/src/lib/uiCore.js +++ b/webapp/src/lib/uiCore.js @@ -14,26 +14,36 @@ export function formatUiValue(value, options = {}) { if (value === null || value === undefined || value === "") return "—"; const numeric = typeof value === "number" ? value : Number(value); if (!Number.isFinite(numeric)) return String(value); - const format = String(options.format || "").toLowerCase(); - const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") || options.type === "ratio"; + const format = String(options.format || "").trim().toLowerCase(); + // Explicit display hints override the legacy percentage default for ratios. + const percent = options.style === "percent" || format.includes("%") || format.includes("percent") || format.includes("pct") + || (!format && !options.style && !options.currency && options.type === "ratio"); + const decimalPattern = format.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/); + const namedPrecision = format.match(/^(?:decimal|percent|usd)_(\d+)$/); + const precision = decimalPattern ? (decimalPattern[1] || "").length : namedPrecision ? Number(namedPrecision[1]) : undefined; + const maximumFractionDigits = options.maximumFractionDigits ?? (precision === undefined ? (percent || options.compact ? 1 : 2) : Math.min(precision, 20)); + const minimumFractionDigits = precision === undefined ? undefined + : Math.min(decimalPattern ? (decimalPattern[1] || "").replaceAll("#", "").length : precision, maximumFractionDigits); if (percent) { const scaled = options.style === "percent" ? numeric : Math.abs(numeric) <= 1 ? numeric * 100 : numeric; return scaled.toLocaleString(undefined, { - maximumFractionDigits: options.maximumFractionDigits ?? 1, + maximumFractionDigits, + minimumFractionDigits, style: options.style === "percent" ? "percent" : "decimal", }) + (options.style === "percent" ? "" : "%"); } const currency = options.style === "currency" || options.currency || format.includes("$") || format.includes("usd") || format.includes("currency") || format.includes("dollar"); return numeric.toLocaleString(undefined, { currency: currency ? options.currency || "USD" : undefined, - maximumFractionDigits: options.maximumFractionDigits ?? 2, + maximumFractionDigits, + minimumFractionDigits, notation: options.compact ? "compact" : "standard", style: currency ? "currency" : "decimal", }); } export function formatUiCompact(value, options = {}) { - return formatUiValue(value, { ...options, compact: true, maximumFractionDigits: options.maximumFractionDigits ?? 1 }); + return formatUiValue(value, { ...options, compact: true }); } export function normalizeFilterValue(value) { diff --git a/webapp/src/lib/uiCore.test.ts b/webapp/src/lib/uiCore.test.ts new file mode 100644 index 000000000..a021a31b8 --- /dev/null +++ b/webapp/src/lib/uiCore.test.ts @@ -0,0 +1,49 @@ +import { describe, expect, test } from "bun:test"; +import { formatCompact, formatValue } from "./format"; +import { formatUiValue } from "./uiCore.js"; + +describe("ratio formatting", () => { + test("escaped LookML percent markers preserve required and optional precision", () => { + for (const display of [formatValue, formatCompact]) { + expect(display(0.1234, { format: String.raw`0.00\%` })).toBe("12.34%"); + expect(display(0.1, { format: String.raw`0.00\%`, type: "ratio" })).toBe("10.00%"); + expect(display(0.1234, { format: String.raw`0.0#\%` })).toBe("12.34%"); + expect(display(0.1, { format: String.raw`0.0#\%` })).toBe("10.0%"); + expect(display(0.1234, { format: String.raw`0\%` })).toBe("12%"); + } + }); + + test("explicit numeric formats preserve ARPU, ARPPU, and AOV values", () => { + const hint = { type: "ratio", format: "#,##0.00" }; + expect(formatValue(160907.2, hint)).toBe("160,907.20"); + expect(formatValue(0.59, hint)).toBe("0.59"); + expect(formatValue(-0.59, hint)).toBe("-0.59"); + expect(formatValue(0, hint)).toBe("0.00"); + expect(formatValue(160907.2, { ...hint, format: "#,##0" })).toBe("160,907"); + expect(formatValue(0.59, { ...hint, format: "decimal_2" })).toBe("0.59"); + expect(formatCompact(160907.2, hint)).toBe("160.91K"); + expect(formatCompact(0.59, hint)).toBe("0.59"); + }); + + test("explicit currency formats override ratio inference", () => { + for (const format of ["usd", "$#,##0.00", "usd_2"]) { + expect(formatValue(160907.2, { type: "ratio", format })).toBe("$160,907.20"); + expect(formatValue(0.59, { type: "ratio", format })).toBe("$0.59"); + } + expect(formatCompact(160907.2, { type: "ratio", format: "usd" })).toBe("$160.9K"); + expect(formatCompact(0.59, { type: "ratio", format: "$0.00" })).toBe("$0.59"); + expect(formatUiValue(0.59, { type: "ratio", style: "currency", currency: "USD" })).toBe("$0.59"); + expect(formatUiValue(0.59, { type: "ratio", style: "decimal" })).toBe("0.59"); + }); + + test("explicit percentages and unformatted ratios retain percent behavior", () => { + for (const format of [undefined, "", "percent", "pct"]) { + expect(formatValue(0.59, { type: "ratio", format })).toBe("59%"); + expect(formatCompact(0.59, { type: "ratio", format })).toBe("59%"); + } + expect(formatValue(0.59, { type: "ratio", format: "0.00%" })).toBe("59.00%"); + expect(formatCompact(0.59, { type: "ratio", format: "percent_2" })).toBe("59.00%"); + expect(formatValue(160907.2, { type: "ratio" })).toBe("160,907.2%"); + expect(formatUiValue(0.59, { style: "percent" })).toBe("59%"); + }); +});