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