react-semaphor 0.1.416 → 0.1.418
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +49 -50
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/analyze-result-contract-Akysi2ML.js +2003 -0
- package/dist/chunks/analyze-result-contract-COjyJzYm.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-B8FmFRHX.js → calendar-preferences-dialog-BbuLgela.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-ck4AU-to.js → calendar-preferences-dialog-CInkkhl_.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Br_1IK1z.js → dashboard-briefing-launcher-B4OWNsVD.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Tr2SqDMK.js → dashboard-briefing-launcher-D7FNuDuc.js} +4 -4
- package/dist/chunks/{dashboard-controls-B7OObDNl.js → dashboard-controls-DTC1eCz0.js} +1 -1
- package/dist/chunks/{dashboard-controls-B2bEv8uG.js → dashboard-controls-DcX7Mid4.js} +5 -5
- package/dist/chunks/{dashboard-json-DAB8WVyb.js → dashboard-json-BHWbQS6I.js} +3 -3
- package/dist/chunks/{dashboard-json-DNixjalS.js → dashboard-json-vu38P5pV.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DWygSAp3.js → edit-dashboard-visual-CkBhJBhp.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Dh8Ge3-B.js → edit-dashboard-visual-DsCr90_3.js} +4 -4
- package/dist/chunks/{index-BkTLAfKy.js → index-C56DuHI8.js} +163 -164
- package/dist/chunks/{index-CQIMj-FF.js → index-C8thRvkW.js} +4 -4
- package/dist/chunks/{switch-DMlqgIx_.js → switch-BXuyni6l.js} +1 -1
- package/dist/chunks/{switch-DgiogS4X.js → switch-Dsx-IwBE.js} +1 -1
- package/dist/chunks/{update-policy-BnEbPhHW.js → update-policy-B5S_LfEu.js} +347 -314
- package/dist/chunks/update-policy-BqBKUk3Q.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-CZA-dSns.js → use-create-flow-overlay-state-BDv_VpL6.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-uujasvbD.js → use-create-flow-overlay-state-CzftV84t.js} +3 -3
- package/dist/chunks/{validators-UqQI3Cg_.js → validators-CLzrE2N_.js} +1 -1
- package/dist/chunks/validators-CPFcUMrV.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +28 -29
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +154 -125
- package/dist/data-app-codegen-node/index.js +691 -609
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +171 -157
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +26 -27
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +17 -18
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +6 -1
- package/dist/types/dashboard-assistant.d.ts +1 -0
- package/dist/types/data-app-codegen-node.d.ts +5 -3
- package/dist/types/data-app-codegen.d.ts +5 -3
- package/dist/types/data-app-sdk-validation.d.ts +1 -0
- package/dist/types/data-app-sdk.d.ts +6 -0
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-8nxUOWp8.js +0 -1
- package/dist/chunks/analyze-result-contract-DPjm6btg.js +0 -1869
- package/dist/chunks/source-identity-BM2FvJDP.js +0 -1
- package/dist/chunks/source-identity-Cv4Nm3TM.js +0 -75
- package/dist/chunks/update-policy-CWg9c08k.js +0 -3
- package/dist/chunks/validators-JzI7olk4.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Phe=Object.defineProperty;var l$=e=>{throw TypeError(e)};var Fhe=(e,t,n)=>t in e?Phe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>Fhe(e,typeof t!="symbol"?t+"":t,n),Jj=(e,t,n)=>t.has(e)||l$("Cannot "+n);var he=(e,t,n)=>(Jj(e,t,"read from private field"),n?n.call(e):t.get(e)),kt=(e,t,n)=>t.has(e)?l$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ft=(e,t,n,r)=>(Jj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ht=(e,t,n)=>(Jj(e,t,"access private method"),n);var rw=(e,t,n,r)=>({set _(o){ft(e,t,o,n)},get _(){return he(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),br=require("react-dom"),p=require("./switch-
|
|
1
|
+
"use strict";var Phe=Object.defineProperty;var l$=e=>{throw TypeError(e)};var Fhe=(e,t,n)=>t in e?Phe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>Fhe(e,typeof t!="symbol"?t+"":t,n),Jj=(e,t,n)=>t.has(e)||l$("Cannot "+n);var he=(e,t,n)=>(Jj(e,t,"read from private field"),n?n.call(e):t.get(e)),kt=(e,t,n)=>t.has(e)?l$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ft=(e,t,n,r)=>(Jj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ht=(e,t,n)=>(Jj(e,t,"access private method"),n);var rw=(e,t,n,r)=>({set _(o){ft(e,t,o,n)},get _(){return he(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),br=require("react-dom"),p=require("./switch-BXuyni6l.js"),Te=require("./x-B6ghREd2.js"),Ohe=require("./analyze-result-contract-COjyJzYm.js"),kc=require("./index-DRlMUglg.js"),Lhe=require("react-dom/client"),Pt=require("./search-DNCejM7Z.js"),$he=require("../types/index.cjs"),$n=require("./date-formatter-B4EBSe9C.js"),Sq=require("./catalog-field-grounding-Bnx-3tE0.js"),nn=require("./index-D7KJindZ.js"),Ss=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),lr=require("./common-types-C73-Ud1-.js"),Cq=require("../dashboard-assistant/index.cjs"),zhe=require("./contracts-CtB2VONT.js"),Bhe=require("../layouts/index.cjs");function zR(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const c$=zR(l),Q=zR(S),UD=zR(br),BR=`import pandas as pd
|
|
2
2
|
df = pd.DataFrame(data) # 'data' contains the query result
|
|
3
3
|
result = df.to_dict('records') # must return 'result' as [dict] type
|
|
4
4
|
`;function Vhe(e){return nn.toDate(e).getMonth()}function Hhe(e){return nn.toDate(e).getFullYear()}function V1(e,t){const r=Ghe(e);let o;if(r.date){const c=Yhe(r.date,2);o=Khe(c.restDateString,c.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const s=o.getTime();let i=0,a;if(r.time&&(i=Zhe(r.time),isNaN(i)))return new Date(NaN);if(r.timezone){if(a=Xhe(r.timezone),isNaN(a))return new Date(NaN)}else{const c=new Date(s+i),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(s+i+a)}const ow={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Uhe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,qhe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Whe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ghe(e){const t={},n=e.split(ow.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],ow.timeZoneDelimiter.test(t.date)&&(t.date=e.split(ow.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=ow.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function Yhe(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const o=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?o:s*100,restDateString:e.slice((r[1]||r[2]).length)}}function Khe(e,t){if(t===null)return new Date(NaN);const n=e.match(Uhe);if(!n)return new Date(NaN);const r=!!n[4],o=ob(n[1]),s=ob(n[2])-1,i=ob(n[3]),a=ob(n[4]),c=ob(n[5])-1;if(r)return nme(t,a,c)?Qhe(t,a,c):new Date(NaN);{const u=new Date(0);return!eme(t,s,i)||!tme(t,o)?new Date(NaN):(u.setUTCFullYear(t,s,Math.max(o,i)),u)}}function ob(e){return e?parseInt(e):1}function Zhe(e){const t=e.match(qhe);if(!t)return NaN;const n=eT(t[1]),r=eT(t[2]),o=eT(t[3]);return rme(n,r,o)?n*nn.millisecondsInHour+r*nn.millisecondsInMinute+o*1e3:NaN}function eT(e){return e&&parseFloat(e.replace(",","."))||0}function Xhe(e){if(e==="Z")return 0;const t=e.match(Whe);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return ome(r,o)?n*(r*nn.millisecondsInHour+o*nn.millisecondsInMinute):NaN}function Qhe(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const o=r.getUTCDay()||7,s=(t-1)*7+n+1-o;return r.setUTCDate(r.getUTCDate()+s),r}const Jhe=[31,null,31,30,31,30,31,31,30,31,30,31];function Nq(e){return e%400===0||e%4===0&&e%100!==0}function eme(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Jhe[t]||(Nq(e)?29:28))}function tme(e,t){return t>=1&&t<=(Nq(e)?366:365)}function nme(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function rme(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function ome(e,t){return t>=0&&t<=59}var H1={exports:{}};H1.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=800,s=16,i=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",h="[object Error]",m="[object Function]",g="[object GeneratorFunction]",b="[object Map]",x="[object Number]",y="[object Null]",w="[object Object]",v="[object Proxy]",C="[object RegExp]",N="[object Set]",_="[object String]",k="[object Undefined]",j="[object WeakMap]",I="[object ArrayBuffer]",T="[object DataView]",E="[object Float32Array]",D="[object Float64Array]",A="[object Int8Array]",P="[object Int16Array]",M="[object Int32Array]",L="[object Uint8Array]",$="[object Uint8ClampedArray]",z="[object Uint16Array]",W="[object Uint32Array]",F=/[\\^$.*+?()[\]{}|]/g,X=/^\[object .+?Constructor\]$/,Y=/^(?:0|[1-9]\d*)$/,R={};R[E]=R[D]=R[A]=R[P]=R[M]=R[L]=R[$]=R[z]=R[W]=!0,R[a]=R[c]=R[I]=R[d]=R[T]=R[f]=R[h]=R[m]=R[b]=R[x]=R[w]=R[C]=R[N]=R[_]=R[j]=!1;var K=typeof p.commonjsGlobal=="object"&&p.commonjsGlobal&&p.commonjsGlobal.Object===Object&&p.commonjsGlobal,O=typeof self=="object"&&self&&self.Object===Object&&self,U=K||O||Function("return this")(),V=t&&!t.nodeType&&t,H=V&&!0&&e&&!e.nodeType&&e,q=H&&H.exports===V,B=q&&K.process,G=function(){try{var de=H&&H.require&&H.require("util").types;return de||B&&B.binding&&B.binding("util")}catch{}}(),Z=G&&G.isTypedArray;function J(de,ke,Le){switch(Le.length){case 0:return de.call(ke);case 1:return de.call(ke,Le[0]);case 2:return de.call(ke,Le[0],Le[1]);case 3:return de.call(ke,Le[0],Le[1],Le[2])}return de.apply(ke,Le)}function oe(de,ke){for(var Le=-1,Dt=Array(de);++Le<de;)Dt[Le]=ke(Le);return Dt}function ie(de){return function(ke){return de(ke)}}function ue(de,ke){return de==null?void 0:de[ke]}function xe(de,ke){return function(Le){return de(ke(Le))}}var te=Array.prototype,ye=Function.prototype,se=Object.prototype,Ie=U["__core-js_shared__"],fe=ye.toString,me=se.hasOwnProperty,we=function(){var de=/[^.]+$/.exec(Ie&&Ie.keys&&Ie.keys.IE_PROTO||"");return de?"Symbol(src)_1."+de:""}(),ee=se.toString,re=fe.call(Object),ne=RegExp("^"+fe.call(me).replace(F,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=q?U.Buffer:void 0,ae=U.Symbol,Ne=U.Uint8Array;ce&&ce.allocUnsafe;var Ee=xe(Object.getPrototypeOf,Object),Ve=Object.create,ge=se.propertyIsEnumerable,pe=te.splice,$e=ae?ae.toStringTag:void 0,Fe=function(){try{var de=Or(Object,"defineProperty");return de({},"",{}),de}catch{}}(),ze=ce?ce.isBuffer:void 0,Ze=Math.max,Je=Date.now,Ce=Or(U,"Map"),Qe=Or(Object,"create"),He=function(){function de(){}return function(ke){if(!Nd(ke))return{};if(Ve)return Ve(ke);de.prototype=ke;var Le=new de;return de.prototype=void 0,Le}}();function _e(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function Me(){this.__data__=Qe?Qe(null):{},this.size=0}function De(de){var ke=this.has(de)&&delete this.__data__[de];return this.size-=ke?1:0,ke}function je(de){var ke=this.__data__;if(Qe){var Le=ke[de];return Le===r?void 0:Le}return me.call(ke,de)?ke[de]:void 0}function Ue(de){var ke=this.__data__;return Qe?ke[de]!==void 0:me.call(ke,de)}function mt(de,ke){var Le=this.__data__;return this.size+=this.has(de)?0:1,Le[de]=Qe&&ke===void 0?r:ke,this}_e.prototype.clear=Me,_e.prototype.delete=De,_e.prototype.get=je,_e.prototype.has=Ue,_e.prototype.set=mt;function pt(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function ut(){this.__data__=[],this.size=0}function ht(de){var ke=this.__data__,Le=it(ke,de);if(Le<0)return!1;var Dt=ke.length-1;return Le==Dt?ke.pop():pe.call(ke,Le,1),--this.size,!0}function nt(de){var ke=this.__data__,Le=it(ke,de);return Le<0?void 0:ke[Le][1]}function At(de){return it(this.__data__,de)>-1}function Ae(de,ke){var Le=this.__data__,Dt=it(Le,de);return Dt<0?(++this.size,Le.push([de,ke])):Le[Dt][1]=ke,this}pt.prototype.clear=ut,pt.prototype.delete=ht,pt.prototype.get=nt,pt.prototype.has=At,pt.prototype.set=Ae;function Ke(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function et(){this.size=0,this.__data__={hash:new _e,map:new(Ce||pt),string:new _e}}function at(de){var ke=Xt(this,de).delete(de);return this.size-=ke?1:0,ke}function vt(de){return Xt(this,de).get(de)}function zt(de){return Xt(this,de).has(de)}function It(de,ke){var Le=Xt(this,de),Dt=Le.size;return Le.set(de,ke),this.size+=Le.size==Dt?0:1,this}Ke.prototype.clear=et,Ke.prototype.delete=at,Ke.prototype.get=vt,Ke.prototype.has=zt,Ke.prototype.set=It;function en(de){var ke=this.__data__=new pt(de);this.size=ke.size}function Tt(){this.__data__=new pt,this.size=0}function ot(de){var ke=this.__data__,Le=ke.delete(de);return this.size=ke.size,Le}function wt(de){return this.__data__.get(de)}function jt(de){return this.__data__.has(de)}function Oe(de,ke){var Le=this.__data__;if(Le instanceof pt){var Dt=Le.__data__;if(!Ce||Dt.length<n-1)return Dt.push([de,ke]),this.size=++Le.size,this;Le=this.__data__=new Ke(Dt)}return Le.set(de,ke),this.size=Le.size,this}en.prototype.clear=Tt,en.prototype.delete=ot,en.prototype.get=wt,en.prototype.has=jt,en.prototype.set=Oe;function Ge(de,ke){var Le=Mr(de),Dt=!Le&&Ln(de),In=!Le&&!Dt&&Cd(de),ir=!Le&&!Dt&&!In&&o$(de),Tr=Le||Dt||In||ir,Bn=Tr?oe(de.length,String):[],Ir=Bn.length;for(var ta in de)Tr&&(ta=="length"||In&&(ta=="offset"||ta=="parent")||ir&&(ta=="buffer"||ta=="byteLength"||ta=="byteOffset")||El(ta,Ir))||Bn.push(ta);return Bn}function le(de,ke,Le){(Le!==void 0&&!sr(de[ke],Le)||Le===void 0&&!(ke in de))&&Et(de,ke,Le)}function Be(de,ke,Le){var Dt=de[ke];(!(me.call(de,ke)&&sr(Dt,Le))||Le===void 0&&!(ke in de))&&Et(de,ke,Le)}function it(de,ke){for(var Le=de.length;Le--;)if(sr(de[Le][0],ke))return Le;return-1}function Et(de,ke,Le){ke=="__proto__"&&Fe?Fe(de,ke,{configurable:!0,enumerable:!0,value:Le,writable:!0}):de[ke]=Le}var Lt=Nt();function be(de){return de==null?de===void 0?k:y:$e&&$e in Object(de)?Ci(de):nw(de)}function Se(de){return nb(de)&&be(de)==a}function We(de){if(!Nd(de)||ew(de))return!1;var ke=eb(de)?ne:X;return ke.test(Zt(de))}function bt(de){return nb(de)&&tb(de.length)&&!!R[be(de)]}function $t(de){if(!Nd(de))return tw(de);var ke=Jg(de),Le=[];for(var Dt in de)Dt=="constructor"&&(ke||!me.call(de,Dt))||Le.push(Dt);return Le}function _t(de,ke,Le,Dt,In){de!==ke&&Lt(ke,function(ir,Tr){if(In||(In=new en),Nd(ir))Fn(de,ke,Tr,Le,_t,Dt,In);else{var Bn=Dt?Dt(Gt(de,Tr),ir,Tr+"",de,ke,In):void 0;Bn===void 0&&(Bn=ir),le(de,Tr,Bn)}},s$)}function Fn(de,ke,Le,Dt,In,ir,Tr){var Bn=Gt(de,Le),Ir=Gt(ke,Le),ta=Tr.get(Ir);if(ta){le(de,Le,ta);return}var Zs=ir?ir(Bn,Ir,Le+"",de,ke,Tr):void 0,rb=Zs===void 0;if(rb){var Xj=Mr(Ir),Qj=!Xj&&Cd(Ir),a$=!Xj&&!Qj&&o$(Ir);Zs=Ir,Xj||Qj||a$?Mr(Bn)?Zs=Bn:To(Bn)?Zs=qe(Bn):Qj?(rb=!1,Zs=Si(Ir)):a$?(rb=!1,Zs=Il(Ir)):Zs=[]:Ehe(Ir)||Ln(Ir)?(Zs=Bn,Ln(Bn)?Zs=Dhe(Bn):(!Nd(Bn)||eb(Bn))&&(Zs=Yh(Ir))):rb=!1}rb&&(Tr.set(Ir,Zs),In(Zs,Ir,Dt,ir,Tr),Tr.delete(Ir)),le(de,Le,Zs)}function On(de,ke){return pn(Re(de,ke,i$),de+"")}var jr=Fe?function(de,ke){return Fe(de,"toString",{configurable:!0,enumerable:!1,value:Ahe(ke),writable:!0})}:i$;function Si(de,ke){return de.slice()}function Is(de){var ke=new de.constructor(de.byteLength);return new Ne(ke).set(new Ne(de)),ke}function Il(de,ke){var Le=Is(de.buffer);return new de.constructor(Le,de.byteOffset,de.length)}function qe(de,ke){var Le=-1,Dt=de.length;for(ke||(ke=Array(Dt));++Le<Dt;)ke[Le]=de[Le];return ke}function lt(de,ke,Le,Dt){var In=!Le;Le||(Le={});for(var ir=-1,Tr=ke.length;++ir<Tr;){var Bn=ke[ir],Ir=void 0;Ir===void 0&&(Ir=de[Bn]),In?Et(Le,Bn,Ir):Be(Le,Bn,Ir)}return Le}function St(de){return On(function(ke,Le){var Dt=-1,In=Le.length,ir=In>1?Le[In-1]:void 0,Tr=In>2?Le[2]:void 0;for(ir=de.length>3&&typeof ir=="function"?(In--,ir):void 0,Tr&&Kh(Le[0],Le[1],Tr)&&(ir=In<3?void 0:ir,In=1),ke=Object(ke);++Dt<In;){var Bn=Le[Dt];Bn&&de(ke,Bn,Dt,ir)}return ke})}function Nt(de){return function(ke,Le,Dt){for(var In=-1,ir=Object(ke),Tr=Dt(ke),Bn=Tr.length;Bn--;){var Ir=Tr[++In];if(Le(ir[Ir],Ir,ir)===!1)break}return ke}}function Xt(de,ke){var Le=de.__data__;return Vc(ke)?Le[typeof ke=="string"?"string":"hash"]:Le.map}function Or(de,ke){var Le=ue(de,ke);return We(Le)?Le:void 0}function Ci(de){var ke=me.call(de,$e),Le=de[$e];try{de[$e]=void 0;var Dt=!0}catch{}var In=ee.call(de);return Dt&&(ke?de[$e]=Le:delete de[$e]),In}function Yh(de){return typeof de.constructor=="function"&&!Jg(de)?He(Ee(de)):{}}function El(de,ke){var Le=typeof de;return ke=ke??i,!!ke&&(Le=="number"||Le!="symbol"&&Y.test(de))&&de>-1&&de%1==0&&de<ke}function Kh(de,ke,Le){if(!Nd(Le))return!1;var Dt=typeof ke;return(Dt=="number"?mr(Le)&&El(ke,Le.length):Dt=="string"&&ke in Le)?sr(Le[ke],de):!1}function Vc(de){var ke=typeof de;return ke=="string"||ke=="number"||ke=="symbol"||ke=="boolean"?de!=="__proto__":de===null}function ew(de){return!!we&&we in de}function Jg(de){var ke=de&&de.constructor,Le=typeof ke=="function"&&ke.prototype||se;return de===Le}function tw(de){var ke=[];if(de!=null)for(var Le in Object(de))ke.push(Le);return ke}function nw(de){return ee.call(de)}function Re(de,ke,Le){return ke=Ze(ke===void 0?de.length-1:ke,0),function(){for(var Dt=arguments,In=-1,ir=Ze(Dt.length-ke,0),Tr=Array(ir);++In<ir;)Tr[In]=Dt[ke+In];In=-1;for(var Bn=Array(ke+1);++In<ke;)Bn[In]=Dt[In];return Bn[ke]=Le(Tr),J(de,this,Bn)}}function Gt(de,ke){if(!(ke==="constructor"&&typeof de[ke]=="function")&&ke!="__proto__")return de[ke]}var pn=tn(jr);function tn(de){var ke=0,Le=0;return function(){var Dt=Je(),In=s-(Dt-Le);if(Le=Dt,In>0){if(++ke>=o)return arguments[0]}else ke=0;return de.apply(void 0,arguments)}}function Zt(de){if(de!=null){try{return fe.call(de)}catch{}try{return de+""}catch{}}return""}function sr(de,ke){return de===ke||de!==de&&ke!==ke}var Ln=Se(function(){return arguments}())?Se:function(de){return nb(de)&&me.call(de,"callee")&&!ge.call(de,"callee")},Mr=Array.isArray;function mr(de){return de!=null&&tb(de.length)&&!eb(de)}function To(de){return nb(de)&&mr(de)}var Cd=ze||Rhe;function eb(de){if(!Nd(de))return!1;var ke=be(de);return ke==m||ke==g||ke==u||ke==v}function tb(de){return typeof de=="number"&&de>-1&&de%1==0&&de<=i}function Nd(de){var ke=typeof de;return de!=null&&(ke=="object"||ke=="function")}function nb(de){return de!=null&&typeof de=="object"}function Ehe(de){if(!nb(de)||be(de)!=w)return!1;var ke=Ee(de);if(ke===null)return!0;var Le=me.call(ke,"constructor")&&ke.constructor;return typeof Le=="function"&&Le instanceof Le&&fe.call(Le)==re}var o$=Z?ie(Z):bt;function Dhe(de){return lt(de,s$(de))}function s$(de){return mr(de)?Ge(de):$t(de)}var Mhe=St(function(de,ke,Le){_t(de,ke,Le)});function Ahe(de){return function(){return de}}function i$(de){return de}function Rhe(){return!1}e.exports=Mhe})(H1,H1.exports);var sme=H1.exports;const fl=p.getDefaultExportFromCjs(sme),ime={theme:"system",setTheme:()=>null},_q=S.createContext(ime);function U1(e,t="system"){return ame(e)?e:t}function ame(e){return e==="light"||e==="dark"||e==="system"}const VR=()=>{const e=S.useContext(_q);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},kq=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const o of r){if(!(o in e)&&o in t){n[o]=t[o];continue}if(o in e&&!(o in t)){n[o]=void 0;continue}const s=e[o],i=t[o];if(!qD(s,i))if(Array.isArray(s)&&Array.isArray(i))n[o]=i;else if(u$(s)&&u$(i)){const a=kq(s,i);Object.keys(a).length>0&&(n[o]=a)}else n[o]=i}return n},qD=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((o,s)=>qD(o,t[s]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>qD(e[o],t[o]))}return!1},u$=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$s=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(Array.isArray(e))return e.map(n=>$s(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=$s(e[n]));return t},jq="__semaphorAuthoredFontFamily";var lq,cq;const lme=(cq=(lq=p.DEFAULT_STYLE.default.chart)==null?void 0:lq.font)==null?void 0:cq.family,cme=new Set([lme,"Open Sans, Arial, sans-serif",'"Open Sans", Arial, sans-serif'].filter(Boolean));function ume(e,t){if(!e)return t?{family:t}:void 0;const{[jq]:n,...r}=e,o=dme(r.family,t,!!n);return{...r,...o?{family:o}:void 0}}function dme(e,t,n=!1){return n&&e||e&&!fme(e)?e:t||e}function fme(e){return cme.has(e.trim())}function hme(e,t){if(!t)return e;const n={...e,font:Ii(e.font,t)},r=gme(e.plugins,t);r&&(n.plugins=r);const o=bme(e.scales,t);return o&&(n.scales=o),n}function mme(e,t){return!e||!t?e:e.map(n=>{if(!n||typeof n!="object")return n;const r=n,o=r.datalabels;return!o||typeof o!="object"?n:{...r,datalabels:{...o,font:Ii(o.font,t)}}})}function pme(e,t){if(!e||typeof e!="object"||!t)return e;const n=e.datasets;return Array.isArray(n)?{...e,datasets:mme(n,t)}:e}function gme(e,t){var n;return e&&{...e,title:e.title?{...e.title,font:Ii(e.title.font,t)}:e.title,subtitle:e.subtitle?{...e.subtitle,font:Ii(e.subtitle.font,t)}:e.subtitle,legend:e.legend?{...e.legend,labels:e.legend.labels?{...e.legend.labels,font:Ii(e.legend.labels.font,t)}:e.legend.labels}:e.legend,tooltip:e.tooltip?{...e.tooltip,titleFont:Ii(e.tooltip.titleFont,t),bodyFont:Ii(e.tooltip.bodyFont,t),footerFont:Ii(e.tooltip.footerFont,t)}:e.tooltip,datalabels:e.datalabels?{...e.datalabels,font:Ii((n=e.datalabels)==null?void 0:n.font,t)}:e.datalabels}}function bme(e,t){return e&&Object.entries(e).reduce((n,[r,o])=>{if(!o||typeof o!="object")return n[r]=o,n;const s=o;return n[r]={...s,ticks:s.ticks?{...s.ticks,font:Ii(s.ticks.font,t)}:s.ticks,title:s.title?{...s.title,font:Ii(s.title.font,t)}:s.title,pointLabels:s.pointLabels?{...s.pointLabels,font:Ii(s.pointLabels.font,t)}:s.pointLabels},n},{})}function Ii(e,t){return typeof e=="function"?e:{...t,...e&&typeof e=="object"?e:{}}}function xme(e,t){const n=$s(e??{}),r=yme(t);if(!r)return n;const o=fl(n,r);return Sme(o,r),o}function yme(e){var h,m,g,b;const t=(h=e.scheme.components)==null?void 0:h.chart,n=kc.SEMAPHOR_DEFAULT_APPEARANCE_SPEC.schemes[e.mode],r=(m=n.components)==null?void 0:m.chart,o=(g=n.tokens)==null?void 0:g.typography,s={};wme(t==null?void 0:t.palette,r==null?void 0:r.palette)&&(s.dataset={backgroundColor:[...t.palette],borderColor:[...t.palette]});const i=(b=e.scheme.tokens)==null?void 0:b.typography,a=Zh(i==null?void 0:i.fontFamily,o==null?void 0:o.fontFamily),c=Zh(i==null?void 0:i.baseFontSize,o==null?void 0:o.baseFontSize);if(a||c!==void 0){const x={...a?{family:a}:void 0,...c!==void 0?{size:c}:void 0};a&&(x[jq]=!0),s.font=x}const u=Zh(t==null?void 0:t.gridColor,r==null?void 0:r.gridColor),d=Zh(t==null?void 0:t.axisColor,r==null?void 0:r.axisColor)??Zh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);(u||d)&&(s.options={scales:{x:tT({gridColor:u,axisColor:d}),y:tT({gridColor:u,axisColor:d}),y2:tT({gridColor:u,axisColor:d}),r:vme({gridColor:u,axisColor:d})}});const f=Zh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);return f&&(s.options=fl(s.options??{},{plugins:{legend:{labels:{color:f}}}})),Object.keys(s).length>0?{chart:s}:void 0}function tT({gridColor:e,axisColor:t}){return{...e?{grid:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t}}:void 0}}function vme({gridColor:e,axisColor:t}){return{...e?{grid:{color:e},angleLines:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t},pointLabels:{color:t}}:void 0}}function wme(e,t){return e!=null&&e.length?!(t!=null&&t.length)||e.length!==t.length?!0:e.some((n,r)=>n!==t[r]):!1}function Zh(e,t){return e!==void 0&&e!==t?e:void 0}function Sme(e,t){var r;const n=(r=t.chart)==null?void 0:r.dataset;n&&(e.chart=e.chart??{},e.chart.dataset=e.chart.dataset??{},Array.isArray(n.backgroundColor)&&(e.chart.dataset.backgroundColor=[...n.backgroundColor]),Array.isArray(n.borderColor)&&(e.chart.dataset.borderColor=[...n.borderColor]))}var wh=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Cme={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ga,pf,uq,Nme=(uq=class{constructor(){kt(this,Ga,Cme);kt(this,pf,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&he(this,pf)&&e!==he(this,Ga)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:he(this,Ga),provider:e}),ft(this,Ga,e),process.env.NODE_ENV!=="production"&&ft(this,pf,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ft(this,pf,!0),he(this,Ga).setTimeout(e,t)}clearTimeout(e){he(this,Ga).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ft(this,pf,!0),he(this,Ga).setInterval(e,t)}clearInterval(e){he(this,Ga).clearInterval(e)}},Ga=new WeakMap,pf=new WeakMap,uq),rf=new Nme;function _me(e){setTimeout(e,0)}var Uf=typeof window>"u"||"Deno"in globalThis;function Zo(){}function kme(e,t){return typeof e=="function"?e(t):e}function WD(e){return typeof e=="number"&&e>=0&&e!==1/0}function Tq(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vu(e,t){return typeof e=="function"?e(t):e}function Ei(e,t){return typeof e=="function"?e(t):e}function d$(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==HR(i,t.options))return!1}else if(!ay(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||s&&!s(t))}function f$(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(qf(t.options.mutationKey)!==qf(s))return!1}else if(!ay(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function HR(e,t){return((t==null?void 0:t.queryKeyHashFn)||qf)(e)}function qf(e){return JSON.stringify(e,(t,n)=>GD(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function ay(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ay(e[n],t[n])):!1}var jme=Object.prototype.hasOwnProperty;function q1(e,t){if(e===t)return e;const n=h$(e)&&h$(t);if(!n&&!(GD(e)&&GD(t)))return t;const o=(n?e:Object.keys(e)).length,s=n?t:Object.keys(t),i=s.length,a=n?new Array(i):{};let c=0;for(let u=0;u<i;u++){const d=n?u:s[u],f=e[d],h=t[d];if(f===h){a[d]=f,(n?u<o:jme.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){a[d]=h;continue}const m=q1(f,h);a[d]=m,m===f&&c++}return o===i&&c===o?e:a}function ly(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function h$(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function GD(e){if(!m$(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!m$(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function m$(e){return Object.prototype.toString.call(e)==="[object Object]"}function Tme(e){return new Promise(t=>{rf.setTimeout(t,e)})}function YD(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return q1(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return q1(e,t)}return t}function Ime(e){return e}function Eme(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Dme(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var W1=Symbol();function Iq(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===W1&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===W1?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Eq(e,t){return typeof e=="function"?e(...t):!!e}var gf,Jc,rp,dq,Mme=(dq=class extends wh{constructor(){super();kt(this,gf);kt(this,Jc);kt(this,rp);ft(this,rp,t=>{if(!Uf&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){he(this,Jc)||this.setEventListener(he(this,rp))}onUnsubscribe(){var t;this.hasListeners()||((t=he(this,Jc))==null||t.call(this),ft(this,Jc,void 0))}setEventListener(t){var n;ft(this,rp,t),(n=he(this,Jc))==null||n.call(this),ft(this,Jc,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){he(this,gf)!==t&&(ft(this,gf,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof he(this,gf)=="boolean"?he(this,gf):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},gf=new WeakMap,Jc=new WeakMap,rp=new WeakMap,dq),UR=new Mme;function KD(){let e,t;const n=new Promise((o,s)=>{e=o,t=s});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}var Ame=_me;function Rme(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Ame;const s=a=>{t?e.push(a):o(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Pr=Rme(),op,eu,sp,fq,Pme=(fq=class extends wh{constructor(){super();kt(this,op,!0);kt(this,eu);kt(this,sp);ft(this,sp,t=>{if(!Uf&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){he(this,eu)||this.setEventListener(he(this,sp))}onUnsubscribe(){var t;this.hasListeners()||((t=he(this,eu))==null||t.call(this),ft(this,eu,void 0))}setEventListener(t){var n;ft(this,sp,t),(n=he(this,eu))==null||n.call(this),ft(this,eu,t(this.setOnline.bind(this)))}setOnline(t){he(this,op)!==t&&(ft(this,op,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return he(this,op)}},op=new WeakMap,eu=new WeakMap,sp=new WeakMap,fq),G1=new Pme;function Fme(e){return Math.min(1e3*2**e,3e4)}function Dq(e){return(e??"online")==="online"?G1.isOnline():!0}var ZD=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Mq(e){let t=!1,n=0,r;const o=KD(),s=()=>o.status!=="pending",i=b=>{var x;if(!s()){const y=new ZD(b);h(y),(x=e.onCancel)==null||x.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>UR.isFocused()&&(e.networkMode==="always"||G1.isOnline())&&e.canRun(),d=()=>Dq(e.networkMode)&&e.canRun(),f=b=>{s()||(r==null||r(),o.resolve(b))},h=b=>{s()||(r==null||r(),o.reject(b))},m=()=>new Promise(b=>{var x;r=y=>{(s()||u())&&b(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var b;r=void 0,s()||(b=e.onContinue)==null||b.call(e)}),g=()=>{if(s())return;let b;const x=n===0?e.initialPromise:void 0;try{b=x??e.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(f).catch(y=>{var _;if(s())return;const w=e.retry??(Uf?0:3),v=e.retryDelay??Fme,C=typeof v=="function"?v(n,y):v,N=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!N){h(y);return}n++,(_=e.onFail)==null||_.call(e,n,y),Tme(C).then(()=>u()?void 0:m()).then(()=>{t?h(y):g()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():m().then(g),o)}}var bf,hq,Aq=(hq=class{constructor(){kt(this,bf)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),WD(this.gcTime)&&ft(this,bf,rf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Uf?1/0:5*60*1e3))}clearGcTimeout(){he(this,bf)&&(rf.clearTimeout(he(this,bf)),ft(this,bf,void 0))}},bf=new WeakMap,hq),xf,ip,ji,yf,mo,C0,vf,ia,Pl,mq,Ome=(mq=class extends Aq{constructor(t){super();kt(this,ia);kt(this,xf);kt(this,ip);kt(this,ji);kt(this,yf);kt(this,mo);kt(this,C0);kt(this,vf);ft(this,vf,!1),ft(this,C0,t.defaultOptions),this.setOptions(t.options),this.observers=[],ft(this,yf,t.client),ft(this,ji,he(this,yf).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ft(this,xf,g$(this.options)),this.state=t.state??he(this,xf),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=he(this,mo))==null?void 0:t.promise}setOptions(t){if(this.options={...he(this,C0),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=g$(this.options);n.data!==void 0&&(this.setState(p$(n.data,n.dataUpdatedAt)),ft(this,xf,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&he(this,ji).remove(this)}setData(t,n){const r=YD(this.state.data,t,this.options);return Ht(this,ia,Pl).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ht(this,ia,Pl).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=he(this,mo))==null?void 0:r.promise;return(o=he(this,mo))==null||o.cancel(t),n?n.then(Zo).catch(Zo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(he(this,xf))}isActive(){return this.observers.some(t=>Ei(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===W1||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>vu(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Tq(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=he(this,mo))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=he(this,mo))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),he(this,ji).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(he(this,mo)&&(he(this,vf)?he(this,mo).cancel({revert:!0}):he(this,mo).cancelRetry()),this.scheduleGc()),he(this,ji).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ht(this,ia,Pl).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,h,m,g,b,x,y,w,v;if(this.state.fetchStatus!=="idle"&&((c=he(this,mo))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(he(this,mo))return he(this,mo).continueRetry(),he(this,mo).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(N=>N.options.queryFn);C&&this.setOptions(C.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(ft(this,vf,!0),r.signal)})},s=()=>{const C=Iq(this.options,n),_=(()=>{const k={client:he(this,yf),queryKey:this.queryKey,meta:this.meta};return o(k),k})();return ft(this,vf,!1),this.options.persister?this.options.persister(C,_,this):C(_)},a=(()=>{const C={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:he(this,yf),state:this.state,fetchFn:s};return o(C),C})();(u=this.options.behavior)==null||u.onFetch(a,this),ft(this,ip,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&Ht(this,ia,Pl).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta}),ft(this,mo,Mq({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:C=>{C instanceof ZD&&C.revert&&this.setState({...he(this,ip),fetchStatus:"idle"}),r.abort()},onFail:(C,N)=>{Ht(this,ia,Pl).call(this,{type:"failed",failureCount:C,error:N})},onPause:()=>{Ht(this,ia,Pl).call(this,{type:"pause"})},onContinue:()=>{Ht(this,ia,Pl).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const C=await he(this,mo).start();if(C===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(C),(m=(h=he(this,ji).config).onSuccess)==null||m.call(h,C,this),(b=(g=he(this,ji).config).onSettled)==null||b.call(g,C,this.state.error,this),C}catch(C){if(C instanceof ZD){if(C.silent)return he(this,mo).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Ht(this,ia,Pl).call(this,{type:"error",error:C}),(y=(x=he(this,ji).config).onError)==null||y.call(x,C,this),(v=(w=he(this,ji).config).onSettled)==null||v.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},xf=new WeakMap,ip=new WeakMap,ji=new WeakMap,yf=new WeakMap,mo=new WeakMap,C0=new WeakMap,vf=new WeakMap,ia=new WeakSet,Pl=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Rq(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...p$(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ft(this,ip,t.manual?o:void 0),o;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Pr.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),he(this,ji).notify({query:this,type:"updated",action:t})})},mq);function Rq(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dq(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function p$(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function g$(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Fs,Nn,N0,bs,wf,ap,ql,tu,_0,lp,cp,Sf,Cf,nu,up,Zn,Yb,XD,QD,JD,e2,t2,n2,r2,Pq,pq,qR=(pq=class extends wh{constructor(t,n){super();kt(this,Zn);kt(this,Fs);kt(this,Nn);kt(this,N0);kt(this,bs);kt(this,wf);kt(this,ap);kt(this,ql);kt(this,tu);kt(this,_0);kt(this,lp);kt(this,cp);kt(this,Sf);kt(this,Cf);kt(this,nu);kt(this,up,new Set);this.options=n,ft(this,Fs,t),ft(this,tu,null),ft(this,ql,KD()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(he(this,Nn).addObserver(this),b$(he(this,Nn),this.options)?Ht(this,Zn,Yb).call(this):this.updateResult(),Ht(this,Zn,e2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return o2(he(this,Nn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return o2(he(this,Nn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ht(this,Zn,t2).call(this),Ht(this,Zn,n2).call(this),he(this,Nn).removeObserver(this)}setOptions(t){const n=this.options,r=he(this,Nn);if(this.options=he(this,Fs).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ei(this.options.enabled,he(this,Nn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ht(this,Zn,r2).call(this),he(this,Nn).setOptions(this.options),n._defaulted&&!ly(this.options,n)&&he(this,Fs).getQueryCache().notify({type:"observerOptionsUpdated",query:he(this,Nn),observer:this});const o=this.hasListeners();o&&x$(he(this,Nn),r,this.options,n)&&Ht(this,Zn,Yb).call(this),this.updateResult(),o&&(he(this,Nn)!==r||Ei(this.options.enabled,he(this,Nn))!==Ei(n.enabled,he(this,Nn))||vu(this.options.staleTime,he(this,Nn))!==vu(n.staleTime,he(this,Nn)))&&Ht(this,Zn,XD).call(this);const s=Ht(this,Zn,QD).call(this);o&&(he(this,Nn)!==r||Ei(this.options.enabled,he(this,Nn))!==Ei(n.enabled,he(this,Nn))||s!==he(this,nu))&&Ht(this,Zn,JD).call(this,s)}getOptimisticResult(t){const n=he(this,Fs).getQueryCache().build(he(this,Fs),t),r=this.createResult(n,t);return $me(this,r)&&(ft(this,bs,r),ft(this,ap,this.options),ft(this,wf,he(this,Nn).state)),r}getCurrentResult(){return he(this,bs)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&he(this,ql).status==="pending"&&he(this,ql).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){he(this,up).add(t)}getCurrentQuery(){return he(this,Nn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=he(this,Fs).defaultQueryOptions(t),r=he(this,Fs).getQueryCache().build(he(this,Fs),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ht(this,Zn,Yb).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),he(this,bs)))}createResult(t,n){var I;const r=he(this,Nn),o=this.options,s=he(this,bs),i=he(this,wf),a=he(this,ap),u=t!==r?t.state:he(this,N0),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const T=this.hasListeners(),E=!T&&b$(t,n),D=T&&x$(t,r,n,o);(E||D)&&(f={...f,...Rq(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=f;m=f.data;let y=!1;if(n.placeholderData!==void 0&&m===void 0&&x==="pending"){let T;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(T=s.data,y=!0):T=typeof n.placeholderData=="function"?n.placeholderData((I=he(this,cp))==null?void 0:I.state.data,he(this,cp)):n.placeholderData,T!==void 0&&(x="success",m=YD(s==null?void 0:s.data,T,n),h=!0)}if(n.select&&m!==void 0&&!y)if(s&&m===(i==null?void 0:i.data)&&n.select===he(this,_0))m=he(this,lp);else try{ft(this,_0,n.select),m=n.select(m),m=YD(s==null?void 0:s.data,m,n),ft(this,lp,m),ft(this,tu,null)}catch(T){ft(this,tu,T)}he(this,tu)&&(g=he(this,tu),m=he(this,lp),b=Date.now(),x="error");const w=f.fetchStatus==="fetching",v=x==="pending",C=x==="error",N=v&&w,_=m!==void 0,j={status:x,fetchStatus:f.fetchStatus,isPending:v,isSuccess:x==="success",isError:C,isInitialLoading:N,isLoading:N,data:m,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!v,isLoadingError:C&&!_,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:C&&_,isStale:WR(t,n),refetch:this.refetch,promise:he(this,ql),isEnabled:Ei(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const T=A=>{j.status==="error"?A.reject(j.error):j.data!==void 0&&A.resolve(j.data)},E=()=>{const A=ft(this,ql,j.promise=KD());T(A)},D=he(this,ql);switch(D.status){case"pending":t.queryHash===r.queryHash&&T(D);break;case"fulfilled":(j.status==="error"||j.data!==D.value)&&E();break;case"rejected":(j.status!=="error"||j.error!==D.reason)&&E();break}}return j}updateResult(){const t=he(this,bs),n=this.createResult(he(this,Nn),this.options);if(ft(this,wf,he(this,Nn).state),ft(this,ap,this.options),he(this,wf).data!==void 0&&ft(this,cp,he(this,Nn)),ly(n,t))return;ft(this,bs,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,s=typeof o=="function"?o():o;if(s==="all"||!s&&!he(this,up).size)return!0;const i=new Set(s??he(this,up));return this.options.throwOnError&&i.add("error"),Object.keys(he(this,bs)).some(a=>{const c=a;return he(this,bs)[c]!==t[c]&&i.has(c)})};Ht(this,Zn,Pq).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ht(this,Zn,e2).call(this)}},Fs=new WeakMap,Nn=new WeakMap,N0=new WeakMap,bs=new WeakMap,wf=new WeakMap,ap=new WeakMap,ql=new WeakMap,tu=new WeakMap,_0=new WeakMap,lp=new WeakMap,cp=new WeakMap,Sf=new WeakMap,Cf=new WeakMap,nu=new WeakMap,up=new WeakMap,Zn=new WeakSet,Yb=function(t){Ht(this,Zn,r2).call(this);let n=he(this,Nn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Zo)),n},XD=function(){Ht(this,Zn,t2).call(this);const t=vu(this.options.staleTime,he(this,Nn));if(Uf||he(this,bs).isStale||!WD(t))return;const r=Tq(he(this,bs).dataUpdatedAt,t)+1;ft(this,Sf,rf.setTimeout(()=>{he(this,bs).isStale||this.updateResult()},r))},QD=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(he(this,Nn)):this.options.refetchInterval)??!1},JD=function(t){Ht(this,Zn,n2).call(this),ft(this,nu,t),!(Uf||Ei(this.options.enabled,he(this,Nn))===!1||!WD(he(this,nu))||he(this,nu)===0)&&ft(this,Cf,rf.setInterval(()=>{(this.options.refetchIntervalInBackground||UR.isFocused())&&Ht(this,Zn,Yb).call(this)},he(this,nu)))},e2=function(){Ht(this,Zn,XD).call(this),Ht(this,Zn,JD).call(this,Ht(this,Zn,QD).call(this))},t2=function(){he(this,Sf)&&(rf.clearTimeout(he(this,Sf)),ft(this,Sf,void 0))},n2=function(){he(this,Cf)&&(rf.clearInterval(he(this,Cf)),ft(this,Cf,void 0))},r2=function(){const t=he(this,Fs).getQueryCache().build(he(this,Fs),this.options);if(t===he(this,Nn))return;const n=he(this,Nn);ft(this,Nn,t),ft(this,N0,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Pq=function(t){Pr.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(he(this,bs))}),he(this,Fs).getQueryCache().notify({query:he(this,Nn),type:"observerResultsUpdated"})})},pq);function Lme(e,t){return Ei(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function b$(e,t){return Lme(e,t)||e.state.data!==void 0&&o2(e,t,t.refetchOnMount)}function o2(e,t,n){if(Ei(t.enabled,e)!==!1&&vu(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&WR(e,t)}return!1}function x$(e,t,n,r){return(e!==t||Ei(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&WR(e,n)}function WR(e,t){return Ei(t.enabled,e)!==!1&&e.isStaleByTime(vu(t.staleTime,e))}function $me(e,t){return!ly(e.getCurrentResult(),t)}function y$(e){return{onFetch:(t,n)=>{var d,f,h,m,g;const r=t.options,o=(h=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,s=((m=t.state.data)==null?void 0:m.pages)||[],i=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let b=!1;const x=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?b=!0:t.signal.addEventListener("abort",()=>{b=!0}),t.signal)})},y=Iq(t.options,t.fetchOptions),w=async(v,C,N)=>{if(b)return Promise.reject();if(C==null&&v.pages.length)return Promise.resolve(v);const k=(()=>{const E={client:t.client,queryKey:t.queryKey,pageParam:C,direction:N?"backward":"forward",meta:t.options.meta};return x(E),E})(),j=await y(k),{maxPages:I}=t.options,T=N?Dme:Eme;return{pages:T(v.pages,j,I),pageParams:T(v.pageParams,C,I)}};if(o&&s.length){const v=o==="backward",C=v?zme:v$,N={pages:s,pageParams:i},_=C(r,N);a=await w(N,_,v)}else{const v=e??s.length;do{const C=c===0?i[0]??r.initialPageParam:v$(r,a);if(c>0&&C==null)break;a=await w(a,C),c++}while(c<v)}return a};t.options.persister?t.fetchFn=()=>{var b,x;return(x=(b=t.options).persister)==null?void 0:x.call(b,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function v$(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function zme(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var k0,Ya,xs,Nf,Ka,Gc,gq,Bme=(gq=class extends Aq{constructor(t){super();kt(this,Ka);kt(this,k0);kt(this,Ya);kt(this,xs);kt(this,Nf);ft(this,k0,t.client),this.mutationId=t.mutationId,ft(this,xs,t.mutationCache),ft(this,Ya,[]),this.state=t.state||Fq(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){he(this,Ya).includes(t)||(he(this,Ya).push(t),this.clearGcTimeout(),he(this,xs).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ft(this,Ya,he(this,Ya).filter(n=>n!==t)),this.scheduleGc(),he(this,xs).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){he(this,Ya).length||(this.state.status==="pending"?this.scheduleGc():he(this,xs).remove(this))}continue(){var t;return((t=he(this,Nf))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,a,c,u,d,f,h,m,g,b,x,y,w,v,C,N,_,k,j,I;const n=()=>{Ht(this,Ka,Gc).call(this,{type:"continue"})},r={client:he(this,k0),meta:this.options.meta,mutationKey:this.options.mutationKey};ft(this,Nf,Mq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(T,E)=>{Ht(this,Ka,Gc).call(this,{type:"failed",failureCount:T,error:E})},onPause:()=>{Ht(this,Ka,Gc).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>he(this,xs).canRun(this)}));const o=this.state.status==="pending",s=!he(this,Nf).canStart();try{if(o)n();else{Ht(this,Ka,Gc).call(this,{type:"pending",variables:t,isPaused:s}),await((a=(i=he(this,xs).config).onMutate)==null?void 0:a.call(i,t,this,r));const E=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));E!==this.state.context&&Ht(this,Ka,Gc).call(this,{type:"pending",context:E,variables:t,isPaused:s})}const T=await he(this,Nf).start();return await((f=(d=he(this,xs).config).onSuccess)==null?void 0:f.call(d,T,t,this.state.context,this,r)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,T,t,this.state.context,r)),await((b=(g=he(this,xs).config).onSettled)==null?void 0:b.call(g,T,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,T,null,t,this.state.context,r)),Ht(this,Ka,Gc).call(this,{type:"success",data:T}),T}catch(T){try{throw await((v=(w=he(this,xs).config).onError)==null?void 0:v.call(w,T,t,this.state.context,this,r)),await((N=(C=this.options).onError)==null?void 0:N.call(C,T,t,this.state.context,r)),await((k=(_=he(this,xs).config).onSettled)==null?void 0:k.call(_,void 0,T,this.state.variables,this.state.context,this,r)),await((I=(j=this.options).onSettled)==null?void 0:I.call(j,void 0,T,t,this.state.context,r)),T}finally{Ht(this,Ka,Gc).call(this,{type:"error",error:T})}}finally{he(this,xs).runNext(this)}}},k0=new WeakMap,Ya=new WeakMap,xs=new WeakMap,Nf=new WeakMap,Ka=new WeakSet,Gc=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Pr.batch(()=>{he(this,Ya).forEach(r=>{r.onMutationUpdate(t)}),he(this,xs).notify({mutation:this,type:"updated",action:t})})},gq);function Fq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Wl,aa,j0,bq,Vme=(bq=class extends wh{constructor(t={}){super();kt(this,Wl);kt(this,aa);kt(this,j0);this.config=t,ft(this,Wl,new Set),ft(this,aa,new Map),ft(this,j0,0)}build(t,n,r){const o=new Bme({client:t,mutationCache:this,mutationId:++rw(this,j0)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){he(this,Wl).add(t);const n=sw(t);if(typeof n=="string"){const r=he(this,aa).get(n);r?r.push(t):he(this,aa).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(he(this,Wl).delete(t)){const n=sw(t);if(typeof n=="string"){const r=he(this,aa).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&he(this,aa).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=sw(t);if(typeof n=="string"){const r=he(this,aa).get(n),o=r==null?void 0:r.find(s=>s.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=sw(t);if(typeof n=="string"){const o=(r=he(this,aa).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Pr.batch(()=>{he(this,Wl).forEach(t=>{this.notify({type:"removed",mutation:t})}),he(this,Wl).clear(),he(this,aa).clear()})}getAll(){return Array.from(he(this,Wl))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>f$(n,r))}findAll(t={}){return this.getAll().filter(n=>f$(t,n))}notify(t){Pr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Pr.batch(()=>Promise.all(t.map(n=>n.continue().catch(Zo))))}},Wl=new WeakMap,aa=new WeakMap,j0=new WeakMap,bq);function sw(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Gl,ru,Os,Yl,yc,JS,s2,xq,Hme=(xq=class extends wh{constructor(n,r){super();kt(this,yc);kt(this,Gl);kt(this,ru);kt(this,Os);kt(this,Yl);ft(this,Gl,n),this.setOptions(r),this.bindMethods(),Ht(this,yc,JS).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=he(this,Gl).defaultMutationOptions(n),ly(this.options,r)||he(this,Gl).getMutationCache().notify({type:"observerOptionsUpdated",mutation:he(this,Os),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&qf(r.mutationKey)!==qf(this.options.mutationKey)?this.reset():((o=he(this,Os))==null?void 0:o.state.status)==="pending"&&he(this,Os).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=he(this,Os))==null||n.removeObserver(this)}onMutationUpdate(n){Ht(this,yc,JS).call(this),Ht(this,yc,s2).call(this,n)}getCurrentResult(){return he(this,ru)}reset(){var n;(n=he(this,Os))==null||n.removeObserver(this),ft(this,Os,void 0),Ht(this,yc,JS).call(this),Ht(this,yc,s2).call(this)}mutate(n,r){var o;return ft(this,Yl,r),(o=he(this,Os))==null||o.removeObserver(this),ft(this,Os,he(this,Gl).getMutationCache().build(he(this,Gl),this.options)),he(this,Os).addObserver(this),he(this,Os).execute(n)}},Gl=new WeakMap,ru=new WeakMap,Os=new WeakMap,Yl=new WeakMap,yc=new WeakSet,JS=function(){var r;const n=((r=he(this,Os))==null?void 0:r.state)??Fq();ft(this,ru,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},s2=function(n){Pr.batch(()=>{var r,o,s,i,a,c,u,d;if(he(this,Yl)&&this.hasListeners()){const f=he(this,ru).variables,h=he(this,ru).context,m={client:he(this,Gl),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((o=(r=he(this,Yl)).onSuccess)==null||o.call(r,n.data,f,h,m),(i=(s=he(this,Yl)).onSettled)==null||i.call(s,n.data,null,f,h,m)):(n==null?void 0:n.type)==="error"&&((c=(a=he(this,Yl)).onError)==null||c.call(a,n.error,f,h,m),(d=(u=he(this,Yl)).onSettled)==null||d.call(u,void 0,n.error,f,h,m))}this.listeners.forEach(f=>{f(he(this,ru))})})},xq);function w$(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Ume(e,t,n){const r=e.slice(0);return r[t]=n,r}var _f,ni,dp,fp,Ti,ou,T0,I0,E0,Uo,i2,a2,l2,c2,u2,yq,qme=(yq=class extends wh{constructor(t,n,r){super();kt(this,Uo);kt(this,_f);kt(this,ni);kt(this,dp);kt(this,fp);kt(this,Ti);kt(this,ou);kt(this,T0);kt(this,I0);kt(this,E0,[]);ft(this,_f,t),ft(this,fp,r),ft(this,dp,[]),ft(this,Ti,[]),ft(this,ni,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&he(this,Ti).forEach(t=>{t.subscribe(n=>{Ht(this,Uo,c2).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,he(this,Ti).forEach(t=>{t.destroy()})}setQueries(t,n){if(ft(this,dp,t),ft(this,fp,n),process.env.NODE_ENV!=="production"){const r=t.map(o=>he(this,_f).defaultQueryOptions(o).queryHash);new Set(r).size!==r.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}Pr.batch(()=>{const r=he(this,Ti),o=Ht(this,Uo,l2).call(this,he(this,dp));ft(this,E0,o),o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const s=o.map(f=>f.observer),i=s.map(f=>f.getCurrentResult()),a=r.length!==s.length,c=s.some((f,h)=>f!==r[h]),u=a||c,d=u?!0:i.some((f,h)=>{const m=he(this,ni)[h];return!m||!ly(f,m)});!u&&!d||(u&&ft(this,Ti,s),ft(this,ni,i),this.hasListeners()&&(u&&(w$(r,s).forEach(f=>{f.destroy()}),w$(s,r).forEach(f=>{f.subscribe(h=>{Ht(this,Uo,c2).call(this,f,h)})})),Ht(this,Uo,u2).call(this)))})}getCurrentResult(){return he(this,ni)}getQueries(){return he(this,Ti).map(t=>t.getCurrentQuery())}getObservers(){return he(this,Ti)}getOptimisticResult(t,n){const r=Ht(this,Uo,l2).call(this,t),o=r.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions));return[o,s=>Ht(this,Uo,a2).call(this,s??o,n),()=>Ht(this,Uo,i2).call(this,o,r)]}},_f=new WeakMap,ni=new WeakMap,dp=new WeakMap,fp=new WeakMap,Ti=new WeakMap,ou=new WeakMap,T0=new WeakMap,I0=new WeakMap,E0=new WeakMap,Uo=new WeakSet,i2=function(t,n){return n.map((r,o)=>{const s=t[o];return r.defaultedQueryOptions.notifyOnChangeProps?s:r.observer.trackResult(s,i=>{n.forEach(a=>{a.observer.trackProp(i)})})})},a2=function(t,n){return n?((!he(this,ou)||he(this,ni)!==he(this,I0)||n!==he(this,T0))&&(ft(this,T0,n),ft(this,I0,he(this,ni)),ft(this,ou,q1(he(this,ou),n(t)))),he(this,ou)):t},l2=function(t){const n=new Map;he(this,Ti).forEach(o=>{const s=o.options.queryHash;if(!s)return;const i=n.get(s);i?i.push(o):n.set(s,[o])});const r=[];return t.forEach(o=>{var c;const s=he(this,_f).defaultQueryOptions(o),a=((c=n.get(s.queryHash))==null?void 0:c.shift())??new qR(he(this,_f),s);r.push({defaultedQueryOptions:s,observer:a})}),r},c2=function(t,n){const r=he(this,Ti).indexOf(t);r!==-1&&(ft(this,ni,Ume(he(this,ni),r,n)),Ht(this,Uo,u2).call(this))},u2=function(){var t;if(this.hasListeners()){const n=he(this,ou),r=Ht(this,Uo,i2).call(this,he(this,ni),he(this,E0)),o=Ht(this,Uo,a2).call(this,r,(t=he(this,fp))==null?void 0:t.combine);n!==o&&Pr.batch(()=>{this.listeners.forEach(s=>{s(he(this,ni))})})}},yq),Za,vq,Oq=(vq=class extends wh{constructor(t={}){super();kt(this,Za);this.config=t,ft(this,Za,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??HR(o,n);let i=this.get(s);return i||(i=new Ome({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){he(this,Za).has(t.queryHash)||(he(this,Za).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=he(this,Za).get(t.queryHash);n&&(t.destroy(),n===t&&he(this,Za).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Pr.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return he(this,Za).get(t)}getAll(){return[...he(this,Za).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>d$(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>d$(t,r)):n}notify(t){Pr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Pr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Pr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Za=new WeakMap,vq),zr,su,iu,hp,mp,au,pp,gp,wq,Wme=(wq=class{constructor(e={}){kt(this,zr);kt(this,su);kt(this,iu);kt(this,hp);kt(this,mp);kt(this,au);kt(this,pp);kt(this,gp);ft(this,zr,e.queryCache||new Oq),ft(this,su,e.mutationCache||new Vme),ft(this,iu,e.defaultOptions||{}),ft(this,hp,new Map),ft(this,mp,new Map),ft(this,au,0)}mount(){rw(this,au)._++,he(this,au)===1&&(ft(this,pp,UR.subscribe(async e=>{e&&(await this.resumePausedMutations(),he(this,zr).onFocus())})),ft(this,gp,G1.subscribe(async e=>{e&&(await this.resumePausedMutations(),he(this,zr).onOnline())})))}unmount(){var e,t;rw(this,au)._--,he(this,au)===0&&((e=he(this,pp))==null||e.call(this),ft(this,pp,void 0),(t=he(this,gp))==null||t.call(this),ft(this,gp,void 0))}isFetching(e){return he(this,zr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return he(this,su).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=he(this,zr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=he(this,zr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(vu(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return he(this,zr).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=he(this,zr).get(r.queryHash),s=o==null?void 0:o.state.data,i=kme(t,s);if(i!==void 0)return he(this,zr).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Pr.batch(()=>he(this,zr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=he(this,zr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=he(this,zr);Pr.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=he(this,zr);return Pr.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Pr.batch(()=>he(this,zr).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Zo).catch(Zo)}invalidateQueries(e,t={}){return Pr.batch(()=>(he(this,zr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Pr.batch(()=>he(this,zr).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(Zo)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Zo)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=he(this,zr).build(this,t);return n.isStaleByTime(vu(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Zo).catch(Zo)}fetchInfiniteQuery(e){return e.behavior=y$(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Zo).catch(Zo)}ensureInfiniteQueryData(e){return e.behavior=y$(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return G1.isOnline()?he(this,su).resumePausedMutations():Promise.resolve()}getQueryCache(){return he(this,zr)}getMutationCache(){return he(this,su)}getDefaultOptions(){return he(this,iu)}setDefaultOptions(e){ft(this,iu,e)}setQueryDefaults(e,t){he(this,hp).set(qf(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...he(this,hp).values()],n={};return t.forEach(r=>{ay(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){he(this,mp).set(qf(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...he(this,mp).values()],n={};return t.forEach(r=>{ay(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...he(this,iu).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=HR(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===W1&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...he(this,iu).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){he(this,zr).clear(),he(this,su).clear()}},zr=new WeakMap,su=new WeakMap,iu=new WeakMap,hp=new WeakMap,mp=new WeakMap,au=new WeakMap,pp=new WeakMap,gp=new WeakMap,wq),GR=Q.createContext(void 0),Xr=e=>{const t=Q.useContext(GR);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Gme=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(GR.Provider,{value:e,children:t})),Lq=Q.createContext(!1),$q=()=>Q.useContext(Lq);Lq.Provider;function Yme(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Kme=Q.createContext(Yme()),zq=()=>Q.useContext(Kme),Bq=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Vq=e=>{Q.useEffect(()=>{e.clearReset()},[e])},Hq=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Eq(n,[e.error,r])),Uq=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},qq=(e,t)=>e.isLoading&&e.isFetching&&!t,d2=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Y1=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Qp({queries:e,...t},n){const r=Xr(),o=$q(),s=zq(),i=Q.useMemo(()=>e.map(b=>{const x=r.defaultQueryOptions(b);return x._optimisticResults=o?"isRestoring":"optimistic",x}),[e,r,o]);i.forEach(b=>{Uq(b),Bq(b,s)}),Vq(s);const[a]=Q.useState(()=>new qme(r,i,t)),[c,u,d]=a.getOptimisticResult(i,t.combine),f=!o&&t.subscribed!==!1;Q.useSyncExternalStore(Q.useCallback(b=>f?a.subscribe(Pr.batchCalls(b)):Zo,[a,f]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),Q.useEffect(()=>{a.setQueries(i,t)},[i,t,a]);const m=c.some((b,x)=>d2(i[x],b))?c.flatMap((b,x)=>{const y=i[x];if(y){const w=new qR(r,y);if(d2(y,b))return Y1(y,w,s);qq(b,o)&&Y1(y,w,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const g=c.find((b,x)=>{const y=i[x];return y&&Hq({result:b,errorResetBoundary:s,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(g!=null&&g.error)throw g.error;return u(d())}function Zme(e,t,n){var f,h,m,g,b;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=$q(),o=zq(),s=Xr(),i=s.defaultQueryOptions(e);(h=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=r?"isRestoring":"optimistic",Uq(i),Bq(i,o),Vq(o);const a=!s.getQueryCache().get(i.queryHash),[c]=Q.useState(()=>new t(s,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(Q.useSyncExternalStore(Q.useCallback(x=>{const y=d?c.subscribe(Pr.batchCalls(x)):Zo;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Q.useEffect(()=>{c.setOptions(i)},[i,c]),d2(i,u))throw Y1(i,c,o);if(Hq({result:u,errorResetBoundary:o,throwOnError:i.throwOnError,query:s.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((g=(m=s.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||g.call(m,i,u),i.experimental_prefetchInRender&&!Uf&&qq(u,r)){const x=a?Y1(i,c,o):(b=s.getQueryCache().get(i.queryHash))==null?void 0:b.promise;x==null||x.catch(Zo).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function Rn(e,t){return Zme(e,qR)}function Xme(e,t){const n=Xr(),r=n.getQueryCache();return Q.useSyncExternalStore(Q.useCallback(o=>r.subscribe(Pr.batchCalls(o)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function ss(e,t){const n=Xr(),[r]=Q.useState(()=>new Hme(n,e));Q.useEffect(()=>{r.setOptions(e)},[r,e]);const o=Q.useSyncExternalStore(Q.useCallback(i=>r.subscribe(Pr.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=Q.useCallback((i,a)=>{r.mutate(i,a).catch(Zo)},[r]);if(o.error&&Eq(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}function Qme(){const e=S.useContext(GR);if(e&&e.isSemaphorClient)return e}function Wq({children:e}){const{setIsSessionExpired:t}=p.useDashboardActions(),n=Qme(),[r]=S.useState(()=>{const o=new Wme({queryCache:new Oq({onError:s=>{s instanceof Error?(console.error(`Something went wrong: ${s.message}`),s.message==="invalid token"&&t(!0)):console.error("Something went wrong:",s)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:!1}}});return o.isSemaphorClient=!0,o});return n?l.jsx(l.Fragment,{children:e}):l.jsx(Gme,{client:r,children:e})}const Jme={id:"",authToken:void 0,tokenProps:{}},D0=S.createContext(Jme),YR=({children:e,dashboardProps:t})=>{const n=S.useMemo(()=>{let r={};const o=t.authToken;return o&&(r=Te.jwtDecode(o.accessToken)),{...t,tokenProps:r}},[t]);return l.jsx(Wq,{children:l.jsx(D0.Provider,{value:n,children:e})})};function gt(){const e=S.useContext(D0);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}const $o=p.create()(p.immer(e=>({initialDashboard:null,selectedDashboard:null,selectedVisual:null,lastSelectedDashboard:null,lastSelectedVisual:null,showHub:!1,actions:{setInitialDashboard:t=>{e(n=>{n.initialDashboard=t})},selectDashboard:t=>{e(n=>{var r;((r=n.selectedDashboard)==null?void 0:r.id)!==t.id&&(n.lastSelectedDashboard=n.selectedDashboard,n.selectedDashboard=t),n.showHub=!1})},updateSelectedDashboard:t=>{e(n=>{n.selectedDashboard=t})},selectVisual:t=>{e(n=>{n.lastSelectedVisual=n.selectedVisual,n.selectedVisual=t})},clearSelectedDashboard:()=>{e(t=>{t.lastSelectedDashboard=t.selectedDashboard,t.selectedDashboard=null,t.showHub=!0})},clearSelectedVisual:()=>{e(t=>{t.lastSelectedVisual=t.selectedVisual,t.selectedVisual=null})},setShowHub:t=>{e(n=>{n.showHub=t})}}}))),epe=()=>$o(e=>e.selectedVisual),Sh=()=>$o(e=>e.actions);function M0(){const{authToken:e,version:t,tokenProps:n,id:r}=gt(),o=$o(g=>g.selectedDashboard),s=$o(g=>g.showHub),i=p.useDashboardStore(g=>g.selectedLensId),a=tpe({showHub:s,selectedDashboardId:o==null?void 0:o.id,dashboardId:r,tokenDashboardId:n==null?void 0:n.dashboard_id});function c(){return!(!(e!=null&&e.accessToken)||!a)}const{data:u,isLoading:d,isFetching:f,isError:h,refetch:m}=Rn({queryKey:["dashboard",i,e==null?void 0:e.accessToken,a],queryFn:()=>p.getDashboard(n.apiServiceUrl,e==null?void 0:e.accessToken,{lensId:i,version:t,dashboardId:a}),enabled:c()});return{data:u,isLoading:d,isFetching:f,isError:h,refetch:m,dashboardIdToFetch:a}}function tpe({showHub:e,selectedDashboardId:t,dashboardId:n,tokenDashboardId:r}){return e?null:t||n||r||null}function npe(){const{authToken:e}=gt(),t=p.useDashboardStore(r=>r.authToken),{setAuthToken:n}=p.useDashboardActions();return S.useEffect(()=>{const r=e==null?void 0:e.accessToken,o=t==null?void 0:t.accessToken;e&&r!==o&&n(e)},[e,t,n]),e}function Gq(e){const t=S.useCallback(s=>`semaphor-default-sheet-${s}`,[]),n=S.useCallback(()=>{if(!e)return null;try{const s=t(e);return localStorage.getItem(s)}catch(s){return console.error("Error reading default sheet preference:",s),null}},[e,t]),r=S.useCallback(s=>{if(!(!e||!s))try{const i=t(e);localStorage.setItem(i,s)}catch(i){console.error("Error saving default sheet preference:",i)}},[e,t]),o=S.useCallback(()=>{if(e)try{const s=t(e);localStorage.removeItem(s)}catch(s){console.error("Error clearing default sheet preference:",s)}},[e,t]);return{getDefaultSheetId:n,setDefaultSheetId:r,clearDefaultSheetId:o}}function rpe(e,t){if(!e||typeof e!="object"||!("kind"in e))return e;switch(e.kind){case"manual":return{kind:"manual",...t!=null&&t.includePresentation?{options:e.options.map(n=>({value:n.value,label:n.label,presentation:n.presentation}))}:{optionValues:e.options.map(n=>n.value).sort()}};case"dataset_values":return{kind:"dataset_values",fieldId:e.fieldId,connectionId:e.connectionId||""};case"field_allowlist":return{kind:"field_allowlist",fieldIds:[...e.fieldIds].sort()};case"metric_allowlist":return{kind:"metric_allowlist",metricIds:[...e.metricIds].sort()};case"sql_query":return{kind:"sql_query",connectionId:e.connectionId,sql:e.sql,valueColumn:e.valueColumn,labelColumn:e.labelColumn};default:return e}}function ope(e,t){return{id:e.id,scope:e.scope,type:e.type,source:rpe(e.source,t),initialValueStrategy:e.initialValueStrategy,defaultValue:e.defaultValue,requiredAtExecution:e.requiredAtExecution,...t!=null&&t.includePresentation?{label:e.label,helpText:e.helpText,hidden:e.hidden,locked:e.locked,placement:e.placement,showLabel:e.showLabel,toolbarWidth:e.toolbarWidth}:{}}}function spe(e){return e.target==="sql_param"?e:{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([r],[o])=>r.localeCompare(o))):n]))}}function S$(e=[],t){return[...e].map(n=>ope(n,t)).sort((n,r)=>n.id.localeCompare(r.id)||n.scope.localeCompare(r.scope)||n.type.localeCompare(r.type))}function ipe(e=[]){return[...e].map(spe).sort((t,n)=>Ss.stableSerialize(t).localeCompare(Ss.stableSerialize(n)))}function f2(e,t){return e?Ss.stableSerialize({controlDefinitions:S$(e.controlDefinitions,t),cardControlDefinitions:S$(e.cardControlDefinitions,t),controlBindings:ipe(e.controlBindings)}):"__none__"}function nT(e,t){return e&&t.has(e)?e:null}function ape({selectedSheetId:e,preservedSelectedSheetId:t,defaultSheetId:n,sheets:r}){var s;const o=new Set((r||[]).map(i=>i.id).filter(i=>typeof i=="string"));return nT(e,o)||nT(t,o)||nT(n,o)||((s=r==null?void 0:r[0])==null?void 0:s.id)||null}function Yq(e){const t=e.trim().split(/[^A-Za-z0-9]+/).filter(Boolean).map(r=>r.toLowerCase());if(!t.length)return"input";const n=t.map((r,o)=>o===0?r:N$(r)).join("");return/^[A-Za-z]/.test(n)?n:`input${N$(n)}`}function KR(e,t){const n=Yq(e);return Kq(n,t)}function A0(e){const n=e.trim().replace(/^\{\{\s*/,"").replace(/\s*\}\}$/,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"");return n?/^[A-Za-z]/.test(n)?n:`input_${n}`:"input"}function Eu(e,t){return Kq(A0(e),t)}function Kq(e,t){const n=new Set(t.map(o=>o.variableName).filter(o=>!!o));if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r+=1;return`${e}${r}`}function ZR(e){return p.getDataType(e.dataType)==="date"?["label","start","end","range"]:["label","value"]}function XR(e){return cpe(e)?["label","value"]:["value"]}function C$(e){return e.kind==="filter"?`filter:${e.filter.id}`:`control:${e.control.id}`}function lpe(e){return{placement:e.hide||e.displayMode==="canvas"?"hidden":"toolbar",...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function Zq(e){return{placement:e.hidden?"hidden":e.placement||(e.scope==="card"?"card_header":"toolbar"),...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function K1(e){return!!e.compatibility}function cpe(e){return e.type==="enum"||e.type==="multi_enum"||e.type==="field_selector"||e.type==="metric_selector"||e.type==="aggregation_selector"||e.type==="grain_selector"}function N$(e){return e&&e[0].toUpperCase()+e.slice(1)}function upe(e){var i,a;const t=[...e.inputs||[]],n=new Set(t.map(c=>c.id)),r=new Set((e.sheets||[]).filter(c=>c.kind==="document").map(c=>c.id));let o=!1;for(const c of e.sheets||[])if(!(c.kind!=="document"||!((a=(i=c.document)==null?void 0:i.inputs)!=null&&a.length)))for(const u of c.document.inputs)n.has(u.id)||(t.push(dpe(u,c.id)),n.add(u.id),o=!0);const s=t.map(c=>{if(c.kind==="filter"&&_$(c,r)&&c.filter.variableName!==c.variableName)return o=!0,{...c,filter:{...c.filter,variableName:c.variableName}};if(c.kind!=="control"||!_$(c,r))return c;const u=Eu(c.control.id||c.variableName,t.filter(d=>d.id!==c.id));return c.variableName===u&&c.control.id===u?c:(o=!0,{...c,variableName:u,control:{...c.control,id:u}})});return o?{...e,inputs:s}:e}function dpe(e,t){const n={id:e.id,label:e.label,variableName:e.variableName,description:e.description,requiredAtExecution:e.requiredAtExecution,scope:{kind:"sheets",sheetIds:[t]},runtimeScope:"perSheet",presentation:{placement:"toolbar"},exports:e.exports,compatibility:{source:"documentInput",sheetId:t,inputId:e.id}};return e.kind==="filter"?{...n,kind:"filter",filter:e.filter}:{...n,kind:"control",control:e.control}}function _$(e,t){var n;switch(e.scope.kind){case"allSheets":return!((n=e.scope.sheetKinds)!=null&&n.length)||e.scope.sheetKinds.includes("document");case"sheets":return e.scope.sheetIds.some(r=>t.has(r));case"documentSections":return t.has(e.scope.sheetId);default:return!1}}function fpe(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function hpe(e,t){const n=fpe(e);return n==="dark"?fl({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function k$(e,t,n){return xme(hpe(e,t),n)}function mpe(e){return Ss.stableSerialize({hasExplicitDefaultControlValues:e!==void 0,values:e??null})}function ppe(e,t){const{controlContractOverrides:n,cardId:r}=t;if(!n||(n.controlDefinitions!==void 0&&(e.controls=n.controlDefinitions),typeof r!="string"||r.trim().length===0))return e;const o=p.findCardById(e,r);return o&&(n.cardControlDefinitions!==void 0&&(o.controls=n.cardControlDefinitions),n.controlBindings!==void 0&&(o.controlBindings=n.controlBindings)),e}function gpe(e,t){const n=S.useRef({key:t,value:e});return n.current.key!==t&&(n.current={key:t,value:e}),n.current.value}function bpe({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,defaultControlValues:s,controlContractOverrides:i,dashboardInputExecutionSnapshot:a,type:c,cardId:u,selectedSheetId:d,onFilterValuesChange:f}){var ye,se,Ie,fe,me;const{authToken:h,tokenProps:m}=gt();npe();const g=p.useDashboardStore(we=>we.selectedLensId),b=p.useDashboardStore(we=>we.relaodToken),{data:x,isLoading:y,isFetching:w,isError:v,refetch:C,dashboardIdToFetch:N}=M0(),_=((se=(ye=m==null?void 0:m.params)==null?void 0:ye.calendarContext)==null?void 0:se.tz)||((Ie=m==null?void 0:m.params)==null?void 0:Ie.timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone,k=(fe=x==null?void 0:x.dashboard)==null?void 0:fe.id,{getDefaultSheetId:j,clearDefaultSheetId:I}=Gq(k),[T,E]=S.useState(o||[]),D=S.useRef(null),A=S.useRef(null),P=mpe(s),M=f2(i),L=f2(i,{includePresentation:!0}),$=S.useRef(s);$.current=s;const z=S.useRef(P);z.current=P;const W=gpe(i,L),F=S.useRef(null),X=S.useRef(!1),Y=S.useRef({dashboardId:null,defaultControlValuesKey:P,controlContractOverridesKey:M}),{setTheme:R}=VR(),{compiledAppearance:K}=p.useAppearance(),O=p.useDashboardStore(we=>we.dashboard.globalStyle),U=S.useMemo(()=>x!=null&&x.dashboard?upe(ppe($s(x.dashboard),{controlContractOverrides:W,cardId:u})):void 0,[x==null?void 0:x.dashboard,W,c,u]),{setDashboardWithFilterValues:V,hydrateRuntimeControlValues:H,setStyle:q,setOnSaveFunction:B,setLenses:G,setSelectedLensId:Z,setInlineFilterValuesMap:J}=p.useDashboardActions();p.useDashboardStore(we=>we.actions.setCustomCards);const oe=p.useDashboardStore(we=>we.filterValues),ie=p.useDashboardStore(we=>we.actions.setThemeStyle),ue=p.useDashboardStore(we=>we.actions.setDashboardTheme),xe=p.useDashboardStore(we=>we.actions.setOnEvent);S.useEffect(()=>{const we=A.current;we&&we!==N&&p.storeEvents.emit("dashboard:unload"),A.current=N},[N]),S.useEffect(()=>{b&&C()},[C,b]),S.useEffect(()=>{var re;const we=((re=x==null?void 0:x.dashboard)==null?void 0:re.id)||null,ee=D.current;we&&we!==ee&&p.storeEvents.emit("dashboard:load"),D.current=we},[(me=x==null?void 0:x.dashboard)==null?void 0:me.id]),S.useEffect(()=>{ue(K.mode)},[K.mode,ue]),S.useEffect(()=>{t&&R(t)},[t,R]);const te=S.useCallback(()=>{const we=$s(p.DEFAULT_STYLE),ee=fl(we,O);if(e){const re=fl(ee,e),ne=k$(K.mode,re,K);ie(ne),q(re)}else{const re=k$(K.mode,ee,K);ie(re),q(p.DEFAULT_STYLE)}},[K,e,O,ie,q]);return S.useEffect(()=>{x&&x.dashboard&&te()},[K.mode,e,O,te,x]),S.useEffect(()=>{var He,_e,Me,De;function we(je,Ue){const mt=je.filters||[],pt=[];for(const ut of Ue){const ht=mt.find(nt=>nt.id===ut.filterId);ht&&pt.push({filterId:ut.filterId,name:ht.column,operation:ut.operation,valueType:p.getFilterValueType(ht),values:ut.values,dataType:ht.dataType,fieldMeta:ht.fieldMeta,semanticContext:ht.semanticContext})}return pt}if(!x||!U)return;const ee=U,{filterValues:re,defaultLensId:ne,lenses:ce}=x;function ae(){if(re&&(re==null?void 0:re.length)>0)return re;const Ue=[...p.buildFilterValuesFromDefaults(ee.filters,_)];if(ee.defaultFilterValues&&ee.defaultFilterValues.length>0)for(const ut of ee.defaultFilterValues){const ht=Ue.findIndex(nt=>nt.filterId===ut.filterId);ht>=0?Ue[ht]=ut:Ue.push(ut)}const mt=we(ee,T||[]),pt=[...Ue];for(const ut of mt){const ht=pt.findIndex(nt=>nt.filterId===ut.filterId);ht>=0?pt[ht]=ut:pt.push(ut)}return pt}const Ne=p.useDashboardStore.getState(),Ee=F.current===U.id&&((He=Ne.dashboard)==null?void 0:He.id)===U.id,Ve=ae(),ge=Ee?p.resolveSameDashboardFilterValues({previousFilters:(_e=Ne.dashboard)==null?void 0:_e.filters,nextFilters:ee.filters,currentFilterValues:Ne.filterValues,defaultFilterValues:Ve}):Ve,pe=p.computeInlineFilterDefaults(ee,_),$e=Ee&&Y.current.controlContractOverridesKey===M?p.flattenRuntimeControlValues({dashboardValues:Ne.controlValues,cardValuesMap:Ne.cardControlValuesMap}):$.current,Fe=Ne.selectedSheetId;let ze=j(),Ze=Fe;Ze&&((Me=U==null?void 0:U.sheets)!=null&&Me.some(Ue=>Ue.id===Ze)||(Ze=null)),ze&&((De=U==null?void 0:U.sheets)!=null&&De.some(Ue=>Ue.id===ze)||(I(),ze=null));const Je=ape({selectedSheetId:d,preservedSelectedSheetId:Ze,defaultSheetId:ze,sheets:U==null?void 0:U.sheets}),Ce=!!a,Qe=!Ce&&X.current;V(ee,ge||[],$e,{selectedSheetId:Je,...x!=null&&x.semanticExecutionPayload?{semanticExecutionPayload:x.semanticExecutionPayload}:{},...a?{dashboardInputValues:a.dashboardInputValues,dashboardInputValuesAreAuthoritative:!0}:Qe?{dashboardInputValues:{},dashboardInputValuesAreAuthoritative:!1}:{}}),X.current=Ce,F.current=U.id,Y.current.dashboardId!==U.id&&(Y.current={dashboardId:U.id,defaultControlValuesKey:z.current,controlContractOverridesKey:M}),J(pe),ce&&G(ce),ne&&Z(ne)},[x,_,g,G,V,Z,J,T,d,j,I,M,a,U]),S.useEffect(()=>{if(!(U!=null&&U.id))return;const we=Y.current;if(we.dashboardId!==U.id){Y.current={dashboardId:U.id,defaultControlValuesKey:P,controlContractOverridesKey:M};return}we.defaultControlValuesKey===P&&we.controlContractOverridesKey===M||(H(U,$.current),Y.current={dashboardId:U.id,defaultControlValuesKey:P,controlContractOverridesKey:M})},[U,P,M,H]),S.useEffect(()=>{f&&oe&&f(oe)},[oe,f]),S.useEffect(()=>{n&&B(n),r&&xe(r)},[n,B,r,xe]),{isFetching:w,isLoading:y,isError:v}}const cy=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));cy.displayName="Card";const QR=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex flex-col space-y-1.5 p-6",e),...t}));QR.displayName="CardHeader";const Jp=Q.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:p.cn("text-2xl font-semibold leading-none tracking-tight",e),...t}));Jp.displayName="CardTitle";const xpe=Q.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));xpe.displayName="CardDescription";const JR=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("px-6 pt-0",e),...t}));JR.displayName="CardContent";const Xq=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex items-center p-6 pt-0",e),...t}));Xq.displayName="CardFooter";/**
|
|
@@ -1293,12 +1293,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
1293
1293
|
|
|
1294
1294
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
1295
1295
|
|
|
1296
|
-
`)}})}});var Wut=$ct(()=>Pue(Ki([Ar({type:gn("text-start"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("text-delta"),id:Ot(),delta:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("text-end"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("error"),errorText:Ot()}),Ar({type:gn("tool-input-start"),toolCallId:Ot(),toolName:Ot(),providerExecuted:Rs().optional(),dynamic:Rs().optional()}),Ar({type:gn("tool-input-delta"),toolCallId:Ot(),inputTextDelta:Ot()}),Ar({type:gn("tool-input-available"),toolCallId:Ot(),toolName:Ot(),input:Wa(),providerExecuted:Rs().optional(),providerMetadata:Wr.optional(),dynamic:Rs().optional()}),Ar({type:gn("tool-input-error"),toolCallId:Ot(),toolName:Ot(),input:Wa(),providerExecuted:Rs().optional(),providerMetadata:Wr.optional(),dynamic:Rs().optional(),errorText:Ot()}),Ar({type:gn("tool-output-available"),toolCallId:Ot(),output:Wa(),providerExecuted:Rs().optional(),dynamic:Rs().optional(),preliminary:Rs().optional()}),Ar({type:gn("tool-output-error"),toolCallId:Ot(),errorText:Ot(),providerExecuted:Rs().optional(),dynamic:Rs().optional()}),Ar({type:gn("reasoning-start"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("reasoning-delta"),id:Ot(),delta:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("reasoning-end"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("source-url"),sourceId:Ot(),url:Ot(),title:Ot().optional(),providerMetadata:Wr.optional()}),Ar({type:gn("source-document"),sourceId:Ot(),mediaType:Ot(),title:Ot(),filename:Ot().optional(),providerMetadata:Wr.optional()}),Ar({type:gn("file"),url:Ot(),mediaType:Ot(),providerMetadata:Wr.optional()}),Ar({type:Eue(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ot().optional(),data:Wa(),transient:Rs().optional()}),Ar({type:gn("start-step")}),Ar({type:gn("finish-step")}),Ar({type:gn("start"),messageId:Ot().optional(),messageMetadata:Wa().optional()}),Ar({type:gn("finish"),finishReason:jue(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:Wa().optional()}),Ar({type:gn("abort")}),Ar({type:gn("message-metadata"),messageMetadata:Wa()})])));function Gut(e){return e.type.startsWith("data-")}function Hue(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const o=t[r];if(o===void 0)continue;const s=r in e?e[r]:void 0,i=o!==null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);i&&a?n[r]=Hue(s,o):n[r]=o}return n}function Yut(e){const t=["ROOT"];let n=-1,r=null;function o(c,u,d){switch(c){case'"':{n=u,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}function s(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function i(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let c=0;c<e.length;c++){const u=e[c];switch(t[t.length-1]){case"ROOT":o(u,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{o(u,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(u,c);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=c}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=c,t.pop();break}default:{n=c,o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}default:{n=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=c;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const f=e.substring(r,c+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(u,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c)):n=c;break}}}let a=e.slice(0,n+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{a+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?a+="true".slice(d.length):"false".startsWith(d)?a+="false".slice(d.length):"null".startsWith(d)&&(a+="null".slice(d.length))}}return a}async function Uue(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await HN({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await HN({text:Yut(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function O1(e){return e.type.startsWith("tool-")}function Kut(e){return e.type==="dynamic-tool"}function bR(e){return O1(e)||Kut(e)}function $H(e){return e.type.split("-").slice(1).join("-")}function Zut({lastMessage:e,messageId:t}){return{message:(e==null?void 0:e.role)==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Xut({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:o,onToolCall:s,onData:i}){return e.pipeThrough(new TransformStream({async transform(a,c){await r(async({state:u,write:d})=>{var f,h,m,g;function b(C){const _=u.message.parts.filter(O1).find(k=>k.toolCallId===C);if(_==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return _}function x(C){const _=u.message.parts.filter(k=>k.type==="dynamic-tool").find(k=>k.toolCallId===C);if(_==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return _}function y(C){var N;const _=u.message.parts.find(I=>O1(I)&&I.toolCallId===C.toolCallId),k=C,j=_;_!=null?(_.state=C.state,j.input=k.input,j.output=k.output,j.errorText=k.errorText,j.rawInput=k.rawInput,j.preliminary=k.preliminary,j.providerExecuted=(N=k.providerExecuted)!=null?N:_.providerExecuted,k.providerMetadata!=null&&_.state==="input-available"&&(_.callProviderMetadata=k.providerMetadata)):u.message.parts.push({type:`tool-${C.toolName}`,toolCallId:C.toolCallId,state:C.state,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null?{callProviderMetadata:k.providerMetadata}:{}})}function w(C){var N,_;const k=u.message.parts.find(T=>T.type==="dynamic-tool"&&T.toolCallId===C.toolCallId),j=C,I=k;k!=null?(k.state=C.state,I.toolName=C.toolName,I.input=j.input,I.output=j.output,I.errorText=j.errorText,I.rawInput=(N=j.rawInput)!=null?N:I.rawInput,I.preliminary=j.preliminary,I.providerExecuted=(_=j.providerExecuted)!=null?_:k.providerExecuted,j.providerMetadata!=null&&k.state==="input-available"&&(k.callProviderMetadata=j.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:C.toolName,toolCallId:C.toolCallId,state:C.state,input:j.input,output:j.output,errorText:j.errorText,preliminary:j.preliminary,providerExecuted:j.providerExecuted,...j.providerMetadata!=null?{callProviderMetadata:j.providerMetadata}:{}})}async function v(C){if(C!=null){const N=u.message.metadata!=null?Hue(u.message.metadata,C):C;t!=null&&await RH({value:N,schema:t}),u.message.metadata=N}}switch(a.type){case"text-start":{const C={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeTextParts[a.id]=C,u.message.parts.push(C),d();break}case"text-delta":{const C=u.activeTextParts[a.id];C.text+=a.delta,C.providerMetadata=(f=a.providerMetadata)!=null?f:C.providerMetadata,d();break}case"text-end":{const C=u.activeTextParts[a.id];C.state="done",C.providerMetadata=(h=a.providerMetadata)!=null?h:C.providerMetadata,delete u.activeTextParts[a.id],d();break}case"reasoning-start":{const C={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeReasoningParts[a.id]=C,u.message.parts.push(C),d();break}case"reasoning-delta":{const C=u.activeReasoningParts[a.id];C.text+=a.delta,C.providerMetadata=(m=a.providerMetadata)!=null?m:C.providerMetadata,d();break}case"reasoning-end":{const C=u.activeReasoningParts[a.id];C.providerMetadata=(g=a.providerMetadata)!=null?g:C.providerMetadata,C.state="done",delete u.activeReasoningParts[a.id],d();break}case"file":{u.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url}),d();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),d();break}case"tool-input-start":{const C=u.message.parts.filter(O1);u.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:C.length,dynamic:a.dynamic},a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted}),d();break}case"tool-input-delta":{const C=u.partialToolCalls[a.toolCallId];C.text+=a.inputTextDelta;const{value:N}=await Uue(C.text);C.dynamic?w({toolCallId:a.toolCallId,toolName:C.toolName,state:"input-streaming",input:N}):y({toolCallId:a.toolCallId,toolName:C.toolName,state:"input-streaming",input:N}),d();break}case"tool-input-available":{a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d();break}case"tool-output-available":{if(a.dynamic){const C=x(a.toolCallId);w({toolCallId:a.toolCallId,toolName:C.toolName,state:"output-available",input:C.input,output:a.output,preliminary:a.preliminary})}else{const C=b(a.toolCallId);y({toolCallId:a.toolCallId,toolName:$H(C),state:"output-available",input:C.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary})}d();break}case"tool-output-error":{if(a.dynamic){const C=x(a.toolCallId);w({toolCallId:a.toolCallId,toolName:C.toolName,state:"output-error",input:C.input,errorText:a.errorText,providerExecuted:a.providerExecuted})}else{const C=b(a.toolCallId);y({toolCallId:a.toolCallId,toolName:$H(C),state:"output-error",input:C.input,rawInput:C.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted})}d();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{a.messageId!=null&&(u.message.id=a.messageId),await v(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&d();break}case"finish":{a.finishReason!=null&&(u.finishReason=a.finishReason),await v(a.messageMetadata),a.messageMetadata!=null&&d();break}case"message-metadata":{await v(a.messageMetadata),a.messageMetadata!=null&&d();break}case"error":{o==null||o(new Error(a.errorText));break}default:if(Gut(a)){(n==null?void 0:n[a.type])!=null&&await RH({value:a.data,schema:n[a.type]});const C=a;if(C.transient){i==null||i(C);break}const N=C.id!=null?u.message.parts.find(_=>C.type===_.type&&C.id===_.id):void 0;N!=null?N.data=C.data:u.message.parts.push(C),i==null||i(C),d()}}c.enqueue(a)})}}))}async function Qut({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){t==null||t(r)}finally{n.releaseLock()}}Zv({prefix:"aitxt",size:24});Zv({prefix:"aiobj",size:24});var Jut=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(r){n(r)}}),this.processQueue()})}};Zv({prefix:"aiobj",size:24});var edt={};Fut(edt,{object:()=>ndt,text:()=>tdt});var tdt=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),ndt=({schema:e})=>{const t=Rut(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const r=await Uue(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value};default:{const o=r.state;throw new Error(`Unsupported parse state: ${o}`)}}},async parseOutput({text:n},r){const o=await HN({text:n});if(!o.success)throw new OH({message:"No object generated: could not parse the response.",cause:o.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});const s=await w3({value:o.value,schema:t});if(!s.success)throw new OH({message:"No object generated: response did not match schema.",cause:s.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return s.value}}};async function rdt(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,o=await new Promise((s,i)=>{const a=new FileReader;a.onload=c=>{var u;s((u=c.target)==null?void 0:u.result)},a.onerror=c=>i(c),a.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:o}}))}var odt=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:o,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:i}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=o,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:e,...t}){var n,r,o,s,i;const a=await bm(this.body),c=await bm(this.headers),u=await bm(this.credentials),d={...Kd(c),...Kd(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:d,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=f==null?void 0:f.api)!=null?r:this.api,m=(f==null?void 0:f.headers)!==void 0?Kd(f.headers):d,g=(f==null?void 0:f.body)!==void 0?f.body:{...a,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},b=(o=f==null?void 0:f.credentials)!=null?o:u,y=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:MH({"Content-Type":"application/json",...m},`ai-sdk/${LH}`,DH()),body:JSON.stringify(g),credentials:b,signal:e});if(!y.ok)throw new Error((i=await y.text())!=null?i:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,r,o,s;const i=await bm(this.body),a=await bm(this.headers),c=await bm(this.credentials),u={...Kd(a),...Kd(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...i,...e.body},headers:u,credentials:c,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(d==null?void 0:d.headers)!==void 0?Kd(d.headers):u,m=(r=d==null?void 0:d.credentials)!=null?r:c,b=await((o=this.fetch)!=null?o:globalThis.fetch)(f,{method:"GET",headers:MH(h,`ai-sdk/${LH}`,DH()),credentials:m});if(b.status===204)return null;if(!b.ok)throw new Error((s=await b.text())!=null?s:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}},C3=class extends odt{constructor(e={}){super(e)}processResponseStream(e){return Vct({stream:e,schema:Wut}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},sdt=class{constructor({generateId:e=Mct,id:t=e(),transport:n=new C3,messageMetadataSchema:r,dataPartSchemas:o,state:s,onError:i,onToolCall:a,onFinish:c,onData:u,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new Jut,this.sendMessage=async(f,h)=>{var m,g,b,x;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...h});return}let y;if("text"in f||"files"in f?y={parts:[...Array.isArray(f.files)?f.files:await rdt(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:y=f,f.messageId!=null){const w=this.state.messages.findIndex(v=>v.id===f.messageId);if(w===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[w].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,w+1),this.state.replaceMessage(w,{...y,id:f.messageId,role:(g=y.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...y,id:(b=y.id)!=null?b:this.generateId(),role:(x=y.role)!=null?x:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...h})},this.regenerate=async({messageId:f,...h}={})=>{const m=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(m===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[m].role==="assistant"?m:m+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...h})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:f="output-available",tool:h,toolCallId:m,output:g,errorText:b})=>this.jobExecutor.run(async()=>{var x,y;const w=this.state.messages,v=w[w.length-1];this.state.replaceMessage(w.length-1,{...v,parts:v.parts.map(C=>bR(C)&&C.toolCallId===m?{...C,state:f,output:g,errorText:b}:C)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(C=>bR(C)&&C.toolCallId===m?{...C,state:f,output:g,errorText:b}:C)),this.status!=="streaming"&&this.status!=="submitted"&&((x=this.sendAutomaticallyWhen)!=null&&x.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=o,this.state=s,this.onError=i,this.onToolCall=a,this.onFinish=c,this.onData=u,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:o}){var s,i,a,c;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let d=!1,f=!1,h=!1;try{const m={state:Zut({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};m.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=m;let g;if(e==="resume-stream"){const x=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(x==null){this.setStatus({status:"ready"});return}g=x}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:m.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:o});const b=x=>this.jobExecutor.run(()=>x({state:m.state,write:()=>{var y;this.setStatus({status:"streaming"}),m.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,m.state.message):this.state.pushMessage(m.state.message)}}));await Qut({stream:Xut({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:b,onError:x=>{throw x}}),onError:x=>{throw x}}),this.setStatus({status:"ready"})}catch(m){if(d||m.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,m instanceof TypeError&&(m.message.toLowerCase().includes("fetch")||m.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&m instanceof Error&&this.onError(m),this.setStatus({status:"error",error:m})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:h,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(m){console.error(m)}this.activeResponse=void 0}(a=this.sendAutomaticallyWhen)!=null&&a.call(this,{messages:this.state.messages})&&!h&&await this.makeRequest({trigger:"submit-message",messageId:(c=this.lastMessage)==null?void 0:c.id,metadata:t,headers:n,body:r})}};function que({messages:e}){const t=e[e.length-1];if(!t||t.role!=="assistant")return!1;const n=t.parts.reduce((o,s,i)=>s.type==="step-start"?i:o,-1),r=t.parts.slice(n+1).filter(bR).filter(o=>!o.providerExecuted);return r.length>0&&r.every(o=>o.state==="output-available"||o.state==="output-error")}function idt(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...s){clearTimeout(n);const i=Date.now(),a=i-r,c=t-a;c<=0?(r=i,e.apply(this,s)):n=setTimeout(()=>{r=Date.now(),e.apply(this,s)},c)}}var adt=idt;const ldt=p.getDefaultExportFromCjs(adt);var Wue=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},vr=(e,t,n)=>(Wue(e,t,"read from private field"),n?n.call(e):t.get(e)),za=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Kc=(e,t,n,r)=>(Wue(e,t,"write to private field"),t.set(e,n),n);function cdt(e,t){return t!=null?ldt(e,t):e}var ki,L1,$1,Sx,Cx,Nx,Dm,xR,yR,udt=class{constructor(e=[]){za(this,ki,void 0),za(this,L1,"ready"),za(this,$1,void 0),za(this,Sx,new Set),za(this,Cx,new Set),za(this,Nx,new Set),this.pushMessage=t=>{Kc(this,ki,vr(this,ki).concat(t)),vr(this,Dm).call(this)},this.popMessage=()=>{Kc(this,ki,vr(this,ki).slice(0,-1)),vr(this,Dm).call(this)},this.replaceMessage=(t,n)=>{Kc(this,ki,[...vr(this,ki).slice(0,t),this.snapshot(n),...vr(this,ki).slice(t+1)]),vr(this,Dm).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?cdt(t,n):t;return vr(this,Sx).add(r),()=>{vr(this,Sx).delete(r)}},this["~registerStatusCallback"]=t=>(vr(this,Cx).add(t),()=>{vr(this,Cx).delete(t)}),this["~registerErrorCallback"]=t=>(vr(this,Nx).add(t),()=>{vr(this,Nx).delete(t)}),za(this,Dm,()=>{vr(this,Sx).forEach(t=>t())}),za(this,xR,()=>{vr(this,Cx).forEach(t=>t())}),za(this,yR,()=>{vr(this,Nx).forEach(t=>t())}),Kc(this,ki,e)}get status(){return vr(this,L1)}set status(e){Kc(this,L1,e),vr(this,xR).call(this)}get error(){return vr(this,$1)}set error(e){Kc(this,$1,e),vr(this,yR).call(this)}get messages(){return vr(this,ki)}set messages(e){Kc(this,ki,[...e]),vr(this,Dm).call(this)}};ki=new WeakMap;L1=new WeakMap;$1=new WeakMap;Sx=new WeakMap;Cx=new WeakMap;Nx=new WeakMap;Dm=new WeakMap;xR=new WeakMap;yR=new WeakMap;var Mm,zH=class extends sdt{constructor({messages:e,...t}){const n=new udt(e);super({...t,state:n}),za(this,Mm,void 0),this["~registerMessagesCallback"]=(r,o)=>vr(this,Mm)["~registerMessagesCallback"](r,o),this["~registerStatusCallback"]=r=>vr(this,Mm)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>vr(this,Mm)["~registerErrorCallback"](r),Kc(this,Mm,n)}};Mm=new WeakMap;function Gue({experimental_throttle:e,resume:t=!1,...n}={}){const r=S.useRef("chat"in n?n.chat:new zH(n));("chat"in n&&n.chat!==r.current||"id"in n&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new zH(n));const s="id"in n?n.id:null,i=S.useCallback(f=>r.current["~registerMessagesCallback"](f,e),[e,s]),a=S.useSyncExternalStore(i,()=>r.current.messages,()=>r.current.messages),c=S.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),u=S.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),d=S.useCallback(f=>{typeof f=="function"&&(f=f(r.current.messages)),r.current.messages=f},[r]);return S.useEffect(()=>{t&&r.current.resumeStream()},[t,r]),{id:r.current.id,messages:a,setMessages:d,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:u,resumeStream:r.current.resumeStream,status:c,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput}}function ddt(e,t){return e.some(n=>n.tableName&&n.tableName===t.tableName||n.datamodelName&&n.datamodelName===t.datamodelName)}function fdt(e){return e.filter((n,r,o)=>r===o.findIndex(s=>s.tableName===n.tableName&&s.datamodelName===n.datamodelName))}function hdt(e,t){return e.filter(n=>!(n.connectionId===t.connectionId&&n.tableName===t.tableName&&n.datamodelName===t.datamodelName))}function mdt(e){return e.toLowerCase()==="clickhouse"?"{database_name}.{table_name}":e.toLowerCase()==="postgres"?"{schema_name}.{table_name}":"{table_name}"}function Yue(e){return e.map(r=>{const o=r.connectionType==="API"||r.connectionType==="S3"||r.connectionType==="S3Tables"?"DuckDb":r.connectionType;return r.datamodelName?{...r,databaseName:"",schemaName:"",tableName:"",connectionType:o,tableReferenceFormat:"dm.{table_name}"}:{...r,connectionType:o,tableReferenceFormat:mdt(o)}}).filter(r=>r.datamodelName?r.connectionId&&r.datamodelName&&r.connectionType:r.connectionId&&r.tableName&&r.connectionType)}function Kue(e){var n,r;if(!e)return"";let t="";try{const o=JSON.parse((e==null?void 0:e.message)||"{}");t=((r=(n=o==null?void 0:o.error)==null?void 0:n.lastError)==null?void 0:r.message)||(o==null?void 0:o.error)||e.message}catch{t=e.message}return t}function Lj(e,t){var n;if((n=e.sheets)!=null&&n.length)return t&&e.sheets.find(r=>r.id===t)||e.sheets[0]}function Zue(e,t,n){const r=Lj(e,t);if(!r)return[];const o=s=>{var i;return{sourceCard:s,visibleCard:((i=n==null?void 0:n[s.id])==null?void 0:i.visibleCard)||s,...n!=null&&n[s.id]?{replacedCard:n[s.id]}:{}}};return(r.frames||[]).map(s=>rj(s)).filter(s=>s!==void 0).map(o)}function Xue(e){var t,n,r;return!!(((t=e.dataSource)==null?void 0:t.mode)!=="semanticDomain"&&((n=e.dataSource)!=null&&n.connectionId)&&(((r=e.dataSource)==null?void 0:r.selectedEntities)||[]).length===1)}function Que(e){var r;const t=((r=e.dataSource)==null?void 0:r.selectedEntities)||[],n=Xue(e);return t.map(o=>{var c,u;const s=Jue(o,{preferCardConnection:n,cardConnectionId:(c=e.dataSource)==null?void 0:c.connectionId,cardConnectionType:(u=e.dataSource)==null?void 0:u.connectionType}),i=(s==null?void 0:s.kind)==="physical"?s.connectionId:o.connectionId,a=(s==null?void 0:s.kind)==="physical"&&s.connectionType||o.connectionType;return{name:o.name,type:o.type,connectionId:i,...a?{connectionType:a}:{},...o.id?{id:o.id}:{},...o.domainId?{domainId:o.domainId}:{},...o.type==="dataset"&&o.name?{datasetName:o.name}:{},...o.type==="dataset"&&o.id?{datasetId:o.id}:{},...o.database?{database:o.database}:{},...o.schema?{schema:o.schema}:{},...o.label?{label:o.label}:{},...s?{sourceRef:s}:{}}})}function Jue(e,t={}){if(!(!e||typeof e!="object")){if(e.type==="dataset"&&e.domainId&&e.name)return{kind:"semantic",domainId:e.domainId,datasetName:e.name,...e.id?{datasetId:e.id}:{},...e.label?{label:e.label}:{},...e.connectionId?{connectionId:e.connectionId}:{}};if(["table","view","materialized view"].includes(e.type)&&(e.connectionId||t.cardConnectionId)&&e.name){const n=t.preferCardConnection&&t.cardConnectionId?t.cardConnectionId:e.connectionId,r=t.preferCardConnection&&t.cardConnectionType?t.cardConnectionType:e.connectionType;return{kind:"physical",connectionId:n,...r?{connectionType:r}:{},tableName:e.name,...e.database?{databaseName:e.database}:{},...e.schema?{schemaName:e.schema}:{},...e.label?{label:e.label}:{},...e.dialect?{dialect:e.dialect}:{}}}}}function ede(e){return typeof e!="string"?void 0:e.trim().toLowerCase()||void 0}const vR="__ambiguous_source__";function Oa(e,t,n){const r=ede(t);if(!r)return;const o=e.get(r);if(!o){e.set(r,n);return}o!==vR&&!$he.semaphorSourcesReferToSameDataset(o,n)&&e.set(r,vR)}function pdt(e,t,n){Oa(e,t==null?void 0:t.id,n),Oa(e,t==null?void 0:t.name,n),Oa(e,t==null?void 0:t.entityId,n),Oa(e,t==null?void 0:t.entityName,n),Oa(e,t==null?void 0:t.datasetId,n),Oa(e,t==null?void 0:t.datasetName,n),t!=null&&t.domainId&&(t!=null&&t.name)&&Oa(e,`${t.domainId}:${t.name}`,n),t!=null&&t.domainId&&(t!=null&&t.id)&&Oa(e,`${t.domainId}:${t.id}`,n),t!=null&&t.schema&&(t!=null&&t.name)&&Oa(e,`${t.schema}.${t.name}`,n),t!=null&&t.database&&(t!=null&&t.schema)&&(t!=null&&t.name)&&Oa(e,`${t.database}.${t.schema}.${t.name}`,n)}function gdt(e){const t=[e==null?void 0:e.qualifiedEntityName,e==null?void 0:e.datasetId,e==null?void 0:e.entityId];if(e!=null&&e.source&&typeof e.source=="object"&&t.push(e.source.datasetName,e.source.datasetId,e.source.tableName,e.source.qualifiedEntityName),typeof(e==null?void 0:e.qualifiedFieldName)=="string"){const n=e.qualifiedFieldName.split(".");n.length>1&&(t.push(n.slice(0,-1).join(".")),t.push(n[n.length-2]))}return t.push(e==null?void 0:e.datasetName,e==null?void 0:e.entityName),t.map(n=>ede(n)).filter(n=>!!n)}function tde(e){var i,a;const t=((i=e.dataSource)==null?void 0:i.selectedEntities)||[],n=Xue(e),r=t.map(c=>{var u,d;return{entity:c,source:Jue(c,{preferCardConnection:n,cardConnectionId:(u=e.dataSource)==null?void 0:u.connectionId,cardConnectionType:(d=e.dataSource)==null?void 0:d.connectionType})}}).filter(c=>!!c.source),o=new Map;r.forEach(({entity:c,source:u})=>{pdt(o,c,u)});const s=r.length===1?(a=r[0])==null?void 0:a.source:void 0;return c=>{const u=c!=null&&c.source&&typeof c.source=="object"?c.source:void 0;if(u)return u;if(!xdt(c)){for(const d of gdt(c)){const f=o.get(d);if(f&&f!==vR)return f}return s}}}function bdt(e){if((e==null?void 0:e.dataType)==="date"||(e==null?void 0:e.dataType)==="datetime")return"date";if((e==null?void 0:e.role)==="metric"||(e==null?void 0:e.role)==="measure")return"measure";if((e==null?void 0:e.role)==="groupby"||(e==null?void 0:e.role)==="pivotby"||(e==null?void 0:e.role)==="detail"||(e==null?void 0:e.role)==="dimension")return"dimension"}function xdt(e){return!!(e!=null&&e.fieldScope||e!=null&&e.calculatedFormula||e!=null&&e.calculatedField||e!=null&&e.isCalculated||lr.hasCalculatedFieldMarker(e))}function ydt(e,t){const n=t==null?void 0:t(e),r=bdt(e);return{id:(e==null?void 0:e.id)||"",name:(e==null?void 0:e.name)||"",label:(e==null?void 0:e.label)||(e==null?void 0:e.name)||"",...e!=null&&e.dataType?{dataType:e.dataType}:{},...e!=null&&e.aggregate?{aggregate:e.aggregate}:{},...e!=null&&e.granularity?{granularity:e.granularity}:{},...e!=null&&e.direction?{direction:e.direction}:{},...e!=null&&e.qualifiedFieldName?{qualifiedFieldName:e.qualifiedFieldName}:{},...e!=null&&e.qualifiedEntityName?{qualifiedEntityName:e.qualifiedEntityName}:{},...e!=null&&e.entityName?{entityName:e.entityName}:{},...e!=null&&e.entityId?{entityId:e.entityId}:{},...r?{role:r}:{},...n?{source:n}:{}}}function Hm(e,t){return(e||[]).map(n=>ydt(n,t))}function nde(e,t){return Hm([...(e==null?void 0:e.groupByColumns)||[],...(e==null?void 0:e.pivotByColumns)||[],...(e==null?void 0:e.detailColumns)||[]],t)}function N3(e){const t={operation:e.operation};return"value"in e&&e.value!==void 0&&(t.value=e.value),"values"in e&&Array.isArray(e.values)&&(t.values=e.values),t}function vdt(e,t,n){const r=new Map((e||[]).map(o=>[o.id,o]));return(t||[]).map(o=>{const s=r.get(o.filterId);return{filterId:o.filterId,label:(s==null?void 0:s.title)||o.label||o.name||o.filterId,...s!=null&&s.type?{type:s.type}:{},...s!=null&&s.column||o.name?{column:(s==null?void 0:s.column)||o.name}:{},...s!=null&&s.dataType?{dataType:s.dataType}:{},origin:n,...N3(o)}})}function wdt(e){return(e||[]).map(t=>({filterId:t.filterId,label:t.label||t.name||t.filterId,...t.name?{column:t.name}:{},origin:"inline",...N3(t)}))}function rde(e,t){var n,r,o,s,i,a,c;return{filterId:t,label:((n=e.field)==null?void 0:n.label)||((r=e.field)==null?void 0:r.name)||t,...(o=e.field)!=null&&o.qualifiedFieldName||(s=e.field)!=null&&s.name?{column:((i=e.field)==null?void 0:i.qualifiedFieldName)||((a=e.field)==null?void 0:a.name)}:{},...(c=e.field)!=null&&c.dataType?{dataType:e.field.dataType}:{},origin:"interaction",operation:e.operator,...e.value!==void 0?{value:e.value}:{}}}function _D(e,t){return(e||[]).flatMap((n,r)=>(n.filters||[]).map((o,s)=>rde(o,`${t}:${r}:${s}`)))}function Sdt(e){return!!e&&typeof e=="object"&&"field"in e&&"operator"in e}function Cdt(e){return!!e&&typeof e=="object"&&"filterId"in e&&"operation"in e}function Ndt(e){if(!e)return{dashboardFilterValues:[],interactionFilterValues:[]};const t=e.filter(Cdt).map(r=>({filterId:r.filterId,label:r.label||r.name||r.filterId,...r.name?{column:r.name}:{},origin:"dashboard",...N3(r)})),n=e.filter(Sdt).map((r,o)=>rde(r,`replaced-insight:${o}`));return{dashboardFilterValues:t,interactionFilterValues:n}}function _dt({card:e,interactionStates:t,currentDashboardId:n}){var c;if(!t)return[];const r=p.getClickFiltersForCardFromStates(e.id,t),o=t[p.DRILL_CONTEXT_CARD_ID],i=(o==null?void 0:o.targetDashboardId)===n&&(o==null?void 0:o.contextMode)!=="none"?(o==null?void 0:o.appliedClickFilters)||[]:[],a=((c=t[e.id])==null?void 0:c.breadcrumbs)??[];return[...r.flatMap((u,d)=>_D(u.filterGroups,`interaction:${u.sourceCardId||e.id}:${d}`)),...i.flatMap((u,d)=>_D(u.filterGroups,`global-interaction:${u.sourceCardId||e.id}:${d}`)),...a.flatMap((u,d)=>_D(u.sourceFilterGroups,`breadcrumb:${e.id}:${d}`))]}function ode(e){return e?{logicalOperator:e.logicalOperator,negate:e.negate,conditions:(e.conditions||[]).map(t=>{var n,r;return{field:((n=t.field)==null?void 0:n.label)||((r=t.field)==null?void 0:r.name)||"",operator:t.operator,value:t.value}}),groups:(e.groups||[]).map(t=>ode(t)).filter(Boolean)}:null}function sde(e){var n;const t=(n=e.python)==null?void 0:n.trim();return!!t&&t!==BR.trim()}function kdt(e){var t;return(t=e.sql)!=null&&t.trim()?"custom-sql":sde(e)?"custom-python":"config"}function ide({sourceCard:e,card:t,replacedCard:n,dashboard:r,viewState:o,runtimeFilterValues:s,interactionStates:i,inlineFilterValuesMap:a}){const c=Lj(r,o.selectedSheetId),u=(c==null?void 0:c.id)||o.selectedSheetId,{finalConfig:d}=G0({card:t,interactionStates:i,currentDashboardId:r.id,filters:r.filters,filterValues:s??o.activeFilters,selectedSheetId:u,inlineFilterValuesMap:a}),f=W0({card:e||t,interactionStates:i,currentDashboardId:r.id,filters:r.filters,filterValues:s??o.activeFilters,selectedSheetId:u}),h=Ndt(n==null?void 0:n.filters),m=!!n&&n.filters!==void 0;return{selectedSheetId:u,finalConfig:d,dashboardFilterValues:m?h.dashboardFilterValues:vdt(f.cardFilters,f.cardFilterValues,"dashboard"),inlineFilterValues:wdt(a==null?void 0:a[t.id]),interactionFilterValues:m?h.interactionFilterValues:_dt({card:t,interactionStates:i,currentDashboardId:r.id})}}function jdt({sourceCard:e,visibleCard:t,dashboard:n,viewState:r,interactionStates:o,inlineFilterValuesMap:s,replacedCard:i,renderOrder:a}){const{finalConfig:c}=ide({sourceCard:e,card:t,replacedCard:i,dashboard:n,viewState:r,interactionStates:o,inlineFilterValuesMap:s}),u=tde(t);return{cardId:e.id,...e.id!==t.id?{visibleCardId:t.id}:{},...i!=null&&i.insightId?{replacementInsightId:i.insightId}:{},title:t.title||"Untitled Card",type:t.type,renderOrder:a,metrics:Hm(c.metricColumns,u),dimensions:nde(c,u),selectedEntities:Que(t)}}function Tdt({activeFilters:e}){return Array.from(new Set((e||[]).map(t=>t.filterId)))}function BH({dashboard:e,selectedSheetId:t,activeFilters:n}){var o;const r=((o=Lj(e,t??null))==null?void 0:o.id)||t||null;return{selectedSheetId:r,activeFilters:py(e.filters,n,r)}}function Idt({dashboard:e,viewState:t,interactionStates:n,inlineFilterValuesMap:r,replacedCards:o}){const s=Lj(e,t.selectedSheetId),i=(s==null?void 0:s.id)||t.selectedSheetId,a=Zue(e,t.selectedSheetId,o),c=dd(e.filters,i);return{dashboardId:e.id,dashboardTitle:e.title||"Untitled Dashboard",selectedSheetId:i,sheetTitle:(s==null?void 0:s.title)||"Untitled Sheet",cards:a.map(({sourceCard:u,visibleCard:d,replacedCard:f},h)=>jdt({sourceCard:u,visibleCard:d,dashboard:e,viewState:t,interactionStates:n,inlineFilterValuesMap:r,replacedCard:f,renderOrder:h})),availableFilters:c.map(u=>{var d,f;return{filterId:u.id,label:u.title,...u.type?{type:u.type}:{},scope:(d=u.applyToCardIds)!=null&&d.length||(f=u.excludeCardIds)!=null&&f.length?"card":"sheet"}}),activeFilterIds:Tdt({activeFilters:t.activeFilters})}}function Edt({dashboard:e,viewState:t,cardId:n,runtimeFilterValues:r,interactionStates:o,inlineFilterValuesMap:s,replacedCards:i}){var C,N,_;const c=Zue(e,t.selectedSheetId,i).find(({sourceCard:k,visibleCard:j})=>k.id===n||j.id===n);if(!c)return{found:!1,cardId:n,selectedEntities:[],metrics:[],dimensions:[],comparison:null,cardFilters:null,effectiveDashboardFilters:[],activeInlineFilters:[],activeInteractionFilters:[],sortingOrGroupingSummary:{groupBy:[],pivotBy:[],sortBy:[]},notes:["Card not found in the current selected sheet."]};const{sourceCard:u,visibleCard:d,replacedCard:f}=c,{finalConfig:h,dashboardFilterValues:m,inlineFilterValues:g,interactionFilterValues:b}=ide({sourceCard:u,card:d,replacedCard:f,interactionStates:o,dashboard:e,viewState:t,runtimeFilterValues:r,inlineFilterValuesMap:s}),{comparisonType:x,targetValue:y}=JWe(h,d.type),w=kdt(d),v=tde(d);return{found:!0,cardId:u.id,...u.id!==d.id?{visibleCardId:d.id}:{},...f!=null&&f.insightId?{replacementInsightId:f.insightId}:{},title:d.title,type:d.type,queryMode:w,...(C=d.sql)!=null&&C.trim()?{sql:d.sql.trim()}:{},...sde(d)?{python:(N=d.python)==null?void 0:N.trim()}:{},...w==="config"&&((_=d.dataSource)!=null&&_.connectionId)?{queryInputs:{connectionId:d.dataSource.connectionId,...d.dataSource.connectionType?{connectionType:d.dataSource.connectionType}:{},chartType:d.type,cardConfig:h,cardDataSource:d.dataSource}}:{},selectedEntities:Que(d),metrics:Hm(h.metricColumns,v),dimensions:nde(h,v),comparison:x!=="none"?{type:x,...y!==void 0?{targetValue:y}:{}}:null,cardFilters:ode(h.filters),effectiveDashboardFilters:m,activeInlineFilters:g,activeInteractionFilters:b,sortingOrGroupingSummary:{groupBy:Hm(h.groupByColumns,v),pivotBy:Hm(h.pivotByColumns,v),sortBy:Hm(h.sortByColumns,v)},notes:[...f?["This frame is currently showing a linked insight replacement."]:[],...w==="custom-sql"?["This card runs custom SQL."]:w==="custom-python"?["This card runs custom Python."]:[]]}}function Am(){return crypto.randomUUID()}function ade(){return crypto.randomUUID()}function wR(e){return typeof(e==null?void 0:e.then)=="function"}async function Ddt({replacedCards:e,apiServiceUrl:t,accessToken:n,queryClient:r}){const o=Object.entries(e);if(o.length===0||!n)return{};const s=await Promise.all(o.map(async([i,a])=>{const c=["resource-by-id",Zr.VISUAL,a.insightId];let u=r.getQueryData(c);if(!u)try{u=await r.fetchQuery({queryKey:c,queryFn:()=>p.getRequest(`${t}/management/v1/visuals/${a.insightId}`,n)})}catch{return null}const d=Mie(u);return d?[i,{insightId:a.insightId,visibleCard:d,filters:a.filters,contextMode:a.contextMode}]:null}));return Object.fromEntries(s.filter(i=>i!==null))}function Mdt({dynamicVisualMode:e="auto"}={}){var M;const{compiledAppearance:t}=p.useAppearance(),n=S.useMemo(()=>bL(t),[t]),r=S.useRef(n);S.useEffect(()=>{r.current=n},[n]);const{authToken:o,tokenProps:s}=gt(),i=Xr(),a=p.useDashboardStore(L=>L.dashboard.aiScopeTables),c=(M=M0().data)==null?void 0:M.assistantProfileId,u=S.useRef(null),d=S.useRef(Am()),f=S.useRef(!1),h=S.useRef(!1),m=S.useRef(e);m.current=e;function g(){const L=p.useAIInteractionStore.getState(),$=p.useDashboardStore.getState(),z=Lie({overrides:L.dashboardEntitySelectionOverrides,dashboardId:$.dashboard.id,draftScopeKey:$.dashboardAssistantDraftScopeKey});return p.appendQualifiedEntityNameToAIContext(cKe({currentAIContext:L.currentAIContext,manualSelectedEntities:z.selectedEntities,hasManualOverride:z.hasManualOverride,dashboardAIContext:$.dashboard.aiContext,derivedSelectedSheetEntities:Oie($.dashboard,$.selectedSheetId)}))}function b(){const L=p.useDashboardStore.getState();return{aiContext:g(),dashboardViewState:BH({dashboard:L.dashboard,selectedSheetId:L.selectedSheetId,activeFilters:L.filterValues})}}const{sendMessage:x,messages:y,setMessages:w,regenerate:v,status:C,addToolResult:N,error:_,stop:k,clearError:j}=Gue({transport:new C3({api:`${s.apiServiceUrl}/v1/assistant`,headers:()=>({Authorization:`Bearer ${o==null?void 0:o.accessToken}`}),body:()=>{const L=p.useAIInteractionStore.getState();u.current||(u.current=b());const{aiContext:$,dashboardViewState:z}=u.current;return{assistantId:"dashboard-assistant",assistantProfileId:c,conversationId:d.current,assistantRequestId:ade(),aiContext:$,dashboardViewState:z,dynamicVisualMode:m.current,dynamicVisualTheme:r.current,reasoningEffort:L.reasoningEffort,showReasoning:L.showReasoning}},credentials:"omit",prepareSendMessagesRequest:({messages:L,body:$})=>({body:{...$,messages:p.cleanupIncompleteMessages(L)}})}),onToolCall:D,sendAutomaticallyWhen:que,onFinish({message:L,isAbort:$,isDisconnect:z,isError:W}){var F;h.current=!1,L!=null&&L.id&&((F=u.current)!=null&&F.aiContext)&&p.useAIInteractionStore.getState().actions.setAssistantMessageContext(L.id,u.current.aiContext),console.log($?"[Dashboard Assistant] Stream aborted by user":z?"[Dashboard Assistant] Stream disconnected (network error)":W?"[Dashboard Assistant] Stream error occurred":"[Dashboard Assistant] Stream completed successfully"),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]))},onError(L){var $;if(h.current=!1,L.name==="AbortError"||($=L.message)!=null&&$.includes("aborted")){console.log("[Dashboard Assistant] Stream aborted (expected)"),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]));return}console.error("[Dashboard Assistant] Stream error:",L),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]))}}),I=S.useCallback((...L)=>{h.current=!0;try{const $=x(...L);return wR($)?$.catch(z=>{throw h.current=!1,z}):$}catch($){throw h.current=!1,$}},[x]),T=S.useCallback((...L)=>{h.current=!0;try{const $=v(...L);return wR($)?$.catch(z=>{throw h.current=!1,z}):$}catch($){throw h.current=!1,$}},[v]),E=L=>{let $=!1;w(z=>{const W=typeof L=="function"?L(z):L;if(W.length===0){if(h.current)return f.current=!0,$=!0,z;f.current=!1,d.current=Am()}return W}),$&&k()};async function D({toolCall:L}){var R,K,O,U;const $=p.useDashboardStore.getState().dashboard,z=p.useDashboardStore.getState().inlineFilterValuesMap,W=p.useInteractionStore.getState(),F=W.interactionStates,X=await Ddt({replacedCards:W.replacedCards,apiServiceUrl:s.apiServiceUrl,accessToken:(o==null?void 0:o.accessToken)||"",queryClient:i}),Y=BH({dashboard:$,selectedSheetId:p.useDashboardStore.getState().selectedSheetId,activeFilters:p.useDashboardStore.getState().filterValues});if(L.toolName==="inspectDashboard"){const V=((R=L.input)==null?void 0:R.mode)||((K=L.args)==null?void 0:K.mode)||"dashboard_summary",H=((O=L.input)==null?void 0:O.cardId)||((U=L.args)==null?void 0:U.cardId)||"",q=Idt({dashboard:$,viewState:Y,interactionStates:F,inlineFilterValuesMap:z,replacedCards:X});N({tool:L.toolName,toolCallId:L.toolCallId,output:V==="card_context"&&H?{mode:V,dashboard:q,card:Edt({dashboard:$,viewState:Y,cardId:H,runtimeFilterValues:p.useDashboardStore.getState().filterValues,interactionStates:F,inlineFilterValuesMap:z,replacedCards:X})}:{mode:V,dashboard:q,scopeTables:Yue(a||[])}})}}const A=!["ready","error"].includes(C),P=Kue(_);return{sendMessage:I,regenerate:T,isLoading:A,messages:y,setMessages:E,status:C,stop:k,errorMessage:P,clearError:j}}const uc=S.forwardRef(({side:e="bottom",children:t,className:n,tooltip:r,onClick:o,openDelay:s=300,buttonProps:i,disabled:a,...c},u)=>l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:s,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{disabled:a,ref:u,size:"sm",variant:"ghost",onClick:o,...c,...i,className:p.cn(`${p.removeRing}`,n),children:t})}),r&&l.jsxs(p.TooltipContent,{side:e,sideOffset:10,className:p.cn("border-foreground/20 bg-foreground text-background"),children:[r,l.jsx(p.TooltipArrow,{className:"fill-foreground"})]})]})}));uc.displayName="IconButton";function lde(){var u;const{authToken:e,tokenProps:t}=gt(),n=(u=M0().data)==null?void 0:u.assistantProfileId;function r(){return!(!n||!(e!=null&&e.accessToken))}const{data:o,isLoading:s,isFetching:i,isError:a}=Rn({queryKey:["assistant-profile",n],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/assistant/${n}`,(e==null?void 0:e.accessToken)||""),enabled:r()});return{assistantProfile:o==null?void 0:o.assistantProfile,isLoading:s,isFetching:i,isError:a}}function cde({seedQuestions:e,handleSeedQuestionClick:t}){return e.length===0?null:l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 p-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(pW,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Example questions"})]}),l.jsx("div",{className:"flex flex-col gap-1",children:e.map((n,r)=>l.jsxs("button",{type:"button",onClick:()=>t(n),className:"flex items-center gap-1.5 rounded-[4px] border border-transparent px-1.5 py-1 text-left text-[12px] text-foreground/85 transition-colors hover:border-border/60 hover:bg-background",children:[l.jsx(Pt.ChevronRight,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate",children:n})]},r))})]})}const Yg=["image/png","image/jpeg","image/jpg","image/gif","image/webp"],Adt=["application/pdf","text/plain","text/markdown"],Rdt=["text/csv","application/json","text/xml","application/xml"],Pdt=["text/javascript","application/javascript","text/typescript","application/x-typescript","text/x-python","application/x-python-code","text/x-sql","application/sql"],Fdt=[...Yg,...Adt,...Rdt,...Pdt],ude=10*1024*1024,Ul=5,dde={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".xml":"text/xml",".js":"text/javascript",".jsx":"text/javascript",".ts":"text/typescript",".tsx":"text/typescript",".py":"text/x-python",".sql":"text/x-sql"};function Odt(e){if(Fdt.includes(e.type))return!0;const t=_3(e.name);return t?Object.prototype.hasOwnProperty.call(dde,t):!1}function _3(e){const t=e.lastIndexOf(".");return t===-1?"":e.substring(t).toLowerCase()}function fde(e){if(e.type)return e.type;const t=_3(e.name);return dde[t]||"application/octet-stream"}function Ldt(e){return e.size<=ude}function y0(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function VH(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const s=r.result.split(",")[1];t(s)},r.onerror=n,r.readAsDataURL(e)})}function $dt(e){return new Promise((t,n)=>{if(!Yg.includes(fde(e))){n(new Error("Not an image file"));return}const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function k3(e){const t=fde(e),n=Yg.includes(t),r={id:crypto.randomUUID(),name:e.name,size:e.size,type:t};if(n)try{r.preview=await $dt(e),r.data=r.preview.split(",")[1]}catch(o){console.error("Failed to create image preview:",o),r.data=await VH(e)}else r.data=await VH(e);return r}function hde(e){const t=[],n=[];for(const r of e)Odt(r)?Ldt(r)?t.push(r):n.push({file:r,error:`File too large: ${y0(r.size)} (max ${y0(ude)})`}):n.push({file:r,error:`File type not supported: ${r.type||_3(r.name)}`});return{valid:t,errors:n}}function zdt(e){var r;const t=(r=e.clipboardData)==null?void 0:r.items;if(!t)return[];const n=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.kind==="file"){const i=s.getAsFile();i&&Yg.includes(i.type)&&n.push(i)}}return n}function Bdt({onFilesSelected:e,disabled:t=!1,currentFileCount:n=0,className:r}){const o=S.useRef(null),s=async a=>{const c=Array.from(a.target.files||[]);if(c.length===0)return;const u=Ul-n;if(c.length>u){rt.error(`You can only attach ${Ul} files per message. You have ${u} slot(s) remaining.`);return}const{valid:d,errors:f}=hde(c);if(f.forEach(({file:h,error:m})=>{rt.error(`${h.name}: ${m}`)}),d.length>0)try{const h=await Promise.all(d.map(m=>k3(m)));e(h)}catch(h){console.error("Failed to process files:",h),rt.error("Failed to process one or more files")}o.current&&(o.current.value="")},i=()=>{var a;(a=o.current)==null||a.click()};return l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:o,type:"file",multiple:!0,accept:".png,.jpg,.jpeg,.gif,.webp,.pdf,.txt,.md,.csv,.json,.xml,.js,.jsx,.ts,.tsx,.py,.sql",onChange:s,className:"hidden",disabled:t||n>=Ul}),l.jsx(p.Button,{variant:"secondary",size:"sm",className:`h-7 px-2 ${r}`,onClick:i,disabled:t||n>=Ul,title:n>=Ul?`Maximum ${Ul} files allowed`:"Attach files",children:l.jsx(NW,{className:"h-4 w-4 text-muted-foreground"})})]})}function Vdt(e,t=[]){let n=[];function r(s,i){const a=Q.createContext(i);a.displayName=s+"Context";const c=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:m,...g}=f,b=((y=h==null?void 0:h[e])==null?void 0:y[c])||a,x=Q.useMemo(()=>g,Object.values(g));return l.jsx(b.Provider,{value:x,children:m})};u.displayName=s+"Provider";function d(f,h){var b;const m=((b=h==null?void 0:h[e])==null?void 0:b[c])||a,g=Q.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>Q.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return Q.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Hdt(o,...t)]}function Hdt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return Q.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Udt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mde=Udt.reduce((e,t)=>{const n=p.createSlot(`Primitive.${t}`),r=Q.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),j3="Progress",T3=100,[qdt]=Vdt(j3),[Wdt,Gdt]=qdt(j3),pde=Q.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:s=Ydt,...i}=e;(o||o===0)&&!HH(o)&&console.error(Kdt(`${o}`,"Progress"));const a=HH(o)?o:T3;r!==null&&!UH(r,a)&&console.error(Zdt(`${r}`,"Progress"));const c=UH(r,a)?r:null,u=UN(c)?s(c,a):void 0;return l.jsx(Wdt,{scope:n,value:c,max:a,children:l.jsx(mde.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":UN(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":xde(c,a),"data-value":c??void 0,"data-max":a,...i,ref:t})})});pde.displayName=j3;var gde="ProgressIndicator",bde=Q.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,o=Gdt(gde,n);return l.jsx(mde.div,{"data-state":xde(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:t})});bde.displayName=gde;function Ydt(e,t){return`${Math.round(e/t*100)}%`}function xde(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function UN(e){return typeof e=="number"}function HH(e){return UN(e)&&!isNaN(e)&&e>0}function UH(e,t){return UN(e)&&!isNaN(e)&&e<=t&&e>=0}function Kdt(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${T3}\`.`}function Zdt(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
1296
|
+
`)}})}});var Wut=$ct(()=>Pue(Ki([Ar({type:gn("text-start"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("text-delta"),id:Ot(),delta:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("text-end"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("error"),errorText:Ot()}),Ar({type:gn("tool-input-start"),toolCallId:Ot(),toolName:Ot(),providerExecuted:Rs().optional(),dynamic:Rs().optional()}),Ar({type:gn("tool-input-delta"),toolCallId:Ot(),inputTextDelta:Ot()}),Ar({type:gn("tool-input-available"),toolCallId:Ot(),toolName:Ot(),input:Wa(),providerExecuted:Rs().optional(),providerMetadata:Wr.optional(),dynamic:Rs().optional()}),Ar({type:gn("tool-input-error"),toolCallId:Ot(),toolName:Ot(),input:Wa(),providerExecuted:Rs().optional(),providerMetadata:Wr.optional(),dynamic:Rs().optional(),errorText:Ot()}),Ar({type:gn("tool-output-available"),toolCallId:Ot(),output:Wa(),providerExecuted:Rs().optional(),dynamic:Rs().optional(),preliminary:Rs().optional()}),Ar({type:gn("tool-output-error"),toolCallId:Ot(),errorText:Ot(),providerExecuted:Rs().optional(),dynamic:Rs().optional()}),Ar({type:gn("reasoning-start"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("reasoning-delta"),id:Ot(),delta:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("reasoning-end"),id:Ot(),providerMetadata:Wr.optional()}),Ar({type:gn("source-url"),sourceId:Ot(),url:Ot(),title:Ot().optional(),providerMetadata:Wr.optional()}),Ar({type:gn("source-document"),sourceId:Ot(),mediaType:Ot(),title:Ot(),filename:Ot().optional(),providerMetadata:Wr.optional()}),Ar({type:gn("file"),url:Ot(),mediaType:Ot(),providerMetadata:Wr.optional()}),Ar({type:Eue(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ot().optional(),data:Wa(),transient:Rs().optional()}),Ar({type:gn("start-step")}),Ar({type:gn("finish-step")}),Ar({type:gn("start"),messageId:Ot().optional(),messageMetadata:Wa().optional()}),Ar({type:gn("finish"),finishReason:jue(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:Wa().optional()}),Ar({type:gn("abort")}),Ar({type:gn("message-metadata"),messageMetadata:Wa()})])));function Gut(e){return e.type.startsWith("data-")}function Hue(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const o=t[r];if(o===void 0)continue;const s=r in e?e[r]:void 0,i=o!==null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);i&&a?n[r]=Hue(s,o):n[r]=o}return n}function Yut(e){const t=["ROOT"];let n=-1,r=null;function o(c,u,d){switch(c){case'"':{n=u,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,r=u,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}function s(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function i(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let c=0;c<e.length;c++){const u=e[c];switch(t[t.length-1]){case"ROOT":o(u,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{o(u,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(u,c);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=c}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=c,t.pop();break}default:{n=c,o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}default:{n=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=c;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const f=e.substring(r,c+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(u,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c)):n=c;break}}}let a=e.slice(0,n+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{a+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?a+="true".slice(d.length):"false".startsWith(d)?a+="false".slice(d.length):"null".startsWith(d)&&(a+="null".slice(d.length))}}return a}async function Uue(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await HN({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await HN({text:Yut(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function O1(e){return e.type.startsWith("tool-")}function Kut(e){return e.type==="dynamic-tool"}function bR(e){return O1(e)||Kut(e)}function $H(e){return e.type.split("-").slice(1).join("-")}function Zut({lastMessage:e,messageId:t}){return{message:(e==null?void 0:e.role)==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Xut({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:o,onToolCall:s,onData:i}){return e.pipeThrough(new TransformStream({async transform(a,c){await r(async({state:u,write:d})=>{var f,h,m,g;function b(C){const _=u.message.parts.filter(O1).find(k=>k.toolCallId===C);if(_==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return _}function x(C){const _=u.message.parts.filter(k=>k.type==="dynamic-tool").find(k=>k.toolCallId===C);if(_==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return _}function y(C){var N;const _=u.message.parts.find(I=>O1(I)&&I.toolCallId===C.toolCallId),k=C,j=_;_!=null?(_.state=C.state,j.input=k.input,j.output=k.output,j.errorText=k.errorText,j.rawInput=k.rawInput,j.preliminary=k.preliminary,j.providerExecuted=(N=k.providerExecuted)!=null?N:_.providerExecuted,k.providerMetadata!=null&&_.state==="input-available"&&(_.callProviderMetadata=k.providerMetadata)):u.message.parts.push({type:`tool-${C.toolName}`,toolCallId:C.toolCallId,state:C.state,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null?{callProviderMetadata:k.providerMetadata}:{}})}function w(C){var N,_;const k=u.message.parts.find(T=>T.type==="dynamic-tool"&&T.toolCallId===C.toolCallId),j=C,I=k;k!=null?(k.state=C.state,I.toolName=C.toolName,I.input=j.input,I.output=j.output,I.errorText=j.errorText,I.rawInput=(N=j.rawInput)!=null?N:I.rawInput,I.preliminary=j.preliminary,I.providerExecuted=(_=j.providerExecuted)!=null?_:k.providerExecuted,j.providerMetadata!=null&&k.state==="input-available"&&(k.callProviderMetadata=j.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:C.toolName,toolCallId:C.toolCallId,state:C.state,input:j.input,output:j.output,errorText:j.errorText,preliminary:j.preliminary,providerExecuted:j.providerExecuted,...j.providerMetadata!=null?{callProviderMetadata:j.providerMetadata}:{}})}async function v(C){if(C!=null){const N=u.message.metadata!=null?Hue(u.message.metadata,C):C;t!=null&&await RH({value:N,schema:t}),u.message.metadata=N}}switch(a.type){case"text-start":{const C={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeTextParts[a.id]=C,u.message.parts.push(C),d();break}case"text-delta":{const C=u.activeTextParts[a.id];C.text+=a.delta,C.providerMetadata=(f=a.providerMetadata)!=null?f:C.providerMetadata,d();break}case"text-end":{const C=u.activeTextParts[a.id];C.state="done",C.providerMetadata=(h=a.providerMetadata)!=null?h:C.providerMetadata,delete u.activeTextParts[a.id],d();break}case"reasoning-start":{const C={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeReasoningParts[a.id]=C,u.message.parts.push(C),d();break}case"reasoning-delta":{const C=u.activeReasoningParts[a.id];C.text+=a.delta,C.providerMetadata=(m=a.providerMetadata)!=null?m:C.providerMetadata,d();break}case"reasoning-end":{const C=u.activeReasoningParts[a.id];C.providerMetadata=(g=a.providerMetadata)!=null?g:C.providerMetadata,C.state="done",delete u.activeReasoningParts[a.id],d();break}case"file":{u.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url}),d();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),d();break}case"tool-input-start":{const C=u.message.parts.filter(O1);u.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:C.length,dynamic:a.dynamic},a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted}),d();break}case"tool-input-delta":{const C=u.partialToolCalls[a.toolCallId];C.text+=a.inputTextDelta;const{value:N}=await Uue(C.text);C.dynamic?w({toolCallId:a.toolCallId,toolName:C.toolName,state:"input-streaming",input:N}):y({toolCallId:a.toolCallId,toolName:C.toolName,state:"input-streaming",input:N}),d();break}case"tool-input-available":{a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{a.dynamic?w({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):y({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d();break}case"tool-output-available":{if(a.dynamic){const C=x(a.toolCallId);w({toolCallId:a.toolCallId,toolName:C.toolName,state:"output-available",input:C.input,output:a.output,preliminary:a.preliminary})}else{const C=b(a.toolCallId);y({toolCallId:a.toolCallId,toolName:$H(C),state:"output-available",input:C.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary})}d();break}case"tool-output-error":{if(a.dynamic){const C=x(a.toolCallId);w({toolCallId:a.toolCallId,toolName:C.toolName,state:"output-error",input:C.input,errorText:a.errorText,providerExecuted:a.providerExecuted})}else{const C=b(a.toolCallId);y({toolCallId:a.toolCallId,toolName:$H(C),state:"output-error",input:C.input,rawInput:C.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted})}d();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{a.messageId!=null&&(u.message.id=a.messageId),await v(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&d();break}case"finish":{a.finishReason!=null&&(u.finishReason=a.finishReason),await v(a.messageMetadata),a.messageMetadata!=null&&d();break}case"message-metadata":{await v(a.messageMetadata),a.messageMetadata!=null&&d();break}case"error":{o==null||o(new Error(a.errorText));break}default:if(Gut(a)){(n==null?void 0:n[a.type])!=null&&await RH({value:a.data,schema:n[a.type]});const C=a;if(C.transient){i==null||i(C);break}const N=C.id!=null?u.message.parts.find(_=>C.type===_.type&&C.id===_.id):void 0;N!=null?N.data=C.data:u.message.parts.push(C),i==null||i(C),d()}}c.enqueue(a)})}}))}async function Qut({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){t==null||t(r)}finally{n.releaseLock()}}Zv({prefix:"aitxt",size:24});Zv({prefix:"aiobj",size:24});var Jut=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(r){n(r)}}),this.processQueue()})}};Zv({prefix:"aiobj",size:24});var edt={};Fut(edt,{object:()=>ndt,text:()=>tdt});var tdt=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),ndt=({schema:e})=>{const t=Rut(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const r=await Uue(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value};default:{const o=r.state;throw new Error(`Unsupported parse state: ${o}`)}}},async parseOutput({text:n},r){const o=await HN({text:n});if(!o.success)throw new OH({message:"No object generated: could not parse the response.",cause:o.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});const s=await w3({value:o.value,schema:t});if(!s.success)throw new OH({message:"No object generated: response did not match schema.",cause:s.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return s.value}}};async function rdt(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,o=await new Promise((s,i)=>{const a=new FileReader;a.onload=c=>{var u;s((u=c.target)==null?void 0:u.result)},a.onerror=c=>i(c),a.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:o}}))}var odt=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:o,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:i}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=o,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:e,...t}){var n,r,o,s,i;const a=await bm(this.body),c=await bm(this.headers),u=await bm(this.credentials),d={...Kd(c),...Kd(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:d,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=f==null?void 0:f.api)!=null?r:this.api,m=(f==null?void 0:f.headers)!==void 0?Kd(f.headers):d,g=(f==null?void 0:f.body)!==void 0?f.body:{...a,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},b=(o=f==null?void 0:f.credentials)!=null?o:u,y=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:MH({"Content-Type":"application/json",...m},`ai-sdk/${LH}`,DH()),body:JSON.stringify(g),credentials:b,signal:e});if(!y.ok)throw new Error((i=await y.text())!=null?i:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,r,o,s;const i=await bm(this.body),a=await bm(this.headers),c=await bm(this.credentials),u={...Kd(a),...Kd(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...i,...e.body},headers:u,credentials:c,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(d==null?void 0:d.headers)!==void 0?Kd(d.headers):u,m=(r=d==null?void 0:d.credentials)!=null?r:c,b=await((o=this.fetch)!=null?o:globalThis.fetch)(f,{method:"GET",headers:MH(h,`ai-sdk/${LH}`,DH()),credentials:m});if(b.status===204)return null;if(!b.ok)throw new Error((s=await b.text())!=null?s:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}},C3=class extends odt{constructor(e={}){super(e)}processResponseStream(e){return Vct({stream:e,schema:Wut}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},sdt=class{constructor({generateId:e=Mct,id:t=e(),transport:n=new C3,messageMetadataSchema:r,dataPartSchemas:o,state:s,onError:i,onToolCall:a,onFinish:c,onData:u,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new Jut,this.sendMessage=async(f,h)=>{var m,g,b,x;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...h});return}let y;if("text"in f||"files"in f?y={parts:[...Array.isArray(f.files)?f.files:await rdt(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:y=f,f.messageId!=null){const w=this.state.messages.findIndex(v=>v.id===f.messageId);if(w===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[w].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,w+1),this.state.replaceMessage(w,{...y,id:f.messageId,role:(g=y.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...y,id:(b=y.id)!=null?b:this.generateId(),role:(x=y.role)!=null?x:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...h})},this.regenerate=async({messageId:f,...h}={})=>{const m=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(m===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[m].role==="assistant"?m:m+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...h})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:f="output-available",tool:h,toolCallId:m,output:g,errorText:b})=>this.jobExecutor.run(async()=>{var x,y;const w=this.state.messages,v=w[w.length-1];this.state.replaceMessage(w.length-1,{...v,parts:v.parts.map(C=>bR(C)&&C.toolCallId===m?{...C,state:f,output:g,errorText:b}:C)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(C=>bR(C)&&C.toolCallId===m?{...C,state:f,output:g,errorText:b}:C)),this.status!=="streaming"&&this.status!=="submitted"&&((x=this.sendAutomaticallyWhen)!=null&&x.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=o,this.state=s,this.onError=i,this.onToolCall=a,this.onFinish=c,this.onData=u,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:o}){var s,i,a,c;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let d=!1,f=!1,h=!1;try{const m={state:Zut({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};m.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=m;let g;if(e==="resume-stream"){const x=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(x==null){this.setStatus({status:"ready"});return}g=x}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:m.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:o});const b=x=>this.jobExecutor.run(()=>x({state:m.state,write:()=>{var y;this.setStatus({status:"streaming"}),m.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,m.state.message):this.state.pushMessage(m.state.message)}}));await Qut({stream:Xut({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:b,onError:x=>{throw x}}),onError:x=>{throw x}}),this.setStatus({status:"ready"})}catch(m){if(d||m.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,m instanceof TypeError&&(m.message.toLowerCase().includes("fetch")||m.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&m instanceof Error&&this.onError(m),this.setStatus({status:"error",error:m})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:h,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(m){console.error(m)}this.activeResponse=void 0}(a=this.sendAutomaticallyWhen)!=null&&a.call(this,{messages:this.state.messages})&&!h&&await this.makeRequest({trigger:"submit-message",messageId:(c=this.lastMessage)==null?void 0:c.id,metadata:t,headers:n,body:r})}};function que({messages:e}){const t=e[e.length-1];if(!t||t.role!=="assistant")return!1;const n=t.parts.reduce((o,s,i)=>s.type==="step-start"?i:o,-1),r=t.parts.slice(n+1).filter(bR).filter(o=>!o.providerExecuted);return r.length>0&&r.every(o=>o.state==="output-available"||o.state==="output-error")}function idt(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...s){clearTimeout(n);const i=Date.now(),a=i-r,c=t-a;c<=0?(r=i,e.apply(this,s)):n=setTimeout(()=>{r=Date.now(),e.apply(this,s)},c)}}var adt=idt;const ldt=p.getDefaultExportFromCjs(adt);var Wue=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},vr=(e,t,n)=>(Wue(e,t,"read from private field"),n?n.call(e):t.get(e)),za=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Kc=(e,t,n,r)=>(Wue(e,t,"write to private field"),t.set(e,n),n);function cdt(e,t){return t!=null?ldt(e,t):e}var ki,L1,$1,Sx,Cx,Nx,Dm,xR,yR,udt=class{constructor(e=[]){za(this,ki,void 0),za(this,L1,"ready"),za(this,$1,void 0),za(this,Sx,new Set),za(this,Cx,new Set),za(this,Nx,new Set),this.pushMessage=t=>{Kc(this,ki,vr(this,ki).concat(t)),vr(this,Dm).call(this)},this.popMessage=()=>{Kc(this,ki,vr(this,ki).slice(0,-1)),vr(this,Dm).call(this)},this.replaceMessage=(t,n)=>{Kc(this,ki,[...vr(this,ki).slice(0,t),this.snapshot(n),...vr(this,ki).slice(t+1)]),vr(this,Dm).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?cdt(t,n):t;return vr(this,Sx).add(r),()=>{vr(this,Sx).delete(r)}},this["~registerStatusCallback"]=t=>(vr(this,Cx).add(t),()=>{vr(this,Cx).delete(t)}),this["~registerErrorCallback"]=t=>(vr(this,Nx).add(t),()=>{vr(this,Nx).delete(t)}),za(this,Dm,()=>{vr(this,Sx).forEach(t=>t())}),za(this,xR,()=>{vr(this,Cx).forEach(t=>t())}),za(this,yR,()=>{vr(this,Nx).forEach(t=>t())}),Kc(this,ki,e)}get status(){return vr(this,L1)}set status(e){Kc(this,L1,e),vr(this,xR).call(this)}get error(){return vr(this,$1)}set error(e){Kc(this,$1,e),vr(this,yR).call(this)}get messages(){return vr(this,ki)}set messages(e){Kc(this,ki,[...e]),vr(this,Dm).call(this)}};ki=new WeakMap;L1=new WeakMap;$1=new WeakMap;Sx=new WeakMap;Cx=new WeakMap;Nx=new WeakMap;Dm=new WeakMap;xR=new WeakMap;yR=new WeakMap;var Mm,zH=class extends sdt{constructor({messages:e,...t}){const n=new udt(e);super({...t,state:n}),za(this,Mm,void 0),this["~registerMessagesCallback"]=(r,o)=>vr(this,Mm)["~registerMessagesCallback"](r,o),this["~registerStatusCallback"]=r=>vr(this,Mm)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>vr(this,Mm)["~registerErrorCallback"](r),Kc(this,Mm,n)}};Mm=new WeakMap;function Gue({experimental_throttle:e,resume:t=!1,...n}={}){const r=S.useRef("chat"in n?n.chat:new zH(n));("chat"in n&&n.chat!==r.current||"id"in n&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new zH(n));const s="id"in n?n.id:null,i=S.useCallback(f=>r.current["~registerMessagesCallback"](f,e),[e,s]),a=S.useSyncExternalStore(i,()=>r.current.messages,()=>r.current.messages),c=S.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),u=S.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),d=S.useCallback(f=>{typeof f=="function"&&(f=f(r.current.messages)),r.current.messages=f},[r]);return S.useEffect(()=>{t&&r.current.resumeStream()},[t,r]),{id:r.current.id,messages:a,setMessages:d,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:u,resumeStream:r.current.resumeStream,status:c,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput}}function ddt(e,t){return e.some(n=>n.tableName&&n.tableName===t.tableName||n.datamodelName&&n.datamodelName===t.datamodelName)}function fdt(e){return e.filter((n,r,o)=>r===o.findIndex(s=>s.tableName===n.tableName&&s.datamodelName===n.datamodelName))}function hdt(e,t){return e.filter(n=>!(n.connectionId===t.connectionId&&n.tableName===t.tableName&&n.datamodelName===t.datamodelName))}function mdt(e){return e.toLowerCase()==="clickhouse"?"{database_name}.{table_name}":e.toLowerCase()==="postgres"?"{schema_name}.{table_name}":"{table_name}"}function Yue(e){return e.map(r=>{const o=r.connectionType==="API"||r.connectionType==="S3"||r.connectionType==="S3Tables"?"DuckDb":r.connectionType;return r.datamodelName?{...r,databaseName:"",schemaName:"",tableName:"",connectionType:o,tableReferenceFormat:"dm.{table_name}"}:{...r,connectionType:o,tableReferenceFormat:mdt(o)}}).filter(r=>r.datamodelName?r.connectionId&&r.datamodelName&&r.connectionType:r.connectionId&&r.tableName&&r.connectionType)}function Kue(e){var n,r;if(!e)return"";let t="";try{const o=JSON.parse((e==null?void 0:e.message)||"{}");t=((r=(n=o==null?void 0:o.error)==null?void 0:n.lastError)==null?void 0:r.message)||(o==null?void 0:o.error)||e.message}catch{t=e.message}return t}function Lj(e,t){var n;if((n=e.sheets)!=null&&n.length)return t&&e.sheets.find(r=>r.id===t)||e.sheets[0]}function Zue(e,t,n){const r=Lj(e,t);if(!r)return[];const o=s=>{var i;return{sourceCard:s,visibleCard:((i=n==null?void 0:n[s.id])==null?void 0:i.visibleCard)||s,...n!=null&&n[s.id]?{replacedCard:n[s.id]}:{}}};return(r.frames||[]).map(s=>rj(s)).filter(s=>s!==void 0).map(o)}function Xue(e){var t,n,r;return!!(((t=e.dataSource)==null?void 0:t.mode)!=="semanticDomain"&&((n=e.dataSource)!=null&&n.connectionId)&&(((r=e.dataSource)==null?void 0:r.selectedEntities)||[]).length===1)}function Que(e){var r;const t=((r=e.dataSource)==null?void 0:r.selectedEntities)||[],n=Xue(e);return t.map(o=>{var c,u;const s=Jue(o,{preferCardConnection:n,cardConnectionId:(c=e.dataSource)==null?void 0:c.connectionId,cardConnectionType:(u=e.dataSource)==null?void 0:u.connectionType}),i=(s==null?void 0:s.kind)==="physical"?s.connectionId:o.connectionId,a=(s==null?void 0:s.kind)==="physical"&&s.connectionType||o.connectionType;return{name:o.name,type:o.type,connectionId:i,...a?{connectionType:a}:{},...o.id?{id:o.id}:{},...o.domainId?{domainId:o.domainId}:{},...o.type==="dataset"&&o.name?{datasetName:o.name}:{},...o.type==="dataset"&&o.id?{datasetId:o.id}:{},...o.database?{database:o.database}:{},...o.schema?{schema:o.schema}:{},...o.label?{label:o.label}:{},...s?{sourceRef:s}:{}}})}function Jue(e,t={}){if(!(!e||typeof e!="object")){if(e.type==="dataset"&&e.domainId&&e.name)return{kind:"semantic",domainId:e.domainId,datasetName:e.name,...e.id?{datasetId:e.id}:{},...e.label?{label:e.label}:{},...e.connectionId?{connectionId:e.connectionId}:{}};if(["table","view","materialized view"].includes(e.type)&&(e.connectionId||t.cardConnectionId)&&e.name){const n=t.preferCardConnection&&t.cardConnectionId?t.cardConnectionId:e.connectionId,r=t.preferCardConnection&&t.cardConnectionType?t.cardConnectionType:e.connectionType;return{kind:"physical",connectionId:n,...r?{connectionType:r}:{},tableName:e.name,...e.database?{databaseName:e.database}:{},...e.schema?{schemaName:e.schema}:{},...e.label?{label:e.label}:{},...e.dialect?{dialect:e.dialect}:{}}}}}function ede(e){return typeof e!="string"?void 0:e.trim().toLowerCase()||void 0}const vR="__ambiguous_source__";function Oa(e,t,n){const r=ede(t);if(!r)return;const o=e.get(r);if(!o){e.set(r,n);return}o!==vR&&!Ohe.semaphorSourcesReferToSameDataset(o,n)&&e.set(r,vR)}function pdt(e,t,n){Oa(e,t==null?void 0:t.id,n),Oa(e,t==null?void 0:t.name,n),Oa(e,t==null?void 0:t.entityId,n),Oa(e,t==null?void 0:t.entityName,n),Oa(e,t==null?void 0:t.datasetId,n),Oa(e,t==null?void 0:t.datasetName,n),t!=null&&t.domainId&&(t!=null&&t.name)&&Oa(e,`${t.domainId}:${t.name}`,n),t!=null&&t.domainId&&(t!=null&&t.id)&&Oa(e,`${t.domainId}:${t.id}`,n),t!=null&&t.schema&&(t!=null&&t.name)&&Oa(e,`${t.schema}.${t.name}`,n),t!=null&&t.database&&(t!=null&&t.schema)&&(t!=null&&t.name)&&Oa(e,`${t.database}.${t.schema}.${t.name}`,n)}function gdt(e){const t=[e==null?void 0:e.qualifiedEntityName,e==null?void 0:e.datasetId,e==null?void 0:e.entityId];if(e!=null&&e.source&&typeof e.source=="object"&&t.push(e.source.datasetName,e.source.datasetId,e.source.tableName,e.source.qualifiedEntityName),typeof(e==null?void 0:e.qualifiedFieldName)=="string"){const n=e.qualifiedFieldName.split(".");n.length>1&&(t.push(n.slice(0,-1).join(".")),t.push(n[n.length-2]))}return t.push(e==null?void 0:e.datasetName,e==null?void 0:e.entityName),t.map(n=>ede(n)).filter(n=>!!n)}function tde(e){var i,a;const t=((i=e.dataSource)==null?void 0:i.selectedEntities)||[],n=Xue(e),r=t.map(c=>{var u,d;return{entity:c,source:Jue(c,{preferCardConnection:n,cardConnectionId:(u=e.dataSource)==null?void 0:u.connectionId,cardConnectionType:(d=e.dataSource)==null?void 0:d.connectionType})}}).filter(c=>!!c.source),o=new Map;r.forEach(({entity:c,source:u})=>{pdt(o,c,u)});const s=r.length===1?(a=r[0])==null?void 0:a.source:void 0;return c=>{const u=c!=null&&c.source&&typeof c.source=="object"?c.source:void 0;if(u)return u;if(!xdt(c)){for(const d of gdt(c)){const f=o.get(d);if(f&&f!==vR)return f}return s}}}function bdt(e){if((e==null?void 0:e.dataType)==="date"||(e==null?void 0:e.dataType)==="datetime")return"date";if((e==null?void 0:e.role)==="metric"||(e==null?void 0:e.role)==="measure")return"measure";if((e==null?void 0:e.role)==="groupby"||(e==null?void 0:e.role)==="pivotby"||(e==null?void 0:e.role)==="detail"||(e==null?void 0:e.role)==="dimension")return"dimension"}function xdt(e){return!!(e!=null&&e.fieldScope||e!=null&&e.calculatedFormula||e!=null&&e.calculatedField||e!=null&&e.isCalculated||lr.hasCalculatedFieldMarker(e))}function ydt(e,t){const n=t==null?void 0:t(e),r=bdt(e);return{id:(e==null?void 0:e.id)||"",name:(e==null?void 0:e.name)||"",label:(e==null?void 0:e.label)||(e==null?void 0:e.name)||"",...e!=null&&e.dataType?{dataType:e.dataType}:{},...e!=null&&e.aggregate?{aggregate:e.aggregate}:{},...e!=null&&e.granularity?{granularity:e.granularity}:{},...e!=null&&e.direction?{direction:e.direction}:{},...e!=null&&e.qualifiedFieldName?{qualifiedFieldName:e.qualifiedFieldName}:{},...e!=null&&e.qualifiedEntityName?{qualifiedEntityName:e.qualifiedEntityName}:{},...e!=null&&e.entityName?{entityName:e.entityName}:{},...e!=null&&e.entityId?{entityId:e.entityId}:{},...r?{role:r}:{},...n?{source:n}:{}}}function Hm(e,t){return(e||[]).map(n=>ydt(n,t))}function nde(e,t){return Hm([...(e==null?void 0:e.groupByColumns)||[],...(e==null?void 0:e.pivotByColumns)||[],...(e==null?void 0:e.detailColumns)||[]],t)}function N3(e){const t={operation:e.operation};return"value"in e&&e.value!==void 0&&(t.value=e.value),"values"in e&&Array.isArray(e.values)&&(t.values=e.values),t}function vdt(e,t,n){const r=new Map((e||[]).map(o=>[o.id,o]));return(t||[]).map(o=>{const s=r.get(o.filterId);return{filterId:o.filterId,label:(s==null?void 0:s.title)||o.label||o.name||o.filterId,...s!=null&&s.type?{type:s.type}:{},...s!=null&&s.column||o.name?{column:(s==null?void 0:s.column)||o.name}:{},...s!=null&&s.dataType?{dataType:s.dataType}:{},origin:n,...N3(o)}})}function wdt(e){return(e||[]).map(t=>({filterId:t.filterId,label:t.label||t.name||t.filterId,...t.name?{column:t.name}:{},origin:"inline",...N3(t)}))}function rde(e,t){var n,r,o,s,i,a,c;return{filterId:t,label:((n=e.field)==null?void 0:n.label)||((r=e.field)==null?void 0:r.name)||t,...(o=e.field)!=null&&o.qualifiedFieldName||(s=e.field)!=null&&s.name?{column:((i=e.field)==null?void 0:i.qualifiedFieldName)||((a=e.field)==null?void 0:a.name)}:{},...(c=e.field)!=null&&c.dataType?{dataType:e.field.dataType}:{},origin:"interaction",operation:e.operator,...e.value!==void 0?{value:e.value}:{}}}function _D(e,t){return(e||[]).flatMap((n,r)=>(n.filters||[]).map((o,s)=>rde(o,`${t}:${r}:${s}`)))}function Sdt(e){return!!e&&typeof e=="object"&&"field"in e&&"operator"in e}function Cdt(e){return!!e&&typeof e=="object"&&"filterId"in e&&"operation"in e}function Ndt(e){if(!e)return{dashboardFilterValues:[],interactionFilterValues:[]};const t=e.filter(Cdt).map(r=>({filterId:r.filterId,label:r.label||r.name||r.filterId,...r.name?{column:r.name}:{},origin:"dashboard",...N3(r)})),n=e.filter(Sdt).map((r,o)=>rde(r,`replaced-insight:${o}`));return{dashboardFilterValues:t,interactionFilterValues:n}}function _dt({card:e,interactionStates:t,currentDashboardId:n}){var c;if(!t)return[];const r=p.getClickFiltersForCardFromStates(e.id,t),o=t[p.DRILL_CONTEXT_CARD_ID],i=(o==null?void 0:o.targetDashboardId)===n&&(o==null?void 0:o.contextMode)!=="none"?(o==null?void 0:o.appliedClickFilters)||[]:[],a=((c=t[e.id])==null?void 0:c.breadcrumbs)??[];return[...r.flatMap((u,d)=>_D(u.filterGroups,`interaction:${u.sourceCardId||e.id}:${d}`)),...i.flatMap((u,d)=>_D(u.filterGroups,`global-interaction:${u.sourceCardId||e.id}:${d}`)),...a.flatMap((u,d)=>_D(u.sourceFilterGroups,`breadcrumb:${e.id}:${d}`))]}function ode(e){return e?{logicalOperator:e.logicalOperator,negate:e.negate,conditions:(e.conditions||[]).map(t=>{var n,r;return{field:((n=t.field)==null?void 0:n.label)||((r=t.field)==null?void 0:r.name)||"",operator:t.operator,value:t.value}}),groups:(e.groups||[]).map(t=>ode(t)).filter(Boolean)}:null}function sde(e){var n;const t=(n=e.python)==null?void 0:n.trim();return!!t&&t!==BR.trim()}function kdt(e){var t;return(t=e.sql)!=null&&t.trim()?"custom-sql":sde(e)?"custom-python":"config"}function ide({sourceCard:e,card:t,replacedCard:n,dashboard:r,viewState:o,runtimeFilterValues:s,interactionStates:i,inlineFilterValuesMap:a}){const c=Lj(r,o.selectedSheetId),u=(c==null?void 0:c.id)||o.selectedSheetId,{finalConfig:d}=G0({card:t,interactionStates:i,currentDashboardId:r.id,filters:r.filters,filterValues:s??o.activeFilters,selectedSheetId:u,inlineFilterValuesMap:a}),f=W0({card:e||t,interactionStates:i,currentDashboardId:r.id,filters:r.filters,filterValues:s??o.activeFilters,selectedSheetId:u}),h=Ndt(n==null?void 0:n.filters),m=!!n&&n.filters!==void 0;return{selectedSheetId:u,finalConfig:d,dashboardFilterValues:m?h.dashboardFilterValues:vdt(f.cardFilters,f.cardFilterValues,"dashboard"),inlineFilterValues:wdt(a==null?void 0:a[t.id]),interactionFilterValues:m?h.interactionFilterValues:_dt({card:t,interactionStates:i,currentDashboardId:r.id})}}function jdt({sourceCard:e,visibleCard:t,dashboard:n,viewState:r,interactionStates:o,inlineFilterValuesMap:s,replacedCard:i,renderOrder:a}){const{finalConfig:c}=ide({sourceCard:e,card:t,replacedCard:i,dashboard:n,viewState:r,interactionStates:o,inlineFilterValuesMap:s}),u=tde(t);return{cardId:e.id,...e.id!==t.id?{visibleCardId:t.id}:{},...i!=null&&i.insightId?{replacementInsightId:i.insightId}:{},title:t.title||"Untitled Card",type:t.type,renderOrder:a,metrics:Hm(c.metricColumns,u),dimensions:nde(c,u),selectedEntities:Que(t)}}function Tdt({activeFilters:e}){return Array.from(new Set((e||[]).map(t=>t.filterId)))}function BH({dashboard:e,selectedSheetId:t,activeFilters:n}){var o;const r=((o=Lj(e,t??null))==null?void 0:o.id)||t||null;return{selectedSheetId:r,activeFilters:py(e.filters,n,r)}}function Idt({dashboard:e,viewState:t,interactionStates:n,inlineFilterValuesMap:r,replacedCards:o}){const s=Lj(e,t.selectedSheetId),i=(s==null?void 0:s.id)||t.selectedSheetId,a=Zue(e,t.selectedSheetId,o),c=dd(e.filters,i);return{dashboardId:e.id,dashboardTitle:e.title||"Untitled Dashboard",selectedSheetId:i,sheetTitle:(s==null?void 0:s.title)||"Untitled Sheet",cards:a.map(({sourceCard:u,visibleCard:d,replacedCard:f},h)=>jdt({sourceCard:u,visibleCard:d,dashboard:e,viewState:t,interactionStates:n,inlineFilterValuesMap:r,replacedCard:f,renderOrder:h})),availableFilters:c.map(u=>{var d,f;return{filterId:u.id,label:u.title,...u.type?{type:u.type}:{},scope:(d=u.applyToCardIds)!=null&&d.length||(f=u.excludeCardIds)!=null&&f.length?"card":"sheet"}}),activeFilterIds:Tdt({activeFilters:t.activeFilters})}}function Edt({dashboard:e,viewState:t,cardId:n,runtimeFilterValues:r,interactionStates:o,inlineFilterValuesMap:s,replacedCards:i}){var C,N,_;const c=Zue(e,t.selectedSheetId,i).find(({sourceCard:k,visibleCard:j})=>k.id===n||j.id===n);if(!c)return{found:!1,cardId:n,selectedEntities:[],metrics:[],dimensions:[],comparison:null,cardFilters:null,effectiveDashboardFilters:[],activeInlineFilters:[],activeInteractionFilters:[],sortingOrGroupingSummary:{groupBy:[],pivotBy:[],sortBy:[]},notes:["Card not found in the current selected sheet."]};const{sourceCard:u,visibleCard:d,replacedCard:f}=c,{finalConfig:h,dashboardFilterValues:m,inlineFilterValues:g,interactionFilterValues:b}=ide({sourceCard:u,card:d,replacedCard:f,interactionStates:o,dashboard:e,viewState:t,runtimeFilterValues:r,inlineFilterValuesMap:s}),{comparisonType:x,targetValue:y}=JWe(h,d.type),w=kdt(d),v=tde(d);return{found:!0,cardId:u.id,...u.id!==d.id?{visibleCardId:d.id}:{},...f!=null&&f.insightId?{replacementInsightId:f.insightId}:{},title:d.title,type:d.type,queryMode:w,...(C=d.sql)!=null&&C.trim()?{sql:d.sql.trim()}:{},...sde(d)?{python:(N=d.python)==null?void 0:N.trim()}:{},...w==="config"&&((_=d.dataSource)!=null&&_.connectionId)?{queryInputs:{connectionId:d.dataSource.connectionId,...d.dataSource.connectionType?{connectionType:d.dataSource.connectionType}:{},chartType:d.type,cardConfig:h,cardDataSource:d.dataSource}}:{},selectedEntities:Que(d),metrics:Hm(h.metricColumns,v),dimensions:nde(h,v),comparison:x!=="none"?{type:x,...y!==void 0?{targetValue:y}:{}}:null,cardFilters:ode(h.filters),effectiveDashboardFilters:m,activeInlineFilters:g,activeInteractionFilters:b,sortingOrGroupingSummary:{groupBy:Hm(h.groupByColumns,v),pivotBy:Hm(h.pivotByColumns,v),sortBy:Hm(h.sortByColumns,v)},notes:[...f?["This frame is currently showing a linked insight replacement."]:[],...w==="custom-sql"?["This card runs custom SQL."]:w==="custom-python"?["This card runs custom Python."]:[]]}}function Am(){return crypto.randomUUID()}function ade(){return crypto.randomUUID()}function wR(e){return typeof(e==null?void 0:e.then)=="function"}async function Ddt({replacedCards:e,apiServiceUrl:t,accessToken:n,queryClient:r}){const o=Object.entries(e);if(o.length===0||!n)return{};const s=await Promise.all(o.map(async([i,a])=>{const c=["resource-by-id",Zr.VISUAL,a.insightId];let u=r.getQueryData(c);if(!u)try{u=await r.fetchQuery({queryKey:c,queryFn:()=>p.getRequest(`${t}/management/v1/visuals/${a.insightId}`,n)})}catch{return null}const d=Mie(u);return d?[i,{insightId:a.insightId,visibleCard:d,filters:a.filters,contextMode:a.contextMode}]:null}));return Object.fromEntries(s.filter(i=>i!==null))}function Mdt({dynamicVisualMode:e="auto"}={}){var M;const{compiledAppearance:t}=p.useAppearance(),n=S.useMemo(()=>bL(t),[t]),r=S.useRef(n);S.useEffect(()=>{r.current=n},[n]);const{authToken:o,tokenProps:s}=gt(),i=Xr(),a=p.useDashboardStore(L=>L.dashboard.aiScopeTables),c=(M=M0().data)==null?void 0:M.assistantProfileId,u=S.useRef(null),d=S.useRef(Am()),f=S.useRef(!1),h=S.useRef(!1),m=S.useRef(e);m.current=e;function g(){const L=p.useAIInteractionStore.getState(),$=p.useDashboardStore.getState(),z=Lie({overrides:L.dashboardEntitySelectionOverrides,dashboardId:$.dashboard.id,draftScopeKey:$.dashboardAssistantDraftScopeKey});return p.appendQualifiedEntityNameToAIContext(cKe({currentAIContext:L.currentAIContext,manualSelectedEntities:z.selectedEntities,hasManualOverride:z.hasManualOverride,dashboardAIContext:$.dashboard.aiContext,derivedSelectedSheetEntities:Oie($.dashboard,$.selectedSheetId)}))}function b(){const L=p.useDashboardStore.getState();return{aiContext:g(),dashboardViewState:BH({dashboard:L.dashboard,selectedSheetId:L.selectedSheetId,activeFilters:L.filterValues})}}const{sendMessage:x,messages:y,setMessages:w,regenerate:v,status:C,addToolResult:N,error:_,stop:k,clearError:j}=Gue({transport:new C3({api:`${s.apiServiceUrl}/v1/assistant`,headers:()=>({Authorization:`Bearer ${o==null?void 0:o.accessToken}`}),body:()=>{const L=p.useAIInteractionStore.getState();u.current||(u.current=b());const{aiContext:$,dashboardViewState:z}=u.current;return{assistantId:"dashboard-assistant",assistantProfileId:c,conversationId:d.current,assistantRequestId:ade(),aiContext:$,dashboardViewState:z,dynamicVisualMode:m.current,dynamicVisualTheme:r.current,reasoningEffort:L.reasoningEffort,showReasoning:L.showReasoning}},credentials:"omit",prepareSendMessagesRequest:({messages:L,body:$})=>({body:{...$,messages:p.cleanupIncompleteMessages(L)}})}),onToolCall:D,sendAutomaticallyWhen:que,onFinish({message:L,isAbort:$,isDisconnect:z,isError:W}){var F;h.current=!1,L!=null&&L.id&&((F=u.current)!=null&&F.aiContext)&&p.useAIInteractionStore.getState().actions.setAssistantMessageContext(L.id,u.current.aiContext),console.log($?"[Dashboard Assistant] Stream aborted by user":z?"[Dashboard Assistant] Stream disconnected (network error)":W?"[Dashboard Assistant] Stream error occurred":"[Dashboard Assistant] Stream completed successfully"),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]))},onError(L){var $;if(h.current=!1,L.name==="AbortError"||($=L.message)!=null&&$.includes("aborted")){console.log("[Dashboard Assistant] Stream aborted (expected)"),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]));return}console.error("[Dashboard Assistant] Stream error:",L),u.current=null,f.current&&(f.current=!1,d.current=Am(),w([]))}}),I=S.useCallback((...L)=>{h.current=!0;try{const $=x(...L);return wR($)?$.catch(z=>{throw h.current=!1,z}):$}catch($){throw h.current=!1,$}},[x]),T=S.useCallback((...L)=>{h.current=!0;try{const $=v(...L);return wR($)?$.catch(z=>{throw h.current=!1,z}):$}catch($){throw h.current=!1,$}},[v]),E=L=>{let $=!1;w(z=>{const W=typeof L=="function"?L(z):L;if(W.length===0){if(h.current)return f.current=!0,$=!0,z;f.current=!1,d.current=Am()}return W}),$&&k()};async function D({toolCall:L}){var R,K,O,U;const $=p.useDashboardStore.getState().dashboard,z=p.useDashboardStore.getState().inlineFilterValuesMap,W=p.useInteractionStore.getState(),F=W.interactionStates,X=await Ddt({replacedCards:W.replacedCards,apiServiceUrl:s.apiServiceUrl,accessToken:(o==null?void 0:o.accessToken)||"",queryClient:i}),Y=BH({dashboard:$,selectedSheetId:p.useDashboardStore.getState().selectedSheetId,activeFilters:p.useDashboardStore.getState().filterValues});if(L.toolName==="inspectDashboard"){const V=((R=L.input)==null?void 0:R.mode)||((K=L.args)==null?void 0:K.mode)||"dashboard_summary",H=((O=L.input)==null?void 0:O.cardId)||((U=L.args)==null?void 0:U.cardId)||"",q=Idt({dashboard:$,viewState:Y,interactionStates:F,inlineFilterValuesMap:z,replacedCards:X});N({tool:L.toolName,toolCallId:L.toolCallId,output:V==="card_context"&&H?{mode:V,dashboard:q,card:Edt({dashboard:$,viewState:Y,cardId:H,runtimeFilterValues:p.useDashboardStore.getState().filterValues,interactionStates:F,inlineFilterValuesMap:z,replacedCards:X})}:{mode:V,dashboard:q,scopeTables:Yue(a||[])}})}}const A=!["ready","error"].includes(C),P=Kue(_);return{sendMessage:I,regenerate:T,isLoading:A,messages:y,setMessages:E,status:C,stop:k,errorMessage:P,clearError:j}}const uc=S.forwardRef(({side:e="bottom",children:t,className:n,tooltip:r,onClick:o,openDelay:s=300,buttonProps:i,disabled:a,...c},u)=>l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:s,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{disabled:a,ref:u,size:"sm",variant:"ghost",onClick:o,...c,...i,className:p.cn(`${p.removeRing}`,n),children:t})}),r&&l.jsxs(p.TooltipContent,{side:e,sideOffset:10,className:p.cn("border-foreground/20 bg-foreground text-background"),children:[r,l.jsx(p.TooltipArrow,{className:"fill-foreground"})]})]})}));uc.displayName="IconButton";function lde(){var u;const{authToken:e,tokenProps:t}=gt(),n=(u=M0().data)==null?void 0:u.assistantProfileId;function r(){return!(!n||!(e!=null&&e.accessToken))}const{data:o,isLoading:s,isFetching:i,isError:a}=Rn({queryKey:["assistant-profile",n],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/assistant/${n}`,(e==null?void 0:e.accessToken)||""),enabled:r()});return{assistantProfile:o==null?void 0:o.assistantProfile,isLoading:s,isFetching:i,isError:a}}function cde({seedQuestions:e,handleSeedQuestionClick:t}){return e.length===0?null:l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 p-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(pW,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Example questions"})]}),l.jsx("div",{className:"flex flex-col gap-1",children:e.map((n,r)=>l.jsxs("button",{type:"button",onClick:()=>t(n),className:"flex items-center gap-1.5 rounded-[4px] border border-transparent px-1.5 py-1 text-left text-[12px] text-foreground/85 transition-colors hover:border-border/60 hover:bg-background",children:[l.jsx(Pt.ChevronRight,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate",children:n})]},r))})]})}const Yg=["image/png","image/jpeg","image/jpg","image/gif","image/webp"],Adt=["application/pdf","text/plain","text/markdown"],Rdt=["text/csv","application/json","text/xml","application/xml"],Pdt=["text/javascript","application/javascript","text/typescript","application/x-typescript","text/x-python","application/x-python-code","text/x-sql","application/sql"],Fdt=[...Yg,...Adt,...Rdt,...Pdt],ude=10*1024*1024,Ul=5,dde={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".xml":"text/xml",".js":"text/javascript",".jsx":"text/javascript",".ts":"text/typescript",".tsx":"text/typescript",".py":"text/x-python",".sql":"text/x-sql"};function Odt(e){if(Fdt.includes(e.type))return!0;const t=_3(e.name);return t?Object.prototype.hasOwnProperty.call(dde,t):!1}function _3(e){const t=e.lastIndexOf(".");return t===-1?"":e.substring(t).toLowerCase()}function fde(e){if(e.type)return e.type;const t=_3(e.name);return dde[t]||"application/octet-stream"}function Ldt(e){return e.size<=ude}function y0(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function VH(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const s=r.result.split(",")[1];t(s)},r.onerror=n,r.readAsDataURL(e)})}function $dt(e){return new Promise((t,n)=>{if(!Yg.includes(fde(e))){n(new Error("Not an image file"));return}const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function k3(e){const t=fde(e),n=Yg.includes(t),r={id:crypto.randomUUID(),name:e.name,size:e.size,type:t};if(n)try{r.preview=await $dt(e),r.data=r.preview.split(",")[1]}catch(o){console.error("Failed to create image preview:",o),r.data=await VH(e)}else r.data=await VH(e);return r}function hde(e){const t=[],n=[];for(const r of e)Odt(r)?Ldt(r)?t.push(r):n.push({file:r,error:`File too large: ${y0(r.size)} (max ${y0(ude)})`}):n.push({file:r,error:`File type not supported: ${r.type||_3(r.name)}`});return{valid:t,errors:n}}function zdt(e){var r;const t=(r=e.clipboardData)==null?void 0:r.items;if(!t)return[];const n=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.kind==="file"){const i=s.getAsFile();i&&Yg.includes(i.type)&&n.push(i)}}return n}function Bdt({onFilesSelected:e,disabled:t=!1,currentFileCount:n=0,className:r}){const o=S.useRef(null),s=async a=>{const c=Array.from(a.target.files||[]);if(c.length===0)return;const u=Ul-n;if(c.length>u){rt.error(`You can only attach ${Ul} files per message. You have ${u} slot(s) remaining.`);return}const{valid:d,errors:f}=hde(c);if(f.forEach(({file:h,error:m})=>{rt.error(`${h.name}: ${m}`)}),d.length>0)try{const h=await Promise.all(d.map(m=>k3(m)));e(h)}catch(h){console.error("Failed to process files:",h),rt.error("Failed to process one or more files")}o.current&&(o.current.value="")},i=()=>{var a;(a=o.current)==null||a.click()};return l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:o,type:"file",multiple:!0,accept:".png,.jpg,.jpeg,.gif,.webp,.pdf,.txt,.md,.csv,.json,.xml,.js,.jsx,.ts,.tsx,.py,.sql",onChange:s,className:"hidden",disabled:t||n>=Ul}),l.jsx(p.Button,{variant:"secondary",size:"sm",className:`h-7 px-2 ${r}`,onClick:i,disabled:t||n>=Ul,title:n>=Ul?`Maximum ${Ul} files allowed`:"Attach files",children:l.jsx(NW,{className:"h-4 w-4 text-muted-foreground"})})]})}function Vdt(e,t=[]){let n=[];function r(s,i){const a=Q.createContext(i);a.displayName=s+"Context";const c=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:m,...g}=f,b=((y=h==null?void 0:h[e])==null?void 0:y[c])||a,x=Q.useMemo(()=>g,Object.values(g));return l.jsx(b.Provider,{value:x,children:m})};u.displayName=s+"Provider";function d(f,h){var b;const m=((b=h==null?void 0:h[e])==null?void 0:b[c])||a,g=Q.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>Q.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return Q.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Hdt(o,...t)]}function Hdt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return Q.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Udt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mde=Udt.reduce((e,t)=>{const n=p.createSlot(`Primitive.${t}`),r=Q.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),j3="Progress",T3=100,[qdt]=Vdt(j3),[Wdt,Gdt]=qdt(j3),pde=Q.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:s=Ydt,...i}=e;(o||o===0)&&!HH(o)&&console.error(Kdt(`${o}`,"Progress"));const a=HH(o)?o:T3;r!==null&&!UH(r,a)&&console.error(Zdt(`${r}`,"Progress"));const c=UH(r,a)?r:null,u=UN(c)?s(c,a):void 0;return l.jsx(Wdt,{scope:n,value:c,max:a,children:l.jsx(mde.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":UN(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":xde(c,a),"data-value":c??void 0,"data-max":a,...i,ref:t})})});pde.displayName=j3;var gde="ProgressIndicator",bde=Q.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,o=Gdt(gde,n);return l.jsx(mde.div,{"data-state":xde(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:t})});bde.displayName=gde;function Ydt(e,t){return`${Math.round(e/t*100)}%`}function xde(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function UN(e){return typeof e=="number"}function HH(e){return UN(e)&&!isNaN(e)&&e>0}function UH(e,t){return UN(e)&&!isNaN(e)&&e<=t&&e>=0}function Kdt(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${T3}\`.`}function Zdt(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
1297
1297
|
- a positive number
|
|
1298
1298
|
- less than the value passed to \`max\` (or ${T3} if no \`max\` prop is set)
|
|
1299
1299
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
1300
1300
|
|
|
1301
|
-
Defaulting to \`null\`.`}var yde=pde,Xdt=bde;const I3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(yde,{ref:r,className:p.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Xdt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));I3.displayName=yde.displayName;function Qdt({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const o=s=>Yg.includes(s)?Ipe:s.includes("pdf")||s.includes("text")?di:s.includes("javascript")||s.includes("typescript")||s.includes("python")||s.includes("sql")?bW:Dpe;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(s=>{const i=o(s.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:s.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:y0(s.size)}),s.uploadProgress!==void 0&&s.uploadProgress<100&&l.jsx(I3,{value:s.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(s.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${s.name}`,children:l.jsx(Te.X,{className:"h-3 w-3"})})]},s.id)})})}function Jdt({file:e,className:t=""}){return Yg.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",y0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:y0(e.size)})]})}function eft({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:o}){const[s,i]=S.useState(!1),a=S.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=S.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),m=f.clientX,g=f.clientY;(m<h.left||m>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=S.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=S.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const m=Ul-r;if(h.length>m){rt.error(`You can only attach ${Ul} files per message. You have ${m} slot(s) remaining.`);return}const{valid:g,errors:b}=hde(h);if(b.forEach(({file:x,error:y})=>{rt.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>k3(y)));t(x),rt.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),rt.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:p.cn("relative",o),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,s&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(p.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ul-r," slot(s) available"]})]})})]})}function tft(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function nft({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!tft(e,t,n):r}function vde(e){const{tokenProps:t}=gt(),n=p.useDashboardStore(c=>c.authToken)||e;p.useEditorStore(c=>c.selectedConnectionId),p.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:o,data:s,isLoading:i,isError:a}=Rn({queryKey:["semantic-domains"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:o,error:a,semanticDomainsData:s,semanticDomains:(s==null?void 0:s.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function rft({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:o}){const{semanticDomains:s,isSemanticDomainsLoading:i}=vde(),a=S.useMemo(()=>sft(s,e),[s,e]),c=S.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(wde,{label:"Semantic Domains"}),c.map(d=>l.jsx(oft,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:o},d.id))]})}function oft({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:o}){const[s,i]=S.useState(!1),a=s||t.length>0||!!n,{datasets:c,isPending:u}=P1e(a?e.id:void 0),d=S.useMemo(()=>{if(!t)return c;const v=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(v))},[c,t]),f=t.length>0&&d.length>0,h=s||f||!!n,m=c.length,g=S.useMemo(()=>d.filter(v=>r.some(C=>Jn(C,US(v)))).length,[d,r]),b=S.useMemo(()=>d.map(US),[d]),x=b.length>0&&b.every(v=>r.some(C=>Jn(C,v))),y=()=>{if(b.length===0)return;if(x){o(r.filter(C=>!b.some(N=>Jn(C,N))));return}const v=[...r];for(const C of b)v.some(N=>Jn(N,C))||v.push(C);o(v)},w=v=>{const C=US(v),N=r.some(_=>Jn(_,C));o(N?r.filter(_=>!Jn(_,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),m>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",m," dataset",m===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(v=>{const C=US(v),N=r.some(_=>Jn(_,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:N,onCheckedChange:()=>w(v),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(Bi,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:v.label||v.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:v.type==="virtual"?"virtual":"dataset"})]}),v.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:v.description})]})]})},v.id)})})]})}function wde({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function sft(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function US(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function ift({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:o,isConnectionsLoading:s}=Ac(),i=S.useMemo(()=>t?o.filter(c=>c.id===t):o,[o,t]);if(s&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(wde,{label:"Direct Sources"}),i.map(c=>l.jsx(aft,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function aft({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:o}){var g;const[s,i]=S.useState(!1),a=s||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",m=S.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:m>0?m:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(lft,{connection:e,selectedEntities:r,onSelectionChange:o}):h?l.jsx(cft,{connection:e,selectedEntities:r,onSelectionChange:o}):u?l.jsx(uft,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:o}):d?l.jsx(Sde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:o}):l.jsx(E3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:o}),!f&&!h&&l.jsx(dft,{connection:e,search:t,selectedEntities:r,onSelectionChange:o})]})]})}function lft({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,o=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),s=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(p.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>s(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(p.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),o.length>0&&l.jsx("ul",{className:"space-y-1",children:o.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(di,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},a.id))})]})}function cft({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,o]=S.useState(""),[s,i]=S.useState(""),[a,c]=S.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),m=s.trim();if(!h||!m)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:m,sourceType:a};n([...t,g]),o(""),i(""),c("api")},f=h=>{n(t.filter(m=>!("id"in m&&m.id===h&&m.connectionId===e.id&&m.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(p.Input,{value:r,onChange:h=>o(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(p.Input,{value:s,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(p.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!s.trim(),onClick:d,children:[l.jsx(kr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(_h,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},h.id))})]})}function uft({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:o}){var a;const s=$j("/v1/databases",{connection_id:e.id},["databases",e.id]);if(s.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=s.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(Cde,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(Sde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:o}):l.jsx(E3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:o}))},c.database_name))})}function Sde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:o}){var a;const s=$j("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(s.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=s.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(Cde,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(E3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:o})},c.schema_name))})}function E3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:o,onSelectionChange:s}){const i=$j("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=S.useMemo(()=>{var b;const m=((b=i.data)==null?void 0:b.tables)??[];if(!r)return m;const g=r.trim().toLowerCase();return m.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(m,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:m,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(m=>c(m.table_name,m.table_type)),d=u.length>0&&u.every(m=>o.some(g=>Jn(g,m))),f=(m,g)=>{const b=c(m,g),x=o.some(y=>Jn(y,b));s(x?o.filter(y=>!Jn(y,b)):[...o,b])},h=()=>{if(u.length===0)return;if(d){s(o.filter(g=>!u.some(b=>Jn(g,b))));return}const m=[...o];for(const g of u)m.some(b=>Jn(b,g))||m.push(g);s(m)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(m=>{const g=c(m.table_name,m.table_type),b=o.some(x=>Jn(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:b,onCheckedChange:()=>f(m.table_name,m.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(p.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:m.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:m.table_type??"table"})]})]})},m.table_name)})]})}function dft({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const o=$j("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),s=S.useMemo(()=>{var u;const a=((u=o.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[o.data,t]);if(o.isLoading||s.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Jn(d,c));r(u?n.filter(d=>!Jn(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:s.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Jn(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(Cpe,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function Cde({label:e,indentLevel:t,search:n,renderChildren:r}){const[o,s]=S.useState(!1),i=o||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:p.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function $j(e,t,n,r=!0){const{tokenProps:o}=gt(),s=p.useDashboardStore(a=>a.authToken),i=S.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return Rn({queryKey:n,queryFn:()=>p.getRequest(`${o.apiServiceUrl}${e}`,(s==null?void 0:s.accessToken)||"",i),enabled:r&&!!(s!=null&&s.accessToken)&&Object.values(i).every(a=>a.length>0)})}function qH(e){return e.type==="dataset"&&e.label||e.name}function fft({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:qH(n)}),l.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t(n)},"aria-label":`Remove ${qH(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function WH(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function kD(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function D3({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:o,onSaveSelectedEntities:s,saveAsDashboardDefault:i=!1}){var te,ye;const{tokenProps:a}=gt(),c=a.config,u=a.semanticDomainAccess||Lhe.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=S.useState([]),[h,m]=S.useState(void 0),[g,b]=S.useState(""),[x,y]=S.useState("all"),[w,v]=S.useState(void 0),C=S.useRef(!1),{updateDataSource:N}=p.useEditorActions(),_=p.useDashboardStore(se=>se.isVisualEditing),k=p.useDashboardStore(se=>se.dashboard.aiContext),{setAiContext:j}=p.useDashboardActions(),I=u.mode,T=(c==null?void 0:c.showDirectSource)!==!1,E=I==="include"||I==="exclude"||!T,D=I!=="all",A=T&&!E,P=E?"semanticDomain":n.mode,M=r==="dataSource"&&!T,L=I==="include"&&(((te=u.domainIds)==null?void 0:te.length)||0)===1?(ye=u.domainIds)==null?void 0:ye[0]:void 0,$=S.useCallback(se=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:se,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...se!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),z=S.useCallback(se=>{N({...n,...se})},[n,N]),W=S.useCallback(se=>{if(r==="aiContext"){"semanticDomainId"in se&&m(se.semanticDomainId);return}z(se)},[r,z]),F=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},S.useEffect(()=>{if(r==="aiContext"&&!e)return;if(E&&n.mode!=="semanticDomain"&&r==="dataSource"){$("semanticDomain");return}if(!D||P!=="semanticDomain")return;const se=F,Ie=u.domainIds??[],fe=r==="aiContext"?d:n.selectedEntities,me=((fe==null?void 0:fe.length)??0)>0,we=((d==null?void 0:d.length)??0)>0;nft({mode:I,currentDomainId:se,scopedDomainIds:Ie,hasSelectedEntities:me})&&(r==="dataSource"?z({semanticDomainId:void 0,selectedEntities:[]}):m(void 0),we&&f([]))},[E,D,P,n.mode,F,n.selectedEntities,r,h,d,e,u.domainIds,I,T,z,$]),S.useEffect(()=>{L&&!F&&W({semanticDomainId:L})},[L,F,W]),S.useEffect(()=>{if(!e){C.current=!1,b(""),v(void 0),y(E?"semantic":"all");return}if(C.current)return;f([...o||[]]);const se=r==="aiContext"?WH(o):void 0;m(n.semanticDomainId||se),v(kD(o))},[e,r,o,n.semanticDomainId,E]);const X=se=>{C.current=!0,f(d.filter(Ie=>!Jn(Ie,se)))},Y=S.useCallback((se,Ie)=>{C.current=!0,f(se),v(Ie??kD(se))},[]),R=()=>{var Ie,fe;if(r==="aiContext"){if(_&&N(n),i){const me={...k,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(me)}s==null||s(d),t(!1);return}const se=kD(d)??w??P;if(se==="semanticDomain"){const me=WH(d)||h||n.semanticDomainId,we=((Ie=d==null?void 0:d[0])==null?void 0:Ie.connectionId)||n.connectionId,ee=((fe=d==null?void 0:d[0])==null?void 0:fe.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:me,connectionId:we,connectionType:ee,selectedEntities:d})}else if(se==="upload"||se==="url"){const me=d==null?void 0:d[0];N({...n,mode:se,semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}else{const me=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=vde(),{connections:O}=Ac(),U=se=>{y(se),se==="semantic"||se.startsWith("domain:")?n.mode!=="semanticDomain"&&$("semanticDomain"):(se==="direct"||se.startsWith("conn:"))&&n.mode==="semanticDomain"&&$("database")},V=x.startsWith("domain:"),H=x.startsWith("conn:"),q=V?x.slice(7):void 0,B=H?x.slice(5):void 0,G=!A||x==="all"||x==="semantic"||V,Z=T&&!E&&(x==="all"||x==="direct"||H),J=((o==null?void 0:o.length)??0)>0,oe=d.length===0&&!J,ie=d.length===0&&J?"Clear":"Add",ue=r==="aiContext"?"Data context":M?"Select dataset":"Add data",xe=r==="aiContext"?"Set the overall data scope for the dashboard":M?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(p.VisuallyHidden,{children:l.jsx(cs,{children:ue})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:ue}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:xe})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx(Pt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:se=>b(se.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]}),A&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(Hb,{label:"All",active:x==="all",onClick:()=>U("all")}),(K.length>0||O.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(Hb,{label:"Semantic",active:x==="semantic",onClick:()=>U("semantic")}),l.jsx(Hb,{label:"Direct",active:x==="direct",onClick:()=>U("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(se=>l.jsx(Hb,{label:se.label||se.name,active:x===`domain:${se.id}`,onClick:()=>U(`domain:${se.id}`)},`domain:${se.id}`)),O.map(se=>l.jsx(Hb,{label:se.name,active:x===`conn:${se.id}`,onClick:()=>U(`conn:${se.id}`)},`conn:${se.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(rft,{domainAccess:u,search:g,scopeDomainId:q,selectedEntities:d,onSelectionChange:se=>Y(se,"semanticDomain")}),Z&&l.jsx(ift,{search:g,scopeConnectionId:B,selectedEntities:d,onSelectionChange:se=>Y(se)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:R,disabled:oe,className:p.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",oe&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:ie}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(fft,{selectedEntities:d,onDeselectEntity:X})]})]})})}function Hb({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:p.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const Zp={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function qN(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(iP,{className:r});case"view":return l.jsx(Pt.Eye,{className:r});case"materialized view":return l.jsx(Tpe,{className:r});case"model":return l.jsx(P0,{className:r});case"file":return l.jsx(di,{className:r});case"dataset":return l.jsx(Bi,{className:r});case"upload":return l.jsx(p.Upload,{className:r});case"url":return l.jsx(nP,{className:r});default:return l.jsx(_h,{className:r})}}const _x=e=>e.name||e.name,hft=e=>{const t=_x(e),n="description"in e?e.description:"",r=e.database||"",o=e.schema||"",s=[e.type,r,o].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),s.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:s.join(" · ")})]})};function mft({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:o}){const[s,i]=S.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(p.TooltipProvider,{children:l.jsx("div",{className:o,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const m="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:qN(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:_x(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${_x(f)}`,children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:hft(f)})]},m)}),d&&l.jsxs(p.Tooltip,{open:s,onOpenChange:i,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ui,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:qN(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:_x(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${_x(f)}`,children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const qS=e=>e.label||(e==null?void 0:e.name),GH=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function pft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:o,selectedEntities:s,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=gt(),f=(d==null?void 0:d.type)==="dashboard",[h,m]=S.useState(""),[g,b]=S.useState(""),x=o.filter(_=>{if(!h)return!0;const k=qS(_).toLowerCase(),j=(GH(_)||"").toLowerCase(),I=h.toLowerCase();return k.includes(I)||j.includes(I)});S.useEffect(()=>{e||(m(""),b(""))},[e]),S.useEffect(()=>{x.length>0&&!g&&b(qS(x[0]))},[x,g]);const y=()=>{if(!g)return;const _=x.find(k=>qS(k)===g);_&&(s.some(j=>"id"in _&&"id"in j?_.id===j.id:_.name===j.name&&_.connectionId===j.connectionId)||t(_),i(_),r())},w=_=>{(_.key==="Tab"||_.key==="Enter")&&(_.preventDefault(),y())};if(!e)return null;const v=_=>s.some(k=>"id"in _&&"id"in k?_.id===k.id:_.name===k.name&&_.connectionId===k.connectionId),C=s.length===o.length,N=s.length>0;return l.jsx(l.Fragment,{children:l.jsxs(hj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:w,children:[o.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx(Pt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Ts.Input,{placeholder:"Search entities",value:h,onValueChange:m,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),u==null||u()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(kr,{className:"h-2.5 w-2.5"}),"Add"]})]}),o.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[s.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),a==null||a()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),c==null||c()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(mj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(pj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),u==null||u()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(gj,{className:"p-0.5",children:x.map((_,k)=>{const j=v(_),I="id"in _?_.id:`${_.connectionId}-${_.name}`,T=qS(_);return l.jsxs(bj,{value:T,onSelect:()=>{j?n==null||n(_):t(_)},onMouseDown:E=>{E.preventDefault(),E.stopPropagation()},className:p.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(p.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:qN(_.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:T}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:GH(_)})]})]},I)})})]})]})})}function SR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:o=!1,open:s,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:m="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,w]=S.useState(!1),[v,C]=S.useState(!1),N=s??y,_=s!==void 0,k=S.useRef(!1),I=p.useEditorStore(q=>q.card.dataSource)??Zp,{selectedEntities:T,availableEntities:E,syncWithGlobalContext:D,setSelectedEntities:A,applyDashboardDefaultEntities:P,isEntitySelected:M}=oj(x),L=e==="full"||e==="display",$=e==="full"||e==="trigger",z=S.useMemo(()=>b&&T.length>0?`Add entity (${T.length})`:g,[T.length,b,g]);S.useEffect(()=>{N&&!k.current&&o&&D(),k.current=N},[N,o,D]);const W=S.useCallback(q=>{_||w(q),i==null||i(q)},[_,i]),F=S.useCallback(q=>{const B=T.filter(G=>!Jn(G,q));A(B),c==null||c(q),d==null||d(B)},[c,d,T,A]),X=S.useCallback(q=>{if(q.length===0)return;const B=T.filter(G=>!q.some(Z=>Jn(G,Z)));A(B),u==null||u(q),d==null||d(B)},[u,d,T,A]),Y=S.useCallback(q=>{const B=M(q)?T.filter(G=>!Jn(G,q)):[...T,q];A(B),d==null||d(B)},[M,d,T,A]),R=S.useCallback(()=>{A(E),d==null||d(E)},[E,d,A]),K=S.useCallback(()=>{A([]),d==null||d([])},[d,A]),O=S.useCallback(q=>{x==="dashboard"?P():A(q),d==null||d(q)},[P,x,d,A]),U=S.useCallback(q=>{const B=T.some(G=>Jn(G,q))?T:[...T,q];A(B),a==null||a(q),d==null||d(B),W(!1)},[a,d,T,W,A]),V=L?l.jsx(mft,{className:p.cn(n?"contents":"space-y-2"),entities:T,availableEntities:E,onRemoveEntity:F,onRemoveEntities:X}):null,H=$?l.jsxs(l.Fragment,{children:[l.jsxs(p.Popover,{open:N,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:m,size:"xs",className:p.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(Qq,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:z})]})}),l.jsx(p.PopoverContent,{className:p.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:q=>q.preventDefault(),children:l.jsx(pft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:E,selectedEntities:T,onTabComplete:U,onSelectAll:R,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(D3,{incomingSelectedEntities:T,open:v,onOpenChange:C,dataSource:I,dialogMode:"aiContext",onSaveSelectedEntities:O,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:p.cn(n?"flex flex-wrap items-center gap-1":"",!n&&L?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[H,V]}):l.jsxs(l.Fragment,{children:[V,H]})})}const M3=S.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:o,stop:s,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=S.useState(!1),h=S.useRef(null),{queueMessage:m}=p.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=p.useFileActions(),y=p.useFileAttachments(c);S.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const w=S.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const A=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${A}px`}},[e]);S.useEffect(()=>{w()},[w]),S.useEffect(()=>{const D=setTimeout(()=>{w()},0);return()=>clearTimeout(D)},[w]);const v=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(m(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),v()),D.key==="@"&&f(!0)},N=S.useCallback(D=>{const A=zdt(D.nativeEvent);A.length>0&&(D.preventDefault(),A.forEach(async P=>{const M=await k3(P);g(c,M)}))},[g,c]),_=S.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),k=S.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),j=S.useCallback(D=>{b(c,D)},[b,c]),I=S.useCallback(D=>{const A=`@${D}`;e.includes(A)&&t(e.replace(A,"").replace(/\s{2,}/g," ").trim())},[e,t]),T=!e.trim()&&y.length===0,E=a!=="ready"&&!o;return l.jsxs(eft,{onFilesDropped:_,currentFileCount:y.length,disabled:o,className:"space-y-2",children:[l.jsx(SR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const A="label"in D?D.label:D.name;I(A)},onEntitiesRemoved:D=>{let A=e;D.forEach(P=>{const M="label"in P?P.label:P.name;A=A.replace(`@${M}`,"")}),A!==e&&t(A.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Qdt,{files:y,onRemove:j,showRemove:!o}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{w(),i==null||i()},placeholder:E?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(SR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var P;const A="label"in D?D.label:D.name;t(`${e}@${A} `),(P=h.current)==null||P.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(Bdt,{onFilesSelected:k,disabled:o,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),o?l.jsx("button",{type:"button",onClick:s,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(sP,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:T,onClick:v,title:E?"Message will be queued":"Send",className:E?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(IW,{className:"h-3 w-3"})})]})]})]})});M3.displayName="ChatInputWithContext";function Nde({assistantType:e,className:t}){const n=p.useMessageQueue(e),{removeFromQueue:r}=p.useQueueActions();return n.length===0?null:l.jsxs("div",{className:p.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(tP,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(o=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:o.text}),l.jsx("button",{type:"button",onClick:()=>r(e,o.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},o.id))})]})}function _de({assistantType:e,status:t,isLoading:n,sendMessage:r}){const o=p.useMessageQueue(e),{dequeueMessage:s}=p.useQueueActions();S.useEffect(()=>{if(t!=="ready"||n||!(o&&o.length>0))return;const a=s(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,o,s,r,e])}const YH={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-inspectDataContext":{"input-streaming":"Inspecting data context...","input-available":"Reading grounded fields..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function gft(e,t){var r;if((r=YH[e])!=null&&r[t])return YH[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function kde(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const o=r,s=o.state;return{hasActiveTools:!0,activeToolText:gft(o.type,s),toolType:o.type}}}return{hasActiveTools:!1}}function bft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function xft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const yft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wft={};function KH(e,t){return(wft.jsx?vft:yft).test(e)}const Sft=/[ \t\n\f\r]/g;function Cft(e){return typeof e=="object"?e.type==="text"?ZH(e.value):!1:ZH(e)}function ZH(e){return e.replace(Sft,"")===""}class Xv{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Xv.prototype.normal={};Xv.prototype.property={};Xv.prototype.space=void 0;function jde(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Xv(n,r,t)}function CR(e){return e.toLowerCase()}class Ks{constructor(t,n){this.attribute=n,this.property=t}}Ks.prototype.attribute="";Ks.prototype.booleanish=!1;Ks.prototype.boolean=!1;Ks.prototype.commaOrSpaceSeparated=!1;Ks.prototype.commaSeparated=!1;Ks.prototype.defined=!1;Ks.prototype.mustUseProperty=!1;Ks.prototype.number=!1;Ks.prototype.overloadedBoolean=!1;Ks.prototype.property="";Ks.prototype.spaceSeparated=!1;Ks.prototype.space=void 0;let Nft=0;const un=Gh(),eo=Gh(),NR=Gh(),dt=Gh(),pr=Gh(),np=Gh(),ei=Gh();function Gh(){return 2**++Nft}const _R=Object.freeze(Object.defineProperty({__proto__:null,boolean:un,booleanish:eo,commaOrSpaceSeparated:ei,commaSeparated:np,number:dt,overloadedBoolean:NR,spaceSeparated:pr},Symbol.toStringTag,{value:"Module"})),jD=Object.keys(_R);class A3 extends Ks{constructor(t,n,r,o){let s=-1;if(super(t,n),XH(this,"space",o),typeof r=="number")for(;++s<jD.length;){const i=jD[s];XH(this,jD[s],(r&_R[i])===_R[i])}}}A3.prototype.defined=!0;function XH(e,t,n){n&&(e[t]=n)}function Kg(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const s=new A3(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[CR(r)]=r,n[CR(s.attribute)]=r}return new Xv(t,n,e.space)}const Tde=Kg({properties:{ariaActiveDescendant:null,ariaAtomic:eo,ariaAutoComplete:null,ariaBusy:eo,ariaChecked:eo,ariaColCount:dt,ariaColIndex:dt,ariaColSpan:dt,ariaControls:pr,ariaCurrent:null,ariaDescribedBy:pr,ariaDetails:null,ariaDisabled:eo,ariaDropEffect:pr,ariaErrorMessage:null,ariaExpanded:eo,ariaFlowTo:pr,ariaGrabbed:eo,ariaHasPopup:null,ariaHidden:eo,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:pr,ariaLevel:dt,ariaLive:null,ariaModal:eo,ariaMultiLine:eo,ariaMultiSelectable:eo,ariaOrientation:null,ariaOwns:pr,ariaPlaceholder:null,ariaPosInSet:dt,ariaPressed:eo,ariaReadOnly:eo,ariaRelevant:null,ariaRequired:eo,ariaRoleDescription:pr,ariaRowCount:dt,ariaRowIndex:dt,ariaRowSpan:dt,ariaSelected:eo,ariaSetSize:dt,ariaSort:null,ariaValueMax:dt,ariaValueMin:dt,ariaValueNow:dt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ide(e,t){return t in e?e[t]:t}function Ede(e,t){return Ide(e,t.toLowerCase())}const _ft=Kg({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:np,acceptCharset:pr,accessKey:pr,action:null,allow:null,allowFullScreen:un,allowPaymentRequest:un,allowUserMedia:un,alt:null,as:null,async:un,autoCapitalize:null,autoComplete:pr,autoFocus:un,autoPlay:un,blocking:pr,capture:null,charSet:null,checked:un,cite:null,className:pr,cols:dt,colSpan:null,content:null,contentEditable:eo,controls:un,controlsList:pr,coords:dt|np,crossOrigin:null,data:null,dateTime:null,decoding:null,default:un,defer:un,dir:null,dirName:null,disabled:un,download:NR,draggable:eo,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:un,formTarget:null,headers:pr,height:dt,hidden:NR,high:dt,href:null,hrefLang:null,htmlFor:pr,httpEquiv:pr,id:null,imageSizes:null,imageSrcSet:null,inert:un,inputMode:null,integrity:null,is:null,isMap:un,itemId:null,itemProp:pr,itemRef:pr,itemScope:un,itemType:pr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:un,low:dt,manifest:null,max:null,maxLength:dt,media:null,method:null,min:null,minLength:dt,multiple:un,muted:un,name:null,nonce:null,noModule:un,noValidate:un,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:un,optimum:dt,pattern:null,ping:pr,placeholder:null,playsInline:un,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:un,referrerPolicy:null,rel:pr,required:un,reversed:un,rows:dt,rowSpan:dt,sandbox:pr,scope:null,scoped:un,seamless:un,selected:un,shadowRootClonable:un,shadowRootDelegatesFocus:un,shadowRootMode:null,shape:null,size:dt,sizes:null,slot:null,span:dt,spellCheck:eo,src:null,srcDoc:null,srcLang:null,srcSet:null,start:dt,step:null,style:null,tabIndex:dt,target:null,title:null,translate:null,type:null,typeMustMatch:un,useMap:null,value:eo,width:dt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:pr,axis:null,background:null,bgColor:null,border:dt,borderColor:null,bottomMargin:dt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:un,declare:un,event:null,face:null,frame:null,frameBorder:null,hSpace:dt,leftMargin:dt,link:null,longDesc:null,lowSrc:null,marginHeight:dt,marginWidth:dt,noResize:un,noHref:un,noShade:un,noWrap:un,object:null,profile:null,prompt:null,rev:null,rightMargin:dt,rules:null,scheme:null,scrolling:eo,standby:null,summary:null,text:null,topMargin:dt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:dt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:un,disableRemotePlayback:un,prefix:null,property:null,results:dt,security:null,unselectable:null},space:"html",transform:Ede}),kft=Kg({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ei,accentHeight:dt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:dt,amplitude:dt,arabicForm:null,ascent:dt,attributeName:null,attributeType:null,azimuth:dt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:dt,by:null,calcMode:null,capHeight:dt,className:pr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:dt,diffuseConstant:dt,direction:null,display:null,dur:null,divisor:dt,dominantBaseline:null,download:un,dx:null,dy:null,edgeMode:null,editable:null,elevation:dt,enableBackground:null,end:null,event:null,exponent:dt,externalResourcesRequired:null,fill:null,fillOpacity:dt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:np,g2:np,glyphName:np,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:dt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:dt,horizOriginX:dt,horizOriginY:dt,id:null,ideographic:dt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:dt,k:dt,k1:dt,k2:dt,k3:dt,k4:dt,kernelMatrix:ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:dt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:dt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:dt,overlineThickness:dt,paintOrder:null,panose1:null,path:null,pathLength:dt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:pr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:dt,pointsAtY:dt,pointsAtZ:dt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ei,rev:ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ei,requiredFeatures:ei,requiredFonts:ei,requiredFormats:ei,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:dt,specularExponent:dt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:dt,strikethroughThickness:dt,string:null,stroke:null,strokeDashArray:ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:dt,strokeOpacity:dt,strokeWidth:null,style:null,surfaceScale:dt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ei,tabIndex:dt,tableValues:null,target:null,targetX:dt,targetY:dt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:dt,underlineThickness:dt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:dt,values:null,vAlphabetic:dt,vMathematical:dt,vectorEffect:null,vHanging:dt,vIdeographic:dt,version:null,vertAdvY:dt,vertOriginX:dt,vertOriginY:dt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:dt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ide}),Dde=Kg({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Mde=Kg({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ede}),Ade=Kg({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),jft={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Tft=/[A-Z]/g,QH=/-[a-z]/g,Ift=/^data[-\w.:]+$/i;function Eft(e,t){const n=CR(t);let r=t,o=Ks;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ift.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(QH,Mft);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!QH.test(s)){let i=s.replace(Tft,Dft);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=A3}return new o(r,t)}function Dft(e){return"-"+e.toLowerCase()}function Mft(e){return e.charAt(1).toUpperCase()}const Aft=jde([Tde,_ft,Dde,Mde,Ade],"html"),R3=jde([Tde,kft,Dde,Mde,Ade],"svg");function Rft(e){return e.join(" ").trim()}var P3={},JH=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Pft=/\n/g,Fft=/^\s*/,Oft=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Lft=/^:\s*/,$ft=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,zft=/^[;\s]*/,Bft=/^\s+|\s+$/g,Vft=`
|
|
1301
|
+
Defaulting to \`null\`.`}var yde=pde,Xdt=bde;const I3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(yde,{ref:r,className:p.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Xdt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));I3.displayName=yde.displayName;function Qdt({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const o=s=>Yg.includes(s)?Ipe:s.includes("pdf")||s.includes("text")?di:s.includes("javascript")||s.includes("typescript")||s.includes("python")||s.includes("sql")?bW:Dpe;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(s=>{const i=o(s.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:s.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:y0(s.size)}),s.uploadProgress!==void 0&&s.uploadProgress<100&&l.jsx(I3,{value:s.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(s.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${s.name}`,children:l.jsx(Te.X,{className:"h-3 w-3"})})]},s.id)})})}function Jdt({file:e,className:t=""}){return Yg.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",y0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:y0(e.size)})]})}function eft({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:o}){const[s,i]=S.useState(!1),a=S.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=S.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),m=f.clientX,g=f.clientY;(m<h.left||m>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=S.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=S.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const m=Ul-r;if(h.length>m){rt.error(`You can only attach ${Ul} files per message. You have ${m} slot(s) remaining.`);return}const{valid:g,errors:b}=hde(h);if(b.forEach(({file:x,error:y})=>{rt.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>k3(y)));t(x),rt.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),rt.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:p.cn("relative",o),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,s&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(p.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ul-r," slot(s) available"]})]})})]})}function tft(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function nft({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!tft(e,t,n):r}function vde(e){const{tokenProps:t}=gt(),n=p.useDashboardStore(c=>c.authToken)||e;p.useEditorStore(c=>c.selectedConnectionId),p.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:o,data:s,isLoading:i,isError:a}=Rn({queryKey:["semantic-domains"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:o,error:a,semanticDomainsData:s,semanticDomains:(s==null?void 0:s.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function rft({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:o}){const{semanticDomains:s,isSemanticDomainsLoading:i}=vde(),a=S.useMemo(()=>sft(s,e),[s,e]),c=S.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(wde,{label:"Semantic Domains"}),c.map(d=>l.jsx(oft,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:o},d.id))]})}function oft({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:o}){const[s,i]=S.useState(!1),a=s||t.length>0||!!n,{datasets:c,isPending:u}=P1e(a?e.id:void 0),d=S.useMemo(()=>{if(!t)return c;const v=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(v))},[c,t]),f=t.length>0&&d.length>0,h=s||f||!!n,m=c.length,g=S.useMemo(()=>d.filter(v=>r.some(C=>Jn(C,US(v)))).length,[d,r]),b=S.useMemo(()=>d.map(US),[d]),x=b.length>0&&b.every(v=>r.some(C=>Jn(C,v))),y=()=>{if(b.length===0)return;if(x){o(r.filter(C=>!b.some(N=>Jn(C,N))));return}const v=[...r];for(const C of b)v.some(N=>Jn(N,C))||v.push(C);o(v)},w=v=>{const C=US(v),N=r.some(_=>Jn(_,C));o(N?r.filter(_=>!Jn(_,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),m>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",m," dataset",m===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(v=>{const C=US(v),N=r.some(_=>Jn(_,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:N,onCheckedChange:()=>w(v),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(Bi,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:v.label||v.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:v.type==="virtual"?"virtual":"dataset"})]}),v.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:v.description})]})]})},v.id)})})]})}function wde({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function sft(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function US(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function ift({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:o,isConnectionsLoading:s}=Ac(),i=S.useMemo(()=>t?o.filter(c=>c.id===t):o,[o,t]);if(s&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(wde,{label:"Direct Sources"}),i.map(c=>l.jsx(aft,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function aft({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:o}){var g;const[s,i]=S.useState(!1),a=s||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",m=S.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:m>0?m:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(lft,{connection:e,selectedEntities:r,onSelectionChange:o}):h?l.jsx(cft,{connection:e,selectedEntities:r,onSelectionChange:o}):u?l.jsx(uft,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:o}):d?l.jsx(Sde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:o}):l.jsx(E3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:o}),!f&&!h&&l.jsx(dft,{connection:e,search:t,selectedEntities:r,onSelectionChange:o})]})]})}function lft({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,o=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),s=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(p.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>s(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(p.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),o.length>0&&l.jsx("ul",{className:"space-y-1",children:o.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(di,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},a.id))})]})}function cft({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,o]=S.useState(""),[s,i]=S.useState(""),[a,c]=S.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),m=s.trim();if(!h||!m)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:m,sourceType:a};n([...t,g]),o(""),i(""),c("api")},f=h=>{n(t.filter(m=>!("id"in m&&m.id===h&&m.connectionId===e.id&&m.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(p.Input,{value:r,onChange:h=>o(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(p.Input,{value:s,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(p.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!s.trim(),onClick:d,children:[l.jsx(kr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(_h,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},h.id))})]})}function uft({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:o}){var a;const s=$j("/v1/databases",{connection_id:e.id},["databases",e.id]);if(s.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=s.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(Cde,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(Sde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:o}):l.jsx(E3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:o}))},c.database_name))})}function Sde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:o}){var a;const s=$j("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(s.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=s.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(Cde,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(E3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:o})},c.schema_name))})}function E3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:o,onSelectionChange:s}){const i=$j("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=S.useMemo(()=>{var b;const m=((b=i.data)==null?void 0:b.tables)??[];if(!r)return m;const g=r.trim().toLowerCase();return m.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(m,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:m,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(m=>c(m.table_name,m.table_type)),d=u.length>0&&u.every(m=>o.some(g=>Jn(g,m))),f=(m,g)=>{const b=c(m,g),x=o.some(y=>Jn(y,b));s(x?o.filter(y=>!Jn(y,b)):[...o,b])},h=()=>{if(u.length===0)return;if(d){s(o.filter(g=>!u.some(b=>Jn(g,b))));return}const m=[...o];for(const g of u)m.some(b=>Jn(b,g))||m.push(g);s(m)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(m=>{const g=c(m.table_name,m.table_type),b=o.some(x=>Jn(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:b,onCheckedChange:()=>f(m.table_name,m.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(p.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:m.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:m.table_type??"table"})]})]})},m.table_name)})]})}function dft({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const o=$j("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),s=S.useMemo(()=>{var u;const a=((u=o.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[o.data,t]);if(o.isLoading||s.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Jn(d,c));r(u?n.filter(d=>!Jn(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:s.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Jn(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Tn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(Cpe,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function Cde({label:e,indentLevel:t,search:n,renderChildren:r}){const[o,s]=S.useState(!1),i=o||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:p.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(Pt.ChevronRight,{className:p.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function $j(e,t,n,r=!0){const{tokenProps:o}=gt(),s=p.useDashboardStore(a=>a.authToken),i=S.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return Rn({queryKey:n,queryFn:()=>p.getRequest(`${o.apiServiceUrl}${e}`,(s==null?void 0:s.accessToken)||"",i),enabled:r&&!!(s!=null&&s.accessToken)&&Object.values(i).every(a=>a.length>0)})}function qH(e){return e.type==="dataset"&&e.label||e.name}function fft({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:qH(n)}),l.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t(n)},"aria-label":`Remove ${qH(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function WH(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function kD(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function D3({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:o,onSaveSelectedEntities:s,saveAsDashboardDefault:i=!1}){var te,ye;const{tokenProps:a}=gt(),c=a.config,u=a.semanticDomainAccess||$he.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=S.useState([]),[h,m]=S.useState(void 0),[g,b]=S.useState(""),[x,y]=S.useState("all"),[w,v]=S.useState(void 0),C=S.useRef(!1),{updateDataSource:N}=p.useEditorActions(),_=p.useDashboardStore(se=>se.isVisualEditing),k=p.useDashboardStore(se=>se.dashboard.aiContext),{setAiContext:j}=p.useDashboardActions(),I=u.mode,T=(c==null?void 0:c.showDirectSource)!==!1,E=I==="include"||I==="exclude"||!T,D=I!=="all",A=T&&!E,P=E?"semanticDomain":n.mode,M=r==="dataSource"&&!T,L=I==="include"&&(((te=u.domainIds)==null?void 0:te.length)||0)===1?(ye=u.domainIds)==null?void 0:ye[0]:void 0,$=S.useCallback(se=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:se,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...se!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),z=S.useCallback(se=>{N({...n,...se})},[n,N]),W=S.useCallback(se=>{if(r==="aiContext"){"semanticDomainId"in se&&m(se.semanticDomainId);return}z(se)},[r,z]),F=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},S.useEffect(()=>{if(r==="aiContext"&&!e)return;if(E&&n.mode!=="semanticDomain"&&r==="dataSource"){$("semanticDomain");return}if(!D||P!=="semanticDomain")return;const se=F,Ie=u.domainIds??[],fe=r==="aiContext"?d:n.selectedEntities,me=((fe==null?void 0:fe.length)??0)>0,we=((d==null?void 0:d.length)??0)>0;nft({mode:I,currentDomainId:se,scopedDomainIds:Ie,hasSelectedEntities:me})&&(r==="dataSource"?z({semanticDomainId:void 0,selectedEntities:[]}):m(void 0),we&&f([]))},[E,D,P,n.mode,F,n.selectedEntities,r,h,d,e,u.domainIds,I,T,z,$]),S.useEffect(()=>{L&&!F&&W({semanticDomainId:L})},[L,F,W]),S.useEffect(()=>{if(!e){C.current=!1,b(""),v(void 0),y(E?"semantic":"all");return}if(C.current)return;f([...o||[]]);const se=r==="aiContext"?WH(o):void 0;m(n.semanticDomainId||se),v(kD(o))},[e,r,o,n.semanticDomainId,E]);const X=se=>{C.current=!0,f(d.filter(Ie=>!Jn(Ie,se)))},Y=S.useCallback((se,Ie)=>{C.current=!0,f(se),v(Ie??kD(se))},[]),R=()=>{var Ie,fe;if(r==="aiContext"){if(_&&N(n),i){const me={...k,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(me)}s==null||s(d),t(!1);return}const se=kD(d)??w??P;if(se==="semanticDomain"){const me=WH(d)||h||n.semanticDomainId,we=((Ie=d==null?void 0:d[0])==null?void 0:Ie.connectionId)||n.connectionId,ee=((fe=d==null?void 0:d[0])==null?void 0:fe.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:me,connectionId:we,connectionType:ee,selectedEntities:d})}else if(se==="upload"||se==="url"){const me=d==null?void 0:d[0];N({...n,mode:se,semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}else{const me=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=vde(),{connections:O}=Ac(),U=se=>{y(se),se==="semantic"||se.startsWith("domain:")?n.mode!=="semanticDomain"&&$("semanticDomain"):(se==="direct"||se.startsWith("conn:"))&&n.mode==="semanticDomain"&&$("database")},V=x.startsWith("domain:"),H=x.startsWith("conn:"),q=V?x.slice(7):void 0,B=H?x.slice(5):void 0,G=!A||x==="all"||x==="semantic"||V,Z=T&&!E&&(x==="all"||x==="direct"||H),J=((o==null?void 0:o.length)??0)>0,oe=d.length===0&&!J,ie=d.length===0&&J?"Clear":"Add",ue=r==="aiContext"?"Data context":M?"Select dataset":"Add data",xe=r==="aiContext"?"Set the overall data scope for the dashboard":M?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(p.VisuallyHidden,{children:l.jsx(cs,{children:ue})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:ue}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:xe})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx(Pt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:se=>b(se.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Te.X,{className:"h-3 w-3"})})]}),A&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(Hb,{label:"All",active:x==="all",onClick:()=>U("all")}),(K.length>0||O.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(Hb,{label:"Semantic",active:x==="semantic",onClick:()=>U("semantic")}),l.jsx(Hb,{label:"Direct",active:x==="direct",onClick:()=>U("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(se=>l.jsx(Hb,{label:se.label||se.name,active:x===`domain:${se.id}`,onClick:()=>U(`domain:${se.id}`)},`domain:${se.id}`)),O.map(se=>l.jsx(Hb,{label:se.name,active:x===`conn:${se.id}`,onClick:()=>U(`conn:${se.id}`)},`conn:${se.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(rft,{domainAccess:u,search:g,scopeDomainId:q,selectedEntities:d,onSelectionChange:se=>Y(se,"semanticDomain")}),Z&&l.jsx(ift,{search:g,scopeConnectionId:B,selectedEntities:d,onSelectionChange:se=>Y(se)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:R,disabled:oe,className:p.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",oe&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:ie}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(fft,{selectedEntities:d,onDeselectEntity:X})]})]})})}function Hb({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:p.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const Zp={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function qN(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(iP,{className:r});case"view":return l.jsx(Pt.Eye,{className:r});case"materialized view":return l.jsx(Tpe,{className:r});case"model":return l.jsx(P0,{className:r});case"file":return l.jsx(di,{className:r});case"dataset":return l.jsx(Bi,{className:r});case"upload":return l.jsx(p.Upload,{className:r});case"url":return l.jsx(nP,{className:r});default:return l.jsx(_h,{className:r})}}const _x=e=>e.name||e.name,hft=e=>{const t=_x(e),n="description"in e?e.description:"",r=e.database||"",o=e.schema||"",s=[e.type,r,o].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),s.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:s.join(" · ")})]})};function mft({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:o}){const[s,i]=S.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(p.TooltipProvider,{children:l.jsx("div",{className:o,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const m="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:qN(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:_x(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${_x(f)}`,children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:hft(f)})]},m)}),d&&l.jsxs(p.Tooltip,{open:s,onOpenChange:i,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ui,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:qN(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:_x(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${_x(f)}`,children:l.jsx(Te.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const qS=e=>e.label||(e==null?void 0:e.name),GH=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function pft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:o,selectedEntities:s,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=gt(),f=(d==null?void 0:d.type)==="dashboard",[h,m]=S.useState(""),[g,b]=S.useState(""),x=o.filter(_=>{if(!h)return!0;const k=qS(_).toLowerCase(),j=(GH(_)||"").toLowerCase(),I=h.toLowerCase();return k.includes(I)||j.includes(I)});S.useEffect(()=>{e||(m(""),b(""))},[e]),S.useEffect(()=>{x.length>0&&!g&&b(qS(x[0]))},[x,g]);const y=()=>{if(!g)return;const _=x.find(k=>qS(k)===g);_&&(s.some(j=>"id"in _&&"id"in j?_.id===j.id:_.name===j.name&&_.connectionId===j.connectionId)||t(_),i(_),r())},w=_=>{(_.key==="Tab"||_.key==="Enter")&&(_.preventDefault(),y())};if(!e)return null;const v=_=>s.some(k=>"id"in _&&"id"in k?_.id===k.id:_.name===k.name&&_.connectionId===k.connectionId),C=s.length===o.length,N=s.length>0;return l.jsx(l.Fragment,{children:l.jsxs(hj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:w,children:[o.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx(Pt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Ts.Input,{placeholder:"Search entities",value:h,onValueChange:m,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),u==null||u()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(kr,{className:"h-2.5 w-2.5"}),"Add"]})]}),o.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[s.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),a==null||a()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),c==null||c()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(mj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(pj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:_=>{_.preventDefault(),_.stopPropagation(),u==null||u()},onMouseDown:_=>{_.preventDefault(),_.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(gj,{className:"p-0.5",children:x.map((_,k)=>{const j=v(_),I="id"in _?_.id:`${_.connectionId}-${_.name}`,T=qS(_);return l.jsxs(bj,{value:T,onSelect:()=>{j?n==null||n(_):t(_)},onMouseDown:E=>{E.preventDefault(),E.stopPropagation()},className:p.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(p.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:qN(_.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:T}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:GH(_)})]})]},I)})})]})]})})}function SR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:o=!1,open:s,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:m="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,w]=S.useState(!1),[v,C]=S.useState(!1),N=s??y,_=s!==void 0,k=S.useRef(!1),I=p.useEditorStore(q=>q.card.dataSource)??Zp,{selectedEntities:T,availableEntities:E,syncWithGlobalContext:D,setSelectedEntities:A,applyDashboardDefaultEntities:P,isEntitySelected:M}=oj(x),L=e==="full"||e==="display",$=e==="full"||e==="trigger",z=S.useMemo(()=>b&&T.length>0?`Add entity (${T.length})`:g,[T.length,b,g]);S.useEffect(()=>{N&&!k.current&&o&&D(),k.current=N},[N,o,D]);const W=S.useCallback(q=>{_||w(q),i==null||i(q)},[_,i]),F=S.useCallback(q=>{const B=T.filter(G=>!Jn(G,q));A(B),c==null||c(q),d==null||d(B)},[c,d,T,A]),X=S.useCallback(q=>{if(q.length===0)return;const B=T.filter(G=>!q.some(Z=>Jn(G,Z)));A(B),u==null||u(q),d==null||d(B)},[u,d,T,A]),Y=S.useCallback(q=>{const B=M(q)?T.filter(G=>!Jn(G,q)):[...T,q];A(B),d==null||d(B)},[M,d,T,A]),R=S.useCallback(()=>{A(E),d==null||d(E)},[E,d,A]),K=S.useCallback(()=>{A([]),d==null||d([])},[d,A]),O=S.useCallback(q=>{x==="dashboard"?P():A(q),d==null||d(q)},[P,x,d,A]),U=S.useCallback(q=>{const B=T.some(G=>Jn(G,q))?T:[...T,q];A(B),a==null||a(q),d==null||d(B),W(!1)},[a,d,T,W,A]),V=L?l.jsx(mft,{className:p.cn(n?"contents":"space-y-2"),entities:T,availableEntities:E,onRemoveEntity:F,onRemoveEntities:X}):null,H=$?l.jsxs(l.Fragment,{children:[l.jsxs(p.Popover,{open:N,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:m,size:"xs",className:p.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(Qq,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:z})]})}),l.jsx(p.PopoverContent,{className:p.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:q=>q.preventDefault(),children:l.jsx(pft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:E,selectedEntities:T,onTabComplete:U,onSelectAll:R,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(D3,{incomingSelectedEntities:T,open:v,onOpenChange:C,dataSource:I,dialogMode:"aiContext",onSaveSelectedEntities:O,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:p.cn(n?"flex flex-wrap items-center gap-1":"",!n&&L?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[H,V]}):l.jsxs(l.Fragment,{children:[V,H]})})}const M3=S.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:o,stop:s,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=S.useState(!1),h=S.useRef(null),{queueMessage:m}=p.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=p.useFileActions(),y=p.useFileAttachments(c);S.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const w=S.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const A=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${A}px`}},[e]);S.useEffect(()=>{w()},[w]),S.useEffect(()=>{const D=setTimeout(()=>{w()},0);return()=>clearTimeout(D)},[w]);const v=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(m(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),v()),D.key==="@"&&f(!0)},N=S.useCallback(D=>{const A=zdt(D.nativeEvent);A.length>0&&(D.preventDefault(),A.forEach(async P=>{const M=await k3(P);g(c,M)}))},[g,c]),_=S.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),k=S.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),j=S.useCallback(D=>{b(c,D)},[b,c]),I=S.useCallback(D=>{const A=`@${D}`;e.includes(A)&&t(e.replace(A,"").replace(/\s{2,}/g," ").trim())},[e,t]),T=!e.trim()&&y.length===0,E=a!=="ready"&&!o;return l.jsxs(eft,{onFilesDropped:_,currentFileCount:y.length,disabled:o,className:"space-y-2",children:[l.jsx(SR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const A="label"in D?D.label:D.name;I(A)},onEntitiesRemoved:D=>{let A=e;D.forEach(P=>{const M="label"in P?P.label:P.name;A=A.replace(`@${M}`,"")}),A!==e&&t(A.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Qdt,{files:y,onRemove:j,showRemove:!o}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{w(),i==null||i()},placeholder:E?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(SR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var P;const A="label"in D?D.label:D.name;t(`${e}@${A} `),(P=h.current)==null||P.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(Bdt,{onFilesSelected:k,disabled:o,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),o?l.jsx("button",{type:"button",onClick:s,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(sP,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:T,onClick:v,title:E?"Message will be queued":"Send",className:E?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(IW,{className:"h-3 w-3"})})]})]})]})});M3.displayName="ChatInputWithContext";function Nde({assistantType:e,className:t}){const n=p.useMessageQueue(e),{removeFromQueue:r}=p.useQueueActions();return n.length===0?null:l.jsxs("div",{className:p.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(tP,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(o=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:o.text}),l.jsx("button",{type:"button",onClick:()=>r(e,o.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(Te.X,{className:"h-3 w-3"})})]},o.id))})]})}function _de({assistantType:e,status:t,isLoading:n,sendMessage:r}){const o=p.useMessageQueue(e),{dequeueMessage:s}=p.useQueueActions();S.useEffect(()=>{if(t!=="ready"||n||!(o&&o.length>0))return;const a=s(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,o,s,r,e])}const YH={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-inspectDataContext":{"input-streaming":"Inspecting data context...","input-available":"Reading grounded fields..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function gft(e,t){var r;if((r=YH[e])!=null&&r[t])return YH[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function kde(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const o=r,s=o.state;return{hasActiveTools:!0,activeToolText:gft(o.type,s),toolType:o.type}}}return{hasActiveTools:!1}}function bft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function xft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const yft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wft={};function KH(e,t){return(wft.jsx?vft:yft).test(e)}const Sft=/[ \t\n\f\r]/g;function Cft(e){return typeof e=="object"?e.type==="text"?ZH(e.value):!1:ZH(e)}function ZH(e){return e.replace(Sft,"")===""}class Xv{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Xv.prototype.normal={};Xv.prototype.property={};Xv.prototype.space=void 0;function jde(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Xv(n,r,t)}function CR(e){return e.toLowerCase()}class Ks{constructor(t,n){this.attribute=n,this.property=t}}Ks.prototype.attribute="";Ks.prototype.booleanish=!1;Ks.prototype.boolean=!1;Ks.prototype.commaOrSpaceSeparated=!1;Ks.prototype.commaSeparated=!1;Ks.prototype.defined=!1;Ks.prototype.mustUseProperty=!1;Ks.prototype.number=!1;Ks.prototype.overloadedBoolean=!1;Ks.prototype.property="";Ks.prototype.spaceSeparated=!1;Ks.prototype.space=void 0;let Nft=0;const un=Gh(),eo=Gh(),NR=Gh(),dt=Gh(),pr=Gh(),np=Gh(),ei=Gh();function Gh(){return 2**++Nft}const _R=Object.freeze(Object.defineProperty({__proto__:null,boolean:un,booleanish:eo,commaOrSpaceSeparated:ei,commaSeparated:np,number:dt,overloadedBoolean:NR,spaceSeparated:pr},Symbol.toStringTag,{value:"Module"})),jD=Object.keys(_R);class A3 extends Ks{constructor(t,n,r,o){let s=-1;if(super(t,n),XH(this,"space",o),typeof r=="number")for(;++s<jD.length;){const i=jD[s];XH(this,jD[s],(r&_R[i])===_R[i])}}}A3.prototype.defined=!0;function XH(e,t,n){n&&(e[t]=n)}function Kg(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const s=new A3(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[CR(r)]=r,n[CR(s.attribute)]=r}return new Xv(t,n,e.space)}const Tde=Kg({properties:{ariaActiveDescendant:null,ariaAtomic:eo,ariaAutoComplete:null,ariaBusy:eo,ariaChecked:eo,ariaColCount:dt,ariaColIndex:dt,ariaColSpan:dt,ariaControls:pr,ariaCurrent:null,ariaDescribedBy:pr,ariaDetails:null,ariaDisabled:eo,ariaDropEffect:pr,ariaErrorMessage:null,ariaExpanded:eo,ariaFlowTo:pr,ariaGrabbed:eo,ariaHasPopup:null,ariaHidden:eo,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:pr,ariaLevel:dt,ariaLive:null,ariaModal:eo,ariaMultiLine:eo,ariaMultiSelectable:eo,ariaOrientation:null,ariaOwns:pr,ariaPlaceholder:null,ariaPosInSet:dt,ariaPressed:eo,ariaReadOnly:eo,ariaRelevant:null,ariaRequired:eo,ariaRoleDescription:pr,ariaRowCount:dt,ariaRowIndex:dt,ariaRowSpan:dt,ariaSelected:eo,ariaSetSize:dt,ariaSort:null,ariaValueMax:dt,ariaValueMin:dt,ariaValueNow:dt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ide(e,t){return t in e?e[t]:t}function Ede(e,t){return Ide(e,t.toLowerCase())}const _ft=Kg({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:np,acceptCharset:pr,accessKey:pr,action:null,allow:null,allowFullScreen:un,allowPaymentRequest:un,allowUserMedia:un,alt:null,as:null,async:un,autoCapitalize:null,autoComplete:pr,autoFocus:un,autoPlay:un,blocking:pr,capture:null,charSet:null,checked:un,cite:null,className:pr,cols:dt,colSpan:null,content:null,contentEditable:eo,controls:un,controlsList:pr,coords:dt|np,crossOrigin:null,data:null,dateTime:null,decoding:null,default:un,defer:un,dir:null,dirName:null,disabled:un,download:NR,draggable:eo,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:un,formTarget:null,headers:pr,height:dt,hidden:NR,high:dt,href:null,hrefLang:null,htmlFor:pr,httpEquiv:pr,id:null,imageSizes:null,imageSrcSet:null,inert:un,inputMode:null,integrity:null,is:null,isMap:un,itemId:null,itemProp:pr,itemRef:pr,itemScope:un,itemType:pr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:un,low:dt,manifest:null,max:null,maxLength:dt,media:null,method:null,min:null,minLength:dt,multiple:un,muted:un,name:null,nonce:null,noModule:un,noValidate:un,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:un,optimum:dt,pattern:null,ping:pr,placeholder:null,playsInline:un,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:un,referrerPolicy:null,rel:pr,required:un,reversed:un,rows:dt,rowSpan:dt,sandbox:pr,scope:null,scoped:un,seamless:un,selected:un,shadowRootClonable:un,shadowRootDelegatesFocus:un,shadowRootMode:null,shape:null,size:dt,sizes:null,slot:null,span:dt,spellCheck:eo,src:null,srcDoc:null,srcLang:null,srcSet:null,start:dt,step:null,style:null,tabIndex:dt,target:null,title:null,translate:null,type:null,typeMustMatch:un,useMap:null,value:eo,width:dt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:pr,axis:null,background:null,bgColor:null,border:dt,borderColor:null,bottomMargin:dt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:un,declare:un,event:null,face:null,frame:null,frameBorder:null,hSpace:dt,leftMargin:dt,link:null,longDesc:null,lowSrc:null,marginHeight:dt,marginWidth:dt,noResize:un,noHref:un,noShade:un,noWrap:un,object:null,profile:null,prompt:null,rev:null,rightMargin:dt,rules:null,scheme:null,scrolling:eo,standby:null,summary:null,text:null,topMargin:dt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:dt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:un,disableRemotePlayback:un,prefix:null,property:null,results:dt,security:null,unselectable:null},space:"html",transform:Ede}),kft=Kg({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ei,accentHeight:dt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:dt,amplitude:dt,arabicForm:null,ascent:dt,attributeName:null,attributeType:null,azimuth:dt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:dt,by:null,calcMode:null,capHeight:dt,className:pr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:dt,diffuseConstant:dt,direction:null,display:null,dur:null,divisor:dt,dominantBaseline:null,download:un,dx:null,dy:null,edgeMode:null,editable:null,elevation:dt,enableBackground:null,end:null,event:null,exponent:dt,externalResourcesRequired:null,fill:null,fillOpacity:dt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:np,g2:np,glyphName:np,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:dt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:dt,horizOriginX:dt,horizOriginY:dt,id:null,ideographic:dt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:dt,k:dt,k1:dt,k2:dt,k3:dt,k4:dt,kernelMatrix:ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:dt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:dt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:dt,overlineThickness:dt,paintOrder:null,panose1:null,path:null,pathLength:dt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:pr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:dt,pointsAtY:dt,pointsAtZ:dt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ei,rev:ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ei,requiredFeatures:ei,requiredFonts:ei,requiredFormats:ei,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:dt,specularExponent:dt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:dt,strikethroughThickness:dt,string:null,stroke:null,strokeDashArray:ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:dt,strokeOpacity:dt,strokeWidth:null,style:null,surfaceScale:dt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ei,tabIndex:dt,tableValues:null,target:null,targetX:dt,targetY:dt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:dt,underlineThickness:dt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:dt,values:null,vAlphabetic:dt,vMathematical:dt,vectorEffect:null,vHanging:dt,vIdeographic:dt,version:null,vertAdvY:dt,vertOriginX:dt,vertOriginY:dt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:dt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ide}),Dde=Kg({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Mde=Kg({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ede}),Ade=Kg({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),jft={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Tft=/[A-Z]/g,QH=/-[a-z]/g,Ift=/^data[-\w.:]+$/i;function Eft(e,t){const n=CR(t);let r=t,o=Ks;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ift.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(QH,Mft);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!QH.test(s)){let i=s.replace(Tft,Dft);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=A3}return new o(r,t)}function Dft(e){return"-"+e.toLowerCase()}function Mft(e){return e.charAt(1).toUpperCase()}const Aft=jde([Tde,_ft,Dde,Mde,Ade],"html"),R3=jde([Tde,kft,Dde,Mde,Ade],"svg");function Rft(e){return e.join(" ").trim()}var P3={},JH=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Pft=/\n/g,Fft=/^\s*/,Oft=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Lft=/^:\s*/,$ft=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,zft=/^[;\s]*/,Bft=/^\s+|\s+$/g,Vft=`
|
|
1302
1302
|
`,eU="/",tU="*",nf="",Hft="comment",Uft="declaration";function qft(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(g){var b=g.match(Pft);b&&(n+=b.length);var x=g.lastIndexOf(Vft);r=~x?g.length-x:r+g.length}function s(){var g={line:n,column:r};return function(b){return b.position=new i(g),u(),b}}function i(g){this.start=g,this.end={line:n,column:r},this.source=t.source}i.prototype.content=e;function a(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var x=b[0];return o(x),e=e.slice(x.length),b}}function u(){c(Fft)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=s();if(!(eU!=e.charAt(0)||tU!=e.charAt(1))){for(var b=2;nf!=e.charAt(b)&&(tU!=e.charAt(b)||eU!=e.charAt(b+1));)++b;if(b+=2,nf===e.charAt(b-1))return a("End of comment missing");var x=e.slice(2,b-2);return r+=2,o(x),e=e.slice(b),r+=2,g({type:Hft,comment:x})}}function h(){var g=s(),b=c(Oft);if(b){if(f(),!c(Lft))return a("property missing ':'");var x=c($ft),y=g({type:Uft,property:nU(b[0].replace(JH,nf)),value:x?nU(x[0].replace(JH,nf)):nf});return c(zft),y}}function m(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),m()}function nU(e){return e?e.replace(Bft,nf):nf}var Wft=qft,Gft=p.commonjsGlobal&&p.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P3,"__esModule",{value:!0});P3.default=Kft;const Yft=Gft(Wft);function Kft(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Yft.default)(e),o=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:i,value:a}=s;o?t(i,a,s):a&&(n=n||{},n[i]=a)}),n}var zj={};Object.defineProperty(zj,"__esModule",{value:!0});zj.camelCase=void 0;var Zft=/^--[a-zA-Z0-9_-]+$/,Xft=/-([a-z])/g,Qft=/^[^-]+$/,Jft=/^-(webkit|moz|ms|o|khtml)-/,eht=/^-(ms)-/,tht=function(e){return!e||Qft.test(e)||Zft.test(e)},nht=function(e,t){return t.toUpperCase()},rU=function(e,t){return"".concat(t,"-")},rht=function(e,t){return t===void 0&&(t={}),tht(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(eht,rU):e=e.replace(Jft,rU),e.replace(Xft,nht))};zj.camelCase=rht;var oht=p.commonjsGlobal&&p.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},sht=oht(P3),iht=zj;function kR(e,t){var n={};return!e||typeof e!="string"||(0,sht.default)(e,function(r,o){r&&o&&(n[(0,iht.camelCase)(r,t)]=o)}),n}kR.default=kR;var aht=kR;const lht=p.getDefaultExportFromCjs(aht),Rde=Pde("end"),F3=Pde("start");function Pde(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function cht(e){const t=F3(e),n=Rde(e);if(t&&n)return{start:t,end:n}}function oy(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?oU(e.position):"start"in e||"end"in e?oU(e):"line"in e||"column"in e?jR(e):""}function jR(e){return sU(e&&e.line)+":"+sU(e&&e.column)}function oU(e){return jR(e&&e.start)+"-"+jR(e&&e.end)}function sU(e){return e&&typeof e=="number"?e:1}class us extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",s={},i=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?o=t:!s.cause&&t&&(i=!0,o=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=a?a.line:void 0,this.name=oy(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=i&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}us.prototype.file="";us.prototype.name="";us.prototype.reason="";us.prototype.message="";us.prototype.stack="";us.prototype.column=void 0;us.prototype.line=void 0;us.prototype.ancestors=void 0;us.prototype.cause=void 0;us.prototype.fatal=void 0;us.prototype.place=void 0;us.prototype.ruleId=void 0;us.prototype.source=void 0;const O3={}.hasOwnProperty,uht=new Map,dht=/[A-Z]/g,fht=new Set(["table","tbody","thead","tfoot","tr"]),hht=new Set(["td","th"]),Fde="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function mht(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Sht(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=wht(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?R3:Aft,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Ode(o,e,void 0);return s&&typeof s!="string"?s:o.create(e,o.Fragment,{children:s||void 0},void 0)}function Ode(e,t,n){if(t.type==="element")return pht(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ght(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return xht(e,t,n);if(t.type==="mdxjsEsm")return bht(e,t);if(t.type==="root")return yht(e,t,n);if(t.type==="text")return vht(e,t)}function pht(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=R3,e.schema=o),e.ancestors.push(t);const s=$de(e,t.tagName,!1),i=Cht(e,t);let a=$3(e,t);return fht.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!Cft(c):!0})),Lde(e,i,s,t),L3(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}function ght(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}v0(e,t.position)}function bht(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);v0(e,t.position)}function xht(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=R3,e.schema=o),e.ancestors.push(t);const s=t.name===null?e.Fragment:$de(e,t.name,!0),i=Nht(e,t),a=$3(e,t);return Lde(e,i,s,t),L3(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}function yht(e,t,n){const r={};return L3(r,$3(e,t)),e.create(t,e.Fragment,r,n)}function vht(e,t){return t.value}function Lde(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function L3(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function wht(e,t,n){return r;function r(o,s,i,a){const u=Array.isArray(i.children)?n:t;return a?u(s,i,a):u(s,i)}}function Sht(e,t){return n;function n(r,o,s,i){const a=Array.isArray(s.children),c=F3(r);return t(o,s,i,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Cht(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&O3.call(t.properties,o)){const s=_ht(e,o,t.properties[o]);if(s){const[i,a]=s;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&hht.has(t.tagName)?r=a:n[i]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Nht(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const i=s.expression;i.type;const a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else v0(e,t.position);else{const o=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else v0(e,t.position);else s=r.value===null?!0:r.value;n[o]=s}return n}function $3(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:uht;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const u=o.get(c)||0;i=c+"-"+u,o.set(c,u+1)}}const a=Ode(e,s,i);a!==void 0&&n.push(a)}return n}function _ht(e,t,n){const r=Eft(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?xft(n):Rft(n)),r.property==="style"){let o=typeof n=="object"?n:kht(e,String(n));return e.stylePropertyNameCase==="css"&&(o=jht(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?jft[r.property]||r.property:r.attribute,n]}}function kht(e,t){try{return lht(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new us("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=Fde+"#cannot-parse-style-attribute",o}}function $de(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let s=-1,i;for(;++s<o.length;){const a=KH(o[s])?{type:"Identifier",name:o[s]}:{type:"Literal",value:o[s]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=i}else r=KH(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return O3.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);v0(e)}function v0(e,t){const n=new us("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Fde+"#cannot-handle-mdx-estrees-without-createevaluater",n}function jht(e){const t={};let n;for(n in e)O3.call(e,n)&&(t[Tht(n)]=e[n]);return t}function Tht(e){let t=e.replace(dht,Iht);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Iht(e){return"-"+e.toLowerCase()}const TD={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Eht={};function z3(e,t){const n=Eht,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zde(e,r,o)}function zde(e,t,n){if(Dht(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return iU(e.children,t,n)}return Array.isArray(e)?iU(e,t,n):""}function iU(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=zde(e[o],t,n);return r.join("")}function Dht(e){return!!(e&&typeof e=="object")}const aU=document.createElement("i");function B3(e){const t="&"+e+";";aU.innerHTML=t;const n=aU.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ci(e,t,n,r){const o=e.length;let s=0,i;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s<r.length;)i=r.slice(s,s+1e4),i.unshift(t,0),e.splice(...i),s+=1e4,t+=1e4}function Pi(e,t){return e.length>0?(ci(e,e.length,0,t),e):t}const lU={}.hasOwnProperty;function Bde(e){const t={};let n=-1;for(;++n<e.length;)Mht(t,e[n]);return t}function Mht(e,t){let n;for(n in t){const o=(lU.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let i;if(s)for(i in s){lU.call(o,i)||(o[i]=[]);const a=s[i];Aht(o[i],Array.isArray(a)?a:a?[a]:[])}}}function Aht(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ci(e,0,0,r)}function Vde(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function wa(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ws=Sd(/[A-Za-z]/),os=Sd(/[\dA-Za-z]/),Rht=Sd(/[#-'*+\--9=?A-Z^-~]/);function WN(e){return e!==null&&(e<32||e===127)}const TR=Sd(/\d/),Pht=Sd(/[\dA-Fa-f]/),Fht=Sd(/[!-/:-@[-`{-~]/);function Bt(e){return e!==null&&e<-2}function ur(e){return e!==null&&(e<0||e===32)}function Cn(e){return e===-2||e===-1||e===32}const Bj=Sd(new RegExp("\\p{P}|\\p{S}","u")),vh=Sd(/\s/);function Sd(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Zg(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(s===37&&os(e.charCodeAt(n+1))&&os(e.charCodeAt(n+2)))o=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(i=String.fromCharCode(s,a),o=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+o+1,i=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Mn(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let s=0;return i;function i(c){return Cn(c)?(e.enter(n),a(c)):t(c)}function a(c){return Cn(c)&&s++<o?(e.consume(c),a):(e.exit(n),t(c))}}const Oht={tokenize:Lht};function Lht(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Mn(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),s(a)}function s(a){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,i(a)}function i(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Bt(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),i)}}const $ht={tokenize:zht},cU={tokenize:Bht};function zht(e){const t=this,n=[];let r=0,o,s,i;return a;function a(v){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(v)}return u(v)}function c(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&w();const C=t.events.length;let N=C,_;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){_=t.events[N][1].end;break}y(r);let k=C;for(;k<t.events.length;)t.events[k][1].end={..._},k++;return ci(t.events,N+1,0,t.events.slice(C)),t.events.length=k,u(v)}return a(v)}function u(v){if(r===n.length){if(!o)return h(v);if(o.currentConstruct&&o.currentConstruct.concrete)return g(v);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(cU,d,f)(v)}function d(v){return o&&w(),y(r),h(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,i=t.now().offset,g(v)}function h(v){return t.containerState={},e.attempt(cU,m,g)(v)}function m(v){return r++,n.push([t.currentConstruct,t.containerState]),h(v)}function g(v){if(v===null){o&&w(),y(0),e.consume(v);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:s}),b(v)}function b(v){if(v===null){x(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return Bt(v)?(e.consume(v),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(v),b)}function x(v,C){const N=t.sliceStream(v);if(C&&N.push(null),v.previous=s,s&&(s.next=v),s=v,o.defineSkip(v.start),o.write(N),t.parser.lazy[v.start.line]){let _=o.events.length;for(;_--;)if(o.events[_][1].start.offset<i&&(!o.events[_][1].end||o.events[_][1].end.offset>i))return;const k=t.events.length;let j=k,I,T;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(I){T=t.events[j][1].end;break}I=!0}for(y(r),_=k;_<t.events.length;)t.events[_][1].end={...T},_++;ci(t.events,j+1,0,t.events.slice(k)),t.events.length=_}}function y(v){let C=n.length;for(;C-- >v;){const N=n[C];t.containerState=N[1],N[0].exit.call(t,e)}n.length=v}function w(){o.write([null]),s=void 0,o=void 0,t.containerState._closeFlow=void 0}}function Bht(e,t,n){return Mn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Xp(e){if(e===null||ur(e)||vh(e))return 1;if(Bj(e))return 2}function Vj(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const s=e[o].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const IR={name:"attention",resolveAll:Vht,tokenize:Hht};function Vht(e,t){let n=-1,r,o,s,i,a,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};uU(f,-c),uU(h,c),i={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:c>1?"strong":"emphasis",start:{...i.start},end:{...a.end}},e[r][1].end={...i.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Pi(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Pi(u,[["enter",o,t],["enter",i,t],["exit",i,t],["enter",s,t]]),u=Pi(u,Vj(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Pi(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Pi(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,ci(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Hht(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Xp(r);let s;return i;function i(c){return s=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===s)return e.consume(c),a;const u=e.exit("attentionSequence"),d=Xp(c),f=!d||d===2&&o||n.includes(c),h=!o||o===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(o||!h)),u._close=!!(s===42?h:h&&(d||!f)),t(c)}}function uU(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Uht={name:"autolink",tokenize:qht};function qht(e,t,n){let r=0;return o;function o(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(m){return ws(m)?(e.consume(m),i):m===64?n(m):u(m)}function i(m){return m===43||m===45||m===46||os(m)?(r=1,a(m)):u(m)}function a(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||os(m))&&r++<32?(e.consume(m),a):(r=0,u(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||WN(m)?n(m):(e.consume(m),c)}function u(m){return m===64?(e.consume(m),d):Rht(m)?(e.consume(m),u):n(m)}function d(m){return os(m)?f(m):n(m)}function f(m){return m===46?(e.consume(m),r=0,d):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):h(m)}function h(m){if((m===45||os(m))&&r++<63){const g=m===45?h:f;return e.consume(m),g}return n(m)}}const Qv={partial:!0,tokenize:Wht};function Wht(e,t,n){return r;function r(s){return Cn(s)?Mn(e,o,"linePrefix")(s):o(s)}function o(s){return s===null||Bt(s)?t(s):n(s)}}const Hde={continuation:{tokenize:Yht},exit:Kht,name:"blockQuote",tokenize:Ght};function Ght(e,t,n){const r=this;return o;function o(i){if(i===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),s}return n(i)}function s(i){return Cn(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function Yht(e,t,n){const r=this;return o;function o(i){return Cn(i)?Mn(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):s(i)}function s(i){return e.attempt(Hde,t,n)(i)}}function Kht(e){e.exit("blockQuote")}const Ude={name:"characterEscape",tokenize:Zht};function Zht(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),o}function o(s){return Fht(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const qde={name:"characterReference",tokenize:Xht};function Xht(e,t,n){const r=this;let o=0,s,i;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,i=os,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,i=Pht,d):(e.enter("characterReferenceValue"),s=7,i=TR,d(f))}function d(f){if(f===59&&o){const h=e.exit("characterReferenceValue");return i===os&&!B3(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(f)&&o++<s?(e.consume(f),d):n(f)}}const dU={partial:!0,tokenize:Jht},fU={concrete:!0,name:"codeFenced",tokenize:Qht};function Qht(e,t,n){const r=this,o={partial:!0,tokenize:N};let s=0,i=0,a;return c;function c(_){return u(_)}function u(_){const k=r.events[r.events.length-1];return s=k&&k[1].type==="linePrefix"?k[2].sliceSerialize(k[1],!0).length:0,a=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(_)}function d(_){return _===a?(i++,e.consume(_),d):i<3?n(_):(e.exit("codeFencedFenceSequence"),Cn(_)?Mn(e,f,"whitespace")(_):f(_))}function f(_){return _===null||Bt(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(dU,b,C)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(_))}function h(_){return _===null||Bt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(_)):Cn(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mn(e,m,"whitespace")(_)):_===96&&_===a?n(_):(e.consume(_),h)}function m(_){return _===null||Bt(_)?f(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||Bt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(_)):_===96&&_===a?n(_):(e.consume(_),g)}function b(_){return e.attempt(o,C,x)(_)}function x(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),y}function y(_){return s>0&&Cn(_)?Mn(e,w,"linePrefix",s+1)(_):w(_)}function w(_){return _===null||Bt(_)?e.check(dU,b,C)(_):(e.enter("codeFlowValue"),v(_))}function v(_){return _===null||Bt(_)?(e.exit("codeFlowValue"),w(_)):(e.consume(_),v)}function C(_){return e.exit("codeFenced"),t(_)}function N(_,k,j){let I=0;return T;function T(M){return _.enter("lineEnding"),_.consume(M),_.exit("lineEnding"),E}function E(M){return _.enter("codeFencedFence"),Cn(M)?Mn(_,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):D(M)}function D(M){return M===a?(_.enter("codeFencedFenceSequence"),A(M)):j(M)}function A(M){return M===a?(I++,_.consume(M),A):I>=i?(_.exit("codeFencedFenceSequence"),Cn(M)?Mn(_,P,"whitespace")(M):P(M)):j(M)}function P(M){return M===null||Bt(M)?(_.exit("codeFencedFence"),k(M)):j(M)}}}function Jht(e,t,n){const r=this;return o;function o(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s)}function s(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}const ID={name:"codeIndented",tokenize:tmt},emt={partial:!0,tokenize:nmt};function tmt(e,t,n){const r=this;return o;function o(u){return e.enter("codeIndented"),Mn(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(u):n(u)}function i(u){return u===null?c(u):Bt(u)?e.attempt(emt,i,c)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Bt(u)?(e.exit("codeFlowValue"),i(u)):(e.consume(u),a)}function c(u){return e.exit("codeIndented"),t(u)}}function nmt(e,t,n){const r=this;return o;function o(i){return r.parser.lazy[r.now().line]?n(i):Bt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):Mn(e,s,"linePrefix",5)(i)}function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):Bt(i)?o(i):n(i)}}const rmt={name:"codeText",previous:smt,resolve:omt,tokenize:imt};function omt(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function smt(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function imt(e,t,n){let r=0,o,s;return i;function i(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),o=0,d(f)):Bt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Bt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),o++,d):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class amt{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&Ub(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ub(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ub(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ub(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ub(this.left,n.reverse())}}}function Ub(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Wde(e){const t={};let n=-1,r,o,s,i,a,c,u;const d=new amt(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,lmt(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,o=void 0;s--;)if(i=d.get(s),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(o&&(d.get(o)[1].type="lineEndingBlank"),i[1].type="lineEnding",o=s);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;o&&(r[1].end={...d.get(o)[1].start},a=d.slice(o,n),a.unshift(r),d.splice(o,n-o+1,a))}}return ci(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function lmt(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const s=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,c=[],u={};let d,f,h=-1,m=n,g=0,b=0;const x=[b];for(;m;){for(;e.get(++o)[1]!==m;);s.push(o),m._tokenizer||(d=r.sliceStream(m),m.next||d.push(null),f&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(b=h+1,x.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):x.pop(),h=x.length;h--;){const y=a.slice(x[h],x[h+1]),w=s.pop();c.push([w,w+y.length-1]),e.splice(w,2,y)}for(c.reverse(),h=-1;++h<c.length;)u[g+c[h][0]]=g+c[h][1],g+=c[h][1]-c[h][0]-1;return u}const cmt={resolve:dmt,tokenize:fmt},umt={partial:!0,tokenize:hmt};function dmt(e){return Wde(e),e}function fmt(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?s(a):Bt(a)?e.check(umt,i,s)(a):(e.consume(a),o)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function i(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function hmt(e,t,n){const r=this;return o;function o(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Mn(e,s,"linePrefix")}function s(i){if(i===null||Bt(i))return n(i);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Gde(e,t,n,r,o,s,i,a,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(o),e.enter(s),e.consume(y),e.exit(s),h):y===null||y===32||y===41||WN(y)?n(y):(e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(y))}function h(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Bt(y)?n(y):(e.consume(y),y===92?g:m)}function g(y){return y===60||y===62||y===92?(e.consume(y),m):m(y)}function b(y){return!d&&(y===null||y===41||ur(y))?(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,b):y===41?(e.consume(y),d--,b):y===null||y===32||y===40||WN(y)?n(y):(e.consume(y),y===92?x:b)}function x(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function Yde(e,t,n,r,o,s){const i=this;let a=0,c;return u;function u(m){return e.enter(r),e.enter(o),e.consume(m),e.exit(o),e.enter(s),d}function d(m){return a>999||m===null||m===91||m===93&&!c||m===94&&!a&&"_hiddenFootnoteSupport"in i.parser.constructs?n(m):m===93?(e.exit(s),e.enter(o),e.consume(m),e.exit(o),e.exit(r),t):Bt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||Bt(m)||a++>999?(e.exit("chunkString"),d(m)):(e.consume(m),c||(c=!Cn(m)),m===92?h:f)}function h(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}}function Kde(e,t,n,r,o,s){let i;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(o),e.consume(h),e.exit(o),i=h===40?41:h,c):n(h)}function c(h){return h===i?(e.enter(o),e.consume(h),e.exit(o),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===i?(e.exit(s),c(i)):h===null?n(h):Bt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Mn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===i||h===null||Bt(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===i||h===92?(e.consume(h),d):d(h)}}function sy(e,t){let n;return r;function r(o){return Bt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Cn(o)?Mn(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const mmt={name:"definition",tokenize:gmt},pmt={partial:!0,tokenize:bmt};function gmt(e,t,n){const r=this;let o;return s;function s(m){return e.enter("definition"),i(m)}function i(m){return Yde.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function a(m){return o=wa(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return ur(m)?sy(e,u)(m):u(m)}function u(m){return Gde(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return e.attempt(pmt,f,f)(m)}function f(m){return Cn(m)?Mn(e,h,"whitespace")(m):h(m)}function h(m){return m===null||Bt(m)?(e.exit("definition"),r.parser.defined.push(o),t(m)):n(m)}}function bmt(e,t,n){return r;function r(a){return ur(a)?sy(e,o)(a):n(a)}function o(a){return Kde(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Cn(a)?Mn(e,i,"whitespace")(a):i(a)}function i(a){return a===null||Bt(a)?t(a):n(a)}}const xmt={name:"hardBreakEscape",tokenize:ymt};function ymt(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),o}function o(s){return Bt(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const vmt={name:"headingAtx",resolve:wmt,tokenize:Smt};function wmt(e,t){let n=e.length-2,r=3,o,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ci(e,r,n-r+1,[["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t]])),e}function Smt(e,t,n){let r=0;return o;function o(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&r++<6?(e.consume(d),i):d===null||ur(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||Bt(d)?(e.exit("atxHeading"),t(d)):Cn(d)?Mn(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||ur(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const Cmt=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],hU=["pre","script","style","textarea"],Nmt={concrete:!0,name:"htmlFlow",resolveTo:jmt,tokenize:Tmt},_mt={partial:!0,tokenize:Emt},kmt={partial:!0,tokenize:Imt};function jmt(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Tmt(e,t,n){const r=this;let o,s,i,a,c;return u;function u(R){return d(R)}function d(R){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(R),f}function f(R){return R===33?(e.consume(R),h):R===47?(e.consume(R),s=!0,b):R===63?(e.consume(R),o=3,r.interrupt?t:F):ws(R)?(e.consume(R),i=String.fromCharCode(R),x):n(R)}function h(R){return R===45?(e.consume(R),o=2,m):R===91?(e.consume(R),o=5,a=0,g):ws(R)?(e.consume(R),o=4,r.interrupt?t:F):n(R)}function m(R){return R===45?(e.consume(R),r.interrupt?t:F):n(R)}function g(R){const K="CDATA[";return R===K.charCodeAt(a++)?(e.consume(R),a===K.length?r.interrupt?t:D:g):n(R)}function b(R){return ws(R)?(e.consume(R),i=String.fromCharCode(R),x):n(R)}function x(R){if(R===null||R===47||R===62||ur(R)){const K=R===47,O=i.toLowerCase();return!K&&!s&&hU.includes(O)?(o=1,r.interrupt?t(R):D(R)):Cmt.includes(i.toLowerCase())?(o=6,K?(e.consume(R),y):r.interrupt?t(R):D(R)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(R):s?w(R):v(R))}return R===45||os(R)?(e.consume(R),i+=String.fromCharCode(R),x):n(R)}function y(R){return R===62?(e.consume(R),r.interrupt?t:D):n(R)}function w(R){return Cn(R)?(e.consume(R),w):T(R)}function v(R){return R===47?(e.consume(R),T):R===58||R===95||ws(R)?(e.consume(R),C):Cn(R)?(e.consume(R),v):T(R)}function C(R){return R===45||R===46||R===58||R===95||os(R)?(e.consume(R),C):N(R)}function N(R){return R===61?(e.consume(R),_):Cn(R)?(e.consume(R),N):v(R)}function _(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),c=R,k):Cn(R)?(e.consume(R),_):j(R)}function k(R){return R===c?(e.consume(R),c=null,I):R===null||Bt(R)?n(R):(e.consume(R),k)}function j(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||ur(R)?N(R):(e.consume(R),j)}function I(R){return R===47||R===62||Cn(R)?v(R):n(R)}function T(R){return R===62?(e.consume(R),E):n(R)}function E(R){return R===null||Bt(R)?D(R):Cn(R)?(e.consume(R),E):n(R)}function D(R){return R===45&&o===2?(e.consume(R),L):R===60&&o===1?(e.consume(R),$):R===62&&o===4?(e.consume(R),X):R===63&&o===3?(e.consume(R),F):R===93&&o===5?(e.consume(R),W):Bt(R)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(_mt,Y,A)(R)):R===null||Bt(R)?(e.exit("htmlFlowData"),A(R)):(e.consume(R),D)}function A(R){return e.check(kmt,P,Y)(R)}function P(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),M}function M(R){return R===null||Bt(R)?A(R):(e.enter("htmlFlowData"),D(R))}function L(R){return R===45?(e.consume(R),F):D(R)}function $(R){return R===47?(e.consume(R),i="",z):D(R)}function z(R){if(R===62){const K=i.toLowerCase();return hU.includes(K)?(e.consume(R),X):D(R)}return ws(R)&&i.length<8?(e.consume(R),i+=String.fromCharCode(R),z):D(R)}function W(R){return R===93?(e.consume(R),F):D(R)}function F(R){return R===62?(e.consume(R),X):R===45&&o===2?(e.consume(R),F):D(R)}function X(R){return R===null||Bt(R)?(e.exit("htmlFlowData"),Y(R)):(e.consume(R),X)}function Y(R){return e.exit("htmlFlow"),t(R)}}function Imt(e,t,n){const r=this;return o;function o(i){return Bt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):n(i)}function s(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}function Emt(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Qv,t,n)}}const Dmt={name:"htmlText",tokenize:Mmt};function Mmt(e,t,n){const r=this;let o,s,i;return a;function a(F){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(F),c}function c(F){return F===33?(e.consume(F),u):F===47?(e.consume(F),N):F===63?(e.consume(F),v):ws(F)?(e.consume(F),j):n(F)}function u(F){return F===45?(e.consume(F),d):F===91?(e.consume(F),s=0,g):ws(F)?(e.consume(F),w):n(F)}function d(F){return F===45?(e.consume(F),m):n(F)}function f(F){return F===null?n(F):F===45?(e.consume(F),h):Bt(F)?(i=f,$(F)):(e.consume(F),f)}function h(F){return F===45?(e.consume(F),m):f(F)}function m(F){return F===62?L(F):F===45?h(F):f(F)}function g(F){const X="CDATA[";return F===X.charCodeAt(s++)?(e.consume(F),s===X.length?b:g):n(F)}function b(F){return F===null?n(F):F===93?(e.consume(F),x):Bt(F)?(i=b,$(F)):(e.consume(F),b)}function x(F){return F===93?(e.consume(F),y):b(F)}function y(F){return F===62?L(F):F===93?(e.consume(F),y):b(F)}function w(F){return F===null||F===62?L(F):Bt(F)?(i=w,$(F)):(e.consume(F),w)}function v(F){return F===null?n(F):F===63?(e.consume(F),C):Bt(F)?(i=v,$(F)):(e.consume(F),v)}function C(F){return F===62?L(F):v(F)}function N(F){return ws(F)?(e.consume(F),_):n(F)}function _(F){return F===45||os(F)?(e.consume(F),_):k(F)}function k(F){return Bt(F)?(i=k,$(F)):Cn(F)?(e.consume(F),k):L(F)}function j(F){return F===45||os(F)?(e.consume(F),j):F===47||F===62||ur(F)?I(F):n(F)}function I(F){return F===47?(e.consume(F),L):F===58||F===95||ws(F)?(e.consume(F),T):Bt(F)?(i=I,$(F)):Cn(F)?(e.consume(F),I):L(F)}function T(F){return F===45||F===46||F===58||F===95||os(F)?(e.consume(F),T):E(F)}function E(F){return F===61?(e.consume(F),D):Bt(F)?(i=E,$(F)):Cn(F)?(e.consume(F),E):I(F)}function D(F){return F===null||F===60||F===61||F===62||F===96?n(F):F===34||F===39?(e.consume(F),o=F,A):Bt(F)?(i=D,$(F)):Cn(F)?(e.consume(F),D):(e.consume(F),P)}function A(F){return F===o?(e.consume(F),o=void 0,M):F===null?n(F):Bt(F)?(i=A,$(F)):(e.consume(F),A)}function P(F){return F===null||F===34||F===39||F===60||F===61||F===96?n(F):F===47||F===62||ur(F)?I(F):(e.consume(F),P)}function M(F){return F===47||F===62||ur(F)?I(F):n(F)}function L(F){return F===62?(e.consume(F),e.exit("htmlTextData"),e.exit("htmlText"),t):n(F)}function $(F){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),z}function z(F){return Cn(F)?Mn(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):W(F)}function W(F){return e.enter("htmlTextData"),i(F)}}const V3={name:"labelEnd",resolveAll:Fmt,resolveTo:Omt,tokenize:Lmt},Amt={tokenize:$mt},Rmt={tokenize:zmt},Pmt={tokenize:Bmt};function Fmt(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&ci(e,0,e.length,n),e}function Omt(e,t){let n=e.length,r=0,o,s,i,a;for(;n--;)if(o=e[n][1],s){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(s=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(i=n);const c={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[i-2][1].start}};return a=[["enter",c,t],["enter",u,t]],a=Pi(a,e.slice(s+1,s+r+3)),a=Pi(a,[["enter",d,t]]),a=Pi(a,Vj(t.parser.constructs.insideSpan.null,e.slice(s+r+4,i-3),t)),a=Pi(a,[["exit",d,t],e[i-2],e[i-1],["exit",u,t]]),a=Pi(a,e.slice(i+1)),a=Pi(a,[["exit",c,t]]),ci(e,s,e.length,a),e}function Lmt(e,t,n){const r=this;let o=r.events.length,s,i;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){s=r.events[o][1];break}return a;function a(h){return s?s._inactive?f(h):(i=r.parser.defined.includes(wa(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),c):n(h)}function c(h){return h===40?e.attempt(Amt,d,i?d:f)(h):h===91?e.attempt(Rmt,d,i?u:f)(h):i?d(h):f(h)}function u(h){return e.attempt(Pmt,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function $mt(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),o}function o(f){return ur(f)?sy(e,s)(f):s(f)}function s(f){return f===41?d(f):Gde(e,i,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function i(f){return ur(f)?sy(e,c)(f):d(f)}function a(f){return n(f)}function c(f){return f===34||f===39||f===40?Kde(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return ur(f)?sy(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function zmt(e,t,n){const r=this;return o;function o(a){return Yde.call(r,e,s,i,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(wa(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function i(a){return n(a)}}function Bmt(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),o}function o(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Vmt={name:"labelStartImage",resolveAll:V3.resolveAll,tokenize:Hmt};function Hmt(e,t,n){const r=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),i):n(a)}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Umt={name:"labelStartLink",resolveAll:V3.resolveAll,tokenize:qmt};function qmt(e,t,n){const r=this;return o;function o(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),s}function s(i){return i===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(i):t(i)}}const ED={name:"lineEnding",tokenize:Wmt};function Wmt(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Mn(e,t,"linePrefix")}}const z1={name:"thematicBreak",tokenize:Gmt};function Gmt(e,t,n){let r=0,o;return s;function s(u){return e.enter("thematicBreak"),i(u)}function i(u){return o=u,a(u)}function a(u){return u===o?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||Bt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===o?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Cn(u)?Mn(e,a,"whitespace")(u):a(u))}}const As={continuation:{tokenize:Xmt},exit:Jmt,name:"list",tokenize:Zmt},Ymt={partial:!0,tokenize:ept},Kmt={partial:!0,tokenize:Qmt};function Zmt(e,t,n){const r=this,o=r.events[r.events.length-1];let s=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,i=0;return a;function a(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:TR(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(z1,n,u)(m):u(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return TR(m)&&++i<10?(e.consume(m),c):(!r.interrupt||i<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),u(m)):n(m)}function u(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Qv,r.interrupt?n:d,e.attempt(Ymt,h,f))}function d(m){return r.containerState.initialBlankLine=!0,s++,h(m)}function f(m){return Cn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),h):n(m)}function h(m){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function Xmt(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Qv,o,s);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Mn(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Cn(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Kmt,t,i)(a))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Mn(e,e.attempt(As,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Qmt(e,t,n){const r=this;return Mn(e,o,"listItemIndent",r.containerState.size+1);function o(s){const i=r.events[r.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(s):n(s)}}function Jmt(e){e.exit(this.containerState.type)}function ept(e,t,n){const r=this;return Mn(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(s){const i=r.events[r.events.length-1];return!Cn(s)&&i&&i[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const mU={name:"setextUnderline",resolveTo:tpt,tokenize:npt};function tpt(e,t){let n=e.length,r,o,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",s?(e.splice(o,0,["enter",i,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=i,e.push(["exit",i,t]),e}function npt(e,t,n){const r=this;let o;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),o=u,i(u)):n(u)}function i(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===o?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),Cn(u)?Mn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Bt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const rpt={tokenize:opt};function opt(e){const t=this,n=e.attempt(Qv,r,e.attempt(this.parser.constructs.flowInitial,o,Mn(e,e.attempt(this.parser.constructs.flow,o,e.attempt(cmt,o)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const spt={resolveAll:Xde()},ipt=Zde("string"),apt=Zde("text");function Zde(e){return{resolveAll:Xde(e==="text"?lpt:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],s=n.attempt(o,i,a);return i;function i(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=o[d];let h=-1;if(f)for(;++h<f.length;){const m=f[h];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function Xde(e){return t;function t(n,r){let o=-1,s;for(;++o<=n.length;)s===void 0?n[o]&&n[o][1].type==="data"&&(s=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==s+2&&(n[s][1].end=n[o-1][1].end,n.splice(s+2,o-s-2),o=s+2),s=void 0);return e?e(n,r):n}}function lpt(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],o=t.sliceStream(r);let s=o.length,i=-1,a=0,c;for(;s--;){const u=o[s];if(typeof u=="string"){for(i=u.length;u.charCodeAt(i-1)===32;)a++,i--;if(i)break;i=-1}else if(u===-2)c=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?i:r.start._bufferIndex+i,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const cpt={42:As,43:As,45:As,48:As,49:As,50:As,51:As,52:As,53:As,54:As,55:As,56:As,57:As,62:Hde},upt={91:mmt},dpt={[-2]:ID,[-1]:ID,32:ID},fpt={35:vmt,42:z1,45:[mU,z1],60:Nmt,61:mU,95:z1,96:fU,126:fU},hpt={38:qde,92:Ude},mpt={[-5]:ED,[-4]:ED,[-3]:ED,33:Vmt,38:qde,42:IR,60:[Uht,Dmt],91:Umt,92:[xmt,Ude],93:V3,95:IR,96:rmt},ppt={null:[IR,spt]},gpt={null:[42,95]},bpt={null:[]},xpt=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:gpt,contentInitial:upt,disable:bpt,document:cpt,flow:fpt,flowInitial:dpt,insideSpan:ppt,string:hpt,text:mpt},Symbol.toStringTag,{value:"Module"}));function ypt(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},s=[];let i=[],a=[];const c={attempt:k(N),check:k(_),consume:w,enter:v,exit:C,interrupt:k(_,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:m,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&s.push(t),u;function f(E){return i=Pi(i,E),x(),i[i.length-1]!==null?[]:(j(t,0),u.events=Vj(s,u.events,u),u.events)}function h(E,D){return wpt(m(E),D)}function m(E){return vpt(i,E)}function g(){const{_bufferIndex:E,_index:D,line:A,column:P,offset:M}=r;return{_bufferIndex:E,_index:D,line:A,column:P,offset:M}}function b(E){o[E.line]=E.column,T()}function x(){let E;for(;r._index<i.length;){const D=i[r._index];if(typeof D=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<D.length;)y(D.charCodeAt(r._bufferIndex));else y(D)}}function y(E){d=d(E)}function w(E){Bt(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,T()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=E}function v(E,D){const A=D||{};return A.type=E,A.start=g(),u.events.push(["enter",A,u]),a.push(A),A}function C(E){const D=a.pop();return D.end=g(),u.events.push(["exit",D,u]),D}function N(E,D){j(E,D.from)}function _(E,D){D.restore()}function k(E,D){return A;function A(P,M,L){let $,z,W,F;return Array.isArray(P)?Y(P):"tokenize"in P?Y([P]):X(P);function X(U){return V;function V(H){const q=H!==null&&U[H],B=H!==null&&U.null,G=[...Array.isArray(q)?q:q?[q]:[],...Array.isArray(B)?B:B?[B]:[]];return Y(G)(H)}}function Y(U){return $=U,z=0,U.length===0?L:R(U[z])}function R(U){return V;function V(H){return F=I(),W=U,U.partial||(u.currentConstruct=U),U.name&&u.parser.constructs.disable.null.includes(U.name)?O():U.tokenize.call(D?Object.assign(Object.create(u),D):u,c,K,O)(H)}}function K(U){return E(W,F),M}function O(U){return F.restore(),++z<$.length?R($[z]):L}}}function j(E,D){E.resolveAll&&!s.includes(E)&&s.push(E),E.resolve&&ci(u.events,D,u.events.length-D,E.resolve(u.events.slice(D),u)),E.resolveTo&&(u.events=E.resolveTo(u.events,u))}function I(){const E=g(),D=u.previous,A=u.currentConstruct,P=u.events.length,M=Array.from(a);return{from:P,restore:L};function L(){r=E,u.previous=D,u.currentConstruct=A,u.events.length=P,a=M,T()}}function T(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function vpt(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,s=t.end._bufferIndex;let i;if(n===o)i=[e[n].slice(r,s)];else{if(i=e.slice(n,o),r>-1){const a=i[0];typeof a=="string"?i[0]=a.slice(r):i.shift()}s>0&&i.push(e[o].slice(0,s))}return i}function wpt(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const s=e[n];let i;if(typeof s=="string")i=s;else switch(s){case-5:{i="\r";break}case-4:{i=`
|
|
1303
1303
|
`;break}case-3:{i=`\r
|
|
1304
1304
|
`;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&o)continue;i=" ";break}default:i=String.fromCharCode(s)}o=s===-2,r.push(i)}return r.join("")}function Spt(e){const r={constructs:Bde([xpt,...(e||{}).extensions||[]]),content:o(Oht),defined:[],document:o($ht),flow:o(rpt),lazy:{},string:o(ipt),text:o(apt)};return r;function o(s){return i;function i(a){return ypt(r,s,a)}}}function Cpt(e){for(;!Wde(e););return e}const pU=/[\0\t\n\r]/g;function Npt(){let e=1,t="",n=!0,r;return o;function o(s,i,a){const c=[];let u,d,f,h,m;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(i||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(pU.lastIndex=f,u=pU.exec(s),h=u&&u.index!==void 0?u.index:s.length,m=s.charCodeAt(h),!u){t=s.slice(f);break}if(m===10&&f===h&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<h&&(c.push(s.slice(f,h)),e+=h-f),m){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const _pt=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kpt(e){return e.replace(_pt,jpt)}function jpt(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),s=o===120||o===88;return Vde(n.slice(s?2:1),s?16:10)}return B3(n)||e}const Qde={}.hasOwnProperty;function Tpt(e,t,n){return typeof t!="string"&&(n=t,t=void 0),Ipt(n)(Cpt(Spt(n).document().write(Npt()(e,t,!0))))}function Ipt(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ye),autolinkProtocol:I,autolinkEmail:I,atxHeading:s(ie),blockQuote:s(B),characterEscape:I,characterReference:I,codeFenced:s(G),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(G,i),codeText:s(Z,i),codeTextData:I,data:I,codeFlowValue:I,definition:s(J),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(oe),hardBreakEscape:s(ue),hardBreakTrailing:s(ue),htmlFlow:s(xe,i),htmlFlowData:I,htmlText:s(xe,i),htmlTextData:I,image:s(te),label:i,link:s(ye),listItem:s(Ie),listItemValue:h,listOrdered:s(se,f),listUnordered:s(se),paragraph:s(fe),reference:R,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(ie),strong:s(me),thematicBreak:s(ee)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:q,autolinkProtocol:H,blockQuote:c(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:O,characterReferenceMarkerNumeric:O,characterReferenceValue:U,characterReference:V,codeFenced:c(x),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:T,codeIndented:c(y),codeText:c(M),codeTextData:T,data:T,definition:c(),definitionDestinationString:C,definitionLabelString:w,definitionTitleString:v,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(A),htmlFlowData:T,htmlText:c(P),htmlTextData:T,image:c($),label:W,labelText:z,lineEnding:E,link:c(L),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:K,resourceDestinationString:F,resourceTitleString:X,resource:Y,setextHeading:c(j),setextHeadingLineSequence:k,setextHeadingText:_,strong:c(),thematicBreak:c()}};Jde(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(re){let ne={type:"root",children:[]};const ce={stack:[ne],tokenStack:[],config:t,enter:a,exit:u,buffer:i,resume:d,data:n},ae=[];let Ne=-1;for(;++Ne<re.length;)if(re[Ne][1].type==="listOrdered"||re[Ne][1].type==="listUnordered")if(re[Ne][0]==="enter")ae.push(Ne);else{const Ee=ae.pop();Ne=o(re,Ee,Ne)}for(Ne=-1;++Ne<re.length;){const Ee=t[re[Ne][0]];Qde.call(Ee,re[Ne][1].type)&&Ee[re[Ne][1].type].call(Object.assign({sliceSerialize:re[Ne][2].sliceSerialize},ce),re[Ne][1])}if(ce.tokenStack.length>0){const Ee=ce.tokenStack[ce.tokenStack.length-1];(Ee[1]||gU).call(ce,void 0,Ee[0])}for(ne.position={start:Wc(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:Wc(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<t.transforms.length;)ne=t.transforms[Ne](ne)||ne;return ne}function o(re,ne,ce){let ae=ne-1,Ne=-1,Ee=!1,Ve,ge,pe,$e;for(;++ae<=ce;){const Fe=re[ae];switch(Fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Fe[0]==="enter"?Ne++:Ne--,$e=void 0;break}case"lineEndingBlank":{Fe[0]==="enter"&&(Ve&&!$e&&!Ne&&!pe&&(pe=ae),$e=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:$e=void 0}if(!Ne&&Fe[0]==="enter"&&Fe[1].type==="listItemPrefix"||Ne===-1&&Fe[0]==="exit"&&(Fe[1].type==="listUnordered"||Fe[1].type==="listOrdered")){if(Ve){let ze=ae;for(ge=void 0;ze--;){const Ze=re[ze];if(Ze[1].type==="lineEnding"||Ze[1].type==="lineEndingBlank"){if(Ze[0]==="exit")continue;ge&&(re[ge][1].type="lineEndingBlank",Ee=!0),Ze[1].type="lineEnding",ge=ze}else if(!(Ze[1].type==="linePrefix"||Ze[1].type==="blockQuotePrefix"||Ze[1].type==="blockQuotePrefixWhitespace"||Ze[1].type==="blockQuoteMarker"||Ze[1].type==="listItemIndent"))break}pe&&(!ge||pe<ge)&&(Ve._spread=!0),Ve.end=Object.assign({},ge?re[ge][1].start:Fe[1].end),re.splice(ge||ae,0,["exit",Ve,Fe[2]]),ae++,ce++}if(Fe[1].type==="listItemPrefix"){const ze={type:"listItem",_spread:!1,start:Object.assign({},Fe[1].start),end:void 0};Ve=ze,re.splice(ae,0,["enter",ze,Fe[2]]),ae++,ce++,pe=void 0,$e=!0}}}return re[ne][1]._spread=Ee,ce}function s(re,ne){return ce;function ce(ae){a.call(this,re(ae),ae),ne&&ne.call(this,ae)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(re,ne,ce){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([ne,ce||void 0]),re.position={start:Wc(ne.start),end:void 0}}function c(re){return ne;function ne(ce){re&&re.call(this,ce),u.call(this,ce)}}function u(re,ne){const ce=this.stack.pop(),ae=this.tokenStack.pop();if(ae)ae[0].type!==re.type&&(ne?ne.call(this,re,ae[0]):(ae[1]||gU).call(this,re,ae[0]));else throw new Error("Cannot close `"+re.type+"` ("+oy({start:re.start,end:re.end})+"): it’s not open");ce.position.end=Wc(re.end)}function d(){return z3(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(re){if(this.data.expectingFirstListItemValue){const ne=this.stack[this.stack.length-2];ne.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function m(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.lang=re}function g(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.meta=re}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.value=re.replace(/(\r?\n|\r)$/g,"")}function w(re){const ne=this.resume(),ce=this.stack[this.stack.length-1];ce.label=ne,ce.identifier=wa(this.sliceSerialize(re)).toLowerCase()}function v(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.title=re}function C(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.url=re}function N(re){const ne=this.stack[this.stack.length-1];if(!ne.depth){const ce=this.sliceSerialize(re).length;ne.depth=ce}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function k(re){const ne=this.stack[this.stack.length-1];ne.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function I(re){const ce=this.stack[this.stack.length-1].children;let ae=ce[ce.length-1];(!ae||ae.type!=="text")&&(ae=we(),ae.position={start:Wc(re.start),end:void 0},ce.push(ae)),this.stack.push(ae)}function T(re){const ne=this.stack.pop();ne.value+=this.sliceSerialize(re),ne.position.end=Wc(re.end)}function E(re){const ne=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ce=ne.children[ne.children.length-1];ce.position.end=Wc(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ne.type)&&(I.call(this,re),T.call(this,re))}function D(){this.data.atHardBreak=!0}function A(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.value=re}function P(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.value=re}function M(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.value=re}function L(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function $(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function z(re){const ne=this.sliceSerialize(re),ce=this.stack[this.stack.length-2];ce.label=kpt(ne),ce.identifier=wa(ne).toLowerCase()}function W(){const re=this.stack[this.stack.length-1],ne=this.resume(),ce=this.stack[this.stack.length-1];if(this.data.inReference=!0,ce.type==="link"){const ae=re.children;ce.children=ae}else ce.alt=ne}function F(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.url=re}function X(){const re=this.resume(),ne=this.stack[this.stack.length-1];ne.title=re}function Y(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function K(re){const ne=this.resume(),ce=this.stack[this.stack.length-1];ce.label=ne,ce.identifier=wa(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function O(re){this.data.characterReferenceType=re.type}function U(re){const ne=this.sliceSerialize(re),ce=this.data.characterReferenceType;let ae;ce?(ae=Vde(ne,ce==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ae=B3(ne);const Ne=this.stack[this.stack.length-1];Ne.value+=ae}function V(re){const ne=this.stack.pop();ne.position.end=Wc(re.end)}function H(re){T.call(this,re);const ne=this.stack[this.stack.length-1];ne.url=this.sliceSerialize(re)}function q(re){T.call(this,re);const ne=this.stack[this.stack.length-1];ne.url="mailto:"+this.sliceSerialize(re)}function B(){return{type:"blockquote",children:[]}}function G(){return{type:"code",lang:null,meta:null,value:""}}function Z(){return{type:"inlineCode",value:""}}function J(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function oe(){return{type:"emphasis",children:[]}}function ie(){return{type:"heading",depth:0,children:[]}}function ue(){return{type:"break"}}function xe(){return{type:"html",value:""}}function te(){return{type:"image",title:null,url:"",alt:null}}function ye(){return{type:"link",title:null,url:"",children:[]}}function se(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function Ie(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function fe(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function we(){return{type:"text",value:""}}function ee(){return{type:"thematicBreak"}}}function Wc(e){return{line:e.line,column:e.column,offset:e.offset}}function Jde(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Jde(e,r):Ept(e,r)}}function Ept(e,t){let n;for(n in t)if(Qde.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function gU(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+oy({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+oy({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+oy({start:t.start,end:t.end})+") is still open")}function Dpt(e){const t=this;t.parser=n;function n(r){return Tpt(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Mpt(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Apt(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -1343,4 +1343,4 @@ prismjs/prism.js:
|
|
|
1343
1343
|
More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const c=s?` (code: ${s})`:"",u=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
|
|
1344
1344
|
|
|
1345
1345
|
Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function e$({errorMessage:e}){return l.jsxs("div",{className:"flex items-start gap-2 rounded-control border border-red-300 bg-red-50/60 p-2 text-[12px] text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:[l.jsx(Vi,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"whitespace-pre-wrap break-words leading-[1.55]",children:J0t(e)})]})}function evt({error:e,resetErrorBoundary:t}){return l.jsxs("div",{className:"my-3 space-y-2 rounded-control border border-border/60 bg-muted/20 p-2.5",children:[l.jsx(e$,{errorMessage:e==null?void 0:e.message}),l.jsx("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:t,children:"Try again"})]})}function tvt({text:e,files:t}){return l.jsxs(Jfe,{who:"You",children:[e&&l.jsx("div",{className:"whitespace-pre-line text-[13px] leading-[1.55] text-foreground",children:e}),t&&t.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 pt-0.5",children:t.map(n=>l.jsx(Jdt,{file:n},n.id))})]})}function nvt({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(bft,{children:JSON.stringify(o,null,2)})]})]})}function ehe(e,t){return!e||e.role!=="assistant"?!1:(e.parts??[]).some(r=>{if(!r)return!1;switch(r.type){case"text":return typeof r.text=="string"&&r.text.trim().length>0;case"reasoning":return typeof r.text=="string"&&r.text.trim().length>0||r.state==="streaming";case"error":return!0;default:return typeof r.type=="string"&&(r.type.startsWith("tool-")||r.type==="dynamic-tool")?J3(r,t):!1}})}function nq(){return l.jsx("span",{className:"relative grid h-2 w-2 shrink-0 place-items-center",children:l.jsx("span",{className:"absolute inset-0 animate-pulse rounded-full bg-muted-foreground/70"})})}function rvt({status:e,errorMessage:t,activeToolText:n}){return n?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(nq,{}),l.jsx("span",{children:n})]}):e==="submitted"||e==="streaming"?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(nq,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(e$,{errorMessage:t}):null}function ovt(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(o=>o.type==="text"&&typeof o.text=="string"&&o.text.trim().length>0))}))==null?void 0:t.id:void 0}function svt({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,v,C;const u=ovt(n),d=e.id===u;if(e.role==="user"){const N=((y=e.parts)==null?void 0:y.filter(I=>I.type==="text"))||[],_=((w=e.parts)==null?void 0:w.filter(I=>I.type==="file"))||[],k=N.map(I=>I.text).join(`
|
|
1346
|
-
`).trim(),j=_.map((I,T)=>{var A,P;let E="",D;if((A=I.url)!=null&&A.startsWith("data:")){const M=I.url.match(/data:[^;]+;base64,(.+)/);M&&(E=M[1],(P=I.mediaType)!=null&&P.startsWith("image/")&&(D=I.url))}return{id:`${e.id||t}-file-${T}`,name:I.filename||`File ${T+1}`,size:0,type:I.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(tvt,{text:k||void 0,files:j.length>0?j:void 0})}const f=((v=e.parts)==null?void 0:v.filter(N=>N.type==="reasoning"))||[],h=f.length>0,m=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(Cc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Nc,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Pt.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(_c,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,_)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:_+1}),l.jsx(YU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${_}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,_)=>{var j;const k=`${e.id||t}-${_}`;switch(N.type){case"text":{const I=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:T,quickReplies:E}=X0t(I),D=T.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(YU,{text:T,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:A,value:P},M)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${k}-qr-${M}`))})]})]},k)}return e.role==="system"&&s?l.jsx(nvt,{text:I},k):null}case"error":{const I=N,T=I.errorText??I.error??I.message;return l.jsx("div",{className:"my-4",children:l.jsx(e$,{errorMessage:T})},k)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&J3(N,r)?l.jsx(ka,{FallbackComponent:({error:I,resetErrorBoundary:T})=>l.jsx(evt,{error:I,resetErrorBoundary:T}),children:l.jsx(W0t,{part:N,idx:k,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},k):null}});return e.role==="assistant"?ehe(e,r)?l.jsxs(Jfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const ivt=8,avt=24,lvt=20;function cvt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function the({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const b=S.useRef(null),x=S.useRef(null),y=S.useRef(e.length),w=S.useRef(!1),v=S.useRef(null),C=S.useRef(!1),N=S.useRef(g),[_,k]=S.useState(!0),[j,I]=S.useState(0),[T,E]=S.useState(avt);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=ehe(D,t),P=cvt(a,c,u,A),M=gk({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:ivt,overscan:6,gap:20,paddingEnd:P?T+lvt:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();k(X=>X===F?X:F),F&&I(0)}}),L=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,M.scrollToEnd({behavior:W})}),I(0),k(!0)},[M]);S.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,L("auto"))},[e.length,g,L]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!M.isAtEnd()&&I(F=>F+e.length-W),e.length===0&&(I(0),k(!0),w.current=!1,C.current=!1)},[e.length,M]);const $=M.getVirtualItems(),z=M.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const F=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&E(R=>R===Y?R:Y)};if(F(),typeof ResizeObserver>"u")return;const X=new ResizeObserver(F);return X.observe(W),()=>X.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:z},children:[$.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:M.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(svt,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(z-T,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(rvt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!_&&l.jsxs("button",{type:"button",onClick:()=>L("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(bo,{className:"h-3 w-3"}),"Latest",j>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:j>9?"9+":j})]})]})}function uvt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const dvt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function fvt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=S.useState(!1),[a,c]=S.useState(p.isDevEnv),[u,d]=S.useState(!1),[f,h]=S.useState("auto"),[m,g]=S.useState(!1),[b,x]=S.useState(!1),[y,w]=S.useState(0),v=n??b,{isLocalDev:C,isConsoleMode:N}=eg(),_=C||N||a,k=S.useRef(null);p.useDashboardStore(ae=>ae.dashboard.aiScopeTables),p.useDashboardStore(ae=>ae.isDashboardEditing);const j=p.useDashboardStore(ae=>ae.selectedSheetId),{setDataSource:I}=p.useEditorActions(),{setSelectedFrameId:T,setIsDashboardEditing:E}=p.useDashboardActions(),D=xL(),{clearAssistantMessageContexts:A}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:M,getFileAttachments:L}=p.useFileActions(),$=p.useFileAttachments("dashboard"),z=p.useEditorStore(ae=>ae.card.dataSource),{assistantProfile:W}=lde(),F=p.useDashboardStore(ae=>ae.handleOpenAssistantProfile),{selectedEntities:X,applyDashboardDefaultEntities:Y}=oj("dashboard"),{sendMessage:R,isLoading:K,messages:O,setMessages:U,status:V,stop:H,errorMessage:q,clearError:B}=Mdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(ae=>ae+1)},[]),Z=S.useCallback(ae=>{r==null||r(ae),n===void 0&&x(ae)},[n,r]),J=S.useCallback(()=>{Z(!v)},[v,Z]);S.useEffect(()=>{if(!v)return;function ae(Ne){Ne.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ae),()=>{window.removeEventListener("keydown",ae)}},[v,Z]);const[oe,ie]=S.useState(""),ue=ae=>{ie(ae.target.value)};async function xe({sql:ae,cardTitle:Ne,connectionId:Ee,cardType:Ve,python:ge,cardConfig:pe,dataSource:$e,customVisualPreferences:Fe,visualizationMode:ze,dynamicCardPreferences:Ze}){if(!j)return;const Je=ze==="dynamic",Ce=p.hasValidCardConfig(pe),Qe=Ee||($e==null?void 0:$e.connectionId)||"",He=$e?{...$e,connectionId:Qe||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:Qe?{connectionId:Qe,connectionType:"",mode:"database",selectedEntities:[]}:Zp,Me=!(Ce&&(!Je||(Ze==null?void 0:Ze.provenance)==="card-config"||(Ze==null?void 0:Ze.provenance)==="query_spec")),De=Me?uvt(ae):"",je=Me?ge:"",Ue={id:p.v4(),title:Ne||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Ve==="horizontalBar"?"y":"x"},...Je&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Ve,sql:De,python:je,dataSource:He,config:pe,connectionId:Qe,visualizationMode:ze,dynamicCardPreferences:Ze,customCardPreferences:Fe?{url:Fe.url,componentName:Fe.componentName,pluginChartType:Fe.pluginChartType,settings:Fe.settings,type:"component"}:void 0},mt={id:p.v4(),cards:[Ue],activeCardId:Ue.id};try{await D(j,mt,"end"),E(!0),T(mt.id)}catch(pt){console.error("Failed to add assistant visual to dashboard:",pt),rt.error(pt instanceof Error?pt.message:"Failed to prepare semantic metadata for the new visual")}}const te=ae=>{ae.preventDefault();const Ne=oe.trim();if(!Ne&&$.length===0)return;const Ee=[];Ne&&Ee.push({type:"text",text:Ne}),$.forEach(Ve=>{Ve.data&&Ee.push({type:"file",mediaType:Ve.type,filename:Ve.name,url:`data:${Ve.type};base64,${Ve.data}`})}),R({role:"user",parts:Ee}),ie(""),M("dashboard"),G()};S.useEffect(()=>{var ae;e&&((ae=k.current)==null||ae.focus())},[e]),_de({assistantType:"dashboard",status:V,isLoading:K,sendMessage:R});const{hasActiveTools:ye,activeToolText:se}=kde(O);function Ie(ae){const Ne={role:"user",parts:[{type:"text",text:ae.title+" "+ae.subtitle}]};R(Ne),G()}function fe(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}function me(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}const we=S.useCallback(async()=>{const ae=JSON.stringify(O??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ae),rt.success("Conversation copied")}catch(Ne){console.error("Failed to copy conversation",Ne),rt.error("Unable to copy conversation")}},[O]),ee=(oe==null?void 0:oe.length)===0&&(O==null?void 0:O.filter(ae=>ae.role==="user").length)===0;function re(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ne(){return l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsx(uc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Nh,{className:"size-3.5"})})}),l.jsxs(ko,{align:"end",children:[l.jsx(fa,{children:"Options"}),l.jsx(qi,{}),l.jsx(Zc,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(Zc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Zc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(qi,{}),l.jsx(fa,{children:"Dynamic Visuals"}),l.jsx(Zc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Zc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Zc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ce=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",v&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[re(),F&&l.jsxs("button",{type:"button",onClick:F,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&ne(),_&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:we,children:"Copy Conversation"}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:v?"Exit fullscreen":"Expand",onClick:J,children:v?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const ae=O.filter(Ne=>Ne.role==="assistant").map(Ne=>Ne.id).filter(Ne=>!!Ne);U([]),P("dashboard"),B(),A(ae)},children:l.jsx(oP,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Te.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(the,{messages:O,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:V,errorMessage:q,activeToolText:K&&ye?se:void 0,className:p.cn(v?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(v&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&ee&&l.jsx(Bce,{onClick:Ie,placeholders:dvt}),ee&&W&&l.jsx(cde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:fe}),l.jsx(Nde,{assistantType:"dashboard"}),l.jsx(M3,{ref:k,setInput:ie,stop:H,input:oe,handleInputChange:ue,handleSubmit:ae=>{te(ae)},isLoading:K,status:V,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(D3,{incomingSelectedEntities:X,open:m,onOpenChange:g,dataSource:z||Zp,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ae=>Y()})]});return v&&o?br.createPortal(l.jsx(Lg,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ce})}),o):ce}function hvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=gie(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);S.useEffect(()=>{if(!c||u)return;async function d(m){if(mvt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),rt.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=pvt(m);if(g!=null&&g.id){const b=hie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),rt.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function mvt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function pvt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function gvt(e,t){switch(e.interactionMode){case"drillToDetail":bvt(e,t);break;case"drillThrough":xvt(e,t);break;case"drillToURL":yvt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function bvt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function xvt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function yvt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function vvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Xi,{children:[l.jsx(cs,{children:i||"Insight Detail"}),l.jsx(Gs,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(yie,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Aie,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function wvt(){const e=p.useInteractionStore(C=>C.interactionStates),t=p.useInteractionStore(C=>C.setInteractionState),n=p.useInteractionStore(C=>C.clearLastInteractionEvent),r=p.useInteractionStore(C=>C.replaceCardWithInsight),o=p.useInteractionStore(C=>C.setPendingDrillThrough),s=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Sh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=zG((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Rie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:_})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:_})},replaceCardContent:({cardId:C,insightId:N,filters:_,contextMode:k})=>{r(C,N,_,k)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j})=>{const I={filters:C},T={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[I]},E={...p.createInitialInteractionState(),appliedClickFilters:[T],contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const _=N.lastInteractionEvent,k=`${C}-${_.interactionMode}-${_.sourceCardId}-${Date.now()}`;if(y.current.has(k))return;y.current.add(k);try{gvt(_,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(k)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[s,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(vvt,{open:g.open,onOpenChange:v,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function Svt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Cvt(t.value);return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Cvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Nvt(e){return e?`Back to ${e}`:"Back"}function _vt(){var y,w,v,C,N;const e=p.useInteractionStore(_=>_.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(_=>_.actions.goBackFromDrill),n=p.useDashboardStore(_=>_.actions.clearDrillContext),{selectDashboard:r}=Sh(),[o,s]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const _=j=>{s({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},k=()=>{a(!1)};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",k)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(v=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:v[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(_){console.error("[DrillBack] Error during back navigation:",_)}},g=()=>{n()},b=_=>{_.target.closest("button")||(a(!0),c.current={x:_.clientX-o.x,y:_.clientY-o.y})};Svt(f);const x=Nvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((_,k)=>{const j=_.field.label||_.field.name,I=String(_.value);return l.jsxs(co,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",I]},k)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Te.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(R0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function kvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function jvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=qg({id:`filter:${e.id}`,disabled:n||!t}),x={transform:bi.Translate.toString(m),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(Q5,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const rq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Tvt=[];function nhe({open:e,onOpenChange:t}){var O,U,V;const[n,r]=S.useState(!1),[o,s]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(H=>{var q;return(q=H.dashboard)==null?void 0:q.sheets}),u=p.useDashboardStore(H=>H.dashboard),d=p.useDashboardStore(H=>H.dashboardInputValues),f=p.useDashboardStore(H=>H.filterValues),h=p.useDashboardStore(H=>H.controlValues),m=p.useDashboardStore(H=>H.inlineFilterValuesMap),g=p.useDashboardStore(H=>H.cardControlValuesMap),b=p.useDashboardStore(H=>H.selectedSheetId),x=p.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=p.useDashboardStore(H=>H.isDownloadingPdf),{authToken:w,tokenProps:v}=gt(),C=c==null?void 0:c.find(H=>H.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(C),k=_&&C?C.document:void 0,j=S.useMemo(()=>_&&C?Wv(u,C.id):[],[C,_,u]),I=j.length>0,T=S.useMemo(()=>_&&C?gce(u,C.id):!1,[C,_,u]),E=S.useMemo(()=>I?j.map(Gv):(k==null?void 0:k.inputs)||Tvt,[k,j,I]),D=((U=(O=v==null?void 0:v.params)==null?void 0:O.calendarContext)==null?void 0:U.tz)||((V=v==null?void 0:v.params)==null?void 0:V.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=S.useMemo(()=>gle(E),[E]),P=S.useMemo(()=>mle(E,D),[E,D]),M=S.useMemo(()=>ple(E),[E]),L=x?x.filterValuesByInputId:P,$=x?x.controlValuesByInputId:M,z=S.useMemo(()=>_?T&&C&&k?wZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):yle(E,L,$,A,A):[],[k,E,C,_,u,g,h,f,m,d,$,L,A,D,T]),W=!!C,F=N.length>0,X=((c==null?void 0:c.length)||0)>1||_,Y=i.sheetSelection==="current"&&(!W||_&&z.length>0)||i.sheetSelection==="all"&&!F;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!F&&a(H=>({...H,sheetSelection:"current"}))},[F,e,i.sheetSelection]);const R=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){rt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){rt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){rt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!F){rt.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&_,q=H?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",B=rt.loading(q);try{if(H){if(!k||!C)throw new Error("Selected document sheet is missing document data");if(z.length>0){rt.dismiss(B),rt.error(`Set ${z.join(", ")} before exporting`);return}const Z=new Date().toISOString(),J=T?CZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(oe=>oe.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:Z,timezone:D}).snapshot:void 0;await bF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:Z}}})}else{const Z=ZJ();await IZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,Z)}rt.dismiss(B);const G=H?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";rt.success(G,{duration:2e3}),R()}catch(G){rt.dismiss(B),rt.error("Failed to download PDF",{description:z_(G,"Please try again or contact support."),descriptionClassName:$_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{s(!1)}}return l.jsx(ks,{open:e,onOpenChange:H=>{if(!H){R();return}t(!0)},children:l.jsxs(ls,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Xi,{children:[l.jsx(cs,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Gs,{className:"text-[13px] leading-5",children:_?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[X&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:rq,children:"Export scope"}),l.jsxs(Ca,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"current",id:"scope-current",disabled:!W}),_?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!F&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"all",id:"scope-all",disabled:!F}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:z.length>0?`Set ${z.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Tn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(r_,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:rq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&K()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(n_,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(Ic,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:R,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:o||y||Y,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(jc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function rhe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=S.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(jc,{className:p.cn("size-4",e)})}),l.jsx(nhe,{open:i,onOpenChange:a})]})}function oq(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Ivt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=qg({id:`control:${e.id}`,disabled:!n}),d={transform:bi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(Ale,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function sq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function iq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Evt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return iq(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=iq(t,n).filter(a=>!s.has(a));return[...o,...i]}function Dvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Mvt(e){return Cp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Cp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function aq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function Avt(e){const t={sheetId:e.selectedSheetId},n=p.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=p.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||p.getBackingDefaultSlot(e.dashboardInput)}function Rvt(e){return ohe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function ohe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=Dvt(e.dashboard,t);return FK(D_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Mvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Pvt(e,t){return"toolbar"}function Fvt(){const e=Dc("interactive"),t=p.useDashboardStore(U=>U.selectedSheetId),n=p.useDashboardStore(U=>U.dashboard.filters),r=p.useDashboardStore(U=>U.dashboard.filterLayout),o=p.useDashboardStore(U=>U.isDashboardEditing),s=p.useDashboardStore(U=>U.controlValues),i=p.useDashboardStore(U=>U.filterValues);p.useDashboardStore(U=>U.filteringCards);const a=p.useDashboardStore(U=>U.inlineFilterValuesMap),c=p.useDashboardStore(U=>U.dashboardInputValues),u=p.useInteractionStore(U=>U.clearAllClickFilters),d=p.useInteractionStore(U=>Object.entries(U.interactionStates).reduce((V,[H,q])=>{var B;return H===p.DRILL_CONTEXT_CARD_ID?V:V+(((B=q.appliedClickFilters)==null?void 0:B.length)??0)},0)),f=p.useDashboardStore(U=>U.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=lj(Gp(Hg,{activationConstraint:{distance:5}})),_=p.useDashboardStore(U=>U.dashboard),k=Rvt({dashboard:_,selectedSheetId:t}).filter(U=>Pvt(U.filter)==="toolbar"),j=ohe({dashboard:_,selectedSheetId:t}),I=k.map(U=>U.filter),T=new Map(k.map(U=>[`filter:${U.filter.id}`,U])),E=HYe(_),D=E.filter(U=>!U.hidden&&t0(U)==="toolbar"),A=E.filter(U=>!U.hidden&&t0(U)==="advanced"),P=Evt(r==null?void 0:r.toolbarItemOrder,I,D),M=new Map(I.map(U=>[`filter:${U.id}`,U])),L=new Map(D.map(U=>[`control:${U.id}`,U]));function $(U){const{active:V,over:H}=U;if(!H||V.id===H.id)return;const q=String(V.id),B=String(H.id),G=P.findIndex(ye=>ye===q),Z=P.findIndex(ye=>ye===B);if(G===-1||Z===-1)return;const J=Ug(P,G,Z);y({toolbarItemOrder:J});const oe=new Set((n||[]).map(ye=>ye.id)),ie=P.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),ue=J.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),xe=P.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),te=J.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(oq(n||[],ie,ue)),g(oq(_.controls||[],xe,te))}const z=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,F=(i==null?void 0:i.filter(U=>sq(U)).length)??0,X=j.filter(aq),Y=X.filter(U=>{const V=Avt({dashboardInput:U,dashboardInputValues:c,defaultInputValues:_.defaultInputValues,selectedSheetId:t});return(V==null?void 0:V.status)==="set"&&V.value.kind==="filter"&&sq(V.value.filterValue)}).length,R=a?Object.values(a).reduce((U,V)=>U+((V==null?void 0:V.length)??0),0):0,K=F+Y+R+d,O=()=>{w([]),X.forEach(U=>{m(U,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([U,V])=>{V==null||V.forEach(H=>{f(U,H.filterId)})})};return!I.length&&!D.length&&!A.length&&!W&&K===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(zv,{sensors:N,collisionDetection:Ov,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",z?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Bv,{items:P,strategy:jL,children:l.jsx(sR,{className:"gap-3 pr-0",wrap:z,children:P.map(U=>{const V=M.get(U);if(V){const q=T.get(U),B=q&&aq(q);return l.jsx(jvt,{filter:V,isEditing:o,storageOptions:B?{storageTarget:"dashboardInput",dashboardInput:q,sheetId:t??void 0}:void 0,inputVariableName:B?q.variableName:void 0,onUpdateFilter:B?(G,Z)=>{C({...q,variableName:(Z==null?void 0:Z.variableName)||q.variableName,filter:G})}:void 0,onRemoveFilter:B?()=>{w((i||[]).filter(G=>G.filterId!==V.id)),b(q.id)}:void 0},U)}const H=L.get(U);return H?l.jsx(Ivt,{control:H,value:s==null?void 0:s[H.id],isEditing:o,onChange:q=>x(H.id,q)},U):null})})}),A.length>0&&l.jsx(Tie,{title:"",controls:A,values:s,onChange:(U,V)=>x(U.id,V),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:O,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Te.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:K})]}),W&&l.jsx("div",{className:p.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(rhe,{})})]})})})}function she(){var me,we;const{showAssistant:e,tokenProps:t,renderMode:n}=gt(),r=kvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:o}=eg(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=Rh(s),a=sZ({displayMode:s,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=yst({initialPosition:"bottom-right"}),x=kf(ee=>ee.setFullscreen),y=kf(ee=>ee.setPanelOpen),w=kf(ee=>ee.setContainer),v=HY("dashboard"),C=UY(),N=qY("dashboard"),_=v.isOpen,k=C==="dashboard",j=p.useDashboardStore(ee=>ee.isVisualEditing),I=p.useDashboardStore(ee=>ee.themeStyle),T=Mc(),E=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.sheets}),D=p.useDashboardStore(ee=>ee.showFilters),A=p.useDashboardStore(ee=>ee.isDashboardEditing),P=p.useDashboardStore(ee=>ee.selectedSheetId),M=E==null?void 0:E.find(ee=>ee.id===P),L=p.useDashboardStore(ee=>{var re,ne,ce;return(ce=(ne=(re=ee.dashboard)==null?void 0:re.sheets)==null?void 0:ne.find(ae=>ae.id===ee.selectedSheetId))==null?void 0:ce.kind}),$=p.useDashboardStore(ee=>{var re,ne;return((ne=(re=ee.dashboard)==null?void 0:re.summary)==null?void 0:ne.position)||"top"}),z=L==="document",W=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.id}),{getDefaultSheetId:F,setDefaultSheetId:X,clearDefaultSheetId:Y}=Gq(W),[R,K]=S.useState(null),{setSelectedSheetId:O,setSheetTitle:U,addSheet:V,setSheets:H}=p.useDashboardActions();hvt(u);const{setActiveAssistantType:q}=p.useAIActions();S.useEffect(()=>{if(W){const ee=F();K(ee)}},[W,F]),S.useEffect(()=>{_?q("dashboard"):C==="dashboard"&&x(null)},[_,q,C,x]),S.useEffect(()=>{var ee;_||(ee=c.current)==null||ee.resize(0)},[_]);function B(ee){var re,ne;ee?((re=c.current)==null||re.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ne=c.current)==null||ne.resize(0),q(null))}function G(ee="dashboard"){const re={id:p.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:p.createDefaultDocumentDefinition()}:{}};V(re),O(re.id)}function Z(ee,re){if(!W)return;R===ee?(Y(),K(null),rt.success("Default sheet cleared")):(X(ee),K(ee),rt.success(`"${re}" set as default sheet`))}function J(ee){var re;ee<1?(y("dashboard",!1),x(null),q(null),(re=c.current)==null||re.resize(0)):(_||y("dashboard",!0),q("dashboard"))}function oe(){return(I==null?void 0:I.canvasTheme)==="muted"||!(I!=null&&I.canvasTheme)?"hsl(var(--semaphor-muted))":(I==null?void 0:I.canvasTheme)==="clear"?"":I==null?void 0:I.canvasTheme}const ie=(ee,re)=>{ee.dataTransfer.setData("tabIndex",re.toString())},ue=ee=>{ee.preventDefault()},xe=(ee,re)=>{const ne=ee.dataTransfer.getData("tabIndex");if(ne===re.toString())return;const ce=Array.from(E||[]),[ae]=ce.splice(parseInt(ne),1);ce.splice(re,0,ae),H(ce)},te=r===!0&&!i&&!_&&!j&&!D;function ye(){if(E&&E.length>1||A)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((ee,re)=>{const ne=P===ee.id,ce=R===ee.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:ae=>ie(ae,re),onDragOver:ue,onDrop:ae=>xe(ae,re),onClick:()=>O(ee.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ee.id,children:[ee.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(mN,{enabled:A&&ne,text:ee.title,onSave:ae=>U(ee.id,ae),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ce?"Clear default sheet":"Set as default sheet",title:ce?"Clear default sheet":"Set as default sheet",onClick:ae=>{ae.stopPropagation(),Z(ee.id,ee.title||"Sheet")},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),Z(ee.id,ee.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ne||ce?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(DW,{className:p.cn("h-3 w-3 transition-colors",ce?"fill-current text-amber-500":"text-muted-foreground")})}),A&&ne&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:ae=>{ae.stopPropagation(),f(!0)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),f(!0))},children:l.jsx(Te.X,{className:"h-3 w-3"})})]},ee.id)}),A&&l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(ko,{align:"start",className:"w-48",children:[l.jsxs(Sn,{onSelect:()=>G("dashboard"),children:[l.jsx(Yf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Sn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function se(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ee=>l.jsx(p.TabsContent,{style:{backgroundColor:oe(),...T.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(eH,{sheet:ee})},ee.id))})}function Ie(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",I==null?void 0:I.dashboardTabsContainer),onValueChange:ee=>{O(ee)},value:P||void 0,children:[ye(),$==="top"&&!z&&l.jsx($A,{}),P&&!z&&l.jsx(Fvt,{}),z?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:se()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:se()}),$==="bottom"&&!z&&l.jsx($A,{}),l.jsx(vst,{open:d,setOpen:f})]})}const fe=S.useCallback(ee=>{w("dashboard",ee)},[w]);return E?a&&P&&!z?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&z&&M?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(eH,{sheet:M})}):l.jsxs(l.Fragment,{children:[l.jsx(wvt,{}),l.jsx(_vt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(zce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(uR,{children:Ie()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(xst,{open:_,onTabClick:B,withHandle:!0,disabled:!_}),l.jsx(uR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:J,defaultSize:_?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(fvt,{open:_,setOpen:B,isFullscreen:k,onFullscreenChange:ee=>x(ee?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:fe,className:p.cn("absolute inset-0",!k&&"pointer-events-none")}),te&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",b().horizontal,b().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||B(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Fpe,{className:"h-5 w-5"})})})]})]}):null}const ihe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Ovt(d),[d]),{theme:h}=VR(),m=Lvt(h),g=S.useMemo(()=>o??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=S.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=S.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Lg,{...c,ref:u,className:i,style:a,children:s})})});ihe.displayName="AppearanceProvider";function Ovt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Lvt(e){const t=U1(e),[n,r]=S.useState(()=>$vt());return S.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const o=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!o)return;const s=()=>{r(o.matches?"dark":"light")};return s(),typeof o.addEventListener=="function"?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):((a=o.addListener)==null||a.call(o,s),()=>{var c;return(c=o.removeListener)==null?void 0:c.call(o,s)})},[t]),t==="system"?n:t}function $vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const ahe=S.createContext({openBrandStudioPreview:()=>{}}),zvt=ahe.Provider;function Bvt(){return S.useContext(ahe)}function Vvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=U1(t),[s,i]=S.useState(()=>Hvt(n)||o),a=S.useCallback(u=>{const d=U1(u);Uvt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(_q.Provider,{...r,value:c,children:e})}function Hvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=U1(t,"system");return n===t?n:null}catch{return null}}function Uvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const qvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function t$({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=gt(),s=M0(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=S.useState(!1),[d,f]=S.useState(null),[h,m]=S.useState(null),[g,b]=S.useState(null),[x,y]=S.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Rn({queryKey:PG({resourceType:Zr.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});S.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),S.useEffect(()=>{v.data!==void 0&&y({scopeKey:w,appearance:v.data})},[v.data,w]);const C=(x==null?void 0:x.scopeKey)===w?x.appearance:null,N=i!==void 0?i:v.data!==void 0?v.data:C,_=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),k=S.useCallback(()=>{f(g??h??_),u(!0)},[g,h,_]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const I=S.useMemo(()=>({openBrandStudioPreview:k}),[k]),T=g??h??e;return l.jsx(Vvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(zvt,{value:I,children:l.jsx(ihe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:T,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(S.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(qvt,{appearance:d,onDraftChange:b,onSave:A=>{m(A),b(A),f(A)},onCancel:j})})})]})})})})}function lhe({children:e,preferences:t}){const{currentUser:n}=Zi(),r=S.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(MG.Provider,{value:r,children:l.jsx(nj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Wvt(e=2e3,t=500){const n=Xme(),[r,o]=S.useState(!1),[s,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),S.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function n$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=Wvt(e,t);return S.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function che(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:e,children:[l.jsx(n$,{componentType:"dashboard",componentId:e.id}),l.jsx(t$,{appearance:e.appearance,children:l.jsx(lhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(_P,{...e,type:"dashboard",children:l.jsx(she,{})})})})})]})})}function Gvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[o,s]=S.useState(),i=S.useCallback(()=>{var m,g,b;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return S.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function Yvt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=eg(),r=Rh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=Gvt([t,s,r]);return S.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Hs,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(X5,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Te.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Kvt(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(Yvt,{filter:r}),l.jsx(Gk,{filter:r})]},r.id))}):null}function Zvt(){var i;const e=p.useDashboardStore(a=>a.dashboard),t=p.useDashboardStore(a=>a.selectedSheetId),n=p.useDashboardStore(a=>a.isVisualEditing),r=p.useDashboardStore(a=>a.isDashboardEditing),o=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),s=p.isDocumentSheet(o);return l.jsx("div",{role:"dashboard-plus-main",className:p.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!s&&l.jsx(Kvt,{}),l.jsx(she,{})]})})}const Xvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-B7OObDNl.js"))),Qvt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-DWygSAp3.js"))),Jvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-DNixjalS.js")));function ewt({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:n,children:[l.jsx(n$,{componentType:"surfboard",componentId:n.id}),l.jsxs(t$,{appearance:s,children:[l.jsx(Vbe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(lhe,{preferences:i,children:[o&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Jvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Xvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(_P,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Qvt,{})}),l.jsx(Zvt,{})]})})})]})]})]})]})})}var twt=Object.defineProperty,nwt=(e,t,n)=>t in e?twt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZS=(e,t,n)=>nwt(e,typeof t!="symbol"?t+"":t,n);const rwt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},owt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},swt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function iwt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function uhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const awt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=uhe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},lwt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},cwt={stringify:e=>e,parse:e=>e},HD={string:cwt,number:lwt,boolean:rwt,function:owt,method:awt,json:swt},Gb=Symbol.for("r2wc.render"),XS=Symbol.for("r2wc.connected"),Ld=Symbol.for("r2wc.context"),Qs=Symbol.for("r2wc.props");function uwt(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=iwt(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),ZS(this,s,!0),ZS(this,o),ZS(this,r,{}),ZS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qs].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?HD[y]:null;if(y==="method"){const v=uhe(b);Object.defineProperty(this[Qs].container,v,{enumerable:!0,configurable:!0,get(){return this[Qs][v]},set(C){this[Qs][v]=C,this[Gb]()}}),this[Qs][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qs][g]=w.parse(x,b,this))}for(const g of a)this[Qs][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[XS]=!0,this[Gb]()}disconnectedCallback(){this[XS]=!1,this[Ld]&&n.unmount(this[Ld]),delete this[Ld]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?HD[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qs][y]=v.parse(x,g,this),this[Gb]())}[(s=XS,o=Ld,r=Qs,Gb)](){this[XS]&&(this[Ld]?n.update(this[Ld],this[Qs]):this[Ld]=n.mount(this.container,e,this[Qs]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qs][m]},set(x){this[Qs][m]=x;const y=b?HD[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Gb]()}})}return h}function dwt(e,t,n){const r=Ohe.createRoot(e),o=S.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function fwt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function hwt({root:e}){e.unmount()}function mwt(e,t={}){return uwt(e,t,{mount:dwt,update:fwt,unmount:hwt})}const pwt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},gwt=mwt(che,{props:pwt}),bwt=S.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(XL,{context:t})," "]})}),dhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),xwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),ywt=Array.from(dhe).join(", "),vwt=3,wwt="Self-heal",Swt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Cwt({card:e}){var W,F,X,Y,R;const[t,n]=S.useState({}),{authToken:r}=gt(),o=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:s}=p.useAppearance(),i=S.useMemo(()=>Tv(s),[s]),a=p.useEditorStore(K=>K.frame),c=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:m}=Vh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(F=m==null?void 0:m.visuals)==null?void 0:F.find(K=>{var O;return K.name===((O=f.customCardPreferences)==null?void 0:O.componentName)}),b=Iv(f,g)??"single",x=S.useMemo(()=>nL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(O=>(O==null?void 0:O.id)===e.id);return K<0?-1:Xy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Jm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),v=S.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,b]),{data:C}=O_(v),N=p.useInteractionStore(K=>K.interactionStates),_=p.useDashboardStore(K=>{var O;return(O=K.dashboard)==null?void 0:O.id}),k=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),I=p.useDashboardStore(K=>K.selectedSheetId),T=S.useMemo(()=>J5({card:e,sheetId:I||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,I,c,u,d]),{cardFilters:E,cardFilterValues:D}=S.useMemo(()=>W0({card:e,interactionStates:N,currentDashboardId:_,filters:k,filterValues:j,selectedSheetId:I}),[e,N,_,k,j,I]),A=S.useCallback((K,O)=>{const U=oL(O);n(V=>({...V,[K]:U}))},[]),P=(X=f.customCardPreferences)==null?void 0:X.componentName,M=P?h(P):null,L=fN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>tL(x),[x]),z=S.useMemo(()=>$.map((K,O)=>Jm(K,O,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(S.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[M&&b==="single"&&l.jsx(M,{editing:!0,params:o,theme:i,settings:L,cardMetadata:Wse({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T}),M&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,O)=>{if(!K)return null;const U=Xy(K,O),V=Jm(K,U,g==null?void 0:g.slots);return l.jsx(_5,{onDataChange:A,card:K,effectiveCardType:V},`${K.id}-${U}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(M,{editing:!0,onDataChange:A,...sL({configCard:f,slotOrderedCards:$,slotTypes:z,multiInputData:t,params:o,theme:i,chartSettings:L,filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T})})})]})]},(R=f.customCardPreferences)==null?void 0:R.componentName)}):null}const Nwt=S.memo(Cwt,(e,t)=>{var n,r,o,s,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((o=e.card.customCardPreferences)==null?void 0:o.slotSettings)===((s=t.card.customCardPreferences)==null?void 0:s.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),_wt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var fhe=["PageUp","PageDown"],hhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],mhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Qg="Slider",[OR,kwt,jwt]=p.createCollection(Qg),[phe]=p.createContextScope(Qg,[jwt]),[Twt,Zj]=phe(Qg),ghe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),v=i==="horizontal"?Iwt:Ewt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(E)}}),_=Q.useRef(C);function k(E){const D=Pwt(C,E);T(E,D)}function j(E){T(E,y.current)}function I(){const E=_.current[y.current];C[y.current]!==E&&h(C)}function T(E,D,{commit:A}={commit:!1}){const P=$wt(s),M=zwt(Math.round((E-r)/s)*s+r,P),L=p.clamp(M,[r,o]);N(($=[])=>{const z=Awt($,L,D);if(Lwt(z,c*s)){y.current=z.indexOf(L);const W=String(z)!==String($);return W&&A&&h(z),W?z:$}else return $})}return l.jsx(Twt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(OR.Provider,{scope:e.__scopeSlider,children:l.jsx(OR.Slot,{scope:e.__scopeSlider,children:l.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(_.current=C)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:k,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:I,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(o,C.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const M=fhe.includes(E.key)||E.shiftKey&&hhe.includes(E.key)?10:1,L=y.current,$=C[L],z=s*M*D;T($+z,L,{commit:!0})}}})})})})});ghe.displayName=Qg;var[bhe,xhe]=phe(Qg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Iwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,v=>h(v)),g=Q.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],k=r$(N,y?[n,r]:[r,n]);return g.current=C,k(v-C.left)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(yhe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const C=w(v.clientX);i==null||i(C)},onSlideMove:v=>{const C=w(v.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:v=>{const N=mhe[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),Ewt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=r$(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(yhe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=mhe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),yhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Zj(Qg,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):fhe.concat(hhe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),vhe="SliderTrack",whe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(vhe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});whe.displayName=vhe;var LR="SliderRange",She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(LR,n),s=xhe(LR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>_he(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});She.displayName=LR;var $R="SliderThumb",Che=Q.forwardRef((e,t)=>{const n=kwt(e.__scopeSlider),[r,o]=Q.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(Dwt,{...e,ref:s,index:i})}),Dwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=Zj($R,n),a=xhe($R,n),[c,u]=Q.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:_he(m,i.min,i.max),b=Rwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?Fwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(OR.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Nhe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Che.displayName=$R;var Mwt="RadioBubbleInput",Nhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=Q.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return Q.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});Nhe.displayName=Mwt;function Awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function _he(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function Rwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Pwt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Fwt(e,t,n){const r=e/2,s=r$([0,50],[0,r]);return(r-s(t)*n)*n}function Owt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Lwt(e,t){if(t>0){const n=Owt(e);return Math.min(...n)>=t}return!0}function r$(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function $wt(e){return(String(e).split(".")[1]||"").length}function zwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var khe=ghe,Bwt=whe,Vwt=She,Hwt=Che;const jhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(khe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Bwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Vwt,{className:"absolute h-full bg-primary"})}),l.jsx(Hwt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));jhe.displayName=khe.displayName;const The=["SUN","MON","TUE","WED","THU","FRI","SAT"],Uwt=The.reduce((e,t,n)=>({...e,[t]:n}),{}),$l={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function qwt(e){if(!e||!e.trim())return{...$l};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...$l,isCustom:!0};const[o,s,i,a,c]=r,u=Number(o),d=Number(s);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...$l,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...$l,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Uwt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...$l,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...$l,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...$l,repeats:"monthly",hour:d,minute:u}:{...$l,hour:d,minute:u,isCustom:!0}}function Wwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((o,s)=>o-s).map(o=>The[o]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Ihe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,o=t.toString().padStart(2,"0");return`${r}:${o} ${n}`}function Gwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Ywt(e){if(e.length===7)return"every day";const t=e.slice().sort((o,s)=>o-s);if(t.length===5&&t.every(o=>o>=1&&o<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(o=>r[o]).join(", ")}function Kwt(e,t,n,r){const o=Ihe(e.hour,e.minute),s=Gwt(t);let i;if(e.isCustom)i=`Custom schedule · ${o} ${s}`;else switch(e.repeats){case"daily":i=`Daily at ${o} ${s}`;break;case"weekly":i=`Weekly · ${Ywt(e.weekdays)} at ${o} ${s}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${o} ${s}`;break;case"monthly":i=`Monthly on the 1st at ${o} ${s}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Zwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=HL;exports.AccordionContent=c0;exports.AccordionItem=a0;exports.AccordionTrigger=l0;exports.AddDataPicker=D3;exports.AggregateTable=Sk;exports.Alert=wF;exports.AlertDescription=SF;exports.AlertDialog=jh;exports.AlertDialogAction=ld;exports.AlertDialogCancel=cd;exports.AlertDialogContent=rd;exports.AlertDialogDescription=ad;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=od;exports.AlertDialogTitle=id;exports.AlertDialogTrigger=lye;exports.AlertTitle=JZ;exports.ArrowDown=bo;exports.ArrowDownIcon=Yqe;exports.ArrowLeft=R0;exports.ArrowRight=t_;exports.ArrowUp=Ro;exports.ArrowUpIcon=Zqe;exports.AssistantContextEntityControls=SR;exports.AssistantVirtualizedMessages=the;exports.AtSign=Qq;exports.AxisConfigurator=lg;exports.Badge=co;exports.Bell=e1;exports.BookType=eW;exports.BulletChartIcon=Gfe;exports.COMMON_TIMEZONES=Zwt;exports.CSS=bi;exports.CalculatedFieldEditor=ole;exports.Calculator=nW;exports.Calendar=ii;exports.Calendar$1=j1;exports.CalendarRange=rW;exports.Card=cy;exports.CardContent=JR;exports.CardHeader=QR;exports.CardSummary=WA;exports.CardTitle=Jp;exports.ChartArea=h2;exports.ChartColumnIncreasing=oW;exports.ChartColumnStacked=sW;exports.ChartJsVisual=vv;exports.ChartLine=iW;exports.ChartNoAxesGantt=lW;exports.ChartPie=cW;exports.ChartScatter=uW;exports.ChatInputWithContext=M3;exports.Checkbox=Tn;exports.ChevronLeft=Ch;exports.ChevronsUpDown=hW;exports.Circle=eP;exports.CircleAlert=Wf;exports.CircleCheck=mW;exports.CircleHelp=pW;exports.Clock=tP;exports.CodeHighlighter=Hf;exports.CodeXml=t1;exports.Collapsible=Cc;exports.CollapsibleContent=_c;exports.CollapsibleTrigger=Nc;exports.ColorField=Ri;exports.Command=hj;exports.CommandEmpty=pj;exports.CommandGroup=gj;exports.CommandInput=DL;exports.CommandItem=bj;exports.CommandList=mj;exports.CommandSeparator=Nae;exports.ComparisonMetadataBadge=Nee;exports.Container=_P;exports.ControlDefaultValueEditor=kle;exports.ControlDefinitionOptionsEditor=_le;exports.ControlIdInput=wle;exports.ControlVisibilitySettings=att;exports.Copy=Du;exports.CopyButton=Iu;exports.CopyPlus=p2;exports.Cross2Icon=eWe;exports.CustomFilterPopover=X5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=kJ;exports.DEFAULT_SCHEDULE_VM=$l;exports.Dashboard=che;exports.DashboardCard=Eie;exports.DashboardCreateDialogBase=lY;exports.DashboardExportDialog=nhe;exports.DashboardPlus=ewt;exports.DashboardWC=gwt;exports.DataTableConditionalFormattingSettings=mce;exports.DataTablePagination=dk;exports.Database=Bi;exports.DateRangePicker=D5;exports.DefaultChatTransport=C3;exports.Dialog=ks;exports.DialogContent=ls;exports.DialogDescription=Gs;exports.DialogFooter=Ic;exports.DialogHeader=Xi;exports.DialogTitle=cs;exports.DialogTrigger=sY;exports.DisplayPreferencesProvider=nj;exports.DndContext=zv;exports.Donut=gW;exports.Download=jc;exports.DownloadPdf=rhe;exports.DragOverlay=uae;exports.DropdownMenu=Bo;exports.DropdownMenuCheckboxItem=Zc;exports.DropdownMenuContent=ko;exports.DropdownMenuItem=Sn;exports.DropdownMenuLabel=fa;exports.DropdownMenuRadioGroup=pbe;exports.DropdownMenuRadioItem=DG;exports.DropdownMenuSeparator=qi;exports.DropdownMenuSub=gP;exports.DropdownMenuSubContent=c_;exports.DropdownMenuSubTrigger=l_;exports.DropdownMenuTrigger=Vo;exports.EMPTY_DATA_SOURCE=Zp;exports.Editable=mN;exports.EditableText=Hs;exports.EditorCustomVisual=Nwt;exports.Ellipsis=ui;exports.EllipsisVertical=Nh;exports.ErrorBoundary=ka;exports.ExportError=pg;exports.ExternalLink=xp;exports.EyeOff=n_;exports.Fallback=ej;exports.FallbackVisual=Jy;exports.FeedbackCategory=td;exports.FeedbackDialog=S0;exports.FieldsList=XL;exports.FieldsSection=bwt;exports.FileCode=bW;exports.FileSpreadsheet=xW;exports.FileText=di;exports.Filter=Gf;exports.FilterComponent=Gk;exports.FilterInfo=VA;exports.FilterableFieldsPanel=ile;exports.Globe=_h;exports.Grid3x3=g2;exports.GripVertical=Tc;exports.HEATMAP_PRESET_PALETTES=CM;exports.Hash=yW;exports.House=vW;exports.HoverCard=gg;exports.HoverCardContent=Vu;exports.HoverCardTrigger=bg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=dhe;exports.INLINE_ALLOWED_TOOL_LIST=ywt;exports.INLINE_BLOCKED_MUTATING_TOOLS=xwt;exports.IconButton=uc;exports.IconForFieldType=R1;exports.InfoHover=yL;exports.InlineFilterBar=vie;exports.KPICard=Ku;exports.KeyboardSensor=Lv;exports.Layers=P0;exports.LayoutDashboard=Yf;exports.Link=nP;exports.LoadingDots=Uu;exports.Lock=r_;exports.MAX_SELF_HEAL_ATTEMPTS=vwt;exports.Map=CW;exports.Markdown=cfe;exports.MatrixTableVisual=wk;exports.MdStackedLineChart=qfe;exports.MultiInputEmptyRenderer=_5;exports.PYTHON_DEFAULT_CODE=BR;exports.PanelResizeHandle=Rj;exports.Paperclip=NW;exports.PenLine=b2;exports.Pencil=x2;exports.PendingMessagesDisplay=Nde;exports.PersistedDynamicVisual=tj;exports.PiChartPolar=Bfe;exports.Pin=kW;exports.PinOff=_W;exports.PivotTableTanstack=Og;exports.Placeholders=Bce;exports.Play=jW;exports.Plus=kr;exports.PointerSensor=Hg;exports.Progress=I3;exports.RECOVERABLE_SQL_ERROR_CODES=Swt;exports.Radar=TW;exports.RadioGroup=Ca;exports.RadioGroupItem=Co;exports.RefreshCw=Kf;exports.ResizableHandle=bst;exports.ResizablePanel=uR;exports.ResizablePanelGroup=zce;exports.ResourceEditDialog=$Y;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=wwt;exports.SeedQuestions=cde;exports.SemaphorContext=D0;exports.SemaphorContextProvider=YR;exports.SemaphorQueryClient=Wq;exports.SemaphorReadyIndicator=n$;exports.SemaphorStyleWrapper=Lg;exports.Send=IW;exports.Settings=rP;exports.Settings2=F0;exports.Share2=EW;exports.ShareDialog=LY;exports.Sheet=fee;exports.SheetContent=SO;exports.SheetDescription=NO;exports.SheetHeader=mee;exports.SheetTitle=CO;exports.SheetTrigger=lFe;exports.Slider=jhe;exports.SortableContext=Bv;exports.Sparkles=Z1;exports.Square=sP;exports.SquarePen=oP;exports.Star=DW;exports.StructuralParticipantSelector=Sle;exports.SummaryCard=$A;exports.TABLE_PRESENTATION_DEFAULT_STYLE=ju;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Oi;exports.TableBody=Bu;exports.TableCell=An;exports.TableColumnVisibilitySettings=nce;exports.TableHead=to;exports.TableHeader=Lh;exports.TablePresentationSettings=oce;exports.TableRow=Sr;exports.TableSkeleton=vL;exports.TableVisual=Hu;exports.TbChartBubble=Vfe;exports.TbChartFunnel=Hfe;exports.TbChartTreemap=Ufe;exports.TextCard=Hp;exports.Textarea=Ih;exports.TiSortNumerically=Wfe;exports.Toggle=Qk;exports.Tornado=MW;exports.Trash2=hl;exports.TreePalm=aP;exports.TrendingUp=AW;exports.TriangleAlert=Vi;exports.TypeGlyph=Av;exports.UXProvider=t$;exports.User=RW;exports.Users=s_;exports.applyFilterOverridesToDashboardInputSlots=vZ;exports.areContextEntitiesEqual=Jn;exports.areEntitiesJoined=DJ;exports.arrayMove=Ug;exports.buildCardControlUsageById=ctt;exports.buildCustomCardTheme=Tv;exports.buildDashboardCardExecutionSnapshot=yZ;exports.buildDashboardControlUsageById=ltt;exports.buildDashboardExecutionSnapshot=pF;exports.buildDashboardInputExecutionSnapshot=wu;exports.buildDashboardSheetsInputExecutionSnapshot=SZ;exports.buildDashboardStructuralParticipantIdsByControlId=Ile;exports.buildFilterFieldMeta=OL;exports.buildFilterSemanticContext=LL;exports.buildInlineFilterNodes=J5;exports.buildMultiInputCustomVisualProps=sL;exports.buildScheduleExpr=Wwt;exports.buildSchedulePreview=Kwt;exports.buildSlotOrderedCards=tL;exports.calculateContextAwareFilters=W0;exports.calculateFieldState=hO;exports.canUserAccessVisuals=m0e;exports.canUserCreateDashboards=VY;exports.canUserEdit=d0e;exports.canUserManageDashboards=h0e;exports.canUserManageGroups=p0e;exports.canUserUseFilters=f0e;exports.cancelExport=XRe;exports.chartSupportsDataLabels=CQ;exports.chartSupportsLegend=wQ;exports.chartTypes=Kj;exports.cleanupKpiMetricComparisonMode=Mae;exports.cloneDeep=$s;exports.cloneLinkedFrameWithSourceMapping=fYe;exports.closestCenter=Ov;exports.commitSharedCalculatedFields=Gd;exports.createAssistantConversationId=Am;exports.createAssistantRequestId=ade;exports.createCardsFromSlots=jWe;exports.createChartConfig=mg;exports.createDashboardControlInputFromControl=oot;exports.createDefaultGlobalDateFilter=k1e;exports.createExport=XJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=fdt;exports.doesStoredFilterMatchField=Yp;exports.downloadDocumentPdf=bF;exports.downloadPdf=IZ;exports.extractSqlParamReferences=Aoe;exports.extractTableMetadata=FL;exports.fieldAlreadyExists=AJ;exports.findCustomVisualConfigCard=rL;exports.findDashboardFrameById=h1e;exports.flexRender=Bs;exports.formatDisplayFormula=tJe;exports.formatFileSize=ePe;exports.formatFilterLine=tX;exports.formatTimeLabel=Ihe;exports.getAutoDetectedChartIcon=T0t;exports.getChartGridStyle=e_e;exports.getChartIconByType=I0t;exports.getColorForValue=z2;exports.getConfigSlotExpectedType=kWe;exports.getCoreRowModel=lk;exports.getCustomVisualInputCards=nL;exports.getDateFormatOptionsForGranularity=s0;exports.getDefaultAxisConfig=V2;exports.getDefaultChartColors=Ph;exports.getDefaultDataLabelsConfig=rv;exports.getDefaultExportFormat=xX;exports.getDefaultFilterSql=F5;exports.getDefaultLegendConfig=ZF;exports.getDefaultRunningTotalPartitionByFieldIds=ey;exports.getDocumentSectionEditorCard=zet;exports.getDocumentSheetDashboardInputs=Wv;exports.getDownloadUrl=ZRe;exports.getEffectiveCardTypeForSlot=Jm;exports.getEntityIcon=qN;exports.getErrorMessage=Kue;exports.getExportStatus=KRe;exports.getExports=YRe;exports.getExpressionFieldKind=Xu;exports.getFieldExpressionAnnotation=$L;exports.getFilterCount=yN;exports.getGlobalDateFilter=Ah;exports.getGlobalDateFilterCoverage=yi;exports.getGranularityOptionsForFieldType=r3;exports.getKeys=cr;exports.getMatrixVisualLoadingState=vk;exports.getMetricDisplayLabel=gRe;exports.getNewField=LJ;exports.getObjectDiff=kq;exports.getPaginationRowModel=ck;exports.getRoleBasedDisplayOverrides=BY;exports.getRunningTotalOrderByCandidates=NQe;exports.getSelectedDateFilterColumn=Poe;exports.getSheetScopedFilterValues=py;exports.getSlotDefinitionForIndex=eL;exports.getSlotExpectedChartType=Zk;exports.getSlotIndexForCard=Xy;exports.getSortedRowModel=uee;exports.getSupportedExportFormats=bX;exports.getTableConditionalFormattingColumnOptions=lce;exports.getTableOutputColumnOptions=cce;exports.getTablePageSizeOptions=YJ;exports.handleAggregationChange=HA;exports.handleAggregationLabelChange=xie;exports.hasFlatTableTotalsBehavior=NCe;exports.hasMatrixResultData=av;exports.horizontalListSortingStrategy=jL;exports.isCalculatedFilterField=i0;exports.isCardSummaryVisibleOnCard=iL;exports.isCustomVisualConfigCard=OA;exports.isDefaultColor=ACe;exports.isEligibleFlatTableTotalsCard=rg;exports.isExportComplete=JRe;exports.isExportInProgress=QRe;exports.isInAiScopeArray=ddt;exports.isManagedCalculatedExpressionField=ya;exports.isMetricTransformEnabled=SQe;exports.isPromiseLike=wR;exports.isSubtotalEnabledAggregateTable=PL;exports.isSupportedDocumentTableCardType=Bet;exports.lastAssistantMessageIsCompleteWithToolCalls=que;exports.merge=fl;exports.mergeAxisConfig=H2;exports.normalizeConditionalFormatting=lF;exports.normalizeContextFormatMode=aX;exports.normalizeDashboardInputVariableName=A0;exports.normalizeMultiInputPayload=oL;exports.parseScheduleExpr=qwt;exports.pivotData=Z0;exports.prepareFeedbackData=Yj;exports.purify=bA;exports.reindexSlotCards=_We;exports.remarkGfm=Ofe;exports.removeFromScopeArray=hdt;exports.resolveDashboardInputContext=_l;exports.resolveDomainCalculatedFieldForEdit=ZJe;exports.resolveMultiInputType=Iv;exports.resolveMultiInputTypeFromVisual=TWe;exports.resolveTablePageSize=sk;exports.resolveTablePresentationStyle=MO;exports.sanitizeAIScope=Yue;exports.saveCalculatedFieldToCardScope=tR;exports.saveCalculatedFieldToSharedScope=sle;exports.saveCalculatedFieldToSheetScope=nR;exports.seedSemanticMetricFormatDefaults=Rae;exports.setTableColumnVisibility=eee;exports.setupEditorWithCard=L_;exports.showAllTableColumns=oPe;exports.showJoinRequiredNotification=MJ;exports.sortByColumnsToSortState=Ree;exports.sortStateToSortByColumns=Pee;exports.sortableKeyboardCoordinates=IL;exports.supportsMetricTransformForMetric=Aae;exports.supportsTableConditionalFormatting=sce;exports.toEntityArray=xa;exports.ue=rt;exports.useActiveExports=C0e;exports.useActiveToolStatus=kde;exports.useAddFrameWithFreshSemanticExecutionPayload=xL;exports.useAddNewFrame=zie;exports.useAssistantContainer=qY;exports.useAssistantContextEntities=oj;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=HY;exports.useAssistantProfile=lde;exports.useAutoSubmitQueue=_de;exports.useBrandStudioPreview=Bvt;exports.useCard=TRe;exports.useCardFilterValues=zJ;exports.useCardSummary=aL;exports.useChat=Gue;exports.useColumns=ML;exports.useCreateVisualWithFrame=dxe;exports.useCurrentUserInfo=Zi;exports.useCustomVisual=Vh;exports.useCustomVisualsQuery=Z5;exports.useDashboardAppearance=Mc;exports.useDashboardById=zG;exports.useDashboardPreferences=eg;exports.useDashboardQuery=M0;exports.useDashboardStructuralParticipants=Ele;exports.useDashboardSummary=tie;exports.useDataColumns=Fae;exports.useDateFilterHook=i7e;exports.useDebounce=Yx;exports.useDefaultDashboardMutation=AG;exports.useDisplayPreferences=Nl;exports.useDroppable=cae;exports.useEditorAside=xj;exports.useEditorCardQuery=O_;exports.useEnsureReactGlobals=loe;exports.useExportActions=WY;exports.useExportStore=b_;exports.useFieldManagement=Pae;exports.useFilterableFields=Iae;exports.useFullscreenAssistant=UY;exports.useGroupMembers=hye;exports.useGroups=EY;exports.useHasDashboardId=GY;exports.useInProgressExportsCount=N0e;exports.useJoinabilityMap=RL;exports.useManagementActions=Sh;exports.useManagementStore=$o;exports.useMutation=ss;exports.usePivotTableConfig=Oh;exports.usePluginQuery=Bse;exports.useQuery=Rn;exports.useQueryClient=Xr;exports.useReactTable=uk;exports.useResolveExistingFrameSemanticExecutionPayload=gYe;exports.useResourceManagement=xP;exports.useResourceUpdateState=BG;exports.useScopedFields=Tae;exports.useSelectedVisual=epe;exports.useSemaphorContext=gt;exports.useSensor=Gp;exports.useSensors=lj;exports.useSortable=qg;exports.useStarredChartsStore=_wt;exports.useSurfaceAppearance=Dc;exports.useTableQueryState=_ee;exports.useTextFilterHook=b7e;exports.useTheme=VR;exports.useTopoJson=sv;exports.useUnifiedUsers=CP;exports.useUpdateResource=FG;exports.useUpdateVisualMutation=fxe;exports.useUserPreferences=cY;exports.useVisualById=d_;exports.useVisualManagement=uxe;exports.validateFieldForChartType=Dae;exports.verticalListSortingStrategy=TL;
|
|
1346
|
+
`).trim(),j=_.map((I,T)=>{var A,P;let E="",D;if((A=I.url)!=null&&A.startsWith("data:")){const M=I.url.match(/data:[^;]+;base64,(.+)/);M&&(E=M[1],(P=I.mediaType)!=null&&P.startsWith("image/")&&(D=I.url))}return{id:`${e.id||t}-file-${T}`,name:I.filename||`File ${T+1}`,size:0,type:I.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(tvt,{text:k||void 0,files:j.length>0?j:void 0})}const f=((v=e.parts)==null?void 0:v.filter(N=>N.type==="reasoning"))||[],h=f.length>0,m=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(Cc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Nc,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Pt.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(_c,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,_)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:_+1}),l.jsx(YU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${_}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,_)=>{var j;const k=`${e.id||t}-${_}`;switch(N.type){case"text":{const I=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:T,quickReplies:E}=X0t(I),D=T.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(YU,{text:T,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:A,value:P},M)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${k}-qr-${M}`))})]})]},k)}return e.role==="system"&&s?l.jsx(nvt,{text:I},k):null}case"error":{const I=N,T=I.errorText??I.error??I.message;return l.jsx("div",{className:"my-4",children:l.jsx(e$,{errorMessage:T})},k)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&J3(N,r)?l.jsx(ka,{FallbackComponent:({error:I,resetErrorBoundary:T})=>l.jsx(evt,{error:I,resetErrorBoundary:T}),children:l.jsx(W0t,{part:N,idx:k,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},k):null}});return e.role==="assistant"?ehe(e,r)?l.jsxs(Jfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const ivt=8,avt=24,lvt=20;function cvt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function the({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const b=S.useRef(null),x=S.useRef(null),y=S.useRef(e.length),w=S.useRef(!1),v=S.useRef(null),C=S.useRef(!1),N=S.useRef(g),[_,k]=S.useState(!0),[j,I]=S.useState(0),[T,E]=S.useState(avt);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=ehe(D,t),P=cvt(a,c,u,A),M=gk({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:ivt,overscan:6,gap:20,paddingEnd:P?T+lvt:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();k(X=>X===F?X:F),F&&I(0)}}),L=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,M.scrollToEnd({behavior:W})}),I(0),k(!0)},[M]);S.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,L("auto"))},[e.length,g,L]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!M.isAtEnd()&&I(F=>F+e.length-W),e.length===0&&(I(0),k(!0),w.current=!1,C.current=!1)},[e.length,M]);const $=M.getVirtualItems(),z=M.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const F=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&E(R=>R===Y?R:Y)};if(F(),typeof ResizeObserver>"u")return;const X=new ResizeObserver(F);return X.observe(W),()=>X.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:z},children:[$.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:M.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(svt,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(z-T,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(rvt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!_&&l.jsxs("button",{type:"button",onClick:()=>L("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(bo,{className:"h-3 w-3"}),"Latest",j>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:j>9?"9+":j})]})]})}function uvt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const dvt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function fvt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=S.useState(!1),[a,c]=S.useState(p.isDevEnv),[u,d]=S.useState(!1),[f,h]=S.useState("auto"),[m,g]=S.useState(!1),[b,x]=S.useState(!1),[y,w]=S.useState(0),v=n??b,{isLocalDev:C,isConsoleMode:N}=eg(),_=C||N||a,k=S.useRef(null);p.useDashboardStore(ae=>ae.dashboard.aiScopeTables),p.useDashboardStore(ae=>ae.isDashboardEditing);const j=p.useDashboardStore(ae=>ae.selectedSheetId),{setDataSource:I}=p.useEditorActions(),{setSelectedFrameId:T,setIsDashboardEditing:E}=p.useDashboardActions(),D=xL(),{clearAssistantMessageContexts:A}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:M,getFileAttachments:L}=p.useFileActions(),$=p.useFileAttachments("dashboard"),z=p.useEditorStore(ae=>ae.card.dataSource),{assistantProfile:W}=lde(),F=p.useDashboardStore(ae=>ae.handleOpenAssistantProfile),{selectedEntities:X,applyDashboardDefaultEntities:Y}=oj("dashboard"),{sendMessage:R,isLoading:K,messages:O,setMessages:U,status:V,stop:H,errorMessage:q,clearError:B}=Mdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(ae=>ae+1)},[]),Z=S.useCallback(ae=>{r==null||r(ae),n===void 0&&x(ae)},[n,r]),J=S.useCallback(()=>{Z(!v)},[v,Z]);S.useEffect(()=>{if(!v)return;function ae(Ne){Ne.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ae),()=>{window.removeEventListener("keydown",ae)}},[v,Z]);const[oe,ie]=S.useState(""),ue=ae=>{ie(ae.target.value)};async function xe({sql:ae,cardTitle:Ne,connectionId:Ee,cardType:Ve,python:ge,cardConfig:pe,dataSource:$e,customVisualPreferences:Fe,visualizationMode:ze,dynamicCardPreferences:Ze}){if(!j)return;const Je=ze==="dynamic",Ce=p.hasValidCardConfig(pe),Qe=Ee||($e==null?void 0:$e.connectionId)||"",He=$e?{...$e,connectionId:Qe||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:Qe?{connectionId:Qe,connectionType:"",mode:"database",selectedEntities:[]}:Zp,Me=!(Ce&&(!Je||(Ze==null?void 0:Ze.provenance)==="card-config"||(Ze==null?void 0:Ze.provenance)==="query_spec")),De=Me?uvt(ae):"",je=Me?ge:"",Ue={id:p.v4(),title:Ne||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Ve==="horizontalBar"?"y":"x"},...Je&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Ve,sql:De,python:je,dataSource:He,config:pe,connectionId:Qe,visualizationMode:ze,dynamicCardPreferences:Ze,customCardPreferences:Fe?{url:Fe.url,componentName:Fe.componentName,pluginChartType:Fe.pluginChartType,settings:Fe.settings,type:"component"}:void 0},mt={id:p.v4(),cards:[Ue],activeCardId:Ue.id};try{await D(j,mt,"end"),E(!0),T(mt.id)}catch(pt){console.error("Failed to add assistant visual to dashboard:",pt),rt.error(pt instanceof Error?pt.message:"Failed to prepare semantic metadata for the new visual")}}const te=ae=>{ae.preventDefault();const Ne=oe.trim();if(!Ne&&$.length===0)return;const Ee=[];Ne&&Ee.push({type:"text",text:Ne}),$.forEach(Ve=>{Ve.data&&Ee.push({type:"file",mediaType:Ve.type,filename:Ve.name,url:`data:${Ve.type};base64,${Ve.data}`})}),R({role:"user",parts:Ee}),ie(""),M("dashboard"),G()};S.useEffect(()=>{var ae;e&&((ae=k.current)==null||ae.focus())},[e]),_de({assistantType:"dashboard",status:V,isLoading:K,sendMessage:R});const{hasActiveTools:ye,activeToolText:se}=kde(O);function Ie(ae){const Ne={role:"user",parts:[{type:"text",text:ae.title+" "+ae.subtitle}]};R(Ne),G()}function fe(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}function me(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}const we=S.useCallback(async()=>{const ae=JSON.stringify(O??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ae),rt.success("Conversation copied")}catch(Ne){console.error("Failed to copy conversation",Ne),rt.error("Unable to copy conversation")}},[O]),ee=(oe==null?void 0:oe.length)===0&&(O==null?void 0:O.filter(ae=>ae.role==="user").length)===0;function re(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ne(){return l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsx(uc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Nh,{className:"size-3.5"})})}),l.jsxs(ko,{align:"end",children:[l.jsx(fa,{children:"Options"}),l.jsx(qi,{}),l.jsx(Zc,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(Zc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Zc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(qi,{}),l.jsx(fa,{children:"Dynamic Visuals"}),l.jsx(Zc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Zc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Zc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ce=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",v&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[re(),F&&l.jsxs("button",{type:"button",onClick:F,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&ne(),_&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:we,children:"Copy Conversation"}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:v?"Exit fullscreen":"Expand",onClick:J,children:v?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const ae=O.filter(Ne=>Ne.role==="assistant").map(Ne=>Ne.id).filter(Ne=>!!Ne);U([]),P("dashboard"),B(),A(ae)},children:l.jsx(oP,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Te.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(the,{messages:O,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:V,errorMessage:q,activeToolText:K&&ye?se:void 0,className:p.cn(v?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(v&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&ee&&l.jsx(Bce,{onClick:Ie,placeholders:dvt}),ee&&W&&l.jsx(cde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:fe}),l.jsx(Nde,{assistantType:"dashboard"}),l.jsx(M3,{ref:k,setInput:ie,stop:H,input:oe,handleInputChange:ue,handleSubmit:ae=>{te(ae)},isLoading:K,status:V,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(D3,{incomingSelectedEntities:X,open:m,onOpenChange:g,dataSource:z||Zp,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ae=>Y()})]});return v&&o?br.createPortal(l.jsx(Lg,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ce})}),o):ce}function hvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=gie(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);S.useEffect(()=>{if(!c||u)return;async function d(m){if(mvt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),rt.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=pvt(m);if(g!=null&&g.id){const b=hie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),rt.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function mvt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function pvt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function gvt(e,t){switch(e.interactionMode){case"drillToDetail":bvt(e,t);break;case"drillThrough":xvt(e,t);break;case"drillToURL":yvt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function bvt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function xvt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function yvt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function vvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Xi,{children:[l.jsx(cs,{children:i||"Insight Detail"}),l.jsx(Gs,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(yie,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Aie,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function wvt(){const e=p.useInteractionStore(C=>C.interactionStates),t=p.useInteractionStore(C=>C.setInteractionState),n=p.useInteractionStore(C=>C.clearLastInteractionEvent),r=p.useInteractionStore(C=>C.replaceCardWithInsight),o=p.useInteractionStore(C=>C.setPendingDrillThrough),s=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Sh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=zG((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Rie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:_})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:_})},replaceCardContent:({cardId:C,insightId:N,filters:_,contextMode:k})=>{r(C,N,_,k)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j})=>{const I={filters:C},T={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[I]},E={...p.createInitialInteractionState(),appliedClickFilters:[T],contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const _=N.lastInteractionEvent,k=`${C}-${_.interactionMode}-${_.sourceCardId}-${Date.now()}`;if(y.current.has(k))return;y.current.add(k);try{gvt(_,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(k)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[s,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(vvt,{open:g.open,onOpenChange:v,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function Svt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Cvt(t.value);return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Cvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Nvt(e){return e?`Back to ${e}`:"Back"}function _vt(){var y,w,v,C,N;const e=p.useInteractionStore(_=>_.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(_=>_.actions.goBackFromDrill),n=p.useDashboardStore(_=>_.actions.clearDrillContext),{selectDashboard:r}=Sh(),[o,s]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const _=j=>{s({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},k=()=>{a(!1)};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",k)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(v=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:v[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(_){console.error("[DrillBack] Error during back navigation:",_)}},g=()=>{n()},b=_=>{_.target.closest("button")||(a(!0),c.current={x:_.clientX-o.x,y:_.clientY-o.y})};Svt(f);const x=Nvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((_,k)=>{const j=_.field.label||_.field.name,I=String(_.value);return l.jsxs(co,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",I]},k)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Te.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(R0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function kvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function jvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=qg({id:`filter:${e.id}`,disabled:n||!t}),x={transform:bi.Translate.toString(m),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(Q5,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const rq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Tvt=[];function nhe({open:e,onOpenChange:t}){var O,U,V;const[n,r]=S.useState(!1),[o,s]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(H=>{var q;return(q=H.dashboard)==null?void 0:q.sheets}),u=p.useDashboardStore(H=>H.dashboard),d=p.useDashboardStore(H=>H.dashboardInputValues),f=p.useDashboardStore(H=>H.filterValues),h=p.useDashboardStore(H=>H.controlValues),m=p.useDashboardStore(H=>H.inlineFilterValuesMap),g=p.useDashboardStore(H=>H.cardControlValuesMap),b=p.useDashboardStore(H=>H.selectedSheetId),x=p.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=p.useDashboardStore(H=>H.isDownloadingPdf),{authToken:w,tokenProps:v}=gt(),C=c==null?void 0:c.find(H=>H.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(C),k=_&&C?C.document:void 0,j=S.useMemo(()=>_&&C?Wv(u,C.id):[],[C,_,u]),I=j.length>0,T=S.useMemo(()=>_&&C?gce(u,C.id):!1,[C,_,u]),E=S.useMemo(()=>I?j.map(Gv):(k==null?void 0:k.inputs)||Tvt,[k,j,I]),D=((U=(O=v==null?void 0:v.params)==null?void 0:O.calendarContext)==null?void 0:U.tz)||((V=v==null?void 0:v.params)==null?void 0:V.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=S.useMemo(()=>gle(E),[E]),P=S.useMemo(()=>mle(E,D),[E,D]),M=S.useMemo(()=>ple(E),[E]),L=x?x.filterValuesByInputId:P,$=x?x.controlValuesByInputId:M,z=S.useMemo(()=>_?T&&C&&k?wZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):yle(E,L,$,A,A):[],[k,E,C,_,u,g,h,f,m,d,$,L,A,D,T]),W=!!C,F=N.length>0,X=((c==null?void 0:c.length)||0)>1||_,Y=i.sheetSelection==="current"&&(!W||_&&z.length>0)||i.sheetSelection==="all"&&!F;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!F&&a(H=>({...H,sheetSelection:"current"}))},[F,e,i.sheetSelection]);const R=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){rt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){rt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){rt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!F){rt.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&_,q=H?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",B=rt.loading(q);try{if(H){if(!k||!C)throw new Error("Selected document sheet is missing document data");if(z.length>0){rt.dismiss(B),rt.error(`Set ${z.join(", ")} before exporting`);return}const Z=new Date().toISOString(),J=T?CZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(oe=>oe.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:Z,timezone:D}).snapshot:void 0;await bF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:Z}}})}else{const Z=ZJ();await IZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,Z)}rt.dismiss(B);const G=H?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";rt.success(G,{duration:2e3}),R()}catch(G){rt.dismiss(B),rt.error("Failed to download PDF",{description:z_(G,"Please try again or contact support."),descriptionClassName:$_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{s(!1)}}return l.jsx(ks,{open:e,onOpenChange:H=>{if(!H){R();return}t(!0)},children:l.jsxs(ls,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Xi,{children:[l.jsx(cs,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Gs,{className:"text-[13px] leading-5",children:_?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[X&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:rq,children:"Export scope"}),l.jsxs(Ca,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"current",id:"scope-current",disabled:!W}),_?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!F&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"all",id:"scope-all",disabled:!F}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:z.length>0?`Set ${z.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Tn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(r_,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:rq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&K()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(n_,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(Ic,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:R,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:o||y||Y,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(jc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function rhe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=S.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(jc,{className:p.cn("size-4",e)})}),l.jsx(nhe,{open:i,onOpenChange:a})]})}function oq(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Ivt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=qg({id:`control:${e.id}`,disabled:!n}),d={transform:bi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(Ale,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function sq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function iq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Evt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return iq(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=iq(t,n).filter(a=>!s.has(a));return[...o,...i]}function Dvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Mvt(e){return Cp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Cp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function aq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function Avt(e){const t={sheetId:e.selectedSheetId},n=p.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=p.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||p.getBackingDefaultSlot(e.dashboardInput)}function Rvt(e){return ohe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function ohe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=Dvt(e.dashboard,t);return FK(D_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Mvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Pvt(e,t){return"toolbar"}function Fvt(){const e=Dc("interactive"),t=p.useDashboardStore(U=>U.selectedSheetId),n=p.useDashboardStore(U=>U.dashboard.filters),r=p.useDashboardStore(U=>U.dashboard.filterLayout),o=p.useDashboardStore(U=>U.isDashboardEditing),s=p.useDashboardStore(U=>U.controlValues),i=p.useDashboardStore(U=>U.filterValues);p.useDashboardStore(U=>U.filteringCards);const a=p.useDashboardStore(U=>U.inlineFilterValuesMap),c=p.useDashboardStore(U=>U.dashboardInputValues),u=p.useInteractionStore(U=>U.clearAllClickFilters),d=p.useInteractionStore(U=>Object.entries(U.interactionStates).reduce((V,[H,q])=>{var B;return H===p.DRILL_CONTEXT_CARD_ID?V:V+(((B=q.appliedClickFilters)==null?void 0:B.length)??0)},0)),f=p.useDashboardStore(U=>U.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=lj(Gp(Hg,{activationConstraint:{distance:5}})),_=p.useDashboardStore(U=>U.dashboard),k=Rvt({dashboard:_,selectedSheetId:t}).filter(U=>Pvt(U.filter)==="toolbar"),j=ohe({dashboard:_,selectedSheetId:t}),I=k.map(U=>U.filter),T=new Map(k.map(U=>[`filter:${U.filter.id}`,U])),E=HYe(_),D=E.filter(U=>!U.hidden&&t0(U)==="toolbar"),A=E.filter(U=>!U.hidden&&t0(U)==="advanced"),P=Evt(r==null?void 0:r.toolbarItemOrder,I,D),M=new Map(I.map(U=>[`filter:${U.id}`,U])),L=new Map(D.map(U=>[`control:${U.id}`,U]));function $(U){const{active:V,over:H}=U;if(!H||V.id===H.id)return;const q=String(V.id),B=String(H.id),G=P.findIndex(ye=>ye===q),Z=P.findIndex(ye=>ye===B);if(G===-1||Z===-1)return;const J=Ug(P,G,Z);y({toolbarItemOrder:J});const oe=new Set((n||[]).map(ye=>ye.id)),ie=P.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),ue=J.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),xe=P.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),te=J.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(oq(n||[],ie,ue)),g(oq(_.controls||[],xe,te))}const z=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,F=(i==null?void 0:i.filter(U=>sq(U)).length)??0,X=j.filter(aq),Y=X.filter(U=>{const V=Avt({dashboardInput:U,dashboardInputValues:c,defaultInputValues:_.defaultInputValues,selectedSheetId:t});return(V==null?void 0:V.status)==="set"&&V.value.kind==="filter"&&sq(V.value.filterValue)}).length,R=a?Object.values(a).reduce((U,V)=>U+((V==null?void 0:V.length)??0),0):0,K=F+Y+R+d,O=()=>{w([]),X.forEach(U=>{m(U,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([U,V])=>{V==null||V.forEach(H=>{f(U,H.filterId)})})};return!I.length&&!D.length&&!A.length&&!W&&K===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(zv,{sensors:N,collisionDetection:Ov,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",z?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Bv,{items:P,strategy:jL,children:l.jsx(sR,{className:"gap-3 pr-0",wrap:z,children:P.map(U=>{const V=M.get(U);if(V){const q=T.get(U),B=q&&aq(q);return l.jsx(jvt,{filter:V,isEditing:o,storageOptions:B?{storageTarget:"dashboardInput",dashboardInput:q,sheetId:t??void 0}:void 0,inputVariableName:B?q.variableName:void 0,onUpdateFilter:B?(G,Z)=>{C({...q,variableName:(Z==null?void 0:Z.variableName)||q.variableName,filter:G})}:void 0,onRemoveFilter:B?()=>{w((i||[]).filter(G=>G.filterId!==V.id)),b(q.id)}:void 0},U)}const H=L.get(U);return H?l.jsx(Ivt,{control:H,value:s==null?void 0:s[H.id],isEditing:o,onChange:q=>x(H.id,q)},U):null})})}),A.length>0&&l.jsx(Tie,{title:"",controls:A,values:s,onChange:(U,V)=>x(U.id,V),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:O,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Te.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:K})]}),W&&l.jsx("div",{className:p.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(rhe,{})})]})})})}function she(){var me,we;const{showAssistant:e,tokenProps:t,renderMode:n}=gt(),r=kvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:o}=eg(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=Rh(s),a=sZ({displayMode:s,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=yst({initialPosition:"bottom-right"}),x=kf(ee=>ee.setFullscreen),y=kf(ee=>ee.setPanelOpen),w=kf(ee=>ee.setContainer),v=HY("dashboard"),C=UY(),N=qY("dashboard"),_=v.isOpen,k=C==="dashboard",j=p.useDashboardStore(ee=>ee.isVisualEditing),I=p.useDashboardStore(ee=>ee.themeStyle),T=Mc(),E=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.sheets}),D=p.useDashboardStore(ee=>ee.showFilters),A=p.useDashboardStore(ee=>ee.isDashboardEditing),P=p.useDashboardStore(ee=>ee.selectedSheetId),M=E==null?void 0:E.find(ee=>ee.id===P),L=p.useDashboardStore(ee=>{var re,ne,ce;return(ce=(ne=(re=ee.dashboard)==null?void 0:re.sheets)==null?void 0:ne.find(ae=>ae.id===ee.selectedSheetId))==null?void 0:ce.kind}),$=p.useDashboardStore(ee=>{var re,ne;return((ne=(re=ee.dashboard)==null?void 0:re.summary)==null?void 0:ne.position)||"top"}),z=L==="document",W=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.id}),{getDefaultSheetId:F,setDefaultSheetId:X,clearDefaultSheetId:Y}=Gq(W),[R,K]=S.useState(null),{setSelectedSheetId:O,setSheetTitle:U,addSheet:V,setSheets:H}=p.useDashboardActions();hvt(u);const{setActiveAssistantType:q}=p.useAIActions();S.useEffect(()=>{if(W){const ee=F();K(ee)}},[W,F]),S.useEffect(()=>{_?q("dashboard"):C==="dashboard"&&x(null)},[_,q,C,x]),S.useEffect(()=>{var ee;_||(ee=c.current)==null||ee.resize(0)},[_]);function B(ee){var re,ne;ee?((re=c.current)==null||re.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ne=c.current)==null||ne.resize(0),q(null))}function G(ee="dashboard"){const re={id:p.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:p.createDefaultDocumentDefinition()}:{}};V(re),O(re.id)}function Z(ee,re){if(!W)return;R===ee?(Y(),K(null),rt.success("Default sheet cleared")):(X(ee),K(ee),rt.success(`"${re}" set as default sheet`))}function J(ee){var re;ee<1?(y("dashboard",!1),x(null),q(null),(re=c.current)==null||re.resize(0)):(_||y("dashboard",!0),q("dashboard"))}function oe(){return(I==null?void 0:I.canvasTheme)==="muted"||!(I!=null&&I.canvasTheme)?"hsl(var(--semaphor-muted))":(I==null?void 0:I.canvasTheme)==="clear"?"":I==null?void 0:I.canvasTheme}const ie=(ee,re)=>{ee.dataTransfer.setData("tabIndex",re.toString())},ue=ee=>{ee.preventDefault()},xe=(ee,re)=>{const ne=ee.dataTransfer.getData("tabIndex");if(ne===re.toString())return;const ce=Array.from(E||[]),[ae]=ce.splice(parseInt(ne),1);ce.splice(re,0,ae),H(ce)},te=r===!0&&!i&&!_&&!j&&!D;function ye(){if(E&&E.length>1||A)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((ee,re)=>{const ne=P===ee.id,ce=R===ee.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:ae=>ie(ae,re),onDragOver:ue,onDrop:ae=>xe(ae,re),onClick:()=>O(ee.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ee.id,children:[ee.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(mN,{enabled:A&&ne,text:ee.title,onSave:ae=>U(ee.id,ae),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ce?"Clear default sheet":"Set as default sheet",title:ce?"Clear default sheet":"Set as default sheet",onClick:ae=>{ae.stopPropagation(),Z(ee.id,ee.title||"Sheet")},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),Z(ee.id,ee.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ne||ce?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(DW,{className:p.cn("h-3 w-3 transition-colors",ce?"fill-current text-amber-500":"text-muted-foreground")})}),A&&ne&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:ae=>{ae.stopPropagation(),f(!0)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),f(!0))},children:l.jsx(Te.X,{className:"h-3 w-3"})})]},ee.id)}),A&&l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(ko,{align:"start",className:"w-48",children:[l.jsxs(Sn,{onSelect:()=>G("dashboard"),children:[l.jsx(Yf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Sn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function se(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ee=>l.jsx(p.TabsContent,{style:{backgroundColor:oe(),...T.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(eH,{sheet:ee})},ee.id))})}function Ie(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",I==null?void 0:I.dashboardTabsContainer),onValueChange:ee=>{O(ee)},value:P||void 0,children:[ye(),$==="top"&&!z&&l.jsx($A,{}),P&&!z&&l.jsx(Fvt,{}),z?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:se()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:se()}),$==="bottom"&&!z&&l.jsx($A,{}),l.jsx(vst,{open:d,setOpen:f})]})}const fe=S.useCallback(ee=>{w("dashboard",ee)},[w]);return E?a&&P&&!z?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&z&&M?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(eH,{sheet:M})}):l.jsxs(l.Fragment,{children:[l.jsx(wvt,{}),l.jsx(_vt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(zce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(uR,{children:Ie()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(xst,{open:_,onTabClick:B,withHandle:!0,disabled:!_}),l.jsx(uR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:J,defaultSize:_?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(fvt,{open:_,setOpen:B,isFullscreen:k,onFullscreenChange:ee=>x(ee?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:fe,className:p.cn("absolute inset-0",!k&&"pointer-events-none")}),te&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",b().horizontal,b().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||B(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Fpe,{className:"h-5 w-5"})})})]})]}):null}const ihe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Ovt(d),[d]),{theme:h}=VR(),m=Lvt(h),g=S.useMemo(()=>o??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=S.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=S.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Lg,{...c,ref:u,className:i,style:a,children:s})})});ihe.displayName="AppearanceProvider";function Ovt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Lvt(e){const t=U1(e),[n,r]=S.useState(()=>$vt());return S.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const o=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!o)return;const s=()=>{r(o.matches?"dark":"light")};return s(),typeof o.addEventListener=="function"?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):((a=o.addListener)==null||a.call(o,s),()=>{var c;return(c=o.removeListener)==null?void 0:c.call(o,s)})},[t]),t==="system"?n:t}function $vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const ahe=S.createContext({openBrandStudioPreview:()=>{}}),zvt=ahe.Provider;function Bvt(){return S.useContext(ahe)}function Vvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=U1(t),[s,i]=S.useState(()=>Hvt(n)||o),a=S.useCallback(u=>{const d=U1(u);Uvt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(_q.Provider,{...r,value:c,children:e})}function Hvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=U1(t,"system");return n===t?n:null}catch{return null}}function Uvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const qvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function t$({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=gt(),s=M0(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=S.useState(!1),[d,f]=S.useState(null),[h,m]=S.useState(null),[g,b]=S.useState(null),[x,y]=S.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Rn({queryKey:PG({resourceType:Zr.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});S.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),S.useEffect(()=>{v.data!==void 0&&y({scopeKey:w,appearance:v.data})},[v.data,w]);const C=(x==null?void 0:x.scopeKey)===w?x.appearance:null,N=i!==void 0?i:v.data!==void 0?v.data:C,_=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),k=S.useCallback(()=>{f(g??h??_),u(!0)},[g,h,_]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const I=S.useMemo(()=>({openBrandStudioPreview:k}),[k]),T=g??h??e;return l.jsx(Vvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(zvt,{value:I,children:l.jsx(ihe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:T,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(S.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(qvt,{appearance:d,onDraftChange:b,onSave:A=>{m(A),b(A),f(A)},onCancel:j})})})]})})})})}function lhe({children:e,preferences:t}){const{currentUser:n}=Zi(),r=S.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(MG.Provider,{value:r,children:l.jsx(nj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Wvt(e=2e3,t=500){const n=Xme(),[r,o]=S.useState(!1),[s,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),S.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function n$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=Wvt(e,t);return S.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function che(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:e,children:[l.jsx(n$,{componentType:"dashboard",componentId:e.id}),l.jsx(t$,{appearance:e.appearance,children:l.jsx(lhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(_P,{...e,type:"dashboard",children:l.jsx(she,{})})})})})]})})}function Gvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[o,s]=S.useState(),i=S.useCallback(()=>{var m,g,b;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return S.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function Yvt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=eg(),r=Rh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=Gvt([t,s,r]);return S.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Hs,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(X5,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Te.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Kvt(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(Yvt,{filter:r}),l.jsx(Gk,{filter:r})]},r.id))}):null}function Zvt(){var i;const e=p.useDashboardStore(a=>a.dashboard),t=p.useDashboardStore(a=>a.selectedSheetId),n=p.useDashboardStore(a=>a.isVisualEditing),r=p.useDashboardStore(a=>a.isDashboardEditing),o=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),s=p.isDocumentSheet(o);return l.jsx("div",{role:"dashboard-plus-main",className:p.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!s&&l.jsx(Kvt,{}),l.jsx(she,{})]})})}const Xvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-DTC1eCz0.js"))),Qvt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-CkBhJBhp.js"))),Jvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-vu38P5pV.js")));function ewt({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:n,children:[l.jsx(n$,{componentType:"surfboard",componentId:n.id}),l.jsxs(t$,{appearance:s,children:[l.jsx(Vbe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(lhe,{preferences:i,children:[o&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Jvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Xvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(_P,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Qvt,{})}),l.jsx(Zvt,{})]})})})]})]})]})]})})}var twt=Object.defineProperty,nwt=(e,t,n)=>t in e?twt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZS=(e,t,n)=>nwt(e,typeof t!="symbol"?t+"":t,n);const rwt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},owt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},swt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function iwt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function uhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const awt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=uhe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},lwt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},cwt={stringify:e=>e,parse:e=>e},HD={string:cwt,number:lwt,boolean:rwt,function:owt,method:awt,json:swt},Gb=Symbol.for("r2wc.render"),XS=Symbol.for("r2wc.connected"),Ld=Symbol.for("r2wc.context"),Qs=Symbol.for("r2wc.props");function uwt(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=iwt(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),ZS(this,s,!0),ZS(this,o),ZS(this,r,{}),ZS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qs].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?HD[y]:null;if(y==="method"){const v=uhe(b);Object.defineProperty(this[Qs].container,v,{enumerable:!0,configurable:!0,get(){return this[Qs][v]},set(C){this[Qs][v]=C,this[Gb]()}}),this[Qs][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qs][g]=w.parse(x,b,this))}for(const g of a)this[Qs][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[XS]=!0,this[Gb]()}disconnectedCallback(){this[XS]=!1,this[Ld]&&n.unmount(this[Ld]),delete this[Ld]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?HD[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qs][y]=v.parse(x,g,this),this[Gb]())}[(s=XS,o=Ld,r=Qs,Gb)](){this[XS]&&(this[Ld]?n.update(this[Ld],this[Qs]):this[Ld]=n.mount(this.container,e,this[Qs]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qs][m]},set(x){this[Qs][m]=x;const y=b?HD[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Gb]()}})}return h}function dwt(e,t,n){const r=Lhe.createRoot(e),o=S.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function fwt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function hwt({root:e}){e.unmount()}function mwt(e,t={}){return uwt(e,t,{mount:dwt,update:fwt,unmount:hwt})}const pwt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},gwt=mwt(che,{props:pwt}),bwt=S.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(XL,{context:t})," "]})}),dhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),xwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),ywt=Array.from(dhe).join(", "),vwt=3,wwt="Self-heal",Swt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Cwt({card:e}){var W,F,X,Y,R;const[t,n]=S.useState({}),{authToken:r}=gt(),o=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:s}=p.useAppearance(),i=S.useMemo(()=>Tv(s),[s]),a=p.useEditorStore(K=>K.frame),c=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:m}=Vh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(F=m==null?void 0:m.visuals)==null?void 0:F.find(K=>{var O;return K.name===((O=f.customCardPreferences)==null?void 0:O.componentName)}),b=Iv(f,g)??"single",x=S.useMemo(()=>nL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(O=>(O==null?void 0:O.id)===e.id);return K<0?-1:Xy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Jm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),v=S.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,b]),{data:C}=O_(v),N=p.useInteractionStore(K=>K.interactionStates),_=p.useDashboardStore(K=>{var O;return(O=K.dashboard)==null?void 0:O.id}),k=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),I=p.useDashboardStore(K=>K.selectedSheetId),T=S.useMemo(()=>J5({card:e,sheetId:I||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,I,c,u,d]),{cardFilters:E,cardFilterValues:D}=S.useMemo(()=>W0({card:e,interactionStates:N,currentDashboardId:_,filters:k,filterValues:j,selectedSheetId:I}),[e,N,_,k,j,I]),A=S.useCallback((K,O)=>{const U=oL(O);n(V=>({...V,[K]:U}))},[]),P=(X=f.customCardPreferences)==null?void 0:X.componentName,M=P?h(P):null,L=fN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>tL(x),[x]),z=S.useMemo(()=>$.map((K,O)=>Jm(K,O,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(S.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[M&&b==="single"&&l.jsx(M,{editing:!0,params:o,theme:i,settings:L,cardMetadata:Wse({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T}),M&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,O)=>{if(!K)return null;const U=Xy(K,O),V=Jm(K,U,g==null?void 0:g.slots);return l.jsx(_5,{onDataChange:A,card:K,effectiveCardType:V},`${K.id}-${U}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(M,{editing:!0,onDataChange:A,...sL({configCard:f,slotOrderedCards:$,slotTypes:z,multiInputData:t,params:o,theme:i,chartSettings:L,filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T})})})]})]},(R=f.customCardPreferences)==null?void 0:R.componentName)}):null}const Nwt=S.memo(Cwt,(e,t)=>{var n,r,o,s,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((o=e.card.customCardPreferences)==null?void 0:o.slotSettings)===((s=t.card.customCardPreferences)==null?void 0:s.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),_wt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var fhe=["PageUp","PageDown"],hhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],mhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Qg="Slider",[OR,kwt,jwt]=p.createCollection(Qg),[phe]=p.createContextScope(Qg,[jwt]),[Twt,Zj]=phe(Qg),ghe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),v=i==="horizontal"?Iwt:Ewt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(E)}}),_=Q.useRef(C);function k(E){const D=Pwt(C,E);T(E,D)}function j(E){T(E,y.current)}function I(){const E=_.current[y.current];C[y.current]!==E&&h(C)}function T(E,D,{commit:A}={commit:!1}){const P=$wt(s),M=zwt(Math.round((E-r)/s)*s+r,P),L=p.clamp(M,[r,o]);N(($=[])=>{const z=Awt($,L,D);if(Lwt(z,c*s)){y.current=z.indexOf(L);const W=String(z)!==String($);return W&&A&&h(z),W?z:$}else return $})}return l.jsx(Twt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(OR.Provider,{scope:e.__scopeSlider,children:l.jsx(OR.Slot,{scope:e.__scopeSlider,children:l.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(_.current=C)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:k,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:I,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(o,C.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const M=fhe.includes(E.key)||E.shiftKey&&hhe.includes(E.key)?10:1,L=y.current,$=C[L],z=s*M*D;T($+z,L,{commit:!0})}}})})})})});ghe.displayName=Qg;var[bhe,xhe]=phe(Qg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Iwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,v=>h(v)),g=Q.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],k=r$(N,y?[n,r]:[r,n]);return g.current=C,k(v-C.left)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(yhe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const C=w(v.clientX);i==null||i(C)},onSlideMove:v=>{const C=w(v.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:v=>{const N=mhe[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),Ewt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=r$(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(yhe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=mhe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),yhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Zj(Qg,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):fhe.concat(hhe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),vhe="SliderTrack",whe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(vhe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});whe.displayName=vhe;var LR="SliderRange",She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(LR,n),s=xhe(LR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>_he(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});She.displayName=LR;var $R="SliderThumb",Che=Q.forwardRef((e,t)=>{const n=kwt(e.__scopeSlider),[r,o]=Q.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(Dwt,{...e,ref:s,index:i})}),Dwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=Zj($R,n),a=xhe($R,n),[c,u]=Q.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:_he(m,i.min,i.max),b=Rwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?Fwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(OR.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Nhe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Che.displayName=$R;var Mwt="RadioBubbleInput",Nhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=Q.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return Q.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});Nhe.displayName=Mwt;function Awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function _he(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function Rwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Pwt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Fwt(e,t,n){const r=e/2,s=r$([0,50],[0,r]);return(r-s(t)*n)*n}function Owt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Lwt(e,t){if(t>0){const n=Owt(e);return Math.min(...n)>=t}return!0}function r$(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function $wt(e){return(String(e).split(".")[1]||"").length}function zwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var khe=ghe,Bwt=whe,Vwt=She,Hwt=Che;const jhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(khe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Bwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Vwt,{className:"absolute h-full bg-primary"})}),l.jsx(Hwt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));jhe.displayName=khe.displayName;const The=["SUN","MON","TUE","WED","THU","FRI","SAT"],Uwt=The.reduce((e,t,n)=>({...e,[t]:n}),{}),$l={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function qwt(e){if(!e||!e.trim())return{...$l};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...$l,isCustom:!0};const[o,s,i,a,c]=r,u=Number(o),d=Number(s);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...$l,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...$l,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Uwt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...$l,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...$l,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...$l,repeats:"monthly",hour:d,minute:u}:{...$l,hour:d,minute:u,isCustom:!0}}function Wwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((o,s)=>o-s).map(o=>The[o]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Ihe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,o=t.toString().padStart(2,"0");return`${r}:${o} ${n}`}function Gwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Ywt(e){if(e.length===7)return"every day";const t=e.slice().sort((o,s)=>o-s);if(t.length===5&&t.every(o=>o>=1&&o<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(o=>r[o]).join(", ")}function Kwt(e,t,n,r){const o=Ihe(e.hour,e.minute),s=Gwt(t);let i;if(e.isCustom)i=`Custom schedule · ${o} ${s}`;else switch(e.repeats){case"daily":i=`Daily at ${o} ${s}`;break;case"weekly":i=`Weekly · ${Ywt(e.weekdays)} at ${o} ${s}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${o} ${s}`;break;case"monthly":i=`Monthly on the 1st at ${o} ${s}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Zwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=HL;exports.AccordionContent=c0;exports.AccordionItem=a0;exports.AccordionTrigger=l0;exports.AddDataPicker=D3;exports.AggregateTable=Sk;exports.Alert=wF;exports.AlertDescription=SF;exports.AlertDialog=jh;exports.AlertDialogAction=ld;exports.AlertDialogCancel=cd;exports.AlertDialogContent=rd;exports.AlertDialogDescription=ad;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=od;exports.AlertDialogTitle=id;exports.AlertDialogTrigger=lye;exports.AlertTitle=JZ;exports.ArrowDown=bo;exports.ArrowDownIcon=Yqe;exports.ArrowLeft=R0;exports.ArrowRight=t_;exports.ArrowUp=Ro;exports.ArrowUpIcon=Zqe;exports.AssistantContextEntityControls=SR;exports.AssistantVirtualizedMessages=the;exports.AtSign=Qq;exports.AxisConfigurator=lg;exports.Badge=co;exports.Bell=e1;exports.BookType=eW;exports.BulletChartIcon=Gfe;exports.COMMON_TIMEZONES=Zwt;exports.CSS=bi;exports.CalculatedFieldEditor=ole;exports.Calculator=nW;exports.Calendar=ii;exports.Calendar$1=j1;exports.CalendarRange=rW;exports.Card=cy;exports.CardContent=JR;exports.CardHeader=QR;exports.CardSummary=WA;exports.CardTitle=Jp;exports.ChartArea=h2;exports.ChartColumnIncreasing=oW;exports.ChartColumnStacked=sW;exports.ChartJsVisual=vv;exports.ChartLine=iW;exports.ChartNoAxesGantt=lW;exports.ChartPie=cW;exports.ChartScatter=uW;exports.ChatInputWithContext=M3;exports.Checkbox=Tn;exports.ChevronLeft=Ch;exports.ChevronsUpDown=hW;exports.Circle=eP;exports.CircleAlert=Wf;exports.CircleCheck=mW;exports.CircleHelp=pW;exports.Clock=tP;exports.CodeHighlighter=Hf;exports.CodeXml=t1;exports.Collapsible=Cc;exports.CollapsibleContent=_c;exports.CollapsibleTrigger=Nc;exports.ColorField=Ri;exports.Command=hj;exports.CommandEmpty=pj;exports.CommandGroup=gj;exports.CommandInput=DL;exports.CommandItem=bj;exports.CommandList=mj;exports.CommandSeparator=Nae;exports.ComparisonMetadataBadge=Nee;exports.Container=_P;exports.ControlDefaultValueEditor=kle;exports.ControlDefinitionOptionsEditor=_le;exports.ControlIdInput=wle;exports.ControlVisibilitySettings=att;exports.Copy=Du;exports.CopyButton=Iu;exports.CopyPlus=p2;exports.Cross2Icon=eWe;exports.CustomFilterPopover=X5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=kJ;exports.DEFAULT_SCHEDULE_VM=$l;exports.Dashboard=che;exports.DashboardCard=Eie;exports.DashboardCreateDialogBase=lY;exports.DashboardExportDialog=nhe;exports.DashboardPlus=ewt;exports.DashboardWC=gwt;exports.DataTableConditionalFormattingSettings=mce;exports.DataTablePagination=dk;exports.Database=Bi;exports.DateRangePicker=D5;exports.DefaultChatTransport=C3;exports.Dialog=ks;exports.DialogContent=ls;exports.DialogDescription=Gs;exports.DialogFooter=Ic;exports.DialogHeader=Xi;exports.DialogTitle=cs;exports.DialogTrigger=sY;exports.DisplayPreferencesProvider=nj;exports.DndContext=zv;exports.Donut=gW;exports.Download=jc;exports.DownloadPdf=rhe;exports.DragOverlay=uae;exports.DropdownMenu=Bo;exports.DropdownMenuCheckboxItem=Zc;exports.DropdownMenuContent=ko;exports.DropdownMenuItem=Sn;exports.DropdownMenuLabel=fa;exports.DropdownMenuRadioGroup=pbe;exports.DropdownMenuRadioItem=DG;exports.DropdownMenuSeparator=qi;exports.DropdownMenuSub=gP;exports.DropdownMenuSubContent=c_;exports.DropdownMenuSubTrigger=l_;exports.DropdownMenuTrigger=Vo;exports.EMPTY_DATA_SOURCE=Zp;exports.Editable=mN;exports.EditableText=Hs;exports.EditorCustomVisual=Nwt;exports.Ellipsis=ui;exports.EllipsisVertical=Nh;exports.ErrorBoundary=ka;exports.ExportError=pg;exports.ExternalLink=xp;exports.EyeOff=n_;exports.Fallback=ej;exports.FallbackVisual=Jy;exports.FeedbackCategory=td;exports.FeedbackDialog=S0;exports.FieldsList=XL;exports.FieldsSection=bwt;exports.FileCode=bW;exports.FileSpreadsheet=xW;exports.FileText=di;exports.Filter=Gf;exports.FilterComponent=Gk;exports.FilterInfo=VA;exports.FilterableFieldsPanel=ile;exports.Globe=_h;exports.Grid3x3=g2;exports.GripVertical=Tc;exports.HEATMAP_PRESET_PALETTES=CM;exports.Hash=yW;exports.House=vW;exports.HoverCard=gg;exports.HoverCardContent=Vu;exports.HoverCardTrigger=bg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=dhe;exports.INLINE_ALLOWED_TOOL_LIST=ywt;exports.INLINE_BLOCKED_MUTATING_TOOLS=xwt;exports.IconButton=uc;exports.IconForFieldType=R1;exports.InfoHover=yL;exports.InlineFilterBar=vie;exports.KPICard=Ku;exports.KeyboardSensor=Lv;exports.Layers=P0;exports.LayoutDashboard=Yf;exports.Link=nP;exports.LoadingDots=Uu;exports.Lock=r_;exports.MAX_SELF_HEAL_ATTEMPTS=vwt;exports.Map=CW;exports.Markdown=cfe;exports.MatrixTableVisual=wk;exports.MdStackedLineChart=qfe;exports.MultiInputEmptyRenderer=_5;exports.PYTHON_DEFAULT_CODE=BR;exports.PanelResizeHandle=Rj;exports.Paperclip=NW;exports.PenLine=b2;exports.Pencil=x2;exports.PendingMessagesDisplay=Nde;exports.PersistedDynamicVisual=tj;exports.PiChartPolar=Bfe;exports.Pin=kW;exports.PinOff=_W;exports.PivotTableTanstack=Og;exports.Placeholders=Bce;exports.Play=jW;exports.Plus=kr;exports.PointerSensor=Hg;exports.Progress=I3;exports.RECOVERABLE_SQL_ERROR_CODES=Swt;exports.Radar=TW;exports.RadioGroup=Ca;exports.RadioGroupItem=Co;exports.RefreshCw=Kf;exports.ResizableHandle=bst;exports.ResizablePanel=uR;exports.ResizablePanelGroup=zce;exports.ResourceEditDialog=$Y;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=wwt;exports.SeedQuestions=cde;exports.SemaphorContext=D0;exports.SemaphorContextProvider=YR;exports.SemaphorQueryClient=Wq;exports.SemaphorReadyIndicator=n$;exports.SemaphorStyleWrapper=Lg;exports.Send=IW;exports.Settings=rP;exports.Settings2=F0;exports.Share2=EW;exports.ShareDialog=LY;exports.Sheet=fee;exports.SheetContent=SO;exports.SheetDescription=NO;exports.SheetHeader=mee;exports.SheetTitle=CO;exports.SheetTrigger=lFe;exports.Slider=jhe;exports.SortableContext=Bv;exports.Sparkles=Z1;exports.Square=sP;exports.SquarePen=oP;exports.Star=DW;exports.StructuralParticipantSelector=Sle;exports.SummaryCard=$A;exports.TABLE_PRESENTATION_DEFAULT_STYLE=ju;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Oi;exports.TableBody=Bu;exports.TableCell=An;exports.TableColumnVisibilitySettings=nce;exports.TableHead=to;exports.TableHeader=Lh;exports.TablePresentationSettings=oce;exports.TableRow=Sr;exports.TableSkeleton=vL;exports.TableVisual=Hu;exports.TbChartBubble=Vfe;exports.TbChartFunnel=Hfe;exports.TbChartTreemap=Ufe;exports.TextCard=Hp;exports.Textarea=Ih;exports.TiSortNumerically=Wfe;exports.Toggle=Qk;exports.Tornado=MW;exports.Trash2=hl;exports.TreePalm=aP;exports.TrendingUp=AW;exports.TriangleAlert=Vi;exports.TypeGlyph=Av;exports.UXProvider=t$;exports.User=RW;exports.Users=s_;exports.applyFilterOverridesToDashboardInputSlots=vZ;exports.areContextEntitiesEqual=Jn;exports.areEntitiesJoined=DJ;exports.arrayMove=Ug;exports.buildCardControlUsageById=ctt;exports.buildCustomCardTheme=Tv;exports.buildDashboardCardExecutionSnapshot=yZ;exports.buildDashboardControlUsageById=ltt;exports.buildDashboardExecutionSnapshot=pF;exports.buildDashboardInputExecutionSnapshot=wu;exports.buildDashboardSheetsInputExecutionSnapshot=SZ;exports.buildDashboardStructuralParticipantIdsByControlId=Ile;exports.buildFilterFieldMeta=OL;exports.buildFilterSemanticContext=LL;exports.buildInlineFilterNodes=J5;exports.buildMultiInputCustomVisualProps=sL;exports.buildScheduleExpr=Wwt;exports.buildSchedulePreview=Kwt;exports.buildSlotOrderedCards=tL;exports.calculateContextAwareFilters=W0;exports.calculateFieldState=hO;exports.canUserAccessVisuals=m0e;exports.canUserCreateDashboards=VY;exports.canUserEdit=d0e;exports.canUserManageDashboards=h0e;exports.canUserManageGroups=p0e;exports.canUserUseFilters=f0e;exports.cancelExport=XRe;exports.chartSupportsDataLabels=CQ;exports.chartSupportsLegend=wQ;exports.chartTypes=Kj;exports.cleanupKpiMetricComparisonMode=Mae;exports.cloneDeep=$s;exports.cloneLinkedFrameWithSourceMapping=fYe;exports.closestCenter=Ov;exports.commitSharedCalculatedFields=Gd;exports.createAssistantConversationId=Am;exports.createAssistantRequestId=ade;exports.createCardsFromSlots=jWe;exports.createChartConfig=mg;exports.createDashboardControlInputFromControl=oot;exports.createDefaultGlobalDateFilter=k1e;exports.createExport=XJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=fdt;exports.doesStoredFilterMatchField=Yp;exports.downloadDocumentPdf=bF;exports.downloadPdf=IZ;exports.extractSqlParamReferences=Aoe;exports.extractTableMetadata=FL;exports.fieldAlreadyExists=AJ;exports.findCustomVisualConfigCard=rL;exports.findDashboardFrameById=h1e;exports.flexRender=Bs;exports.formatDisplayFormula=tJe;exports.formatFileSize=ePe;exports.formatFilterLine=tX;exports.formatTimeLabel=Ihe;exports.getAutoDetectedChartIcon=T0t;exports.getChartGridStyle=e_e;exports.getChartIconByType=I0t;exports.getColorForValue=z2;exports.getConfigSlotExpectedType=kWe;exports.getCoreRowModel=lk;exports.getCustomVisualInputCards=nL;exports.getDateFormatOptionsForGranularity=s0;exports.getDefaultAxisConfig=V2;exports.getDefaultChartColors=Ph;exports.getDefaultDataLabelsConfig=rv;exports.getDefaultExportFormat=xX;exports.getDefaultFilterSql=F5;exports.getDefaultLegendConfig=ZF;exports.getDefaultRunningTotalPartitionByFieldIds=ey;exports.getDocumentSectionEditorCard=zet;exports.getDocumentSheetDashboardInputs=Wv;exports.getDownloadUrl=ZRe;exports.getEffectiveCardTypeForSlot=Jm;exports.getEntityIcon=qN;exports.getErrorMessage=Kue;exports.getExportStatus=KRe;exports.getExports=YRe;exports.getExpressionFieldKind=Xu;exports.getFieldExpressionAnnotation=$L;exports.getFilterCount=yN;exports.getGlobalDateFilter=Ah;exports.getGlobalDateFilterCoverage=yi;exports.getGranularityOptionsForFieldType=r3;exports.getKeys=cr;exports.getMatrixVisualLoadingState=vk;exports.getMetricDisplayLabel=gRe;exports.getNewField=LJ;exports.getObjectDiff=kq;exports.getPaginationRowModel=ck;exports.getRoleBasedDisplayOverrides=BY;exports.getRunningTotalOrderByCandidates=NQe;exports.getSelectedDateFilterColumn=Poe;exports.getSheetScopedFilterValues=py;exports.getSlotDefinitionForIndex=eL;exports.getSlotExpectedChartType=Zk;exports.getSlotIndexForCard=Xy;exports.getSortedRowModel=uee;exports.getSupportedExportFormats=bX;exports.getTableConditionalFormattingColumnOptions=lce;exports.getTableOutputColumnOptions=cce;exports.getTablePageSizeOptions=YJ;exports.handleAggregationChange=HA;exports.handleAggregationLabelChange=xie;exports.hasFlatTableTotalsBehavior=NCe;exports.hasMatrixResultData=av;exports.horizontalListSortingStrategy=jL;exports.isCalculatedFilterField=i0;exports.isCardSummaryVisibleOnCard=iL;exports.isCustomVisualConfigCard=OA;exports.isDefaultColor=ACe;exports.isEligibleFlatTableTotalsCard=rg;exports.isExportComplete=JRe;exports.isExportInProgress=QRe;exports.isInAiScopeArray=ddt;exports.isManagedCalculatedExpressionField=ya;exports.isMetricTransformEnabled=SQe;exports.isPromiseLike=wR;exports.isSubtotalEnabledAggregateTable=PL;exports.isSupportedDocumentTableCardType=Bet;exports.lastAssistantMessageIsCompleteWithToolCalls=que;exports.merge=fl;exports.mergeAxisConfig=H2;exports.normalizeConditionalFormatting=lF;exports.normalizeContextFormatMode=aX;exports.normalizeDashboardInputVariableName=A0;exports.normalizeMultiInputPayload=oL;exports.parseScheduleExpr=qwt;exports.pivotData=Z0;exports.prepareFeedbackData=Yj;exports.purify=bA;exports.reindexSlotCards=_We;exports.remarkGfm=Ofe;exports.removeFromScopeArray=hdt;exports.resolveDashboardInputContext=_l;exports.resolveDomainCalculatedFieldForEdit=ZJe;exports.resolveMultiInputType=Iv;exports.resolveMultiInputTypeFromVisual=TWe;exports.resolveTablePageSize=sk;exports.resolveTablePresentationStyle=MO;exports.sanitizeAIScope=Yue;exports.saveCalculatedFieldToCardScope=tR;exports.saveCalculatedFieldToSharedScope=sle;exports.saveCalculatedFieldToSheetScope=nR;exports.seedSemanticMetricFormatDefaults=Rae;exports.setTableColumnVisibility=eee;exports.setupEditorWithCard=L_;exports.showAllTableColumns=oPe;exports.showJoinRequiredNotification=MJ;exports.sortByColumnsToSortState=Ree;exports.sortStateToSortByColumns=Pee;exports.sortableKeyboardCoordinates=IL;exports.supportsMetricTransformForMetric=Aae;exports.supportsTableConditionalFormatting=sce;exports.toEntityArray=xa;exports.ue=rt;exports.useActiveExports=C0e;exports.useActiveToolStatus=kde;exports.useAddFrameWithFreshSemanticExecutionPayload=xL;exports.useAddNewFrame=zie;exports.useAssistantContainer=qY;exports.useAssistantContextEntities=oj;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=HY;exports.useAssistantProfile=lde;exports.useAutoSubmitQueue=_de;exports.useBrandStudioPreview=Bvt;exports.useCard=TRe;exports.useCardFilterValues=zJ;exports.useCardSummary=aL;exports.useChat=Gue;exports.useColumns=ML;exports.useCreateVisualWithFrame=dxe;exports.useCurrentUserInfo=Zi;exports.useCustomVisual=Vh;exports.useCustomVisualsQuery=Z5;exports.useDashboardAppearance=Mc;exports.useDashboardById=zG;exports.useDashboardPreferences=eg;exports.useDashboardQuery=M0;exports.useDashboardStructuralParticipants=Ele;exports.useDashboardSummary=tie;exports.useDataColumns=Fae;exports.useDateFilterHook=i7e;exports.useDebounce=Yx;exports.useDefaultDashboardMutation=AG;exports.useDisplayPreferences=Nl;exports.useDroppable=cae;exports.useEditorAside=xj;exports.useEditorCardQuery=O_;exports.useEnsureReactGlobals=loe;exports.useExportActions=WY;exports.useExportStore=b_;exports.useFieldManagement=Pae;exports.useFilterableFields=Iae;exports.useFullscreenAssistant=UY;exports.useGroupMembers=hye;exports.useGroups=EY;exports.useHasDashboardId=GY;exports.useInProgressExportsCount=N0e;exports.useJoinabilityMap=RL;exports.useManagementActions=Sh;exports.useManagementStore=$o;exports.useMutation=ss;exports.usePivotTableConfig=Oh;exports.usePluginQuery=Bse;exports.useQuery=Rn;exports.useQueryClient=Xr;exports.useReactTable=uk;exports.useResolveExistingFrameSemanticExecutionPayload=gYe;exports.useResourceManagement=xP;exports.useResourceUpdateState=BG;exports.useScopedFields=Tae;exports.useSelectedVisual=epe;exports.useSemaphorContext=gt;exports.useSensor=Gp;exports.useSensors=lj;exports.useSortable=qg;exports.useStarredChartsStore=_wt;exports.useSurfaceAppearance=Dc;exports.useTableQueryState=_ee;exports.useTextFilterHook=b7e;exports.useTheme=VR;exports.useTopoJson=sv;exports.useUnifiedUsers=CP;exports.useUpdateResource=FG;exports.useUpdateVisualMutation=fxe;exports.useUserPreferences=cY;exports.useVisualById=d_;exports.useVisualManagement=uxe;exports.validateFieldForChartType=Dae;exports.verticalListSortingStrategy=TL;
|