@epam/statgpt-conversation-list 0.5.0 → 0.6.0-rc.0

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