@epam/statgpt-conversation-list 0.7.0-dev.33 → 0.7.0-dev.34
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 +1 -1
- package/index.mjs +1 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("classnames");c=s(c);let l=require("react");l=s(l);let u=require("lodash"),d=require("@epam/statgpt-ui-components"),f=require("@tabler/icons-react"),p=require("react/jsx-runtime"),m=require("jszip");m=s(m);let h=require("@epam/statgpt-shared-toolkit"),g=require("@epam/statgpt-dial-toolkit");var _=function(e){return e.DELETE=`delete`,e.EXPORT=`export`,e.SHARE=`share`,e.RENAME=`rename`,e}({}),v=function(e){return e.SHARED=`shared`,e.TODAY=`today`,e.YESTERDAY=`yesterday`,e.WEEK=`week`,e.EARLIER=`earlier`,e}({}),y=(e,t)=>e?.resources?.filter(e=>e?.parentPath===t)?.map(e=>{let n=`${e?.bucket}/${t}`,r=e?.url?.split(`/`)?.slice(1)?.join(`/`);return{...e,folderId:n,id:r,isShared:!0}})||[],b=e=>({[v.SHARED]:e}),x={[v.TODAY]:[],[v.YESTERDAY]:[],[v.WEEK]:[],[v.EARLIER]:[]},S=(e,t)=>e.toDateString()===t.toDateString(),C=(e,t)=>S(t,new Date(e.getFullYear(),e.getMonth(),e.getDate()-1)),w=(e,t)=>{let n=e.getTime()-t.getTime();return Math.floor(n/(1e3*60*60*24))},T=e=>e.updatedAt||Number(e.id?.split(`-`).pop()),E=e=>{let t=new Date,n=(0,u.cloneDeep)(x);for(let r of e)if(r.updatedAt){let e=new Date(r.updatedAt),i;i=S(t,e)?n[v.TODAY]:C(t,e)?n[v.YESTERDAY]:w(t,e)<=7?n[v.WEEK]:n[v.EARLIER],i?.some(e=>e.id===r.id)||i.push(r)}return n},D=e=>e?.sort((e,t)=>(T(t)||0)-(T(e)||0)),O=(e,t)=>e===v.SHARED?t?.shared||`Shared`:e===v.TODAY?t?.today||`Today`:e===v.YESTERDAY?t?.yesterday||`Yesterday`:e===v.WEEK?t?.lastWeek||`Last week`:t?.earlier||`Earlier`,k=(0,l.createContext)(null);function A(){let e=(0,l.useContext)(k);if(!e)throw Error(`useConversationStyles must be used within ConversationStylesContext.Provider`);return e}var j=({onCloseModal:e,deleteConversation:t,locale:n})=>{let{titles:r,disableModalDividers:i,isSmallModalButton:a}=A();return(0,p.jsxs)(d.Popup,{heading:r?.deleteTitle??`Delete conversation`,portalId:`delete-conversation`,containerClassName:`delete-conversation-popup`,size:d.PopUpSize.SM,dividers:!i,onClose:e,closeButtonTitle:r?.close??`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:n,children:r?.deleteMessage??`Are you sure you want to delete this conversation? This action cannot be undone.`}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:r?.cancel??`Cancel`,isSmallButton:a,onClick:t=>{t.stopPropagation(),e()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary text-button-primary-error`,title:r?.delete??`Delete`,isSmallButton:a,onClick:e=>{e.stopPropagation(),t()}})]})]})},M=e=>(0,u.uniqBy)(I((0,h.getConversationAttachments)(e)).map(e=>({...e,relativePath:``,contentLength:0})),e=>B(e.relativePath,e.name)),N=e=>e.endsWith(`/`),P=e=>{let t=e.toLowerCase();return[`data:`,`//`,`http://`,`https://`,`file://`,`ftp://`,`mailto:`,`telnet://`,`api/files`].some(e=>t.startsWith(e))},F=e=>{let t=B(...e.split(`/`).map(e=>decodeURIComponent(e))),n=t.lastIndexOf(`/`);return{absolutePath:t.slice(0,n),name:t.slice(n+1)}},I=e=>e?e.map(e=>{if(!e.url||P(e.url)||N(e.url))return null;let{absolutePath:t,name:n}=F(e.url);return{id:e.url,name:n,contentType:e.type,folderId:t,absolutePath:t}}).filter(Boolean):[];async function L(e,t){let n=M(e),r=new m.default;n.forEach(e=>{let n=t(`${encodeURI(B(e.absolutePath,e.name))}`.replace(`files/`,``)),i=B(`res`,R(e.folderId),e.name);r.file(i,n)});let i={version:5,history:[e].map(z)||[],folders:[]},a=JSON.stringify(i,null,2);return r.file(`conversations/conversations_history.json`,a),await r.generateAsync({type:`base64`})}var R=e=>{let t=e.split(`/`);return t.length>2?B(...t.slice(2)):void 0},z=e=>(0,u.omit)(e,[`publicationInfo`]),B=(...e)=>e.filter(Boolean).join(`/`);function V(e,t){let n=document.createElement(`a`);n.download=t,n.href=e,n.style.display=`none`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}var H=Object.defineProperty,U=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,K=(e,t,n)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||={})W.call(t,n)&&K(e,n,t[n]);if(U)for(var n of U(t))G.call(t,n)&&K(e,n,t[n]);return e},J=(e,t)=>{var n={};for(var r in e)W.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&U)for(var r of U(e))t.indexOf(r)<0&&G.call(e,r)&&(n[r]=e[r]);return n},Y;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};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(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(Y||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(Y||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(Y||={});var X=Y,ee={L:X.QrCode.Ecc.LOW,M:X.QrCode.Ecc.MEDIUM,Q:X.QrCode.Ecc.QUARTILE,H:X.QrCode.Ecc.HIGH},te=128,Z=`L`,Q=`#FFFFFF`,ne=`#000000`,re=!1,ie=1,ae=4,oe=0,se=.1;function ce(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function le(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ue(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*se),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function de(e,t){return t==null?e?ae:oe:Math.max(Math.floor(t),0)}function fe({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=l.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...X.QrSegment.makeSegments(t)),e),[]);return X.QrCode.encodeSegments(r,ee[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:u,margin:d,numCells:f,calculatedImageSettings:p}=l.default.useMemo(()=>{let e=c.getModules(),t=de(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ue(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:u,numCells:f,calculatedImageSettings:p}}var pe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),me=l.default.forwardRef(function(e,t){let n=e,{value:r,size:i=te,level:a=Z,bgColor:o=Q,fgColor:s=ne,includeMargin:c=re,minVersion:u=ie,boostLevel:d,marginSize:f,imageSettings:p}=n,m=J(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=J(m,[`style`]),_=p?.src,v=l.default.useRef(null),y=l.default.useRef(null),b=l.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=l.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=fe({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});l.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=le(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,pe?t.fill(new Path2D(ce(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),l.default.useEffect(()=>{S(!1)},[_]);let D=q({height:i,width:i},h),O=null;return _!=null&&(O=l.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),l.default.createElement(l.default.Fragment,null,l.default.createElement(`canvas`,q({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});me.displayName=`QRCodeCanvas`;var $=l.default.forwardRef(function(e,t){let n=e,{value:r,size:i=te,level:a=Z,bgColor:o=Q,fgColor:s=ne,includeMargin:c=re,minVersion:u=ie,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=J(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=fe({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=le(_,y.excavation)),x=l.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=ce(b,g);return l.default.createElement(`svg`,q({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&l.default.createElement(`title`,null,f),l.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),l.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});$.displayName=`QRCodeSVG`;var he=(e,t)=>({invitationType:g.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),ge=e=>`/${h.SHARE_CONVERSATION_ROUTE}/${e?.invitationLink?.split(`/`).at(-1)||``}`,_e=(e,t)=>t?.find(t=>{let n=e?.id?.split(`/`)?.pop(),r=t?.url?.split(`/`)?.pop()||``;return r===n||decodeURI(r)===n}),ve=e=>(e?.messages?.filter(e=>!!e?.custom_content?.attachments))?.flatMap(e=>e?.custom_content?.attachments?.map(e=>({url:e?.url||``}))||[])?.filter(e=>!!e?.url)||[],ye=({conversation:e,locale:t,onCloseModal:n,modalDividers:r,getConversation:i,generateConversationLink:a,chatExpiration:o,chatExpirationDays:s,close:c,chatWarning:u,shareLink:m,shareCopyLink:_,shareCopiedLink:v,shareDescription:y,shareRemoveAccessToUsers:b,chatName:x,getSharedConversations:S,revokeSharedConversations:C,baseUrl:w,id:T,clientSharedPage:E,clientSharedProp:D,shareAlertMessage:O})=>{let[k,A]=(0,l.useState)(null),[j,M]=(0,l.useState)(),[N,P]=(0,l.useState)(!1),[F,I]=(0,l.useState)(!1),[L,R]=(0,l.useState)(),z=(0,l.useRef)(null),B=(0,l.useRef)(null),V=(0,l.useMemo)(()=>e?.id?decodeURI(e.id):T?.[0]&&T?.[1]&&t?decodeURI(`${T[0]}/${t}/${T[1]}`):null,[e?.id,T,t]),H=(0,l.useMemo)(()=>{if(!k)return``;let e=w||window.location.origin;return w&&w!==window.location.origin&&E&&D?`${e}/${E}?${D}=${k.split(`/${h.SHARE_CONVERSATION_ROUTE}/`)?.[1]}`:`${e}/${t}${k}`},[w,k,t,E,D]),U=(0,l.useCallback)(async e=>{let t=await S?.((0,g.getSharedConversationsRequest)(g.ShareTarget.OTHERS));if(t)return _e({id:e},t.resources)},[S]);(0,l.useEffect)(()=>{if(!V||z.current===V)return;z.current=V,P(!1),B.current?.abort();let e=new AbortController;return B.current=e,(async()=>{try{let t=he(V,ve(await i?.(V))),n=await a?.(t),r=await U(V);if(e.signal.aborted||!n)return;A(ge(n)),M(r),P(!0)}catch(t){if(e.signal.aborted)return;P(!1),console.error(`Error sharing conversation`,t)}})(),()=>{e.abort(),z.current=null}},[V,a,i,U]);let W=(0,l.useCallback)(()=>{B.current?.abort(),z.current=null,n(),A(null),P(!1),I(!1)},[n]),G=(0,l.useCallback)(()=>{I(!0),navigator.clipboard.writeText(H||``)},[H]),K=async()=>{try{if(R(!0),j&&await C?.({resources:[j]}),V){let e=await U(V);B.current?.signal.aborted||M(e)}}catch(e){console.error(`Error revoking shared conversation`,e)}finally{B.current?.signal.aborted||R(!1)}},q=(0,l.useCallback)(()=>(0,p.jsx)(d.Button,{buttonClassName:F?`text-button-secondary`:`text-button-primary`,iconBefore:F?(0,p.jsx)(f.IconCheck,{width:20,height:20}):(0,p.jsx)(f.IconCopy,{width:20,height:20}),title:F?v??`Copied`:_??`Copy link`,disabled:F,onClick:G}),[F,G,v,_]);return(0,p.jsxs)(d.Popup,{heading:m??`Share link`,portalId:`share`,size:d.PopUpSize.SM,dividers:r,onClose:W,closeButtonTitle:c??`Close`,children:[N?(0,p.jsxs)(`div`,{className:`share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0`,children:[O?(0,p.jsx)(d.InlineAlert,{type:d.InlineAlertType.Note,icon:(0,p.jsx)(f.IconInfoCircle,{width:16,height:16}),children:O}):null,e?.name?(0,p.jsxs)(`div`,{className:`share-info flex w-full`,children:[(0,p.jsx)(`p`,{className:`share-info-title body-1 mr-1 text-neutrals-800`,children:x??`Chat name:`}),(0,p.jsx)(`h3`,{className:`min-w-0 flex-1 truncate`,title:e?.name,children:e?.name})]}):null,(0,p.jsxs)(`div`,{className:`share-info flex`,children:[(0,p.jsx)(`p`,{className:`share-info-title body-1 mr-1 text-neutrals-800`,children:o??`Link expiration date:`}),(0,p.jsxs)(`h3`,{children:[`3 `,s??`days`]})]}),(0,p.jsx)($,{className:`min-h-[200px] self-center rounded border border-neutrals-600 p-2`,value:H,size:200}),(0,p.jsx)(`p`,{className:`body-2 text-neutrals-1000`,children:y??`Your name, special instructions, and any messages you add after sharing remain confidential.`}),(0,p.jsx)(d.InputWithIcon,{containerClasses:`share-input-container`,cssClass:`share-input`,readonly:!0,placeholder:H,value:H,inputId:`conversationLink`,iconAfterInput:q()})]}):(0,p.jsx)(`div`,{className:`flex items-center justify-center p-6`,children:(0,p.jsx)(d.Loader,{})}),N?e&&j?(0,p.jsx)(`div`,{className:`remove-access`,children:(0,p.jsx)(d.Button,{title:b??`Remove access to all users`,buttonClassName:`remove-access-button py-3 px-4`,isSmallButton:!0,disabled:L,onClick:K})}):(0,p.jsx)(`p`,{className:`body-2 share-footer text-neutrals-800`,children:u??`This chat has not been shared with anyone yet.`}):(0,p.jsx)(`div`,{})]})},be=({conversation:e,onCloseModal:t,renameConversation:n,locale:r})=>{let{titles:i,disableModalDividers:a,isSmallModalButton:o}=A(),[s,c]=(0,l.useState)(e?.name||``),u=e=>{c(e)},f=()=>{let t=`${e?.folderId}/${encodeURIComponent((0,h.getClearedConversationName)(s))}-${new Date().getTime()}`;n(`conversations/${e.id}`,`conversations/${t}`)};return(0,p.jsxs)(d.Popup,{heading:i?.renameTitle??`Rename conversation`,portalId:`rename-conversation`,containerClassName:`rename-conversation-popup`,size:d.PopUpSize.SM,dividers:!a,onClose:t,closeButtonTitle:i?.close??`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:r,children:(0,p.jsx)(d.Input,{inputId:`rename`,value:s,onChange:u,cssClass:`w-full`})}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:i?.cancel??`Cancel`,isSmallButton:o,onClick:e=>{e.stopPropagation(),t()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary text-button-primary`,title:i?.save??`Rename`,isSmallButton:o,disabled:!s,onClick:e=>{e.stopPropagation(),f()}})]})]})},xe=(0,l.createContext)(null);function Se({children:e,value:t}){return(0,p.jsx)(xe.Provider,{value:t,children:e})}function Ce(){let e=(0,l.useContext)(xe);if(!e)throw Error(`useConversationListActions must be used within ConversationListActionsProvider`);return e}var we=({conversation:e,triggerButton:t,isDisabled:n})=>{let r=A(),{locale:i,deleteConversation:a,renameConversation:o,getConversation:s,getFileBlob:c,shareConversationProps:u}=Ce(),f=(0,l.useMemo)(()=>{let t=[{key:_.DELETE,title:r?.titles?.delete??`Delete`,icon:r.actionsIcons?.[_.DELETE]}];return e?.model?.id?.endsWith(h.ONBOARDING_MODEL_POSTFIX)?t:[...e.isShared?[]:[{key:_.SHARE,title:r?.titles?.share??`Share`,icon:r.actionsIcons?.[_.SHARE]},{key:_.RENAME,title:r?.titles?.rename??`Rename`,icon:r.actionsIcons?.[_.RENAME]}],{key:_.EXPORT,title:r?.titles?.export??`Export`,icon:r.actionsIcons?.[_.EXPORT]},...t]},[e.isShared,e?.model?.id,r.titles,r.actionsIcons]),[m,g]=(0,l.useState)(d.PopUpState.Closed),[v,y]=(0,l.useState)(d.PopUpState.Closed),[b,x]=(0,l.useState)(d.PopUpState.Closed),S=(0,l.useCallback)(()=>{g(d.PopUpState.Closed)},[g]),C=(0,l.useCallback)(()=>{y(d.PopUpState.Closed)},[y]),w=(0,l.useCallback)(()=>{x(d.PopUpState.Closed)},[x]),T=(0,l.useCallback)(()=>{a(e),S()},[e,a,S]),E=(0,l.useCallback)((e,t)=>{o(e,t),w()},[o,w]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.Dropdown,{containerClassName:`ml-3 hidden group-hover:flex`,triggerButton:t??(0,p.jsx)(Te,{disabled:n}),options:f,openedClassName:`!flex action-menu-opened`,onOptionSelect:t=>{t===_.DELETE&&g(d.PopUpState.Opened),t===_.SHARE&&y(d.PopUpState.Opened),t===_.RENAME&&x(d.PopUpState.Opened),t===_.EXPORT&&s(decodeURI(e.id)).then(e=>{L(e,c).then(e=>{V(`data:application/zip;base64,${e}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})},disabled:n}),m===d.PopUpState.Opened&&(0,p.jsx)(j,{locale:i,deleteConversation:T,onCloseModal:S}),v===d.PopUpState.Opened&&(0,p.jsx)(ye,{conversation:e,locale:i,onCloseModal:C,...u}),b===d.PopUpState.Opened&&(0,p.jsx)(be,{conversation:e,locale:i,renameConversation:E,onCloseModal:w})]})},Te=({disabled:e})=>(0,p.jsx)(`div`,{className:(0,c.default)(`flex items-center justify-center w-[24px]`,e?`cursor-not-allowed`:`cursor-pointer`),children:(0,p.jsx)(f.IconDotsVertical,{width:20,height:20,stroke:2,className:`text-primary`})}),Ee=({conversation:e,selectedConversationId:t,searchQuery:n,onConversationClick:r,isDisabled:i})=>{let{titles:a,conversationItemIcon:o}=A(),s=(0,l.useRef)(null),u=(0,h.getClearedConversationName)(e?.name);return(0,l.useEffect)(()=>{if(e?.id===t&&s?.current){let e=s.current.parentElement?.parentElement?.parentElement;if(e){let t=s.current.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height,i=n.height,a=t.top-n.top+e.scrollTop-(i/2-r/2);e.scrollTo({top:a,behavior:`smooth`})}}},[e,t]),(0,p.jsxs)(`div`,{ref:s,className:(0,c.default)(`flex justify-between items-center py-2 px-3 border-transparent relative group border`,`conversation-item`,t===e?.id&&`bg-hues-100 conversation-item-active`,i?`cursor-not-allowed`:`cursor-pointer hover:border-hues-600`),onClick:()=>!i&&r(e.folderId,e?.id),title:i?a?.noActionsAllowed:u,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[o||null,(0,p.jsx)(`h3`,{className:(0,c.default)(`truncate font-semibold text-neutrals-1000 sm:body-2`,`conversation-item-text`,t===e?.id?`conversation-item-text-active`:``),title:i?a?.noActionsAllowed:u,children:n?.length?(0,p.jsx)(d.HighlightText,{text:u,highlightText:n}):u})]}),(0,p.jsx)(we,{conversation:e,isDisabled:i})]})},De=({handleConversationClick:e,selectedConversationId:t,groupLabel:n,groupedConversations:r,isDisabled:i})=>{let{titles:a}=A(),[o,s]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700`,onClick:(0,l.useCallback)(()=>{s(e=>!e)},[s]),children:[(0,p.jsx)(f.IconCaretRightFilled,{className:(0,c.default)(`w-3 h-3 conversation-group-items-arrow`,o?`rotate-[90deg]`:`rotate-0`)}),(0,p.jsx)(`span`,{className:`body-3 conversation-group-items-title-text`,children:O(n,a)})]}),!o&&(0,p.jsx)(`div`,{className:(0,c.default)(`flex flex-col gap-y-3`,`conversation-group-items`),children:D(r).map(n=>(0,p.jsx)(Ee,{isDisabled:i,conversation:n,selectedConversationId:t,onConversationClick:e},n.id||n.name))})]},n)},Oe=({searchQuery:e,isExpandedSearch:t,onSearchConversations:n,toggleSearchField:r})=>{let{titles:i,searchIcon:a}=A();return(0,p.jsx)(p.Fragment,{children:t?(0,p.jsx)(d.InputWithIcon,{inputId:`conversations-search`,placeholder:i?.searchPlaceholder??`Search`,containerClasses:`conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none`,cssClass:`h-auto`,value:e,iconAfterInput:(0,p.jsx)(d.IconButton,{buttonClassName:`text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5`,onClick:r,icon:(0,p.jsx)(f.IconX,{})}),onChange:n}):(0,p.jsx)(d.Button,{buttonClassName:`text-button-tertiary p-0 search-button`,iconBefore:a||(0,p.jsx)(f.IconSearch,{className:`size-5`}),onClick:r})})},ke=({conversations:e,selectedConversationId:t,searchQuery:n,handleConversationClick:r,isDisabled:i})=>{let{titles:a}=A(),[o,s]=(0,l.useState)([]);return(0,l.useEffect)(()=>{s(D(e?.filter(e=>(0,h.getClearedConversationName)(e?.name)?.includes(n||``))))},[e,n]),(0,p.jsx)(p.Fragment,{children:o?.length?o.map(e=>(0,p.jsx)(Ee,{conversation:e,searchQuery:n,selectedConversationId:t,onConversationClick:r,isDisabled:i},e.id)):(0,p.jsx)(`h3`,{className:`text-neutrals-800`,children:a?.noConversation??`No conversations yet`})})},Ae=()=>{let{titles:e}=A();return(0,p.jsxs)(`div`,{className:`flex flex-col p-8 text-center`,children:[(0,p.jsx)(`p`,{className:`text-neutrals-800`,children:e?.noConversation??`No conversations yet`}),(0,p.jsx)(`p`,{className:`mt-2 text-sm text-neutrals-800`,children:e?.clickNewChat??`Click "New Chat" to start a conversation`})]})},je=({handleConversationClick:e,selectedConversationId:t,actions:n,children:r,isCollapsed:i,isStreaming:a,conversationStyles:o,conversations:s,locale:u,sharedConversations:f,setConversations:m,setSharedConversations:_,shareConversationProps:v,handleSelectedConversationRemove:x})=>{let[S,C]=(0,l.useState)({}),[w,T]=(0,l.useState)(!0),[D,O]=(0,l.useState)(``),[A,j]=(0,l.useState)(!1),{getConversations:M,getSharedConversations:N,deleteConversation:P,renameConversation:F}=n,I=(0,l.useMemo)(()=>!!D?.length,[D]);(0,l.useEffect)(()=>{C({...b(f),...E(s)})},[s,f]),(0,l.useEffect)(()=>{async function e(){try{T(!0);let e=await M(u),t=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(e)),_((0,h.cleanConversationNames)(y(t,u)))}catch(e){console.error(`Error loading conversation`,e)}finally{T(!1)}}e()},[M,m,u,N,_]);let L=(0,l.useCallback)(async e=>{try{await P(e);let n=await M(u),r=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(n)),_((0,h.cleanConversationNames)(y(r,u))),t===e?.id&&x()}catch(e){console.error(`Error deleting conversation`,e)}},[P,M,u,N,m,_,t,x]),R=(0,l.useCallback)(async(e,t)=>{try{T(!0),await F(e,t);let n=await M(u),r=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(n)),_((0,h.cleanConversationNames)(y(r,u)))}catch(e){console.error(`Error renaming conversation`,e)}finally{T(!1)}},[M,u,N,m,_,F]),z=(0,l.useCallback)(e=>{O(e)},[O]),B=(0,l.useCallback)(()=>{j(e=>!e),O(``)},[j]);return w?(0,p.jsx)(d.Loader,{}):(0,p.jsx)(Se,{value:{locale:u,deleteConversation:L,renameConversation:R,getConversation:n.getConversation,getFileBlob:n.getFileBlob,shareConversationProps:v},children:(0,p.jsxs)(k.Provider,{value:o,children:[!i&&(0,p.jsxs)(`div`,{className:(0,c.default)(`flex justify-between items-center pr-6`,A?` pt-4 pb-0 sm:pt-10`:` pt-6 pb-2 sm:pt-10`),children:[!A&&(0,p.jsx)(`h3`,{className:`sm:body-2 text-neutrals-700`,children:o?.titles?.allChats??`All Chats`}),(0,p.jsx)(Oe,{searchQuery:D,isExpandedSearch:A,onSearchConversations:z,toggleSearchField:B})]}),(0,p.jsx)(`div`,{className:`scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0`,children:i?null:(0,p.jsx)(`div`,{className:(0,c.default)(`flex flex-col pr-4`,I?`gap-y-1`:`gap-y-6`),children:s?.length===0&&f?.length===0?(0,p.jsx)(Ae,{}):I?(0,p.jsx)(ke,{conversations:[...f,...s],searchQuery:D,selectedConversationId:t,handleConversationClick:e,isDisabled:a}):Object.entries(S).map(([n,r])=>r?.length>0&&(0,p.jsx)(De,{isDisabled:a,groupLabel:n,groupedConversations:r,handleConversationClick:e,selectedConversationId:t},n))})}),r]})})},Me=({onCloseModal:e,disableModalDividers:t,signOut:n,isSmallButton:r,locale:i,titles:a})=>(0,p.jsxs)(d.Popup,{heading:a?.popupTitle||`Log out?`,portalId:`sign-out`,containerClassName:`sign-out-popup`,size:d.PopUpSize.SM,dividers:!t,onClose:e,closeButtonTitle:`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:i,children:a?.popupText}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:a?.popupCancel||`Cancel`,isSmallButton:r,onClick:t=>{t.stopPropagation(),e()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary`,title:a?.popupApply||`Sign Out`,isSmallButton:r,onClick:e=>{e.stopPropagation(),n?.()}})]})]}),Ne=({userInfo:e,signOutAction:t,contactSupportUrl:n,styles:r,locale:i,titles:a})=>{let o=e=>e?.split(` `)?.map((e,t)=>t<2?e[0].toUpperCase():``)?.join(``)??``,s=(0,l.useMemo)(()=>e?.name?o(e?.name):e?.email?.[0].toUpperCase()??``,[e]),[u,f]=(0,l.useState)(!1),m=e?.name?.split(` `),h=m?`${m?.[0]??``} ${m?.[1]?.[0]?m?.[1]?.[0]+`.`:``}`:e?.email??``,g=(0,l.useCallback)(()=>{f(!0)},[]),_=(0,l.useCallback)(()=>{f(!1)},[]),v=(0,l.useCallback)(()=>{window.open(n||`#`,`_blank`,`noopener,noreferrer`)},[n]),y=(0,l.useMemo)(()=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:(0,c.default)(`cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0`,r?.initialStyles),children:s}),(0,p.jsx)(`p`,{className:(0,c.default)(`h3 cursor-pointer overflow-hidden text-ellipsis`,r?.userNameStyles),children:(r?.showShortName?h:e?.name)??e?.email??``})]}),[s,h,r,e]),b=(0,l.useMemo)(()=>(0,p.jsxs)(`div`,{className:(0,c.default)(`py-1`,r?.dropDownStyles),children:[r?.settingsIcon&&(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.settings,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.settingsIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.settings||`Settings`})]}),r?.contactSupportIcon&&(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.contactSupport,onClick:v,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.contactSupportIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.contactSupport||`Contact support`})]}),(0,p.jsx)(`div`,{className:(0,c.default)(`h-0 border-t border-neutrals-600 my-2`,r?.showSeparator?`block`:`hidden`)}),(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.signOut,onClick:g,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.signOutIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.signOut||`Sign out`}),u&&(0,p.jsx)(Me,{onCloseModal:_,signOut:()=>t?.(),locale:i,disableModalDividers:r?.disableModalDividers,titles:a})]})]}),[r,a,g,v,u,_,i,t]);if(e)return(0,p.jsx)(d.Dropdown,{containerClassName:(0,c.default)(`transition-opacity group-hover:opacity-100 shrink w-full`,r?.dropdownContainerClassName),triggerButton:y,content:b,openedClassName:`action-menu-opened`})};exports.ActionMenu=we,exports.ActionMenuItem=_,exports.ConversationList=je,exports.User=Ne,exports.getSharedConversationsGroup=b,exports.transformSharedConversations=y;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("classnames");c=s(c);let l=require("react");l=s(l);let u=require("lodash"),d=require("@epam/statgpt-ui-components"),f=require("@tabler/icons-react"),p=require("react/jsx-runtime"),m=require("jszip");m=s(m);let h=require("@epam/statgpt-shared-toolkit"),g=require("@epam/statgpt-dial-toolkit");var _=function(e){return e.DELETE=`delete`,e.EXPORT=`export`,e.SHARE=`share`,e.RENAME=`rename`,e}({}),v=function(e){return e.SHARED=`shared`,e.TODAY=`today`,e.YESTERDAY=`yesterday`,e.WEEK=`week`,e.EARLIER=`earlier`,e}({}),y=(e,t)=>e?.resources?.filter(e=>e?.parentPath===t)?.map(e=>{let n=`${e?.bucket}/${t}`,r=e?.url?.split(`/`)?.slice(1)?.join(`/`);return{...e,folderId:n,id:r,isShared:!0}})||[],b=e=>({[v.SHARED]:e}),x={[v.TODAY]:[],[v.YESTERDAY]:[],[v.WEEK]:[],[v.EARLIER]:[]},S=(e,t)=>e.toDateString()===t.toDateString(),C=(e,t)=>S(t,new Date(e.getFullYear(),e.getMonth(),e.getDate()-1)),w=(e,t)=>{let n=e.getTime()-t.getTime();return Math.floor(n/(1e3*60*60*24))},T=e=>e.updatedAt||Number(e.id?.split(`-`).pop()),E=e=>{let t=new Date,n=(0,u.cloneDeep)(x);for(let r of e)if(r.updatedAt){let e=new Date(r.updatedAt),i;i=S(t,e)?n[v.TODAY]:C(t,e)?n[v.YESTERDAY]:w(t,e)<=7?n[v.WEEK]:n[v.EARLIER],i?.some(e=>e.id===r.id)||i.push(r)}return n},D=e=>e?.sort((e,t)=>(T(t)||0)-(T(e)||0)),O=(e,t)=>e===v.SHARED?t?.shared||`Shared`:e===v.TODAY?t?.today||`Today`:e===v.YESTERDAY?t?.yesterday||`Yesterday`:e===v.WEEK?t?.lastWeek||`Last week`:t?.earlier||`Earlier`,k=(0,l.createContext)(null);function A(){let e=(0,l.useContext)(k);if(!e)throw Error(`useConversationStyles must be used within ConversationStylesContext.Provider`);return e}var j=({onCloseModal:e,deleteConversation:t,locale:n})=>{let{titles:r,disableModalDividers:i,isSmallModalButton:a}=A();return(0,p.jsxs)(d.Popup,{heading:r?.deleteTitle??`Delete conversation`,portalId:`delete-conversation`,containerClassName:`delete-conversation-popup`,size:d.PopUpSize.SM,dividers:!i,onClose:e,closeButtonTitle:r?.close??`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:n,children:r?.deleteMessage??`Are you sure you want to delete this conversation? This action cannot be undone.`}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:r?.cancel??`Cancel`,isSmallButton:a,onClick:t=>{t.stopPropagation(),e()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary text-button-primary-error`,title:r?.delete??`Delete`,isSmallButton:a,onClick:e=>{e.stopPropagation(),t()}})]})]})},M=e=>(0,u.uniqBy)(I((0,h.getConversationAttachments)(e)).map(e=>({...e,relativePath:``,contentLength:0})),e=>B(e.relativePath,e.name)),N=e=>e.endsWith(`/`),P=e=>{let t=e.toLowerCase();return[`data:`,`//`,`http://`,`https://`,`file://`,`ftp://`,`mailto:`,`telnet://`,`api/files`].some(e=>t.startsWith(e))},F=e=>{let t=B(...e.split(`/`).map(e=>decodeURIComponent(e))),n=t.lastIndexOf(`/`);return{absolutePath:t.slice(0,n),name:t.slice(n+1)}},I=e=>e?e.map(e=>{if(!e.url||P(e.url)||N(e.url))return null;let{absolutePath:t,name:n}=F(e.url);return{id:e.url,name:n,contentType:e.type,folderId:t,absolutePath:t}}).filter(Boolean):[];async function L(e,t){let n=M(e),r=new m.default;n.forEach(e=>{let n=t(`${encodeURI(B(e.absolutePath,e.name))}`.replace(`files/`,``)),i=B(`res`,R(e.folderId),e.name);r.file(i,n)});let i={version:5,history:[e].map(z)||[],folders:[]},a=JSON.stringify(i,null,2);return r.file(`conversations/conversations_history.json`,a),await r.generateAsync({type:`base64`})}var R=e=>{let t=e.split(`/`);return t.length>2?B(...t.slice(2)):void 0},z=e=>(0,u.omit)(e,[`publicationInfo`]),B=(...e)=>e.filter(Boolean).join(`/`);function V(e,t){let n=document.createElement(`a`);n.download=t,n.href=e,n.style.display=`none`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}var H=Object.defineProperty,U=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,K=(e,t,n)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||={})W.call(t,n)&&K(e,n,t[n]);if(U)for(var n of U(t))G.call(t,n)&&K(e,n,t[n]);return e},J=(e,t)=>{var n={};for(var r in e)W.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&U)for(var r of U(e))t.indexOf(r)<0&&G.call(e,r)&&(n[r]=e[r]);return n},Y;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};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(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(Y||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(Y||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(Y||={});var X=Y,ee={L:X.QrCode.Ecc.LOW,M:X.QrCode.Ecc.MEDIUM,Q:X.QrCode.Ecc.QUARTILE,H:X.QrCode.Ecc.HIGH},te=128,Z=`L`,Q=`#FFFFFF`,ne=`#000000`,re=!1,ie=1,ae=4,oe=0,se=.1;function ce(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function le(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ue(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*se),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function de(e,t){return t==null?e?ae:oe:Math.max(Math.floor(t),0)}function fe({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=l.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...X.QrSegment.makeSegments(t)),e),[]);return X.QrCode.encodeSegments(r,ee[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:u,margin:d,numCells:f,calculatedImageSettings:p}=l.default.useMemo(()=>{let e=c.getModules(),t=de(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ue(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:u,numCells:f,calculatedImageSettings:p}}var pe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),me=l.default.forwardRef(function(e,t){let n=e,{value:r,size:i=te,level:a=Z,bgColor:o=Q,fgColor:s=ne,includeMargin:c=re,minVersion:u=ie,boostLevel:d,marginSize:f,imageSettings:p}=n,m=J(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=J(m,[`style`]),_=p?.src,v=l.default.useRef(null),y=l.default.useRef(null),b=l.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=l.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=fe({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});l.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=le(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,pe?t.fill(new Path2D(ce(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),l.default.useEffect(()=>{S(!1)},[_]);let D=q({height:i,width:i},h),O=null;return _!=null&&(O=l.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),l.default.createElement(l.default.Fragment,null,l.default.createElement(`canvas`,q({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});me.displayName=`QRCodeCanvas`;var $=l.default.forwardRef(function(e,t){let n=e,{value:r,size:i=te,level:a=Z,bgColor:o=Q,fgColor:s=ne,includeMargin:c=re,minVersion:u=ie,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=J(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=fe({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=le(_,y.excavation)),x=l.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=ce(b,g);return l.default.createElement(`svg`,q({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&l.default.createElement(`title`,null,f),l.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),l.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});$.displayName=`QRCodeSVG`;var he=(e,t)=>({invitationType:g.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),ge=e=>`/${h.SHARE_CONVERSATION_ROUTE}/${e?.invitationLink?.split(`/`).at(-1)||``}`,_e=(e,t)=>t?.find(t=>{let n=e?.id?.split(`/`)?.pop(),r=t?.url?.split(`/`)?.pop()||``;return r===n||decodeURI(r)===n}),ve=e=>(e?.messages?.filter(e=>!!e?.custom_content?.attachments))?.flatMap(e=>e?.custom_content?.attachments?.map(e=>({url:e?.url||``}))||[])?.filter(e=>!!e?.url)||[],ye=({conversation:e,locale:t,onCloseModal:n,modalDividers:r,getConversation:i,generateConversationLink:a,chatExpiration:o,chatExpirationDays:s,close:c,chatWarning:u,shareLink:m,shareCopyLink:_,shareCopiedLink:v,shareDescription:y,shareRemoveAccessToUsers:b,chatName:x,getSharedConversations:S,revokeSharedConversations:C,baseUrl:w,id:T,clientSharedPage:E,clientSharedProp:D,shareAlertMessage:O})=>{let[k,A]=(0,l.useState)(null),[j,M]=(0,l.useState)(),[N,P]=(0,l.useState)(!1),[F,I]=(0,l.useState)(!1),[L,R]=(0,l.useState)(),z=(0,l.useRef)(null),B=(0,l.useRef)(null),V=(0,l.useMemo)(()=>e?.id?decodeURI(e.id):T?.[0]&&T?.[1]&&t?decodeURI(`${T[0]}/${t}/${T[1]}`):null,[e?.id,T,t]),H=(0,l.useMemo)(()=>{if(!k)return``;let e=w||window.location.origin;return w&&w!==window.location.origin&&E&&D?`${e}/${E}?${D}=${k.split(`/${h.SHARE_CONVERSATION_ROUTE}/`)?.[1]}`:`${e}/${t}${k}`},[w,k,t,E,D]),U=(0,l.useCallback)(async e=>{let t=await S?.((0,g.getSharedConversationsRequest)(g.ShareTarget.OTHERS));if(t)return _e({id:e},t.resources)},[S]);(0,l.useEffect)(()=>{if(!V||z.current===V)return;z.current=V,P(!1),B.current?.abort();let e=new AbortController;return B.current=e,(async()=>{try{let t=he(V,ve(await i?.(V))),n=await a?.(t),r=await U(V);if(e.signal.aborted||!n)return;A(ge(n)),M(r),P(!0)}catch(t){if(e.signal.aborted)return;P(!1),console.error(`Error sharing conversation`,t)}})(),()=>{e.abort(),z.current=null}},[V,a,i,U]);let W=(0,l.useCallback)(()=>{B.current?.abort(),z.current=null,n(),A(null),P(!1),I(!1)},[n]),G=(0,l.useCallback)(()=>{I(!0),navigator.clipboard.writeText(H||``)},[H]),K=async()=>{try{if(R(!0),j&&await C?.({resources:[j]}),V){let e=await U(V);B.current?.signal.aborted||M(e)}}catch(e){console.error(`Error revoking shared conversation`,e)}finally{B.current?.signal.aborted||R(!1)}},q=(0,l.useCallback)(()=>(0,p.jsx)(d.Button,{buttonClassName:F?`text-button-secondary`:`text-button-primary`,iconBefore:F?(0,p.jsx)(f.IconCheck,{width:20,height:20}):(0,p.jsx)(f.IconCopy,{width:20,height:20}),title:F?v??`Copied`:_??`Copy link`,disabled:F,onClick:G}),[F,G,v,_]);return(0,p.jsxs)(d.Popup,{heading:m??`Share link`,portalId:`share`,size:d.PopUpSize.SM,dividers:r,onClose:W,closeButtonTitle:c??`Close`,children:[N?(0,p.jsxs)(`div`,{className:`share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0`,children:[O?(0,p.jsx)(d.InlineAlert,{type:d.InlineAlertType.Note,icon:(0,p.jsx)(f.IconInfoCircle,{width:16,height:16}),children:O}):null,e?.name?(0,p.jsxs)(`div`,{className:`share-info flex w-full`,children:[(0,p.jsx)(`p`,{className:`share-info-title body-1 mr-1 text-neutrals-800`,children:x??`Chat name:`}),(0,p.jsx)(`h3`,{className:`min-w-0 flex-1 truncate`,title:e?.name,children:e?.name})]}):null,(0,p.jsxs)(`div`,{className:`share-info flex`,children:[(0,p.jsx)(`p`,{className:`share-info-title body-1 mr-1 text-neutrals-800`,children:o??`Link expiration date:`}),(0,p.jsxs)(`h3`,{children:[`3 `,s??`days`]})]}),(0,p.jsx)($,{className:`min-h-[200px] self-center rounded border border-neutrals-600 p-2`,value:H,size:200}),(0,p.jsx)(`p`,{className:`body-2 text-neutrals-1000`,children:y??`Your name, special instructions, and any messages you add after sharing remain confidential.`}),(0,p.jsx)(d.InputWithIcon,{containerClasses:`share-input-container`,cssClass:`share-input`,readonly:!0,placeholder:H,value:H,inputId:`conversationLink`,iconAfterInput:q()})]}):(0,p.jsx)(`div`,{className:`flex items-center justify-center p-6`,children:(0,p.jsx)(d.Loader,{})}),N?e&&j?(0,p.jsx)(`div`,{className:`remove-access`,children:(0,p.jsx)(d.Button,{title:b??`Remove access to all users`,buttonClassName:`remove-access-button py-3 px-4`,isSmallButton:!0,disabled:L,onClick:K})}):(0,p.jsx)(`p`,{className:`body-2 share-footer text-neutrals-800`,children:u??`This chat has not been shared with anyone yet.`}):(0,p.jsx)(`div`,{})]})},be=({conversation:e,onCloseModal:t,renameConversation:n,locale:r})=>{let{titles:i,disableModalDividers:a,isSmallModalButton:o}=A(),[s,c]=(0,l.useState)(e?.name||``),u=e=>{c(e)},f=()=>{let t=`${e?.folderId}/${encodeURIComponent((0,h.getClearedConversationName)(s))}-${new Date().getTime()}`;n(`conversations/${e.id}`,`conversations/${t}`)};return(0,p.jsxs)(d.Popup,{heading:i?.renameTitle??`Rename conversation`,portalId:`rename-conversation`,containerClassName:`rename-conversation-popup`,size:d.PopUpSize.SM,dividers:!a,onClose:t,closeButtonTitle:i?.close??`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:r,children:(0,p.jsx)(d.Input,{inputId:`rename`,value:s,onChange:u,cssClass:`w-full`})}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:i?.cancel??`Cancel`,isSmallButton:o,onClick:e=>{e.stopPropagation(),t()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary text-button-primary`,title:i?.save??`Rename`,isSmallButton:o,disabled:!s,onClick:e=>{e.stopPropagation(),f()}})]})]})},xe=(0,l.createContext)(null);function Se({children:e,value:t}){return(0,p.jsx)(xe.Provider,{value:t,children:e})}function Ce(){let e=(0,l.useContext)(xe);if(!e)throw Error(`useConversationListActions must be used within ConversationListActionsProvider`);return e}var we=({conversation:e,triggerButton:t,isDisabled:n})=>{let r=A(),{locale:i,deleteConversation:a,renameConversation:o,getConversation:s,getFileBlob:c,shareConversationProps:u}=Ce(),f=(0,l.useMemo)(()=>{let t=[{key:_.DELETE,title:r?.titles?.delete??`Delete`,icon:r.actionsIcons?.[_.DELETE]}];return e?.model?.id?.endsWith(h.ONBOARDING_MODEL_POSTFIX)?t:[...e.isShared?[]:[{key:_.SHARE,title:r?.titles?.share??`Share`,icon:r.actionsIcons?.[_.SHARE]},{key:_.RENAME,title:r?.titles?.rename??`Rename`,icon:r.actionsIcons?.[_.RENAME]}],{key:_.EXPORT,title:r?.titles?.export??`Export`,icon:r.actionsIcons?.[_.EXPORT]},...t]},[e.isShared,e?.model?.id,r.titles,r.actionsIcons]),[m,g]=(0,l.useState)(d.PopUpState.Closed),[v,y]=(0,l.useState)(d.PopUpState.Closed),[b,x]=(0,l.useState)(d.PopUpState.Closed),S=(0,l.useCallback)(()=>{g(d.PopUpState.Closed)},[g]),C=(0,l.useCallback)(()=>{y(d.PopUpState.Closed)},[y]),w=(0,l.useCallback)(()=>{x(d.PopUpState.Closed)},[x]),T=(0,l.useCallback)(()=>{a(e),S()},[e,a,S]),E=(0,l.useCallback)((e,t)=>{o(e,t),w()},[o,w]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.Dropdown,{containerClassName:`ml-3 hidden group-hover:flex`,triggerButton:t??(0,p.jsx)(Te,{disabled:n}),options:f,openedClassName:`!flex action-menu-opened`,onOptionSelect:t=>{t===_.DELETE&&g(d.PopUpState.Opened),t===_.SHARE&&y(d.PopUpState.Opened),t===_.RENAME&&x(d.PopUpState.Opened),t===_.EXPORT&&s(decodeURI(e.id)).then(e=>{L(e,c).then(e=>{V(`data:application/zip;base64,${e}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})},disabled:n}),m===d.PopUpState.Opened&&(0,p.jsx)(j,{locale:i,deleteConversation:T,onCloseModal:S}),v===d.PopUpState.Opened&&(0,p.jsx)(ye,{conversation:e,locale:i,onCloseModal:C,...u}),b===d.PopUpState.Opened&&(0,p.jsx)(be,{conversation:e,locale:i,renameConversation:E,onCloseModal:w})]})},Te=({disabled:e})=>(0,p.jsx)(`div`,{className:(0,c.default)(`flex items-center justify-center w-[24px]`,e?`cursor-not-allowed`:`cursor-pointer`),children:(0,p.jsx)(f.IconDotsVertical,{width:20,height:20,stroke:2,className:`text-primary`})}),Ee=({conversation:e,selectedConversationId:t,searchQuery:n,onConversationClick:r,isDisabled:i})=>{let{titles:a,conversationItemIcon:o}=A(),s=(0,l.useRef)(null),u=(0,h.getClearedConversationName)(e?.name);return(0,l.useEffect)(()=>{if(e?.id===t&&s?.current){let e=s.current.parentElement?.parentElement?.parentElement;if(e){let t=s.current.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height,i=n.height,a=t.top-n.top+e.scrollTop-(i/2-r/2);e.scrollTo({top:a,behavior:`smooth`})}}},[e,t]),(0,p.jsxs)(`div`,{ref:s,className:(0,c.default)(`flex justify-between items-center py-2 px-3 border-transparent relative group border`,`conversation-item`,t===e?.id&&`bg-hues-100 conversation-item-active`,i?`cursor-not-allowed`:`cursor-pointer hover:border-hues-600`),onClick:()=>!i&&r(e.folderId,e?.id),title:i?a?.noActionsAllowed:u,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[o||null,(0,p.jsx)(`h3`,{className:(0,c.default)(`truncate pb-px -mb-px font-semibold text-neutrals-1000 sm:body-2`,`conversation-item-text`,t===e?.id?`conversation-item-text-active`:``),title:i?a?.noActionsAllowed:u,children:n?.length?(0,p.jsx)(d.HighlightText,{text:u,highlightText:n}):u})]}),(0,p.jsx)(we,{conversation:e,isDisabled:i})]})},De=({handleConversationClick:e,selectedConversationId:t,groupLabel:n,groupedConversations:r,isDisabled:i})=>{let{titles:a}=A(),[o,s]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700`,onClick:(0,l.useCallback)(()=>{s(e=>!e)},[s]),children:[(0,p.jsx)(f.IconCaretRightFilled,{className:(0,c.default)(`w-3 h-3 conversation-group-items-arrow`,o?`rotate-[90deg]`:`rotate-0`)}),(0,p.jsx)(`span`,{className:`body-3 conversation-group-items-title-text`,children:O(n,a)})]}),!o&&(0,p.jsx)(`div`,{className:(0,c.default)(`flex flex-col gap-y-3`,`conversation-group-items`),children:D(r).map(n=>(0,p.jsx)(Ee,{isDisabled:i,conversation:n,selectedConversationId:t,onConversationClick:e},n.id||n.name))})]},n)},Oe=({searchQuery:e,isExpandedSearch:t,onSearchConversations:n,toggleSearchField:r})=>{let{titles:i,searchIcon:a}=A();return(0,p.jsx)(p.Fragment,{children:t?(0,p.jsx)(d.InputWithIcon,{inputId:`conversations-search`,placeholder:i?.searchPlaceholder??`Search`,containerClasses:`conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none`,cssClass:`h-auto`,value:e,iconAfterInput:(0,p.jsx)(d.IconButton,{buttonClassName:`text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5`,onClick:r,icon:(0,p.jsx)(f.IconX,{})}),onChange:n}):(0,p.jsx)(d.Button,{buttonClassName:`text-button-tertiary p-0 search-button`,iconBefore:a||(0,p.jsx)(f.IconSearch,{className:`size-5`}),onClick:r})})},ke=({conversations:e,selectedConversationId:t,searchQuery:n,handleConversationClick:r,isDisabled:i})=>{let{titles:a}=A(),[o,s]=(0,l.useState)([]);return(0,l.useEffect)(()=>{s(D(e?.filter(e=>(0,h.getClearedConversationName)(e?.name)?.includes(n||``))))},[e,n]),(0,p.jsx)(p.Fragment,{children:o?.length?o.map(e=>(0,p.jsx)(Ee,{conversation:e,searchQuery:n,selectedConversationId:t,onConversationClick:r,isDisabled:i},e.id)):(0,p.jsx)(`h3`,{className:`text-neutrals-800`,children:a?.noConversation??`No conversations yet`})})},Ae=()=>{let{titles:e}=A();return(0,p.jsxs)(`div`,{className:`flex flex-col p-8 text-center`,children:[(0,p.jsx)(`p`,{className:`text-neutrals-800`,children:e?.noConversation??`No conversations yet`}),(0,p.jsx)(`p`,{className:`mt-2 text-sm text-neutrals-800`,children:e?.clickNewChat??`Click "New Chat" to start a conversation`})]})},je=({handleConversationClick:e,selectedConversationId:t,actions:n,children:r,isCollapsed:i,isStreaming:a,conversationStyles:o,conversations:s,locale:u,sharedConversations:f,setConversations:m,setSharedConversations:_,shareConversationProps:v,handleSelectedConversationRemove:x})=>{let[S,C]=(0,l.useState)({}),[w,T]=(0,l.useState)(!0),[D,O]=(0,l.useState)(``),[A,j]=(0,l.useState)(!1),{getConversations:M,getSharedConversations:N,deleteConversation:P,renameConversation:F}=n,I=(0,l.useMemo)(()=>!!D?.length,[D]);(0,l.useEffect)(()=>{C({...b(f),...E(s)})},[s,f]),(0,l.useEffect)(()=>{async function e(){try{T(!0);let e=await M(u),t=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(e)),_((0,h.cleanConversationNames)(y(t,u)))}catch(e){console.error(`Error loading conversation`,e)}finally{T(!1)}}e()},[M,m,u,N,_]);let L=(0,l.useCallback)(async e=>{try{await P(e);let n=await M(u),r=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(n)),_((0,h.cleanConversationNames)(y(r,u))),t===e?.id&&x()}catch(e){console.error(`Error deleting conversation`,e)}},[P,M,u,N,m,_,t,x]),R=(0,l.useCallback)(async(e,t)=>{try{T(!0),await F(e,t);let n=await M(u),r=await N((0,g.getSharedConversationsRequest)(g.ShareTarget.ME));m((0,h.cleanConversationNames)(n)),_((0,h.cleanConversationNames)(y(r,u)))}catch(e){console.error(`Error renaming conversation`,e)}finally{T(!1)}},[M,u,N,m,_,F]),z=(0,l.useCallback)(e=>{O(e)},[O]),B=(0,l.useCallback)(()=>{j(e=>!e),O(``)},[j]);return w?(0,p.jsx)(d.Loader,{}):(0,p.jsx)(Se,{value:{locale:u,deleteConversation:L,renameConversation:R,getConversation:n.getConversation,getFileBlob:n.getFileBlob,shareConversationProps:v},children:(0,p.jsxs)(k.Provider,{value:o,children:[!i&&(0,p.jsxs)(`div`,{className:(0,c.default)(`flex justify-between items-center pr-6`,A?` pt-4 pb-0 sm:pt-10`:` pt-6 pb-2 sm:pt-10`),children:[!A&&(0,p.jsx)(`h3`,{className:`sm:body-2 text-neutrals-700`,children:o?.titles?.allChats??`All Chats`}),(0,p.jsx)(Oe,{searchQuery:D,isExpandedSearch:A,onSearchConversations:z,toggleSearchField:B})]}),(0,p.jsx)(`div`,{className:`scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0`,children:i?null:(0,p.jsx)(`div`,{className:(0,c.default)(`flex flex-col pr-4`,I?`gap-y-1`:`gap-y-6`),children:s?.length===0&&f?.length===0?(0,p.jsx)(Ae,{}):I?(0,p.jsx)(ke,{conversations:[...f,...s],searchQuery:D,selectedConversationId:t,handleConversationClick:e,isDisabled:a}):Object.entries(S).map(([n,r])=>r?.length>0&&(0,p.jsx)(De,{isDisabled:a,groupLabel:n,groupedConversations:r,handleConversationClick:e,selectedConversationId:t},n))})}),r]})})},Me=({onCloseModal:e,disableModalDividers:t,signOut:n,isSmallButton:r,locale:i,titles:a})=>(0,p.jsxs)(d.Popup,{heading:a?.popupTitle||`Log out?`,portalId:`sign-out`,containerClassName:`sign-out-popup`,size:d.PopUpSize.SM,dividers:!t,onClose:e,closeButtonTitle:`Cancel`,children:[(0,p.jsx)(`div`,{className:`px-6 py-4 sm:px-0`,lang:i,children:a?.popupText}),(0,p.jsxs)(`div`,{className:`delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3`,children:[(0,p.jsx)(d.Button,{buttonClassName:`cancel-button`,title:a?.popupCancel||`Cancel`,isSmallButton:r,onClick:t=>{t.stopPropagation(),e()}}),(0,p.jsx)(d.Button,{buttonClassName:`text-button-primary`,title:a?.popupApply||`Sign Out`,isSmallButton:r,onClick:e=>{e.stopPropagation(),n?.()}})]})]}),Ne=({userInfo:e,signOutAction:t,contactSupportUrl:n,styles:r,locale:i,titles:a})=>{let o=e=>e?.split(` `)?.map((e,t)=>t<2?e[0].toUpperCase():``)?.join(``)??``,s=(0,l.useMemo)(()=>e?.name?o(e?.name):e?.email?.[0].toUpperCase()??``,[e]),[u,f]=(0,l.useState)(!1),m=e?.name?.split(` `),h=m?`${m?.[0]??``} ${m?.[1]?.[0]?m?.[1]?.[0]+`.`:``}`:e?.email??``,g=(0,l.useCallback)(()=>{f(!0)},[]),_=(0,l.useCallback)(()=>{f(!1)},[]),v=(0,l.useCallback)(()=>{window.open(n||`#`,`_blank`,`noopener,noreferrer`)},[n]),y=(0,l.useMemo)(()=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:(0,c.default)(`cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0`,r?.initialStyles),children:s}),(0,p.jsx)(`p`,{className:(0,c.default)(`h3 cursor-pointer overflow-hidden text-ellipsis`,r?.userNameStyles),children:(r?.showShortName?h:e?.name)??e?.email??``})]}),[s,h,r,e]),b=(0,l.useMemo)(()=>(0,p.jsxs)(`div`,{className:(0,c.default)(`py-1`,r?.dropDownStyles),children:[r?.settingsIcon&&(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.settings,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.settingsIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.settings||`Settings`})]}),r?.contactSupportIcon&&(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.contactSupport,onClick:v,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.contactSupportIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.contactSupport||`Contact support`})]}),(0,p.jsx)(`div`,{className:(0,c.default)(`h-0 border-t border-neutrals-600 my-2`,r?.showSeparator?`block`:`hidden`)}),(0,p.jsxs)(`button`,{className:(0,c.default)(`p-2 items-center flex gap-1 text-primary fill-primary`,r?.dropdownButtonTypographyStyles||`body-1`,r?.dropdownButtonStyles),title:a?.signOut,onClick:g,children:[(0,p.jsx)(`span`,{className:`shrink-0`,children:r?.signOutIcon}),(0,p.jsx)(`span`,{className:`min-w-0 break-words`,children:a?.signOut||`Sign out`}),u&&(0,p.jsx)(Me,{onCloseModal:_,signOut:()=>t?.(),locale:i,disableModalDividers:r?.disableModalDividers,titles:a})]})]}),[r,a,g,v,u,_,i,t]);if(e)return(0,p.jsx)(d.Dropdown,{containerClassName:(0,c.default)(`transition-opacity group-hover:opacity-100 shrink w-full`,r?.dropdownContainerClassName),triggerButton:y,content:b,openedClassName:`action-menu-opened`})};exports.ActionMenu=we,exports.ActionMenuItem=_,exports.ConversationList=je,exports.User=Ne,exports.getSharedConversationsGroup=b,exports.transformSharedConversations=y;
|
package/index.mjs
CHANGED
|
@@ -1403,7 +1403,7 @@ var Xe = ({ conversation: e, triggerButton: t, isDisabled: n }) => {
|
|
|
1403
1403
|
children: [/* @__PURE__ */ N("div", {
|
|
1404
1404
|
className: "flex min-w-0 flex-1 items-center",
|
|
1405
1405
|
children: [l || null, /* @__PURE__ */ M("h3", {
|
|
1406
|
-
className: e("truncate font-semibold text-neutrals-1000 sm:body-2", "conversation-item-text", n === t?.id ? "conversation-item-text-active" : ""),
|
|
1406
|
+
className: e("truncate pb-px -mb-px font-semibold text-neutrals-1000 sm:body-2", "conversation-item-text", n === t?.id ? "conversation-item-text-active" : ""),
|
|
1407
1407
|
title: o ? c?.noActionsAllowed : d,
|
|
1408
1408
|
children: r?.length ? /* @__PURE__ */ M(m, {
|
|
1409
1409
|
text: d,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/statgpt-conversation-list",
|
|
3
|
-
"version": "0.7.0-dev.
|
|
3
|
+
"version": "0.7.0-dev.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@epam/statgpt-dial-toolkit": "0.7.0-dev.
|
|
7
|
-
"@epam/statgpt-shared-toolkit": "0.7.0-dev.
|
|
8
|
-
"@epam/statgpt-ui-components": "0.7.0-dev.
|
|
6
|
+
"@epam/statgpt-dial-toolkit": "0.7.0-dev.34",
|
|
7
|
+
"@epam/statgpt-shared-toolkit": "0.7.0-dev.34",
|
|
8
|
+
"@epam/statgpt-ui-components": "0.7.0-dev.34"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@epam/ai-dial-shared": "^0.43.3",
|