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