@epam/statgpt-conversation-view 0.3.0-rc.16 → 0.3.0-rc.18
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/index.js +2 -2
- package/index.mjs +289 -290
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|\r| )|[\0-]`,"gm"),Va=(e,t,n,s)=>({name:Ga(s||`${n} ${new Date().toLocaleDateString()}`),folderId:`${e}/${t}`,prompt:s}),Ga=e=>{const t=e?.replace(/\r\n|\r/gm,`
|
|
4
4
|
`).split(`
|
|
5
5
|
`).map(s=>s.replace(_a," ").trim()).filter(Boolean)[0]??"";return(t.length>cs?t.substring(0,cs):t).trim()},Ba=(e,t,n,s,r,i)=>{const d=`${e}/${t}`;return{name:n,folderId:d,prompt:r,id:ee.generateConversationId({folderId:d,name:n}),messages:[{role:de.Role.Assistant,content:s}],custom_fields:{configuration:{choice:i}}}};var Ha=Object.defineProperty,ht=Object.getOwnPropertySymbols,Ys=Object.prototype.hasOwnProperty,qs=Object.prototype.propertyIsEnumerable,us=(e,t,n)=>t in e?Ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nt=(e,t)=>{for(var n in t||(t={}))Ys.call(t,n)&&us(e,n,t[n]);if(ht)for(var n of ht(t))qs.call(t,n)&&us(e,n,t[n]);return e},jt=(e,t)=>{var n={};for(var s in e)Ys.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&ht)for(var s of ht(e))t.indexOf(s)<0&&qs.call(e,s)&&(n[s]=e[s]);return n};var $e;(e=>{const t=class Q{constructor(o,c,l,m){if(this.version=o,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],o<Q.MIN_VERSION||o>Q.MAX_VERSION)throw new RangeError("Version value out of range");if(m<-1||m>7)throw new RangeError("Mask value out of range");this.size=o*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(l);if(this.drawCodewords(p),m==-1){let g=1e9;for(let C=0;C<8;C++){this.applyMask(C),this.drawFormatBits(C);const w=this.getPenaltyScore();w<g&&(m=C,g=w),this.applyMask(C)}}r(0<=m&&m<=7),this.mask=m,this.applyMask(m),this.drawFormatBits(m),this.isFunction=[]}static encodeText(o,c){const l=e.QrSegment.makeSegments(o);return Q.encodeSegments(l,c)}static encodeBinary(o,c){const l=e.QrSegment.makeBytes(o);return Q.encodeSegments([l],c)}static encodeSegments(o,c,l=1,m=40,h=-1,p=!0){if(!(Q.MIN_VERSION<=l&&l<=m&&m<=Q.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,C;for(g=l;;g++){const b=Q.getNumDataCodewords(g,c)*8,D=d.getTotalBits(o,g);if(D<=b){C=D;break}if(g>=m)throw new RangeError("Data too long")}for(const b of[Q.Ecc.MEDIUM,Q.Ecc.QUARTILE,Q.Ecc.HIGH])p&&C<=Q.getNumDataCodewords(g,b)*8&&(c=b);let w=[];for(const b of o){n(b.mode.modeBits,4,w),n(b.numChars,b.mode.numCharCountBits(g),w);for(const D of b.getData())w.push(D)}r(w.length==C);const y=Q.getNumDataCodewords(g,c)*8;r(w.length<=y),n(0,Math.min(4,y-w.length),w),n(0,(8-w.length%8)%8,w),r(w.length%8==0);for(let b=236;w.length<y;b^=253)n(b,8,w);let x=[];for(;x.length*8<w.length;)x.push(0);return w.forEach((b,D)=>x[D>>>3]|=b<<7-(D&7)),new Q(g,c,x,h)}getModule(o,c){return 0<=o&&o<this.size&&0<=c&&c<this.size&&this.modules[c][o]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const o=this.getAlignmentPatternPositions(),c=o.length;for(let l=0;l<c;l++)for(let m=0;m<c;m++)l==0&&m==0||l==0&&m==c-1||l==c-1&&m==0||this.drawAlignmentPattern(o[l],o[m]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(o){const c=this.errorCorrectionLevel.formatBits<<3|o;let l=c;for(let h=0;h<10;h++)l=l<<1^(l>>>9)*1335;const m=(c<<10|l)^21522;r(m>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,s(m,h));this.setFunctionModule(8,7,s(m,6)),this.setFunctionModule(8,8,s(m,7)),this.setFunctionModule(7,8,s(m,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,s(m,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,s(m,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,s(m,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let o=this.version;for(let l=0;l<12;l++)o=o<<1^(o>>>11)*7973;const c=this.version<<12|o;r(c>>>18==0);for(let l=0;l<18;l++){const m=s(c,l),h=this.size-11+l%3,p=Math.floor(l/3);this.setFunctionModule(h,p,m),this.setFunctionModule(p,h,m)}}drawFinderPattern(o,c){for(let l=-4;l<=4;l++)for(let m=-4;m<=4;m++){const h=Math.max(Math.abs(m),Math.abs(l)),p=o+m,g=c+l;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(o,c){for(let l=-2;l<=2;l++)for(let m=-2;m<=2;m++)this.setFunctionModule(o+m,c+l,Math.max(Math.abs(m),Math.abs(l))!=1)}setFunctionModule(o,c,l){this.modules[c][o]=l,this.isFunction[c][o]=!0}addEccAndInterleave(o){const c=this.version,l=this.errorCorrectionLevel;if(o.length!=Q.getNumDataCodewords(c,l))throw new RangeError("Invalid argument");const m=Q.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][c],h=Q.ECC_CODEWORDS_PER_BLOCK[l.ordinal][c],p=Math.floor(Q.getNumRawDataModules(c)/8),g=m-p%m,C=Math.floor(p/m);let w=[];const y=Q.reedSolomonComputeDivisor(h);for(let b=0,D=0;b<m;b++){let E=o.slice(D,D+C-h+(b<g?0:1));D+=E.length;const T=Q.reedSolomonComputeRemainder(E,y);b<g&&E.push(0),w.push(E.concat(T))}let x=[];for(let b=0;b<w[0].length;b++)w.forEach((D,E)=>{(b!=C-h||E>=g)&&x.push(D[b])});return r(x.length==p),x}drawCodewords(o){if(o.length!=Math.floor(Q.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let m=0;m<this.size;m++)for(let h=0;h<2;h++){const p=l-h,C=(l+1&2)==0?this.size-1-m:m;!this.isFunction[C][p]&&c<o.length*8&&(this.modules[C][p]=s(o[c>>>3],7-(c&7)),c++)}}r(c==o.length*8)}applyMask(o){if(o<0||o>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let l=0;l<this.size;l++){let m;switch(o){case 0:m=(l+c)%2==0;break;case 1:m=c%2==0;break;case 2:m=l%3==0;break;case 3:m=(l+c)%3==0;break;case 4:m=(Math.floor(l/3)+Math.floor(c/2))%2==0;break;case 5:m=l*c%2+l*c%3==0;break;case 6:m=(l*c%2+l*c%3)%2==0;break;case 7:m=((l+c)%2+l*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][l]&&m&&(this.modules[c][l]=!this.modules[c][l])}}getPenaltyScore(){let o=0;for(let h=0;h<this.size;h++){let p=!1,g=0,C=[0,0,0,0,0,0,0];for(let w=0;w<this.size;w++)this.modules[h][w]==p?(g++,g==5?o+=Q.PENALTY_N1:g>5&&o++):(this.finderPenaltyAddHistory(g,C),p||(o+=this.finderPenaltyCountPatterns(C)*Q.PENALTY_N3),p=this.modules[h][w],g=1);o+=this.finderPenaltyTerminateAndCount(p,g,C)*Q.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,C=[0,0,0,0,0,0,0];for(let w=0;w<this.size;w++)this.modules[w][h]==p?(g++,g==5?o+=Q.PENALTY_N1:g>5&&o++):(this.finderPenaltyAddHistory(g,C),p||(o+=this.finderPenaltyCountPatterns(C)*Q.PENALTY_N3),p=this.modules[w][h],g=1);o+=this.finderPenaltyTerminateAndCount(p,g,C)*Q.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(o+=Q.PENALTY_N2)}let c=0;for(const h of this.modules)c=h.reduce((p,g)=>p+(g?1:0),c);const l=this.size*this.size,m=Math.ceil(Math.abs(c*20-l*10)/l)-1;return r(0<=m&&m<=9),o+=m*Q.PENALTY_N4,r(0<=o&&o<=2568888),o}getAlignmentPatternPositions(){if(this.version==1)return[];{const o=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(o*2-2))*2;let l=[6];for(let m=this.size-7;l.length<o;m-=c)l.splice(1,0,m);return l}}static getNumRawDataModules(o){if(o<Q.MIN_VERSION||o>Q.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*o+128)*o+64;if(o>=2){const l=Math.floor(o/7)+2;c-=(25*l-10)*l-55,o>=7&&(c-=36)}return r(208<=c&&c<=29648),c}static getNumDataCodewords(o,c){return Math.floor(Q.getNumRawDataModules(o)/8)-Q.ECC_CODEWORDS_PER_BLOCK[c.ordinal][o]*Q.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][o]}static reedSolomonComputeDivisor(o){if(o<1||o>255)throw new RangeError("Degree out of range");let c=[];for(let m=0;m<o-1;m++)c.push(0);c.push(1);let l=1;for(let m=0;m<o;m++){for(let h=0;h<c.length;h++)c[h]=Q.reedSolomonMultiply(c[h],l),h+1<c.length&&(c[h]^=c[h+1]);l=Q.reedSolomonMultiply(l,2)}return c}static reedSolomonComputeRemainder(o,c){let l=c.map(m=>0);for(const m of o){const h=m^l.shift();l.push(0),c.forEach((p,g)=>l[g]^=Q.reedSolomonMultiply(p,h))}return l}static reedSolomonMultiply(o,c){if(o>>>8||c>>>8)throw new RangeError("Byte out of range");let l=0;for(let m=7;m>=0;m--)l=l<<1^(l>>>7)*285,l^=(c>>>m&1)*o;return r(l>>>8==0),l}finderPenaltyCountPatterns(o){const c=o[1];r(c<=this.size*3);const l=c>0&&o[2]==c&&o[3]==c*3&&o[4]==c&&o[5]==c;return(l&&o[0]>=c*4&&o[6]>=c?1:0)+(l&&o[6]>=c*4&&o[0]>=c?1:0)}finderPenaltyTerminateAndCount(o,c,l){return o&&(this.finderPenaltyAddHistory(c,l),c=0),c+=this.size,this.finderPenaltyAddHistory(c,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(o,c){c[0]==0&&(o+=this.size),c.pop(),c.unshift(o)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(f,o,c){if(o<0||o>31||f>>>o)throw new RangeError("Value out of range");for(let l=o-1;l>=0;l--)c.push(f>>>l&1)}function s(f,o){return(f>>>o&1)!=0}function r(f){if(!f)throw new Error("Assertion error")}const i=class ge{constructor(o,c,l){if(this.mode=o,this.numChars=c,this.bitData=l,c<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(o){let c=[];for(const l of o)n(l,8,c);return new ge(ge.Mode.BYTE,o.length,c)}static makeNumeric(o){if(!ge.isNumeric(o))throw new RangeError("String contains non-numeric characters");let c=[];for(let l=0;l<o.length;){const m=Math.min(o.length-l,3);n(parseInt(o.substring(l,l+m),10),m*3+1,c),l+=m}return new ge(ge.Mode.NUMERIC,o.length,c)}static makeAlphanumeric(o){if(!ge.isAlphanumeric(o))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],l;for(l=0;l+2<=o.length;l+=2){let m=ge.ALPHANUMERIC_CHARSET.indexOf(o.charAt(l))*45;m+=ge.ALPHANUMERIC_CHARSET.indexOf(o.charAt(l+1)),n(m,11,c)}return l<o.length&&n(ge.ALPHANUMERIC_CHARSET.indexOf(o.charAt(l)),6,c),new ge(ge.Mode.ALPHANUMERIC,o.length,c)}static makeSegments(o){return o==""?[]:ge.isNumeric(o)?[ge.makeNumeric(o)]:ge.isAlphanumeric(o)?[ge.makeAlphanumeric(o)]:[ge.makeBytes(ge.toUtf8ByteArray(o))]}static makeEci(o){let c=[];if(o<0)throw new RangeError("ECI assignment value out of range");if(o<128)n(o,8,c);else if(o<16384)n(2,2,c),n(o,14,c);else if(o<1e6)n(6,3,c),n(o,21,c);else throw new RangeError("ECI assignment value out of range");return new ge(ge.Mode.ECI,0,c)}static isNumeric(o){return ge.NUMERIC_REGEX.test(o)}static isAlphanumeric(o){return ge.ALPHANUMERIC_REGEX.test(o)}getData(){return this.bitData.slice()}static getTotalBits(o,c){let l=0;for(const m of o){const h=m.mode.numCharCountBits(c);if(m.numChars>=1<<h)return 1/0;l+=4+h+m.bitData.length}return l}static toUtf8ByteArray(o){o=encodeURI(o);let c=[];for(let l=0;l<o.length;l++)o.charAt(l)!="%"?c.push(o.charCodeAt(l)):(c.push(parseInt(o.substring(l+1,l+3),16)),l+=2);return c}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let d=i;e.QrSegment=i})($e||($e={}));(e=>{(t=>{const n=class{constructor(r,i){this.ordinal=r,this.formatBits=i}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})($e||($e={}));(e=>{(t=>{const n=class{constructor(r,i){this.modeBits=r,this.numBitsCharCount=i}numCharCountBits(r){return this.numBitsCharCount[Math.floor((r+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})($e||($e={}));var Ye=$e;var Ua={L:Ye.QrCode.Ecc.LOW,M:Ye.QrCode.Ecc.MEDIUM,Q:Ye.QrCode.Ecc.QUARTILE,H:Ye.QrCode.Ecc.HIGH},Ks=128,Zs="L",Xs="#FFFFFF",Qs="#000000",er=!1,tr=1,Wa=4,za=0,$a=.1;function nr(e,t=0){const n=[];return e.forEach(function(s,r){let i=null;s.forEach(function(d,f){if(!d&&i!==null){n.push(`M${i+t} ${r+t}h${f-i}v1H${i+t}z`),i=null;return}if(f===s.length-1){if(!d)return;i===null?n.push(`M${f+t},${r+t} h1v1H${f+t}z`):n.push(`M${i+t},${r+t} h${f+1-i}v1H${i+t}z`);return}d&&i===null&&(i=f)})}),n.join("")}function sr(e,t){return e.slice().map((n,s)=>s<t.y||s>=t.y+t.h?n:n.map((r,i)=>i<t.x||i>=t.x+t.w?r:!1))}function Ja(e,t,n,s){if(s==null)return null;const r=e.length+n*2,i=Math.floor(t*$a),d=r/t,f=(s.width||i)*d,o=(s.height||i)*d,c=s.x==null?e.length/2-f/2:s.x*d,l=s.y==null?e.length/2-o/2:s.y*d,m=s.opacity==null?1:s.opacity;let h=null;if(s.excavate){let g=Math.floor(c),C=Math.floor(l),w=Math.ceil(f+c-g),y=Math.ceil(o+l-C);h={x:g,y:C,w,h:y}}const p=s.crossOrigin;return{x:c,y:l,h:o,w:f,excavation:h,opacity:m,crossOrigin:p}}function Ya(e,t){return t!=null?Math.max(Math.floor(t),0):e?Wa:za}function rr({value:e,level:t,minVersion:n,includeMargin:s,marginSize:r,imageSettings:i,size:d,boostLevel:f}){let o=u.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((C,w)=>(C.push(...Ye.QrSegment.makeSegments(w)),C),[]);return Ye.QrCode.encodeSegments(g,Ua[t],n,void 0,void 0,f)},[e,t,n,f]);const{cells:c,margin:l,numCells:m,calculatedImageSettings:h}=u.useMemo(()=>{let p=o.getModules();const g=Ya(s,r),C=p.length+g*2,w=Ja(p,d,g,i);return{cells:p,margin:g,numCells:C,calculatedImageSettings:w}},[o,d,i,s,r]);return{qrcode:o,margin:l,cells:c,numCells:m,calculatedImageSettings:h}}var qa=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ka=u.forwardRef(function(t,n){const s=t,{value:r,size:i=Ks,level:d=Zs,bgColor:f=Xs,fgColor:o=Qs,includeMargin:c=er,minVersion:l=tr,boostLevel:m,marginSize:h,imageSettings:p}=s,C=jt(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=C,y=jt(C,["style"]),x=p?.src,b=u.useRef(null),D=u.useRef(null),E=u.useCallback(F=>{b.current=F,typeof n=="function"?n(F):n&&(n.current=F)},[n]),[T,A]=u.useState(!1),{margin:N,cells:I,numCells:k,calculatedImageSettings:M}=rr({value:r,level:d,minVersion:l,boostLevel:m,includeMargin:c,marginSize:h,imageSettings:p,size:i});u.useEffect(()=>{if(b.current!=null){const F=b.current,B=F.getContext("2d");if(!B)return;let V=I;const z=D.current,Z=M!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;Z&&M.excavation!=null&&(V=sr(I,M.excavation));const ie=window.devicePixelRatio||1;F.height=F.width=i*ie;const K=i/k*ie;B.scale(K,K),B.fillStyle=f,B.fillRect(0,0,k,k),B.fillStyle=o,qa?B.fill(new Path2D(nr(V,N))):I.forEach(function(q,Y){q.forEach(function(ce,me){ce&&B.fillRect(me+N,Y+N,1,1)})}),M&&(B.globalAlpha=M.opacity),Z&&B.drawImage(z,M.x+N,M.y+N,M.w,M.h)}}),u.useEffect(()=>{A(!1)},[x]);const j=Nt({height:i,width:i},w);let _=null;return x!=null&&(_=u.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{A(!0)},ref:D,crossOrigin:M?.crossOrigin})),u.createElement(u.Fragment,null,u.createElement("canvas",Nt({style:j,height:i,width:i,ref:E,role:"img"},y)),_)});Ka.displayName="QRCodeCanvas";var ar=u.forwardRef(function(t,n){const s=t,{value:r,size:i=Ks,level:d=Zs,bgColor:f=Xs,fgColor:o=Qs,includeMargin:c=er,minVersion:l=tr,boostLevel:m,title:h,marginSize:p,imageSettings:g}=s,C=jt(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:y,numCells:x,calculatedImageSettings:b}=rr({value:r,level:d,minVersion:l,boostLevel:m,includeMargin:c,marginSize:p,imageSettings:g,size:i});let D=y,E=null;g!=null&&b!=null&&(b.excavation!=null&&(D=sr(y,b.excavation)),E=u.createElement("image",{href:g.src,height:b.h,width:b.w,x:b.x+w,y:b.y+w,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const T=nr(D,w);return u.createElement("svg",Nt({height:i,width:i,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},C),!!h&&u.createElement("title",null,h),u.createElement("path",{fill:f,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),u.createElement("path",{fill:o,d:T,shapeRendering:"crispEdges"}),E)});ar.displayName="QRCodeSVG";const Za=(e,t)=>({invitationType:ee.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),Xa=e=>{const t=e?.invitationLink?.split("/").at(-1)||"";return`/${J.SHARE_CONVERSATION_ROUTE}/${t}`},Qa=(e,t)=>t?.find(n=>{const s=e?.id?.split("/")?.pop(),r=n?.url?.split("/")?.pop()||"";return r===s||decodeURI(r)===s}),ei=e=>e?.messages?.filter(n=>!!n?.custom_content?.attachments)?.flatMap(n=>n?.custom_content?.attachments?.map(s=>({url:s?.url||""}))||[])?.filter(n=>!!n?.url)||[],ti=({conversation:e,locale:t,onCloseModal:n,modalDividers:s,getConversation:r,generateConversationLink:i,chatExpiration:d,chatExpirationDays:f,close:o,chatWarning:c,shareLink:l,shareCopyLink:m,shareCopiedLink:h,shareDescription:p,shareRemoveAccessToUsers:g,chatName:C,getSharedConversations:w,revokeSharedConversations:y,baseUrl:x,id:b,clientSharedPage:D,clientSharedProp:E})=>{const[T,A]=u.useState(null),[N,I]=u.useState(),[k,M]=u.useState(!1),[j,_]=u.useState(!1),[F,B]=u.useState(),V=u.useMemo(()=>{const q=x||window.location.origin;if(x&&x!==window.location.origin&&D&&E){const Y=T?.split(`/${J.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${q}/${D}?${E}=${Y}`}return`${q}/${t}${T}`},[x,T,t,D,E]);u.useEffect(()=>{(async()=>{try{const Y=decodeURI(e?e?.id:`${b?.[0]}/${t}/${b?.[1]}`),ce=`${decodeURI(Y)}`,me=await r?.(ce),H=Za(Y,ei(me)),ne=await i?.(H),se=await w?.(ee.getSharedConversationsRequest(ee.ShareTarget.OTHERS));ne&&se&&(M(!0),A(Xa(ne)),I(Qa(e,se?.resources)))}catch(Y){M(!1),console.error("Error sharing conversation",Y)}})()},[e,i,r,w,b,t]);const z=u.useCallback(()=>{n(),A(null),M(!1),_(!1)},[n]),Z=u.useCallback(()=>{_(!0),navigator.clipboard.writeText(V||"")},[V]),ie=async()=>{try{B(!0),N&&await y?.({resources:[N]})}catch(q){B(!1),console.error("Error revoking shared conversation",q)}},K=u.useCallback(()=>a.jsx(v.Button,{buttonClassName:j?"text-button-secondary":"text-button-primary",iconBefore:j?a.jsx(ke.IconCheck,{width:20,height:20}):a.jsx(ke.IconCopy,{width:20,height:20}),title:j?h??"Copied":m??"Copy link",disabled:j,onClick:Z}),[j,Z,h,m]);return a.jsxs(v.Popup,{heading:l??"Share link",portalId:"share",size:v.PopUpSize.SM,dividers:s,onClose:z,closeButtonTitle:o??"Close",children:[k?a.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[e?.name?a.jsxs("div",{className:"flex share-info w-full",children:[a.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:C??"Chat name:"}),a.jsx("h3",{className:"flex-1 min-w-0 truncate",title:e?.name,children:e?.name})]}):null,a.jsxs("div",{className:"flex share-info",children:[a.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:d??"Link expiration date:"}),a.jsxs("h3",{children:["3 ",f??"days"]})]}),a.jsx(ar,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:V,size:200}),a.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),a.jsx(v.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:V,value:V,inputId:"conversationLink",iconAfterInput:K()})]}):a.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:a.jsx(v.Loader,{})}),k?e&&N?a.jsx("div",{className:"remove-access",children:a.jsx(v.Button,{title:g??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:F,onClick:ie})}):a.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:c??"This chat has not been shared with anyone yet."}):a.jsx("div",{})]})},ir=({shareButtonClass:e,shareIcon:t,...n})=>{const[s,r]=u.useState(v.PopUpState.Closed),i=()=>{r(v.PopUpState.Opened)},d=u.useCallback(()=>{r(v.PopUpState.Closed)},[]);return a.jsxs(a.Fragment,{children:[a.jsx(v.Button,{buttonClassName:e||"text-button-secondary",title:n?.share||"Share",iconBefore:t,onClick:i}),s===v.PopUpState.Opened&&a.jsx(ti,{onCloseModal:d,...n})]})},or=({conversation:e,locale:t,isOpenedAdvancedView:n,isShowShareButton:s,shareConversationProps:r})=>a.jsx(a.Fragment,{children:a.jsxs("header",{className:P("bg-white border-b px-6 py-2 border-gray-200 flex justify-between items-center sm:hidden","conversation-view-header"),children:[a.jsx("span",{className:P("flex-1 min-w-0 truncate h4","conversation-view-header-text"),title:e?.name,children:e?.name}),a.jsx("div",{className:"flex gap-4",children:!n&&s&&a.jsx("div",{className:"flex gap-x-2",children:a.jsx(ir,{conversation:e,locale:t,...r})})})]})}),lr=({content:e,textColorClass:t})=>{const{isOpenedAdvancedView:n}=Be();return a.jsx("div",{className:P("prose max-w-none break-words",n?"body-2":"body-1",t),children:a.jsx(_s,{remarkPlugins:[Vs],components:{strong:s=>a.jsx("strong",{className:t,...s}),a:({href:s,children:r,...i})=>a.jsx("a",{href:s,target:"_blank",...i,children:r})},children:e})})},cr=({choiceButtons:e,disabled:t,onClick:n})=>{const s=P("flex w-full min-h-[72px] flex-col items-start justify-center rounded border px-4 py-2 text-left","border-hues-200 hover:bg-hues-100","disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent");return e.map(r=>a.jsx("div",{className:"mt-4",children:a.jsxs("button",{type:"button",className:s,disabled:t,onClick:()=>n(r[de.DialSchemaProperties.DialWidgetOptions]?.populateText,r?.const),"aria-label":"button",children:[a.jsx("h3",{className:"mb-1",children:r.title}),r.const!==bt.COMPLETE&&a.jsx("p",{className:"body-1 text-neutrals-800",children:r[de.DialSchemaProperties.DialWidgetOptions]?.populateText})]})},r.title))},ni=({titles:e,messageContent:t,choiceButtons:n,disabled:s,onClick:r,handleOnboardingSkip:i})=>a.jsxs("div",{className:"onboarding w-full h-full flex flex-col flex-1 overflow-auto",children:[a.jsx(or,{conversation:{name:e?.onboardingTitle??"Introducing the AI assistant"}}),a.jsxs("div",{className:"onboarding-content flex flex-col",children:[a.jsx(lr,{content:t}),a.jsx("div",{className:"mt-4",children:a.jsx(cr,{choiceButtons:n,disabled:s,onClick:r})}),a.jsxs("div",{className:"flex mt-8",children:[a.jsx(v.Button,{title:e?.skipOnboardingNow,buttonClassName:"text-button-secondary mr-4",disabled:s,onClick:()=>i?.(),isSmallButton:!0}),a.jsx(v.Button,{title:e?.refuseOnboarding,buttonClassName:"text-button-tertiary",disabled:s,onClick:()=>i?.(!0),isSmallButton:!0})]})]})]}),ur=({titles:e,openNewConversation:t})=>a.jsxs("div",{className:"text-center bg-accent-300 body-3 p-2",children:[a.jsx("span",{className:"mr-2 text-neutrals-900",children:e?.onboardingFooter}),a.jsxs("span",{onClick:t,className:"cursor-pointer inline-flex align-top",children:[a.jsx(ke.IconPlus,{width:15,height:15}),a.jsx("p",{className:"ml-1",children:e?.onboardingFooterLink})]})]}),dr=({firstLine:e,secondLine:t})=>{const n=e!=null&&e.trim()!=="",s=t!=null&&t.trim()!=="";return a.jsxs("div",{className:P("text-center body-3",s?"p-0":n?"p-1":"p-3"),children:[n&&a.jsx("div",{className:"text-neutrals-800",children:e}),s&&a.jsx("div",{className:"text-neutrals-800",children:t})]})},si=({suggestionsList:e,welcomeText:t,titleIcon:n,actions:s,titles:r,inputMessageStyles:i,isBottomInputPosition:d,prompt:f,onboardingMessageSchema:o,handleConversationClick:c,setConversations:l,locale:m,setSharedConversations:h})=>{const[p,g]=u.useState(null),[C,w]=u.useState(!0),[y,x]=u.useState(!1),{onboardingFileSchema:b,onboardingFileName:D,onboardingFilePath:E,isShowOnboarding:T,setIsShowOnboarding:A,setOnboardingFileSchema:N}=Ne(),{isAgentAvailable:I}=v.useAgentAvailability(),{statusMessages:k}=Vt();u.useEffect(()=>{(async()=>{try{const B=await s.getBucket();g(B.bucket)}catch(B){console.error(B instanceof Error?B.message:"Request error")}finally{w(!1)}})()},[s]);const M=u.useCallback(async(F,B)=>{if(!p){console.error("No bucket");return}x(!0);try{const V=T?Ba(p,m,r?.onboardingTitle??"Introducing the AI assistant",o?.properties?.choice?.description??"",F,B):Va(p,m,r.newChat??"New chat",F),z=await s.createConversation(V,m,T),Z=await s.getConversations(m),ie=await s.getSharedConversations(ee.getSharedConversationsRequest(ee.ShareTarget.ME));if(o&&b){const K={...b,isStarted:!0};await s.putOnboardingFile?.(D,E,K),N?.(K)}l(J.cleanConversationNames(Z)),h(J.cleanConversationNames(Ea.transformSharedConversations(ie,m))),c(z.folderId,z.id)}catch(V){console.error(V instanceof Error?V.message:"Creation conversation failed"),x(!1)}},[s,p,c,T,m,D,E,b,o,l,N,h,r.newChat,r?.onboardingTitle]),j=u.useCallback(async F=>{if(A(!1),F&&b){const B={...b,isSkipped:!0};await s.putOnboardingFile?.(D,E,B),N?.(B)}},[s,D,E,b,A,N]);u.useEffect(()=>{f&&p&&M(f)},[p,f]);const _=()=>{const F=!p;return I?a.jsxs(a.Fragment,{children:[a.jsx(Js,{containerClasses:P(i.inputContainerClass,d&&"order-3 mt-auto"),inputClasses:"mr-2",disabled:F,placeholder:r?.askAnything??"Ask anything...",sendMessageIcon:i.sendMessageIcon,onSendMessage:M}),a.jsx("div",{className:"max-w-full overflow-x-auto no-scrollbar",children:a.jsx("div",{className:P("flex flex-wrap justify-center gap-2 sm:flex-nowrap","tags-container"),children:e.map(B=>a.jsx(v.Tag,{title:B.title,text:B[de.DialSchemaProperties.DialWidgetOptions]?.populateText,disabled:F,onClick:M},B.title))})})]}):a.jsx(v.InlineAlert,{type:v.InlineAlertType.Error,children:k.assistantUnavailable})};return a.jsxs("div",{className:"flex flex-col h-full w-full",children:[y||f&&C?a.jsx(v.Loader,{}):T?a.jsx(ni,{titles:r,messageContent:o?.properties?.choice?.description||"",choiceButtons:o?.properties?.choice?.oneOf||[],disabled:!p,handleOnboardingSkip:j,onClick:M}):a.jsxs("div",{className:"flex flex-col h-full items-center justify-center sm:px-4",children:[a.jsxs("div",{className:P("flex items-center max-w-full sm-min:px-4",d?"mt-auto mb-8":"mb-6"),children:[n,a.jsx("h1",{className:"text-hues-800 text-center sm:h2",children:t??r?.welcomeTitle??"How can I help you?"})]}),_()]}),T&&a.jsx(ur,{titles:r,openNewConversation:()=>A(!1)}),!T&&a.jsx(dr,{firstLine:r.footerFirstLine,secondLine:r.footerSecondLine})]})},Gt=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M11.3301 6.25L8.00008 9.75L4.67008 6.25L11.3301 6.25Z",fill:"currentColor"})),ri=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M8.00016 1.33325C4.3135 1.33325 1.3335 4.31325 1.3335 7.99992C1.3335 11.6866 4.3135 14.6666 8.00016 14.6666C11.6868 14.6666 14.6668 11.6866 14.6668 7.99992C14.6668 4.31325 11.6868 1.33325 8.00016 1.33325ZM8.00016 13.3333C5.06016 13.3333 2.66683 10.9399 2.66683 7.99992C2.66683 5.05992 5.06016 2.66659 8.00016 2.66659C10.9402 2.66659 13.3335 5.05992 13.3335 7.99992C13.3335 10.9399 10.9402 13.3333 8.00016 13.3333ZM10.3935 4.66659L8.00016 7.05992L5.60683 4.66659L4.66683 5.60659L7.06016 7.99992L4.66683 10.3933L5.60683 11.3333L8.00016 8.93992L10.3935 11.3333L11.3335 10.3933L8.94016 7.99992L11.3335 5.60659L10.3935 4.66659Z",fill:"currentColor"})),ai=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M12.8232 7C12.926 7 13.012 7.07201 13.0244 7.16797L13.1807 8.22754C13.4315 8.32754 13.6621 8.46012 13.876 8.62012L14.9004 8.21973C14.9208 8.21186 14.9453 8.20803 14.9697 8.20801C15.0436 8.20801 15.1133 8.24392 15.1504 8.30762L15.9736 9.69238C16.0227 9.7803 16.0018 9.88834 15.9238 9.94824L15.0566 10.6084C15.0731 10.7363 15.085 10.8642 15.085 11C15.085 11.1358 15.0731 11.2637 15.0566 11.3916L15.9238 12.0518C16.0018 12.1117 16.0227 12.2197 15.9736 12.3076L15.1504 13.6924C15.1133 13.7561 15.0434 13.792 14.9736 13.792C14.9492 13.7919 14.9248 13.7881 14.9004 13.7803L13.876 13.3799C13.6621 13.5359 13.4315 13.6725 13.1807 13.7725L13.0244 14.832C13.012 14.928 12.926 15 12.8232 15H11.1787C11.0759 15 10.9889 14.928 10.9766 14.832L10.8203 13.7725C10.5696 13.6725 10.3397 13.5398 10.126 13.3799L9.10156 13.7803C9.08115 13.7882 9.05667 13.792 9.03223 13.792C8.95826 13.792 8.88761 13.7563 8.85059 13.6924L8.02832 12.3076C7.97924 12.2197 8.0001 12.1117 8.07812 12.0518L8.94531 11.3916C8.92889 11.2637 8.91699 11.1319 8.91699 11C8.91699 10.8681 8.92889 10.7363 8.94531 10.6084L8.07812 9.94824C8.0001 9.88832 7.97515 9.78032 8.02832 9.69238L8.85059 8.30762C8.88754 8.24383 8.95763 8.20816 9.02734 8.20801C9.05192 8.20801 9.07699 8.21179 9.10156 8.21973L10.126 8.62012C10.3397 8.46418 10.5696 8.32752 10.8203 8.22754L10.9766 7.16797C10.9889 7.07197 11.0759 7 11.1787 7H12.8232ZM11.7129 7.7998L11.6309 8.33984L11.5654 8.79199L11.1289 8.96387C10.9604 9.03184 10.792 9.12795 10.6152 9.25586L10.2451 9.52832L9.81738 9.36035L9.29492 9.15625L9.00684 9.63965L9.45117 9.97559L9.81738 10.2559L9.75977 10.708C9.74743 10.828 9.73926 10.92 9.73926 11C9.73926 11.08 9.74743 11.1719 9.75977 11.2959L9.81738 11.748L9.45117 12.0283L9.00684 12.3643L9.29492 12.8477L9.81738 12.6436L10.2529 12.4717L10.627 12.752C10.7913 12.8719 10.9561 12.9642 11.1328 13.0361L11.5693 13.208L11.6348 13.6602L11.7129 14.2002H12.2891L12.3711 13.6602L12.4365 13.208L12.873 13.0361C13.0415 12.9681 13.21 12.8721 13.3867 12.7441L13.7568 12.4717L14.1846 12.6396L14.707 12.8438L14.9941 12.3604L14.5508 12.0244L14.1846 11.7441L14.2422 11.292C14.2545 11.172 14.2627 11.084 14.2627 11C14.2627 10.916 14.2586 10.832 14.2422 10.708L14.1846 10.2559L14.5508 9.97559L14.9902 9.63574L14.7021 9.15234L14.1807 9.35645L13.7441 9.52832L13.3701 9.24805C13.2057 9.12808 13.0411 9.03586 12.8643 8.96387L12.4287 8.79199L12.3623 8.33984L12.2842 7.7998H11.7129ZM3.33301 12.6338H2V11.3008H3.33301V12.6338ZM7.00977 11.3008C7.03732 11.7651 7.12864 12.2121 7.27441 12.6338H4.66699V11.3008H7.00977ZM12.001 9.40039C12.9097 9.40043 13.6455 10.116 13.6455 11C13.6455 11.884 12.9097 12.5996 12.001 12.5996C11.0922 12.5996 10.3564 11.884 10.3564 11C10.3564 10.116 11.0922 9.40039 12.001 9.40039ZM12.001 10.2002C11.5486 10.2002 11.1787 10.56 11.1787 11C11.1787 11.44 11.5486 11.7998 12.001 11.7998C12.4533 11.7998 12.8232 11.44 12.8232 11C12.8232 10.56 12.4533 10.2002 12.001 10.2002ZM3.33301 8.63379H2V7.30078H3.33301V8.63379ZM8.63574 7.30078C8.21765 7.68124 7.86483 8.13197 7.59473 8.63379H4.66699V7.30078H8.63574ZM3.33301 4.7334H2V3.40039H3.33301V4.7334ZM14 4.7334H4.66699V3.40039H14V4.7334Z",fill:"currentColor"}));function fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tt={exports:{}},ii=tt.exports,ds;function oi(){return ds||(ds=1,(function(e,t){(function(n,s){s(t)})(ii,(function(n){var s=function(){return s=Object.assign||function(Fe){for(var it,kt=1,ka=arguments.length;kt<ka;kt++){it=arguments[kt];for(var Et in it)Object.prototype.hasOwnProperty.call(it,Et)&&(Fe[Et]=it[Et])}return Fe},s.apply(this,arguments)},r=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},i={weekdays:{shorthand:["أحد","اثنين","ثلاثاء","أربعاء","خميس","جمعة","سبت"],longhand:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]},months:{shorthand:["1","2","3","4","5","6","7","8","9","10","11","12"],longhand:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]},firstDayOfWeek:6,rangeSeparator:" إلى ",weekAbbreviation:"Wk",scrollTitle:"قم بالتمرير للزيادة",toggleTitle:"اضغط للتبديل",amPM:["ص","م"],yearAriaLabel:"سنة",monthAriaLabel:"شهر",hourAriaLabel:"ساعة",minuteAriaLabel:"دقيقة",time_24hr:!1};r.l10ns.ar=i,r.l10ns;var d=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},f={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jän","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Jänner","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};d.l10ns.at=f,d.l10ns;var o=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},c={weekdays:{shorthand:["B.","B.e.","Ç.a.","Ç.","C.a.","C.","Ş."],longhand:["Bazar","Bazar ertəsi","Çərşənbə axşamı","Çərşənbə","Cümə axşamı","Cümə","Şənbə"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","İyn","İyl","Avq","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","İyun","İyul","Avqust","Sentyabr","Oktyabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmaq üçün sürüşdürün",toggleTitle:"Aç / Bağla",amPM:["GƏ","GS"],time_24hr:!0};o.l10ns.az=c,o.l10ns;var l=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},m={weekdays:{shorthand:["Нд","Пн","Аў","Ср","Чц","Пт","Сб"],longhand:["Нядзеля","Панядзелак","Аўторак","Серада","Чацвер","Пятніца","Субота"]},months:{shorthand:["Сту","Лют","Сак","Кра","Тра","Чэр","Ліп","Жні","Вер","Кас","Ліс","Сне"],longhand:["Студзень","Люты","Сакавік","Красавік","Травень","Чэрвень","Ліпень","Жнівень","Верасень","Кастрычнік","Лістапад","Снежань"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Тыд.",scrollTitle:"Пракруціце для павелічэння",toggleTitle:"Націсніце для пераключэння",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};l.l10ns.be=m,l.l10ns;var h=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},p={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Juni","Juli","Avgust","Septembar","Oktobar","Novembar","Decembar"]},time_24hr:!0};h.l10ns.bs=p,h.l10ns;var g=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},C={weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},months:{shorthand:["Яну","Фев","Март","Апр","Май","Юни","Юли","Авг","Сеп","Окт","Ное","Дек"],longhand:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"]},time_24hr:!0,firstDayOfWeek:1};g.l10ns.bg=C,g.l10ns;var w=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},y={weekdays:{shorthand:["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],longhand:["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"]},months:{shorthand:["জানু","ফেব্রু","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],longhand:["জানুয়ারী","ফেব্রুয়ারী","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"]}};w.l10ns.bn=y,w.l10ns;var x=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},b={weekdays:{shorthand:["Dg","Dl","Dt","Dc","Dj","Dv","Ds"],longhand:["Diumenge","Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte"]},months:{shorthand:["Gen","Febr","Març","Abr","Maig","Juny","Jul","Ag","Set","Oct","Nov","Des"],longhand:["Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Setembre","Octubre","Novembre","Desembre"]},ordinal:function(ae){var Fe=ae%100;if(Fe>3&&Fe<21)return"è";switch(Fe%10){case 1:return"r";case 2:return"n";case 3:return"r";case 4:return"t";default:return"è"}},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};x.l10ns.cat=x.l10ns.ca=b,x.l10ns;var D=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},E={weekdays:{shorthand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"],longhand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"]},months:{shorthand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"],longhand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"]},firstDayOfWeek:6,ordinal:function(){return""}};D.l10ns.ckb=E,D.l10ns;var T=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},A={weekdays:{shorthand:["Ne","Po","Út","St","Čt","Pá","So"],longhand:["Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota"]},months:{shorthand:["Led","Ún","Bře","Dub","Kvě","Čer","Čvc","Srp","Zář","Říj","Lis","Pro"],longhand:["Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" do ",weekAbbreviation:"Týd.",scrollTitle:"Rolujte pro změnu",toggleTitle:"Přepnout dopoledne/odpoledne",amPM:["dop.","odp."],yearAriaLabel:"Rok",time_24hr:!0};T.l10ns.cs=A,T.l10ns;var N=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},I={weekdays:{shorthand:["Sul","Llun","Maw","Mer","Iau","Gwe","Sad"],longhand:["Dydd Sul","Dydd Llun","Dydd Mawrth","Dydd Mercher","Dydd Iau","Dydd Gwener","Dydd Sadwrn"]},months:{shorthand:["Ion","Chwef","Maw","Ebr","Mai","Meh","Gorff","Awst","Medi","Hyd","Tach","Rhag"],longhand:["Ionawr","Chwefror","Mawrth","Ebrill","Mai","Mehefin","Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr"]},firstDayOfWeek:1,ordinal:function(ae){return ae===1?"af":ae===2?"ail":ae===3||ae===4?"ydd":ae===5||ae===6?"ed":ae>=7&&ae<=10||ae==12||ae==15||ae==18||ae==20?"fed":ae==11||ae==13||ae==14||ae==16||ae==17||ae==19?"eg":ae>=21&&ae<=39?"ain":""},time_24hr:!0};N.l10ns.cy=I,N.l10ns;var k=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},M={weekdays:{shorthand:["søn","man","tir","ons","tors","fre","lør"],longhand:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"uge",time_24hr:!0};k.l10ns.da=M,k.l10ns;var j=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};j.l10ns.de=_,j.l10ns;var F={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(ae){var Fe=ae%100;if(Fe>3&&Fe<21)return"th";switch(Fe%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},B=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},V={firstDayOfWeek:1,rangeSeparator:" ĝis ",weekAbbreviation:"Sem",scrollTitle:"Rulumu por pligrandigi la valoron",toggleTitle:"Klaku por ŝalti",weekdays:{shorthand:["Dim","Lun","Mar","Mer","Ĵaŭ","Ven","Sab"],longhand:["dimanĉo","lundo","mardo","merkredo","ĵaŭdo","vendredo","sabato"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aŭg","Sep","Okt","Nov","Dec"],longhand:["januaro","februaro","marto","aprilo","majo","junio","julio","aŭgusto","septembro","oktobro","novembro","decembro"]},ordinal:function(){return"-a"},time_24hr:!0};B.l10ns.eo=V,B.l10ns;var z=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Z={weekdays:{shorthand:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb"],longhand:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"]},months:{shorthand:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],longhand:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},ordinal:function(){return"º"},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};z.l10ns.es=Z,z.l10ns;var ie=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},K={weekdays:{shorthand:["P","E","T","K","N","R","L"],longhand:["Pühapäev","Esmaspäev","Teisipäev","Kolmapäev","Neljapäev","Reede","Laupäev"]},months:{shorthand:["Jaan","Veebr","Märts","Apr","Mai","Juuni","Juuli","Aug","Sept","Okt","Nov","Dets"],longhand:["Jaanuar","Veebruar","Märts","Aprill","Mai","Juuni","Juuli","August","September","Oktoober","November","Detsember"]},firstDayOfWeek:1,ordinal:function(){return"."},weekAbbreviation:"Näd",rangeSeparator:" kuni ",scrollTitle:"Keri, et suurendada",toggleTitle:"Klõpsa, et vahetada",time_24hr:!0};ie.l10ns.et=K,ie.l10ns;var q=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Y={weekdays:{shorthand:["یک","دو","سه","چهار","پنج","جمعه","شنبه"],longhand:["یکشنبه","دوشنبه","سهشنبه","چهارشنبه","پنچشنبه","جمعه","شنبه"]},months:{shorthand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"],longhand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"]},firstDayOfWeek:6,ordinal:function(){return""}};q.l10ns.fa=Y,q.l10ns;var ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},me={firstDayOfWeek:1,weekdays:{shorthand:["su","ma","ti","ke","to","pe","la"],longhand:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"]},months:{shorthand:["tammi","helmi","maalis","huhti","touko","kesä","heinä","elo","syys","loka","marras","joulu"],longhand:["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kesäkuu","heinäkuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"]},ordinal:function(){return"."},time_24hr:!0};ce.l10ns.fi=me,ce.l10ns;var H=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ne={weekdays:{shorthand:["Sun","Mán","Týs","Mik","Hós","Frí","Ley"],longhand:["Sunnudagur","Mánadagur","Týsdagur","Mikudagur","Hósdagur","Fríggjadagur","Leygardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","Apríl","Mai","Juni","Juli","August","Septembur","Oktobur","Novembur","Desembur"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",scrollTitle:"Rulla fyri at broyta",toggleTitle:"Trýst fyri at skifta",yearAriaLabel:"Ár",time_24hr:!0};H.l10ns.fo=ne,H.l10ns;var se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},oe={firstDayOfWeek:1,weekdays:{shorthand:["dim","lun","mar","mer","jeu","ven","sam"],longhand:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},months:{shorthand:["janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],longhand:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},ordinal:function(ae){return ae>1?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};se.l10ns.fr=oe,se.l10ns;var he=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ce={weekdays:{shorthand:["Κυ","Δε","Τρ","Τε","Πέ","Πα","Σά"],longhand:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},months:{shorthand:["Ιαν","Φεβ","Μάρ","Απρ","Μάι","Ιούν","Ιούλ","Αύγ","Σεπ","Οκτ","Νοέ","Δεκ"],longhand:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"]},firstDayOfWeek:1,ordinal:function(){return""},weekAbbreviation:"Εβδ",rangeSeparator:" έως ",scrollTitle:"Μετακυλήστε για προσαύξηση",toggleTitle:"Κάντε κλικ για αλλαγή",amPM:["ΠΜ","ΜΜ"],yearAriaLabel:"χρόνος",monthAriaLabel:"μήνας",hourAriaLabel:"ώρα",minuteAriaLabel:"λεπτό"};he.l10ns.gr=Ce,he.l10ns;var ve=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},we={weekdays:{shorthand:["א","ב","ג","ד","ה","ו","ש"],longhand:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"]},months:{shorthand:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],longhand:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},rangeSeparator:" אל ",time_24hr:!0};ve.l10ns.he=we,ve.l10ns;var Se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ee={weekdays:{shorthand:["रवि","सोम","मंगल","बुध","गुरु","शुक्र","शनि"],longhand:["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार"]},months:{shorthand:["जन","फर","मार्च","अप्रेल","मई","जून","जूलाई","अग","सित","अक्ट","नव","दि"],longhand:["जनवरी ","फरवरी","मार्च","अप्रेल","मई","जून","जूलाई","अगस्त ","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"]}};Se.l10ns.hi=Ee,Se.l10ns;var ye=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},De={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Sij","Velj","Ožu","Tra","Svi","Lip","Srp","Kol","Ruj","Lis","Stu","Pro"],longhand:["Siječanj","Veljača","Ožujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac"]},time_24hr:!0};ye.l10ns.hr=De,ye.l10ns;var je=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Le={firstDayOfWeek:1,weekdays:{shorthand:["V","H","K","Sz","Cs","P","Szo"],longhand:["Vasárnap","Hétfő","Kedd","Szerda","Csütörtök","Péntek","Szombat"]},months:{shorthand:["Jan","Feb","Már","Ápr","Máj","Jún","Júl","Aug","Szep","Okt","Nov","Dec"],longhand:["Január","Február","Március","Április","Május","Június","Július","Augusztus","Szeptember","Október","November","December"]},ordinal:function(){return"."},weekAbbreviation:"Hét",scrollTitle:"Görgessen",toggleTitle:"Kattintson a váltáshoz",rangeSeparator:" - ",time_24hr:!0};je.l10ns.hu=Le,je.l10ns;var W=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},R={weekdays:{shorthand:["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"],longhand:["Կիրակի","Եկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},months:{shorthand:["Հնվ","Փտր","Մար","Ապր","Մայ","Հնս","Հլս","Օգս","Սեպ","Հոկ","Նմբ","Դեկ"],longhand:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"ՇԲՏ",scrollTitle:"Ոլորեք՝ մեծացնելու համար",toggleTitle:"Սեղմեք՝ փոխելու համար",amPM:["ՄԿ","ԿՀ"],yearAriaLabel:"Տարի",monthAriaLabel:"Ամիս",hourAriaLabel:"Ժամ",minuteAriaLabel:"Րոպե",time_24hr:!0};W.l10ns.hy=R,W.l10ns;var G=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},$={weekdays:{shorthand:["Min","Sen","Sel","Rab","Kam","Jum","Sab"],longhand:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],longhand:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0,rangeSeparator:" - "};G.l10ns.id=$,G.l10ns;var le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},re={weekdays:{shorthand:["Sun","Mán","Þri","Mið","Fim","Fös","Lau"],longhand:["Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maí","Jún","Júl","Ágú","Sep","Okt","Nóv","Des"],longhand:["Janúar","Febrúar","Mars","Apríl","Maí","Júní","Júlí","Ágúst","September","Október","Nóvember","Desember"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",yearAriaLabel:"Ár",time_24hr:!0};le.l10ns.is=re,le.l10ns;var fe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Me={weekdays:{shorthand:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],longhand:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"]},months:{shorthand:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],longhand:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},firstDayOfWeek:1,ordinal:function(){return"°"},rangeSeparator:" al ",weekAbbreviation:"Se",scrollTitle:"Scrolla per aumentare",toggleTitle:"Clicca per cambiare",time_24hr:!0};fe.l10ns.it=Me,fe.l10ns;var Oe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ae={weekdays:{shorthand:["日","月","火","水","木","金","土"],longhand:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},months:{shorthand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],longhand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},time_24hr:!0,rangeSeparator:" から ",monthAriaLabel:"月",amPM:["午前","午後"],yearAriaLabel:"年",hourAriaLabel:"時間",minuteAriaLabel:"分"};Oe.l10ns.ja=Ae,Oe.l10ns;var at=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},L={weekdays:{shorthand:["კვ","ორ","სა","ოთ","ხუ","პა","შა"],longhand:["კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი"]},months:{shorthand:["იან","თებ","მარ","აპრ","მაი","ივნ","ივლ","აგვ","სექ","ოქტ","ნოე","დეკ"],longhand:["იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"კვ.",scrollTitle:"დასქროლეთ გასადიდებლად",toggleTitle:"დააკლიკეთ გადართვისთვის",amPM:["AM","PM"],yearAriaLabel:"წელი",time_24hr:!0};at.l10ns.ka=L,at.l10ns;var O=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},U={weekdays:{shorthand:["일","월","화","수","목","금","토"],longhand:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},months:{shorthand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],longhand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"]},ordinal:function(){return"일"},rangeSeparator:" ~ ",amPM:["오전","오후"]};O.l10ns.ko=U,O.l10ns;var te=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},X={weekdays:{shorthand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស.","សុក្រ","សៅរ៍"],longhand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស្បតិ៍","សុក្រ","សៅរ៍"]},months:{shorthand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"],longhand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"]},ordinal:function(){return""},firstDayOfWeek:1,rangeSeparator:" ដល់ ",weekAbbreviation:"សប្តាហ៍",scrollTitle:"រំកិលដើម្បីបង្កើន",toggleTitle:"ចុចដើម្បីផ្លាស់ប្ដូរ",yearAriaLabel:"ឆ្នាំ",time_24hr:!0};te.l10ns.km=X,te.l10ns;var be=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xe={weekdays:{shorthand:["Жс","Дс","Сc","Ср","Бс","Жм","Сб"],longhand:["Жексенбi","Дүйсенбi","Сейсенбi","Сәрсенбi","Бейсенбi","Жұма","Сенбi"]},months:{shorthand:["Қаң","Ақп","Нау","Сәу","Мам","Мау","Шiл","Там","Қыр","Қаз","Қар","Жел"],longhand:["Қаңтар","Ақпан","Наурыз","Сәуiр","Мамыр","Маусым","Шiлде","Тамыз","Қыркүйек","Қазан","Қараша","Желтоқсан"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Апта",scrollTitle:"Үлкейту үшін айналдырыңыз",toggleTitle:"Ауыстыру үшін басыңыз",amPM:["ТД","ТК"],yearAriaLabel:"Жыл"};be.l10ns.kz=xe,be.l10ns;var Re=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},We={weekdays:{shorthand:["S","Pr","A","T","K","Pn","Š"],longhand:["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis"]},months:{shorthand:["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rgp","Rgs","Spl","Lap","Grd"],longhand:["Sausis","Vasaris","Kovas","Balandis","Gegužė","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis"]},firstDayOfWeek:1,ordinal:function(){return"-a"},rangeSeparator:" iki ",weekAbbreviation:"Sav",scrollTitle:"Keisti laiką pelės rateliu",toggleTitle:"Perjungti laiko formatą",time_24hr:!0};Re.l10ns.lt=We,Re.l10ns;var cn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},un={firstDayOfWeek:1,weekdays:{shorthand:["Sv","Pr","Ot","Tr","Ce","Pk","Se"],longhand:["Svētdiena","Pirmdiena","Otrdiena","Trešdiena","Ceturtdiena","Piektdiena","Sestdiena"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jūn","Jūl","Aug","Sep","Okt","Nov","Dec"],longhand:["Janvāris","Februāris","Marts","Aprīlis","Maijs","Jūnijs","Jūlijs","Augusts","Septembris","Oktobris","Novembris","Decembris"]},rangeSeparator:" līdz ",time_24hr:!0};cn.l10ns.lv=un,cn.l10ns;var dn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},fn={weekdays:{shorthand:["Не","По","Вт","Ср","Че","Пе","Са"],longhand:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},months:{shorthand:["Јан","Фев","Мар","Апр","Мај","Јун","Јул","Авг","Сеп","Окт","Ное","Дек"],longhand:["Јануари","Февруари","Март","Април","Мај","Јуни","Јули","Август","Септември","Октомври","Ноември","Декември"]},firstDayOfWeek:1,weekAbbreviation:"Нед.",rangeSeparator:" до ",time_24hr:!0};dn.l10ns.mk=fn,dn.l10ns;var mn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},hn={firstDayOfWeek:1,weekdays:{shorthand:["Да","Мя","Лх","Пү","Ба","Бя","Ня"],longhand:["Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням"]},months:{shorthand:["1-р сар","2-р сар","3-р сар","4-р сар","5-р сар","6-р сар","7-р сар","8-р сар","9-р сар","10-р сар","11-р сар","12-р сар"],longhand:["Нэгдүгээр сар","Хоёрдугаар сар","Гуравдугаар сар","Дөрөвдүгээр сар","Тавдугаар сар","Зургаадугаар сар","Долдугаар сар","Наймдугаар сар","Есдүгээр сар","Аравдугаар сар","Арваннэгдүгээр сар","Арванхоёрдугаар сар"]},rangeSeparator:"-с ",time_24hr:!0};mn.l10ns.mn=hn,mn.l10ns;var ya=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Da={weekdays:{shorthand:["Aha","Isn","Sel","Rab","Kha","Jum","Sab"],longhand:["Ahad","Isnin","Selasa","Rabu","Khamis","Jumaat","Sabtu"]},months:{shorthand:["Jan","Feb","Mac","Apr","Mei","Jun","Jul","Ogo","Sep","Okt","Nov","Dis"],longhand:["Januari","Februari","Mac","April","Mei","Jun","Julai","Ogos","September","Oktober","November","Disember"]},firstDayOfWeek:1,ordinal:function(){return""}};ya.l10ns;var gn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},pn={weekdays:{shorthand:["နွေ","လာ","ဂါ","ဟူး","ကြာ","သော","နေ"],longhand:["တနင်္ဂနွေ","တနင်္လာ","အင်္ဂါ","ဗုဒ္ဓဟူး","ကြာသပတေး","သောကြာ","စနေ"]},months:{shorthand:["ဇန်","ဖေ","မတ်","ပြီ","မေ","ဇွန်","လိုင်","သြ","စက်","အောက်","နို","ဒီ"],longhand:["ဇန်နဝါရီ","ဖေဖော်ဝါရီ","မတ်","ဧပြီ","မေ","ဇွန်","ဇူလိုင်","သြဂုတ်","စက်တင်ဘာ","အောက်တိုဘာ","နိုဝင်ဘာ","ဒီဇင်ဘာ"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0};gn.l10ns.my=pn,gn.l10ns;var wn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},vn={weekdays:{shorthand:["zo","ma","di","wo","do","vr","za"],longhand:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"]},months:{shorthand:["jan","feb","mrt","apr","mei","jun","jul","aug","sept","okt","nov","dec"],longhand:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]},firstDayOfWeek:1,weekAbbreviation:"wk",rangeSeparator:" t/m ",scrollTitle:"Scroll voor volgende / vorige",toggleTitle:"Klik om te wisselen",time_24hr:!0,ordinal:function(ae){return ae===1||ae===8||ae>=20?"ste":"de"}};wn.l10ns.nl=vn,wn.l10ns;var Cn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},bn={weekdays:{shorthand:["Sø.","Må.","Ty.","On.","To.","Fr.","La."],longhand:["Søndag","Måndag","Tysdag","Onsdag","Torsdag","Fredag","Laurdag"]},months:{shorthand:["Jan","Feb","Mars","Apr","Mai","Juni","Juli","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Veke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};Cn.l10ns.nn=bn,Cn.l10ns;var xn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Sn={weekdays:{shorthand:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],longhand:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Uke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};xn.l10ns.no=Sn,xn.l10ns;var yn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Dn={weekdays:{shorthand:["ਐਤ","ਸੋਮ","ਮੰਗਲ","ਬੁੱਧ","ਵੀਰ","ਸ਼ੁੱਕਰ","ਸ਼ਨਿੱਚਰ"],longhand:["ਐਤਵਾਰ","ਸੋਮਵਾਰ","ਮੰਗਲਵਾਰ","ਬੁੱਧਵਾਰ","ਵੀਰਵਾਰ","ਸ਼ੁੱਕਰਵਾਰ","ਸ਼ਨਿੱਚਰਵਾਰ"]},months:{shorthand:["ਜਨ","ਫ਼ਰ","ਮਾਰ","ਅਪ੍ਰੈ","ਮਈ","ਜੂਨ","ਜੁਲਾ","ਅਗ","ਸਤੰ","ਅਕ","ਨਵੰ","ਦਸੰ"],longhand:["ਜਨਵਰੀ","ਫ਼ਰਵਰੀ","ਮਾਰਚ","ਅਪ੍ਰੈਲ","ਮਈ","ਜੂਨ","ਜੁਲਾਈ","ਅਗਸਤ","ਸਤੰਬਰ","ਅਕਤੂਬਰ","ਨਵੰਬਰ","ਦਸੰਬਰ"]},time_24hr:!0};yn.l10ns.pa=Dn,yn.l10ns;var Mn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},kn={weekdays:{shorthand:["Nd","Pn","Wt","Śr","Cz","Pt","So"],longhand:["Niedziela","Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota"]},months:{shorthand:["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paź","Lis","Gru"],longhand:["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"]},rangeSeparator:" do ",weekAbbreviation:"tydz.",scrollTitle:"Przewiń, aby zwiększyć",toggleTitle:"Kliknij, aby przełączyć",firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return"."}};Mn.l10ns.pl=kn,Mn.l10ns;var En=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Tn={weekdays:{shorthand:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],longhand:["Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"]},months:{shorthand:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],longhand:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"]},rangeSeparator:" até ",time_24hr:!0};En.l10ns.pt=Tn,En.l10ns;var An=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Nn={weekdays:{shorthand:["Dum","Lun","Mar","Mie","Joi","Vin","Sâm"],longhand:["Duminică","Luni","Marți","Miercuri","Joi","Vineri","Sâmbătă"]},months:{shorthand:["Ian","Feb","Mar","Apr","Mai","Iun","Iul","Aug","Sep","Oct","Noi","Dec"],longhand:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"]},firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return""}};An.l10ns.ro=Nn,An.l10ns;var jn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},In={weekdays:{shorthand:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},months:{shorthand:["Янв","Фев","Март","Апр","Май","Июнь","Июль","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Нед.",scrollTitle:"Прокрутите для увеличения",toggleTitle:"Нажмите для переключения",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};jn.l10ns.ru=In,jn.l10ns;var Ln=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},On={weekdays:{shorthand:["ඉ","ස","අ","බ","බ්ර","සි","සෙ"],longhand:["ඉරිදා","සඳුදා","අඟහරුවාදා","බදාදා","බ්රහස්පතින්දා","සිකුරාදා","සෙනසුරාදා"]},months:{shorthand:["ජන","පෙබ","මාර්","අප්රේ","මැයි","ජුනි","ජූලි","අගෝ","සැප්","ඔක්","නොවැ","දෙසැ"],longhand:["ජනවාරි","පෙබරවාරි","මාර්තු","අප්රේල්","මැයි","ජුනි","ජූලි","අගෝස්තු","සැප්තැම්බර්","ඔක්තෝබර්","නොවැම්බර්","දෙසැම්බර්"]},time_24hr:!0};Ln.l10ns.si=On,Ln.l10ns;var Rn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Fn={weekdays:{shorthand:["Ned","Pon","Ut","Str","Štv","Pia","Sob"],longhand:["Nedeľa","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Máj","Jún","Júl","Aug","Sep","Okt","Nov","Dec"],longhand:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};Rn.l10ns.sk=Fn,Rn.l10ns;var Pn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_n={weekdays:{shorthand:["Ned","Pon","Tor","Sre","Čet","Pet","Sob"],longhand:["Nedelja","Ponedeljek","Torek","Sreda","Četrtek","Petek","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Marec","April","Maj","Junij","Julij","Avgust","September","Oktober","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};Pn.l10ns.sl=_n,Pn.l10ns;var Vn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Gn={weekdays:{shorthand:["Di","Hë","Ma","Më","En","Pr","Sh"],longhand:["E Diel","E Hënë","E Martë","E Mërkurë","E Enjte","E Premte","E Shtunë"]},months:{shorthand:["Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gus","Sht","Tet","Nën","Dhj"],longhand:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"]},firstDayOfWeek:1,rangeSeparator:" deri ",weekAbbreviation:"Java",yearAriaLabel:"Viti",monthAriaLabel:"Muaji",hourAriaLabel:"Ora",minuteAriaLabel:"Minuta",time_24hr:!0};Vn.l10ns.sq=Gn,Vn.l10ns;var Bn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Hn={weekdays:{shorthand:["Ned","Pon","Uto","Sre","Čet","Pet","Sub"],longhand:["Nedelja","Ponedeljak","Utorak","Sreda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Jun","Jul","Avgust","Septembar","Oktobar","Novembar","Decembar"]},firstDayOfWeek:1,weekAbbreviation:"Ned.",rangeSeparator:" do ",time_24hr:!0};Bn.l10ns.sr=Hn,Bn.l10ns;var Un=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Wn={firstDayOfWeek:1,weekAbbreviation:"v",weekdays:{shorthand:["sön","mån","tis","ons","tor","fre","lör"],longhand:["söndag","måndag","tisdag","onsdag","torsdag","fredag","lördag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"]},rangeSeparator:" till ",time_24hr:!0,ordinal:function(){return"."}};Un.l10ns.sv=Wn,Un.l10ns;var zn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},$n={weekdays:{shorthand:["อา","จ","อ","พ","พฤ","ศ","ส"],longhand:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"]},months:{shorthand:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],longhand:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"]},firstDayOfWeek:1,rangeSeparator:" ถึง ",scrollTitle:"เลื่อนเพื่อเพิ่มหรือลด",toggleTitle:"คลิกเพื่อเปลี่ยน",time_24hr:!0,ordinal:function(){return""}};zn.l10ns.th=$n,zn.l10ns;var Jn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Yn={weekdays:{shorthand:["Paz","Pzt","Sal","Çar","Per","Cum","Cmt"],longhand:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"]},months:{shorthand:["Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara"],longhand:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmak için kaydırın",toggleTitle:"Aç/Kapa",amPM:["ÖÖ","ÖS"],time_24hr:!0};Jn.l10ns.tr=Yn,Jn.l10ns;var qn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Kn={firstDayOfWeek:1,weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},months:{shorthand:["Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру"],longhand:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"]},time_24hr:!0};qn.l10ns.uk=Kn,qn.l10ns;var Zn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Xn={weekdays:{shorthand:["Якш","Душ","Сеш","Чор","Пай","Жум","Шан"],longhand:["Якшанба","Душанба","Сешанба","Чоршанба","Пайшанба","Жума","Шанба"]},months:{shorthand:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январ","Феврал","Март","Апрел","Май","Июн","Июл","Август","Сентябр","Октябр","Ноябр","Декабр"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Ҳафта",scrollTitle:"Катталаштириш учун айлантиринг",toggleTitle:"Ўтиш учун босинг",amPM:["AM","PM"],yearAriaLabel:"Йил",time_24hr:!0};Zn.l10ns.uz=Xn,Zn.l10ns;var Qn=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},es={weekdays:{shorthand:["Ya","Du","Se","Cho","Pa","Ju","Sha"],longhand:["Yakshanba","Dushanba","Seshanba","Chorshanba","Payshanba","Juma","Shanba"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","Iyun","Iyul","Avg","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","Iyun","Iyul","Avgust","Sentabr","Oktabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Hafta",scrollTitle:"Kattalashtirish uchun aylantiring",toggleTitle:"O‘tish uchun bosing",amPM:["AM","PM"],yearAriaLabel:"Yil",time_24hr:!0};Qn.l10ns.uz_latn=es,Qn.l10ns;var ts=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ns={weekdays:{shorthand:["CN","T2","T3","T4","T5","T6","T7"],longhand:["Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy"]},months:{shorthand:["Th1","Th2","Th3","Th4","Th5","Th6","Th7","Th8","Th9","Th10","Th11","Th12"],longhand:["Tháng một","Tháng hai","Tháng ba","Tháng tư","Tháng năm","Tháng sáu","Tháng bảy","Tháng tám","Tháng chín","Tháng mười","Tháng mười một","Tháng mười hai"]},firstDayOfWeek:1,rangeSeparator:" đến "};ts.l10ns.vn=ns,ts.l10ns;var ss=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},rs={weekdays:{shorthand:["周日","周一","周二","周三","周四","周五","周六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"周",scrollTitle:"滚动切换",toggleTitle:"点击切换 12/24 小时时制"};ss.l10ns.zh=rs,ss.l10ns;var as=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},is={weekdays:{shorthand:["週日","週一","週二","週三","週四","週五","週六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"週",scrollTitle:"滾動切換",toggleTitle:"點擊切換 12/24 小時時制"};as.l10ns.zh_tw=is,as.l10ns;var Ma={ar:i,at:f,az:c,be:m,bg:C,bn:y,bs:p,ca:b,ckb:E,cat:b,cs:A,cy:I,da:M,de:_,default:s({},F),en:F,eo:V,es:Z,et:K,fa:Y,fi:me,fo:ne,fr:oe,gr:Ce,he:we,hi:Ee,hr:De,hu:Le,hy:R,id:$,is:re,it:Me,ja:Ae,ka:L,ko:U,km:X,kz:xe,lt:We,lv:un,mk:fn,mn:hn,ms:Da,my:pn,nl:vn,nn:bn,no:Sn,pa:Dn,pl:kn,pt:Tn,ro:Nn,ru:In,si:On,sk:Fn,sl:_n,sq:Gn,sr:Hn,sv:Wn,th:$n,tr:Yn,uk:Kn,vn:ns,zh:rs,zh_tw:is,uz:Xn,uz_latn:es};n.default=Ma,Object.defineProperty(n,"__esModule",{value:!0})}))})(tt,tt.exports)),tt.exports}var li=oi();const ci=fr(li);var ct={exports:{}},ui=ct.exports,fs;function di(){return fs||(fs=1,(function(e,t){(function(n,s){e.exports=s()})(ui,(function(){var n=function(){return n=Object.assign||function(c){for(var l,m=1,h=arguments.length;m<h;m++){l=arguments[m];for(var p in l)Object.prototype.hasOwnProperty.call(l,p)&&(c[p]=l[p])}return c},n.apply(this,arguments)},s=function(o,c,l){return l.months[c?"shorthand":"longhand"][o]};function r(o){for(;o.firstChild;)o.removeChild(o.firstChild)}function i(o){try{if(typeof o.composedPath=="function"){var c=o.composedPath();return c[0]}return o.target}catch{return o.target}}var d={shorthand:!1,dateFormat:"F Y",altFormat:"F Y",theme:"light"};function f(o){var c=n(n({},d),o);return function(l){l.config.dateFormat=c.dateFormat,l.config.altFormat=c.altFormat;var m={monthsContainer:null};function h(){if(l.rContainer){r(l.rContainer);for(var k=0;k<l.monthElements.length;k++){var M=l.monthElements[k];M.parentNode&&M.parentNode.removeChild(M)}}}function p(){l.rContainer&&(m.monthsContainer=l._createElement("div","flatpickr-monthSelect-months"),m.monthsContainer.tabIndex=-1,g(),l.rContainer.appendChild(m.monthsContainer),l.calendarContainer.classList.add("flatpickr-monthSelect-theme-"+c.theme))}function g(){if(m.monthsContainer){r(m.monthsContainer);for(var k=document.createDocumentFragment(),M=0;M<12;M++){var j=l.createDay("flatpickr-monthSelect-month",new Date(l.currentYear,M),0,M);j.dateObj.getMonth()===new Date().getMonth()&&j.dateObj.getFullYear()===new Date().getFullYear()&&j.classList.add("today"),j.textContent=s(M,c.shorthand,l.l10n),j.addEventListener("click",x),k.appendChild(j)}m.monthsContainer.appendChild(k),l.config.minDate&&l.currentYear===l.config.minDate.getFullYear()?l.prevMonthNav.classList.add("flatpickr-disabled"):l.prevMonthNav.classList.remove("flatpickr-disabled"),l.config.maxDate&&l.currentYear===l.config.maxDate.getFullYear()?l.nextMonthNav.classList.add("flatpickr-disabled"):l.nextMonthNav.classList.remove("flatpickr-disabled")}}function C(){l._bind(l.prevMonthNav,"click",function(k){k.preventDefault(),k.stopPropagation(),l.changeYear(l.currentYear-1),y(),g()}),l._bind(l.nextMonthNav,"click",function(k){k.preventDefault(),k.stopPropagation(),l.changeYear(l.currentYear+1),y(),g()}),l._bind(m.monthsContainer,"mouseover",function(k){l.config.mode==="range"&&l.onMouseOver(i(k),"flatpickr-monthSelect-month")})}function w(){if(l.rContainer&&l.selectedDates.length){for(var k=l.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected"),M=0;M<k.length;M++)k[M].classList.remove("selected");var j=l.selectedDates[0].getMonth(),_=l.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child("+(j+1)+")");_&&_.classList.add("selected")}}function y(){var k=l.selectedDates[0];if(k&&(k=new Date(k),k.setFullYear(l.currentYear),l.config.minDate&&k<l.config.minDate&&(k=l.config.minDate),l.config.maxDate&&k>l.config.maxDate&&(k=l.config.maxDate),l.currentYear=k.getFullYear()),l.currentYearElement.value=String(l.currentYear),l.rContainer){var M=l.rContainer.querySelectorAll(".flatpickr-monthSelect-month");M.forEach(function(j){j.dateObj.setFullYear(l.currentYear),l.config.minDate&&j.dateObj<l.config.minDate||l.config.maxDate&&j.dateObj>l.config.maxDate?j.classList.add("flatpickr-disabled"):j.classList.remove("flatpickr-disabled")})}w()}function x(k){k.preventDefault(),k.stopPropagation();var M=i(k);if(M instanceof Element&&!M.classList.contains("flatpickr-disabled")&&!M.classList.contains("notAllowed")&&(b(M.dateObj),l.config.closeOnSelect)){var j=l.config.mode==="single",_=l.config.mode==="range"&&l.selectedDates.length===2;(j||_)&&l.close()}}function b(k){var M=new Date(l.currentYear,k.getMonth(),k.getDate()),j=[];switch(l.config.mode){case"single":j=[M];break;case"multiple":j.push(M);break;case"range":l.selectedDates.length===2?j=[M]:(j=l.selectedDates.concat([M]),j.sort(function(_,F){return _.getTime()-F.getTime()}));break}l.setDate(j,!0),w()}var D={37:-1,39:1,40:3,38:-3};function E(k,M,j,_){var F=D[_.keyCode]!==void 0;if(!(!F&&_.keyCode!==13)&&!(!l.rContainer||!m.monthsContainer)){var B=l.rContainer.querySelector(".flatpickr-monthSelect-month.selected"),V=Array.prototype.indexOf.call(m.monthsContainer.children,document.activeElement);if(V===-1){var z=B||m.monthsContainer.firstElementChild;z.focus(),V=z.$i}F?m.monthsContainer.children[(12+V+D[_.keyCode])%12].focus():_.keyCode===13&&m.monthsContainer.contains(document.activeElement)&&b(document.activeElement.dateObj)}}function T(){var k;((k=l.config)===null||k===void 0?void 0:k.mode)==="range"&&l.selectedDates.length===1&&l.clear(!1),l.selectedDates.length||g()}function A(){c._stubbedCurrentMonth=l._initialDate.getMonth(),l._initialDate.setMonth(c._stubbedCurrentMonth),l.currentMonth=c._stubbedCurrentMonth}function N(){c._stubbedCurrentMonth&&(l._initialDate.setMonth(c._stubbedCurrentMonth),l.currentMonth=c._stubbedCurrentMonth,delete c._stubbedCurrentMonth)}function I(){if(m.monthsContainer!==null)for(var k=m.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month"),M=0;M<k.length;M++)k[M].removeEventListener("click",x)}return{onParseConfig:function(){l.config.enableTime=!1},onValueUpdate:w,onKeyDown:E,onReady:[A,h,p,C,w,function(){l.config.onClose.push(T),l.loadedPlugins.push("monthSelect")}],onDestroy:[N,I,function(){l.config.onClose=l.config.onClose.filter(function(k){return k!==T})}]}}}return f}))})(ct)),ct.exports}var fi=di();const mi=fr(fi),ms=(e,t,n,s,r=!1,i)=>{const d={...ci[s]},f=mi;r&&(d.firstDayOfWeek=1);const o={minDate:n===J.CalendarResolution.MONTH?new Date(e.getFullYear(),e.getMonth()):e,maxDate:n===J.CalendarResolution.MONTH?new Date(t.getFullYear(),t.getMonth()):t,locale:d};return n===J.CalendarResolution.MONTH?{...o,dateFormat:"M Y",plugins:[new f({shorthand:!0,dateFormat:"M Y"})]}:{...o,monthSelectorType:"static",dateFormat:i||"d.m.Y"}},hs=e=>{e?.setMinutes(e.getMinutes()-e.getTimezoneOffset())},hi={year:"numeric",month:"short",day:"numeric"},gt=(e,t)=>e?.toLocaleDateString(t,hi)||"",gi=(e,t)=>{const{startPeriod:n,endPeriod:s}=e;if(!t.startPeriod&&!t.endPeriod&&n&&s)return{startPeriod:new Date(n?.getTime()),endPeriod:new Date(s?.getTime())};const r=n?new Date(Math.max(n.getTime(),t.startPeriod.getTime())):t.startPeriod,i=s?new Date(Math.min(s.getTime(),t.endPeriod.getTime())):t.endPeriod;return{startPeriod:r,endPeriod:i}},pi=(e,t)=>{const{endPeriod:n}=e,s=n?.getFullYear()||new Date().getFullYear(),r=s+ +t,i=new Date(+t<0?s:r,n?.getMonth()||0,n?.getDate()||1),d=new Date(+t<0?r:s,0,1);return{startPeriod:new Date(Math.max(d.getTime(),e?.startPeriod?.getTime()||0)),endPeriod:i}},wi=e=>({quarterly:e?.quarterly||"Q",monthly:e?.monthly||"M"}),mr=(e,t)=>{const n=wi(t);return S.isQuarterly(e)&&n?.quarterly?e?.replace(/Q/g,n?.quarterly):S.isMonthly(e)&&n?.monthly?e?.replace(/M/g,n?.monthly):e};var qe=(e=>(e.FLAT_LIST="FLAT_LIST",e.HIERARCHY="HIERARCHY",e))(qe||{});const hr=(e,t,n,s,r)=>e?.map(i=>{const d=S.findCodelistByDimension(t?.codelists,t?.conceptSchemes,i)?.codes,f=S.getAvailableCodes(i,n,d,s),o=d?.some(c=>c?.parent);return{id:i?.id,title:S.getDimensionTitle(t?.conceptSchemes,i,s),dimensionValues:f,isTimeDimension:i?.type===S.DimensionType.TIME_DIMENSION,isHierarchical:o,displayMode:o?qe.HIERARCHY:qe.FLAT_LIST,datasetUrn:r,filterType:"dataset"}})||[],vi=e=>e?.filterType==="shared",It=e=>{if(e?.id)return vi(e)?`shared:${e.id}`:e?.datasetUrn?`${e.datasetUrn}:${e.id}`:e.id},Ge=(e,t)=>It(e)===It(t),pt=(e,t)=>e?.map(n=>t&&Ge(n,t)?{...t,isSelectedFilter:!0}:{...n,isSelectedFilter:!1}),gr=(e,t,n)=>e?e.map(s=>Ge(s,t)?{...s,displayMode:n}:s):[],pr=e=>e?.filter(t=>!!t?.isSelectedValue)||[],Bt=e=>e?.map(t=>({...t,dimensionValues:pr(t?.dimensionValues)})).filter(t=>t.dimensionValues?.length||t.timeRange?.startPeriod||t.timeRange?.endPeriod),wr=e=>e?.reduce((t,n)=>(n?.dimensionValues?.length??0)+t,0)||0,vr=e=>({...e,dimensionValues:e?.dimensionValues?.map(t=>({...t,isSelectedValue:!1})),timeRange:void 0}),Cr=(e,t)=>e?.map(n=>Ge(n,t)?vr(n):n),br=e=>e?.map(t=>vr(t)),xr=(e,t,n)=>e.map(s=>{const r=t?.filters.find(d=>d.componentCode===s.id);let i=[];if(r)if(s.isTimeDimension){const d=r.values.filter(m=>!!m),f=S.getAnnotationPeriod(n?.[0]?.annotations),o=d[0]?J.getTimePeriod(d[0]):null,c=d[1]?J.getTimePeriod(d[1]):null;let l=f;return o&&c&&(l=f?gi({startPeriod:o,endPeriod:c},f):{startPeriod:o,endPeriod:c}),{...s,timeRange:l}}else i=s?.dimensionValues?.map(f=>r?.values?.includes(f.id)?{...f,isSelectedValue:!0}:f);else i=s.dimensionValues;return{...s,dimensionValues:i}}),wt=e=>e?.map(t=>({...t,isDisabled:!0})),Ci=e=>new Map(e?.map(t=>[t.id,{...t,children:[]}])),bi=e=>{if(!e)return[];const t=Ci(e),n=[];return e.forEach(s=>{if(s&&s.parent){const r=t.get(s.parent),i=t.get(s.id);r&&r.children&&i&&(r.children=[...r.children,i])}else{const r=t.get(s.id);r&&n.push(r)}}),n},xi=(e,t=!1)=>t?`${e*v.TREE_NODE_PADDING-v.TREE_NODE_ARROW_SIZE}px`:`${e*v.TREE_NODE_PADDING}px`,nt=e=>e?.children?.reduce((t,n)=>[...t,n,...nt(n)],[])||[],ot=(e,t)=>e?e.map(n=>({...n,isSelectedValue:t})):[],Si=e=>{const t=e.children?.every(s=>s.isSelectedValue),n=e.children?.every(s=>!s.isSelectedValue);if(e.isSelectedValue){if(e.isSelectedValue&&t)return[{...e,isSelectedValue:!1},...ot(nt(e),!0)]}else{if(n)return[{...e,isSelectedValue:!0},...ot(nt(e),!0)];if(t)return[{...e,isSelectedValue:!0},...ot(nt(e),!1)]}return[{...e,isSelectedValue:!1},...ot(nt(e),!1)]},yi=e=>[{key:qe.HIERARCHY,title:e?.hierarchy||"Hierarchy"},{key:qe.FLAT_LIST,title:e?.flatList||"Flat list"}],Di=({calendarResolution:e,timeRange:t,timeRangeOptions:n,calendarStartFromMonday:s=!0,locale:r=J.Locale.EN,radioIcon:i,initialConstraints:d,onValueChange:f,calendarIcon:o,dateFormat:c,titles:l,defaultTimeOption:m})=>{const h=S.getAnnotationPeriod(d?.[0]?.annotations),[p,g]=u.useState(t),C=!t||t?.startPeriod?.getTime()===h?.startPeriod?.getTime()&&t?.endPeriod?.getTime()===h?.endPeriod?.getTime()?0:J.CUSTOM_PERIOD,[w,y]=u.useState(m??C),x=u.useMemo(()=>{const{startPeriod:A,endPeriod:N}=h,I=A?.getFullYear(),k=N?.getFullYear(),M=new Date().getFullYear();return n.filter(j=>j.value===J.CUSTOM_PERIOD||j.value===0||+j.value>=0&&k-M>=+j.value||+j.value<0&&I-M<+j.value)},[h,n]);u.useEffect(()=>{f(p,w)},[p]);const b=A=>{A&&(hs(A),g(N=>N?{...N,startPeriod:A||null}:{endPeriod:null,startPeriod:A||null}))},D=A=>{A&&(hs(A),g(N=>N?{...N,endPeriod:A||null}:{startPeriod:null,endPeriod:A||null}))};if(h==null)return null;const E=ms(h.startPeriod,p?.endPeriod||h.endPeriod,e,r,s,c),T=ms(p?.startPeriod||h.startPeriod,h.endPeriod,e,r,s,c);return a.jsxs("div",{className:"mt-3 overflow-auto flex flex-col pt-2 pb-2 pr-3 h-full flex-1 min-w-0",children:[a.jsx("div",{className:"w-full",children:x.map(A=>a.jsx(v.Radio,{id:A.value.toString(),checked:w===A.value,label:A.title,onChange:()=>{const{value:N}=A;y(N),N!==J.CUSTOM_PERIOD&&g(N===0?h:pi(h,N))},radioIcon:i},A.value.toString()))}),a.jsx("div",{className:"w-full",children:w===J.CUSTOM_PERIOD&&a.jsxs("div",{className:"flex filters-time-period gap-4 mt-3 caption text-neutral-700",children:[a.jsx(v.Calendar,{onChange:b,options:E,value:p?.startPeriod||h?.startPeriod,label:l?.from||"From",id:"time-options-start",icon:o}),a.jsx(v.Calendar,{onChange:D,options:T,value:p?.endPeriod||h?.endPeriod,label:l?.to||"To",id:"time-options-end",icon:o,isEndDate:!0})]})})]})},Mi=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M6.25 4.66668L9.75 8.00001L6.25 11.3333L6.25 4.66668Z",fill:"currentColor"})),Sr=({node:e,level:t=1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:i})=>{const[d,f]=u.useState(!1),o="cursor-pointer text-neutrals-1000 w-6 h-6 shrink-0";u.useEffect(()=>{f(!!e?.children?.length)},[e]);const c=(l,m)=>{e?.children?.length?r?.(Si(e)):s?.(l,m)};return a.jsxs("div",{className:"flex flex-col",children:[a.jsxs("div",{className:"flex items-center",style:{paddingLeft:xi(t,d)},children:[d&&(e?.isExpanded?a.jsx(Mi,{className:o,onClick:()=>i?.(e)}):a.jsx(Gt,{className:o,onClick:()=>i?.(e)})),a.jsx(v.Checkbox,{id:e?.id,label:e?.name,checked:!!e.isSelectedValue,checkboxIcon:n,onChange:c})]}),d&&e?.isExpanded&&a.jsx(a.Fragment,{children:e?.children?.map(l=>a.jsx(Sr,{node:l,level:t+1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:i},l?.id))})]},e?.id)},ki=({filterValues:e,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r})=>{const[i,d]=u.useState([]);return u.useEffect(()=>{d(bi(e))},[e]),i?.map(f=>a.jsx(Sr,{node:f,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r},f?.id))},Ei=({style:e,filterValue:t,checkboxIcon:n,selectFilterValue:s})=>a.jsx("div",{style:e,children:a.jsx(v.Checkbox,{id:t.id,label:t.name,checked:!!t.isSelectedValue,checkboxIcon:n,onChange:s})}),Ti=Ta.FixedSizeList,gs=24,ps=232,Ai=({filterValues:e,checkboxIcon:t,isHierarchicalView:n,isDisableValues:s,selectFilterValue:r,selectHierarchicalNodes:i,expandHierarchicalValue:d})=>{const f=v.useIsMobile();if(!e)return null;const o=e.length*gs,c=o>ps?ps:o;return a.jsx("div",{className:P(s&&"pointer-events-none opacity-[0.7]","h-full overflow-auto"),style:{height:f?c+"px":"100%"},children:n?a.jsx(ki,{filterValues:e,checkboxIcon:t,selectFilterValue:r,selectHierarchicalNodes:i,expandHierarchicalValue:d}):a.jsx(Aa,{children:({width:l,height:m})=>a.jsx(Ti,{itemCount:e.length,itemSize:gs,width:l,height:m,children:({index:h,style:p})=>a.jsx(Ei,{index:h,style:p,filterValue:e[h],checkboxIcon:t,selectFilterValue:r})})})})},yr=({selectedFilter:e,filterValuesProps:t,locale:n,isDisableValues:s,timeRangeOptions:r,onTimePeriodChange:i,selectFilterValue:d,titles:f,initialConstraints:o,selectHierarchicalNodes:c,expandHierarchicalValue:l,selectedTimeOption:m})=>{const[h,p]=u.useState(""),[g,C]=u.useState([]),w=e?.displayMode===qe.HIERARCHY;u.useEffect(()=>{const x=e?.dimensionValues?.filter(b=>b?.name?.toLowerCase()?.includes(h?.toLowerCase()))||[];C(w?S.getFilteredItemsWithParents(e?.dimensionValues,x):x)},[w,h,e?.dimensionValues]),u.useEffect(()=>{p("")},[e]);const y=u.useCallback(x=>{p(x)},[p]);return a.jsx(a.Fragment,{children:e?.isTimeDimension&&o?a.jsx(Di,{titles:f,initialConstraints:o,calendarResolution:J.CalendarResolution.DAY,timeRange:e?.timeRange||null,timeRangeOptions:r||[],calendarStartFromMonday:!0,locale:n,radioIcon:t?.radioIcon,onValueChange:i,calendarIcon:t?.calendarIcon,dateFormat:t?.dateFormat,defaultTimeOption:m}):a.jsxs("div",{className:P("flex flex-col pt-2 pb-2 h-full flex-1 min-w-0 sm:border-0","filter-values-container"),children:[a.jsx(v.InputWithIcon,{inputId:"filters-search-input",containerClasses:"gap-2 items-center filters-search-input",cssClass:"filters-search-input-text",placeholder:f?.searchPlaceholder??"Search",value:h,onChange:y,iconBeforeInput:a.jsx(ke.IconSearch,{width:t?.searchIconSize,height:t?.searchIconSize,className:"text-primary"})}),a.jsx("div",{className:"flex flex-col mt-3 body-2 overflow-auto flex-1 min-h-0",children:a.jsx(Ai,{filterValues:h?g:e?.dimensionValues,checkboxIcon:t?.checkboxIcon,isHierarchicalView:w,isDisableValues:s,selectFilterValue:d,selectHierarchicalNodes:c,expandHierarchicalValue:l})})]})})},Ni=({filter:e,onSelectFilter:t,onSelectDisplayMode:n,onDeleteFilter:s,locale:r,titles:i,initialConstraints:d,datasetIcon:f,datasetName:o,hideFacetCounterByDefault:c,filterValuesProps:l,isDisableValues:m,timeRangeOptions:h,onTimePeriodChange:p,selectFilterValue:g,selectHierarchicalNodes:C,expandHierarchicalValue:w})=>{const y=v.useIsMobile(),[x,b]=u.useState(0),[D,E]=u.useState(!1),T=e?.isTimeDimension&&e?.timeRange,A=u.useMemo(()=>e?.timeRange?.startPeriod&&e?.timeRange?.endPeriod?`${gt(e?.timeRange?.startPeriod,r)} -
|
|
6
|
-
${gt(e?.timeRange?.endPeriod,r)}`:"",[r,e?.timeRange]);u.useEffect(()=>{b(pr(e?.dimensionValues)?.length)},[e?.dimensionValues]);const N=M=>{n?.(e,M)},I=c?x>0:!0;u.useEffect(()=>{e.isSelectedFilter||E(!1)},[e.isSelectedFilter]);const k=()=>{y&&E(M=>!M),t(e)};return a.jsxs("div",{className:"flex flex-col",children:[o&&a.jsxs("h4",{className:"filters-facet-dataset-name",children:[a.jsx("span",{className:"filters-facet-dataset-icon",children:f}),o]}),a.jsxs("div",{className:P("flex justify-between items-center p-2 hover:bg-hues-100 py-2 sm:py-4 sm:hover:bg-white","filters-facet-item cursor-pointer",e?.isSelectedFilter&&!y&&"bg-hues-100",e?.isDisabled&&"cursor-default pointer-events-none opacity-[0.7]"),onClick:k,children:[a.jsxs("h3",{className:"w-full truncate flex-1 min-w-0 sm:flex sm:items-center",title:e?.title,children:[a.jsx("span",{className:"truncate",children:e?.title}),y&&a.jsx(Gt,{className:P("chevron-icon w-6 h-6 shrink-0",D&&"rotate-180")})]}),a.jsxs("div",{className:"ml-2 flex gap-2 items-center text-neutrals-800",children:[T&&a.jsx("span",{className:"filters-facet-item-counter border-none",children:A}),!T&&I&&a.jsx("span",{className:P("px-2 text-center","filters-facet-item-counter"),children:x?`${x}/${e?.dimensionValues?.length||0}`:i?.all||"All"}),T?null:a.jsxs("div",{className:"flex items-center gap-2 filters-facet-item-settings",children:[a.jsx(v.Dropdown,{triggerButton:a.jsx(v.IconButton,{buttonClassName:P("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:a.jsx(ai,{width:16,height:16}),title:i?.displayOrder||"Display Order",disabled:!e?.isHierarchical}),options:yi(i),selectedOption:e?.displayMode,disabled:!e?.isHierarchical,onOptionSelect:N}),x>0&&a.jsx(v.IconButton,{buttonClassName:P("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:a.jsx(ri,{width:16,height:16}),title:i?.reset||"Reset",onClick:M=>{M.stopPropagation(),s?.(e)}})]})]})]}),D&&a.jsx(yr,{titles:i,selectedFilter:e,locale:r,isDisableValues:m,timeRangeOptions:h,selectFilterValue:g,selectHierarchicalNodes:C,expandHierarchicalValue:w,onTimePeriodChange:p,filterValuesProps:l,initialConstraints:d})]})},ut=(e,t,n,s,r=J.Locale.EN)=>{const i=t?.map(d=>{const f=S.findCodelistByDimension(n?.codelists,n?.conceptSchemes,d),o=S.getAvailableCodesFromConstrains(f?.codes,d.id,s,r);return{...d,dimensionValues:o}});return e?.map(d=>{const o=(i?.find(c=>c.id===d.id)?.dimensionValues||[]).map(c=>{const l=d.dimensionValues?.find(m=>m?.id===c?.id)?.isSelectedValue;return{...c,isSelectedValue:l}});return{...d,isDisabled:!1,dimensionValues:o}})||[]},ji="COUNTRY",Ii="FREQUENCY",ws=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Li(n):Oi(t||"",e.id)},Li=e=>`name:${e}`,Oi=(e,t)=>`dataset:${e}:id:${t}`,Dr=[{id:ji,getMergedValueKey:ws()},{id:Ii,getMergedValueKey:ws()}],Ri=new Map(Dr.map(e=>[e.id,e])),Fi=e=>e?Ri.get(e):void 0,Mr=e=>!!Fi(e),Pi=e=>e?.filterType==="shared"&&Mr(e?.id),_i=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(r=>{const i=t.getMergedValueKey(r,s.datasetUrn),d={datasetUrn:s.datasetUrn,id:r.id,name:r.name,parent:r.parent},f=n.get(i);if(f){f.isSelectedValue=f.isSelectedValue||r.isSelectedValue,f.sourceValues=[...f.sourceValues||[],d];return}n.set(i,{id:i,name:r.name,isSelectedValue:r.isSelectedValue,parent:r.parent,sourceValues:[d]})})}),Array.from(n.values())},kr=e=>{const t=new Map,n=[];return e.forEach(r=>{if(Mr(r?.id)&&r?.datasetUrn){const i=t.get(r.id)||[];t.set(r.id,[...i,r]);return}n.push(r)}),[...Dr.flatMap(r=>{const i=t.get(r.id);return i?.length?{...i[0],datasetUrn:void 0,filterType:"shared",dimensionValues:_i(i,r)}:[]}),...n]},Vi=e=>{if(!Pi(e))return[e];const t=new Map;return e.dimensionValues?.forEach(n=>{n.sourceValues?.forEach(s=>{const r=s.datasetUrn||"",i=t.get(r),d={id:s.id,name:s.name,parent:s.parent,isSelectedValue:n.isSelectedValue};if(i){i.dimensionValues=[...i.dimensionValues||[],d];return}t.set(r,{...e,datasetUrn:r,filterType:"dataset",dimensionValues:[d]})})}),Array.from(t.values())},Gi=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,hr(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,Bi=(e,t)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([n,s])=>{const r=s?.map(i=>{const d=S.findCodelistByDimension(e?.structuresMap?.get(n)?.codelists,e?.structuresMap?.get(n)?.conceptSchemes,i),f=S.getAvailableCodesFromConstrains(d?.codes,i.id,e?.constraintsMap?.get(n),t);return{...i,dimensionValues:f}})||[];return[n,r]})),Hi=(e,t)=>{const n=Gi(e,t),s=Bi(e,t);return new Map(Array.from(n?.entries()||[]).map(([r,i])=>{const d=s?.get(r),f=i.map(o=>({...o,dimensionValues:d?.find(c=>c.id===o.id)?.dimensionValues||[]}));return[r,f]}))},Ui=(e,t,n)=>kr(t?.flatMap(s=>{const r=s?.urn,i=e?.get(r)||[],d=n?.get(r)||[];return xr(i,s,d)})||[]),Lt=e=>e?.flatMap(t=>Vi(t))?.reduce((t,n)=>{const s=n?.datasetUrn||"";return t.has(s)||t.set(s,[]),t?.get(s)?.push(n),t},new Map),Tt=(e,t,n=J.Locale.EN)=>{const s=[];return Array.from(e?.entries())?.forEach(([r,i])=>{const d=t?.dimensionsMap?.get(r),f=t?.structuresMap?.get(r),o=t?.constraintsMap?.get(r);s.push(...ut(i,d,f,o,n))}),kr(s)},Ht=(e,t)=>t?Lt(e).get(t)||[]:e.filter(n=>n.filterType!=="shared"),Wi=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?S.generateShortUrn(n?.name,"",n?.agencyID):void 0},zi=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,$i=({filtersList:e,hideFacetCounterByDefault:t,locale:n,onSelectFilter:s,onDeleteFilter:r,onSelectDisplayMode:i,filterValuesProps:d,isDisableValues:f,timeRangeOptions:o,initialConstraints:c,datasetIcon:l,structuresMap:m,onTimePeriodChange:h,selectFilterValue:p,selectHierarchicalNodes:g,titles:C,expandHierarchicalValue:w})=>a.jsx("div",{className:P("overflow-y-auto advanced-view-filters-list min-w-[320px] pr-3 h-full sm:w-full"),children:e?.map(y=>a.jsx(Ni,{titles:C,locale:n,filter:y,onSelectFilter:s,onSelectDisplayMode:i,onDeleteFilter:r,hideFacetCounterByDefault:t,isDisableValues:f,timeRangeOptions:o,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:w,onTimePeriodChange:h,filterValuesProps:d,initialConstraints:c,datasetIcon:l,datasetName:Wi(y,m)},It(y)))}),Er=({filtersList:e,titles:t,selectedFilter:n,modalProps:s,locale:r,isDisableValues:i,timeSeriesCount:d,timeRangeOptions:f,initialConstraints:o,datasetIcon:c,structuresMap:l,setSelectedFilter:m,onSelectDisplayMode:h,onDeleteFilter:p,updateSelectedFilterValues:g,onTimePeriodChange:C,selectedTimeOption:w})=>{const y=v.useIsMobile(),x=u.useCallback(A=>{const N=e?.find(I=>Ge(I,A));if(!N){m(void 0);return}m({...N,isSelectedFilter:!0})},[e,m]),b=(A,N)=>{if(!n)return;const I={...n,dimensionValues:n?.dimensionValues?.map(k=>k?.id===A?{...k,isSelectedValue:N}:k)};m(I),g&&g(I)},D=A=>{if(!n)return;const N={...n,dimensionValues:n?.dimensionValues?.map(I=>A?.find(M=>M?.id===I?.id)||I)};m(N),g&&g(N)},E=A=>{n&&m({...n,dimensionValues:n?.dimensionValues?.map(N=>N?.id===A?.id?{...N,isExpanded:!A?.isExpanded}:N)})},T=(A,N)=>{if(!n)return;const I={...n,timeRange:A||void 0};C?.(N),m(I),g&&g(I)};return a.jsxs("div",{className:P("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[a.jsxs("div",{className:P("h-full sm:w-full",s?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[a.jsx($i,{filtersList:e,hideFacetCounterByDefault:s?.isHideFacetCounterByDefault,locale:r,titles:t,onSelectFilter:x,onSelectDisplayMode:h,onDeleteFilter:p,isDisableValues:i,initialConstraints:o,datasetIcon:c,structuresMap:l,timeRangeOptions:f,selectFilterValue:b,selectHierarchicalNodes:D,expandHierarchicalValue:E,onTimePeriodChange:T,filterValuesProps:s?.filterValuesProps}),s?.isShowTimeSeriesCount&&d?a.jsxs("h4",{className:"text-neutrals-800 my-4",children:[t?.timeSeries??"Timeseries",": ",d]}):null]}),!y&&a.jsx(yr,{selectedFilter:n,locale:r,titles:t,isDisableValues:i,timeRangeOptions:f,selectFilterValue:b,selectHierarchicalNodes:D,expandHierarchicalValue:E,onTimePeriodChange:T,filterValuesProps:s?.filterValuesProps,initialConstraints:o,selectedTimeOption:w})]})},vt=(e,t)=>{let n=[];return Ht(e,t).filter(s=>s.timeRange||s.dimensionValues?.some(r=>r.isSelectedValue)).forEach(s=>{const{id:r,dimensionValues:i}=s;s.isTimeDimension?n=[...n,...Ji(s.timeRange,r)]:n.push({componentCode:r,operator:S.SeriesFilterOperator.EQUALS,value:i?.filter(d=>d.isSelectedValue)?.map(d=>d.id).join(S.GET_v3_FILTER_AND)||""})}),n},Ji=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:S.SeriesFilterOperator.GREATER_OR_EQUAL,value:vs(new Date(e.startPeriod))},{componentCode:t,operator:S.SeriesFilterOperator.LESS_OR_EQUAL,value:vs(new Date(e.endPeriod),1)}],Yi=1e3*60*60*24,vs=(e,t=0)=>{e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMinutes(e.getMinutes()-e.getTimezoneOffset());let n=e.getTime();return n+=t?Yi-1:0,e=new Date(n),n.toString()},qi=e=>e.map(t=>({componentCode:t.id||"",operator:J.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),Tr=(e,t)=>{const n=t?.timeDimensions?.[0],s=S.getTimeRangeFromAttachment(e,n)||null;return s?S.getQueryTimePeriodFilters(s,n?.id):null},Ar=(e,t,n)=>{const s=Bt(Ht(e,n)),r=s.find(i=>i?.isTimeDimension&&i?.timeRange);return{filterKey:S.getTimeSeriesFilterKey(t||[],qi(s)),timeFilter:S.getQueryTimePeriodFilters(r?.timeRange,r?.id)}},Nr=(e,t)=>Ht(e,t)?.filter(n=>n.timeRange||n.dimensionValues?.some(s=>s.isSelectedValue)).map(n=>n?.isTimeDimension?{componentCode:n?.id,operator:J.QueryFilterType.BETWEEN,values:[Cs(n?.timeRange?.startPeriod||void 0)||"",Cs(n?.timeRange?.endPeriod||void 0)||""]}:{componentCode:n?.id,operator:J.QueryFilterType.IN,values:n?.dimensionValues?.filter(s=>s.isSelectedValue)?.map(s=>s.id)||[]}),Cs=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0"),s=e.getFullYear();return`${n}-${t}-${s}`},Ki=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||v.SERIES_LIMIT>e;return a.jsx("div",{className:"body-3 text-neutrals-800 sm:text-center flex gap-x-[4px] sm:justify-center items-center",children:n?a.jsx("span",{children:t?.seriesCount?.(e)}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:t?.warningIcon}),a.jsx("span",{children:t?.counterLimit?.(e,v.SERIES_LIMIT)})]})})},jr=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,titles:r,applyDisabled:i,timeseriesLength:d,limitMessages:f})=>{const o=v.useIsMobile();return a.jsxs("div",{className:P("flex py-4 px-6","modal-footer-wrapper",e?.isShowCancelButton?"justify-between":"gap-x-8 flex-row-reverse items-center justify-between sm:flex-col sm:gap-y-4 items-center"),children:[!e?.isShowCancelButton&&a.jsx(Ki,{timeseriesLength:d,limitMessages:f}),a.jsxs("div",{className:P("flex",e?.isShowCancelButton?"justify-between":"gap-x-8 flex-row-reverse justify-end sm:flex-col-reverse sm:gap-y-4 items-center"),children:[a.jsx(v.Button,{iconBefore:o?e?.resetIcon:void 0,buttonClassName:"text-button-tertiary p-0",title:e?.isShowClearIcon?r?.clearAllFilters??"Clear All Filters":r?.clearAll??"Clear All",onClick:()=>n(),isSmallButton:o}),a.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?a.jsx(v.Button,{buttonClassName:"text-button-tertiary sm:h8",title:r?.cancel??"Cancel",onClick:s,isSmallButton:o}):null,a.jsx(v.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:r?.apply??"Apply",onClick:t,isSmallButton:o,disabled:i})]})]})]})},Zi=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M3.33333 13.3327V8.66602H2V7.33268H6V8.66602H4.66667V13.3327H3.33333ZM3.33333 5.99935V2.66602H4.66667V5.99935H3.33333ZM6 5.99935V4.66602H7.33333V2.66602H8.66667V4.66602H10V5.99935H6ZM7.33333 13.3327V7.33268H8.66667V13.3327H7.33333ZM11.3333 13.3327V11.3327H10V9.99935H14V11.3327H12.6667V13.3327H11.3333ZM11.3333 8.66602V2.66602H12.6667V8.66602H11.3333Z",fill:"currentColor"}));var pe=(e=>(e.DATA_GRID="dataGrid",e.METADATA_PER_SERIES="metadataPerSeries",e.CHARTS="charts",e.CHARTS_NAVIGATION="chartsNavigation",e.OPEN_ADVANCED_VIEW="openAdvancedView",e.FILTERS="filters",e.CHART_PER_SERIES="chartPerSeries",e.METADATA_PER_DATASET="metadataPerDataset",e.EXIT_ADVANCED_VIEW="exitAdvancedView",e))(pe||{});const Ut=["charts","chartsNavigation"],bs=["dataGrid","metadataPerSeries",...Ut,"openAdvancedView"],Ir=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],He=(e,t)=>({title:t?.[`${e}Title`]||"",description:t?.[`${e}Description`]||""}),Ot=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Xi=(e,t)=>{if(!e||!t)return"";if(bs.includes(t)){const s=Ot(bs,e);if(s)return s}const n=Ot(Ir,e);return n||""},Lr=(e,t)=>{const n=Ot(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},Or=e=>Lr(Ir,e),Qi=e=>Lr(Ut,e),eo=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!Ut.includes(e.lastDisplayedElement),Pe=5,to=({targetPosition:e,overlayClasses:t,onClose:n})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-Pe,bottom:e.top+Pe}}),a.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+Pe,bottom:0}}),a.jsx("div",{className:"overlay overlay-left",style:{top:e.top-Pe,height:e.height+Pe*2,width:e.left,left:0-Pe,right:e.left-Pe*2}}),a.jsx("div",{className:"overlay overlay-right",style:{top:e.top-Pe,left:e.right+Pe,height:e.height+Pe*2,right:0}}),a.jsx("div",{className:P("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),Ue=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:r,shouldMoveToNextStep:i,supressReferenceClick:d})=>{const[f,o]=u.useState(!0),[c,l]=u.useState(!1),m=u.useRef(null),{isShowOnboarding:h,onboardingFileSchema:p,setOnboardingFileSchema:g}=Ne(),{refs:C,floatingStyles:w,context:y,placement:x}=Ie.useFloating({open:f,onOpenChange:o,placement:"right-start",elements:{reference:e?.current},middleware:[Ie.offset({mainAxis:12,crossAxis:-4}),Ie.flip(),Ie.shift(),Ie.arrow({element:m})],whileElementsMounted:Ie.autoUpdate}),b=Ie.useClick(y),{getFloatingProps:D}=Ie.useInteractions([b]),E=u.useCallback(()=>{if(h){const I=Xi(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,...I?{[I]:!0}:{}},lastDisplayedElement:I})}o?.(!1)},[h,p,g]);u.useEffect(()=>{C.setReference(e?.current??null)},[e,C]);const T=()=>E(),A=e?.current?.getBoundingClientRect();u.useEffect(()=>{r&&!c&&(E(),l(!0))},[r,E,c]);const N=()=>{s?(s?.(),i?E():o(!1)):d||(E(),e?.current?.click())};return a.jsx(a.Fragment,{children:f&&a.jsxs(Ie.FloatingPortal,{children:[A&&a.jsx(to,{overlayClasses:d?"cursor-default":"cursor-pointer",targetPosition:A,onClose:N}),a.jsxs("div",{ref:C.setFloating,style:w,...D(),className:"tooltip z-tooltip max-w-[350px]",children:[a.jsxs("div",{className:"tooltip-header",children:[a.jsx("h3",{children:t}),a.jsx(v.CloseButton,{btnClassNames:"w-4 h-4",onClick:T})]}),a.jsx("div",{className:"tooltip-description",children:a.jsx("p",{children:n})}),a.jsx("div",{ref:m,className:P("tooltip-arrow absolute w-3 h-3 rotate-45",x?.includes("right")?"left-[-4px]":"right-[-6px]",x?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},Rr=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,titles:r,isModalClosed:i,warningIcon:d,filterIconClassName:f,timeSeriesCount:o})=>{const c=u.useRef(null),[l,m]=u.useState(""),[h,p]=u.useState(""),[g,C]=u.useState(!1),{onboardingFileSchema:w,isShowOnboarding:y}=Ne(),x=v.SERIES_LIMIT<(o??0),b=u.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return u.useEffect(()=>{if(y){const{title:D,description:E}=He(pe.FILTERS,r);m(D),p(E)}},[r,y]),u.useEffect(()=>{y&&C(w?.lastDisplayedElement===pe.FILTERS)},[w?.lastDisplayedElement,y]),a.jsx("div",{className:"relative filter-button-container",ref:c,children:n?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[a.jsx(v.Button,{iconBefore:a.jsx(Zi,{className:P("size-4",f)}),iconAfter:x?d:void 0,title:b,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(v.PopUpState.Opened)}),e?.isShowBadge&&a.jsx("div",{className:"filter-count-badge",children:a.jsx("h5",{children:t})}),g&&a.jsx(Ue,{reference:c,title:l,description:h,onReferenceClick:()=>s(v.PopUpState.Opened),shouldCloseTooltip:i})]})})},xs=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function Wt(e){return e.type===ee.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function Fr(e){return e.type===ee.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function Pr(e){return e.type===ee.AttachmentType.MARKDOWN&&!Wt(e)}function no(e){return e.type===ee.AttachmentType.CSV}function zt(e){return e.type===ee.AttachmentType.TABLE}function ze(e){return e.type===ee.AttachmentType.CUSTOM_DATA_GRID}function dt(e){return e.type===ee.AttachmentType.CUSTOM_CHART}function so(e){return e.type===ee.AttachmentType.PLOTLY}function $t(e){return e.type===ee.AttachmentType.CUSTOM_CODE_SAMPLE}function _r(e){return e.type===ee.AttachmentType.CROSS_DATASET_GRID}const ro=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),ao=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(r=>Fr(r))?s:t,-1),io=e=>e?.reduce((t,n)=>n?.role===de.Role.Assistant?n:t,{}),oo=(e,t,n,s)=>({role:de.Role.System,content:"",custom_content:{attachments:n?.map(r=>({type:ee.AttachmentType.JSON,title:r?.title,data:JSON.stringify({urn:r?.urn,metadata:r?.metadata,filters:t?.urn===r?.urn?e:r?.filters})}))||[],form_schema:s?.custom_content?.form_schema}}),Vr=(e,t,n,s)=>{if(!e)return[];const r=e?.at(-1);return r&&r.role===de.Role.System&&e?.pop(),[...e,oo(t,n,s,io(e))]},Gr=(e,t,n)=>n?.map(s=>({...s,filters:t?.urn===s?.urn?e:s?.filters}))||[],lo=new WeakMap,co=new WeakMap,Br=new Set;function Hr(e,t,n){const s=e.get(t);if(s)return s;const r=n();return e.set(t,r),Br.add(r),r}function uo(e){return Hr(lo,e,()=>new Map)}function fo(e){return Hr(co,e,()=>new Map)}function _e(...e){return JSON.stringify(e)}async function Ve(e,t,n){const s=uo(e);if(s.has(t))return s.get(t);const r=fo(e),i=r.get(t);if(i)return i;const d=n().then(f=>(s.set(t,f),f)).finally(()=>{r.delete(t)});return r.set(t,d),d}function Ss(){Br.forEach(e=>e.clear())}const mo=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:r,modalProps:i,attachmentsDataQuery:d,dataQueries:f,initialConstraints:o,onFiltersChange:c,locale:l,timeRangeOptions:m,titles:h,conversationKey:p,conversation:g,setConversation:C,updateConversation:w,updateDataQueries:y,limitMessages:x,filterIconClassName:b})=>{const[D,E]=u.useState(v.PopUpState.Closed),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState(),[j,_]=u.useState([]),[F,B]=u.useState(void 0),V=u.useRef(o||[]),[z,Z]=u.useState([]),[ie,K]=u.useState(),[q,Y]=u.useState(),ce=u.useRef(!1),[me,H]=u.useState(!1),ne=W=>{const R=W?T.map(G=>G.id===W.id?W:G):T;Y(!0),A(wt(R)),K?.(!0),se(W?.isTimeDimension?pt(R,W):R,A,K)};u.useEffect(()=>{D===v.PopUpState.Closed&&Z(V.current)},[D]);const se=u.useCallback((W,R,G)=>{const $=d?.urn??"",le=vt(W).filter(fe=>fe.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e($,le),()=>e.getConstraints($,le)):Promise.resolve(void 0)).then(fe=>{const Me=fe?.data?.dataConstraints||[];V.current=Me,G?.(!1),R(ut(W,t,s,Me,l))}).catch(()=>{V.current=[],G?.(!1),R(ut(W,t,s,[],l))}).finally(()=>{Y(!1)})},[e,d?.urn,t,l,s]);u.useEffect(()=>{const W=hr(t,s,n,l),R=t?.map($=>{const le=S.findCodelistByDimension(s?.codelists,s?.conceptSchemes,$),re=S.getAvailableCodesFromConstrains(le?.codes,$.id,V.current,l);return{...$,dimensionValues:re}}),G=W.map($=>{const le=R?.find(re=>re.id===$.id)?.dimensionValues||[];return{...$,dimensionValues:le}});if(!ce.current){const $=xr(G,d,V.current);K?.(!0),se($,I,K),ce.current=!0}},[t,n,s,d,l,o,se]),u.useEffect(()=>{N?.length&&_(Bt(N))},[N]),u.useEffect(()=>{A(W=>pt(W,k))},[k]),u.useEffect(()=>{D===v.PopUpState.Opened&&(M({...N?.[0],isSelectedFilter:!0}),A(N)),D===v.PopUpState.Closed&&M(void 0)},[N,D]);const oe=u.useCallback(async W=>{const R=Nr(W),G=g?{...g,messages:Vr(g?.messages,R,d,f)}:null;C?.(G),y?.(Gr(R,d,f)),await w(decodeURI(p),{name:G?.name,messages:G?.messages||[]})},[d,g,p,f,C,w,y]),he=u.useCallback((W,R)=>{A(G=>gr(G,W,R)),Ge(k,W)&&M(G=>G&&{...G,displayMode:R})},[k]),Ce=u.useCallback(W=>Ar(W,t),[t]),ve=u.useCallback((W,R)=>{const G=ut(R,t,s,W,l);V.current=W,M($=>G?.find(le=>Ge(le,$))||$),A(G),Y(!1)},[t,l,s]),we=u.useCallback(W=>{Y(!0),A(wt(W));const R=d?.urn??"",G=vt(W).filter(le=>le.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e(R,G),()=>e.getConstraints(R,G)):Promise.resolve(void 0)).then(le=>{ve(le?.data?.dataConstraints||[],W)}).catch(()=>{ve([],W)})},[e,d?.urn,ve]),Se=u.useCallback(W=>{const R=Cr(T,W);we(R)},[we,T]),Ee=u.useCallback(()=>{V.current=z,E(v.PopUpState.Closed),H(!0)},[z]),ye=u.useCallback(()=>{const W=br(T);we(W)},[we,T]),De=u.useCallback(()=>{const W=Ce(T);c?.(W,V.current,T),I(T),E(v.PopUpState.Closed),H(!0),u.startTransition(()=>{oe(T)})},[Ce,T,c,oe,V]),je=W=>{B(W)},Le=Number(S.getTimeSeriesCount(V?.current?.[0]?.annotations));return a.jsxs("div",{className:"filters-container",children:[a.jsx(Rr,{buttonProps:r,selectedFiltersCount:wr(j),isLoading:ie,setModalState:E,titles:h,isModalClosed:me,warningIcon:x?.warningIcon,filterIconClassName:b,timeSeriesCount:Le}),a.jsx(a.Fragment,{children:D===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:h?.settings||"Settings",portalId:"filters",size:v.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:i?.isShowDividers,onClose:Ee,closeButtonTitle:h?.close||"Close",children:[a.jsx(Er,{locale:l,titles:h,timeRangeOptions:m,filtersList:T,selectedFilter:k,isDisableValues:q,modalProps:i,initialConstraints:o,timeSeriesCount:`${Le}`,setSelectedFilter:M,onSelectDisplayMode:he,onDeleteFilter:Se,updateSelectedFilterValues:ne,onTimePeriodChange:je,selectedTimeOption:F}),a.jsx(jr,{titles:h,onApply:De,onClose:Ee,onClearAllFilters:ye,modalProps:i,applyDisabled:ie||q,timeseriesLength:Le,limitMessages:x})]})})]})},ho=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:r})=>a.jsxs("div",{children:[t&&s&&a.jsxs("p",{className:"caption mt-4 inline-flex items-center attachment-dataset-name",children:[a.jsx("span",{className:"mr-1 attachment-dataset-icon",children:n}),t]}),r?.map(i=>a.jsxs("p",{className:"body-1 mb-2 last:mb-0",children:[i?.title,a.jsx("span",{children:e??" set to "}),a.jsx("span",{className:"font-bold",children:i?.valuesTitles?.join(", ")})]},i?.title))]}),go=({titles:e,attachmentInfoList:t,datasetIcon:n})=>a.jsxs("div",{className:"attachment-details flex flex-col",children:[a.jsx("p",{className:P("body-1",t&&t.length<=1&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),t?.map(s=>!!s?.queryFiltersDetails?.length&&a.jsx(ho,{setToTitle:e?.setToTitle,datasetName:s?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:s?.queryFiltersDetails},s?.datasetName))]}),po=({icon:e,title:t})=>a.jsx("div",{className:P("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:a.jsxs("p",{className:P("flex body-3 items-center"),children:[e,a.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),wo=e=>ue.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),ue.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),vo=e=>ue.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),ue.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),ys=[{value:S.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:S.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:S.SdmxDataFormat.CSV,title:"SDMX-CSV"}],Co=e=>[{value:S.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:S.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:S.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],Ds=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:r})=>a.jsxs(v.CollapsibleBlock,{title:e,value:n.title,children:[a.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(i=>a.jsx("div",{className:"flex flex-col",children:a.jsx(v.Radio,{id:i.value,checked:n.value===i.value,label:i.title,description:i.description,onChange:()=>{s(i)},radioIcon:a.jsx(ke.IconCircleFilled,{className:"w-3 h-3"})},i.value)},i.value))}),r]}),bo=(e,t,n,s)=>{if(s?.filterKey&&e===S.DownloadType.DATA_IN_TABLE)return s;let r=null,i=null;return t&&n&&e===S.DownloadType.DATA_IN_TABLE&&(r=n==null?null:S.getTimeSeriesFilterKey(n,t.filters),i=S.getTimeQueryFilter(t,S.getTimeDimension(n))),{filterKey:r,timeFilter:i}},xo=({actions:e,dataQuery:t,datasetIcon:n,isDisplayDatasetIcon:s=!0,datasetName:r,onCloseModal:i,type:d=S.DownloadType.FULL_DATASET,locale:f=J.Locale.EN,dimensions:o,filters:c,urn:l,titles:m,limitMessages:h,showLimitMessage:p,externalLink:g})=>{const C=Co(m),[w,y]=u.useState(ys[0]),[x,b]=u.useState(C[0]),[D,E]=u.useState(!0),T=u.useCallback(()=>{const A=bo(d,t,o,c),N=t?.urn||l||"",I=x.value,k=w.value,M=`${r}.${k}`;e.downloadDataSet(N,k,f,I,A,M,D),i()},[d,t,o,c,l,x.value,w.value,e,f,D,i,r]);return a.jsxs(v.Popup,{heading:a.jsx("p",{className:"download-heading h2",children:m?.download||"Download"}),portalId:"filters",size:v.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:i,closeButtonTitle:m?.close||"Close",children:[a.jsxs("div",{className:"download-info flex flex-col gap-1 px-6",children:[a.jsxs("div",{className:"download-info-text flex gap-1",children:[a.jsxs("p",{className:"text-neutrals-800 body-3",children:[m?.dataset||"Dataset",":"]}),a.jsxs("span",{className:"h4 flex flex-row gap-x-1 flex-1 min-w-0",children:[s&&n,a.jsx("p",{className:"flex-1 min-w-0 truncate",children:r})]})]}),p&&a.jsx(v.RequestLimitMessage,{limitMessages:h,isDownload:!0,query:g})]}),a.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[a.jsx(Ds,{title:m?.dataFormat||"Data Format",selectedValue:w,setSelectedValue:y,items:ys,infoMessage:a.jsx(v.DownloadFormatMessage,{limitMessages:h,query:g})}),a.jsx(Ds,{title:m?.attributes||"Attributes",selectedValue:x,setSelectedValue:b,items:C}),a.jsx(v.CollapsibleBlock,{title:m?.metadata||"Metadata",value:D?m?.all||"Included":m?.none||"Not included",children:a.jsxs("div",{className:`flex gap-4 cursor-pointer download-metadata ${D?"download-metadata-active":""}`,children:[D?a.jsx(wo,{width:44,height:24,className:"text-primary",onClick:()=>{E(!D)}}):a.jsx(vo,{width:44,height:24,className:"text-neutrals-500",onClick:()=>{E(!D)}}),a.jsx("div",{children:m?.includeMetadata||"Include Metadata"})]})})]}),a.jsx("div",{className:"download-button flex p-6 mt-auto",children:a.jsx(v.Button,{buttonClassName:"text-button-primary",title:m?.download||"Download",onClick:T})})]})},So=({id:e,title:t,version:n,agency:s,isActive:r,isSingleTab:i,onSelectDataset:d})=>a.jsx("div",{className:P("dataset-tab truncate last:mr-4",r?"dataset-tab-active":"border-b-transparent",i?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{i||d(S.generateShortUrn(e,n,s))},children:a.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),Ur=({datasets:e,locale:t,isHideAdvancedViewButton:n,openAdvancedViewIcon:s,initialSelectedDatasetUrn:r,selectDataset:i,onOpenAdvancedView:d,titles:f})=>{const{isOpenedAdvancedView:o}=Be(),[c,l]=u.useState(),m=u.useRef(null),[h,p]=u.useState(""),[g,C]=u.useState(""),[w,y]=u.useState(!1),{onboardingFileSchema:x,isShowOnboarding:b}=Ne();u.useEffect(()=>{if(b){const{title:E,description:T}=He(pe.OPEN_ADVANCED_VIEW,f);p(E),C(T)}},[f,b]),u.useEffect(()=>{if(b){const E=x?.lastDisplayedElement===pe.OPEN_ADVANCED_VIEW;y(E),E&&m?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[x?.lastDisplayedElement,b]),u.useEffect(()=>{if(!r&&!c&&e?.[0]){const E=S.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);l(E),i?.(E)}else r&&r!==c&&(l(r),i?.(r))},[e,i,r,c]);const D=u.useCallback(E=>{l(E),i?.(E)},[i]);return a.jsxs("div",{className:P("dataset-tabs flex justify-between items-center w-full",n&&o&&"hide-advance-button"),children:[a.jsx("div",{className:"flex items-center w-full overflow-y-auto gap-4 sm:w-[calc(100%-30px)]",children:e?.map(E=>a.jsx(So,{id:E?.id,title:S.getLocalizedName(E,t||J.Locale.EN),version:E?.version,agency:E?.agencyID,isActive:e?.length>1&&c===S.generateShortUrn(E?.id,E?.version,E?.agencyID),isSingleTab:e?.length===1,onSelectDataset:D},E?.id))}),!n&&a.jsx("div",{ref:m,children:a.jsx(v.IconButton,{buttonClassName:"advanced-view-button",icon:s,onClick:d})}),w&&a.jsx(Ue,{reference:m,title:h,description:g,onReferenceClick:d,shouldCloseTooltip:o})]})},yo=(e,t,n,s)=>t?.map(r=>{const i=e?.find(m=>m?.urn===r?.urn),d=n?.get(r?.urn),f=d?.conceptSchemes||[],o=d?.codelists||[],c=S.getDimensions(d),l=[...c?.dimensions||[],...c?.timeDimensions||[]];return{datasetName:S.getLocalizedName(d?.dataflows?.[0],s),queryFiltersDetails:Do(Ms(i?.filters||[],l,f,o,s),Ms(r?.filters,l,f,o,s))}}),Do=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!Pt.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},Ms=(e,t,n,s,r)=>e?.map(i=>{const d=t.find(c=>c?.id===i?.componentCode),f=S.getConcept(d?.conceptIdentity||"",n),o=S.findCodelistByDimension(s,n,d);return{id:i?.componentCode,title:S.getLocalizedName(f,r),valuesTitles:i?.operator===J.QueryFilterType.BETWEEN?[`${gt(J.getTimePeriod(i?.values?.[0]),r)} - ${gt(J.getTimePeriod(i?.values?.[1]),r)}`]:i?.values?.map(c=>S.getLocalizedName(o?.codes?.find(l=>l?.id===c),r)||c)}}),Mo=(e,t,n)=>{let s="",r="";if(e?.timeFilter){const d=decodeURIComponent(e.timeFilter||"")?.split(":");s=d[1]||"",r=d[3]||""}else if(t){const d=t?.filters.find(f=>f.componentCode===S.TIME_PERIOD);s=d?.values?.[0]||"",r=d?.values?.[1]||""}return`&filter=${e?.filterKey||S.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${r}`},Wr=(e,t,n,s)=>{const r=e?Mo(t,n,s):"";return n?.metadata?.datasetUrl+r},zr=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M2.33325 12.3267L6.33325 8.32001L8.99992 10.9867L14.6666 4.61334L13.7266 3.67334L8.99992 8.98667L6.33325 6.32001L1.33325 11.3267L2.33325 12.3267Z",fill:"currentColor"})),ko=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.50644 4.00043L1.97857 7.52207L1.5 7.99979L1.97857 8.47751L5.50644 11.9991L6.46019 11.0437L3.41088 7.99979L6.46019 4.95587L5.50644 4.00043ZM10.4918 4.00043L14.0197 7.52207L14.4983 7.99979L14.0197 8.47751L10.4918 11.9991L9.53809 11.0437L12.5874 7.99979L9.53809 4.95587L10.4918 4.00043Z",fill:"currentColor"})),$r=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M2.3999 4V12H13.5999V4H2.3999ZM5.7359 10.8H3.5999V5.2H5.7359V10.8ZM9.0639 10.8H6.9359V5.2H9.0719V10.8H9.0639ZM12.3999 10.8H10.2639V5.2H12.3999V10.8Z",fill:"currentColor"})),Eo=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.18519 10.4815H7.18116C7.31033 10.9089 7.50501 11.3078 7.7535 11.6667H2.18519C1.53333 11.6667 1 11.1333 1 10.4815V2.18519C1 1.53333 1.53333 1 2.18519 1H10.4815C11.1333 1 11.6667 1.53333 11.6667 2.18519V5.02017C11.5296 5.00683 11.3906 5 11.25 5C10.9876 5 10.7307 5.02378 10.4815 5.06931V2.18519H2.18519V10.4815ZM7.69316 6.92288C7.99945 6.45568 8.39531 6.05248 8.85633 5.73769H3.37044V6.92288H7.69316ZM7 9.25C7 8.8544 7.05405 8.47143 7.15517 8.10807H3.37044V9.29326H7.00022L7 9.25ZM3.37044 4.5525H9.29636V3.36731H3.37044V4.5525ZM11.6624 10.9695C12.5981 10.8087 13.2264 9.91979 13.0656 8.98403C12.9049 8.04827 12.016 7.42002 11.0802 7.58078C10.1444 7.74155 9.51618 8.63046 9.67695 9.56621C9.83771 10.502 10.7266 11.1302 11.6624 10.9695ZM11.8656 12.1521C11.9243 12.142 11.9824 12.1303 12.0396 12.1168L14.5611 15.5477L15.5281 14.8371L13.1449 11.5944C13.9785 10.9558 14.4384 9.88763 14.2483 8.78085C13.9753 7.19192 12.4659 6.12513 10.877 6.39811C9.28808 6.67109 8.22129 8.18047 8.49428 9.7694C8.76726 11.3583 10.2766 12.4251 11.8656 12.1521Z",fill:"currentColor"})),To=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:r,dataGridTitle:i,titles:d})=>{const f=u.useRef(null),[o,c]=u.useState(""),[l,m]=u.useState(""),[h,p]=u.useState(!1),{onboardingFileSchema:g,isShowOnboarding:C}=Ne(),w=u.useCallback((x,b="")=>r?so(x)||dt(x)?a.jsx(zr,{className:b}):ze(x)||_r(x)?a.jsx($r,{className:b}):Wt(x)?a.jsx(Eo,{className:b}):Pr(x)||$t(x)?a.jsx(ko,{className:b}):null:null,[r]),y=u.useCallback(x=>ze(x)?i||"Data Grid":x.title,[i]);return u.useEffect(()=>{if(C&&dt(e)){const{title:x,description:b}=He(pe.CHARTS,d);c(x),m(b)}},[e,d,C]),u.useEffect(()=>{if(dt(e)&&C){const x=g?.lastDisplayedElement===pe.CHARTS;p(x),x&&f?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,C]),a.jsxs("div",{ref:f,className:P("cursor-pointer min-w-30","flex items-center gap-1","attachment-tab",n===t?"attachment-tab-active text-primary":""),onClick:()=>s(t),children:[w(e,"w-4 h-4"),a.jsx("h4",{className:"truncate max-w-[130px]",title:y(e),children:y(e)}),h&&a.jsx(Ue,{reference:f,title:o,description:l})]},e.index||t)},Ao=({attachments:e,...t})=>a.jsx("div",{className:"flex items-center w-fit flex-wrap attachments-tabs",children:e.map((n,s)=>a.jsx(To,{attachment:n,index:s,...t},s))}),No=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,titles:r,externalLink:i,isExternaLinkIncludeFilters:d,limitMessages:f,onSelectedAttachmentChange:o,onDownloadClick:c,showAdvancedView:l,isTableSettingsOpen:m,onTableSettingsOpen:h})=>{const p=!l&&!!h&&!!(n&&ze(n));return a.jsxs("div",{className:"flex min-w-0 w-full justify-between itms-center",children:[a.jsx(Ao,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:o,titles:r}),a.jsxs("div",{className:"flex gap-x-3 items-center flex-wrap w-fit justify-end",children:[n&&ze(n)&&d&&a.jsx("a",{href:i,target:"_blank",children:a.jsx(v.Button,{title:f?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:f?.dataExplorerIcon})}),p&&a.jsx(v.Button,{disabled:m,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1",iconBefore:a.jsx($r,{className:"size-4"}),title:s?.columnsTitle||"Columns",onClick:h}),n&&ze(n)&&a.jsx(v.Button,{title:s?.downloadTitle||"Download",buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:"ml-1",onClick:c,iconBefore:s?.downloadIcon}),n&&$t(n)&&a.jsx(v.CopyButton,{title:s?.copyTitle,copiedTitle:s?.copiedTitle,tooltip:s?.copiedTooltip,icon:s?.copyIcon,copiedIcon:s?.copiedIcon,onClick:()=>navigator.clipboard.writeText(n.data??"")})]})]})},jo=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const r=t.url,[i,d]=u.useState(null);async function f(o){if(o==null)return;const c=await n.getFile(o);d(c)}return a.jsxs("div",{className:`border rounded-lg p-3 bg-white transition-colors ${s}`,children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"body-2 text-neutrals-800 truncate",title:t.title,children:t.title})})}),r&&a.jsx("div",{className:"flex-shrink-0",children:a.jsx(v.Button,{title:e??"Download",onClick:()=>f(t.url),buttonClassName:"text-button-tertiary"})})]}),i&&a.jsx("div",{className:"mt-3",children:a.jsx("pre",{className:"bg-white p-3 rounded-md overflow-x-auto",children:a.jsx("code",{children:JSON.stringify(i,null,2)})})})]})},Jr="json";function Io(e){return Oo(e)?Lo(e?.slice(Jr.length)):e}function Lo(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function Oo(e){return e?.startsWith(Jr)||!1}const Ro=({attachment:e,className:t=""})=>{const n=Io(e.data);return n?a.jsxs("div",{className:`attachment-json border rounded-lg bg-white ${t}`,children:[a.jsx("div",{className:"flex items-center justify-between px-3 py-2 border-b border-neutrals-200 bg-neutrals-100 rounded-t-lg",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),a.jsx("div",{className:"p-3",children:a.jsx("pre",{className:"text-neutrals-800 overflow-x-auto whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:a.jsx("code",{children:n})})})]}):null},Fo=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},Po=e=>Fo(e)?e:"",_o=e=>ue.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M11.3333 4.66667H8.66659V6.00001H11.3333C12.4333 6.00001 13.3333 6.9 13.3333 8C13.3333 9.1 12.4333 10 11.3333 10H8.66659V11.3333H11.3333C13.1733 11.3333 14.6666 9.84 14.6666 8C14.6666 6.16 13.1733 4.66667 11.3333 4.66667ZM7.33325 10H4.66659C3.56659 10 2.66659 9.1 2.66659 8C2.66659 6.9 3.56659 6.00001 4.66659 6.00001H7.33325V4.66667H4.66659C2.82659 4.66667 1.33325 6.16 1.33325 8C1.33325 9.84 2.82659 11.3333 4.66659 11.3333H7.33325V10ZM5.33325 7.33334H10.6666V8.66667H5.33325V7.33334Z",fill:"currentColor"})),Vo=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=Po(e.data||"");if(!s)return null;const r=i=>{window.open(i,"_blank")?.focus()};return a.jsx("div",{className:`border rounded-lg bg-white pl-4 py-3 pr-3 max-w-[500px] ${n}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-hues-800 flex-shrink-0 mt-1",role:"img","aria-label":"Link",children:a.jsx(_o,{width:16,height:16})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"mb-1",children:a.jsx(v.Link,{url:s,title:e.title})}),a.jsx("div",{className:"text-neutrals-600 break-all truncate",children:s})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(v.Button,{title:t??"Open link",onClick:()=>r(s),buttonClassName:"text-button-tertiary"})})]})})},Yr=({dimensionsInfo:e})=>a.jsx("div",{className:"sidebar flex flex-col w-[176px] gap-3 min-h-0 overflow-auto",children:e.map(t=>a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h5",{className:"text-neutrals-800",children:t.title}),a.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),Go=({titles:e,chart:t,isOpen:n,onClose:s})=>{const[r,i]=u.useState(v.PopUpState.Closed);u.useEffect(()=>{i(n?v.PopUpState.Opened:v.PopUpState.Closed)},[n]);const d=u.useCallback(()=>{i(v.PopUpState.Closed),s?.()},[s]);return a.jsx(a.Fragment,{children:r===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:a.jsx("h1",{className:"single-chart-popup-heading",children:e?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:v.PopUpSize.LG,dividers:!1,onClose:d,closeButtonTitle:e?.close??"Close",children:[a.jsxs("div",{className:"single-chart-popup-content flex flex-row flex-1 gap-4 min-h-0 h-full",children:[a.jsx("div",{className:"flex flex-col flex-1 min-h-0",children:a.jsx(Gs,{option:t.config,className:"w-full h-full",style:{width:"100%",height:"100%"}})}),a.jsx(Yr,{dimensionsInfo:t.dimensions})]}),a.jsx("div",{})]})})},Jt=e=>{const[t,n]=u.useState(!1),s=u.useRef(null),[r,i]=u.useState(""),[d,f]=u.useState(""),[o,c]=u.useState(!1),{onboardingFileSchema:l,isShowOnboarding:m}=Ne(),[h,p]=u.useState(!1),g=u.useCallback(()=>{n(!0)},[]),C=u.useCallback(()=>{n(!1),p(!0)},[]);return u.useEffect(()=>{if(m){const{title:w,description:y}=He(pe.CHART_PER_SERIES,e.titles);i(w),f(y)}},[e.titles,m]),u.useEffect(()=>{m&&c(l?.lastDisplayedElement===pe.CHART_PER_SERIES&&e.node.rowIndex===0)},[l?.lastDisplayedElement,e.node.rowIndex,m]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,children:a.jsx(v.IconButton,{title:e.titles?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:a.jsx(zr,{className:"w-5 h-5"}),onClick:g})}),o&&a.jsx(Ue,{reference:s,title:r,description:d,onReferenceClick:g,shouldCloseTooltip:h}),t&&a.jsx(Go,{chart:e.value,isOpen:t,onClose:C,titles:e.titles})]})},rt=32,xt=32,Bo=16,St="padding-0",Ze=200,Ke={flex:1,minWidth:Ze},Ho=rt,yt="observationValueCell",Yt="metadataCell",qr="chartCell",st="Chart_column",Uo=(e,t,n,s,r,i)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:St,cellRenderer:Yt,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:r,action:i}});function Wo(e,t,n,s=Ho,r,i){return{headerName:"",field:st,colId:st,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:St,suppressColumnsToolPanel:!0,cellRenderer:Jt,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:r,action:i}}}const Rt=["index","value"],zo=e=>({columns:Yo(e),data:$o(e)}),$o=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:r,...i}=s,d=Jo(s,t);n[d]={...n[d]||{},...i,[s[t]]:r}}return Object.values(n)},Jo=(e,t)=>Object.keys(e).filter(n=>!Rt.includes(n)&&n!==t).map(n=>e[n]).join("."),Yo=e=>{const{metadata:t,data:n}=e,s=t.time_column,r=t.pinned_columns||[],i=n.schema.fields,d=[],f=n.data.map(h=>h[s]),c=Array.from(new Set(f)).filter(h=>h!=null).map(h=>({field:h,colId:h,headerName:h,cellClass:"text-right",width:Ze})),l=r.map(h=>i.find(p=>p.name===h)).filter(h=>h!=null),m=i.filter(h=>!r.includes(h.name)).filter(h=>h!=null);if(l.length>0)for(const h of[...l])h.name===s||Rt.includes(h.name)||d.push({colId:h.name,field:h.name,headerName:h.name,pinned:"left",...Ke,tooltipValueGetter:p=>p.value});for(const h of[...m])h.name===s||Rt.includes(h.name)||d.push({colId:h.name,field:h.name,headerName:h.name,pinned:!1,...Ke,tooltipValueGetter:p=>p.value});return d.push(...c),d},qt=e=>e*xt+rt+Bo,qo=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[r,i]=u.useState(!1),[d,f]=u.useState([]),[o,c]=u.useState(),[l,m]=u.useState(400);u.useEffect(()=>{e.url!=null&&(i(!0),t.getFile(e.url).then(p=>{if(p==null){f([]),c([]),i(!1);return}const{columns:g,data:C}=zo(p);f(C),c(g),i(!1)}))},[e.url,t]),u.useEffect(()=>{d?(m(qt(d.length)),s?.(d.length>=v.SERIES_LIMIT)):s?.(!1)},[d,s]);const h=u.useMemo(()=>a.jsx(_t.AgGridReact,{headerHeight:rt,rowHeight:xt,rowData:d,columnDefs:o,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:o&&o?.length>5?"fitCellContents":"fitGridWidth"}}),[d,o]);return r?a.jsx(v.Loader,{}):a.jsx("div",{className:`w-full ${n}`,children:a.jsx("div",{className:"ag-theme-quartz w-full min-h-[80px] max-h-[400px]",style:{height:l},children:h})})},Kr=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M7.4665 6.39967H8.53317V5.33301H7.4665V6.39967ZM7.4665 10.6663H8.53317V7.46634H7.4665V10.6663ZM7.9945 13.333C5.0505 13.333 2.6665 10.9437 2.6665 7.99967C2.6665 5.05567 5.0505 2.66634 7.9945 2.66634C10.9438 2.66634 13.3332 5.05567 13.3332 7.99967C13.3332 10.9437 10.9438 13.333 7.9945 13.333ZM7.99984 3.73301C5.6425 3.73301 3.73317 5.64234 3.73317 7.99967C3.73317 10.357 5.6425 12.2663 7.99984 12.2663C10.3572 12.2663 12.2665 10.357 12.2665 7.99967C12.2665 5.64234 10.3572 3.73301 7.99984 3.73301Z",fill:"currentColor"})),Ko=({title:e,value:t})=>{const n=u.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return a.jsxs("div",{className:"flex gap-x-3 body-3",children:[a.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),a.jsx("p",{title:n(),className:"font-semibold truncate pr-3",children:n()})]})},Zo=({title:e,value:t,attachedKeysTitles:n,locale:s})=>{const[r,i]=u.useState(!1),[d,f]=u.useState(!1),o=u.useRef(null),c=u.useCallback(()=>{d&&i(m=>!m)},[i,d]),l=u.useCallback(()=>Array.isArray(t)?t?.map(m=>typeof m=="object"?m?.[s]:m)?.join(", "):t,[s,t]);return u.useEffect(()=>{o?.current&&f(o?.current?.scrollHeight>o?.current?.offsetHeight)},[o]),a.jsxs("div",{className:"metadata-item",children:[n?.map(m=>a.jsx("div",{title:m,className:"metadata-item-key pr-3 mb-1 text-neutrals-800",children:m},m)),a.jsxs("div",{className:P("flex items-center",d&&"justify-between"),children:[a.jsx("h2",{title:e,className:"metadata-item-title",children:e}),d&&a.jsx(v.IconButton,{buttonClassName:P("border-none p-0 w-6 h-6",r?"rotate-[180deg]":""),isBaseIconStyles:!1,icon:a.jsx(Gt,{width:24,height:24}),onClick:c})]}),a.jsx("p",{title:l(),className:P("metadata-item-value pr-3",!r&&"line-clamp-4"),ref:o,children:l()})]})},Kt=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,titles:r,locale:i})=>{const[d,f]=u.useState(v.PopUpState.Closed);u.useEffect(()=>{f(n?v.PopUpState.Opened:v.PopUpState.Closed)},[n]);const o=u.useCallback(()=>{f(v.PopUpState.Closed),s?.()},[s]);return a.jsx(a.Fragment,{children:d===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:a.jsx("h1",{className:"metadata-heading",children:r?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:v.PopUpSize.LG,dividers:!1,onClose:o,closeButtonTitle:r?.close||"Close",children:[a.jsxs("div",{className:"metadata-content overflow-hidden h-full",children:[t?.length>0&&a.jsx("div",{className:"metadata-description",children:t?.map(c=>a.jsx(Ko,{title:c?.title,value:c?.value},c?.title))}),a.jsx("div",{className:"h-full overflow-y-auto metadata-list",children:e&&e?.length>0?e?.map(c=>a.jsx(Zo,{title:c?.title,value:c?.value,locale:i,attachedKeysTitles:c?.attachedKeysTitles},c?.id||c?.title)):a.jsx("div",{className:"metadata-empty text-neutrals-700 flex h-full justify-center items-center",children:r?.noMetadata||"No metadata"})})]}),a.jsx("div",{})]})})},Xo=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Qo=e=>e?.data?.attributes,Zr=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),ks=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?S.getLocalizedName(n?.codes?.find(r=>r?.id===e),t)||"":s},Ct=(e,t,n)=>e?.map(s=>{const r=s?.name||"",i=t?.get(r),d=i?.codes?.length?i:void 0,f=Array.isArray(s?.value)?s?.value.map(o=>ks(o,n,d)):ks(s?.value,n,d);return{id:S.getLocalizedName(d,n)||s?.name,title:S.getLocalizedName(d||i,n),value:f||s?.value}})||[],Dt=(e,t,n)=>({title:n?.dataset||"Dataset",value:S.getLocalizedName(e,t)}),el=(e,t,n,s)=>[Dt(e,n,s),{title:s?.agency??"Agency",value:e?.agencyID},{title:s?.lastUpdated??"Last updated",value:t}],Xr=(e,t,n)=>({title:S.getDimensionTitle(e?.conceptSchemes,S.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),Qr=(e,t)=>({title:t?.observation||"Observation",value:e}),ea=(e,t,n,s,r,i)=>{const d={title:s?.timeSeries||"Time Series",value:i?.originalData?.name};return n?[Xr(e,t,r),d,Qr(n,s)]:[d]},tl=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.map((s,r)=>s?.values?.length>0?{...s}:{...s,values:[{value:t?.[r]}]}):n},nl=(e,t,n)=>e?.map(s=>{const r=s?.id,i=s?.values?.[0]?.value||s?.values?.[0]?.id,d=s?.values?.[0]?.ids,f=t?.get(r),o=f?.codes?.length?f:void 0,c=S.getLocalizedName(o?.codes?.find(m=>m?.id===i),n)||i,l=d&&d.map(m=>S.getLocalizedName(o?.codes?.find(h=>h?.id===m),n)||m);return{id:r,title:S.getLocalizedName(f,n)||r,value:d?l:c}}).filter(({value:s})=>!!s)||[],sl=(e,t)=>{const n=e?.dataSets?.[0],r=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=n?.dimensionGroupAttributes;return new Map(r.map(d=>{const f=d?.relationship?.dimensions,{codedSeriesKey:o,decodedSeriesKey:c}=rl(e,t,f);return[d.id,{values:i?.[o]||[],decodedSeriesKey:c,codedSeriesKey:o}]}))},rl=(e,t,n)=>{const s=e?.structures?.[0],r=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],i=new Array(r?.length)?.fill(""),d=new Array(r?.length)?.fill("");return n&&n?.forEach(f=>{const o=r?.findIndex(m=>m?.id===f)||0,c=t[o],l=r[o]?.values?.findIndex(m=>m?.id===c||m?.value===c)||0;i[o]=l>=0?l:c,d[o]=c}),{codedSeriesKey:i?.join(":"),decodedSeriesKey:d?.join(":")}},al=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),r=Array.isArray(t);return n||(s||r?{values:t}:{value:t?.toString()})},il=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},ta=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(r=>r?.id===t)?.name||t,ol=(e,t,n,s=J.Locale.EN)=>{const r=n?.dataStructureComponents?.dimensionList,i=[...r?.dimensions||[],...r?.timeDimensions||[]],d=[];return(e?.split(":")||[])?.forEach((o,c)=>{if(o!==""){const l=i?.[c]?.id||"",m=S.getLocalizedName(t?.get(l),s),h=ta(l,o,t);d.push(`${m}: ${h}`)}}),d},ll=(e,t,n,s,r=J.Locale.EN)=>{if(!e||!t||!s)return[];const i=e?.structures?.[0]?.attributes?.dimensionGroup||[],d=sl(e,s);return i?.map((f,o)=>{const c=d?.get(f?.id),l=n?.get(f?.id),m=il(al(f,c?.values?.[o]));return{id:f?.id,title:S.getLocalizedName(l,r),value:Array.isArray(m)?m?.map(h=>ta(f?.id,h,n)||""):m,attachedKeysTitles:ol(c?.decodedSeriesKey,n,t)}})?.filter(({value:f})=>f?.some(o=>!!o))||[]},na=e=>{const[t,n]=u.useState(!1),s=u.useRef(null),[r,i]=u.useState(""),[d,f]=u.useState(""),[o,c]=u.useState(!1),{onboardingFileSchema:l,isShowOnboarding:m}=Ne(),[h,p]=u.useState(!1),g=u.useMemo(()=>S.getStructureComponentsMap(e?.dataSetData),[e?.dataSetData]),C=u.useMemo(()=>[Dt(e?.dataSetData?.dataflows?.[0],e?.locale,e.titles),...Ct(Zr(e,g),g,e?.locale),...Ct(Qo(e),g,e?.locale),...ll(e?.attributesData,e?.dataSetData?.dataStructures?.[0],g,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,g]),w=u.useMemo(()=>ea(e?.dataSetData,e?.locale,e?.valueFormatted||e?.value,e.titles,e?.colDef,e?.data),[e]),y=u.useCallback(()=>{n(!0)},[]),x=u.useCallback(()=>{n(!1),p(!0)},[]);return u.useEffect(()=>{if(m){const{title:b,description:D}=He(pe.METADATA_PER_SERIES,e.titles);i(b),f(D)}},[e.titles,m]),u.useEffect(()=>{if(m){const b=l?.lastDisplayedElement===pe.METADATA_PER_SERIES&&e.node.rowIndex===0;c(b),b&&setTimeout(()=>{s?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[l?.lastDisplayedElement,e.node.rowIndex,m]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,children:a.jsx(v.IconButton,{title:e.titles?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:a.jsx(Kr,{className:"w-5 h-5"}),onClick:y})}),o&&a.jsx(Ue,{reference:s,title:r,description:d,onReferenceClick:y,shouldCloseTooltip:h}),t&&a.jsx(Kt,{titles:e.titles,locale:e?.locale,metadata:C,metadataDescription:e?.metadataSettings?.isMetadataDescription?w:[],isOpenMetadata:t,onCloseMetadata:x})]})},sa=e=>{const[t,n]=u.useState(!1),s=u.useMemo(()=>S.getStructureComponentsMap(e?.dataSetData),[e?.dataSetData]),r=u.useMemo(()=>Ct(Xo(e),s,e?.locale),[e,s]),i=u.useMemo(()=>[Dt(e?.dataSetData?.dataflows?.[0],e?.locale,e?.titles),...Ct(Zr(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Xr(e?.dataSetData,e?.locale,e?.colDef),Qr(e?.valueFormatted||e?.value,e?.titles)],...r],[e,s,r]),d=u.useMemo(()=>ea(e?.dataSetData,e?.locale,e?.valueFormatted||e?.value,e?.titles,e?.colDef,e?.data),[e]),f=u.useCallback(()=>{n(!0)},[]),o=u.useCallback(()=>{n(!1)},[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"w-full h-full p-2 text-end relative",children:[e?.valueFormatted||e?.value,r?.length>0&&a.jsx("div",{className:"metadata-indicator",title:e.titles?.metadata||"View details",onClick:f})]}),t&&a.jsx(Kt,{titles:e.titles,locale:e?.locale,metadata:i,metadataDescription:e?.metadataSettings?.isMetadataDescription?d:[],isOpenMetadata:t,onCloseMetadata:o})]})},ra=({ref:e,fixHeight:t,gridHeight:n,children:s})=>a.jsx("div",{ref:e,className:P("ag-theme-quartz w-full min-h-[80px]",t?"max-h-[400px]":"max-h-full"),style:{height:n},children:s}),cl=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,titles:r,showLimitMessage:i,onApiReady:d})=>{const[f,o]=u.useState(!1),[c,l]=u.useState([]),[m,h]=u.useState(),[p,g]=u.useState(400),C=u.useRef(null),[w,y]=u.useState(""),[x,b]=u.useState(""),[D,E]=u.useState(!1),{isShowOnboarding:T,onboardingFileSchema:A,setOnboardingFileSchema:N}=Ne();u.useEffect(()=>{if(e.grid_data==null)o(!0);else{const M=e.grid_data.columns.map(j=>j.colId===st?{...j,hide:!n}:j);l(e.grid_data.data),h(M),o(!1)}},[e.grid_data,n]),u.useEffect(()=>{c?(g(qt(c.length)),i?.(c.length>=v.SERIES_LIMIT)):i?.(!1)},[c,i]),u.useEffect(()=>{if(T){const{title:M,description:j}=He(pe.DATA_GRID,r);y(M),b(j)}},[r,T]),u.useEffect(()=>{A&&!A?.infoElements?.dataGrid&&N?.({...A,infoElements:{...A?.infoElements,dataGrid:!0},lastDisplayedElement:pe.DATA_GRID})},[A,N]),u.useEffect(()=>{if(T){const M=A?.lastDisplayedElement===pe.DATA_GRID;E(M),!f&&!t&&M&&setTimeout(()=>{C?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[A?.lastDisplayedElement,T,t,f]);const I=u.useCallback(M=>{d?.(M.api)},[d]),k=u.useMemo(()=>a.jsx(_t.AgGridReact,{onGridReady:I,headerHeight:rt,rowHeight:xt,rowData:c,enableCellTextSelection:!0,columnDefs:m,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:{[Yt]:na,[yt]:sa,[qr]:Jt}}),[c,m,I]);return f||t?a.jsx(v.Loader,{}):a.jsxs("div",{className:"w-full h-full",children:[a.jsx(ra,{ref:C,fixHeight:s,gridHeight:p,children:k}),D&&a.jsx(Ue,{reference:C,title:w,description:x,supressReferenceClick:!0})]})},ul=200,dl=8,fl=2,ml=({currentIndex:e,totalCount:t,icons:n,titles:s,onPrev:r,onNext:i})=>{const d=u.useRef(null),[f,o]=u.useState(""),[c,l]=u.useState(""),[m,h]=u.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ne();u.useEffect(()=>{if(g){const{title:x,description:b}=He(pe.CHARTS_NAVIGATION,s);o(x),l(b)}},[s,g]),u.useEffect(()=>{if(g){const x=p?.lastDisplayedElement===pe.CHARTS_NAVIGATION;h(x),x&&d?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const C=t>0?e/t*100:0,w=t>0?Math.min(dl*t,ul):0,y=t>0?Math.max(w/t,fl):0;return a.jsxs("div",{className:"w-full flex flex-row items-center gap-2 justify-center",children:[a.jsx("div",{className:P("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:r,children:n?.[mt.PREVIOUS]}),a.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[a.jsx("div",{className:"h-[4px] rounded-full bg-neutral-300 relative",style:{width:`${w}px`},children:a.jsx("div",{className:"h-full rounded-full bg-primary absolute",style:{left:`${C}%`,width:`${y}px`}})}),a.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),a.jsx("div",{className:P("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:i,ref:d,children:n?.[mt.NEXT]}),m&&a.jsx(Ue,{reference:d,title:f,description:c})]})},hl=({limitAmount:e,titles:t,openAdvancedView:n})=>{const[s,r]=u.useState(!1),{refs:i,floatingStyles:d,context:f}=Ie.useFloating({open:s,onOpenChange:r,placement:"top-start"}),o=Ie.useHover(f,{handleClose:Ie.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:c,getFloatingProps:l}=Ie.useInteractions([o]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex w-fit",ref:i.setReference,...c(),children:a.jsxs("div",{className:"flex bg-hues-100 w-fit px-4 mt-1 py-2 gap-1",children:[a.jsx("h5",{className:"font-bold",children:t?.limits||"Limited to"}),a.jsxs("h5",{children:[e," ",t?.timeseriesLimit||"Timeseries"]})]})}),s&&a.jsx("div",{className:"floating",ref:i.setFloating,style:d,...l(),children:a.jsxs("div",{className:"flex flex-col bg-white z-10 p-4 rounded shadow w-[300px] mb-2 gap-2",children:[a.jsxs("div",{children:[a.jsxs("h5",{className:"text-neutrals-900",children:[a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),a.jsxs("span",{className:"font-bold pr-0.5",children:[t?.limitLinkInfoP1_2||"limited to"," ",e]}),t?.limitLinkInfoP1_3||"for better clarity and performance."]}),a.jsxs("h5",{className:"text-neutrals-900",children:[a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP2_1||"To visualize specific timeseries"}),a.jsx("span",{className:"font-bold pr-0.5",children:t?.limitLinkInfoP2_2||"filter"}),a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP2_3||"your request, or"}),a.jsx("span",{className:"font-bold pr-0.5",children:t?.limitLinkInfoP2_4||"refine"}),t?.limitLinkInfoP2_5||"it in the chat."]})]}),n&&a.jsx("h4",{className:"cursor-pointer text-primary",onClick:n,children:t?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function gl(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const r=n.textStyle?.fontSize??12,i=n.textStyle?.fontFamily??"sans-serif";s.font=`${r}px ${i}`;const d=s.measureText(t).width,f=n.itemWidth??25,o=n.itemGap??10;return d+f+o}const pl=({option:e,style:t})=>{const n=u.useRef(null),[s,r]=u.useState(e);u.useEffect(()=>{r(Pt.cloneDeep(e))},[e]);const i=u.useCallback(()=>{const d=n.current?.getEchartsInstance?.();if(!d)return;const o=d.getDom().clientWidth,c=e.legend||{},l=c.itemHeight??14,m=c.textStyle?.fontSize??12,h=d.getModel()?.getComponent("legend")?.getData()||[];let p=0;h.forEach(y=>{const x=y.option.name||"";p+=gl(d,x,c)});const C=Math.max(1,Math.ceil(p/o))*(+l+ +m+6),w=20;r(y=>({...y,grid:{...y.grid||{},bottom:C+w}}))},[e.legend]);return u.useEffect(()=>{i();const d=()=>{i()};return window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}},[e,i]),a.jsx(Gs,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},wl=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:r=!0,titles:i})=>{const[d,f]=u.useState(!0),[o,c]=u.useState([]),[l,m]=u.useState(0),[h,p]=u.useState(void 0),{onboardingFileSchema:g,isShowOnboarding:C,setOnboardingFileSchema:w}=Ne(),y=u.useRef(null);u.useEffect(()=>{f(e.charting_data==null),c(e.charting_data?.units||[])},[e.charting_data]),u.useEffect(()=>{const D=o?.length>=l;p(!d&&D?o[l]:o[0]),D||m(0)},[d,o,l]),u.useEffect(()=>{g&&C&&!d&&(eo(g)&&(w?.(Qi(g)),y?.current?.scrollIntoView({block:"center",behavior:"smooth"})),g.lastDisplayedElement===pe.CHART_PER_SERIES&&w?.(Or(g)))},[d,w,g,C]);const x=u.useCallback(()=>{m(D=>Math.min(D+1,o.length-1))},[o]),b=u.useCallback(()=>{m(D=>Math.max(D-1,0))},[]);return d||n?a.jsx(v.Loader,{}):a.jsx("div",{className:"chart-attachment w-full h-full",ref:y,children:e.charting_data&&a.jsx("div",{className:"flex flex-col w-full h-full gap-4",children:o.length==0||h==null?a.jsx("h4",{className:"ml-1",children:i?.chartInfo||"No data"}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("h3",{className:"chart-attachment-title",children:[i?.chart||"Chart"," ",l+1,"/",o.length]}),a.jsx("span",{className:"text-neutrals-700 h4 chart-attachment-info",children:i?.chartInfo||"Chart Information"})]}),a.jsxs("div",{className:P("chart-area overflow-hidden flex flex-row gap-4 h-full ",r&&"max-h-[400px] min-h-[400px]",!r&&"min-h-[300px]"),children:[a.jsxs("div",{className:"flex flex-col flex-1 min-h-0 min-w-0 gap-4",children:[a.jsx(pl,{option:h.config,style:{width:"100%",height:"100%",minHeight:0}}),h.limitedByRowsAmountTo&&a.jsx(hl,{limitAmount:h.limitedByRowsAmountTo,openAdvancedView:s,titles:i}),o.length>1&&a.jsx(ml,{icons:t,currentIndex:l,totalCount:o.length,titles:i,onNext:x,onPrev:b})]}),a.jsx(Yr,{dimensionsInfo:h.dimensions})]})]})})})},vl=Na.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function Je(...e){return vl(P(...e))}const Cl=({attachment:e,className:t})=>{const{data:n,language:s}=e;return a.jsx("div",{className:Je(["h-full w-full [&_.cursors-layer]:hidden",t]),children:a.jsx(ja,{value:n,language:s,theme:"vs-light",options:{readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},aa=u.createContext(void 0);function ia({children:e,titles:t}){return a.jsx(aa.Provider,{value:t,children:e})}function Zt(){return u.useContext(aa)}const bl=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,showLimitMessage:r})=>{const[i,d]=u.useState(!1),[f,o]=u.useState([]),[c,l]=u.useState(),[m,h]=u.useState(400);u.useEffect(()=>{if(e.gridContent==null)d(!0);else{const g=e.gridContent.columns.map(C=>C.colId===st?{...C,hide:!n}:C);o(e.gridContent.data),l(g),d(!1)}},[e.gridContent,n]),u.useEffect(()=>{f?(h(qt(f.length)),r?.(f.length>=v.SERIES_LIMIT)):r?.(!1)},[f,r]);const p=u.useMemo(()=>a.jsx(_t.AgGridReact,{headerHeight:rt,rowHeight:xt,rowData:f,enableCellTextSelection:!0,columnDefs:c,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:{[Yt]:na,[yt]:sa,[qr]:Jt}}),[f,c]);return i||t?a.jsx(v.Loader,{}):a.jsx("div",{className:"w-full h-full",children:a.jsx(ra,{fixHeight:s,gridHeight:m,children:p})})},xl=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,isOpenedAdvancedView:r,onOpenAdvancedView:i,showLimitMessage:d,onGridApiReady:f})=>{const o=Zt();return a.jsxs("div",{className:"flex flex-1 w-full justify-center min-h-0",children:[no(e)&&a.jsx(jo,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),zt(e)&&a.jsx(qo,{actions:t,attachment:e,showLimitMessage:d}),ze(e)&&a.jsx(cl,{attachment:e,isDataLoading:s,isChartColumnVisible:r,fixHeight:!r,titles:o,showLimitMessage:d,onApiReady:f}),_r(e)&&a.jsx(bl,{attachment:e,isDataLoading:s,isChartColumnVisible:r,fixHeight:!r,showLimitMessage:d}),dt(e)&&a.jsx(wl,{titles:o,isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:r?void 0:i,fixHeight:!r}),Wt(e)&&a.jsx(Vo,{attachment:e,openLinkTitle:n?.openLinkTitle}),Pr(e)&&a.jsx(Ro,{attachment:e}),$t(e)&&a.jsx(Cl,{attachment:e,className:n?.codeAttachmentContainerClassName})]})};os.ModuleRegistry.registerModules([os.AllCommunityModule]);const oa=({attachments:e,actions:t,titles:n,messageStyles:s,attachmentsStyles:r,isSystemAttachments:i,isShowAttachments:d,showAdvancedView:f,currentDataQuery:o,dataQueries:c,attachmentInfoList:l,datasets:m,initialSelectedDatasetUrn:h,isDataLoading:p,isDataSetAttachments:g,locale:C,dimensions:w,filters:y,selectDataset:x,onAdvancedViewOpen:b,limitMessages:D,attachmentsConfig:E,isTableSettingsOpen:T,onTableSettingsOpen:A,onTableSettingsClose:N,onGridApiReady:I})=>{const[k,M]=u.useState(0),[j,_]=u.useState(null),{isOpenedAdvancedView:F,setIsOpenedAdvancedView:B}=Be(),[V,z]=u.useState(v.PopUpState.Closed),[Z,ie]=u.useState(!1),[K,q]=u.useState(),[Y,ce]=u.useState(),[me,H]=u.useState(!1),ne={downloadDataSet:t.downloadDataSet,getConstraints:t.getConstraints},se=S.DownloadType.DATA_IN_TABLE,oe=Se=>{M(Se)},he=u.useCallback(()=>{b?.(),B(!0),t.updateCurrentDataQuery(o||c?.[0]),t.updateDataQueries(c),t.updateDatasets(m)},[t,o,c,m,B,b]);u.useEffect(()=>{_(e[k]||null)},[e,k]),u.useEffect(()=>{ie(g&&(m==null||m?.length==0))},[m,g]),u.useEffect(()=>{T&&j&&!ze(j)&&N?.()},[T,j,N]);const Ce=u.useCallback(()=>{z(v.PopUpState.Closed)},[z]),ve=E?.isExternaLinkIncludeFilters,we=Wr(ve,y,o||c?.[0],w);return!e||e.length===0?null:a.jsx(a.Fragment,{children:F&&!d?a.jsx(po,{icon:s?.advanceViewIcon,title:s?.openAdvanceViewTitle??"Opened in Advanced view"}):a.jsxs("div",{className:P("space-y-3 max-w-full max-h-full h-full",!F&&!i?"pt-5":"pt-0"),children:[!F&&Z?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[i&&!F&&a.jsx(go,{titles:{queryUpdatedManuallyTitle:n?.queryUpdatedManually,setToTitle:n?.setTo},datasetIcon:r?.datasetIcon,attachmentInfoList:l}),!F&&m?.length!=null&&m?.length>0&&a.jsx(Ur,{datasets:m,initialSelectedDatasetUrn:h,locale:C,titles:n,isHideAdvancedViewButton:!f,openAdvancedViewIcon:r?.openAdvancedViewIcon,selectDataset:x,onOpenAdvancedView:he}),me&&a.jsx(v.RequestLimitMessage,{limitMessages:D,showAdvancedViewButton:!!j&&zt(j)&&f,onAdvancedViewClick:he,query:we}),a.jsx("div",{className:P(!F&&m?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:a.jsxs("div",{className:"flex flex-col max-w-full items-center gap-4 h-full",children:[a.jsx(No,{attachments:e,selectedAttachmentIndex:k,selectedAttachment:j,attachmentsStyles:r,titles:n,externalLink:we,isExternaLinkIncludeFilters:ve,limitMessages:D,onSelectedAttachmentChange:oe,onDownloadClick:()=>z(v.PopUpState.Opened),showAdvancedView:f,isTableSettingsOpen:T,onTableSettingsOpen:A}),j!=null&&a.jsx(xl,{selectedAttachment:j,actions:t,attachmentsStyles:r,isDataLoading:p,isOpenedAdvancedView:F,onOpenAdvancedView:he,showLimitMessage:H,onGridApiReady:I})]})})]}),a.jsxs(a.Fragment,{children:[V===v.PopUpState.Opened&&a.jsx(xo,{actions:ne,onCloseModal:Ce,dataQuery:o,datasetName:j?.title||"",locale:C,type:se,dimensions:w,filters:y,urn:o?.urn,datasetIcon:r?.datasetIcon,isDisplayDatasetIcon:r?.isDisplayDatasetIcon,titles:r?.downloadTitles,setIsShowDownloadAlert:q,setDownloadAlertDetails:ce,limitMessages:D,showLimitMessage:me,externalLink:we}),K&&a.jsx(v.Alert,{alertDetails:Y,successIcon:r?.successDownloadIcon,errorIcon:r?.errorDownloadIcon,onClose:()=>q(!1),closeButtonTitle:r?.closeTitle||"Close"})]})]})})},Sl=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function yl(e){return e.colId??e.field??null}function Dl(e){return String(e.headerName??e.field??e.colId??"").trim()}function Ml(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function kl(e,t){const n=e.getColumnDefs()??[],s=Ml(e),r=[];for(const f of n){const o=yl(f);if(!o)continue;const c=Dl(f);if(!t({colId:o,label:c,colDef:f}))continue;const l=s.get(o);r.push({id:o,type:"item",label:c,isChecked:!(l?.hide??!1),draggable:!0,checkable:!0})}const i=e.getColumnState().map(f=>f.colId),d=new Map(i.map((f,o)=>[f,o]));return r.sort((f,o)=>{const c=d.get(f.id)??Number.MAX_SAFE_INTEGER,l=d.get(o.id)??Number.MAX_SAFE_INTEGER;return c-l})}function Es(e,t){let n=e,s;for(const r of t){if(s=n.find(i=>i.id===r),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function Ft(e){const t=[];for(const n of e){if(n.type==="group"){t.push(...Ft(n.items));continue}if(n.items?.length){t.push(...Ft(n.items));continue}t.push(n.id)}return t}function El(e,t,n){const s=[...t];return e.map(r=>n.has(r)?s.shift()??r:r)}function Ts(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()}}function Tl(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const As=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function la(e,t){u.useEffect(()=>{if(e){for(const n of As)e.addEventListener(n,t);return()=>{for(const n of As)e.removeEventListener(n,t)}}},[e,t])}function Al({currentUrn:e}){const[t,n]=u.useState(),[s,r]=u.useState(null),i=u.useRef(new Map),d=u.useRef(new Map),f=u.useCallback(c=>{if(n(c),i.current.has(e))s==null&&r(i.current.get(e)??null);else{const m=Ts(c);i.current.set(e,m),r(m)}const l=d.current.get(e);l&&(c.applyColumnState({state:l.columnState,applyOrder:!0}),c.setColumnGroupState(l.columnGroupState))},[e]);u.useEffect(()=>{r(i.current.get(e)??null)},[e]);const o=u.useCallback(()=>{t&&d.current.set(e,Ts(t))},[e,t]);return la(t,o),{gridApi:t,onGridApiReady:f,initialColumnsState:s}}const ca=u.createContext(null);function Nl({currentUrn:e,children:t}){const[n,s]=u.useState(!1),r=u.useCallback(()=>s(!0),[]),i=u.useCallback(()=>s(!1),[]),{gridApi:d,onGridApiReady:f,initialColumnsState:o}=Al({currentUrn:e}),c=u.useMemo(()=>({tableSettings:{isOpen:n,open:r,close:i},agGrid:{gridApi:d,onGridApiReady:f,initialColumnsState:o}}),[d,o,n,f,r,i]);return a.jsx(ca.Provider,{value:c,children:t})}function ua(){const e=u.useContext(ca);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const jl=e=>{const{tableSettings:{isOpen:t,open:n,close:s},agGrid:{onGridApiReady:r}}=ua();return a.jsx(oa,{...e,isTableSettingsOpen:t,onTableSettingsOpen:n,onTableSettingsClose:s,onGridApiReady:r})},Il=({actions:e,structureDataMaps:t,dimensions:n,buttonProps:s,modalProps:r,attachmentsDataQuery:i,dataQueries:d,initialConstraints:f,onFiltersChange:o,locale:c,timeRangeOptions:l,titles:m,datasetIcon:h,conversationKey:p,conversation:g,setConversation:C,updateConversation:w,updateDataQueries:y,limitMessages:x,filterIconClassName:b})=>{const[D,E]=u.useState(v.PopUpState.Closed),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState(),[j,_]=u.useState([]),[F,B]=u.useState(void 0),V=u.useRef(f||[]),z=u.useRef(t?.constraintsMap),[Z,ie]=u.useState([]),[K,q]=u.useState(),[Y,ce]=u.useState(),[me,H]=u.useState(!1),ne=u.useMemo(()=>zi(d,t),[d,t]),se=R=>{const G=R?T.map($=>Ge($,R)?R:$):T;ce(!0),A(wt(G)),q?.(!0),oe(R?.isTimeDimension?pt(G,R):G,A,q)};u.useEffect(()=>{D===v.PopUpState.Closed&&ie(V.current)},[D]);const oe=u.useCallback((R,G,$)=>{const le=Lt(R),re=d?.map(fe=>{const Me=fe?.urn??"",Oe=vt(le?.get(Me)||[]).filter(Ae=>Ae.componentCode!==S.TIME_PERIOD);return e?Ve(e.getConstraints,_e(Me,Oe),()=>e.getConstraints(Me,Oe)):Promise.resolve(void 0)})||[];Promise.all(re).then(fe=>{const Me=new Map(fe?.map(Oe=>{const Ae=Oe?.data?.dataConstraints;return[S.generateShortUrn(Ae?.[0]?.id,Ae?.[0]?.version,Ae?.[0]?.agencyID),Ae]}));z.current=Me,$?.(!1),G(Tt(le,{...t,constraintsMap:Me},c))}).catch(()=>{const fe=new Map;z.current=fe,$?.(!1),G(Tt(le,{...t,constraintsMap:fe},c))}).finally(()=>{ce(!1)})},[e,d,c,t]);u.useEffect(()=>{if(!ne){q(!0);return}const R=Hi(t,c),G=Ui(R,d,t?.constraintsMap);q?.(!0),oe(G,I,q)},[d,oe,ne,c,t]),u.useEffect(()=>{N?.length&&_(Bt(N))},[N]),u.useEffect(()=>{A(R=>pt(R,k))},[k]),u.useEffect(()=>{D===v.PopUpState.Opened&&(M({...N?.[0],isSelectedFilter:!0}),A(N)),D===v.PopUpState.Closed&&M(void 0)},[N,D]);const he=u.useCallback(async R=>{const G=Nr(R,i?.urn),$=g?{...g,messages:Vr(g?.messages,G,i,d)}:null;C?.($),y?.(Gr(G,i,d)),await w(decodeURI(p),{name:$?.name,messages:$?.messages||[]})},[i,g,p,d,C,w,y]),Ce=u.useCallback((R,G)=>{A($=>gr($,R,G)),Ge(k,R)&&M($=>$&&{...$,displayMode:G})},[k]),ve=u.useCallback(R=>Ar(R,n,i?.urn),[i?.urn,n]),we=u.useCallback((R,G)=>{const $=new Map(z.current);$.set(i?.urn||"",R),z.current=$;const le=Tt(Lt(G),{...t,constraintsMap:$},c);V.current=R,M(re=>le?.find(fe=>Ge(fe,re))||re),A(le),ce(!1)},[i?.urn,c,t]),Se=u.useCallback(R=>{ce(!0),A(wt(R));const G=i?.urn??"",$=vt(R,G).filter(re=>re.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e(G,$),()=>e.getConstraints(G,$)):Promise.resolve(void 0)).then(re=>{we(re?.data?.dataConstraints||[],R)}).catch(()=>{we([],R)})},[e,i?.urn,we]),Ee=u.useCallback(R=>{const G=Cr(T,R);Se(G)},[Se,T]),ye=u.useCallback(()=>{V.current=Z,E(v.PopUpState.Closed),H(!0)},[Z]),De=u.useCallback(()=>{const R=br(T);Se(R)},[Se,T]),je=u.useCallback(()=>{const R=ve(T);o?.(R,V.current,T),I(T),E(v.PopUpState.Closed),H(!0),u.startTransition(()=>{he(T)})},[ve,T,o,he,V]),Le=R=>{B(R)},W=Number(S.getTimeSeriesCount(V?.current?.[0]?.annotations));return a.jsxs("div",{className:"filters-container",children:[a.jsx(Rr,{buttonProps:s,selectedFiltersCount:wr(j),isLoading:K,setModalState:E,titles:m,isModalClosed:me,warningIcon:x?.warningIcon,filterIconClassName:b,timeSeriesCount:W}),a.jsx(a.Fragment,{children:D===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:m?.settings||"Settings",portalId:"filters",size:v.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:r?.isShowDividers,onClose:ye,closeButtonTitle:m?.close||"Close",children:[a.jsx(Er,{locale:c,titles:m,timeRangeOptions:l,filtersList:T,selectedFilter:k,isDisableValues:Y,modalProps:r,initialConstraints:f,datasetIcon:h,structuresMap:t?.structuresMap,timeSeriesCount:`${W}`,setSelectedFilter:M,onSelectDisplayMode:Ce,onDeleteFilter:Ee,updateSelectedFilterValues:se,onTimePeriodChange:Le,selectedTimeOption:F}),a.jsx(jr,{titles:m,onApply:je,onClose:ye,onClearAllFilters:De,modalProps:r,applyDisabled:K||Y,timeseriesLength:W,limitMessages:x})]})})]})},Ll=u.createContext(null);function Xt(){const e=u.useContext(Ll);if(!e)throw new Error("useCrossDatasetMode must be used within CrossDatasetModeProvider");return e}const Ol=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:r,dimensions:i,locale:d,attachmentsStyles:f,isDataLoading:o,setIsFiltering:c,titles:l,limitMessages:m,attachmentsConfig:h,filters:p,onFiltersChange:g})=>{const C={getConstraints:t.getConstraints},{isCrossDatasetModeOn:w}=Xt();return u.useEffect(()=>{o||c?.(!1)},[o,c]),a.jsx("div",{className:"bg-white rounded h-full min-h-0",children:a.jsxs("div",{className:"flex flex-col gap-4 h-full overflow-x-hidden",children:[a.jsxs("div",{className:"data-details-header flex justify-between items-center",children:[a.jsx("h2",{children:l?.content??"Content"}),w?a.jsx(Il,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:d,actions:C,dimensions:i,titles:l,...e,onFiltersChange:g,limitMessages:m}):a.jsx(mo,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:d,actions:C,dimensions:i,titles:l,...e,onFiltersChange:g,limitMessages:m})]}),a.jsx("div",{className:"advanced-view-attachments-container flex-1 min-h-0",children:a.jsx(jl,{titles:l,attachments:n,attachmentsStyles:f,currentDataQuery:s,dimensions:i,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:o,locale:d,filters:p,limitMessages:m,attachmentsConfig:h})})]})})};function At(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Xe(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const d=e.defaultFormattingWidth||e.defaultWidth,f=n?.width?String(n.width):d;r=e.formattingValues[f]||e.formattingValues[d]}else{const d=e.defaultWidth,f=n?.width?String(n.width):e.defaultWidth;r=e.values[f]||e.values[d]}const i=e.argumentCallback?e.argumentCallback(t):t;return r[i]}}function Qe(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(r);if(!i)return null;const d=i[0],f=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(f)?Fl(f,m=>m.test(d)):Rl(f,m=>m.test(d));let c;c=e.valueCallback?e.valueCallback(o):o,c=n.valueCallback?n.valueCallback(c):c;const l=t.slice(d.length);return{value:c,rest:l}}}function Rl(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Fl(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Pl(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],i=t.match(e.parsePattern);if(!i)return null;let d=e.valueCallback?e.valueCallback(i[0]):i[0];d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(r.length);return{value:d,rest:f}}}const Ns=Symbol.for("constructDateFrom");function da(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ns in e?e[Ns](t):e instanceof Date?new e.constructor(t):new Date(t)}function _l(e,...t){const n=da.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let Vl={};function Gl(){return Vl}function Qt(e,t){return da(t||e,e)}function js(e,t){const n=Gl(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=Qt(e,t?.in),i=r.getDay(),d=(i<s?7:0)+i-s;return r.setDate(r.getDate()-d),r.setHours(0,0,0,0),r}function fa(e,t,n){const[s,r]=_l(n?.in,e,t);return+js(s,n)==+js(r,n)}function et(e,t){if(e.one!==void 0&&t===1)return e.one;const n=t%10,s=t%100;return n===1&&s!==11?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(s<10||s>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function Te(e){return(t,n)=>n&&n.addSuffix?n.comparison&&n.comparison>0?e.future?et(e.future,t):"за "+et(e.regular,t):e.past?et(e.past,t):et(e.regular,t)+" тому":et(e.regular,t)}const Bl=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",Hl={lessThanXSeconds:Te({regular:{one:"менше секунди",singularNominative:"менше {{count}} секунди",singularGenitive:"менше {{count}} секунд",pluralGenitive:"менше {{count}} секунд"},future:{one:"менше, ніж за секунду",singularNominative:"менше, ніж за {{count}} секунду",singularGenitive:"менше, ніж за {{count}} секунди",pluralGenitive:"менше, ніж за {{count}} секунд"}}),xSeconds:Te({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунди",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду тому",singularGenitive:"{{count}} секунди тому",pluralGenitive:"{{count}} секунд тому"},future:{singularNominative:"за {{count}} секунду",singularGenitive:"за {{count}} секунди",pluralGenitive:"за {{count}} секунд"}}),halfAMinute:Bl,lessThanXMinutes:Te({regular:{one:"менше хвилини",singularNominative:"менше {{count}} хвилини",singularGenitive:"менше {{count}} хвилин",pluralGenitive:"менше {{count}} хвилин"},future:{one:"менше, ніж за хвилину",singularNominative:"менше, ніж за {{count}} хвилину",singularGenitive:"менше, ніж за {{count}} хвилини",pluralGenitive:"менше, ніж за {{count}} хвилин"}}),xMinutes:Te({regular:{singularNominative:"{{count}} хвилина",singularGenitive:"{{count}} хвилини",pluralGenitive:"{{count}} хвилин"},past:{singularNominative:"{{count}} хвилину тому",singularGenitive:"{{count}} хвилини тому",pluralGenitive:"{{count}} хвилин тому"},future:{singularNominative:"за {{count}} хвилину",singularGenitive:"за {{count}} хвилини",pluralGenitive:"за {{count}} хвилин"}}),aboutXHours:Te({regular:{singularNominative:"близько {{count}} години",singularGenitive:"близько {{count}} годин",pluralGenitive:"близько {{count}} годин"},future:{singularNominative:"приблизно за {{count}} годину",singularGenitive:"приблизно за {{count}} години",pluralGenitive:"приблизно за {{count}} годин"}}),xHours:Te({regular:{singularNominative:"{{count}} годину",singularGenitive:"{{count}} години",pluralGenitive:"{{count}} годин"}}),xDays:Te({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} днi",pluralGenitive:"{{count}} днів"}}),aboutXWeeks:Te({regular:{singularNominative:"близько {{count}} тижня",singularGenitive:"близько {{count}} тижнів",pluralGenitive:"близько {{count}} тижнів"},future:{singularNominative:"приблизно за {{count}} тиждень",singularGenitive:"приблизно за {{count}} тижні",pluralGenitive:"приблизно за {{count}} тижнів"}}),xWeeks:Te({regular:{singularNominative:"{{count}} тиждень",singularGenitive:"{{count}} тижні",pluralGenitive:"{{count}} тижнів"}}),aboutXMonths:Te({regular:{singularNominative:"близько {{count}} місяця",singularGenitive:"близько {{count}} місяців",pluralGenitive:"близько {{count}} місяців"},future:{singularNominative:"приблизно за {{count}} місяць",singularGenitive:"приблизно за {{count}} місяці",pluralGenitive:"приблизно за {{count}} місяців"}}),xMonths:Te({regular:{singularNominative:"{{count}} місяць",singularGenitive:"{{count}} місяці",pluralGenitive:"{{count}} місяців"}}),aboutXYears:Te({regular:{singularNominative:"близько {{count}} року",singularGenitive:"близько {{count}} років",pluralGenitive:"близько {{count}} років"},future:{singularNominative:"приблизно за {{count}} рік",singularGenitive:"приблизно за {{count}} роки",pluralGenitive:"приблизно за {{count}} років"}}),xYears:Te({regular:{singularNominative:"{{count}} рік",singularGenitive:"{{count}} роки",pluralGenitive:"{{count}} років"}}),overXYears:Te({regular:{singularNominative:"більше {{count}} року",singularGenitive:"більше {{count}} років",pluralGenitive:"більше {{count}} років"},future:{singularNominative:"більше, ніж за {{count}} рік",singularGenitive:"більше, ніж за {{count}} роки",pluralGenitive:"більше, ніж за {{count}} років"}}),almostXYears:Te({regular:{singularNominative:"майже {{count}} рік",singularGenitive:"майже {{count}} роки",pluralGenitive:"майже {{count}} років"},future:{singularNominative:"майже за {{count}} рік",singularGenitive:"майже за {{count}} роки",pluralGenitive:"майже за {{count}} років"}})},Ul=(e,t,n)=>(n=n||{},Hl[e](t,n)),Wl={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},zl={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},$l={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Jl={date:At({formats:Wl,defaultWidth:"full"}),time:At({formats:zl,defaultWidth:"full"}),dateTime:At({formats:$l,defaultWidth:"full"})},en=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function Yl(e){const t=en[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function ma(e){return"'у "+en[e]+" о' p"}function ql(e){const t=en[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const Kl=(e,t,n)=>{const s=Qt(e),r=s.getDay();return fa(s,t,n)?ma(r):Yl(r)},Zl=(e,t,n)=>{const s=Qt(e),r=s.getDay();return fa(s,t,n)?ma(r):ql(r)},Xl={lastWeek:Kl,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:Zl,other:"P"},Ql=(e,t,n,s)=>{const r=Xl[e];return typeof r=="function"?r(t,n,s):r},ec={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},tc={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},nc={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},sc={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},rc={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},ac={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранок",afternoon:"день",evening:"вечір",night:"ніч"}},ic={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"}},oc=(e,t)=>{const n=String(t?.unit),s=Number(e);let r;return n==="date"?s===3||s===23?r="-є":r="-е":n==="minute"||n==="second"||n==="hour"?r="-а":r="-й",s+r},lc={ordinalNumber:oc,era:Xe({values:ec,defaultWidth:"wide"}),quarter:Xe({values:tc,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Xe({values:nc,defaultWidth:"wide",formattingValues:sc,defaultFormattingWidth:"wide"}),day:Xe({values:rc,defaultWidth:"wide"}),dayPeriod:Xe({values:ac,defaultWidth:"any",formattingValues:ic,defaultFormattingWidth:"wide"})},cc=/^(\d+)(-?(е|й|є|а|я))?/i,uc=/\d+/i,dc={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},fc={any:[/^д/i,/^н/i]},mc={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},hc={any:[/1/i,/2/i,/3/i,/4/i]},gc={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},pc={narrow:[/^с/i,/^л/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^л/i,/^с/i,/^в/i,/^ж/i,/^л/i,/^г/i],any:[/^сі/i,/^лю/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^лип/i,/^се/i,/^в/i,/^ж/i,/^лис/i,/^г/i]},wc={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},vc={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},Cc={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},bc={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},xc={ordinalNumber:Pl({matchPattern:cc,parsePattern:uc,valueCallback:e=>parseInt(e,10)}),era:Qe({matchPatterns:dc,defaultMatchWidth:"wide",parsePatterns:fc,defaultParseWidth:"any"}),quarter:Qe({matchPatterns:mc,defaultMatchWidth:"wide",parsePatterns:hc,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Qe({matchPatterns:gc,defaultMatchWidth:"wide",parsePatterns:pc,defaultParseWidth:"any"}),day:Qe({matchPatterns:wc,defaultMatchWidth:"wide",parsePatterns:vc,defaultParseWidth:"any"}),dayPeriod:Qe({matchPatterns:Cc,defaultMatchWidth:"wide",parsePatterns:bc,defaultParseWidth:"any"})},Sc={code:"uk",formatDistance:Ul,formatLong:Jl,formatRelative:Ql,localize:lc,match:xc,options:{weekStartsOn:1,firstWeekContainsDate:1}},yc=e=>e===J.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",Dc=(e,t)=>{const n=yc(t);return e!=null&&e!==""&&n&&ls.isValid(new Date(e))?ls.format(new Date(e),n,t===J.Locale.UK?{locale:Sc}:void 0):""},Mc=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:r,metadataSettings:i,locale:d,titles:f,getDatasetUpdatedTime:o,externalLink:c,datasetIcon:l,externalLinkIcon:m,metadataButtonClassName:h,metadataIconClassName:p,infoSegmentContainerClassName:g,infoSegmentHeaderClassName:C,nameAndMetadataContainerClassName:w})=>{const[y,x]=u.useState(""),[b,D]=u.useState(!1),E=u.useRef(null),[T,A]=u.useState(""),[N,I]=u.useState(""),[k,M]=u.useState(!1),{onboardingFileSchema:j,isShowOnboarding:_}=Ne(),[F,B]=u.useState(!1),V=u.useMemo(()=>i?.isMetadataDescription?el(n,y,d,f):[],[n,y,d,i?.isMetadataDescription,f]),z=u.useMemo(()=>[...i?.isMetadataDescription?[]:[Dt(n,d,f)],...nl(tl(s),S.getStructureComponentsMap(r),d)],[s,n,d,i?.isMetadataDescription,r,f]),Z=u.useCallback(()=>{D(!0)},[]),ie=u.useCallback(()=>{D(!1),B(!0)},[]);u.useEffect(()=>{const Y=o&&o(z)||Dc(S.getLastUpdatedTime(n),d);x(Y)},[n,d,z,o]),u.useEffect(()=>{if(_){const{title:q,description:Y}=He(pe.METADATA_PER_DATASET,f);A(q),I(Y)}},[f,_]),u.useEffect(()=>{_&&M(j?.lastDisplayedElement===pe.METADATA_PER_DATASET)},[j?.lastDisplayedElement,_]);const K=(q,Y)=>a.jsxs("div",{className:Je("flex gap-1 text-neutrals-1000",g),children:[a.jsxs("span",{className:Je("text-neutral-800",C),children:[q,":"]}),a.jsx("span",{children:Y})]});return a.jsxs("div",{className:"flex flex-col bg-white gap-3 dataset-info",children:[t&&a.jsxs("div",{className:"flex gap-1 items-center py-1 px-2 rounded-[20px] bg-accent-500 body-2 w-fit",children:[l,f?.dataset??"Dataset"]}),a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex gap-1 items-center",children:[a.jsxs("div",{role:"heading","aria-level":4,className:Je("flex gap-1 items-center h4",w),children:[a.jsx("div",{ref:E,children:a.jsx(v.IconButton,{title:f?.metadata??"View details",buttonClassName:Je("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:a.jsx(Kr,{className:Je("size-4",p)}),onClick:Z})}),a.jsx("span",{children:S.getLocalizedName(n,d)})]}),c&&a.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:m||a.jsx(ke.IconExternalLink,{className:"text-primary cursor-pointer w-4 h-4 shrink-0"})})]}),a.jsxs("div",{className:"flex gap-2 body-3 items-center",children:[e&&a.jsxs(a.Fragment,{children:[K(f?.agency??"Agency",n?.agencyID??""),a.jsx("div",{"aria-hidden":"true",className:"border-l border-l-neutral-500 h-[14px]"})]}),K(f?.lastUpdated??"Last updated",y)]})]}),k&&a.jsx(Ue,{reference:E,title:T,description:N,onReferenceClick:Z,shouldCloseTooltip:F}),b&&a.jsx(Kt,{titles:f,locale:d,metadata:z,metadataDescription:V,isOpenMetadata:b,onCloseMetadata:ie})]})},kc=({titles:e,locale:t,isShowShare:n,shareConversationProps:s})=>{const{setIsOpenedAdvancedView:r}=Be(),i=u.useRef(null),[d,f]=u.useState(""),[o,c]=u.useState(""),[l,m]=u.useState(!1),{onboardingFileSchema:h,isShowOnboarding:p}=Ne();return u.useEffect(()=>{if(p){const{title:g,description:C}=He(pe.EXIT_ADVANCED_VIEW,e);f(g),c(C)}},[e,p]),u.useEffect(()=>{p&&m(h?.lastDisplayedElement===pe.EXIT_ADVANCED_VIEW)},[h?.lastDisplayedElement,p]),a.jsxs("header",{className:P("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[a.jsxs("div",{className:P("flex gap-3 items-center",!n&&"justify-between w-full","advanced-view-header-title"),children:[a.jsx("div",{ref:i,className:P(!n&&"order-2","flex"),children:a.jsx(v.CloseButton,{btnClassNames:"button-close",onClick:()=>r(!1),title:e?.close||"Close"})}),l&&a.jsx(Ue,{reference:i,title:d,description:o,onReferenceClick:()=>r(!1),shouldMoveToNextStep:!0}),a.jsx("h2",{className:"sm:h-3",children:e?.advanceViewTitle??"Advanced view"})]}),n&&a.jsx(ir,{locale:t,...s})]})};function Mt(e,t,n){const s=S.getConcept(e.conceptIdentity,t),r=S.getArtifactByUrnWithWildCard(s?.coreRepresentation?.enumeration,n);return{concept:s,codeList:r||void 0}}function ha(e,t,n){const s=e.findIndex(r=>r.id===t);return n.originalData.parsedTimeSeriesValue[s]}function tn(e,t,n,s,r){const i=ha(e,t,s),d=n?.codes?.find(f=>f.id===i);return S.getLocalizedName(d,r)}function Ec(e,t,n,s,r,i,d,f,o){const c=Tc(e,n),l=o?.startPeriod&&o.endPeriod?S.getAdditionalColumns(f,o):[],m=Ac(e,t,n,s,r,i,l);return[Uo(e,t?.data,n,r,i,d),...c,...m,Wo(e,t?.data,n,void 0,i,d)]}function Tc(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],r=S.getDimensions(e)?.dimensions||[];return r.map(i=>{const{codeList:d,concept:f}=Mt(i,n,s),o=c=>{const{data:l,colDef:m}=c,h=m.field;return tn(r,h,d,l,t)};return{headerName:S.getLocalizedName(f,t),field:i.id,colId:i.id,valueGetter:o,...Ke,tooltipValueGetter:c=>c.value}})}function Ac(e,t,n,s,r,i,d){const f=Ic(d,S.getTimePeriods(t));return jc(f,(c,l)=>Nc(c,l||c,s,i),e,n,r,i)}const Nc=(e,t,n=J.defaultFormatNumbers,s)=>({headerName:mr(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Ze,cellClass:["justify-end","cell-with-meta"],valueFormatter:r=>J.formatNumberBySign(r.value,n)}),jc=(e,t,n,s,r,i)=>{const d=[];return e.sort((o,c)=>S.sortPeriods(o,c)).forEach(o=>{d.push({headerName:o.toString(),field:o.toString(),...t(o.toString()),valueGetter:c=>c.data[c.column.getColId()]?.value?.[0]?.value||null,cellClass:St,cellRenderer:yt,width:Ze,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:r,titles:i}})}),d},Ic=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(c=>S.isYearly(c)),s=t.some(c=>S.isSemiAnnually(c)),r=t.some(c=>S.isQuarterly(c)),i=t.some(c=>S.isMonthly(c)),d=t.some(c=>S.isWeekly(c)),f=t.some(c=>S.isDaily(c)),o=e.filter(c=>S.isYearly(c)?n:S.isSemiAnnually(c)?s:S.isQuarterly(c)?r:S.isMonthly(c)?i:S.isWeekly(c)?d:S.isDaily(c)?f:!0);return Array.from(new Set([...o,...t]))};function Lc(e,t,n){const s=t.map(i=>i.id).filter(i=>i!=null),r=n.map(i=>i.id).filter(i=>i!=null);return Oc(e,s,r,s)}const Oc=(e,t,n,s)=>{const r=Fc(e,t),i={};for(const d of r){const f=d.rowTime,o=ga(f,s);if(i[o]==null){i[o]={};for(const c of s)i[o][c]=f[c]}i[o]={attributes:d.attributes.filter(({value:c})=>c),...i[o],id:o,originalData:d.originalData,...Rc(f,n)}}return Object.values(i)},ga=(e,t)=>t.map(n=>e[n]).join("_"),Rc=(e,t)=>{const n=ga(e,t),{OBS_VALUE:s,obsAttributes:r}=e,i={};return i[n]={value:s,obsAttributes:r},i},Fc=(e,t)=>{const n=[];for(const s of e){const r={},i=s.name.split(".");for(let d=0;d<t.length;d+=1)r[t[d]]=i[d];if(!s.values.length){const d={...r};d.TIME_PERIOD=void 0,d.OBS_VALUE=void 0,n.push({rowTime:d,attributes:s.attributes,id:s.name,originalData:s})}s.values.forEach(d=>{const f={...r};f.TIME_PERIOD=d.dimensionAtObservation;const o=Pc(s,d);f.OBS_VALUE=o,f.obsAttributes=d?.obsAttributes?.filter(({value:c})=>c)||[],n.push({rowTime:f,attributes:s.attributes,id:s.name,originalData:s})})}return n},Pc=(e,t)=>{const s=[...e.attributes,...t.obsAttributes].find(({name:r})=>r==="OBS_VALUE");return s?[s]:t.values},_c="#EEEEEE",Vc="#777777";function Gc(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:r=>{let i=r[0].axisValueLabel+"<br/>";return r.forEach(d=>{d.value!==null&&d.value!==void 0&&(i+=d.marker+" "+d.seriesName+": "+d.value+"<br/>")}),i}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Is(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Is(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Is(e=_c,t=Vc){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function pa(e,t,n,s){return t.map(i=>{const d=S.getDimensions(n)?.dimensions||[],f=d?.find(c=>c.id===i);if(f==null)return e[i]||"";const{codeList:o}=Mt(f,n.conceptSchemes||[],n.codelists||[]);return tn(d,i,o,e,s)}).join(" - ")}function Bc(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(i=>i!=null),r=S.getDimensions(e)?.dimensions?.filter(i=>i.id!=null&&!n.includes(i.id)&&t?.metadata?.countryDimension!==i.id).map(i=>i.id).filter(i=>i!=null)||[];return[...n,...r]}function Hc(e,t,n){const s={};return e.forEach(r=>{const i=Uc(r,t,n);s[i]||(s[i]={rows:[]}),s[i].rows.push(r)}),Object.keys(s).map(r=>s[r])}function Uc(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(i=>s?.find(f=>f.id===i)==null?e[i]||"":ha(s,i,e)).join(" - ")}function Wc(e,t){const n={};return e.forEach(s=>n[s]=zc(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function zc(e,t){const n=t.map(r=>$c(e,r));return new Set(n).size===1}function $c(e,t){return t[e]}const Jc="line",lt=10;function Yc(e,t,n,s,r){const i=nn(t,e,n,s,r),f=S.getTimePeriods(t).sort((m,h)=>S.sortPeriods(m,h)),o=Bc(e,n),{nonUniqDimensions:c}=Wc(o,i);return{units:Hc(i,c,e).map(m=>wa(m,e,n,f,s,r))}}function qc(e,t,n,s,r,i){return wa({rows:[e]},n,s,t,r,i)}function wa(e,t,n,s,r,i){const d=Xc(e.rows,t,r),f=d?.find(c=>S.FREQUENCY_DIMENSION_ID.includes(c?.id))?.id,o=Kc(e.rows.length>lt?e.rows.slice(0,lt):e.rows,t,n,r,Ls(s,e?.rows?.[0],f));return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>lt?lt:void 0,dimensions:d,config:Gc(Ls(s,e?.rows?.[0],f),o,i)}}function Ls(e,t,n){if(n){const s=t?.[n];if(s===S.Periods.MONTHLY)return e?.filter(r=>S.isMonthly(r));if(s===S.Periods.QUARTERLY)return e?.filter(r=>S.isQuarterly(r));if(s===S.Periods.ANNUAL)return e?.filter(r=>S.isYearly(r))}return e}function Kc(e,t,n,s,r){return e.map(i=>({name:n?.metadata?.countryDimension==null?"":pa(i,[n?.metadata?.countryDimension],t,s),type:Jc,data:r.map(d=>Zc(d,i))}))}function Zc(e,t){return t[e]?.value?.[0]?.value||null}function Xc(e,t,n){return(S.getDimensions(t)?.dimensions||[]).map(s=>{if(s.id!=null)return{id:s.id,title:Qc(s,t,n),value:pa(e[0],[s.id],t,n)}}).filter(s=>s!=null)}function Qc(e,t,n){const s=t.conceptSchemes||[],r=t.codelists||[],{concept:i}=Mt(e,s,r);return S.getLocalizedName(i,n)||e.id}function nn(e,t,n,s,r){const i=e==null?[]:S.getParsedResponse(e),d=S.getDimensions(t)?.dimensions||[],f=S.getDimensions(t)?.timeDimensions||[],o=Lc(i,d,f);return eu(o,e,t,n,s,r)}function eu(e,t,n,s,r,i){const f=S.getTimePeriods(t).sort((o,c)=>S.sortPeriods(o,c));return e.map(o=>({...o,[st]:qc(o,f,n,s,r,i)}))}function tu(e,t,n,s,r,i,d,f,o,c,l){return{columns:Ec(e,t,s,r,i,f,o,c,l),data:nn(t,e,n,s,d)}}function nu(e,t,n,s,r,i,d,f,o,c,l){const m=e.dataflows?.[0]?.names?.[s],h=tu(e,t,n,s,r,i,d,f,o,c,l);return{title:m||f?.dataGrid||"Data Grid",grid_data:h}}function su(e){const t=e.replace(/\r\n/g,`
|
|
6
|
+
${gt(e?.timeRange?.endPeriod,r)}`:"",[r,e?.timeRange]);u.useEffect(()=>{b(pr(e?.dimensionValues)?.length)},[e?.dimensionValues]);const N=M=>{n?.(e,M)},I=c?x>0:!0;u.useEffect(()=>{e.isSelectedFilter||E(!1)},[e.isSelectedFilter]);const k=()=>{y&&E(M=>!M),t(e)};return a.jsxs("div",{className:"flex flex-col",children:[o&&a.jsxs("h4",{className:"filters-facet-dataset-name",children:[a.jsx("span",{className:"filters-facet-dataset-icon",children:f}),o]}),a.jsxs("div",{className:P("flex justify-between items-center p-2 hover:bg-hues-100 py-2 sm:py-4 sm:hover:bg-white","filters-facet-item cursor-pointer",e?.isSelectedFilter&&!y&&"bg-hues-100",e?.isDisabled&&"cursor-default pointer-events-none opacity-[0.7]"),onClick:k,children:[a.jsxs("h3",{className:"w-full truncate flex-1 min-w-0 sm:flex sm:items-center",title:e?.title,children:[a.jsx("span",{className:"truncate",children:e?.title}),y&&a.jsx(Gt,{className:P("chevron-icon w-6 h-6 shrink-0",D&&"rotate-180")})]}),a.jsxs("div",{className:"ml-2 flex gap-2 items-center text-neutrals-800",children:[T&&a.jsx("span",{className:"filters-facet-item-counter border-none",children:A}),!T&&I&&a.jsx("span",{className:P("px-2 text-center","filters-facet-item-counter"),children:x?`${x}/${e?.dimensionValues?.length||0}`:i?.all||"All"}),T?null:a.jsxs("div",{className:"flex items-center gap-2 filters-facet-item-settings",children:[a.jsx(v.Dropdown,{triggerButton:a.jsx(v.IconButton,{buttonClassName:P("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:a.jsx(ai,{width:16,height:16}),title:i?.displayOrder||"Display Order",disabled:!e?.isHierarchical}),options:yi(i),selectedOption:e?.displayMode,disabled:!e?.isHierarchical,onOptionSelect:N}),x>0&&a.jsx(v.IconButton,{buttonClassName:P("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:a.jsx(ri,{width:16,height:16}),title:i?.reset||"Reset",onClick:M=>{M.stopPropagation(),s?.(e)}})]})]})]}),D&&a.jsx(yr,{titles:i,selectedFilter:e,locale:r,isDisableValues:m,timeRangeOptions:h,selectFilterValue:g,selectHierarchicalNodes:C,expandHierarchicalValue:w,onTimePeriodChange:p,filterValuesProps:l,initialConstraints:d})]})},ut=(e,t,n,s,r=J.Locale.EN)=>{const i=t?.map(d=>{const f=S.findCodelistByDimension(n?.codelists,n?.conceptSchemes,d),o=S.getAvailableCodesFromConstrains(f?.codes,d.id,s,r);return{...d,dimensionValues:o}});return e?.map(d=>{const o=(i?.find(c=>c.id===d.id)?.dimensionValues||[]).map(c=>{const l=d.dimensionValues?.find(m=>m?.id===c?.id)?.isSelectedValue;return{...c,isSelectedValue:l}});return{...d,isDisabled:!1,dimensionValues:o}})||[]},ji="COUNTRY",Ii="FREQUENCY",ws=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Li(n):Oi(t||"",e.id)},Li=e=>`name:${e}`,Oi=(e,t)=>`dataset:${e}:id:${t}`,Dr=[{id:ji,getMergedValueKey:ws()},{id:Ii,getMergedValueKey:ws()}],Ri=new Map(Dr.map(e=>[e.id,e])),Fi=e=>e?Ri.get(e):void 0,Mr=e=>!!Fi(e),Pi=e=>e?.filterType==="shared"&&Mr(e?.id),_i=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(r=>{const i=t.getMergedValueKey(r,s.datasetUrn),d={datasetUrn:s.datasetUrn,id:r.id,name:r.name,parent:r.parent},f=n.get(i);if(f){f.isSelectedValue=f.isSelectedValue||r.isSelectedValue,f.sourceValues=[...f.sourceValues||[],d];return}n.set(i,{id:i,name:r.name,isSelectedValue:r.isSelectedValue,parent:r.parent,sourceValues:[d]})})}),Array.from(n.values())},kr=e=>{const t=new Map,n=[];return e.forEach(r=>{if(Mr(r?.id)&&r?.datasetUrn){const i=t.get(r.id)||[];t.set(r.id,[...i,r]);return}n.push(r)}),[...Dr.flatMap(r=>{const i=t.get(r.id);return i?.length?{...i[0],datasetUrn:void 0,filterType:"shared",dimensionValues:_i(i,r)}:[]}),...n]},Vi=e=>{if(!Pi(e))return[e];const t=new Map;return e.dimensionValues?.forEach(n=>{n.sourceValues?.forEach(s=>{const r=s.datasetUrn||"",i=t.get(r),d={id:s.id,name:s.name,parent:s.parent,isSelectedValue:n.isSelectedValue};if(i){i.dimensionValues=[...i.dimensionValues||[],d];return}t.set(r,{...e,datasetUrn:r,filterType:"dataset",dimensionValues:[d]})})}),Array.from(t.values())},Gi=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,hr(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,Bi=(e,t)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([n,s])=>{const r=s?.map(i=>{const d=S.findCodelistByDimension(e?.structuresMap?.get(n)?.codelists,e?.structuresMap?.get(n)?.conceptSchemes,i),f=S.getAvailableCodesFromConstrains(d?.codes,i.id,e?.constraintsMap?.get(n),t);return{...i,dimensionValues:f}})||[];return[n,r]})),Hi=(e,t)=>{const n=Gi(e,t),s=Bi(e,t);return new Map(Array.from(n?.entries()||[]).map(([r,i])=>{const d=s?.get(r),f=i.map(o=>({...o,dimensionValues:d?.find(c=>c.id===o.id)?.dimensionValues||[]}));return[r,f]}))},Ui=(e,t,n)=>kr(t?.flatMap(s=>{const r=s?.urn,i=e?.get(r)||[],d=n?.get(r)||[];return xr(i,s,d)})||[]),Lt=e=>e?.flatMap(t=>Vi(t))?.reduce((t,n)=>{const s=n?.datasetUrn||"";return t.has(s)||t.set(s,[]),t?.get(s)?.push(n),t},new Map),Tt=(e,t,n=J.Locale.EN)=>{const s=[];return Array.from(e?.entries())?.forEach(([r,i])=>{const d=t?.dimensionsMap?.get(r),f=t?.structuresMap?.get(r),o=t?.constraintsMap?.get(r);s.push(...ut(i,d,f,o,n))}),kr(s)},Ht=(e,t)=>t?Lt(e).get(t)||[]:e.filter(n=>n.filterType!=="shared"),Wi=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?S.generateShortUrn(n?.name,"",n?.agencyID):void 0},zi=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,$i=({filtersList:e,hideFacetCounterByDefault:t,locale:n,onSelectFilter:s,onDeleteFilter:r,onSelectDisplayMode:i,filterValuesProps:d,isDisableValues:f,timeRangeOptions:o,initialConstraints:c,datasetIcon:l,structuresMap:m,onTimePeriodChange:h,selectFilterValue:p,selectHierarchicalNodes:g,titles:C,expandHierarchicalValue:w})=>a.jsx("div",{className:P("overflow-y-auto advanced-view-filters-list min-w-[320px] pr-3 h-full sm:w-full"),children:e?.map(y=>a.jsx(Ni,{titles:C,locale:n,filter:y,onSelectFilter:s,onSelectDisplayMode:i,onDeleteFilter:r,hideFacetCounterByDefault:t,isDisableValues:f,timeRangeOptions:o,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:w,onTimePeriodChange:h,filterValuesProps:d,initialConstraints:c,datasetIcon:l,datasetName:Wi(y,m)},It(y)))}),Er=({filtersList:e,titles:t,selectedFilter:n,modalProps:s,locale:r,isDisableValues:i,timeSeriesCount:d,timeRangeOptions:f,initialConstraints:o,datasetIcon:c,structuresMap:l,setSelectedFilter:m,onSelectDisplayMode:h,onDeleteFilter:p,updateSelectedFilterValues:g,onTimePeriodChange:C,selectedTimeOption:w})=>{const y=v.useIsMobile(),x=u.useCallback(A=>{const N=e?.find(I=>Ge(I,A));if(!N){m(void 0);return}m({...N,isSelectedFilter:!0})},[e,m]),b=(A,N)=>{if(!n)return;const I={...n,dimensionValues:n?.dimensionValues?.map(k=>k?.id===A?{...k,isSelectedValue:N}:k)};m(I),g&&g(I)},D=A=>{if(!n)return;const N={...n,dimensionValues:n?.dimensionValues?.map(I=>A?.find(M=>M?.id===I?.id)||I)};m(N),g&&g(N)},E=A=>{n&&m({...n,dimensionValues:n?.dimensionValues?.map(N=>N?.id===A?.id?{...N,isExpanded:!A?.isExpanded}:N)})},T=(A,N)=>{if(!n)return;const I={...n,timeRange:A||void 0};C?.(N),m(I),g&&g(I)};return a.jsxs("div",{className:P("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[a.jsxs("div",{className:P("h-full sm:w-full",s?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[a.jsx($i,{filtersList:e,hideFacetCounterByDefault:s?.isHideFacetCounterByDefault,locale:r,titles:t,onSelectFilter:x,onSelectDisplayMode:h,onDeleteFilter:p,isDisableValues:i,initialConstraints:o,datasetIcon:c,structuresMap:l,timeRangeOptions:f,selectFilterValue:b,selectHierarchicalNodes:D,expandHierarchicalValue:E,onTimePeriodChange:T,filterValuesProps:s?.filterValuesProps}),s?.isShowTimeSeriesCount&&d?a.jsxs("h4",{className:"text-neutrals-800 my-4",children:[t?.timeSeries??"Timeseries",": ",d]}):null]}),!y&&a.jsx(yr,{selectedFilter:n,locale:r,titles:t,isDisableValues:i,timeRangeOptions:f,selectFilterValue:b,selectHierarchicalNodes:D,expandHierarchicalValue:E,onTimePeriodChange:T,filterValuesProps:s?.filterValuesProps,initialConstraints:o,selectedTimeOption:w})]})},vt=(e,t)=>{let n=[];return Ht(e,t).filter(s=>s.timeRange||s.dimensionValues?.some(r=>r.isSelectedValue)).forEach(s=>{const{id:r,dimensionValues:i}=s;s.isTimeDimension?n=[...n,...Ji(s.timeRange,r)]:n.push({componentCode:r,operator:S.SeriesFilterOperator.EQUALS,value:i?.filter(d=>d.isSelectedValue)?.map(d=>d.id).join(S.GET_v3_FILTER_AND)||""})}),n},Ji=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:S.SeriesFilterOperator.GREATER_OR_EQUAL,value:vs(new Date(e.startPeriod))},{componentCode:t,operator:S.SeriesFilterOperator.LESS_OR_EQUAL,value:vs(new Date(e.endPeriod),1)}],Yi=1e3*60*60*24,vs=(e,t=0)=>{e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMinutes(e.getMinutes()-e.getTimezoneOffset());let n=e.getTime();return n+=t?Yi-1:0,e=new Date(n),n.toString()},qi=e=>e.map(t=>({componentCode:t.id||"",operator:J.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),Tr=(e,t)=>{const n=t?.timeDimensions?.[0],s=S.getTimeRangeFromAttachment(e,n)||null;return s?S.getQueryTimePeriodFilters(s,n?.id):null},Ar=(e,t,n)=>{const s=Bt(Ht(e,n)),r=s.find(i=>i?.isTimeDimension&&i?.timeRange);return{filterKey:S.getTimeSeriesFilterKey(t||[],qi(s)),timeFilter:S.getQueryTimePeriodFilters(r?.timeRange,r?.id)}},Nr=(e,t)=>Ht(e,t)?.filter(n=>n.timeRange||n.dimensionValues?.some(s=>s.isSelectedValue)).map(n=>n?.isTimeDimension?{componentCode:n?.id,operator:J.QueryFilterType.BETWEEN,values:[Cs(n?.timeRange?.startPeriod||void 0)||"",Cs(n?.timeRange?.endPeriod||void 0)||""]}:{componentCode:n?.id,operator:J.QueryFilterType.IN,values:n?.dimensionValues?.filter(s=>s.isSelectedValue)?.map(s=>s.id)||[]}),Cs=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0"),s=e.getFullYear();return`${n}-${t}-${s}`},Ki=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||v.SERIES_LIMIT>e;return a.jsx("div",{className:"body-3 text-neutrals-800 sm:text-center flex gap-x-[4px] sm:justify-center items-center",children:n?a.jsx("span",{children:t?.seriesCount?.(e)}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:t?.warningIcon}),a.jsx("span",{children:t?.counterLimit?.(e,v.SERIES_LIMIT)})]})})},jr=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,titles:r,applyDisabled:i,timeseriesLength:d,limitMessages:f})=>{const o=v.useIsMobile();return a.jsxs("div",{className:P("flex py-4 px-6","modal-footer-wrapper",e?.isShowCancelButton?"justify-between":"gap-x-8 flex-row-reverse items-center justify-between sm:flex-col sm:gap-y-4 items-center"),children:[!e?.isShowCancelButton&&a.jsx(Ki,{timeseriesLength:d,limitMessages:f}),a.jsxs("div",{className:P("flex",e?.isShowCancelButton?"justify-between":"gap-x-8 flex-row-reverse justify-end sm:flex-col-reverse sm:gap-y-4 items-center"),children:[a.jsx(v.Button,{iconBefore:o?e?.resetIcon:void 0,buttonClassName:"text-button-tertiary p-0",title:e?.isShowClearIcon?r?.clearAllFilters??"Clear All Filters":r?.clearAll??"Clear All",onClick:()=>n(),isSmallButton:o}),a.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?a.jsx(v.Button,{buttonClassName:"text-button-tertiary sm:h8",title:r?.cancel??"Cancel",onClick:s,isSmallButton:o}):null,a.jsx(v.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:r?.apply??"Apply",onClick:t,isSmallButton:o,disabled:i})]})]})]})},Zi=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M3.33333 13.3327V8.66602H2V7.33268H6V8.66602H4.66667V13.3327H3.33333ZM3.33333 5.99935V2.66602H4.66667V5.99935H3.33333ZM6 5.99935V4.66602H7.33333V2.66602H8.66667V4.66602H10V5.99935H6ZM7.33333 13.3327V7.33268H8.66667V13.3327H7.33333ZM11.3333 13.3327V11.3327H10V9.99935H14V11.3327H12.6667V13.3327H11.3333ZM11.3333 8.66602V2.66602H12.6667V8.66602H11.3333Z",fill:"currentColor"}));var pe=(e=>(e.DATA_GRID="dataGrid",e.METADATA_PER_SERIES="metadataPerSeries",e.CHARTS="charts",e.CHARTS_NAVIGATION="chartsNavigation",e.OPEN_ADVANCED_VIEW="openAdvancedView",e.FILTERS="filters",e.CHART_PER_SERIES="chartPerSeries",e.METADATA_PER_DATASET="metadataPerDataset",e.EXIT_ADVANCED_VIEW="exitAdvancedView",e))(pe||{});const Ut=["charts","chartsNavigation"],bs=["dataGrid","metadataPerSeries",...Ut,"openAdvancedView"],Ir=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],He=(e,t)=>({title:t?.[`${e}Title`]||"",description:t?.[`${e}Description`]||""}),Ot=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Xi=(e,t)=>{if(!e||!t)return"";if(bs.includes(t)){const s=Ot(bs,e);if(s)return s}const n=Ot(Ir,e);return n||""},Lr=(e,t)=>{const n=Ot(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},Or=e=>Lr(Ir,e),Qi=e=>Lr(Ut,e),eo=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!Ut.includes(e.lastDisplayedElement),Pe=5,to=({targetPosition:e,overlayClasses:t,onClose:n})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-Pe,bottom:e.top+Pe}}),a.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+Pe,bottom:0}}),a.jsx("div",{className:"overlay overlay-left",style:{top:e.top-Pe,height:e.height+Pe*2,width:e.left,left:0-Pe,right:e.left-Pe*2}}),a.jsx("div",{className:"overlay overlay-right",style:{top:e.top-Pe,left:e.right+Pe,height:e.height+Pe*2,right:0}}),a.jsx("div",{className:P("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),Ue=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:r,shouldMoveToNextStep:i,supressReferenceClick:d})=>{const[f,o]=u.useState(!0),[c,l]=u.useState(!1),m=u.useRef(null),{isShowOnboarding:h,onboardingFileSchema:p,setOnboardingFileSchema:g}=Ne(),{refs:C,floatingStyles:w,context:y,placement:x}=Ie.useFloating({open:f,onOpenChange:o,placement:"right-start",elements:{reference:e?.current},middleware:[Ie.offset({mainAxis:12,crossAxis:-4}),Ie.flip(),Ie.shift(),Ie.arrow({element:m})],whileElementsMounted:Ie.autoUpdate}),b=Ie.useClick(y),{getFloatingProps:D}=Ie.useInteractions([b]),E=u.useCallback(()=>{if(h){const I=Xi(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,...I?{[I]:!0}:{}},lastDisplayedElement:I})}o?.(!1)},[h,p,g]);u.useEffect(()=>{C.setReference(e?.current??null)},[e,C]);const T=()=>E(),A=e?.current?.getBoundingClientRect();u.useEffect(()=>{r&&!c&&(E(),l(!0))},[r,E,c]);const N=()=>{s?(s?.(),i?E():o(!1)):d||(E(),e?.current?.click())};return a.jsx(a.Fragment,{children:f&&a.jsxs(Ie.FloatingPortal,{children:[A&&a.jsx(to,{overlayClasses:d?"cursor-default":"cursor-pointer",targetPosition:A,onClose:N}),a.jsxs("div",{ref:C.setFloating,style:w,...D(),className:"tooltip z-tooltip max-w-[350px]",children:[a.jsxs("div",{className:"tooltip-header",children:[a.jsx("h3",{children:t}),a.jsx(v.CloseButton,{btnClassNames:"w-4 h-4",onClick:T})]}),a.jsx("div",{className:"tooltip-description",children:a.jsx("p",{children:n})}),a.jsx("div",{ref:m,className:P("tooltip-arrow absolute w-3 h-3 rotate-45",x?.includes("right")?"left-[-4px]":"right-[-6px]",x?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},Rr=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,titles:r,isModalClosed:i,warningIcon:d,filterIconClassName:f,timeSeriesCount:o})=>{const c=u.useRef(null),[l,m]=u.useState(""),[h,p]=u.useState(""),[g,C]=u.useState(!1),{onboardingFileSchema:w,isShowOnboarding:y}=Ne(),x=v.SERIES_LIMIT<(o??0),b=u.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return u.useEffect(()=>{if(y){const{title:D,description:E}=He(pe.FILTERS,r);m(D),p(E)}},[r,y]),u.useEffect(()=>{y&&C(w?.lastDisplayedElement===pe.FILTERS)},[w?.lastDisplayedElement,y]),a.jsx("div",{className:"relative filter-button-container",ref:c,children:n?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[a.jsx(v.Button,{iconBefore:a.jsx(Zi,{className:P("size-4",f)}),iconAfter:x?d:void 0,title:b,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(v.PopUpState.Opened)}),e?.isShowBadge&&a.jsx("div",{className:"filter-count-badge",children:a.jsx("h5",{children:t})}),g&&a.jsx(Ue,{reference:c,title:l,description:h,onReferenceClick:()=>s(v.PopUpState.Opened),shouldCloseTooltip:i})]})})},xs=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function Wt(e){return e.type===ee.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function Fr(e){return e.type===ee.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function Pr(e){return e.type===ee.AttachmentType.MARKDOWN&&!Wt(e)}function no(e){return e.type===ee.AttachmentType.CSV}function zt(e){return e.type===ee.AttachmentType.TABLE}function ze(e){return e.type===ee.AttachmentType.CUSTOM_DATA_GRID}function dt(e){return e.type===ee.AttachmentType.CUSTOM_CHART}function so(e){return e.type===ee.AttachmentType.PLOTLY}function $t(e){return e.type===ee.AttachmentType.CUSTOM_CODE_SAMPLE}function _r(e){return e.type===ee.AttachmentType.CROSS_DATASET_GRID}const ro=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),ao=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(r=>Fr(r))?s:t,-1),io=e=>e?.reduce((t,n)=>n?.role===de.Role.Assistant?n:t,{}),oo=(e,t,n,s)=>({role:de.Role.System,content:"",custom_content:{attachments:n?.map(r=>({type:ee.AttachmentType.JSON,title:r?.title,data:JSON.stringify({urn:r?.urn,metadata:r?.metadata,filters:t?.urn===r?.urn?e:r?.filters})}))||[],form_schema:s?.custom_content?.form_schema}}),Vr=(e,t,n,s)=>{if(!e)return[];const r=e?.at(-1);return r&&r.role===de.Role.System&&e?.pop(),[...e,oo(t,n,s,io(e))]},Gr=(e,t,n)=>n?.map(s=>({...s,filters:t?.urn===s?.urn?e:s?.filters}))||[],lo=new WeakMap,co=new WeakMap,Br=new Set;function Hr(e,t,n){const s=e.get(t);if(s)return s;const r=n();return e.set(t,r),Br.add(r),r}function uo(e){return Hr(lo,e,()=>new Map)}function fo(e){return Hr(co,e,()=>new Map)}function _e(...e){return JSON.stringify(e)}async function Ve(e,t,n){const s=uo(e);if(s.has(t))return s.get(t);const r=fo(e),i=r.get(t);if(i)return i;const d=n().then(f=>(s.set(t,f),f)).finally(()=>{r.delete(t)});return r.set(t,d),d}function Ss(){Br.forEach(e=>e.clear())}const mo=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:r,modalProps:i,attachmentsDataQuery:d,dataQueries:f,initialConstraints:o,onFiltersChange:c,locale:l,timeRangeOptions:m,titles:h,conversationKey:p,conversation:g,setConversation:C,updateConversation:w,updateDataQueries:y,limitMessages:x,filterIconClassName:b})=>{const[D,E]=u.useState(v.PopUpState.Closed),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState(),[j,_]=u.useState([]),[F,B]=u.useState(void 0),V=u.useRef(o||[]),[z,Z]=u.useState([]),[ie,K]=u.useState(),[q,Y]=u.useState(),ce=u.useRef(!1),[me,H]=u.useState(!1),ne=W=>{const R=W?T.map(G=>G.id===W.id?W:G):T;Y(!0),A(wt(R)),K?.(!0),se(W?.isTimeDimension?pt(R,W):R,A,K)};u.useEffect(()=>{D===v.PopUpState.Closed&&Z(V.current)},[D]);const se=u.useCallback((W,R,G)=>{const $=d?.urn??"",le=vt(W).filter(fe=>fe.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e($,le),()=>e.getConstraints($,le)):Promise.resolve(void 0)).then(fe=>{const Me=fe?.data?.dataConstraints||[];V.current=Me,G?.(!1),R(ut(W,t,s,Me,l))}).catch(()=>{V.current=[],G?.(!1),R(ut(W,t,s,[],l))}).finally(()=>{Y(!1)})},[e,d?.urn,t,l,s]);u.useEffect(()=>{const W=hr(t,s,n,l),R=t?.map($=>{const le=S.findCodelistByDimension(s?.codelists,s?.conceptSchemes,$),re=S.getAvailableCodesFromConstrains(le?.codes,$.id,V.current,l);return{...$,dimensionValues:re}}),G=W.map($=>{const le=R?.find(re=>re.id===$.id)?.dimensionValues||[];return{...$,dimensionValues:le}});if(!ce.current){const $=xr(G,d,V.current);K?.(!0),se($,I,K),ce.current=!0}},[t,n,s,d,l,o,se]),u.useEffect(()=>{N?.length&&_(Bt(N))},[N]),u.useEffect(()=>{A(W=>pt(W,k))},[k]),u.useEffect(()=>{D===v.PopUpState.Opened&&(M({...N?.[0],isSelectedFilter:!0}),A(N)),D===v.PopUpState.Closed&&M(void 0)},[N,D]);const oe=u.useCallback(async W=>{const R=Nr(W),G=g?{...g,messages:Vr(g?.messages,R,d,f)}:null;C?.(G),y?.(Gr(R,d,f)),await w(decodeURI(p),{name:G?.name,messages:G?.messages||[]})},[d,g,p,f,C,w,y]),he=u.useCallback((W,R)=>{A(G=>gr(G,W,R)),Ge(k,W)&&M(G=>G&&{...G,displayMode:R})},[k]),Ce=u.useCallback(W=>Ar(W,t),[t]),ve=u.useCallback((W,R)=>{const G=ut(R,t,s,W,l);V.current=W,M($=>G?.find(le=>Ge(le,$))||$),A(G),Y(!1)},[t,l,s]),we=u.useCallback(W=>{Y(!0),A(wt(W));const R=d?.urn??"",G=vt(W).filter(le=>le.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e(R,G),()=>e.getConstraints(R,G)):Promise.resolve(void 0)).then(le=>{ve(le?.data?.dataConstraints||[],W)}).catch(()=>{ve([],W)})},[e,d?.urn,ve]),Se=u.useCallback(W=>{const R=Cr(T,W);we(R)},[we,T]),Ee=u.useCallback(()=>{V.current=z,E(v.PopUpState.Closed),H(!0)},[z]),ye=u.useCallback(()=>{const W=br(T);we(W)},[we,T]),De=u.useCallback(()=>{const W=Ce(T);c?.(W,V.current,T),I(T),E(v.PopUpState.Closed),H(!0),u.startTransition(()=>{oe(T)})},[Ce,T,c,oe,V]),je=W=>{B(W)},Le=Number(S.getTimeSeriesCount(V?.current?.[0]?.annotations));return a.jsxs("div",{className:"filters-container",children:[a.jsx(Rr,{buttonProps:r,selectedFiltersCount:wr(j),isLoading:ie,setModalState:E,titles:h,isModalClosed:me,warningIcon:x?.warningIcon,filterIconClassName:b,timeSeriesCount:Le}),a.jsx(a.Fragment,{children:D===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:h?.settings||"Settings",portalId:"filters",size:v.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:i?.isShowDividers,onClose:Ee,closeButtonTitle:h?.close||"Close",children:[a.jsx(Er,{locale:l,titles:h,timeRangeOptions:m,filtersList:T,selectedFilter:k,isDisableValues:q,modalProps:i,initialConstraints:o,timeSeriesCount:`${Le}`,setSelectedFilter:M,onSelectDisplayMode:he,onDeleteFilter:Se,updateSelectedFilterValues:ne,onTimePeriodChange:je,selectedTimeOption:F}),a.jsx(jr,{titles:h,onApply:De,onClose:Ee,onClearAllFilters:ye,modalProps:i,applyDisabled:ie||q,timeseriesLength:Le,limitMessages:x})]})})]})},ho=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:r})=>a.jsxs("div",{children:[t&&s&&a.jsxs("p",{className:"caption mt-4 inline-flex items-center attachment-dataset-name",children:[a.jsx("span",{className:"mr-1 attachment-dataset-icon",children:n}),t]}),r?.map(i=>a.jsxs("p",{className:"body-1 mb-2 last:mb-0",children:[i?.title,a.jsx("span",{children:e??" set to "}),a.jsx("span",{className:"font-bold",children:i?.valuesTitles?.join(", ")})]},i?.title))]}),go=({titles:e,attachmentInfoList:t,datasetIcon:n})=>a.jsxs("div",{className:"attachment-details flex flex-col",children:[a.jsx("p",{className:P("body-1",t&&t.length<=1&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),t?.map(s=>!!s?.queryFiltersDetails?.length&&a.jsx(ho,{setToTitle:e?.setToTitle,datasetName:s?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:s?.queryFiltersDetails},s?.datasetName))]}),po=({icon:e,title:t})=>a.jsx("div",{className:P("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:a.jsxs("p",{className:P("flex body-3 items-center"),children:[e,a.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),wo=e=>ue.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),ue.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),vo=e=>ue.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),ue.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),ys=[{value:S.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:S.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:S.SdmxDataFormat.CSV,title:"SDMX-CSV"}],Co=e=>[{value:S.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:S.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:S.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],Ds=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:r})=>a.jsxs(v.CollapsibleBlock,{title:e,value:n.title,children:[a.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(i=>a.jsx("div",{className:"flex flex-col",children:a.jsx(v.Radio,{id:i.value,checked:n.value===i.value,label:i.title,description:i.description,onChange:()=>{s(i)},radioIcon:a.jsx(ke.IconCircleFilled,{className:"w-3 h-3"})},i.value)},i.value))}),r]}),bo=(e,t,n,s)=>{if(s?.filterKey&&e===S.DownloadType.DATA_IN_TABLE)return s;let r=null,i=null;return t&&n&&e===S.DownloadType.DATA_IN_TABLE&&(r=n==null?null:S.getTimeSeriesFilterKey(n,t.filters),i=S.getTimeQueryFilter(t,S.getTimeDimension(n))),{filterKey:r,timeFilter:i}},xo=({actions:e,dataQuery:t,datasetIcon:n,isDisplayDatasetIcon:s=!0,datasetName:r,onCloseModal:i,type:d=S.DownloadType.FULL_DATASET,locale:f=J.Locale.EN,dimensions:o,filters:c,urn:l,titles:m,limitMessages:h,showLimitMessage:p,externalLink:g})=>{const C=Co(m),[w,y]=u.useState(ys[0]),[x,b]=u.useState(C[0]),[D,E]=u.useState(!0),T=u.useCallback(()=>{const A=bo(d,t,o,c),N=t?.urn||l||"",I=x.value,k=w.value,M=`${r}.${k}`;e.downloadDataSet(N,k,f,I,A,M,D),i()},[d,t,o,c,l,x.value,w.value,e,f,D,i,r]);return a.jsxs(v.Popup,{heading:a.jsx("p",{className:"download-heading h2",children:m?.download||"Download"}),portalId:"filters",size:v.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:i,closeButtonTitle:m?.close||"Close",children:[a.jsxs("div",{className:"download-info flex flex-col gap-1 px-6",children:[a.jsxs("div",{className:"download-info-text flex gap-1",children:[a.jsxs("p",{className:"text-neutrals-800 body-3",children:[m?.dataset||"Dataset",":"]}),a.jsxs("span",{className:"h4 flex flex-row gap-x-1 flex-1 min-w-0",children:[s&&n,a.jsx("p",{className:"flex-1 min-w-0 truncate",children:r})]})]}),p&&a.jsx(v.RequestLimitMessage,{limitMessages:h,isDownload:!0,query:g})]}),a.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[a.jsx(Ds,{title:m?.dataFormat||"Data Format",selectedValue:w,setSelectedValue:y,items:ys,infoMessage:a.jsx(v.DownloadFormatMessage,{limitMessages:h,query:g})}),a.jsx(Ds,{title:m?.attributes||"Attributes",selectedValue:x,setSelectedValue:b,items:C}),a.jsx(v.CollapsibleBlock,{title:m?.metadata||"Metadata",value:D?m?.all||"Included":m?.none||"Not included",children:a.jsxs("div",{className:`flex gap-4 cursor-pointer download-metadata ${D?"download-metadata-active":""}`,children:[D?a.jsx(wo,{width:44,height:24,className:"text-primary",onClick:()=>{E(!D)}}):a.jsx(vo,{width:44,height:24,className:"text-neutrals-500",onClick:()=>{E(!D)}}),a.jsx("div",{children:m?.includeMetadata||"Include Metadata"})]})})]}),a.jsx("div",{className:"download-button flex p-6 mt-auto",children:a.jsx(v.Button,{buttonClassName:"text-button-primary",title:m?.download||"Download",onClick:T})})]})},So=({id:e,title:t,version:n,agency:s,isActive:r,isSingleTab:i,onSelectDataset:d})=>a.jsx("div",{className:P("dataset-tab truncate last:mr-4",r?"dataset-tab-active":"border-b-transparent",i?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{i||d(S.generateShortUrn(e,n,s))},children:a.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),Ur=({datasets:e,locale:t,isHideAdvancedViewButton:n,openAdvancedViewIcon:s,initialSelectedDatasetUrn:r,selectDataset:i,onOpenAdvancedView:d,titles:f})=>{const{isOpenedAdvancedView:o}=Be(),[c,l]=u.useState(),m=u.useRef(null),[h,p]=u.useState(""),[g,C]=u.useState(""),[w,y]=u.useState(!1),{onboardingFileSchema:x,isShowOnboarding:b}=Ne();u.useEffect(()=>{if(b){const{title:E,description:T}=He(pe.OPEN_ADVANCED_VIEW,f);p(E),C(T)}},[f,b]),u.useEffect(()=>{if(b){const E=x?.lastDisplayedElement===pe.OPEN_ADVANCED_VIEW;y(E),E&&m?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[x?.lastDisplayedElement,b]),u.useEffect(()=>{if(!r&&!c&&e?.[0]){const E=S.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);l(E),i?.(E)}else r&&r!==c&&(l(r),i?.(r))},[e,i,r,c]);const D=u.useCallback(E=>{l(E),i?.(E)},[i]);return a.jsxs("div",{className:P("dataset-tabs flex justify-between items-center w-full",n&&o&&"hide-advance-button"),children:[a.jsx("div",{className:"flex items-center w-full overflow-y-auto gap-4 sm:w-[calc(100%-30px)]",children:e?.map(E=>a.jsx(So,{id:E?.id,title:S.getLocalizedName(E,t||J.Locale.EN),version:E?.version,agency:E?.agencyID,isActive:e?.length>1&&c===S.generateShortUrn(E?.id,E?.version,E?.agencyID),isSingleTab:e?.length===1,onSelectDataset:D},E?.id))}),!n&&a.jsx("div",{ref:m,children:a.jsx(v.IconButton,{buttonClassName:"advanced-view-button",icon:s,onClick:d})}),w&&a.jsx(Ue,{reference:m,title:h,description:g,onReferenceClick:d,shouldCloseTooltip:o})]})},yo=(e,t,n,s)=>t?.map(r=>{const i=e?.find(m=>m?.urn===r?.urn),d=n?.get(r?.urn),f=d?.conceptSchemes||[],o=d?.codelists||[],c=S.getDimensions(d),l=[...c?.dimensions||[],...c?.timeDimensions||[]];return{datasetName:S.getLocalizedName(d?.dataflows?.[0],s),queryFiltersDetails:Do(Ms(i?.filters||[],l,f,o,s),Ms(r?.filters,l,f,o,s))}}),Do=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!Pt.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},Ms=(e,t,n,s,r)=>e?.map(i=>{const d=t.find(c=>c?.id===i?.componentCode),f=S.getConcept(d?.conceptIdentity||"",n),o=S.findCodelistByDimension(s,n,d);return{id:i?.componentCode,title:S.getLocalizedName(f,r),valuesTitles:i?.operator===J.QueryFilterType.BETWEEN?[`${gt(J.getTimePeriod(i?.values?.[0]),r)} - ${gt(J.getTimePeriod(i?.values?.[1]),r)}`]:i?.values?.map(c=>S.getLocalizedName(o?.codes?.find(l=>l?.id===c),r)||c)}}),Mo=(e,t,n)=>{let s="",r="";if(e?.timeFilter){const d=decodeURIComponent(e.timeFilter||"")?.split(":");s=d[1]||"",r=d[3]||""}else if(t){const d=t?.filters.find(f=>f.componentCode===S.TIME_PERIOD);s=d?.values?.[0]||"",r=d?.values?.[1]||""}return`&filter=${e?.filterKey||S.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${r}`},Wr=(e,t,n,s)=>{const r=e?Mo(t,n,s):"";return n?.metadata?.datasetUrl+r},zr=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M2.33325 12.3267L6.33325 8.32001L8.99992 10.9867L14.6666 4.61334L13.7266 3.67334L8.99992 8.98667L6.33325 6.32001L1.33325 11.3267L2.33325 12.3267Z",fill:"currentColor"})),ko=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.50644 4.00043L1.97857 7.52207L1.5 7.99979L1.97857 8.47751L5.50644 11.9991L6.46019 11.0437L3.41088 7.99979L6.46019 4.95587L5.50644 4.00043ZM10.4918 4.00043L14.0197 7.52207L14.4983 7.99979L14.0197 8.47751L10.4918 11.9991L9.53809 11.0437L12.5874 7.99979L9.53809 4.95587L10.4918 4.00043Z",fill:"currentColor"})),$r=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M2.3999 4V12H13.5999V4H2.3999ZM5.7359 10.8H3.5999V5.2H5.7359V10.8ZM9.0639 10.8H6.9359V5.2H9.0719V10.8H9.0639ZM12.3999 10.8H10.2639V5.2H12.3999V10.8Z",fill:"currentColor"})),Eo=e=>ue.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.18519 10.4815H7.18116C7.31033 10.9089 7.50501 11.3078 7.7535 11.6667H2.18519C1.53333 11.6667 1 11.1333 1 10.4815V2.18519C1 1.53333 1.53333 1 2.18519 1H10.4815C11.1333 1 11.6667 1.53333 11.6667 2.18519V5.02017C11.5296 5.00683 11.3906 5 11.25 5C10.9876 5 10.7307 5.02378 10.4815 5.06931V2.18519H2.18519V10.4815ZM7.69316 6.92288C7.99945 6.45568 8.39531 6.05248 8.85633 5.73769H3.37044V6.92288H7.69316ZM7 9.25C7 8.8544 7.05405 8.47143 7.15517 8.10807H3.37044V9.29326H7.00022L7 9.25ZM3.37044 4.5525H9.29636V3.36731H3.37044V4.5525ZM11.6624 10.9695C12.5981 10.8087 13.2264 9.91979 13.0656 8.98403C12.9049 8.04827 12.016 7.42002 11.0802 7.58078C10.1444 7.74155 9.51618 8.63046 9.67695 9.56621C9.83771 10.502 10.7266 11.1302 11.6624 10.9695ZM11.8656 12.1521C11.9243 12.142 11.9824 12.1303 12.0396 12.1168L14.5611 15.5477L15.5281 14.8371L13.1449 11.5944C13.9785 10.9558 14.4384 9.88763 14.2483 8.78085C13.9753 7.19192 12.4659 6.12513 10.877 6.39811C9.28808 6.67109 8.22129 8.18047 8.49428 9.7694C8.76726 11.3583 10.2766 12.4251 11.8656 12.1521Z",fill:"currentColor"})),To=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:r,dataGridTitle:i,titles:d})=>{const f=u.useRef(null),[o,c]=u.useState(""),[l,m]=u.useState(""),[h,p]=u.useState(!1),{onboardingFileSchema:g,isShowOnboarding:C}=Ne(),w=u.useCallback((x,b="")=>r?so(x)||dt(x)?a.jsx(zr,{className:b}):ze(x)||_r(x)?a.jsx($r,{className:b}):Wt(x)?a.jsx(Eo,{className:b}):Pr(x)||$t(x)?a.jsx(ko,{className:b}):null:null,[r]),y=u.useCallback(x=>ze(x)?i||"Data Grid":x.title,[i]);return u.useEffect(()=>{if(C&&dt(e)){const{title:x,description:b}=He(pe.CHARTS,d);c(x),m(b)}},[e,d,C]),u.useEffect(()=>{if(dt(e)&&C){const x=g?.lastDisplayedElement===pe.CHARTS;p(x),x&&f?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,C]),a.jsxs("div",{ref:f,className:P("cursor-pointer min-w-30","flex items-center gap-1","attachment-tab",n===t?"attachment-tab-active text-primary":""),onClick:()=>s(t),children:[w(e,"w-4 h-4"),a.jsx("h4",{className:"truncate max-w-[130px]",title:y(e),children:y(e)}),h&&a.jsx(Ue,{reference:f,title:o,description:l})]},e.index||t)},Ao=({attachments:e,...t})=>a.jsx("div",{className:"flex items-center w-fit flex-wrap attachments-tabs",children:e.map((n,s)=>a.jsx(To,{attachment:n,index:s,...t},s))}),No=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,titles:r,externalLink:i,isExternaLinkIncludeFilters:d,limitMessages:f,onSelectedAttachmentChange:o,onDownloadClick:c,showAdvancedView:l,isTableSettingsOpen:m,onTableSettingsOpen:h})=>{const p=!l&&!!h&&!!(n&&ze(n));return a.jsxs("div",{className:"flex min-w-0 w-full justify-between itms-center",children:[a.jsx(Ao,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:o,titles:r}),a.jsxs("div",{className:"flex gap-x-3 items-center flex-wrap w-fit justify-end",children:[n&&ze(n)&&d&&a.jsx("a",{href:i,target:"_blank",children:a.jsx(v.Button,{title:f?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:f?.dataExplorerIcon})}),p&&a.jsx(v.Button,{disabled:m,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1",iconBefore:a.jsx($r,{className:"size-4"}),title:s?.columnsTitle||"Columns",onClick:h}),n&&ze(n)&&a.jsx(v.Button,{title:s?.downloadTitle||"Download",buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:"ml-1",onClick:c,iconBefore:s?.downloadIcon}),n&&$t(n)&&a.jsx(v.CopyButton,{title:s?.copyTitle,copiedTitle:s?.copiedTitle,tooltip:s?.copiedTooltip,icon:s?.copyIcon,copiedIcon:s?.copiedIcon,onClick:()=>navigator.clipboard.writeText(n.data??"")})]})]})},jo=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const r=t.url,[i,d]=u.useState(null);async function f(o){if(o==null)return;const c=await n.getFile(o);d(c)}return a.jsxs("div",{className:`border rounded-lg p-3 bg-white transition-colors ${s}`,children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"body-2 text-neutrals-800 truncate",title:t.title,children:t.title})})}),r&&a.jsx("div",{className:"flex-shrink-0",children:a.jsx(v.Button,{title:e??"Download",onClick:()=>f(t.url),buttonClassName:"text-button-tertiary"})})]}),i&&a.jsx("div",{className:"mt-3",children:a.jsx("pre",{className:"bg-white p-3 rounded-md overflow-x-auto",children:a.jsx("code",{children:JSON.stringify(i,null,2)})})})]})},Jr="json";function Io(e){return Oo(e)?Lo(e?.slice(Jr.length)):e}function Lo(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function Oo(e){return e?.startsWith(Jr)||!1}const Ro=({attachment:e,className:t=""})=>{const n=Io(e.data);return n?a.jsxs("div",{className:`attachment-json border rounded-lg bg-white ${t}`,children:[a.jsx("div",{className:"flex items-center justify-between px-3 py-2 border-b border-neutrals-200 bg-neutrals-100 rounded-t-lg",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),a.jsx("div",{className:"p-3",children:a.jsx("pre",{className:"text-neutrals-800 overflow-x-auto whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:a.jsx("code",{children:n})})})]}):null},Fo=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},Po=e=>Fo(e)?e:"",_o=e=>ue.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M11.3333 4.66667H8.66659V6.00001H11.3333C12.4333 6.00001 13.3333 6.9 13.3333 8C13.3333 9.1 12.4333 10 11.3333 10H8.66659V11.3333H11.3333C13.1733 11.3333 14.6666 9.84 14.6666 8C14.6666 6.16 13.1733 4.66667 11.3333 4.66667ZM7.33325 10H4.66659C3.56659 10 2.66659 9.1 2.66659 8C2.66659 6.9 3.56659 6.00001 4.66659 6.00001H7.33325V4.66667H4.66659C2.82659 4.66667 1.33325 6.16 1.33325 8C1.33325 9.84 2.82659 11.3333 4.66659 11.3333H7.33325V10ZM5.33325 7.33334H10.6666V8.66667H5.33325V7.33334Z",fill:"currentColor"})),Vo=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=Po(e.data||"");if(!s)return null;const r=i=>{window.open(i,"_blank")?.focus()};return a.jsx("div",{className:`border rounded-lg bg-white pl-4 py-3 pr-3 max-w-[500px] ${n}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-hues-800 flex-shrink-0 mt-1",role:"img","aria-label":"Link",children:a.jsx(_o,{width:16,height:16})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"mb-1",children:a.jsx(v.Link,{url:s,title:e.title})}),a.jsx("div",{className:"text-neutrals-600 break-all truncate",children:s})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(v.Button,{title:t??"Open link",onClick:()=>r(s),buttonClassName:"text-button-tertiary"})})]})})},Yr=({dimensionsInfo:e})=>a.jsx("div",{className:"sidebar flex flex-col w-[176px] gap-3 min-h-0 overflow-auto",children:e.map(t=>a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h5",{className:"text-neutrals-800",children:t.title}),a.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),Go=({titles:e,chart:t,isOpen:n,onClose:s})=>{const[r,i]=u.useState(v.PopUpState.Closed);u.useEffect(()=>{i(n?v.PopUpState.Opened:v.PopUpState.Closed)},[n]);const d=u.useCallback(()=>{i(v.PopUpState.Closed),s?.()},[s]);return a.jsx(a.Fragment,{children:r===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:a.jsx("h1",{className:"single-chart-popup-heading",children:e?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:v.PopUpSize.LG,dividers:!1,onClose:d,closeButtonTitle:e?.close??"Close",children:[a.jsxs("div",{className:"single-chart-popup-content flex flex-row flex-1 gap-4 min-h-0 h-full",children:[a.jsx("div",{className:"flex flex-col flex-1 min-h-0",children:a.jsx(Gs,{option:t.config,className:"w-full h-full",style:{width:"100%",height:"100%"}})}),a.jsx(Yr,{dimensionsInfo:t.dimensions})]}),a.jsx("div",{})]})})},Jt=e=>{const[t,n]=u.useState(!1),s=u.useRef(null),[r,i]=u.useState(""),[d,f]=u.useState(""),[o,c]=u.useState(!1),{onboardingFileSchema:l,isShowOnboarding:m}=Ne(),[h,p]=u.useState(!1),g=u.useCallback(()=>{n(!0)},[]),C=u.useCallback(()=>{n(!1),p(!0)},[]);return u.useEffect(()=>{if(m){const{title:w,description:y}=He(pe.CHART_PER_SERIES,e.titles);i(w),f(y)}},[e.titles,m]),u.useEffect(()=>{m&&c(l?.lastDisplayedElement===pe.CHART_PER_SERIES&&e.node.rowIndex===0)},[l?.lastDisplayedElement,e.node.rowIndex,m]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,children:a.jsx(v.IconButton,{title:e.titles?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:a.jsx(zr,{className:"w-5 h-5"}),onClick:g})}),o&&a.jsx(Ue,{reference:s,title:r,description:d,onReferenceClick:g,shouldCloseTooltip:h}),t&&a.jsx(Go,{chart:e.value,isOpen:t,onClose:C,titles:e.titles})]})},rt=32,xt=32,Bo=16,St="padding-0",Ze=200,Ke={flex:1,minWidth:Ze},Ho=rt,yt="observationValueCell",Yt="metadataCell",qr="chartCell",st="Chart_column",Uo=(e,t,n,s,r,i)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:St,cellRenderer:Yt,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:r,action:i}});function Wo(e,t,n,s=Ho,r,i){return{headerName:"",field:st,colId:st,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:St,suppressColumnsToolPanel:!0,cellRenderer:Jt,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:r,action:i}}}const Rt=["index","value"],zo=e=>({columns:Yo(e),data:$o(e)}),$o=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:r,...i}=s,d=Jo(s,t);n[d]={...n[d]||{},...i,[s[t]]:r}}return Object.values(n)},Jo=(e,t)=>Object.keys(e).filter(n=>!Rt.includes(n)&&n!==t).map(n=>e[n]).join("."),Yo=e=>{const{metadata:t,data:n}=e,s=t.time_column,r=t.pinned_columns||[],i=n.schema.fields,d=[],f=n.data.map(h=>h[s]),c=Array.from(new Set(f)).filter(h=>h!=null).map(h=>({field:h,colId:h,headerName:h,cellClass:"text-right",width:Ze})),l=r.map(h=>i.find(p=>p.name===h)).filter(h=>h!=null),m=i.filter(h=>!r.includes(h.name)).filter(h=>h!=null);if(l.length>0)for(const h of[...l])h.name===s||Rt.includes(h.name)||d.push({colId:h.name,field:h.name,headerName:h.name,pinned:"left",...Ke,tooltipValueGetter:p=>p.value});for(const h of[...m])h.name===s||Rt.includes(h.name)||d.push({colId:h.name,field:h.name,headerName:h.name,pinned:!1,...Ke,tooltipValueGetter:p=>p.value});return d.push(...c),d},qt=e=>e*xt+rt+Bo,qo=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[r,i]=u.useState(!1),[d,f]=u.useState([]),[o,c]=u.useState(),[l,m]=u.useState(400);u.useEffect(()=>{e.url!=null&&(i(!0),t.getFile(e.url).then(p=>{if(p==null){f([]),c([]),i(!1);return}const{columns:g,data:C}=zo(p);f(C),c(g),i(!1)}))},[e.url,t]),u.useEffect(()=>{d?(m(qt(d.length)),s?.(d.length>=v.SERIES_LIMIT)):s?.(!1)},[d,s]);const h=u.useMemo(()=>a.jsx(_t.AgGridReact,{headerHeight:rt,rowHeight:xt,rowData:d,columnDefs:o,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:o&&o?.length>5?"fitCellContents":"fitGridWidth"}}),[d,o]);return r?a.jsx(v.Loader,{}):a.jsx("div",{className:`w-full ${n}`,children:a.jsx("div",{className:"ag-theme-quartz w-full min-h-[80px] max-h-[400px]",style:{height:l},children:h})})},Kr=e=>ue.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},ue.createElement("path",{d:"M7.4665 6.39967H8.53317V5.33301H7.4665V6.39967ZM7.4665 10.6663H8.53317V7.46634H7.4665V10.6663ZM7.9945 13.333C5.0505 13.333 2.6665 10.9437 2.6665 7.99967C2.6665 5.05567 5.0505 2.66634 7.9945 2.66634C10.9438 2.66634 13.3332 5.05567 13.3332 7.99967C13.3332 10.9437 10.9438 13.333 7.9945 13.333ZM7.99984 3.73301C5.6425 3.73301 3.73317 5.64234 3.73317 7.99967C3.73317 10.357 5.6425 12.2663 7.99984 12.2663C10.3572 12.2663 12.2665 10.357 12.2665 7.99967C12.2665 5.64234 10.3572 3.73301 7.99984 3.73301Z",fill:"currentColor"})),Ko=({title:e,value:t})=>{const n=u.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return a.jsxs("div",{className:"flex gap-x-3 body-3",children:[a.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),a.jsx("p",{title:n(),className:"font-semibold truncate pr-3",children:n()})]})},Zo=({title:e,value:t,attachedKeysTitles:n,locale:s})=>{const[r,i]=u.useState(!1),[d,f]=u.useState(!1),o=u.useRef(null),c=u.useCallback(()=>{d&&i(m=>!m)},[i,d]),l=u.useCallback(()=>Array.isArray(t)?t?.map(m=>typeof m=="object"?m?.[s]:m)?.join(", "):t,[s,t]);return u.useEffect(()=>{o?.current&&f(o?.current?.scrollHeight>o?.current?.offsetHeight)},[o]),a.jsxs("div",{className:"metadata-item",children:[n?.map(m=>a.jsx("div",{title:m,className:"metadata-item-key pr-3 mb-1 text-neutrals-800",children:m},m)),a.jsxs("div",{className:P("flex items-center",d&&"justify-between"),children:[a.jsx("h2",{title:e,className:"metadata-item-title",children:e}),d&&a.jsx(v.IconButton,{buttonClassName:P("border-none p-0 w-6 h-6",r?"rotate-[180deg]":""),isBaseIconStyles:!1,icon:a.jsx(Gt,{width:24,height:24}),onClick:c})]}),a.jsx("p",{title:l(),className:P("metadata-item-value pr-3",!r&&"line-clamp-4"),ref:o,children:l()})]})},Kt=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,titles:r,locale:i})=>{const[d,f]=u.useState(v.PopUpState.Closed);u.useEffect(()=>{f(n?v.PopUpState.Opened:v.PopUpState.Closed)},[n]);const o=u.useCallback(()=>{f(v.PopUpState.Closed),s?.()},[s]);return a.jsx(a.Fragment,{children:d===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:a.jsx("h1",{className:"metadata-heading",children:r?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:v.PopUpSize.LG,dividers:!1,onClose:o,closeButtonTitle:r?.close||"Close",children:[a.jsxs("div",{className:"metadata-content overflow-hidden h-full",children:[t?.length>0&&a.jsx("div",{className:"metadata-description",children:t?.map(c=>a.jsx(Ko,{title:c?.title,value:c?.value},c?.title))}),a.jsx("div",{className:"h-full overflow-y-auto metadata-list",children:e&&e?.length>0?e?.map(c=>a.jsx(Zo,{title:c?.title,value:c?.value,locale:i,attachedKeysTitles:c?.attachedKeysTitles},c?.id||c?.title)):a.jsx("div",{className:"metadata-empty text-neutrals-700 flex h-full justify-center items-center",children:r?.noMetadata||"No metadata"})})]}),a.jsx("div",{})]})})},Xo=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Qo=e=>e?.data?.attributes,Zr=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),ks=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?S.getLocalizedName(n?.codes?.find(r=>r?.id===e),t)||"":s},Ct=(e,t,n)=>e?.map(s=>{const r=s?.name||"",i=t?.get(r),d=i?.codes?.length?i:void 0,f=Array.isArray(s?.value)?s?.value.map(o=>ks(o,n,d)):ks(s?.value,n,d);return{id:S.getLocalizedName(d,n)||s?.name,title:S.getLocalizedName(d||i,n),value:f||s?.value}})||[],Dt=(e,t,n)=>({title:n?.dataset||"Dataset",value:S.getLocalizedName(e,t)}),el=(e,t,n,s)=>[Dt(e,n,s),{title:s?.agency??"Agency",value:e?.agencyID},{title:s?.lastUpdated??"Last updated",value:t}],Xr=(e,t,n)=>({title:S.getDimensionTitle(e?.conceptSchemes,S.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),Qr=(e,t)=>({title:t?.observation||"Observation",value:e}),ea=(e,t,n,s,r,i)=>{const d={title:s?.timeSeries||"Time Series",value:i?.originalData?.name};return n?[Xr(e,t,r),d,Qr(n,s)]:[d]},tl=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.map((s,r)=>s?.values?.length>0?{...s}:{...s,values:[{value:t?.[r]}]}):n},nl=(e,t,n)=>e?.map(s=>{const r=s?.id,i=s?.values?.[0]?.value||s?.values?.[0]?.id,d=s?.values?.[0]?.ids,f=t?.get(r),o=f?.codes?.length?f:void 0,c=S.getLocalizedName(o?.codes?.find(m=>m?.id===i),n)||i,l=d&&d.map(m=>S.getLocalizedName(o?.codes?.find(h=>h?.id===m),n)||m);return{id:r,title:S.getLocalizedName(f,n)||r,value:d?l:c}}).filter(({value:s})=>!!s)||[],sl=(e,t)=>{const n=e?.dataSets?.[0],r=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=n?.dimensionGroupAttributes;return new Map(r.map(d=>{const f=d?.relationship?.dimensions,{codedSeriesKey:o,decodedSeriesKey:c}=rl(e,t,f);return[d.id,{values:i?.[o]||[],decodedSeriesKey:c,codedSeriesKey:o}]}))},rl=(e,t,n)=>{const s=e?.structures?.[0],r=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],i=new Array(r?.length)?.fill(""),d=new Array(r?.length)?.fill("");return n&&n?.forEach(f=>{const o=r?.findIndex(m=>m?.id===f)||0,c=t[o],l=r[o]?.values?.findIndex(m=>m?.id===c||m?.value===c)||0;i[o]=l>=0?l:c,d[o]=c}),{codedSeriesKey:i?.join(":"),decodedSeriesKey:d?.join(":")}},al=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),r=Array.isArray(t);return n||(s||r?{values:t}:{value:t?.toString()})},il=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},ta=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(r=>r?.id===t)?.name||t,ol=(e,t,n,s=J.Locale.EN)=>{const r=n?.dataStructureComponents?.dimensionList,i=[...r?.dimensions||[],...r?.timeDimensions||[]],d=[];return(e?.split(":")||[])?.forEach((o,c)=>{if(o!==""){const l=i?.[c]?.id||"",m=S.getLocalizedName(t?.get(l),s),h=ta(l,o,t);d.push(`${m}: ${h}`)}}),d},ll=(e,t,n,s,r=J.Locale.EN)=>{if(!e||!t||!s)return[];const i=e?.structures?.[0]?.attributes?.dimensionGroup||[],d=sl(e,s);return i?.map((f,o)=>{const c=d?.get(f?.id),l=n?.get(f?.id),m=il(al(f,c?.values?.[o]));return{id:f?.id,title:S.getLocalizedName(l,r),value:Array.isArray(m)?m?.map(h=>ta(f?.id,h,n)||""):m,attachedKeysTitles:ol(c?.decodedSeriesKey,n,t)}})?.filter(({value:f})=>f?.some(o=>!!o))||[]},na=e=>{const[t,n]=u.useState(!1),s=u.useRef(null),[r,i]=u.useState(""),[d,f]=u.useState(""),[o,c]=u.useState(!1),{onboardingFileSchema:l,isShowOnboarding:m}=Ne(),[h,p]=u.useState(!1),g=u.useMemo(()=>S.getStructureComponentsMap(e?.dataSetData),[e?.dataSetData]),C=u.useMemo(()=>[Dt(e?.dataSetData?.dataflows?.[0],e?.locale,e.titles),...Ct(Zr(e,g),g,e?.locale),...Ct(Qo(e),g,e?.locale),...ll(e?.attributesData,e?.dataSetData?.dataStructures?.[0],g,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,g]),w=u.useMemo(()=>ea(e?.dataSetData,e?.locale,e?.valueFormatted||e?.value,e.titles,e?.colDef,e?.data),[e]),y=u.useCallback(()=>{n(!0)},[]),x=u.useCallback(()=>{n(!1),p(!0)},[]);return u.useEffect(()=>{if(m){const{title:b,description:D}=He(pe.METADATA_PER_SERIES,e.titles);i(b),f(D)}},[e.titles,m]),u.useEffect(()=>{if(m){const b=l?.lastDisplayedElement===pe.METADATA_PER_SERIES&&e.node.rowIndex===0;c(b),b&&setTimeout(()=>{s?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[l?.lastDisplayedElement,e.node.rowIndex,m]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,children:a.jsx(v.IconButton,{title:e.titles?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:a.jsx(Kr,{className:"w-5 h-5"}),onClick:y})}),o&&a.jsx(Ue,{reference:s,title:r,description:d,onReferenceClick:y,shouldCloseTooltip:h}),t&&a.jsx(Kt,{titles:e.titles,locale:e?.locale,metadata:C,metadataDescription:e?.metadataSettings?.isMetadataDescription?w:[],isOpenMetadata:t,onCloseMetadata:x})]})},sa=e=>{const[t,n]=u.useState(!1),s=u.useMemo(()=>S.getStructureComponentsMap(e?.dataSetData),[e?.dataSetData]),r=u.useMemo(()=>Ct(Xo(e),s,e?.locale),[e,s]),i=u.useMemo(()=>[Dt(e?.dataSetData?.dataflows?.[0],e?.locale,e?.titles),...Ct(Zr(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Xr(e?.dataSetData,e?.locale,e?.colDef),Qr(e?.valueFormatted||e?.value,e?.titles)],...r],[e,s,r]),d=u.useMemo(()=>ea(e?.dataSetData,e?.locale,e?.valueFormatted||e?.value,e?.titles,e?.colDef,e?.data),[e]),f=u.useCallback(()=>{n(!0)},[]),o=u.useCallback(()=>{n(!1)},[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"w-full h-full p-2 text-end relative",children:[e?.valueFormatted||e?.value,r?.length>0&&a.jsx("div",{className:"metadata-indicator",title:e.titles?.metadata||"View details",onClick:f})]}),t&&a.jsx(Kt,{titles:e.titles,locale:e?.locale,metadata:i,metadataDescription:e?.metadataSettings?.isMetadataDescription?d:[],isOpenMetadata:t,onCloseMetadata:o})]})},ra=({ref:e,fixHeight:t,gridHeight:n,children:s})=>a.jsx("div",{ref:e,className:P("ag-theme-quartz w-full min-h-[80px]",t?"max-h-[400px]":"max-h-full"),style:{height:n},children:s}),cl=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,titles:r,showLimitMessage:i,onApiReady:d})=>{const[f,o]=u.useState(!1),[c,l]=u.useState([]),[m,h]=u.useState(),[p,g]=u.useState(400),C=u.useRef(null),[w,y]=u.useState(""),[x,b]=u.useState(""),[D,E]=u.useState(!1),{isShowOnboarding:T,onboardingFileSchema:A,setOnboardingFileSchema:N}=Ne();u.useEffect(()=>{if(e.grid_data==null)o(!0);else{const M=e.grid_data.columns.map(j=>j.colId===st?{...j,hide:!n}:j);l(e.grid_data.data),h(M),o(!1)}},[e.grid_data,n]),u.useEffect(()=>{c?(g(qt(c.length)),i?.(c.length>=v.SERIES_LIMIT)):i?.(!1)},[c,i]),u.useEffect(()=>{if(T){const{title:M,description:j}=He(pe.DATA_GRID,r);y(M),b(j)}},[r,T]),u.useEffect(()=>{A&&!A?.infoElements?.dataGrid&&N?.({...A,infoElements:{...A?.infoElements,dataGrid:!0},lastDisplayedElement:pe.DATA_GRID})},[A,N]),u.useEffect(()=>{if(T){const M=A?.lastDisplayedElement===pe.DATA_GRID;E(M),!f&&!t&&M&&setTimeout(()=>{C?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[A?.lastDisplayedElement,T,t,f]);const I=u.useCallback(M=>{d?.(M.api)},[d]),k=u.useMemo(()=>a.jsx(_t.AgGridReact,{onGridReady:I,headerHeight:rt,rowHeight:xt,rowData:c,enableCellTextSelection:!0,columnDefs:m,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:{[Yt]:na,[yt]:sa,[qr]:Jt}}),[c,m,I]);return f||t?a.jsx(v.Loader,{}):a.jsxs("div",{className:"w-full h-full",children:[a.jsx(ra,{ref:C,fixHeight:s,gridHeight:p,children:k}),D&&a.jsx(Ue,{reference:C,title:w,description:x,supressReferenceClick:!0})]})},ul=200,dl=8,fl=2,ml=({currentIndex:e,totalCount:t,icons:n,titles:s,onPrev:r,onNext:i})=>{const d=u.useRef(null),[f,o]=u.useState(""),[c,l]=u.useState(""),[m,h]=u.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ne();u.useEffect(()=>{if(g){const{title:x,description:b}=He(pe.CHARTS_NAVIGATION,s);o(x),l(b)}},[s,g]),u.useEffect(()=>{if(g){const x=p?.lastDisplayedElement===pe.CHARTS_NAVIGATION;h(x),x&&d?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const C=t>0?e/t*100:0,w=t>0?Math.min(dl*t,ul):0,y=t>0?Math.max(w/t,fl):0;return a.jsxs("div",{className:"w-full flex flex-row items-center gap-2 justify-center",children:[a.jsx("div",{className:P("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:r,children:n?.[mt.PREVIOUS]}),a.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[a.jsx("div",{className:"h-[4px] rounded-full bg-neutral-300 relative",style:{width:`${w}px`},children:a.jsx("div",{className:"h-full rounded-full bg-primary absolute",style:{left:`${C}%`,width:`${y}px`}})}),a.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),a.jsx("div",{className:P("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:i,ref:d,children:n?.[mt.NEXT]}),m&&a.jsx(Ue,{reference:d,title:f,description:c})]})},hl=({limitAmount:e,titles:t,openAdvancedView:n})=>{const[s,r]=u.useState(!1),{refs:i,floatingStyles:d,context:f}=Ie.useFloating({open:s,onOpenChange:r,placement:"top-start"}),o=Ie.useHover(f,{handleClose:Ie.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:c,getFloatingProps:l}=Ie.useInteractions([o]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex w-fit",ref:i.setReference,...c(),children:a.jsxs("div",{className:"flex bg-hues-100 w-fit px-4 mt-1 py-2 gap-1",children:[a.jsx("h5",{className:"font-bold",children:t?.limits||"Limited to"}),a.jsxs("h5",{children:[e," ",t?.timeseriesLimit||"Timeseries"]})]})}),s&&a.jsx("div",{className:"floating",ref:i.setFloating,style:d,...l(),children:a.jsxs("div",{className:"flex flex-col bg-white z-10 p-4 rounded shadow w-[300px] mb-2 gap-2",children:[a.jsxs("div",{children:[a.jsxs("h5",{className:"text-neutrals-900",children:[a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),a.jsxs("span",{className:"font-bold pr-0.5",children:[t?.limitLinkInfoP1_2||"limited to"," ",e]}),t?.limitLinkInfoP1_3||"for better clarity and performance."]}),a.jsxs("h5",{className:"text-neutrals-900",children:[a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP2_1||"To visualize specific timeseries"}),a.jsx("span",{className:"font-bold pr-0.5",children:t?.limitLinkInfoP2_2||"filter"}),a.jsx("span",{className:"pr-0.5",children:t?.limitLinkInfoP2_3||"your request, or"}),a.jsx("span",{className:"font-bold pr-0.5",children:t?.limitLinkInfoP2_4||"refine"}),t?.limitLinkInfoP2_5||"it in the chat."]})]}),n&&a.jsx("h4",{className:"cursor-pointer text-primary",onClick:n,children:t?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function gl(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const r=n.textStyle?.fontSize??12,i=n.textStyle?.fontFamily??"sans-serif";s.font=`${r}px ${i}`;const d=s.measureText(t).width,f=n.itemWidth??25,o=n.itemGap??10;return d+f+o}const pl=({option:e,style:t})=>{const n=u.useRef(null),[s,r]=u.useState(e);u.useEffect(()=>{r(Pt.cloneDeep(e))},[e]);const i=u.useCallback(()=>{const d=n.current?.getEchartsInstance?.();if(!d)return;const o=d.getDom().clientWidth,c=e.legend||{},l=c.itemHeight??14,m=c.textStyle?.fontSize??12,h=d.getModel()?.getComponent("legend")?.getData()||[];let p=0;h.forEach(y=>{const x=y.option.name||"";p+=gl(d,x,c)});const C=Math.max(1,Math.ceil(p/o))*(+l+ +m+6),w=20;r(y=>({...y,grid:{...y.grid||{},bottom:C+w}}))},[e.legend]);return u.useEffect(()=>{i();const d=()=>{i()};return window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}},[e,i]),a.jsx(Gs,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},wl=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:r=!0,titles:i})=>{const[d,f]=u.useState(!0),[o,c]=u.useState([]),[l,m]=u.useState(0),[h,p]=u.useState(void 0),{onboardingFileSchema:g,isShowOnboarding:C,setOnboardingFileSchema:w}=Ne(),y=u.useRef(null);u.useEffect(()=>{f(e.charting_data==null),c(e.charting_data?.units||[])},[e.charting_data]),u.useEffect(()=>{const D=o?.length>=l;p(!d&&D?o[l]:o[0]),D||m(0)},[d,o,l]),u.useEffect(()=>{g&&C&&!d&&(eo(g)&&(w?.(Qi(g)),y?.current?.scrollIntoView({block:"center",behavior:"smooth"})),g.lastDisplayedElement===pe.CHART_PER_SERIES&&w?.(Or(g)))},[d,w,g,C]);const x=u.useCallback(()=>{m(D=>Math.min(D+1,o.length-1))},[o]),b=u.useCallback(()=>{m(D=>Math.max(D-1,0))},[]);return d||n?a.jsx(v.Loader,{}):a.jsx("div",{className:"chart-attachment w-full h-full",ref:y,children:e.charting_data&&a.jsx("div",{className:"flex flex-col w-full h-full gap-4",children:o.length==0||h==null?a.jsx("h4",{className:"ml-1",children:i?.chartInfo||"No data"}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("h3",{className:"chart-attachment-title",children:[i?.chart||"Chart"," ",l+1,"/",o.length]}),a.jsx("span",{className:"text-neutrals-700 h4 chart-attachment-info",children:i?.chartInfo||"Chart Information"})]}),a.jsxs("div",{className:P("chart-area overflow-hidden flex flex-row gap-4 h-full ",r&&"max-h-[400px] min-h-[400px]",!r&&"min-h-[300px]"),children:[a.jsxs("div",{className:"flex flex-col flex-1 min-h-0 min-w-0 gap-4",children:[a.jsx(pl,{option:h.config,style:{width:"100%",height:"100%",minHeight:0}}),h.limitedByRowsAmountTo&&a.jsx(hl,{limitAmount:h.limitedByRowsAmountTo,openAdvancedView:s,titles:i}),o.length>1&&a.jsx(ml,{icons:t,currentIndex:l,totalCount:o.length,titles:i,onNext:x,onPrev:b})]}),a.jsx(Yr,{dimensionsInfo:h.dimensions})]})]})})})},vl=Na.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function Je(...e){return vl(P(...e))}const Cl=({attachment:e,className:t})=>{const{data:n,language:s}=e;return a.jsx("div",{className:Je(["h-full w-full [&_.cursors-layer]:hidden",t]),children:a.jsx(ja,{value:n,language:s,theme:"vs-light",options:{readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},aa=u.createContext(void 0);function ia({children:e,titles:t}){return a.jsx(aa.Provider,{value:t,children:e})}function Zt(){return u.useContext(aa)}const bl=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,showLimitMessage:r})=>{const[i,d]=u.useState(!1),[f,o]=u.useState([]),[c,l]=u.useState(),[m,h]=u.useState(400);u.useEffect(()=>{if(e.gridContent==null)d(!0);else{const g=e.gridContent.columns.map(C=>C.colId===st?{...C,hide:!n}:C);o(e.gridContent.data),l(g),d(!1)}},[e.gridContent,n]),u.useEffect(()=>{f?(h(qt(f.length)),r?.(f.length>=v.SERIES_LIMIT)):r?.(!1)},[f,r]);const p=u.useMemo(()=>a.jsx(_t.AgGridReact,{headerHeight:rt,rowHeight:xt,rowData:f,enableCellTextSelection:!0,columnDefs:c,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:{[Yt]:na,[yt]:sa,[qr]:Jt}}),[f,c]);return i||t?a.jsx(v.Loader,{}):a.jsx("div",{className:"w-full h-full",children:a.jsx(ra,{fixHeight:s,gridHeight:m,children:p})})},xl=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,isOpenedAdvancedView:r,onOpenAdvancedView:i,showLimitMessage:d,onGridApiReady:f})=>{const o=Zt();return a.jsxs("div",{className:"flex flex-1 w-full justify-center min-h-0",children:[no(e)&&a.jsx(jo,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),zt(e)&&a.jsx(qo,{actions:t,attachment:e,showLimitMessage:d}),ze(e)&&a.jsx(cl,{attachment:e,isDataLoading:s,isChartColumnVisible:r,fixHeight:!r,titles:o,showLimitMessage:d,onApiReady:f}),_r(e)&&a.jsx(bl,{attachment:e,isDataLoading:s,isChartColumnVisible:r,fixHeight:!r,showLimitMessage:d}),dt(e)&&a.jsx(wl,{titles:o,isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:r?void 0:i,fixHeight:!r}),Wt(e)&&a.jsx(Vo,{attachment:e,openLinkTitle:n?.openLinkTitle}),Pr(e)&&a.jsx(Ro,{attachment:e}),$t(e)&&a.jsx(Cl,{attachment:e,className:n?.codeAttachmentContainerClassName})]})};os.ModuleRegistry.registerModules([os.AllCommunityModule]);const oa=({attachments:e,actions:t,titles:n,messageStyles:s,attachmentsStyles:r,isSystemAttachments:i,isShowAttachments:d,showAdvancedView:f,currentDataQuery:o,dataQueries:c,attachmentInfoList:l,datasets:m,initialSelectedDatasetUrn:h,isDataLoading:p,isDataSetAttachments:g,locale:C,dimensions:w,filters:y,selectDataset:x,onAdvancedViewOpen:b,limitMessages:D,attachmentsConfig:E,isTableSettingsOpen:T,onTableSettingsOpen:A,onTableSettingsClose:N,onGridApiReady:I})=>{const[k,M]=u.useState(0),[j,_]=u.useState(null),{isOpenedAdvancedView:F,setIsOpenedAdvancedView:B}=Be(),[V,z]=u.useState(v.PopUpState.Closed),[Z,ie]=u.useState(!1),[K,q]=u.useState(),[Y,ce]=u.useState(),[me,H]=u.useState(!1),ne={downloadDataSet:t.downloadDataSet,getConstraints:t.getConstraints},se=S.DownloadType.DATA_IN_TABLE,oe=Se=>{M(Se)},he=u.useCallback(()=>{b?.(),B(!0),t.updateCurrentDataQuery(o||c?.[0]),t.updateDataQueries(c),t.updateDatasets(m)},[t,o,c,m,B,b]);u.useEffect(()=>{_(e[k]||null)},[e,k]),u.useEffect(()=>{ie(g&&(m==null||m?.length==0))},[m,g]),u.useEffect(()=>{T&&j&&!ze(j)&&N?.()},[T,j,N]);const Ce=u.useCallback(()=>{z(v.PopUpState.Closed)},[z]),ve=E?.isExternaLinkIncludeFilters,we=Wr(ve,y,o||c?.[0],w);return!e||e.length===0?null:a.jsx(a.Fragment,{children:F&&!d?a.jsx(po,{icon:s?.advanceViewIcon,title:s?.openAdvanceViewTitle??"Opened in Advanced view"}):a.jsxs("div",{className:P("space-y-3 max-w-full max-h-full h-full",!F&&!i?"pt-5":"pt-0"),children:[!F&&Z?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[i&&!F&&a.jsx(go,{titles:{queryUpdatedManuallyTitle:n?.queryUpdatedManually,setToTitle:n?.setTo},datasetIcon:r?.datasetIcon,attachmentInfoList:l}),!F&&m?.length!=null&&m?.length>0&&a.jsx(Ur,{datasets:m,initialSelectedDatasetUrn:h,locale:C,titles:n,isHideAdvancedViewButton:!f,openAdvancedViewIcon:r?.openAdvancedViewIcon,selectDataset:x,onOpenAdvancedView:he}),me&&a.jsx(v.RequestLimitMessage,{limitMessages:D,showAdvancedViewButton:!!j&&zt(j)&&f,onAdvancedViewClick:he,query:we}),a.jsx("div",{className:P(!F&&m?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:a.jsxs("div",{className:"flex flex-col max-w-full items-center gap-4 h-full",children:[a.jsx(No,{attachments:e,selectedAttachmentIndex:k,selectedAttachment:j,attachmentsStyles:r,titles:n,externalLink:we,isExternaLinkIncludeFilters:ve,limitMessages:D,onSelectedAttachmentChange:oe,onDownloadClick:()=>z(v.PopUpState.Opened),showAdvancedView:f,isTableSettingsOpen:T,onTableSettingsOpen:A}),j!=null&&a.jsx(xl,{selectedAttachment:j,actions:t,attachmentsStyles:r,isDataLoading:p,isOpenedAdvancedView:F,onOpenAdvancedView:he,showLimitMessage:H,onGridApiReady:I})]})})]}),a.jsxs(a.Fragment,{children:[V===v.PopUpState.Opened&&a.jsx(xo,{actions:ne,onCloseModal:Ce,dataQuery:o,datasetName:j?.title||"",locale:C,type:se,dimensions:w,filters:y,urn:o?.urn,datasetIcon:r?.datasetIcon,isDisplayDatasetIcon:r?.isDisplayDatasetIcon,titles:r?.downloadTitles,setIsShowDownloadAlert:q,setDownloadAlertDetails:ce,limitMessages:D,showLimitMessage:me,externalLink:we}),K&&a.jsx(v.Alert,{alertDetails:Y,successIcon:r?.successDownloadIcon,errorIcon:r?.errorDownloadIcon,onClose:()=>q(!1),closeButtonTitle:r?.closeTitle||"Close"})]})]})})},Sl=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function yl(e){return e.colId??e.field??null}function Dl(e){return String(e.headerName??e.field??e.colId??"").trim()}function Ml(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function kl(e,t){const n=e.getColumnDefs()??[],s=Ml(e),r=[];for(const f of n){const o=yl(f);if(!o)continue;const c=Dl(f);if(!t({colId:o,label:c,colDef:f}))continue;const l=s.get(o);r.push({id:o,type:"item",label:c,isChecked:!(l?.hide??!1),draggable:!0,checkable:!0})}const i=e.getColumnState().map(f=>f.colId),d=new Map(i.map((f,o)=>[f,o]));return r.sort((f,o)=>{const c=d.get(f.id)??Number.MAX_SAFE_INTEGER,l=d.get(o.id)??Number.MAX_SAFE_INTEGER;return c-l})}function Es(e,t){let n=e,s;for(const r of t){if(s=n.find(i=>i.id===r),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function Ft(e){const t=[];for(const n of e){if(n.type==="group"){t.push(...Ft(n.items));continue}if(n.items?.length){t.push(...Ft(n.items));continue}t.push(n.id)}return t}function El(e,t,n){const s=[...t];return e.map(r=>n.has(r)?s.shift()??r:r)}function Ts(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()}}function Tl(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const As=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function la(e,t){u.useEffect(()=>{if(e){for(const n of As)e.addEventListener(n,t);return()=>{for(const n of As)e.removeEventListener(n,t)}}},[e,t])}function Al({currentUrn:e}){const[t,n]=u.useState(),[s,r]=u.useState(null),i=u.useRef(new Map),d=u.useRef(new Map),f=u.useCallback(c=>{if(n(c),i.current.has(e))s==null&&r(i.current.get(e)??null);else{const m=Ts(c);i.current.set(e,m),r(m)}const l=d.current.get(e);l&&(c.applyColumnState({state:l.columnState,applyOrder:!0}),c.setColumnGroupState(l.columnGroupState))},[e]);u.useEffect(()=>{r(i.current.get(e)??null)},[e]);const o=u.useCallback(()=>{t&&d.current.set(e,Ts(t))},[e,t]);return la(t,o),{gridApi:t,onGridApiReady:f,initialColumnsState:s}}const ca=u.createContext(null);function Nl({currentUrn:e,children:t}){const[n,s]=u.useState(!1),r=u.useCallback(()=>s(!0),[]),i=u.useCallback(()=>s(!1),[]),{gridApi:d,onGridApiReady:f,initialColumnsState:o}=Al({currentUrn:e}),c=u.useMemo(()=>({tableSettings:{isOpen:n,open:r,close:i},agGrid:{gridApi:d,onGridApiReady:f,initialColumnsState:o}}),[d,o,n,f,r,i]);return a.jsx(ca.Provider,{value:c,children:t})}function ua(){const e=u.useContext(ca);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const jl=e=>{const{tableSettings:{isOpen:t,open:n,close:s},agGrid:{onGridApiReady:r}}=ua();return a.jsx(oa,{...e,isTableSettingsOpen:t,onTableSettingsOpen:n,onTableSettingsClose:s,onGridApiReady:r})},Il=({actions:e,structureDataMaps:t,dimensions:n,buttonProps:s,modalProps:r,attachmentsDataQuery:i,dataQueries:d,initialConstraints:f,onFiltersChange:o,locale:c,timeRangeOptions:l,titles:m,datasetIcon:h,conversationKey:p,conversation:g,setConversation:C,updateConversation:w,updateDataQueries:y,limitMessages:x,filterIconClassName:b})=>{const[D,E]=u.useState(v.PopUpState.Closed),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState(),[j,_]=u.useState([]),[F,B]=u.useState(void 0),V=u.useRef(f||[]),z=u.useRef(t?.constraintsMap),[Z,ie]=u.useState([]),[K,q]=u.useState(),[Y,ce]=u.useState(),[me,H]=u.useState(!1),ne=u.useMemo(()=>zi(d,t),[d,t]),se=R=>{const G=R?T.map($=>Ge($,R)?R:$):T;ce(!0),A(wt(G)),q?.(!0),oe(R?.isTimeDimension?pt(G,R):G,A,q)};u.useEffect(()=>{D===v.PopUpState.Closed&&ie(V.current)},[D]);const oe=u.useCallback((R,G,$)=>{const le=Lt(R),re=d?.map(fe=>{const Me=fe?.urn??"",Oe=vt(le?.get(Me)||[]).filter(Ae=>Ae.componentCode!==S.TIME_PERIOD);return e?Ve(e.getConstraints,_e(Me,Oe),()=>e.getConstraints(Me,Oe)):Promise.resolve(void 0)})||[];Promise.all(re).then(fe=>{const Me=new Map(fe?.map(Oe=>{const Ae=Oe?.data?.dataConstraints;return[S.generateShortUrn(Ae?.[0]?.id,Ae?.[0]?.version,Ae?.[0]?.agencyID),Ae]}));z.current=Me,$?.(!1),G(Tt(le,{...t,constraintsMap:Me},c))}).catch(()=>{const fe=new Map;z.current=fe,$?.(!1),G(Tt(le,{...t,constraintsMap:fe},c))}).finally(()=>{ce(!1)})},[e,d,c,t]);u.useEffect(()=>{if(!ne){q(!0);return}const R=Hi(t,c),G=Ui(R,d,t?.constraintsMap);q?.(!0),oe(G,I,q)},[d,oe,ne,c,t]),u.useEffect(()=>{N?.length&&_(Bt(N))},[N]),u.useEffect(()=>{A(R=>pt(R,k))},[k]),u.useEffect(()=>{D===v.PopUpState.Opened&&(M({...N?.[0],isSelectedFilter:!0}),A(N)),D===v.PopUpState.Closed&&M(void 0)},[N,D]);const he=u.useCallback(async R=>{const G=Nr(R,i?.urn),$=g?{...g,messages:Vr(g?.messages,G,i,d)}:null;C?.($),y?.(Gr(G,i,d)),await w(decodeURI(p),{name:$?.name,messages:$?.messages||[]})},[i,g,p,d,C,w,y]),Ce=u.useCallback((R,G)=>{A($=>gr($,R,G)),Ge(k,R)&&M($=>$&&{...$,displayMode:G})},[k]),ve=u.useCallback(R=>Ar(R,n,i?.urn),[i?.urn,n]),we=u.useCallback((R,G)=>{const $=new Map(z.current);$.set(i?.urn||"",R),z.current=$;const le=Tt(Lt(G),{...t,constraintsMap:$},c);V.current=R,M(re=>le?.find(fe=>Ge(fe,re))||re),A(le),ce(!1)},[i?.urn,c,t]),Se=u.useCallback(R=>{ce(!0),A(wt(R));const G=i?.urn??"",$=vt(R,G).filter(re=>re.componentCode!==S.TIME_PERIOD);(e?Ve(e.getConstraints,_e(G,$),()=>e.getConstraints(G,$)):Promise.resolve(void 0)).then(re=>{we(re?.data?.dataConstraints||[],R)}).catch(()=>{we([],R)})},[e,i?.urn,we]),Ee=u.useCallback(R=>{const G=Cr(T,R);Se(G)},[Se,T]),ye=u.useCallback(()=>{V.current=Z,E(v.PopUpState.Closed),H(!0)},[Z]),De=u.useCallback(()=>{const R=br(T);Se(R)},[Se,T]),je=u.useCallback(()=>{const R=ve(T);o?.(R,V.current,T),I(T),E(v.PopUpState.Closed),H(!0),u.startTransition(()=>{he(T)})},[ve,T,o,he,V]),Le=R=>{B(R)},W=Number(S.getTimeSeriesCount(V?.current?.[0]?.annotations));return a.jsxs("div",{className:"filters-container",children:[a.jsx(Rr,{buttonProps:s,selectedFiltersCount:wr(j),isLoading:K,setModalState:E,titles:m,isModalClosed:me,warningIcon:x?.warningIcon,filterIconClassName:b,timeSeriesCount:W}),a.jsx(a.Fragment,{children:D===v.PopUpState.Opened&&a.jsxs(v.Popup,{heading:m?.settings||"Settings",portalId:"filters",size:v.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:r?.isShowDividers,onClose:ye,closeButtonTitle:m?.close||"Close",children:[a.jsx(Er,{locale:c,titles:m,timeRangeOptions:l,filtersList:T,selectedFilter:k,isDisableValues:Y,modalProps:r,initialConstraints:f,datasetIcon:h,structuresMap:t?.structuresMap,timeSeriesCount:`${W}`,setSelectedFilter:M,onSelectDisplayMode:Ce,onDeleteFilter:Ee,updateSelectedFilterValues:se,onTimePeriodChange:Le,selectedTimeOption:F}),a.jsx(jr,{titles:m,onApply:je,onClose:ye,onClearAllFilters:De,modalProps:r,applyDisabled:K||Y,timeseriesLength:W,limitMessages:x})]})})]})},Ll={isCrossDatasetModeOn:!1},Ol=u.createContext(Ll);function Xt(){return u.useContext(Ol)}const Rl=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:r,dimensions:i,locale:d,attachmentsStyles:f,isDataLoading:o,setIsFiltering:c,titles:l,limitMessages:m,attachmentsConfig:h,filters:p,onFiltersChange:g})=>{const C={getConstraints:t.getConstraints},{isCrossDatasetModeOn:w}=Xt();return u.useEffect(()=>{o||c?.(!1)},[o,c]),a.jsx("div",{className:"bg-white rounded h-full min-h-0",children:a.jsxs("div",{className:"flex flex-col gap-4 h-full overflow-x-hidden",children:[a.jsxs("div",{className:"data-details-header flex justify-between items-center",children:[a.jsx("h2",{children:l?.content??"Content"}),w?a.jsx(Il,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:d,actions:C,dimensions:i,titles:l,...e,onFiltersChange:g,limitMessages:m}):a.jsx(mo,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:d,actions:C,dimensions:i,titles:l,...e,onFiltersChange:g,limitMessages:m})]}),a.jsx("div",{className:"advanced-view-attachments-container flex-1 min-h-0",children:a.jsx(jl,{titles:l,attachments:n,attachmentsStyles:f,currentDataQuery:s,dimensions:i,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:o,locale:d,filters:p,limitMessages:m,attachmentsConfig:h})})]})})};function At(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Xe(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const d=e.defaultFormattingWidth||e.defaultWidth,f=n?.width?String(n.width):d;r=e.formattingValues[f]||e.formattingValues[d]}else{const d=e.defaultWidth,f=n?.width?String(n.width):e.defaultWidth;r=e.values[f]||e.values[d]}const i=e.argumentCallback?e.argumentCallback(t):t;return r[i]}}function Qe(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(r);if(!i)return null;const d=i[0],f=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(f)?Pl(f,m=>m.test(d)):Fl(f,m=>m.test(d));let c;c=e.valueCallback?e.valueCallback(o):o,c=n.valueCallback?n.valueCallback(c):c;const l=t.slice(d.length);return{value:c,rest:l}}}function Fl(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Pl(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function _l(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],i=t.match(e.parsePattern);if(!i)return null;let d=e.valueCallback?e.valueCallback(i[0]):i[0];d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(r.length);return{value:d,rest:f}}}const Ns=Symbol.for("constructDateFrom");function da(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ns in e?e[Ns](t):e instanceof Date?new e.constructor(t):new Date(t)}function Vl(e,...t){const n=da.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let Gl={};function Bl(){return Gl}function Qt(e,t){return da(t||e,e)}function js(e,t){const n=Bl(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=Qt(e,t?.in),i=r.getDay(),d=(i<s?7:0)+i-s;return r.setDate(r.getDate()-d),r.setHours(0,0,0,0),r}function fa(e,t,n){const[s,r]=Vl(n?.in,e,t);return+js(s,n)==+js(r,n)}function et(e,t){if(e.one!==void 0&&t===1)return e.one;const n=t%10,s=t%100;return n===1&&s!==11?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(s<10||s>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function Te(e){return(t,n)=>n&&n.addSuffix?n.comparison&&n.comparison>0?e.future?et(e.future,t):"за "+et(e.regular,t):e.past?et(e.past,t):et(e.regular,t)+" тому":et(e.regular,t)}const Hl=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",Ul={lessThanXSeconds:Te({regular:{one:"менше секунди",singularNominative:"менше {{count}} секунди",singularGenitive:"менше {{count}} секунд",pluralGenitive:"менше {{count}} секунд"},future:{one:"менше, ніж за секунду",singularNominative:"менше, ніж за {{count}} секунду",singularGenitive:"менше, ніж за {{count}} секунди",pluralGenitive:"менше, ніж за {{count}} секунд"}}),xSeconds:Te({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунди",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду тому",singularGenitive:"{{count}} секунди тому",pluralGenitive:"{{count}} секунд тому"},future:{singularNominative:"за {{count}} секунду",singularGenitive:"за {{count}} секунди",pluralGenitive:"за {{count}} секунд"}}),halfAMinute:Hl,lessThanXMinutes:Te({regular:{one:"менше хвилини",singularNominative:"менше {{count}} хвилини",singularGenitive:"менше {{count}} хвилин",pluralGenitive:"менше {{count}} хвилин"},future:{one:"менше, ніж за хвилину",singularNominative:"менше, ніж за {{count}} хвилину",singularGenitive:"менше, ніж за {{count}} хвилини",pluralGenitive:"менше, ніж за {{count}} хвилин"}}),xMinutes:Te({regular:{singularNominative:"{{count}} хвилина",singularGenitive:"{{count}} хвилини",pluralGenitive:"{{count}} хвилин"},past:{singularNominative:"{{count}} хвилину тому",singularGenitive:"{{count}} хвилини тому",pluralGenitive:"{{count}} хвилин тому"},future:{singularNominative:"за {{count}} хвилину",singularGenitive:"за {{count}} хвилини",pluralGenitive:"за {{count}} хвилин"}}),aboutXHours:Te({regular:{singularNominative:"близько {{count}} години",singularGenitive:"близько {{count}} годин",pluralGenitive:"близько {{count}} годин"},future:{singularNominative:"приблизно за {{count}} годину",singularGenitive:"приблизно за {{count}} години",pluralGenitive:"приблизно за {{count}} годин"}}),xHours:Te({regular:{singularNominative:"{{count}} годину",singularGenitive:"{{count}} години",pluralGenitive:"{{count}} годин"}}),xDays:Te({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} днi",pluralGenitive:"{{count}} днів"}}),aboutXWeeks:Te({regular:{singularNominative:"близько {{count}} тижня",singularGenitive:"близько {{count}} тижнів",pluralGenitive:"близько {{count}} тижнів"},future:{singularNominative:"приблизно за {{count}} тиждень",singularGenitive:"приблизно за {{count}} тижні",pluralGenitive:"приблизно за {{count}} тижнів"}}),xWeeks:Te({regular:{singularNominative:"{{count}} тиждень",singularGenitive:"{{count}} тижні",pluralGenitive:"{{count}} тижнів"}}),aboutXMonths:Te({regular:{singularNominative:"близько {{count}} місяця",singularGenitive:"близько {{count}} місяців",pluralGenitive:"близько {{count}} місяців"},future:{singularNominative:"приблизно за {{count}} місяць",singularGenitive:"приблизно за {{count}} місяці",pluralGenitive:"приблизно за {{count}} місяців"}}),xMonths:Te({regular:{singularNominative:"{{count}} місяць",singularGenitive:"{{count}} місяці",pluralGenitive:"{{count}} місяців"}}),aboutXYears:Te({regular:{singularNominative:"близько {{count}} року",singularGenitive:"близько {{count}} років",pluralGenitive:"близько {{count}} років"},future:{singularNominative:"приблизно за {{count}} рік",singularGenitive:"приблизно за {{count}} роки",pluralGenitive:"приблизно за {{count}} років"}}),xYears:Te({regular:{singularNominative:"{{count}} рік",singularGenitive:"{{count}} роки",pluralGenitive:"{{count}} років"}}),overXYears:Te({regular:{singularNominative:"більше {{count}} року",singularGenitive:"більше {{count}} років",pluralGenitive:"більше {{count}} років"},future:{singularNominative:"більше, ніж за {{count}} рік",singularGenitive:"більше, ніж за {{count}} роки",pluralGenitive:"більше, ніж за {{count}} років"}}),almostXYears:Te({regular:{singularNominative:"майже {{count}} рік",singularGenitive:"майже {{count}} роки",pluralGenitive:"майже {{count}} років"},future:{singularNominative:"майже за {{count}} рік",singularGenitive:"майже за {{count}} роки",pluralGenitive:"майже за {{count}} років"}})},Wl=(e,t,n)=>(n=n||{},Ul[e](t,n)),zl={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},$l={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},Jl={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Yl={date:At({formats:zl,defaultWidth:"full"}),time:At({formats:$l,defaultWidth:"full"}),dateTime:At({formats:Jl,defaultWidth:"full"})},en=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function ql(e){const t=en[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function ma(e){return"'у "+en[e]+" о' p"}function Kl(e){const t=en[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const Zl=(e,t,n)=>{const s=Qt(e),r=s.getDay();return fa(s,t,n)?ma(r):ql(r)},Xl=(e,t,n)=>{const s=Qt(e),r=s.getDay();return fa(s,t,n)?ma(r):Kl(r)},Ql={lastWeek:Zl,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:Xl,other:"P"},ec=(e,t,n,s)=>{const r=Ql[e];return typeof r=="function"?r(t,n,s):r},tc={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},nc={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},sc={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},rc={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},ac={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},ic={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранок",afternoon:"день",evening:"вечір",night:"ніч"}},oc={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"}},lc=(e,t)=>{const n=String(t?.unit),s=Number(e);let r;return n==="date"?s===3||s===23?r="-є":r="-е":n==="minute"||n==="second"||n==="hour"?r="-а":r="-й",s+r},cc={ordinalNumber:lc,era:Xe({values:tc,defaultWidth:"wide"}),quarter:Xe({values:nc,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Xe({values:sc,defaultWidth:"wide",formattingValues:rc,defaultFormattingWidth:"wide"}),day:Xe({values:ac,defaultWidth:"wide"}),dayPeriod:Xe({values:ic,defaultWidth:"any",formattingValues:oc,defaultFormattingWidth:"wide"})},uc=/^(\d+)(-?(е|й|є|а|я))?/i,dc=/\d+/i,fc={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},mc={any:[/^д/i,/^н/i]},hc={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},gc={any:[/1/i,/2/i,/3/i,/4/i]},pc={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},wc={narrow:[/^с/i,/^л/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^л/i,/^с/i,/^в/i,/^ж/i,/^л/i,/^г/i],any:[/^сі/i,/^лю/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^лип/i,/^се/i,/^в/i,/^ж/i,/^лис/i,/^г/i]},vc={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},Cc={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},bc={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},xc={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},Sc={ordinalNumber:_l({matchPattern:uc,parsePattern:dc,valueCallback:e=>parseInt(e,10)}),era:Qe({matchPatterns:fc,defaultMatchWidth:"wide",parsePatterns:mc,defaultParseWidth:"any"}),quarter:Qe({matchPatterns:hc,defaultMatchWidth:"wide",parsePatterns:gc,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Qe({matchPatterns:pc,defaultMatchWidth:"wide",parsePatterns:wc,defaultParseWidth:"any"}),day:Qe({matchPatterns:vc,defaultMatchWidth:"wide",parsePatterns:Cc,defaultParseWidth:"any"}),dayPeriod:Qe({matchPatterns:bc,defaultMatchWidth:"wide",parsePatterns:xc,defaultParseWidth:"any"})},yc={code:"uk",formatDistance:Wl,formatLong:Yl,formatRelative:ec,localize:cc,match:Sc,options:{weekStartsOn:1,firstWeekContainsDate:1}},Dc=e=>e===J.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",Mc=(e,t)=>{const n=Dc(t);return e!=null&&e!==""&&n&&ls.isValid(new Date(e))?ls.format(new Date(e),n,t===J.Locale.UK?{locale:yc}:void 0):""},kc=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:r,metadataSettings:i,locale:d,titles:f,getDatasetUpdatedTime:o,externalLink:c,datasetIcon:l,externalLinkIcon:m,metadataButtonClassName:h,metadataIconClassName:p,infoSegmentContainerClassName:g,infoSegmentHeaderClassName:C,nameAndMetadataContainerClassName:w})=>{const[y,x]=u.useState(""),[b,D]=u.useState(!1),E=u.useRef(null),[T,A]=u.useState(""),[N,I]=u.useState(""),[k,M]=u.useState(!1),{onboardingFileSchema:j,isShowOnboarding:_}=Ne(),[F,B]=u.useState(!1),V=u.useMemo(()=>i?.isMetadataDescription?el(n,y,d,f):[],[n,y,d,i?.isMetadataDescription,f]),z=u.useMemo(()=>[...i?.isMetadataDescription?[]:[Dt(n,d,f)],...nl(tl(s),S.getStructureComponentsMap(r),d)],[s,n,d,i?.isMetadataDescription,r,f]),Z=u.useCallback(()=>{D(!0)},[]),ie=u.useCallback(()=>{D(!1),B(!0)},[]);u.useEffect(()=>{const Y=o&&o(z)||Mc(S.getLastUpdatedTime(n),d);x(Y)},[n,d,z,o]),u.useEffect(()=>{if(_){const{title:q,description:Y}=He(pe.METADATA_PER_DATASET,f);A(q),I(Y)}},[f,_]),u.useEffect(()=>{_&&M(j?.lastDisplayedElement===pe.METADATA_PER_DATASET)},[j?.lastDisplayedElement,_]);const K=(q,Y)=>a.jsxs("div",{className:Je("flex gap-1 text-neutrals-1000",g),children:[a.jsxs("span",{className:Je("text-neutral-800",C),children:[q,":"]}),a.jsx("span",{children:Y})]});return a.jsxs("div",{className:"flex flex-col bg-white gap-3 dataset-info",children:[t&&a.jsxs("div",{className:"flex gap-1 items-center py-1 px-2 rounded-[20px] bg-accent-500 body-2 w-fit",children:[l,f?.dataset??"Dataset"]}),a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex gap-1 items-center",children:[a.jsxs("div",{role:"heading","aria-level":4,className:Je("flex gap-1 items-center h4",w),children:[a.jsx("div",{ref:E,children:a.jsx(v.IconButton,{title:f?.metadata??"View details",buttonClassName:Je("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:a.jsx(Kr,{className:Je("size-4",p)}),onClick:Z})}),a.jsx("span",{children:S.getLocalizedName(n,d)})]}),c&&a.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:m||a.jsx(ke.IconExternalLink,{className:"text-primary cursor-pointer w-4 h-4 shrink-0"})})]}),a.jsxs("div",{className:"flex gap-2 body-3 items-center",children:[e&&a.jsxs(a.Fragment,{children:[K(f?.agency??"Agency",n?.agencyID??""),a.jsx("div",{"aria-hidden":"true",className:"border-l border-l-neutral-500 h-[14px]"})]}),K(f?.lastUpdated??"Last updated",y)]})]}),k&&a.jsx(Ue,{reference:E,title:T,description:N,onReferenceClick:Z,shouldCloseTooltip:F}),b&&a.jsx(Kt,{titles:f,locale:d,metadata:z,metadataDescription:V,isOpenMetadata:b,onCloseMetadata:ie})]})},Ec=({titles:e,locale:t,isShowShare:n,shareConversationProps:s})=>{const{setIsOpenedAdvancedView:r}=Be(),i=u.useRef(null),[d,f]=u.useState(""),[o,c]=u.useState(""),[l,m]=u.useState(!1),{onboardingFileSchema:h,isShowOnboarding:p}=Ne();return u.useEffect(()=>{if(p){const{title:g,description:C}=He(pe.EXIT_ADVANCED_VIEW,e);f(g),c(C)}},[e,p]),u.useEffect(()=>{p&&m(h?.lastDisplayedElement===pe.EXIT_ADVANCED_VIEW)},[h?.lastDisplayedElement,p]),a.jsxs("header",{className:P("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[a.jsxs("div",{className:P("flex gap-3 items-center",!n&&"justify-between w-full","advanced-view-header-title"),children:[a.jsx("div",{ref:i,className:P(!n&&"order-2","flex"),children:a.jsx(v.CloseButton,{btnClassNames:"button-close",onClick:()=>r(!1),title:e?.close||"Close"})}),l&&a.jsx(Ue,{reference:i,title:d,description:o,onReferenceClick:()=>r(!1),shouldMoveToNextStep:!0}),a.jsx("h2",{className:"sm:h-3",children:e?.advanceViewTitle??"Advanced view"})]}),n&&a.jsx(ir,{locale:t,...s})]})};function Mt(e,t,n){const s=S.getConcept(e.conceptIdentity,t),r=S.getArtifactByUrnWithWildCard(s?.coreRepresentation?.enumeration,n);return{concept:s,codeList:r||void 0}}function ha(e,t,n){const s=e.findIndex(r=>r.id===t);return n.originalData.parsedTimeSeriesValue[s]}function tn(e,t,n,s,r){const i=ha(e,t,s),d=n?.codes?.find(f=>f.id===i);return S.getLocalizedName(d,r)}function Tc(e,t,n,s,r,i,d,f,o){const c=Ac(e,n),l=o?.startPeriod&&o.endPeriod?S.getAdditionalColumns(f,o):[],m=Nc(e,t,n,s,r,i,l);return[Uo(e,t?.data,n,r,i,d),...c,...m,Wo(e,t?.data,n,void 0,i,d)]}function Ac(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],r=S.getDimensions(e)?.dimensions||[];return r.map(i=>{const{codeList:d,concept:f}=Mt(i,n,s),o=c=>{const{data:l,colDef:m}=c,h=m.field;return tn(r,h,d,l,t)};return{headerName:S.getLocalizedName(f,t),field:i.id,colId:i.id,valueGetter:o,...Ke,tooltipValueGetter:c=>c.value}})}function Nc(e,t,n,s,r,i,d){const f=Lc(d,S.getTimePeriods(t));return Ic(f,(c,l)=>jc(c,l||c,s,i),e,n,r,i)}const jc=(e,t,n=J.defaultFormatNumbers,s)=>({headerName:mr(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Ze,cellClass:["justify-end","cell-with-meta"],valueFormatter:r=>J.formatNumberBySign(r.value,n)}),Ic=(e,t,n,s,r,i)=>{const d=[];return e.sort((o,c)=>S.sortPeriods(o,c)).forEach(o=>{d.push({headerName:o.toString(),field:o.toString(),...t(o.toString()),valueGetter:c=>c.data[c.column.getColId()]?.value?.[0]?.value||null,cellClass:St,cellRenderer:yt,width:Ze,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:r,titles:i}})}),d},Lc=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(c=>S.isYearly(c)),s=t.some(c=>S.isSemiAnnually(c)),r=t.some(c=>S.isQuarterly(c)),i=t.some(c=>S.isMonthly(c)),d=t.some(c=>S.isWeekly(c)),f=t.some(c=>S.isDaily(c)),o=e.filter(c=>S.isYearly(c)?n:S.isSemiAnnually(c)?s:S.isQuarterly(c)?r:S.isMonthly(c)?i:S.isWeekly(c)?d:S.isDaily(c)?f:!0);return Array.from(new Set([...o,...t]))};function Oc(e,t,n){const s=t.map(i=>i.id).filter(i=>i!=null),r=n.map(i=>i.id).filter(i=>i!=null);return Rc(e,s,r,s)}const Rc=(e,t,n,s)=>{const r=Pc(e,t),i={};for(const d of r){const f=d.rowTime,o=ga(f,s);if(i[o]==null){i[o]={};for(const c of s)i[o][c]=f[c]}i[o]={attributes:d.attributes.filter(({value:c})=>c),...i[o],id:o,originalData:d.originalData,...Fc(f,n)}}return Object.values(i)},ga=(e,t)=>t.map(n=>e[n]).join("_"),Fc=(e,t)=>{const n=ga(e,t),{OBS_VALUE:s,obsAttributes:r}=e,i={};return i[n]={value:s,obsAttributes:r},i},Pc=(e,t)=>{const n=[];for(const s of e){const r={},i=s.name.split(".");for(let d=0;d<t.length;d+=1)r[t[d]]=i[d];if(!s.values.length){const d={...r};d.TIME_PERIOD=void 0,d.OBS_VALUE=void 0,n.push({rowTime:d,attributes:s.attributes,id:s.name,originalData:s})}s.values.forEach(d=>{const f={...r};f.TIME_PERIOD=d.dimensionAtObservation;const o=_c(s,d);f.OBS_VALUE=o,f.obsAttributes=d?.obsAttributes?.filter(({value:c})=>c)||[],n.push({rowTime:f,attributes:s.attributes,id:s.name,originalData:s})})}return n},_c=(e,t)=>{const s=[...e.attributes,...t.obsAttributes].find(({name:r})=>r==="OBS_VALUE");return s?[s]:t.values},Vc="#EEEEEE",Gc="#777777";function Bc(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:r=>{let i=r[0].axisValueLabel+"<br/>";return r.forEach(d=>{d.value!==null&&d.value!==void 0&&(i+=d.marker+" "+d.seriesName+": "+d.value+"<br/>")}),i}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Is(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Is(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Is(e=Vc,t=Gc){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function pa(e,t,n,s){return t.map(i=>{const d=S.getDimensions(n)?.dimensions||[],f=d?.find(c=>c.id===i);if(f==null)return e[i]||"";const{codeList:o}=Mt(f,n.conceptSchemes||[],n.codelists||[]);return tn(d,i,o,e,s)}).join(" - ")}function Hc(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(i=>i!=null),r=S.getDimensions(e)?.dimensions?.filter(i=>i.id!=null&&!n.includes(i.id)&&t?.metadata?.countryDimension!==i.id).map(i=>i.id).filter(i=>i!=null)||[];return[...n,...r]}function Uc(e,t,n){const s={};return e.forEach(r=>{const i=Wc(r,t,n);s[i]||(s[i]={rows:[]}),s[i].rows.push(r)}),Object.keys(s).map(r=>s[r])}function Wc(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(i=>s?.find(f=>f.id===i)==null?e[i]||"":ha(s,i,e)).join(" - ")}function zc(e,t){const n={};return e.forEach(s=>n[s]=$c(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function $c(e,t){const n=t.map(r=>Jc(e,r));return new Set(n).size===1}function Jc(e,t){return t[e]}const Yc="line",lt=10;function qc(e,t,n,s,r){const i=nn(t,e,n,s,r),f=S.getTimePeriods(t).sort((m,h)=>S.sortPeriods(m,h)),o=Hc(e,n),{nonUniqDimensions:c}=zc(o,i);return{units:Uc(i,c,e).map(m=>wa(m,e,n,f,s,r))}}function Kc(e,t,n,s,r,i){return wa({rows:[e]},n,s,t,r,i)}function wa(e,t,n,s,r,i){const d=Qc(e.rows,t,r),f=d?.find(c=>S.FREQUENCY_DIMENSION_ID.includes(c?.id))?.id,o=Zc(e.rows.length>lt?e.rows.slice(0,lt):e.rows,t,n,r,Ls(s,e?.rows?.[0],f));return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>lt?lt:void 0,dimensions:d,config:Bc(Ls(s,e?.rows?.[0],f),o,i)}}function Ls(e,t,n){if(n){const s=t?.[n];if(s===S.Periods.MONTHLY)return e?.filter(r=>S.isMonthly(r));if(s===S.Periods.QUARTERLY)return e?.filter(r=>S.isQuarterly(r));if(s===S.Periods.ANNUAL)return e?.filter(r=>S.isYearly(r))}return e}function Zc(e,t,n,s,r){return e.map(i=>({name:n?.metadata?.countryDimension==null?"":pa(i,[n?.metadata?.countryDimension],t,s),type:Yc,data:r.map(d=>Xc(d,i))}))}function Xc(e,t){return t[e]?.value?.[0]?.value||null}function Qc(e,t,n){return(S.getDimensions(t)?.dimensions||[]).map(s=>{if(s.id!=null)return{id:s.id,title:eu(s,t,n),value:pa(e[0],[s.id],t,n)}}).filter(s=>s!=null)}function eu(e,t,n){const s=t.conceptSchemes||[],r=t.codelists||[],{concept:i}=Mt(e,s,r);return S.getLocalizedName(i,n)||e.id}function nn(e,t,n,s,r){const i=e==null?[]:S.getParsedResponse(e),d=S.getDimensions(t)?.dimensions||[],f=S.getDimensions(t)?.timeDimensions||[],o=Oc(i,d,f);return tu(o,e,t,n,s,r)}function tu(e,t,n,s,r,i){const f=S.getTimePeriods(t).sort((o,c)=>S.sortPeriods(o,c));return e.map(o=>({...o,[st]:Kc(o,f,n,s,r,i)}))}function nu(e,t,n,s,r,i,d,f,o,c,l){return{columns:Tc(e,t,s,r,i,f,o,c,l),data:nn(t,e,n,s,d)}}function su(e,t,n,s,r,i,d,f,o,c,l){const m=e.dataflows?.[0]?.names?.[s],h=nu(e,t,n,s,r,i,d,f,o,c,l);return{title:m||f?.dataGrid||"Data Grid",grid_data:h}}function ru(e){const t=e.replace(/\r\n/g,`
|
|
7
7
|
`);if(!t.startsWith("```"))return{code:e};const n=t.split(`
|
|
8
8
|
`),r=n[0].slice(3).trim()||void 0;let i=-1;for(let d=n.length-1;d>0;d--)if(n[d].trim()==="```"){i=d;break}return i===-1?{code:n.slice(1).join(`
|
|
9
9
|
`),language:r}:{code:n.slice(1,i).join(`
|
|
10
|
-
`),language:r}}const ru=["python"];function au(e,t,n){return e.filter(s=>s.type===ee.AttachmentType.MARKDOWN).filter(s=>!t||s.title?.includes(t)).map(s=>{const r=su(s.data??"");return{title:n??"Code samples",type:ee.AttachmentType.CUSTOM_CODE_SAMPLE,language:r.language,data:r.code}}).filter(s=>ru.includes(s.language??""))}const iu="Data Grid",ou="Data",lu="Chart",cu=e=>({title:e||iu,type:ee.AttachmentType.CUSTOM_DATA_GRID}),uu=e=>({title:e||lu,type:ee.AttachmentType.CUSTOM_CHART}),du=e=>({title:e||ou,type:ee.AttachmentType.CROSS_DATASET_GRID});function va(e,t,n,s,r,i,d,f,o,c=!1){const[l,m]=u.useState(),[h,p]=u.useState(),[g,C]=u.useState(),[w,y]=u.useState(),[x,b]=u.useState(cu(d?.dataGrid)),[D,E]=u.useState(uu(d?.chart)),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState([]),[j,_]=u.useState(!1),[F,B]=u.useState({startPeriod:null,endPeriod:null}),{getConstraints:V,getDataSet:z,getDataSetData:Z,putOnboardingFile:ie}=e,K=u.useCallback(H=>{if(!H)return;const ne=S.getDimensions(H);p(H.dataflows?.[0]||void 0),y(H||void 0),I([...ne?.dimensions||[],...ne?.timeDimensions||[]])},[]),q=u.useCallback(async H=>{const ne=S.getFiltersDtoFromDataQuery(H);try{const oe=(await Ve(V,_e(H.urn,ne),()=>V(H.urn,ne)))?.data?.dataConstraints||[];C(oe)}catch{C([])}},[V]),Y=u.useCallback(async H=>{const ne=o?{data:o}:await Ve(z,_e(H.urn),()=>z(H.urn));if(ne?.data){const se=S.getDimensions(ne.data);K(ne.data);const oe=se?.dimensions==null?null:S.getTimeSeriesFilterKey(se?.dimensions,H.filters),he=Tr(H,se);Ve(Z,_e(H.urn,{filterKey:oe,timeFilter:he}),()=>Z(H.urn,{filterKey:oe,timeFilter:he})).then(Ce=>{m(Ce||void 0),M(S.getStructureDimensions(Ce))}).finally(()=>_(!1))}},[K,z,Z,o]);u.useEffect(()=>{K(o)},[K,o]),u.useEffect(()=>{async function H(ne){_(!0);try{await Promise.all([q(ne),Y(ne)])}catch(se){console.error("Error loading dataset details",se)}}n!=null&&!(c&&!o)?H(n):n!=null&&c&&_(!0)},[n,o,c,q,Y]);const ce=u.useCallback((H,ne,se)=>{try{_(!0),C(ne);const oe=se?.find(he=>he.id===S.TIME_PERIOD)?.timeRange;oe&&B(oe),Ve(Z,_e(n?.urn||"",H),()=>Z(n?.urn||"",H)).then(he=>{m(he||void 0),M(S.getStructureDimensions(he))}).finally(()=>_(!1))}catch(oe){console.error("Error loading dataset data",oe)}},[n,Z]);u.useEffect(()=>{w!=null&&l!=null&&g?.length&&b(H=>({...H,...nu(w,l,n,t,s,i,r,d,ie,g,F)}))},[w,l,d,t,s,n,i,r,g,F,ie]),u.useEffect(()=>{w!=null&&l!=null&&E(H=>({...H,charting_data:Yc(w,l,n,t,r)}))},[w,l,n,t,r]),u.useEffect(()=>{f?.length&&A(au(f,n?.urn,d?.codeSamples))},[f,d,n]);const me=u.useMemo(()=>[x,D,...T],[x,D,T]);return{dataMessage:l,structures:w,dataset:h,dimensions:N,structureDimensions:k,onFiltersChange:ce,constraints:g,isLoadingGridData:j,dataSetAttachments:me}}const fu=async(e,t)=>{const n=new Map,s=S.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async i=>({urn:i.urn,response:await t(i.urn,s?.get(i.urn))})))).forEach(i=>{i.status==="fulfilled"&&n.set(i.value.urn,i.value.response?.data?.dataConstraints||[])}),n},mu=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),hu=async(e,t,n,s)=>{const r=mu();return await Promise.allSettled(e.map(async i=>{const d=await t(i.urn);if(d?.data){const f=S.getDimensions(d.data);r.datasetsMap?.set(i?.urn,d?.data?.dataflows?.[0]),r.structuresMap?.set(i?.urn,d?.data),r.dimensionsMap?.set(i?.urn,[...f?.dimensions||[],...f?.timeDimensions||[]]);const o=f?.dimensions==null?null:S.getTimeSeriesFilterKey(f?.dimensions,i.filters),c=Tr(i,f);await gu(i,{filterKey:o,timeFilter:c},n).then(({dataMessage:l,structureDimensions:m})=>{r?.dataMessagesMap?.set(i.urn,l),r?.structureDimensionsMap?.set(i.urn,m||[])}).catch(()=>{r?.structureDimensionsMap?.set(i.urn,[])}).finally(()=>s(!1))}})),r},gu=async(e,t,n)=>n(e.urn,t).then(s=>({dataMessage:s,structureDimensions:S.getStructureDimensions(s)})),pu="Dataset",Os="dataset_name",wu="Agency",Rs="agency",vu="Country dimensions",Cu="country_aggregated",bu="Indicator dimensions",xu="indicator_aggregated",Su="Frequency",yu="frequency_aggregated",Du=".";function Mu(e,t,n){return[Eu(e,n),ku(e,t,n)]}function ku(e,t,n){const s=r=>{const i=r.data?.dataset?.urn;if(i==null)return"";const f=e.get(i)?.dataflows?.[0];return S.getLocalizedName(f,t)||""};return{headerName:n?.dataset||pu,field:Os,colId:Os,valueGetter:s,...Ke,tooltipValueGetter:r=>r.value}}function Eu(e,t){const n=s=>{const r=s.data?.dataset?.urn;return r==null?"":e.get(r)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||wu,field:Rs,colId:Rs,valueGetter:n,...Ke,tooltipValueGetter:s=>s.value}}function Tu(e,t,n,s){return[Au(e,t,n,s),Nu(e,t,n,s),ju(e,t,n,s)]}function Au(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.region;return o==null||f==null||d==null||c==null?"":an(d,c,o,n)};return sn(s?.countryDimensions||vu,Cu,r)}function Nu(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.indicators;return o==null||f==null||d==null||c==null||c.length===0?"":c.map(m=>an(d,m,o,n)||"").join(Du)};return sn(s?.indicatorDimensions||bu,xu,r)}function ju(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.frequency;return o==null||f==null||d==null||c==null?"":an(d,c,o,n)};return sn(s?.frequency||Su,yu,r)}function sn(e,t,n){return{headerName:e,field:t,colId:t,valueGetter:n,...Ke,tooltipValueGetter:s=>s.value}}function rn(e,t){const{data:n}=e,s=n?.dataset?.urn,r=s==null?void 0:t.get(s);return{data:n,urn:s,structures:r}}function an(e,t,n,s){const r=e.conceptSchemes||[],i=e.codelists||[],d=S.getDimensions(e)?.dimensions||[],f=d.find(c=>c.id===t);if(f==null)return;const{codeList:o}=Mt(f,r,i);return tn(d,t,o,n,s)}function Iu(e,t,n){return Lu(e).sort((i,d)=>S.sortPeriods(i,d)).map(i=>({...Ou(i,t,n),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:St,cellRenderer:yt,width:Ze,cellRendererParams:{titles:n}}))}function Lu(e){const t=new Set;return e.forEach(n=>{if(n==null)return;S.getTimePeriods(n).forEach(r=>t.add(r))}),Array.from(t)}function Ou(e,t=J.defaultFormatNumbers,n){return{headerName:mr(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Ze,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>J.formatNumberBySign(s.value,t)}}function Ru(e,t,n,s,r,i){const d=Mu(e,s,r),f=Tu(e,t,s,r),o=Iu(n,i,r);return[...d,...f,...o]}function Fu(e,t,n,s,r){const i=[];return n.forEach(d=>{const f=d.urn,o=t.get(f),c=e.get(f);if(o==null||c==null)return;const l=nn(o,c,d,s,r);i.push(...l.map(m=>({...m,dataset:{urn:f}})))}),i}function Pu(e,t,n,s,r,i,d,f,o,c,l){const m=_u(e,t,n,s,r,i,d,f,o);return{title:o?.dataGrid||"Data",gridContent:m}}function _u(e,t,n,s,r,i,d,f,o,c,l){return{columns:Ru(e,n,t,r,o,i),data:Fu(e,t,s,r,f)}}function Ca(e,t,n,s,r,i){const d=Zt(),[f,o]=u.useState(),[c,l]=u.useState(),[m,h]=u.useState(),[p,g]=u.useState(),[C,w]=u.useState(),[y,x]=u.useState(),[b,D]=u.useState(),[E,T]=u.useState(!1),[A,N]=u.useState(du(d?.dataGrid)),I=u.useCallback(async _=>{try{const F=await fu(_,e.getConstraints);h(F)}catch{h(new Map)}},[e,h]),k=u.useCallback(async _=>{const F=await hu(_,e.getDataSet,e.getDataSetData,T);l(F?.datasetsMap),g(F?.structuresMap),w(F?.dimensionsMap),o(F?.dataMessagesMap),x(F?.structureDimensionsMap)},[e]),{getDimensionsScheme:M}=Sa(),j=u.useCallback(_=>{const F=new Map;for(const B of _)F.set(B.urn,M(B.urn));D(F)},[M]);return u.useEffect(()=>{async function _(F){T(!0);try{j(F),await Promise.all([I(F),k(F)])}catch(B){console.error("Error loading dataset details",B)}finally{T(!1)}}n?.length&&_(n)},[n,I,j,k]),u.useEffect(()=>{p!=null&&p.size>0&&f!=null&&m!=null&&b!=null&&!E&&N(_=>({..._,...Pu(p,f,b,n||[],t,r,i,s,d)}))},[p,f,m,n,t,r,i,s,d,b,E]),{dataMessagesMap:f,structuresMap:p,datasetsMap:c,dimensionsMap:C,structureDimensionsMap:y,constraintsMap:m,datasetDimensionsSchemesMap:b,isLoadingGridData:E,crossDatasetGridAttachment:A}}function Vu({api:e,searchQuery:t,includeColumn:n=Sl}){const[s,r]=u.useState(0),i=u.useCallback(()=>{r(h=>h+1)},[]);la(e,i);const d=u.useMemo(()=>e?kl(e,n):[],[e,n,s]),f=u.useMemo(()=>v.filterDraggableListNodes(d,t),[d,t]),o=u.useCallback(h=>{if(!e)return;const p=Es(d,h.path);p&&(e.applyColumnState({state:[{colId:p.id,hide:!h.nextChecked}]}),i())},[e,d,i]),c=u.useCallback(h=>{if(!e)return;const p=Es(d,h.path);if(!p)return;const C=!(e.getColumnState().find(w=>w.colId===p.id)?.hide??!1);e.applyColumnState({state:[{colId:p.id,hide:C}]}),i()},[e,d,i]),l=u.useCallback(h=>{},[]),m=u.useCallback(h=>{if(!e)return;const p=e.getColumnState().map(y=>y.colId),g=new Set(d.map(y=>y.id)),C=Ft(h),w=El(p,C,g);e.applyColumnState({state:w.map(y=>({colId:y})),applyOrder:!0}),i()},[e,d,i]);return{items:d,visibleItems:f,handleToggleChecked:o,handleToggleExpanded:l,handleItemClick:c,handleItemsChange:m}}function Gu({api:e,includeColumn:t}){const[n,s]=u.useState(""),r=u.useCallback(h=>{s(h)},[s]),i=u.useCallback(()=>s(""),[s]),d=u.useMemo(()=>a.jsx("button",{type:"button",onClick:i,children:a.jsx(ke.IconX,{className:"text-neutrals-1000 size-4"})}),[i]),{visibleItems:f,handleItemsChange:o,handleToggleChecked:c,handleToggleExpanded:l,handleItemClick:m}=Vu({api:e,includeColumn:t,searchQuery:n});return a.jsxs("div",{className:"px-5 py-7 flex flex-col gap-2 flex-1 min-h-0",children:[a.jsx(v.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:"Search",iconBeforeInput:a.jsx(ke.IconSearch,{className:"text-neutrals-1000 size-4"}),iconAfterInput:n?d:void 0,value:n,onChange:r}),a.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:a.jsx(v.DraggableList,{items:f,onItemsChange:o,onToggleChecked:c,onToggleExpanded:l,onItemClick:m})})]})}const Bu=({onClose:e,gridApi:t,initialColumnsState:n,title:s,resetTitle:r})=>{const i=u.useCallback(()=>{t&&Tl(t,n)},[t,n]),d=u.useCallback(()=>{e?.()},[e]);return a.jsxs("div",{className:"h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex justify-between border-b border-neutrals-500 px-5 py-6",children:[a.jsx("div",{className:"h2 text-neutrals-1000",children:s||"Columns"}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("button",{type:"button",className:"text-neutrals-800 flex gap-1 items-center",onClick:i,children:[a.jsx(ke.IconRotate,{className:"rotate-180 size-4"})," ",a.jsx("span",{className:"h4",children:r||"Reset"})]}),a.jsx("div",{className:"h-3 w-[1px] bg-neutrals-600"}),a.jsx("button",{type:"button",onClick:d,children:a.jsx(ke.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),t&&a.jsx(Gu,{api:t})]})},Hu=({attachmentsProps:e,...t})=>{const n=u.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]);return a.jsx(Nl,{currentUrn:n,children:a.jsx(Uu,{attachmentsProps:e,...t})})},Uu=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:r,formattingSettings:i,locale:d,advanceViewStyles:f,getDatasetUpdatedTime:o,attachmentsConfig:c,datasetInfoOptions:l,...m})=>{const h=m.filtersProps.conversation?.messages?.at(-1)?.custom_content?.attachments,{isCrossDatasetModeOn:p}=Xt(),{tableSettings:{isOpen:g,close:C},agGrid:{gridApi:w,initialColumnsState:y}}=ua(),{dataMessage:x,dataset:b,dimensions:D,structureDimensions:E,structures:T,dataSetAttachments:A,onFiltersChange:N,isLoadingGridData:I,constraints:k}=va(t,d,e.currentDataQuery,i,e.styles?.chartingStyles,r,n,h),{dimensionsMap:M,structuresMap:j,structureDimensionsMap:_,constraintsMap:F,crossDatasetGridAttachment:B,isLoadingGridData:V}=Ca(t,d,e.dataQueries,e.styles?.chartingStyles,i,r),[z,Z]=u.useState(),[ie,K]=u.useState({filterKey:null,timeFilter:null}),q=u.useMemo(()=>p?V:I,[p,V,I]),Y=u.useCallback((H,ne,se)=>{K(H),Z(!0),N(H,ne,se)},[N]),ce=u.useCallback(H=>{H&&t?.updateCurrentDataQuery(e?.dataQueries?.find(ne=>ne?.urn===H)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),me=Wr(c?.isExternaLinkIncludeFilters,ie,e.currentDataQuery||e.dataQueries?.[0],D);return a.jsxs("div",{className:"advanced-view flex flex-col flex-1 h-full min-w-0",children:[a.jsx(kc,{titles:n,locale:d,shareConversationProps:s,isShowShare:f?.isShowShare}),e?.datasets?.length?a.jsxs(a.Fragment,{children:[e?.datasets?.length>1&&a.jsx(Ur,{datasets:e?.datasets,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:d,isHideAdvancedViewButton:!0,selectDataset:ce}),q&&!z?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[a.jsx(Mc,{...l,titles:n,locale:d,dataset:b,data:x?.data,structures:T,metadataSettings:r,getDatasetUpdatedTime:o,externalLink:me}),a.jsxs("div",{className:"flex flex-1 min-h-0 overflow-auto border-t border-neutrals-500",children:[a.jsx("div",{className:P("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:a.jsx(Ol,{...m,titles:n,actions:t,attachments:p?[B]:A,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:D,attachmentsStyles:e.styles,isDataLoading:q,locale:d,filtersProps:{...m?.filtersProps,structureDimensions:E,structures:T,structureDataMaps:{dimensionsMap:M,structuresMap:j,structureDimensionsMap:_,constraintsMap:F},onFiltersChange:N,initialConstraints:k},setIsFiltering:Z,attachmentsConfig:c,filters:ie,onFiltersChange:Y})}),g&&a.jsx(Bu,{onClose:C,gridApi:w,initialColumnsState:y,title:e.styles?.columnsTitle,resetTitle:e.styles?.columnsResetTitle})]})]})]}):a.jsx(v.Loader,{})]})};function Wu(e,t,n,s,r){const[i,d]=u.useState([]),[f,o]=u.useState(),[c,l]=u.useState(!1);return u.useEffect(()=>{let m=!0;async function h(p){l(!0);try{const g=await Promise.all(p.map(w=>Ve(e,_e(w.urn),()=>e(w.urn))));if(!m)return;const C=g?.map(w=>w?.data?.dataflows?.[0])?.filter(w=>!!w)||[];d(C),t(C),n(p),s(p[0]),o(new Map(g?.map(w=>[S.generateShortUrn(w?.data?.dataflows?.[0]?.id,w?.data?.dataflows?.[0]?.version,w?.data?.dataflows?.[0]?.agencyID),w?.data])))}catch(g){console.error("Error loading datasets",g)}finally{m&&l(!1)}}if(!r?.length){l(!1);return}return h(r),()=>{m=!1}},[r,e,s,n,t]),{datasets:i,datasetStructuresMap:f,isLoading:c}}function Fs(e){const t=e?.filter(n=>Fr(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...$u(zu(n?.data))}))}function zu(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function $u(e){return{...e,filters:e?.filters?.map(t=>({...t,componentCode:t?.component_code||t?.componentCode})),metadata:{datasetUrl:e?.metadata?.datasetUrl,countryDimension:e?.metadata?.country_dimension||e?.metadata?.countryDimension,indicatorDimensions:e?.metadata?.indicator_dimensions||e?.metadata?.indicatorDimensions}}}var ba=(e=>(e.COMPLETED="completed",e))(ba||{});const Ju=({stage:e,stageRef:t,isCurrentStage:n})=>a.jsxs("div",{ref:t,className:"message-stage flex relative pb-8 last:pb-0 last:mb-8",children:[a.jsx("span",{className:"message-stage-line absolute border-l h-full"}),a.jsx(ke.IconPointFilled,{className:"message-stage-indicator flex shrink-0 z-10"}),a.jsxs("div",{className:"ml-2 w-full",children:[a.jsxs("div",{className:P("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&a.jsx(v.Loader,{}),a.jsx("h3",{className:"message-stage-name",children:e?.name})]}),a.jsx("div",{className:"prose max-w-full break-words",children:a.jsx(_s,{remarkPlugins:[Vs],components:{strong:s=>a.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:r,...i})=>a.jsx("a",{href:s,target:"_blank",...i,children:r}),h1:s=>a.jsx("h1",{className:"h1 text-neutrals-1000",...s}),h2:s=>a.jsx("h2",{className:"h2 text-neutrals-1000",...s}),h3:s=>a.jsx("h3",{className:"h3 text-neutrals-1000",...s}),h4:s=>a.jsx("h4",{className:"h4 text-neutrals-1000",...s}),h5:s=>a.jsx("h5",{className:"h5 text-neutrals-1000",...s}),code:s=>a.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>a.jsx("pre",{className:"bg-neutrals-100 border border-neutrals-600",...s})},children:e?.content})})]})]}),Yu=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,r]=u.useState(),[i,d]=u.useState(),f=u.useRef(null),o=u.useRef(null);u.useEffect(()=>{d(e?.filter(l=>l?.status!==ba.COMPLETED)?.at(-1))},[e]),u.useEffect(()=>{s&&o?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),u.useEffect(()=>{const l=f.current;let m;if(!l)return;const h=new IntersectionObserver(([p])=>{const g=p?.boundingClientRect?.top;m&&!p?.isIntersecting&&g<m&&r(!1),m=g},{threshold:0});return h.observe(l),()=>h.disconnect()},[]);const c=()=>{r(l=>!l)};return a.jsxs("div",{className:"message-stages",ref:f,children:[a.jsxs("div",{className:P("message-stages-header inline-flex max-w-full items-center cursor-pointer",!i?.name&&"default-header"),onClick:c,children:[a.jsx("p",{className:"message-stages-title truncate",children:i?.name||n||"Processing..."}),a.jsx("i",{className:P("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&a.jsx("div",{className:"flex flex-col",children:e?.map(l=>a.jsx(Ju,{stage:l,stageRef:i?o:null,isCurrentStage:l?.index===i?.index},l.index))})]})},qu=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:r=!1,isReadOnly:i=!1,isRegenerateAvailable:d=!1})=>{const f=n?.copy,o=n?.regenerate,c=n?.thumbUp,l=n?.thumbDown,m=n?.thumbPressed,[h,p]=u.useState(e.like??de.LikeState.NoState),{isAgentAvailable:g}=v.useAgentAvailability(),C=w=>{e.responseId&&(p(w),s(e.responseId||"",w))};return a.jsxs("div",{className:P("message-actions","flex gap-x-2 pt-2"),children:[f&&a.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:f}),d&&o&&!i&&!r&&a.jsx("p",{onClick:g?()=>t?.(e):void 0,"aria-disabled":!g,className:P(!g&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:o}),c&&!i&&h!==de.LikeState.Disliked&&(h===de.LikeState.NoState?a.jsx("p",{onClick:()=>C(de.LikeState.Liked),children:c}):a.jsx("p",{children:m})),l&&!i&&h!==de.LikeState.Liked&&(h===de.LikeState.NoState?a.jsx("p",{onClick:()=>C(de.LikeState.Disliked),children:l}):a.jsx("p",{className:"rotate-180",children:m}))]})},Ku=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:r=!1})=>{const i=n?.copy,d=n?.edit,{isAgentAvailable:f}=v.useAgentAvailability();return a.jsxs("div",{className:P("message-actions","flex gap-x-2 pt-2 ml-12"),children:[i&&a.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:i}),d&&!s&&!r&&a.jsx("p",{onClick:f?t:void 0,className:P(!f&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!f,children:d})]})},Zu=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:r})=>{const{isOpenedAdvancedView:i}=Be(),d=u.useRef(null);u.useEffect(()=>{const o=d.current;f(),o&&(o.focus(),o.setSelectionRange(o.value.length,o.value.length))},[]);const f=()=>{const o=d.current;o&&(o.style.height="auto",o.style.height=o.scrollHeight+"px")};return a.jsxs("div",{className:P("max-w-none break-words",i?"body-2":"body-1",t),children:[a.jsx("textarea",{ref:d,className:"resize-none overflow-hidden outline-none bg-neutrals-300 w-full",defaultValue:e,onInput:f}),a.jsxs("div",{className:P("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[a.jsx(v.Button,{buttonClassName:"text-button-secondary small-icon-button",title:r?.cancel,isSmallButton:!0,onClick:n}),a.jsx(v.Button,{buttonClassName:"text-button-primary small-icon-button",title:r?.send,isSmallButton:!0,onClick:()=>s(d.current?.value||"")})]})]})},Xu=({message:e,previousMessage:t,titles:n,actions:s,dataQuery:r,isStreaming:i=!1,isCurrentMessageStreaming:d=!1,messageStyles:f,attachmentsStyles:o,showAdvancedView:c,formattingSettings:l,locale:m,metadataSettings:h,expandStagesIcon:p,onAdvancedViewOpen:g,regenerateMessage:C,selectMessageToSend:w,messageActionsIcons:y,rateResponse:x,editMessage:b,editMessageTitles:D,isReadOnlyConversation:E,isLastNotUserMessage:T,limitMessages:A,attachmentsConfig:N})=>{const[I,k]=u.useState(),[M,j]=u.useState(),[_,F]=u.useState([]),[B,V]=u.useState([]),[z,Z]=u.useState(),[ie,K]=u.useState(!1),{isCrossDatasetModeOn:q}=Xt(),Y=e.role===de.Role.User,ce=e.role===de.Role.System,{datasets:me,datasetStructuresMap:H,isLoading:ne}=Wu(s.getDataSet,s.updateDatasets,s.updateDataQueries,s.updateCurrentDataQuery,I),[se,oe]=u.useState(!1),[he,Ce]=u.useState([]);u.useEffect(()=>{j(I?.[0])},[I]);const{dataSetAttachments:ve,dimensions:we,isLoadingGridData:Se}=va(s,m,M,l,o?.chartingStyles,h,n,e.custom_content?.attachments,M?H?.get(M.urn):void 0,ne),{crossDatasetGridAttachment:Ee,isLoadingGridData:ye}=Ca(s,m,I,o?.chartingStyles,l,h),{isOpenedAdvancedView:De}=Be(),je=u.useMemo(()=>q?ye:Se,[q,ye,Se]),Le=()=>{Y&&oe(!0)},W=()=>{oe(!1)},R=re=>{W(),b?.({...e,content:re})},G=u.useCallback(re=>{re&&(j(I?.find(fe=>fe?.urn===re)),Z(void 0))},[I]);u.useEffect(()=>{const re=e.custom_content?.form_schema?.properties,fe=T?re?.choice?.oneOf||re?.completion?.oneOf:[];Ce(fe||[])},[e,T]),u.useEffect(()=>{const re=xs(e),fe=Fs(re),Me=re.filter(Oe=>zt(Oe));k(fe),V(Me)},[e]),u.useEffect(()=>{K(I!=null&&I.length>0)},[I]),u.useEffect(()=>{r&&r.urn&&Z(r.urn)},[r]),u.useEffect(()=>{if(e?.role===de.Role.System&&t){const re=xs(t),fe=Fs(re)||[];I&&fe&&H&&F(yo(fe,I,H,m))}},[I,M,H,we,m,e?.role,t]);const $=u.useCallback(()=>!Y&&f?.systemMessageIcon&&!(De&&!d)?a.jsx("div",{className:P("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",d?"text-white absolute":"text-neutrals-400"),children:f.systemMessageIcon}):null,[Y,f?.systemMessageIcon,De,d]),le=u.useMemo(()=>a.jsx(oa,{actions:s,titles:n,attachments:ie?q?[Ee]:ve:B,onAdvancedViewOpen:g,isDataSetAttachments:ie,datasets:me,initialSelectedDatasetUrn:z,messageStyles:f,attachmentsStyles:o,showAdvancedView:c,isSystemAttachments:ce,isDataLoading:je,currentDataQuery:M,dataQueries:I,attachmentInfoList:_,locale:m,dimensions:we,selectDataset:G,limitMessages:A,attachmentsConfig:N}),[s,n,ie,ve,B,Ee,me,z,f,o,c,ce,je,M,I,_,m,we,G,g,A,N]);return a.jsx(a.Fragment,{children:!(ce&&De)&&a.jsx("div",{className:P("max-w-full flex",Y?"justify-end":"justify-start","message-wrapper"),children:a.jsxs("div",{className:P("flex items-start max-w-full",(ce||se)&&"w-full"),children:[a.jsxs("div",{className:"mr-2 relative",children:[$(),d&&a.jsx(v.Loader,{})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:P(Y?"bg-neutrals-300 px-6":"pt-0",Y?"user-message":"system-message",Y&&(se?"w-[100%] ml-0":"ml-12")),children:[!Y&&!De&&e?.custom_content?.stages?a.jsx(Yu,{stages:e?.custom_content?.stages,expandIcon:p,processingTitle:f?.processingTitle}):d&&a.jsx("p",{className:"body-1 text-neutrals-700 loading-message",children:n?.loading}),se?a.jsx(Zu,{content:e.content,onCancel:W,onEditApply:R,editMessageTitles:D}):a.jsx(lr,{content:e.content})]}),le,!d&&(Y?!se&&a.jsx(Ku,{messageActionsIcons:y,message:e,isStreaming:i,onEditClick:Le,isReadOnly:E}):a.jsx(qu,{messageActionsIcons:y,message:e,isStreaming:i,regenerateMessage:C,rateResponse:x,isReadOnly:E,isRegenerateAvailable:T})),!De&&!je&&a.jsx(cr,{choiceButtons:he,onClick:w})]})]})})})},Qu=({messages:e,isStreaming:t=!1,isReadOnly:n,scrollBottomIcon:s,conversationViewState:r,...i})=>{const d=u.useRef(null),f=u.useRef(null),{isOpenedAdvancedView:o}=Be(),[c,l]=u.useState(null),[m,h]=u.useState(!1),p=()=>{const x=f.current?.parentElement,b=d.current;if(x&&b){const D=b.offsetTop-x.offsetTop;x.scrollTo({top:D,behavior:"smooth"})}};u.useEffect(()=>{p()},[e,t]),u.useEffect(()=>{!o&&c!==null&&setTimeout(()=>{f?.current?.parentElement?.scrollTo({top:c,behavior:"smooth"})})},[o,c]);const g=()=>{const x=f.current?.parentElement?.scrollTop||null;l(x)},C=()=>{const x=f.current?.parentElement;if(x){const{scrollTop:b,scrollHeight:D,clientHeight:E}=x;b+E>=D?h(!1):!m&&!o&&h(!0)}};u.useEffect(()=>{o&&h(!1)},[o]);const w=v.useDebounce(C,300);u.useEffect(()=>{const x=f.current?.parentElement;return x?.addEventListener("scroll",w),()=>x?.removeEventListener("scroll",w)},[w]);const y=u.useCallback(x=>{const b=J.linkifyText(x);return a.jsx("div",{className:"whitespace-pre-wrap break-words",children:b.map((D,E)=>D.type==="text"?a.jsx(u.Fragment,{children:D.value},E):a.jsx("a",{href:D.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:a.jsx(ke.IconExternalLink,{className:"text-primary cursor-pointer w-4 h-4 shrink-0"})},E))})},[]);return a.jsxs("div",{ref:f,className:"h-full w-full flex justify-center",children:[a.jsxs("div",{className:"flex flex-col gap-y-6 max-w-full chat-messages-wrapper",children:[e.map((x,b)=>{const D=x.id??b;if(x.errorMessage){const N=r?.errorContext?.kind===ee.ERROR_CONTEXT_KIND.RATE_LIMIT?v.InlineAlertType.Warning:v.InlineAlertType.Error;return a.jsx(v.InlineAlert,{type:N,children:a.jsx("div",{className:"flex flex-col",children:y(x.errorMessage)})},D)}const E=b===e.length-1,T=ro(e,b),A=ao(e);return a.jsx(Xu,{message:x,previousMessage:T,onAdvancedViewOpen:g,isStreaming:t,isCurrentMessageStreaming:t&&E&&x.role===de.Role.Assistant,showAdvancedView:b===A&&!n,isLastNotUserMessage:E&&x.role!==de.Role.User,...i},D)}),a.jsx("div",{ref:d,className:"h-4"})]}),a.jsx("div",{onClick:p,className:P("fixed right-10 lg:right-6 sm:hidden bottom-[88px] rounded-[50%] border-[2px] w-[40px] h-[40px] border-primary cursor-pointer text-primary bg-white","scroll-button-wrapper",m?"block":"hidden"),children:a.jsx("div",{className:"flex justify-center items-center w-full h-full",children:s})})]})},ed=e=>{const t={};return e.choices?.[0]?.delta?.content&&(t.content=e.choices[0].delta.content),e.choices?.[0]?.delta?.custom_content&&(t.custom_content=e.choices[0].delta.custom_content),e.choices?.[0]?.delta?.role&&(t.role=e.choices[0].delta.role),e.id&&(t.responseId=e.id),t},td="local",nd=e=>!e.permissions?.includes(de.SharePermission.WRITE)&&!rd(e),sd=(e,t)=>xa(e)!==t,rd=e=>xa(e)===td,xa=e=>e.id.split("/")[0],ad=(e,t)=>on([...t?.messages||[],e]),on=e=>[...e].map(t=>{const n={role:t.role,content:t.content};return(t.role===de.Role.Assistant||t.role===de.Role.System)&&t.custom_content!=null&&(t.custom_content.state!=null||t.custom_content.attachments!=null||t.custom_content.form_schema!=null)&&(n.custom_content={},t.custom_content.state!=null&&(n.custom_content.state=t.custom_content.state),t.custom_content.attachments!=null&&(n.custom_content.attachments=ld(t.custom_content.attachments)),t.custom_content.form_schema!=null&&(n.custom_content.form_schema=t.custom_content.form_schema)),t.role===de.Role.User&&t.custom_content&&(n.custom_content=t.custom_content),n}),id=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return on(n?.slice(0,s)||[])},od=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return on([...n?.slice(0,s)||[],e])};function ld(e){return e.map(t=>({type:t.type,title:t.title,data:t.data,url:t.url,reference_type:t.reference_type,reference_url:t.reference_url}))}const cd=(e,t,n,s)=>{if(!n||t)return null;const r={id:`msg-${Date.now()}`,role:de.Role.User,content:e,timestamp:Date.now()};if(s){const i=s===bt.COMPLETE?ft.COMPLETION:ft.CHOICE;r.custom_content={form_value:{[i]:s}}}return r},ud=(e,t,n)=>`/${t}${n}/${J.getConversationNavPath(e?.folderId,e?.id)}`,dd=(e,t,n)=>{const s=`${t}/${n}`,r=ee.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:r}},fd=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},md=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const r=s.at(-1)??"file",i=fd(r,n);return["files",t,...s.slice(2,-1),i].join("/")},hd=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const r=J.getConversationAttachmentUrls(e),i=Date.now();if(!r.length)return e;const d=await Promise.all(r.map(async f=>{const o=md(f,t,`${i}`);if(o===f)return[f,o];const c=await n(f);return await s(o,c),[f,o]}));return J.replaceConversationAttachmentUrls(e,Object.fromEntries(d))},gd="AbortError",pd=({error:e,statusMessages:t})=>{if(e){if(e.type===ee.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e.exceeded_limit?.length?t.getExceededLimitsMessage(e.exceeded_limit):e.display_message??"";throw new J.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??J.HTTP_ERROR_CODES.TOO_MANY_REQUESTS,details:{kind:ee.ERROR_CONTEXT_KIND.RATE_LIMIT,occurredAt:new Date().toISOString(),retryAfterSeconds:Number(e.retry_after??"")}})}throw new J.HttpError({message:e.message,status:e.status??J.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},wd=({error:e,statusMessages:t})=>{if(e.code===ee.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e;return{errorMessage:n.displayMessage??n.message,errorContext:n.details}}return e.code===ee.DIAL_ERROR_CODES.CONTENT_FILTER?{errorMessage:t.contentFilterError??e.message}:{errorMessage:e.status===J.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},Ps=(e,t)=>{const n=e.customViewState??{},s=n[ee.CUSTOM_VIEW_STATE_KEY]??{};return{...e,customViewState:{...n,[ee.CUSTOM_VIEW_STATE_KEY]:{...s,errorContext:t}}}},vd=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:r,inputMessageStyles:i,shareConversationProps:d,showConversationHeaderAdvancedView:f=!0,formattingSettings:o,metadataSettings:c,expandStagesIcon:l,locale:m,conversationsRoute:h,token:p,titles:g,dataQuery:C,handleInvalidStreaming:w,setConversation:y,setConversations:x,openUrl:b,messageActionsIcons:D,editMessageTitles:E,scrollBottomIcon:T,isFinalMessage:A,limitMessages:N,attachmentsConfig:I})=>{const[k,M]=u.useState(null),[j,_]=u.useState(!1),[F,B]=u.useState(!0),{isStreaming:V,setIsStreaming:z}=Us(),{isOpenedAdvancedView:Z}=Be(),{isAgentAvailable:ie}=v.useAgentAvailability(),{statusMessages:K}=Vt(),{onboardingFileSchema:q,onboardingFilePath:Y,onboardingFileName:ce,isShowOnboarding:me,setOnboardingFileSchema:H}=Ne();u.useEffect(()=>{q&&n.putOnboardingFile?.(ce,Y,q)},[n,q,ce,Y]),u.useEffect(()=>{Z&&q?.lastDisplayedElement===pe.OPEN_ADVANCED_VIEW&&H?.(Or(q))},[n,Z,H,q]);const ne=u.useCallback(()=>{b(`/${m}${h}`)},[m,h,b]),se=u.useCallback(async()=>{try{const{bucket:L}=await n.getBucket(),O=n.getFileBlob&&n.putFile?await hd({conversation:t,bucket:L,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,U=dd(O,L,m);await n.createConversation(U,m);const te=await n.getConversations(m);x(J.cleanConversationNames(te)),b(ud(U,m,h))}catch(L){console.error("Failed to save conversation:",L)}},[n,t,h,m,b,x]),oe=u.useCallback(async L=>{try{await n.updateConversation(decodeURI(e),{name:L.name,messages:L.messages,customViewState:L.customViewState})}catch(O){console.error("Failed to save conversation:",O)}},[n,e]),he=u.useCallback(L=>{y(O=>O?{...O,messages:[...O?.messages||[],L]}:null)},[y]),Ce=u.useCallback(()=>{const L={id:`msg-${Date.now()+1}`,role:de.Role.Assistant,content:"",timestamp:Date.now()};return y(O=>O?{...O,messages:[...O.messages,L]}:null),L},[y]),ve=u.useCallback((L,O)=>{const U=ee.mergeMessages?.(L,[O]);if(U)return y(te=>te?{...te,messages:te.messages.map(X=>X.id===L.id?{...U}:X)}:null),U},[y]),we=u.useCallback((L,O)=>{t?.model?.id&&(n.rateResponse(L,O===de.LikeState.Liked,t.model.id),t.messages=t.messages.map(U=>U.responseId===L?Pt.merge(U,{like:O}):U),oe(t))},[n,t,oe]),Se=u.useCallback((L,O)=>{let U=K.serverError,te,X;if(J.isHttpError(L)){X=L;const be=wd({error:L,statusMessages:K});U=be.errorMessage,te=be.errorContext}else X=new J.HttpError({status:J.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:U});return O&&(O=ve(O,{errorMessage:U})),w?.(X),{assistantMessage:O,errorContext:te}},[w,K.serverError,K.serverOverloaded,K.contentFilterError,ve]),Ee=u.useCallback(async(L,O,U)=>{const te=new AbortController;M(te);let X=L,be;return U?(await ee.streamChatResponse?.(encodeURI(U.id),O,{model:U.model,signal:te?.signal,onMessage:xe=>{pd({error:xe.error,statusMessages:K});const Re=ed(xe);(Re.content||Re.role||Re.responseId)&&(X=ve(X,Re))},onError:xe=>{if(!W(xe))throw console.error("Streaming error:",xe),xe}},p,U?.custom_fields).catch(xe=>{const{assistantMessage:Re,errorContext:We}=Se(xe,X);X=Re,be=We}),{assistantMessage:X,errorContext:be}):{assistantMessage:X,errorContext:be}},[p,ve,Se,K]),ye=u.useCallback(async(L,O,U,te)=>{if(!O)return;let X=Ps(O,te);X={...X,messages:[...O.messages],updatedAt:Date.now()},U&&X.messages.push(U),X.messages.push(L),await oe(X)},[oe]),De=u.useCallback(L=>{y(O=>O&&Ps(O,L))},[y]),je=u.useCallback((L,O)=>{y(U=>U?{...U,messages:U.messages.filter(te=>te.id!==O.id)}:null)},[y]),Le=u.useCallback(()=>{k&&!k.signal.aborted&&k.abort()},[k]),W=L=>L?.name===gd,R=u.useCallback(async(L,O,U,te,X,be=!0)=>{W(X)?await ye(te??U,L,be?O:void 0):je(X,O)},[ye,je]),G=u.useCallback(async(L,O,U)=>{if(!O||!L)return;const te=cd(L,V,O,U);let X,be;if(te){he(te);try{z(!0),X=Ce();const xe=ad(te,O),{assistantMessage:Re,errorContext:We}=await Ee(X,xe,O);De(We),be=Re,await ye(be,O,te,We)}catch(xe){R(O,te,X,be,xe)}finally{z(!1)}}},[V,z,he,Ce,Ee,ye,R,De]),$=u.useCallback(async(L,O,U)=>{let te,X;try{z(!0),te=Ce();const{assistantMessage:be,errorContext:xe}=await Ee(te,L,O);X=be,De(xe),await ye(X,O,void 0,xe)}catch(be){R(O,U,te,X,be,!1)}finally{z(!1)}},[z,ye,R,Ee,Ce,De]),le=u.useCallback(async(L,O)=>{if(!O||!L)return;const U=id(L,O),te={...O,messages:O.messages.slice(0,U.length)};y(X=>X?{...X,...te}:null),$(U,te,L)},[y,$]),{isLastMessageFailed:re,regenerateLastMessage:fe}=u.useMemo(()=>{const L=t?.messages?.at(-1);return{isLastMessageFailed:!!L?.errorMessage,regenerateLastMessage:L&&(()=>le(L,t))}},[t,le]),Me=u.useCallback(async(L,O)=>{if(!O||!L)return;const U=od(L,O),te={...O,messages:[...O.messages.slice(0,U.length-1),L]};y(X=>X?{...X,...te}:null),$(U,te,L)},[y,$]);u.useEffect(()=>{Ss();async function L(){try{B(!0);const{bucket:O}=await n.getBucket(),U=await n.getConversation(decodeURI(e));y(U),_(nd(U)&&sd(U,O)),(U.messages.length===0||U?.messages?.[0]?.role===de.Role.Assistant&&U?.messages?.length===1)&&G(U.prompt,U)}catch{_(!0)}finally{B(!1)}}return e&&L(),()=>{Ss()}},[e]);const Oe=u.useMemo(()=>({getFile:n.getFile,putOnboardingFile:n.putOnboardingFile,getDataSet:n.getDataSet,getDataSetData:n.getDataSetData,getConstraints:n.getConstraints,updateCurrentDataQuery:n.updateCurrentDataQuery,updateDataQueries:n.updateDataQueries,updateDatasets:n.updateDatasets,downloadDataSet:n.downloadDataSet}),[n]);if(F)return a.jsx(v.Loader,{});const Ae=t?.customViewState?.[ee.CUSTOM_VIEW_STATE_KEY],at=()=>{if(Ae?.errorContext?.kind===ee.ERROR_CONTEXT_KIND.RATE_LIMIT&&ee.isRateLimitStillActive(Ae.errorContext)){const L=ee.getRateLimitRestoreDate(Ae.errorContext);if(L){const O=ee.formatDateTime(L);return a.jsx(v.InlineAlert,{type:v.InlineAlertType.Info,children:K.getAssistantRestoreMessage(O.date,O.time)})}}return ie?a.jsx(Js,{onSendMessage:L=>G(L,t),onStopStreaming:Le,inProcess:V,sendMessageIcon:i.sendMessageIcon,retryIcon:i.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:re,onRetryFailed:fe}):a.jsx(v.InlineAlert,{type:v.InlineAlertType.Error,children:K.assistantUnavailable})};return a.jsx(ia,{titles:g,children:a.jsxs("div",{className:P("h-full flex flex-col bg-white conversation-view-wrapper",Z&&!f?"p-4":"pr-2"),children:[Z&&!f?null:a.jsx(or,{conversation:t,locale:m,isOpenedAdvancedView:Z,isShowShareButton:!j&&!me,shareConversationProps:d}),a.jsx("div",{className:P("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:a.jsx(Qu,{messages:t?.messages||[],actions:Oe,isStreaming:V,isReadOnly:j,messageStyles:s,attachmentsStyles:r,formattingSettings:o,metadataSettings:c,expandStagesIcon:l,dataQuery:C,locale:m,titles:g,regenerateMessage:L=>le(L,t),selectMessageToSend:(L,O)=>G(L,t,O),messageActionsIcons:D,rateResponse:we,editMessage:L=>Me(L,t),editMessageTitles:E,scrollBottomIcon:T,isReadOnlyConversation:j||me,limitMessages:N,attachmentsConfig:I,conversationViewState:Ae})}),me?null:j?a.jsx("div",{className:"flex items-center justify-center mt-4",children:a.jsx(v.Button,{iconBefore:a.jsx(ke.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:se,buttonClassName:P("text-button-secondary")})}):a.jsx("div",{className:P(i.inputContainerClass),children:at()}),me&&A&&a.jsx(v.Button,{iconBefore:a.jsx(ke.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:ne,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"})]})})},ln=u.createContext(null);function Cd({map:e,children:t}){const n=u.useMemo(()=>{const s={},r={},i={},d=Object.keys(e);for(const f of d){s[f]={},r[f]={};const o=Object.keys(e[f]);for(const c of o){const l=e[f][c];l.subtype&&(s[f][l.subtype]=c),r[f][l.dimensionType]||(r[f][l.dimensionType]=[]),r[f][l.dimensionType].push(c)}i[f]={timePeriod:r[f]?.TIME_PERIOD?.[0]??void 0,frequency:s[f]?.FREQUENCY??void 0,region:s[f]?.REGION??void 0,indicators:r[f]?.INDICATOR??[],other:(r[f]?.NON_INDICATOR??[]).filter(c=>{const l=e[f][c];return l.subtype!=="FREQUENCY"&&l.subtype!=="REGION"})}}return{map:e,getDimensionsMetadata:f=>e[f],getDimensionMetadata:(f,o)=>e[f]?.[o],getRegionDimension:f=>s[f]?.REGION,getFrequencyDimension:f=>s[f]?.FREQUENCY,getIndicatorDimensions:f=>r[f]?.INDICATOR??[],getDimensionsScheme:f=>i[f]}},[e]);return a.jsx(ln.Provider,{value:n,children:t})}function Sa(){const e=u.useContext(ln);if(!e)throw new Error("useDatasetDimensionsMetadataMap must be used within DatasetDimensionsMetadataMapProvider");return e}function bd(){return u.useContext(ln)}exports.AdvancedView=Hu;exports.AdvancedViewProvider=La;exports.CUSTOM_CHOICE_ID=bt;exports.ChartingIcon=mt;exports.ChatFooter=dr;exports.ChatMessagesProvider=Oa;exports.ChatOnboardingFooter=ur;exports.ConversationView=vd;exports.ConversationViewMessagesProvider=Ra;exports.ConversationViewTitlesProvider=ia;exports.ConversationWelcome=si;exports.CustomContentProperties=ft;exports.DatasetDimensionsMetadataMapProvider=Cd;exports.OnboardingProvider=Fa;exports.STAGE_STATUS=$s;exports.useAdvancedView=Be;exports.useChatMessages=Us;exports.useConversationViewMessages=Vt;exports.useConversationViewTitles=Zt;exports.useDatasetDimensionsMetadataMap=Sa;exports.useDatasetDimensionsMetadataMapOptional=bd;exports.useOnboarding=Ne;
|
|
10
|
+
`),language:r}}const au=["python"];function iu(e,t,n){return e.filter(s=>s.type===ee.AttachmentType.MARKDOWN).filter(s=>!t||s.title?.includes(t)).map(s=>{const r=ru(s.data??"");return{title:n??"Code samples",type:ee.AttachmentType.CUSTOM_CODE_SAMPLE,language:r.language,data:r.code}}).filter(s=>au.includes(s.language??""))}const ou="Data Grid",lu="Data",cu="Chart",uu=e=>({title:e||ou,type:ee.AttachmentType.CUSTOM_DATA_GRID}),du=e=>({title:e||cu,type:ee.AttachmentType.CUSTOM_CHART}),fu=e=>({title:e||lu,type:ee.AttachmentType.CROSS_DATASET_GRID});function va(e,t,n,s,r,i,d,f,o,c=!1){const[l,m]=u.useState(),[h,p]=u.useState(),[g,C]=u.useState(),[w,y]=u.useState(),[x,b]=u.useState(uu(d?.dataGrid)),[D,E]=u.useState(du(d?.chart)),[T,A]=u.useState([]),[N,I]=u.useState([]),[k,M]=u.useState([]),[j,_]=u.useState(!1),[F,B]=u.useState({startPeriod:null,endPeriod:null}),{getConstraints:V,getDataSet:z,getDataSetData:Z,putOnboardingFile:ie}=e,K=u.useCallback(H=>{if(!H)return;const ne=S.getDimensions(H);p(H.dataflows?.[0]||void 0),y(H||void 0),I([...ne?.dimensions||[],...ne?.timeDimensions||[]])},[]),q=u.useCallback(async H=>{const ne=S.getFiltersDtoFromDataQuery(H);try{const oe=(await Ve(V,_e(H.urn,ne),()=>V(H.urn,ne)))?.data?.dataConstraints||[];C(oe)}catch{C([])}},[V]),Y=u.useCallback(async H=>{const ne=o?{data:o}:await Ve(z,_e(H.urn),()=>z(H.urn));if(ne?.data){const se=S.getDimensions(ne.data);K(ne.data);const oe=se?.dimensions==null?null:S.getTimeSeriesFilterKey(se?.dimensions,H.filters),he=Tr(H,se);Ve(Z,_e(H.urn,{filterKey:oe,timeFilter:he}),()=>Z(H.urn,{filterKey:oe,timeFilter:he})).then(Ce=>{m(Ce||void 0),M(S.getStructureDimensions(Ce))}).finally(()=>_(!1))}},[K,z,Z,o]);u.useEffect(()=>{K(o)},[K,o]),u.useEffect(()=>{async function H(ne){_(!0);try{await Promise.all([q(ne),Y(ne)])}catch(se){console.error("Error loading dataset details",se)}}n!=null&&!(c&&!o)?H(n):n!=null&&c&&_(!0)},[n,o,c,q,Y]);const ce=u.useCallback((H,ne,se)=>{try{_(!0),C(ne);const oe=se?.find(he=>he.id===S.TIME_PERIOD)?.timeRange;oe&&B(oe),Ve(Z,_e(n?.urn||"",H),()=>Z(n?.urn||"",H)).then(he=>{m(he||void 0),M(S.getStructureDimensions(he))}).finally(()=>_(!1))}catch(oe){console.error("Error loading dataset data",oe)}},[n,Z]);u.useEffect(()=>{w!=null&&l!=null&&g?.length&&b(H=>({...H,...su(w,l,n,t,s,i,r,d,ie,g,F)}))},[w,l,d,t,s,n,i,r,g,F,ie]),u.useEffect(()=>{w!=null&&l!=null&&E(H=>({...H,charting_data:qc(w,l,n,t,r)}))},[w,l,n,t,r]),u.useEffect(()=>{f?.length&&A(iu(f,n?.urn,d?.codeSamples))},[f,d,n]);const me=u.useMemo(()=>[x,D,...T],[x,D,T]);return{dataMessage:l,structures:w,dataset:h,dimensions:N,structureDimensions:k,onFiltersChange:ce,constraints:g,isLoadingGridData:j,dataSetAttachments:me}}const mu=async(e,t)=>{const n=new Map,s=S.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async i=>({urn:i.urn,response:await t(i.urn,s?.get(i.urn))})))).forEach(i=>{i.status==="fulfilled"&&n.set(i.value.urn,i.value.response?.data?.dataConstraints||[])}),n},hu=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),gu=async(e,t,n,s)=>{const r=hu();return await Promise.allSettled(e.map(async i=>{const d=await t(i.urn);if(d?.data){const f=S.getDimensions(d.data);r.datasetsMap?.set(i?.urn,d?.data?.dataflows?.[0]),r.structuresMap?.set(i?.urn,d?.data),r.dimensionsMap?.set(i?.urn,[...f?.dimensions||[],...f?.timeDimensions||[]]);const o=f?.dimensions==null?null:S.getTimeSeriesFilterKey(f?.dimensions,i.filters),c=Tr(i,f);await pu(i,{filterKey:o,timeFilter:c},n).then(({dataMessage:l,structureDimensions:m})=>{r?.dataMessagesMap?.set(i.urn,l),r?.structureDimensionsMap?.set(i.urn,m||[])}).catch(()=>{r?.structureDimensionsMap?.set(i.urn,[])}).finally(()=>s(!1))}})),r},pu=async(e,t,n)=>n(e.urn,t).then(s=>({dataMessage:s,structureDimensions:S.getStructureDimensions(s)})),wu="Dataset",Os="dataset_name",vu="Agency",Rs="agency",Cu="Country dimensions",bu="country_aggregated",xu="Indicator dimensions",Su="indicator_aggregated",yu="Frequency",Du="frequency_aggregated",Mu=".";function ku(e,t,n){return[Tu(e,n),Eu(e,t,n)]}function Eu(e,t,n){const s=r=>{const i=r.data?.dataset?.urn;if(i==null)return"";const f=e.get(i)?.dataflows?.[0];return S.getLocalizedName(f,t)||""};return{headerName:n?.dataset||wu,field:Os,colId:Os,valueGetter:s,...Ke,tooltipValueGetter:r=>r.value}}function Tu(e,t){const n=s=>{const r=s.data?.dataset?.urn;return r==null?"":e.get(r)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||vu,field:Rs,colId:Rs,valueGetter:n,...Ke,tooltipValueGetter:s=>s.value}}function Au(e,t,n,s){return[Nu(e,t,n,s),ju(e,t,n,s),Iu(e,t,n,s)]}function Nu(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.region;return o==null||f==null||d==null||c==null?"":an(d,c,o,n)};return sn(s?.countryDimensions||Cu,bu,r)}function ju(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.indicators;return o==null||f==null||d==null||c==null||c.length===0?"":c.map(m=>an(d,m,o,n)||"").join(Mu)};return sn(s?.indicatorDimensions||xu,Su,r)}function Iu(e,t,n,s){const r=i=>{const{structures:d,urn:f,data:o}=rn(i,e),c=t.get(f)?.frequency;return o==null||f==null||d==null||c==null?"":an(d,c,o,n)};return sn(s?.frequency||yu,Du,r)}function sn(e,t,n){return{headerName:e,field:t,colId:t,valueGetter:n,...Ke,tooltipValueGetter:s=>s.value}}function rn(e,t){const{data:n}=e,s=n?.dataset?.urn,r=s==null?void 0:t.get(s);return{data:n,urn:s,structures:r}}function an(e,t,n,s){const r=e.conceptSchemes||[],i=e.codelists||[],d=S.getDimensions(e)?.dimensions||[],f=d.find(c=>c.id===t);if(f==null)return;const{codeList:o}=Mt(f,r,i);return tn(d,t,o,n,s)}function Lu(e,t,n){return Ou(e).sort((i,d)=>S.sortPeriods(i,d)).map(i=>({...Ru(i,t,n),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:St,cellRenderer:yt,width:Ze,cellRendererParams:{titles:n}}))}function Ou(e){const t=new Set;return e.forEach(n=>{if(n==null)return;S.getTimePeriods(n).forEach(r=>t.add(r))}),Array.from(t)}function Ru(e,t=J.defaultFormatNumbers,n){return{headerName:mr(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Ze,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>J.formatNumberBySign(s.value,t)}}function Fu(e,t,n,s,r,i){const d=ku(e,s,r),f=Au(e,t,s,r),o=Lu(n,i,r);return[...d,...f,...o]}function Pu(e,t,n,s,r){const i=[];return n.forEach(d=>{const f=d.urn,o=t.get(f),c=e.get(f);if(o==null||c==null)return;const l=nn(o,c,d,s,r);i.push(...l.map(m=>({...m,dataset:{urn:f}})))}),i}function _u(e,t,n,s,r,i,d,f,o,c,l){const m=Vu(e,t,n,s,r,i,d,f,o);return{title:o?.dataGrid||"Data",gridContent:m}}function Vu(e,t,n,s,r,i,d,f,o,c,l){return{columns:Fu(e,n,t,r,o,i),data:Pu(e,t,s,r,f)}}function Ca(e,t,n,s,r,i){const d=Zt(),[f,o]=u.useState(),[c,l]=u.useState(),[m,h]=u.useState(),[p,g]=u.useState(),[C,w]=u.useState(),[y,x]=u.useState(),[b,D]=u.useState(),[E,T]=u.useState(!1),[A,N]=u.useState(fu(d?.dataGrid)),I=u.useCallback(async _=>{try{const F=await mu(_,e.getConstraints);h(F)}catch{h(new Map)}},[e,h]),k=u.useCallback(async _=>{const F=await gu(_,e.getDataSet,e.getDataSetData,T);l(F?.datasetsMap),g(F?.structuresMap),w(F?.dimensionsMap),o(F?.dataMessagesMap),x(F?.structureDimensionsMap)},[e]),{getDimensionsScheme:M}=Sa(),j=u.useCallback(_=>{const F=new Map;for(const B of _)F.set(B.urn,M(B.urn));D(F)},[M]);return u.useEffect(()=>{async function _(F){T(!0);try{j(F),await Promise.all([I(F),k(F)])}catch(B){console.error("Error loading dataset details",B)}finally{T(!1)}}n?.length&&_(n)},[n,I,j,k]),u.useEffect(()=>{p!=null&&p.size>0&&f!=null&&m!=null&&b!=null&&!E&&N(_=>({..._,..._u(p,f,b,n||[],t,r,i,s,d)}))},[p,f,m,n,t,r,i,s,d,b,E]),{dataMessagesMap:f,structuresMap:p,datasetsMap:c,dimensionsMap:C,structureDimensionsMap:y,constraintsMap:m,datasetDimensionsSchemesMap:b,isLoadingGridData:E,crossDatasetGridAttachment:A}}function Gu({api:e,searchQuery:t,includeColumn:n=Sl}){const[s,r]=u.useState(0),i=u.useCallback(()=>{r(h=>h+1)},[]);la(e,i);const d=u.useMemo(()=>e?kl(e,n):[],[e,n,s]),f=u.useMemo(()=>v.filterDraggableListNodes(d,t),[d,t]),o=u.useCallback(h=>{if(!e)return;const p=Es(d,h.path);p&&(e.applyColumnState({state:[{colId:p.id,hide:!h.nextChecked}]}),i())},[e,d,i]),c=u.useCallback(h=>{if(!e)return;const p=Es(d,h.path);if(!p)return;const C=!(e.getColumnState().find(w=>w.colId===p.id)?.hide??!1);e.applyColumnState({state:[{colId:p.id,hide:C}]}),i()},[e,d,i]),l=u.useCallback(h=>{},[]),m=u.useCallback(h=>{if(!e)return;const p=e.getColumnState().map(y=>y.colId),g=new Set(d.map(y=>y.id)),C=Ft(h),w=El(p,C,g);e.applyColumnState({state:w.map(y=>({colId:y})),applyOrder:!0}),i()},[e,d,i]);return{items:d,visibleItems:f,handleToggleChecked:o,handleToggleExpanded:l,handleItemClick:c,handleItemsChange:m}}function Bu({api:e,includeColumn:t}){const[n,s]=u.useState(""),r=u.useCallback(h=>{s(h)},[s]),i=u.useCallback(()=>s(""),[s]),d=u.useMemo(()=>a.jsx("button",{type:"button",onClick:i,children:a.jsx(ke.IconX,{className:"text-neutrals-1000 size-4"})}),[i]),{visibleItems:f,handleItemsChange:o,handleToggleChecked:c,handleToggleExpanded:l,handleItemClick:m}=Gu({api:e,includeColumn:t,searchQuery:n});return a.jsxs("div",{className:"px-5 py-7 flex flex-col gap-2 flex-1 min-h-0",children:[a.jsx(v.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:"Search",iconBeforeInput:a.jsx(ke.IconSearch,{className:"text-neutrals-1000 size-4"}),iconAfterInput:n?d:void 0,value:n,onChange:r}),a.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:a.jsx(v.DraggableList,{items:f,onItemsChange:o,onToggleChecked:c,onToggleExpanded:l,onItemClick:m})})]})}const Hu=({onClose:e,gridApi:t,initialColumnsState:n,title:s,resetTitle:r})=>{const i=u.useCallback(()=>{t&&Tl(t,n)},[t,n]),d=u.useCallback(()=>{e?.()},[e]);return a.jsxs("div",{className:"h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex justify-between border-b border-neutrals-500 px-5 py-6",children:[a.jsx("div",{className:"h2 text-neutrals-1000",children:s||"Columns"}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("button",{type:"button",className:"text-neutrals-800 flex gap-1 items-center",onClick:i,children:[a.jsx(ke.IconRotate,{className:"rotate-180 size-4"})," ",a.jsx("span",{className:"h4",children:r||"Reset"})]}),a.jsx("div",{className:"h-3 w-[1px] bg-neutrals-600"}),a.jsx("button",{type:"button",onClick:d,children:a.jsx(ke.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),t&&a.jsx(Bu,{api:t})]})},Uu=({attachmentsProps:e,...t})=>{const n=u.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]);return a.jsx(Nl,{currentUrn:n,children:a.jsx(Wu,{attachmentsProps:e,...t})})},Wu=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:r,formattingSettings:i,locale:d,advanceViewStyles:f,getDatasetUpdatedTime:o,attachmentsConfig:c,datasetInfoOptions:l,...m})=>{const h=m.filtersProps.conversation?.messages?.at(-1)?.custom_content?.attachments,{isCrossDatasetModeOn:p}=Xt(),{tableSettings:{isOpen:g,close:C},agGrid:{gridApi:w,initialColumnsState:y}}=ua(),{dataMessage:x,dataset:b,dimensions:D,structureDimensions:E,structures:T,dataSetAttachments:A,onFiltersChange:N,isLoadingGridData:I,constraints:k}=va(t,d,e.currentDataQuery,i,e.styles?.chartingStyles,r,n,h),{dimensionsMap:M,structuresMap:j,structureDimensionsMap:_,constraintsMap:F,crossDatasetGridAttachment:B,isLoadingGridData:V}=Ca(t,d,e.dataQueries,e.styles?.chartingStyles,i,r),[z,Z]=u.useState(),[ie,K]=u.useState({filterKey:null,timeFilter:null}),q=u.useMemo(()=>p?V:I,[p,V,I]),Y=u.useCallback((H,ne,se)=>{K(H),Z(!0),N(H,ne,se)},[N]),ce=u.useCallback(H=>{H&&t?.updateCurrentDataQuery(e?.dataQueries?.find(ne=>ne?.urn===H)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),me=Wr(c?.isExternaLinkIncludeFilters,ie,e.currentDataQuery||e.dataQueries?.[0],D);return a.jsxs("div",{className:"advanced-view flex flex-col flex-1 h-full min-w-0",children:[a.jsx(Ec,{titles:n,locale:d,shareConversationProps:s,isShowShare:f?.isShowShare}),e?.datasets?.length?a.jsxs(a.Fragment,{children:[e?.datasets?.length>1&&a.jsx(Ur,{datasets:e?.datasets,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:d,isHideAdvancedViewButton:!0,selectDataset:ce}),q&&!z?a.jsx(v.Loader,{}):a.jsxs(a.Fragment,{children:[a.jsx(kc,{...l,titles:n,locale:d,dataset:b,data:x?.data,structures:T,metadataSettings:r,getDatasetUpdatedTime:o,externalLink:me}),a.jsxs("div",{className:"flex flex-1 min-h-0 overflow-auto border-t border-neutrals-500",children:[a.jsx("div",{className:P("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:a.jsx(Rl,{...m,titles:n,actions:t,attachments:p?[B]:A,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:D,attachmentsStyles:e.styles,isDataLoading:q,locale:d,filtersProps:{...m?.filtersProps,structureDimensions:E,structures:T,structureDataMaps:{dimensionsMap:M,structuresMap:j,structureDimensionsMap:_,constraintsMap:F},onFiltersChange:N,initialConstraints:k},setIsFiltering:Z,attachmentsConfig:c,filters:ie,onFiltersChange:Y})}),g&&a.jsx(Hu,{onClose:C,gridApi:w,initialColumnsState:y,title:e.styles?.columnsTitle,resetTitle:e.styles?.columnsResetTitle})]})]})]}):a.jsx(v.Loader,{})]})};function zu(e,t,n,s,r){const[i,d]=u.useState([]),[f,o]=u.useState(),[c,l]=u.useState(!1);return u.useEffect(()=>{let m=!0;async function h(p){l(!0);try{const g=await Promise.all(p.map(w=>Ve(e,_e(w.urn),()=>e(w.urn))));if(!m)return;const C=g?.map(w=>w?.data?.dataflows?.[0])?.filter(w=>!!w)||[];d(C),t(C),n(p),s(p[0]),o(new Map(g?.map(w=>[S.generateShortUrn(w?.data?.dataflows?.[0]?.id,w?.data?.dataflows?.[0]?.version,w?.data?.dataflows?.[0]?.agencyID),w?.data])))}catch(g){console.error("Error loading datasets",g)}finally{m&&l(!1)}}if(!r?.length){l(!1);return}return h(r),()=>{m=!1}},[r,e,s,n,t]),{datasets:i,datasetStructuresMap:f,isLoading:c}}function Fs(e){const t=e?.filter(n=>Fr(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...Ju($u(n?.data))}))}function $u(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function Ju(e){return{...e,filters:e?.filters?.map(t=>({...t,componentCode:t?.component_code||t?.componentCode})),metadata:{datasetUrl:e?.metadata?.datasetUrl,countryDimension:e?.metadata?.country_dimension||e?.metadata?.countryDimension,indicatorDimensions:e?.metadata?.indicator_dimensions||e?.metadata?.indicatorDimensions}}}var ba=(e=>(e.COMPLETED="completed",e))(ba||{});const Yu=({stage:e,stageRef:t,isCurrentStage:n})=>a.jsxs("div",{ref:t,className:"message-stage flex relative pb-8 last:pb-0 last:mb-8",children:[a.jsx("span",{className:"message-stage-line absolute border-l h-full"}),a.jsx(ke.IconPointFilled,{className:"message-stage-indicator flex shrink-0 z-10"}),a.jsxs("div",{className:"ml-2 w-full",children:[a.jsxs("div",{className:P("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&a.jsx(v.Loader,{}),a.jsx("h3",{className:"message-stage-name",children:e?.name})]}),a.jsx("div",{className:"prose max-w-full break-words",children:a.jsx(_s,{remarkPlugins:[Vs],components:{strong:s=>a.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:r,...i})=>a.jsx("a",{href:s,target:"_blank",...i,children:r}),h1:s=>a.jsx("h1",{className:"h1 text-neutrals-1000",...s}),h2:s=>a.jsx("h2",{className:"h2 text-neutrals-1000",...s}),h3:s=>a.jsx("h3",{className:"h3 text-neutrals-1000",...s}),h4:s=>a.jsx("h4",{className:"h4 text-neutrals-1000",...s}),h5:s=>a.jsx("h5",{className:"h5 text-neutrals-1000",...s}),code:s=>a.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>a.jsx("pre",{className:"bg-neutrals-100 border border-neutrals-600",...s})},children:e?.content})})]})]}),qu=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,r]=u.useState(),[i,d]=u.useState(),f=u.useRef(null),o=u.useRef(null);u.useEffect(()=>{d(e?.filter(l=>l?.status!==ba.COMPLETED)?.at(-1))},[e]),u.useEffect(()=>{s&&o?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),u.useEffect(()=>{const l=f.current;let m;if(!l)return;const h=new IntersectionObserver(([p])=>{const g=p?.boundingClientRect?.top;m&&!p?.isIntersecting&&g<m&&r(!1),m=g},{threshold:0});return h.observe(l),()=>h.disconnect()},[]);const c=()=>{r(l=>!l)};return a.jsxs("div",{className:"message-stages",ref:f,children:[a.jsxs("div",{className:P("message-stages-header inline-flex max-w-full items-center cursor-pointer",!i?.name&&"default-header"),onClick:c,children:[a.jsx("p",{className:"message-stages-title truncate",children:i?.name||n||"Processing..."}),a.jsx("i",{className:P("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&a.jsx("div",{className:"flex flex-col",children:e?.map(l=>a.jsx(Yu,{stage:l,stageRef:i?o:null,isCurrentStage:l?.index===i?.index},l.index))})]})},Ku=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:r=!1,isReadOnly:i=!1,isRegenerateAvailable:d=!1})=>{const f=n?.copy,o=n?.regenerate,c=n?.thumbUp,l=n?.thumbDown,m=n?.thumbPressed,[h,p]=u.useState(e.like??de.LikeState.NoState),{isAgentAvailable:g}=v.useAgentAvailability(),C=w=>{e.responseId&&(p(w),s(e.responseId||"",w))};return a.jsxs("div",{className:P("message-actions","flex gap-x-2 pt-2"),children:[f&&a.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:f}),d&&o&&!i&&!r&&a.jsx("p",{onClick:g?()=>t?.(e):void 0,"aria-disabled":!g,className:P(!g&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:o}),c&&!i&&h!==de.LikeState.Disliked&&(h===de.LikeState.NoState?a.jsx("p",{onClick:()=>C(de.LikeState.Liked),children:c}):a.jsx("p",{children:m})),l&&!i&&h!==de.LikeState.Liked&&(h===de.LikeState.NoState?a.jsx("p",{onClick:()=>C(de.LikeState.Disliked),children:l}):a.jsx("p",{className:"rotate-180",children:m}))]})},Zu=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:r=!1})=>{const i=n?.copy,d=n?.edit,{isAgentAvailable:f}=v.useAgentAvailability();return a.jsxs("div",{className:P("message-actions","flex gap-x-2 pt-2 ml-12"),children:[i&&a.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:i}),d&&!s&&!r&&a.jsx("p",{onClick:f?t:void 0,className:P(!f&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!f,children:d})]})},Xu=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:r})=>{const{isOpenedAdvancedView:i}=Be(),d=u.useRef(null);u.useEffect(()=>{const o=d.current;f(),o&&(o.focus(),o.setSelectionRange(o.value.length,o.value.length))},[]);const f=()=>{const o=d.current;o&&(o.style.height="auto",o.style.height=o.scrollHeight+"px")};return a.jsxs("div",{className:P("max-w-none break-words",i?"body-2":"body-1",t),children:[a.jsx("textarea",{ref:d,className:"resize-none overflow-hidden outline-none bg-neutrals-300 w-full",defaultValue:e,onInput:f}),a.jsxs("div",{className:P("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[a.jsx(v.Button,{buttonClassName:"text-button-secondary small-icon-button",title:r?.cancel,isSmallButton:!0,onClick:n}),a.jsx(v.Button,{buttonClassName:"text-button-primary small-icon-button",title:r?.send,isSmallButton:!0,onClick:()=>s(d.current?.value||"")})]})]})},Qu=({message:e,previousMessage:t,titles:n,actions:s,dataQuery:r,isStreaming:i=!1,isCurrentMessageStreaming:d=!1,messageStyles:f,attachmentsStyles:o,showAdvancedView:c,formattingSettings:l,locale:m,metadataSettings:h,expandStagesIcon:p,onAdvancedViewOpen:g,regenerateMessage:C,selectMessageToSend:w,messageActionsIcons:y,rateResponse:x,editMessage:b,editMessageTitles:D,isReadOnlyConversation:E,isLastNotUserMessage:T,limitMessages:A,attachmentsConfig:N})=>{const[I,k]=u.useState(),[M,j]=u.useState(),[_,F]=u.useState([]),[B,V]=u.useState([]),[z,Z]=u.useState(),[ie,K]=u.useState(!1),{isCrossDatasetModeOn:q}=Xt(),Y=e.role===de.Role.User,ce=e.role===de.Role.System,{datasets:me,datasetStructuresMap:H,isLoading:ne}=zu(s.getDataSet,s.updateDatasets,s.updateDataQueries,s.updateCurrentDataQuery,I),[se,oe]=u.useState(!1),[he,Ce]=u.useState([]);u.useEffect(()=>{j(I?.[0])},[I]);const{dataSetAttachments:ve,dimensions:we,isLoadingGridData:Se}=va(s,m,M,l,o?.chartingStyles,h,n,e.custom_content?.attachments,M?H?.get(M.urn):void 0,ne),{crossDatasetGridAttachment:Ee,isLoadingGridData:ye}=Ca(s,m,I,o?.chartingStyles,l,h),{isOpenedAdvancedView:De}=Be(),je=u.useMemo(()=>q?ye:Se,[q,ye,Se]),Le=()=>{Y&&oe(!0)},W=()=>{oe(!1)},R=re=>{W(),b?.({...e,content:re})},G=u.useCallback(re=>{re&&(j(I?.find(fe=>fe?.urn===re)),Z(void 0))},[I]);u.useEffect(()=>{const re=e.custom_content?.form_schema?.properties,fe=T?re?.choice?.oneOf||re?.completion?.oneOf:[];Ce(fe||[])},[e,T]),u.useEffect(()=>{const re=xs(e),fe=Fs(re),Me=re.filter(Oe=>zt(Oe));k(fe),V(Me)},[e]),u.useEffect(()=>{K(I!=null&&I.length>0)},[I]),u.useEffect(()=>{r&&r.urn&&Z(r.urn)},[r]),u.useEffect(()=>{if(e?.role===de.Role.System&&t){const re=xs(t),fe=Fs(re)||[];I&&fe&&H&&F(yo(fe,I,H,m))}},[I,M,H,we,m,e?.role,t]);const $=u.useCallback(()=>!Y&&f?.systemMessageIcon&&!(De&&!d)?a.jsx("div",{className:P("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",d?"text-white absolute":"text-neutrals-400"),children:f.systemMessageIcon}):null,[Y,f?.systemMessageIcon,De,d]),le=u.useMemo(()=>a.jsx(oa,{actions:s,titles:n,attachments:ie?q?[Ee]:ve:B,onAdvancedViewOpen:g,isDataSetAttachments:ie,datasets:me,initialSelectedDatasetUrn:z,messageStyles:f,attachmentsStyles:o,showAdvancedView:c,isSystemAttachments:ce,isDataLoading:je,currentDataQuery:M,dataQueries:I,attachmentInfoList:_,locale:m,dimensions:we,selectDataset:G,limitMessages:A,attachmentsConfig:N}),[s,n,ie,ve,B,Ee,me,z,f,o,c,ce,je,M,I,_,m,we,G,g,A,N]);return a.jsx(a.Fragment,{children:!(ce&&De)&&a.jsx("div",{className:P("max-w-full flex",Y?"justify-end":"justify-start","message-wrapper"),children:a.jsxs("div",{className:P("flex items-start max-w-full",(ce||se)&&"w-full"),children:[a.jsxs("div",{className:"mr-2 relative",children:[$(),d&&a.jsx(v.Loader,{})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:P(Y?"bg-neutrals-300 px-6":"pt-0",Y?"user-message":"system-message",Y&&(se?"w-[100%] ml-0":"ml-12")),children:[!Y&&!De&&e?.custom_content?.stages?a.jsx(qu,{stages:e?.custom_content?.stages,expandIcon:p,processingTitle:f?.processingTitle}):d&&a.jsx("p",{className:"body-1 text-neutrals-700 loading-message",children:n?.loading}),se?a.jsx(Xu,{content:e.content,onCancel:W,onEditApply:R,editMessageTitles:D}):a.jsx(lr,{content:e.content})]}),le,!d&&(Y?!se&&a.jsx(Zu,{messageActionsIcons:y,message:e,isStreaming:i,onEditClick:Le,isReadOnly:E}):a.jsx(Ku,{messageActionsIcons:y,message:e,isStreaming:i,regenerateMessage:C,rateResponse:x,isReadOnly:E,isRegenerateAvailable:T})),!De&&!je&&a.jsx(cr,{choiceButtons:he,onClick:w})]})]})})})},ed=({messages:e,isStreaming:t=!1,isReadOnly:n,scrollBottomIcon:s,conversationViewState:r,...i})=>{const d=u.useRef(null),f=u.useRef(null),{isOpenedAdvancedView:o}=Be(),[c,l]=u.useState(null),[m,h]=u.useState(!1),p=()=>{const x=f.current?.parentElement,b=d.current;if(x&&b){const D=b.offsetTop-x.offsetTop;x.scrollTo({top:D,behavior:"smooth"})}};u.useEffect(()=>{p()},[e,t]),u.useEffect(()=>{!o&&c!==null&&setTimeout(()=>{f?.current?.parentElement?.scrollTo({top:c,behavior:"smooth"})})},[o,c]);const g=()=>{const x=f.current?.parentElement?.scrollTop||null;l(x)},C=()=>{const x=f.current?.parentElement;if(x){const{scrollTop:b,scrollHeight:D,clientHeight:E}=x;b+E>=D?h(!1):!m&&!o&&h(!0)}};u.useEffect(()=>{o&&h(!1)},[o]);const w=v.useDebounce(C,300);u.useEffect(()=>{const x=f.current?.parentElement;return x?.addEventListener("scroll",w),()=>x?.removeEventListener("scroll",w)},[w]);const y=u.useCallback(x=>{const b=J.linkifyText(x);return a.jsx("div",{className:"whitespace-pre-wrap break-words",children:b.map((D,E)=>D.type==="text"?a.jsx(u.Fragment,{children:D.value},E):a.jsx("a",{href:D.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:a.jsx(ke.IconExternalLink,{className:"text-primary cursor-pointer w-4 h-4 shrink-0"})},E))})},[]);return a.jsxs("div",{ref:f,className:"h-full w-full flex justify-center",children:[a.jsxs("div",{className:"flex flex-col gap-y-6 w-full chat-messages-wrapper",children:[e.map((x,b)=>{const D=x.id??b;if(x.errorMessage){const N=r?.errorContext?.kind===ee.ERROR_CONTEXT_KIND.RATE_LIMIT?v.InlineAlertType.Warning:v.InlineAlertType.Error;return a.jsx(v.InlineAlert,{type:N,children:a.jsx("div",{className:"flex flex-col",children:y(x.errorMessage)})},D)}const E=b===e.length-1,T=ro(e,b),A=ao(e);return a.jsx(Qu,{message:x,previousMessage:T,onAdvancedViewOpen:g,isStreaming:t,isCurrentMessageStreaming:t&&E&&x.role===de.Role.Assistant,showAdvancedView:b===A&&!n,isLastNotUserMessage:E&&x.role!==de.Role.User,...i},D)}),a.jsx("div",{ref:d,className:"h-4"})]}),a.jsx("div",{onClick:p,className:P("fixed right-10 lg:right-6 sm:hidden bottom-[88px] rounded-[50%] border-[2px] w-[40px] h-[40px] border-primary cursor-pointer text-primary bg-white","scroll-button-wrapper",m?"block":"hidden"),children:a.jsx("div",{className:"flex justify-center items-center w-full h-full",children:s})})]})},td=e=>{const t={};return e.choices?.[0]?.delta?.content&&(t.content=e.choices[0].delta.content),e.choices?.[0]?.delta?.custom_content&&(t.custom_content=e.choices[0].delta.custom_content),e.choices?.[0]?.delta?.role&&(t.role=e.choices[0].delta.role),e.id&&(t.responseId=e.id),t},nd="local",sd=e=>!e.permissions?.includes(de.SharePermission.WRITE)&&!ad(e),rd=(e,t)=>xa(e)!==t,ad=e=>xa(e)===nd,xa=e=>e.id.split("/")[0],id=(e,t)=>on([...t?.messages||[],e]),on=e=>[...e].map(t=>{const n={role:t.role,content:t.content};return(t.role===de.Role.Assistant||t.role===de.Role.System)&&t.custom_content!=null&&(t.custom_content.state!=null||t.custom_content.attachments!=null||t.custom_content.form_schema!=null)&&(n.custom_content={},t.custom_content.state!=null&&(n.custom_content.state=t.custom_content.state),t.custom_content.attachments!=null&&(n.custom_content.attachments=cd(t.custom_content.attachments)),t.custom_content.form_schema!=null&&(n.custom_content.form_schema=t.custom_content.form_schema)),t.role===de.Role.User&&t.custom_content&&(n.custom_content=t.custom_content),n}),od=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return on(n?.slice(0,s)||[])},ld=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return on([...n?.slice(0,s)||[],e])};function cd(e){return e.map(t=>({type:t.type,title:t.title,data:t.data,url:t.url,reference_type:t.reference_type,reference_url:t.reference_url}))}const ud=(e,t,n,s)=>{if(!n||t)return null;const r={id:`msg-${Date.now()}`,role:de.Role.User,content:e,timestamp:Date.now()};if(s){const i=s===bt.COMPLETE?ft.COMPLETION:ft.CHOICE;r.custom_content={form_value:{[i]:s}}}return r},dd=(e,t,n)=>`/${t}${n}/${J.getConversationNavPath(e?.folderId,e?.id)}`,fd=(e,t,n)=>{const s=`${t}/${n}`,r=ee.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:r}},md=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},hd=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const r=s.at(-1)??"file",i=md(r,n);return["files",t,...s.slice(2,-1),i].join("/")},gd=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const r=J.getConversationAttachmentUrls(e),i=Date.now();if(!r.length)return e;const d=await Promise.all(r.map(async f=>{const o=hd(f,t,`${i}`);if(o===f)return[f,o];const c=await n(f);return await s(o,c),[f,o]}));return J.replaceConversationAttachmentUrls(e,Object.fromEntries(d))},pd="AbortError",wd=({error:e,statusMessages:t})=>{if(e){if(e.type===ee.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e.exceeded_limit?.length?t.getExceededLimitsMessage(e.exceeded_limit):e.display_message??"";throw new J.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??J.HTTP_ERROR_CODES.TOO_MANY_REQUESTS,details:{kind:ee.ERROR_CONTEXT_KIND.RATE_LIMIT,occurredAt:new Date().toISOString(),retryAfterSeconds:Number(e.retry_after??"")}})}throw new J.HttpError({message:e.message,status:e.status??J.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},vd=({error:e,statusMessages:t})=>{if(e.code===ee.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e;return{errorMessage:n.displayMessage??n.message,errorContext:n.details}}return e.code===ee.DIAL_ERROR_CODES.CONTENT_FILTER?{errorMessage:t.contentFilterError??e.message}:{errorMessage:e.status===J.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},Ps=(e,t)=>{const n=e.customViewState??{},s=n[ee.CUSTOM_VIEW_STATE_KEY]??{};return{...e,customViewState:{...n,[ee.CUSTOM_VIEW_STATE_KEY]:{...s,errorContext:t}}}},Cd=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:r,inputMessageStyles:i,shareConversationProps:d,showConversationHeaderAdvancedView:f=!0,formattingSettings:o,metadataSettings:c,expandStagesIcon:l,locale:m,conversationsRoute:h,token:p,titles:g,dataQuery:C,handleInvalidStreaming:w,setConversation:y,setConversations:x,openUrl:b,messageActionsIcons:D,editMessageTitles:E,scrollBottomIcon:T,isFinalMessage:A,limitMessages:N,attachmentsConfig:I})=>{const[k,M]=u.useState(null),[j,_]=u.useState(!1),[F,B]=u.useState(!0),{isStreaming:V,setIsStreaming:z}=Us(),{isOpenedAdvancedView:Z}=Be(),{isAgentAvailable:ie}=v.useAgentAvailability(),{statusMessages:K}=Vt(),{onboardingFileSchema:q,onboardingFilePath:Y,onboardingFileName:ce,isShowOnboarding:me,setOnboardingFileSchema:H}=Ne();u.useEffect(()=>{q&&n.putOnboardingFile?.(ce,Y,q)},[n,q,ce,Y]),u.useEffect(()=>{Z&&q?.lastDisplayedElement===pe.OPEN_ADVANCED_VIEW&&H?.(Or(q))},[n,Z,H,q]);const ne=u.useCallback(()=>{b(`/${m}${h}`)},[m,h,b]),se=u.useCallback(async()=>{try{const{bucket:L}=await n.getBucket(),O=n.getFileBlob&&n.putFile?await gd({conversation:t,bucket:L,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,U=fd(O,L,m);await n.createConversation(U,m);const te=await n.getConversations(m);x(J.cleanConversationNames(te)),b(dd(U,m,h))}catch(L){console.error("Failed to save conversation:",L)}},[n,t,h,m,b,x]),oe=u.useCallback(async L=>{try{await n.updateConversation(decodeURI(e),{name:L.name,messages:L.messages,customViewState:L.customViewState})}catch(O){console.error("Failed to save conversation:",O)}},[n,e]),he=u.useCallback(L=>{y(O=>O?{...O,messages:[...O?.messages||[],L]}:null)},[y]),Ce=u.useCallback(()=>{const L={id:`msg-${Date.now()+1}`,role:de.Role.Assistant,content:"",timestamp:Date.now()};return y(O=>O?{...O,messages:[...O.messages,L]}:null),L},[y]),ve=u.useCallback((L,O)=>{const U=ee.mergeMessages?.(L,[O]);if(U)return y(te=>te?{...te,messages:te.messages.map(X=>X.id===L.id?{...U}:X)}:null),U},[y]),we=u.useCallback((L,O)=>{t?.model?.id&&(n.rateResponse(L,O===de.LikeState.Liked,t.model.id),t.messages=t.messages.map(U=>U.responseId===L?Pt.merge(U,{like:O}):U),oe(t))},[n,t,oe]),Se=u.useCallback((L,O)=>{let U=K.serverError,te,X;if(J.isHttpError(L)){X=L;const be=vd({error:L,statusMessages:K});U=be.errorMessage,te=be.errorContext}else X=new J.HttpError({status:J.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:U});return O&&(O=ve(O,{errorMessage:U})),w?.(X),{assistantMessage:O,errorContext:te}},[w,K.serverError,K.serverOverloaded,K.contentFilterError,ve]),Ee=u.useCallback(async(L,O,U)=>{const te=new AbortController;M(te);let X=L,be;return U?(await ee.streamChatResponse?.(encodeURI(U.id),O,{model:U.model,signal:te?.signal,onMessage:xe=>{wd({error:xe.error,statusMessages:K});const Re=td(xe);(Re.content||Re.role||Re.responseId)&&(X=ve(X,Re))},onError:xe=>{if(!W(xe))throw console.error("Streaming error:",xe),xe}},p,U?.custom_fields).catch(xe=>{const{assistantMessage:Re,errorContext:We}=Se(xe,X);X=Re,be=We}),{assistantMessage:X,errorContext:be}):{assistantMessage:X,errorContext:be}},[p,ve,Se,K]),ye=u.useCallback(async(L,O,U,te)=>{if(!O)return;let X=Ps(O,te);X={...X,messages:[...O.messages],updatedAt:Date.now()},U&&X.messages.push(U),X.messages.push(L),await oe(X)},[oe]),De=u.useCallback(L=>{y(O=>O&&Ps(O,L))},[y]),je=u.useCallback((L,O)=>{y(U=>U?{...U,messages:U.messages.filter(te=>te.id!==O.id)}:null)},[y]),Le=u.useCallback(()=>{k&&!k.signal.aborted&&k.abort()},[k]),W=L=>L?.name===pd,R=u.useCallback(async(L,O,U,te,X,be=!0)=>{W(X)?await ye(te??U,L,be?O:void 0):je(X,O)},[ye,je]),G=u.useCallback(async(L,O,U)=>{if(!O||!L)return;const te=ud(L,V,O,U);let X,be;if(te){he(te);try{z(!0),X=Ce();const xe=id(te,O),{assistantMessage:Re,errorContext:We}=await Ee(X,xe,O);De(We),be=Re,await ye(be,O,te,We)}catch(xe){R(O,te,X,be,xe)}finally{z(!1)}}},[V,z,he,Ce,Ee,ye,R,De]),$=u.useCallback(async(L,O,U)=>{let te,X;try{z(!0),te=Ce();const{assistantMessage:be,errorContext:xe}=await Ee(te,L,O);X=be,De(xe),await ye(X,O,void 0,xe)}catch(be){R(O,U,te,X,be,!1)}finally{z(!1)}},[z,ye,R,Ee,Ce,De]),le=u.useCallback(async(L,O)=>{if(!O||!L)return;const U=od(L,O),te={...O,messages:O.messages.slice(0,U.length)};y(X=>X?{...X,...te}:null),$(U,te,L)},[y,$]),{isLastMessageFailed:re,regenerateLastMessage:fe}=u.useMemo(()=>{const L=t?.messages?.at(-1);return{isLastMessageFailed:!!L?.errorMessage,regenerateLastMessage:L&&(()=>le(L,t))}},[t,le]),Me=u.useCallback(async(L,O)=>{if(!O||!L)return;const U=ld(L,O),te={...O,messages:[...O.messages.slice(0,U.length-1),L]};y(X=>X?{...X,...te}:null),$(U,te,L)},[y,$]);u.useEffect(()=>{Ss();async function L(){try{B(!0);const{bucket:O}=await n.getBucket(),U=await n.getConversation(decodeURI(e));y(U),_(sd(U)&&rd(U,O)),(U.messages.length===0||U?.messages?.[0]?.role===de.Role.Assistant&&U?.messages?.length===1)&&G(U.prompt,U)}catch{_(!0)}finally{B(!1)}}return e&&L(),()=>{Ss()}},[e]);const Oe=u.useMemo(()=>({getFile:n.getFile,putOnboardingFile:n.putOnboardingFile,getDataSet:n.getDataSet,getDataSetData:n.getDataSetData,getConstraints:n.getConstraints,updateCurrentDataQuery:n.updateCurrentDataQuery,updateDataQueries:n.updateDataQueries,updateDatasets:n.updateDatasets,downloadDataSet:n.downloadDataSet}),[n]);if(F)return a.jsx(v.Loader,{});const Ae=t?.customViewState?.[ee.CUSTOM_VIEW_STATE_KEY],at=()=>{if(Ae?.errorContext?.kind===ee.ERROR_CONTEXT_KIND.RATE_LIMIT&&ee.isRateLimitStillActive(Ae.errorContext)){const L=ee.getRateLimitRestoreDate(Ae.errorContext);if(L){const O=ee.formatDateTime(L);return a.jsx(v.InlineAlert,{type:v.InlineAlertType.Info,children:K.getAssistantRestoreMessage(O.date,O.time)})}}return ie?a.jsx(Js,{onSendMessage:L=>G(L,t),onStopStreaming:Le,inProcess:V,sendMessageIcon:i.sendMessageIcon,retryIcon:i.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:re,onRetryFailed:fe}):a.jsx(v.InlineAlert,{type:v.InlineAlertType.Error,children:K.assistantUnavailable})};return a.jsx(ia,{titles:g,children:a.jsxs("div",{className:P("h-full flex flex-col bg-white conversation-view-wrapper",Z&&!f?"p-4":"pr-2"),children:[Z&&!f?null:a.jsx(or,{conversation:t,locale:m,isOpenedAdvancedView:Z,isShowShareButton:!j&&!me,shareConversationProps:d}),a.jsx("div",{className:P("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:a.jsx(ed,{messages:t?.messages||[],actions:Oe,isStreaming:V,isReadOnly:j,messageStyles:s,attachmentsStyles:r,formattingSettings:o,metadataSettings:c,expandStagesIcon:l,dataQuery:C,locale:m,titles:g,regenerateMessage:L=>le(L,t),selectMessageToSend:(L,O)=>G(L,t,O),messageActionsIcons:D,rateResponse:we,editMessage:L=>Me(L,t),editMessageTitles:E,scrollBottomIcon:T,isReadOnlyConversation:j||me,limitMessages:N,attachmentsConfig:I,conversationViewState:Ae})}),me?null:j?a.jsx("div",{className:"flex items-center justify-center mt-4",children:a.jsx(v.Button,{iconBefore:a.jsx(ke.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:se,buttonClassName:P("text-button-secondary")})}):a.jsx("div",{className:P(i.inputContainerClass),children:at()}),me&&A&&a.jsx(v.Button,{iconBefore:a.jsx(ke.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:ne,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"})]})})},ln=u.createContext(null);function bd({map:e,children:t}){const n=u.useMemo(()=>{const s={},r={},i={},d=Object.keys(e);for(const f of d){s[f]={},r[f]={};const o=Object.keys(e[f]);for(const c of o){const l=e[f][c];l.subtype&&(s[f][l.subtype]=c),r[f][l.dimensionType]||(r[f][l.dimensionType]=[]),r[f][l.dimensionType].push(c)}i[f]={timePeriod:r[f]?.TIME_PERIOD?.[0]??void 0,frequency:s[f]?.FREQUENCY??void 0,region:s[f]?.REGION??void 0,indicators:r[f]?.INDICATOR??[],other:(r[f]?.NON_INDICATOR??[]).filter(c=>{const l=e[f][c];return l.subtype!=="FREQUENCY"&&l.subtype!=="REGION"})}}return{map:e,getDimensionsMetadata:f=>e[f],getDimensionMetadata:(f,o)=>e[f]?.[o],getRegionDimension:f=>s[f]?.REGION,getFrequencyDimension:f=>s[f]?.FREQUENCY,getIndicatorDimensions:f=>r[f]?.INDICATOR??[],getDimensionsScheme:f=>i[f]}},[e]);return a.jsx(ln.Provider,{value:n,children:t})}function Sa(){const e=u.useContext(ln);if(!e)throw new Error("useDatasetDimensionsMetadataMap must be used within DatasetDimensionsMetadataMapProvider");return e}function xd(){return u.useContext(ln)}exports.AdvancedView=Uu;exports.AdvancedViewProvider=La;exports.CUSTOM_CHOICE_ID=bt;exports.ChartingIcon=mt;exports.ChatFooter=dr;exports.ChatMessagesProvider=Oa;exports.ChatOnboardingFooter=ur;exports.ConversationView=Cd;exports.ConversationViewMessagesProvider=Ra;exports.ConversationViewTitlesProvider=ia;exports.ConversationWelcome=si;exports.CustomContentProperties=ft;exports.DatasetDimensionsMetadataMapProvider=bd;exports.OnboardingProvider=Fa;exports.STAGE_STATUS=$s;exports.useAdvancedView=Be;exports.useChatMessages=Us;exports.useConversationViewMessages=Vt;exports.useConversationViewTitles=Zt;exports.useDatasetDimensionsMetadataMap=Sa;exports.useDatasetDimensionsMetadataMapOptional=xd;exports.useOnboarding=Ne;
|