@epam/statgpt-conversation-list 0.3.0-rc.9 → 0.3.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.
- package/index.js +1 -1
- package/index.mjs +101 -106
- 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"),L=require("classnames"),m=require("react"),re=require("lodash"),v=require("@epam/statgpt-ui-components"),X=require("@tabler/icons-react"),Ae=require("jszip"),$=require("@epam/statgpt-dial-toolkit"),B=require("@epam/statgpt-shared-toolkit");var O=(s=>(s.DELETE="delete",s.EXPORT="export",s.SHARE="share",s.RENAME="rename",s))(O||{}),k=(s=>(s.SHARED="shared",s.TODAY="today",s.YESTERDAY="yesterday",s.WEEK="week",s.EARLIER="earlier",s))(k||{});const J=(s,r)=>s?.resources?.filter(o=>o?.parentPath===r)?.map(o=>{const l=`${o?.bucket}/${r}`,u=o?.url?.split("/")?.slice(1)?.join("/");return{...o,folderId:l,id:u,isShared:!0}})||[],ue=s=>({[k.SHARED]:s}),Ie={[k.TODAY]:[],[k.YESTERDAY]:[],[k.WEEK]:[],[k.EARLIER]:[]},de=(s,r)=>s.toDateString()===r.toDateString(),Pe=(s,r)=>{const o=new Date(s.getFullYear(),s.getMonth(),s.getDate()-1);return de(r,o)},je=(s,r)=>{const o=s.getTime()-r.getTime();return Math.floor(o/(1e3*60*60*24))},le=s=>s.updatedAt||Number(s.id?.split("-").pop()),Te=s=>{const r=new Date,o=re.cloneDeep(Ie);for(const l of s)if(l.updatedAt){const u=new Date(l.updatedAt);let d;de(r,u)?d=o[k.TODAY]:Pe(r,u)?d=o[k.YESTERDAY]:je(r,u)<=7?d=o[k.WEEK]:d=o[k.EARLIER],d?.some(f=>f.id===l.id)||d.push(l)}return o},he=s=>s?.sort((r,o)=>(le(o)||0)-(le(r)||0)),De=(s,r)=>s===k.SHARED?r?.shared||"Shared":s===k.TODAY?r?.today||"Today":s===k.YESTERDAY?r?.yesterday||"Yesterday":s===k.WEEK?r?.lastWeek||"Last week":r?.earlier||"Earlier",Oe=({onCloseModal:s,disableModalDividers:r,deleteConversation:o,isSmallButton:l,titles:u,locale:d})=>c.jsxs(v.Popup,{heading:u?.deleteTitle??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:v.PopUpSize.SM,dividers:!r,onClose:s,closeButtonTitle:u?.close??"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:d,children:u?.deleteMessage??"Are you sure you want to delete this conversation? This action cannot be undone."}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:u?.cancel??"Cancel",isSmallButton:l,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary text-button-primary-error",title:u?.delete??"Delete",isSmallButton:l,onClick:f=>{f.stopPropagation(),o()}})]})]}),Le=s=>{const r=s.messages.flatMap(l=>{const u=l.custom_content?.attachments||[],d=l.custom_content?.stages?.flatMap(({attachments:f})=>f??[])||[];return[...u,...d]})||[],o=Fe(r).map(l=>({...l,relativePath:"",contentLength:0}));return re.uniqBy(o,l=>K(l.relativePath,l.name))},ke=s=>s.endsWith("/"),Be=s=>{const r=s.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(o=>r.startsWith(o))},Ue=s=>{const r=K(...s.split("/").map(l=>decodeURIComponent(l))),o=r.lastIndexOf("/");return{absolutePath:r.slice(0,o),name:r.slice(o+1)}},Fe=s=>s?s.map(r=>{if(!r.url||Be(r.url)||ke(r.url))return null;const{absolutePath:o,name:l}=Ue(r.url);return{id:r.url,name:l,contentType:r.type,folderId:o,absolutePath:o}}).filter(Boolean):[];async function ze(s,r){const o=Le(s),l=new Ae;o.forEach(g=>{const e=encodeURI(K(g.absolutePath,g.name)),n=r(`${e}`.replace("files/","")),t=_e(g.folderId),a=K("res",t,g.name);l.file(a,n)});const u={version:5,history:[s].map($e)||[],folders:[]},d=JSON.stringify(u,null,2);return l.file("conversations/conversations_history.json",d),await l.generateAsync({type:"base64"})}const _e=s=>{const r=s.split("/");return r.length>2?K(...r.slice(2)):void 0},$e=s=>re.omit(s,["publicationInfo"]),K=(...s)=>s.filter(Boolean).join("/");function He(s,r){const o=document.createElement("a");o.download=r,o.href=s,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}var Ye=Object.defineProperty,ee=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,ce=(s,r,o)=>r in s?Ye(s,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[r]=o,se=(s,r)=>{for(var o in r||(r={}))pe.call(r,o)&&ce(s,o,r[o]);if(ee)for(var o of ee(r))me.call(r,o)&&ce(s,o,r[o]);return s},oe=(s,r)=>{var o={};for(var l in s)pe.call(s,l)&&r.indexOf(l)<0&&(o[l]=s[l]);if(s!=null&&ee)for(var l of ee(s))r.indexOf(l)<0&&me.call(s,l)&&(o[l]=s[l]);return o};var W;(s=>{const r=class w{constructor(e,n,t,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<w.MIN_VERSION||e>w.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 i=[];for(let h=0;h<this.size;h++)i.push(!1);for(let h=0;h<this.size;h++)this.modules.push(i.slice()),this.isFunction.push(i.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(t);if(this.drawCodewords(p),a==-1){let h=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const C=this.getPenaltyScore();C<h&&(a=x,h=C),this.applyMask(x)}}u(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(e,n){const t=s.QrSegment.makeSegments(e);return w.encodeSegments(t,n)}static encodeBinary(e,n){const t=s.QrSegment.makeBytes(e);return w.encodeSegments([t],n)}static encodeSegments(e,n,t=1,a=40,i=-1,p=!0){if(!(w.MIN_VERSION<=t&&t<=a&&a<=w.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");let h,x;for(h=t;;h++){const E=w.getNumDataCodewords(h,n)*8,R=f.getTotalBits(e,h);if(R<=E){x=R;break}if(h>=a)throw new RangeError("Data too long")}for(const E of[w.Ecc.MEDIUM,w.Ecc.QUARTILE,w.Ecc.HIGH])p&&x<=w.getNumDataCodewords(h,E)*8&&(n=E);let C=[];for(const E of e){o(E.mode.modeBits,4,C),o(E.numChars,E.mode.numCharCountBits(h),C);for(const R of E.getData())C.push(R)}u(C.length==x);const M=w.getNumDataCodewords(h,n)*8;u(C.length<=M),o(0,Math.min(4,M-C.length),C),o(0,(8-C.length%8)%8,C),u(C.length%8==0);for(let E=236;C.length<M;E^=253)o(E,8,C);let N=[];for(;N.length*8<C.length;)N.push(0);return C.forEach((E,R)=>N[R>>>3]|=E<<7-(R&7)),new w(h,n,N,i)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let t=0;t<n;t++)for(let a=0;a<n;a++)t==0&&a==0||t==0&&a==n-1||t==n-1&&a==0||this.drawAlignmentPattern(e[t],e[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let t=n;for(let i=0;i<10;i++)t=t<<1^(t>>>9)*1335;const a=(n<<10|t)^21522;u(a>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,l(a,i));this.setFunctionModule(8,7,l(a,6)),this.setFunctionModule(8,8,l(a,7)),this.setFunctionModule(7,8,l(a,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,l(a,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,l(a,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,l(a,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;u(n>>>18==0);for(let t=0;t<18;t++){const a=l(n,t),i=this.size-11+t%3,p=Math.floor(t/3);this.setFunctionModule(i,p,a),this.setFunctionModule(p,i,a)}}drawFinderPattern(e,n){for(let t=-4;t<=4;t++)for(let a=-4;a<=4;a++){const i=Math.max(Math.abs(a),Math.abs(t)),p=e+a,h=n+t;0<=p&&p<this.size&&0<=h&&h<this.size&&this.setFunctionModule(p,h,i!=2&&i!=4)}}drawAlignmentPattern(e,n){for(let t=-2;t<=2;t++)for(let a=-2;a<=2;a++)this.setFunctionModule(e+a,n+t,Math.max(Math.abs(a),Math.abs(t))!=1)}setFunctionModule(e,n,t){this.modules[n][e]=t,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,t=this.errorCorrectionLevel;if(e.length!=w.getNumDataCodewords(n,t))throw new RangeError("Invalid argument");const a=w.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n],i=w.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n],p=Math.floor(w.getNumRawDataModules(n)/8),h=a-p%a,x=Math.floor(p/a);let C=[];const M=w.reedSolomonComputeDivisor(i);for(let E=0,R=0;E<a;E++){let I=e.slice(R,R+x-i+(E<h?0:1));R+=I.length;const j=w.reedSolomonComputeRemainder(I,M);E<h&&I.push(0),C.push(I.concat(j))}let N=[];for(let E=0;E<C[0].length;E++)C.forEach((R,I)=>{(E!=x-i||I>=h)&&N.push(R[E])});return u(N.length==p),N}drawCodewords(e){if(e.length!=Math.floor(w.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let a=0;a<this.size;a++)for(let i=0;i<2;i++){const p=t-i,x=(t+1&2)==0?this.size-1-a:a;!this.isFunction[x][p]&&n<e.length*8&&(this.modules[x][p]=l(e[n>>>3],7-(n&7)),n++)}}u(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let t=0;t<this.size;t++){let a;switch(e){case 0:a=(t+n)%2==0;break;case 1:a=n%2==0;break;case 2:a=t%3==0;break;case 3:a=(t+n)%3==0;break;case 4:a=(Math.floor(t/3)+Math.floor(n/2))%2==0;break;case 5:a=t*n%2+t*n%3==0;break;case 6:a=(t*n%2+t*n%3)%2==0;break;case 7:a=((t+n)%2+t*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][t]&&a&&(this.modules[n][t]=!this.modules[n][t])}}getPenaltyScore(){let e=0;for(let i=0;i<this.size;i++){let p=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[i][C]==p?(h++,h==5?e+=w.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),p||(e+=this.finderPenaltyCountPatterns(x)*w.PENALTY_N3),p=this.modules[i][C],h=1);e+=this.finderPenaltyTerminateAndCount(p,h,x)*w.PENALTY_N3}for(let i=0;i<this.size;i++){let p=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][i]==p?(h++,h==5?e+=w.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),p||(e+=this.finderPenaltyCountPatterns(x)*w.PENALTY_N3),p=this.modules[C][i],h=1);e+=this.finderPenaltyTerminateAndCount(p,h,x)*w.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let p=0;p<this.size-1;p++){const h=this.modules[i][p];h==this.modules[i][p+1]&&h==this.modules[i+1][p]&&h==this.modules[i+1][p+1]&&(e+=w.PENALTY_N2)}let n=0;for(const i of this.modules)n=i.reduce((p,h)=>p+(h?1:0),n);const t=this.size*this.size,a=Math.ceil(Math.abs(n*20-t*10)/t)-1;return u(0<=a&&a<=9),e+=a*w.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let a=this.size-7;t.length<e;a-=n)t.splice(1,0,a);return t}}static getNumRawDataModules(e){if(e<w.MIN_VERSION||e>w.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return u(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(w.getNumRawDataModules(e)/8)-w.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*w.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let a=0;a<e-1;a++)n.push(0);n.push(1);let t=1;for(let a=0;a<e;a++){for(let i=0;i<n.length;i++)n[i]=w.reedSolomonMultiply(n[i],t),i+1<n.length&&(n[i]^=n[i+1]);t=w.reedSolomonMultiply(t,2)}return n}static reedSolomonComputeRemainder(e,n){let t=n.map(a=>0);for(const a of e){const i=a^t.shift();t.push(0),n.forEach((p,h)=>t[h]^=w.reedSolomonMultiply(p,i))}return t}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let t=0;for(let a=7;a>=0;a--)t=t<<1^(t>>>7)*285,t^=(n>>>a&1)*e;return u(t>>>8==0),t}finderPenaltyCountPatterns(e){const n=e[1];u(n<=this.size*3);const t=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(t&&e[0]>=n*4&&e[6]>=n?1:0)+(t&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,t){return e&&(this.finderPenaltyAddHistory(n,t),n=0),n+=this.size,this.finderPenaltyAddHistory(n,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=r;function o(g,e,n){if(e<0||e>31||g>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)n.push(g>>>t&1)}function l(g,e){return(g>>>e&1)!=0}function u(g){if(!g)throw new Error("Assertion error")}const d=class y{constructor(e,n,t){if(this.mode=e,this.numChars=n,this.bitData=t,n<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let n=[];for(const t of e)o(t,8,n);return new y(y.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const a=Math.min(e.length-t,3);o(parseInt(e.substring(t,t+a),10),a*3+1,n),t+=a}return new y(y.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],t;for(t=0;t+2<=e.length;t+=2){let a=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;a+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),o(a,11,n)}return t<e.length&&o(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new y(y.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)o(e,8,n);else if(e<16384)o(2,2,n),o(e,14,n);else if(e<1e6)o(6,3,n),o(e,21,n);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,n)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let t=0;for(const a of e){const i=a.mode.numCharCountBits(n);if(a.numChars>=1<<i)return 1/0;t+=4+i+a.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?n.push(e.charCodeAt(t)):(n.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return n}};d.NUMERIC_REGEX=/^[0-9]*$/,d.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,d.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let f=d;s.QrSegment=d})(W||(W={}));(s=>{(r=>{const o=class{constructor(u,d){this.ordinal=u,this.formatBits=d}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(s.QrCode||(s.QrCode={}))})(W||(W={}));(s=>{(r=>{const o=class{constructor(u,d){this.modeBits=u,this.numBitsCharCount=d}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(s.QrSegment||(s.QrSegment={}))})(W||(W={}));var V=W;var Qe={L:V.QrCode.Ecc.LOW,M:V.QrCode.Ecc.MEDIUM,Q:V.QrCode.Ecc.QUARTILE,H:V.QrCode.Ecc.HIGH},fe=128,ge="L",Ce="#FFFFFF",Ee="#000000",xe=!1,ve=1,Ge=4,We=0,Ve=.1;function we(s,r=0){const o=[];return s.forEach(function(l,u){let d=null;l.forEach(function(f,g){if(!f&&d!==null){o.push(`M${d+r} ${u+r}h${g-d}v1H${d+r}z`),d=null;return}if(g===l.length-1){if(!f)return;d===null?o.push(`M${g+r},${u+r} h1v1H${g+r}z`):o.push(`M${d+r},${u+r} h${g+1-d}v1H${d+r}z`);return}f&&d===null&&(d=g)})}),o.join("")}function Ne(s,r){return s.slice().map((o,l)=>l<r.y||l>=r.y+r.h?o:o.map((u,d)=>d<r.x||d>=r.x+r.w?u:!1))}function Xe(s,r,o,l){if(l==null)return null;const u=s.length+o*2,d=Math.floor(r*Ve),f=u/r,g=(l.width||d)*f,e=(l.height||d)*f,n=l.x==null?s.length/2-g/2:l.x*f,t=l.y==null?s.length/2-e/2:l.y*f,a=l.opacity==null?1:l.opacity;let i=null;if(l.excavate){let h=Math.floor(n),x=Math.floor(t),C=Math.ceil(g+n-h),M=Math.ceil(e+t-x);i={x:h,y:x,w:C,h:M}}const p=l.crossOrigin;return{x:n,y:t,h:e,w:g,excavation:i,opacity:a,crossOrigin:p}}function Ke(s,r){return r!=null?Math.max(Math.floor(r),0):s?Ge:We}function Re({value:s,level:r,minVersion:o,includeMargin:l,marginSize:u,imageSettings:d,size:f,boostLevel:g}){let e=m.useMemo(()=>{const h=(Array.isArray(s)?s:[s]).reduce((x,C)=>(x.push(...V.QrSegment.makeSegments(C)),x),[]);return V.QrCode.encodeSegments(h,Qe[r],o,void 0,void 0,g)},[s,r,o,g]);const{cells:n,margin:t,numCells:a,calculatedImageSettings:i}=m.useMemo(()=>{let p=e.getModules();const h=Ke(l,u),x=p.length+h*2,C=Xe(p,f,h,d);return{cells:p,margin:h,numCells:x,calculatedImageSettings:C}},[e,f,d,l,u]);return{qrcode:e,margin:t,cells:n,numCells:a,calculatedImageSettings:i}}var qe=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ze=m.forwardRef(function(r,o){const l=r,{value:u,size:d=fe,level:f=ge,bgColor:g=Ce,fgColor:e=Ee,includeMargin:n=xe,minVersion:t=ve,boostLevel:a,marginSize:i,imageSettings:p}=l,x=oe(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=x,M=oe(x,["style"]),N=p?.src,E=m.useRef(null),R=m.useRef(null),I=m.useCallback(U=>{E.current=U,typeof o=="function"?o(U):o&&(o.current=U)},[o]),[j,b]=m.useState(!1),{margin:T,cells:F,numCells:z,calculatedImageSettings:P}=Re({value:u,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:i,imageSettings:p,size:d});m.useEffect(()=>{if(E.current!=null){const U=E.current,S=U.getContext("2d");if(!S)return;let A=F;const D=R.current,Q=P!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;Q&&P.excavation!=null&&(A=Ne(F,P.excavation));const q=window.devicePixelRatio||1;U.height=U.width=d*q;const Z=d/z*q;S.scale(Z,Z),S.fillStyle=g,S.fillRect(0,0,z,z),S.fillStyle=e,qe?S.fill(new Path2D(we(A,T))):F.forEach(function(G,H){G.forEach(function(te,ne){te&&S.fillRect(ne+T,H+T,1,1)})}),P&&(S.globalAlpha=P.opacity),Q&&S.drawImage(D,P.x+T,P.y+T,P.w,P.h)}}),m.useEffect(()=>{b(!1)},[N]);const _=se({height:d,width:d},C);let Y=null;return N!=null&&(Y=m.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{b(!0)},ref:R,crossOrigin:P?.crossOrigin})),m.createElement(m.Fragment,null,m.createElement("canvas",se({style:_,height:d,width:d,ref:I,role:"img"},M)),Y)});Ze.displayName="QRCodeCanvas";var Me=m.forwardRef(function(r,o){const l=r,{value:u,size:d=fe,level:f=ge,bgColor:g=Ce,fgColor:e=Ee,includeMargin:n=xe,minVersion:t=ve,boostLevel:a,title:i,marginSize:p,imageSettings:h}=l,x=oe(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:M,numCells:N,calculatedImageSettings:E}=Re({value:u,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:p,imageSettings:h,size:d});let R=M,I=null;h!=null&&E!=null&&(E.excavation!=null&&(R=Ne(M,E.excavation)),I=m.createElement("image",{href:h.src,height:E.h,width:E.w,x:E.x+C,y:E.y+C,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const j=we(R,C);return m.createElement("svg",se({height:d,width:d,viewBox:`0 0 ${N} ${N}`,ref:o,role:"img"},x),!!i&&m.createElement("title",null,i),m.createElement("path",{fill:g,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),m.createElement("path",{fill:e,d:j,shapeRendering:"crispEdges"}),I)});Me.displayName="QRCodeSVG";const Je=(s,r)=>({invitationType:$.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(s)}`},...r]}),et=s=>{const r=s?.invitationLink?.split("/").at(-1)||"";return`/${B.SHARE_CONVERSATION_ROUTE}/${r}`},tt=(s,r)=>r?.find(o=>{const l=s?.id?.split("/")?.pop(),u=o?.url?.split("/")?.pop()||"";return u===l||decodeURI(u)===l}),nt=s=>s?.messages?.filter(o=>!!o?.custom_content?.attachments)?.flatMap(o=>o?.custom_content?.attachments?.map(l=>({url:l?.url||""}))||[])?.filter(o=>!!o?.url)||[],st=({conversation:s,locale:r,onCloseModal:o,modalDividers:l,getConversation:u,generateConversationLink:d,chatExpiration:f,chatExpirationDays:g,close:e,chatWarning:n,shareLink:t,shareCopyLink:a,shareCopiedLink:i,shareDescription:p,shareRemoveAccessToUsers:h,chatName:x,getSharedConversations:C,revokeSharedConversations:M,baseUrl:N,id:E,clientSharedPage:R,clientSharedProp:I})=>{const[j,b]=m.useState(null),[T,F]=m.useState(),[z,P]=m.useState(!1),[_,Y]=m.useState(!1),[U,S]=m.useState(),A=m.useMemo(()=>{const G=N||window.location.origin;if(N&&N!==window.location.origin&&R&&I){const H=j?.split(`/${B.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${G}/${R}?${I}=${H}`}return`${G}/${r}${j}`},[N,j,r,R,I]);m.useEffect(()=>{(async()=>{try{const H=decodeURI(s?s?.id:`${E?.[0]}/${r}/${E?.[1]}`),te=`${decodeURI(H)}`,ne=await u?.(te),ye=Je(H,nt(ne)),ae=await d?.(ye),ie=await C?.($.getSharedConversationsRequest($.ShareTarget.OTHERS));ae&&ie&&(P(!0),b(et(ae)),F(tt(s,ie?.resources)))}catch(H){P(!1),console.error("Error sharing conversation",H)}})()},[s,d,u,C,E,r]);const D=m.useCallback(()=>{o(),b(null),P(!1),Y(!1)},[o]),Q=m.useCallback(()=>{Y(!0),navigator.clipboard.writeText(A||"")},[A]),q=async()=>{try{S(!0),T&&await M?.({resources:[T]})}catch(G){S(!1),console.error("Error revoking shared conversation",G)}},Z=m.useCallback(()=>c.jsx(v.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:_?i??"Copied":a??"Copy link",disabled:_,onClick:Q}),[_,Q,i,a]);return c.jsxs(v.Popup,{heading:t??"Share link",portalId:"share",size:v.PopUpSize.SM,dividers:l,onClose:D,closeButtonTitle:e??"Close",children:[z?c.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[s?.name?c.jsxs("div",{className:"flex share-info w-full",children:[c.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:x??"Chat name:"}),c.jsx("h3",{className:"flex-1 min-w-0 truncate",title:s?.name,children:s?.name})]}):null,c.jsxs("div",{className:"flex share-info",children:[c.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:f??"Link expiration date:"}),c.jsxs("h3",{children:["3 ",g??"days"]})]}),c.jsx(Me,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:A,size:200}),c.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),c.jsx(v.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:A,value:A,inputId:"conversationLink",iconAfterInput:Z()})]}):c.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:c.jsx(v.Loader,{})}),z?s&&T?c.jsx("div",{className:"remove-access",children:c.jsx(v.Button,{title:h??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:U,onClick:q})}):c.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:n??"This chat has not been shared with anyone yet."}):c.jsx("div",{})]})},ot=({conversation:s,onCloseModal:r,renameConversation:o,locale:l,disableModalDividers:u,titles:d,isSmallButton:f})=>{const[g,e]=m.useState(s?.name||""),n=a=>{e(a)},t=()=>{const a=`${s?.folderId}/${encodeURIComponent(B.getClearedConversationName(g))}-${new Date().getTime()}`;o(`conversations/${s.id}`,`conversations/${a}`)};return c.jsxs(v.Popup,{heading:d?.renameTitle??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:v.PopUpSize.SM,dividers:!u,onClose:r,closeButtonTitle:d?.close??"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:l,children:c.jsx(v.Input,{inputId:"rename",value:g,onChange:n,cssClass:"w-full"})}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:d?.cancel??"Cancel",isSmallButton:f,onClick:a=>{a.stopPropagation(),r()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary text-button-primary",title:d?.save??"Rename",isSmallButton:f,disabled:!g,onClick:a=>{a.stopPropagation(),t()}})]})]})},Se=({conversation:s,conversationStyles:r,shareConversationProps:o,onConversationDelete:l,getConversation:u,getFileBlob:d,renameConversation:f,triggerButton:g,locale:e,isDisabled:n})=>{const t=m.useMemo(()=>{const b=[{key:O.DELETE,title:r?.titles?.delete??"Delete",icon:r.actionsIcons?.[O.DELETE]}];return s?.model?.id?.endsWith(B.ONBOARDING_MODEL_POSTFIX)?b:[...s.isShared?[]:[{key:O.SHARE,title:r?.titles?.share??"Share",icon:r.actionsIcons?.[O.SHARE]},{key:O.RENAME,title:r?.titles?.rename??"Rename",icon:r.actionsIcons?.[O.RENAME]}],{key:O.EXPORT,title:r?.titles?.export??"Export",icon:r.actionsIcons?.[O.EXPORT]},...b]},[s.isShared,s?.model?.id,r.titles,r.actionsIcons]),[a,i]=m.useState(v.PopUpState.Closed),[p,h]=m.useState(v.PopUpState.Closed),[x,C]=m.useState(v.PopUpState.Closed),M=m.useCallback(()=>{i(v.PopUpState.Closed)},[i]),N=m.useCallback(()=>{h(v.PopUpState.Closed)},[h]),E=m.useCallback(()=>{C(v.PopUpState.Closed)},[C]),R=m.useCallback(()=>{l(s),M()},[s,l,M]),I=m.useCallback((b,T)=>{f(b,T),E()},[f,E]),j=b=>{b===O.DELETE&&i(v.PopUpState.Opened),b===O.SHARE&&h(v.PopUpState.Opened),b===O.RENAME&&C(v.PopUpState.Opened),b===O.EXPORT&&u(decodeURI(s.id)).then(T=>{ze(T,d).then(F=>{He(`data:application/zip;base64,${F}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return c.jsxs(c.Fragment,{children:[c.jsx(v.Dropdown,{containerClassName:"ml-3 group-hover:visible invisible",triggerButton:g??c.jsx(rt,{disabled:n}),options:t,openedClassName:"action-menu-opened",onOptionSelect:j,disabled:n}),a===v.PopUpState.Opened&&c.jsx(Oe,{titles:r.titles,locale:e,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton,deleteConversation:R,onCloseModal:M}),p===v.PopUpState.Opened&&c.jsx(st,{conversation:s,locale:e,onCloseModal:N,...o}),x===v.PopUpState.Opened&&c.jsx(ot,{conversation:s,locale:e,titles:r.titles,renameConversation:I,onCloseModal:E,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton})]})},rt=({disabled:s})=>c.jsx("div",{className:L("flex items-center justify-center w-[24px]",s?"cursor-not-allowed":"cursor-pointer"),children:c.jsx(X.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),be=({conversation:s,selectedConversationId:r,searchQuery:o,onConversationClick:l,actions:u,locale:d,isDisabled:f,conversationStyles:g,shareConversationProps:e})=>{const n=m.useRef(null),t=B.getClearedConversationName(s?.name);return m.useEffect(()=>{if(s?.id===r&&n?.current){const a=n.current.parentElement?.parentElement?.parentElement;if(a){const i=n.current.getBoundingClientRect(),p=a.getBoundingClientRect(),h=i.height,x=p.height,M=i.top-p.top+a.scrollTop-(x/2-h/2);a.scrollTo({top:M,behavior:"smooth"})}}},[s,r]),c.jsxs("div",{ref:n,className:L("flex justify-between items-center py-2 px-3 border-transparent relative group border","conversation-item",r===s?.id&&"bg-hues-100 conversation-item-active",f?"cursor-not-allowed":"cursor-pointer hover:border-hues-600"),onClick:()=>!f&&l(s.folderId,s?.id),title:f?g?.titles?.noActionsAllowed:t,children:[c.jsxs("div",{className:"flex flex-1 min-w-0 items-center",children:[g.conversationItemIcon?g.conversationItemIcon:null,c.jsx("h3",{className:L("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",r===s?.id?"conversation-item-text-active":""),title:f?g?.titles?.noActionsAllowed:t,children:o?.length?c.jsx(v.HighlightText,{text:t,highlightText:o}):t})]}),c.jsx(Se,{locale:d,conversationStyles:g,conversation:s,onConversationDelete:u.deleteConversation,getConversation:u.getConversation,getFileBlob:u.getFileBlob,renameConversation:u.renameConversation,shareConversationProps:e,isDisabled:f})]})},at=({handleConversationClick:s,actions:r,selectedConversationId:o,groupLabel:l,conversationStyles:u,groupedConversations:d,shareConversationProps:f,locale:g,isDisabled:e})=>{const[n,t]=m.useState(!1),a=m.useCallback(()=>{t(i=>!i)},[t]);return c.jsxs("div",{children:[c.jsxs("div",{className:"inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",onClick:a,children:[c.jsx(X.IconCaretRightFilled,{className:L("w-3 h-3 conversation-group-items-arrow",n?"rotate-[90deg]":"rotate-0")}),c.jsx("span",{className:"body-3 conversation-group-items-title-text",children:De(l,u?.titles)})]}),!n&&c.jsx("div",{className:L("flex flex-col gap-y-3","conversation-group-items"),children:he(d).map(i=>c.jsx(be,{locale:g,isDisabled:e,conversationStyles:u,conversation:i,selectedConversationId:o,onConversationClick:s,actions:r,shareConversationProps:f},i.id||i.name))})]},l)},it=({searchQuery:s,isExpandedSearch:r,titles:o,searchIcon:l,onSearchConversations:u,toggleSearchField:d})=>c.jsx(c.Fragment,{children:r?c.jsx(v.InputWithIcon,{inputId:"conversations-search",placeholder:o?.searchPlaceholder??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:s,iconAfterInput:c.jsx(v.IconButton,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:d,icon:c.jsx(X.IconX,{})}),onChange:u}):c.jsx(v.Button,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:l||c.jsx(X.IconSearch,{className:"w-5 h-5"}),onClick:d})}),lt=({conversations:s,selectedConversationId:r,searchQuery:o,conversationStyles:l,handleConversationClick:u,actions:d,locale:f,shareConversationProps:g})=>{const[e,n]=m.useState([]);return m.useEffect(()=>{n(he(s?.filter(t=>B.getClearedConversationName(t?.name)?.includes(o||""))))},[s,o]),c.jsx(c.Fragment,{children:e?.length?e.map(t=>c.jsx(be,{locale:f,conversationStyles:l,conversation:t,searchQuery:o,selectedConversationId:r,onConversationClick:u,actions:d,shareConversationProps:g},t.id)):c.jsx("h3",{className:"text-neutrals-800",children:l?.titles?.noConversation??"No conversations yet"})})},ct=({titles:s})=>c.jsxs("div",{className:"p-8 text-center flex flex-col",children:[c.jsx("p",{className:"text-neutrals-800",children:s?.noConversation??"No conversations yet"}),c.jsx("p",{className:"text-sm text-neutrals-800 mt-2",children:s?.clickNewChat??'Click "New Chat" to start a conversation'})]}),ut=({handleConversationClick:s,selectedConversationId:r,actions:o,children:l,isCollapsed:u,isStreaming:d,conversationStyles:f,conversations:g,locale:e,sharedConversations:n,setConversations:t,setSharedConversations:a,shareConversationProps:i,handleSelectedConversationRemove:p})=>{const[h,x]=m.useState({}),[C,M]=m.useState(!0),[N,E]=m.useState(""),[R,I]=m.useState(!1),{getConversations:j,getSharedConversations:b,deleteConversation:T,renameConversation:F}=o,z=m.useMemo(()=>!!N?.length,[N]);m.useEffect(()=>{x({...ue(n),...Te(g)})},[g,n]),m.useEffect(()=>{async function S(){try{M(!0);const A=await j(e),D=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(A)),a(B.cleanConversationNames(J(D,e)))}catch(A){console.error("Error loading conversation",A)}finally{M(!1)}}S()},[j,t,e,b,a]);const P=m.useCallback(async S=>{try{await T(S);const A=await j(e),D=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(A)),a(B.cleanConversationNames(J(D,e))),r===S?.id&&p()}catch(A){console.error("Error deleting conversation",A)}},[T,j,e,b,t,a,r,p]),_=m.useCallback(async(S,A)=>{try{M(!0),await F(S,A);const D=await j(e),Q=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(D)),a(B.cleanConversationNames(J(Q,e)))}catch(D){console.error("Error renaming conversation",D)}finally{M(!1)}},[j,e,b,t,a,F]),Y=m.useCallback(S=>{E(S)},[E]),U=m.useCallback(()=>{I(S=>!S),E("")},[I]);return C?c.jsx(v.Loader,{}):c.jsxs(c.Fragment,{children:[!u&&c.jsxs("div",{className:L("flex justify-between items-center",R?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!R&&c.jsx("h3",{className:"text-neutrals-700 sm:body-2",children:f?.titles?.allChats??"All Chats"}),c.jsx(it,{searchQuery:N,searchIcon:f.searchIcon,titles:f.titles,isExpandedSearch:R,onSearchConversations:Y,toggleSearchField:U})]}),c.jsx("div",{className:L("scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",z?"gap-y-1":"gap-y-6"),children:u?null:c.jsx(c.Fragment,{children:g?.length===0&&n?.length===0?c.jsx(ct,{titles:f.titles}):z?c.jsx(lt,{locale:e,conversationStyles:f,conversations:[...n,...g],searchQuery:N,selectedConversationId:r,handleConversationClick:s,shareConversationProps:i,actions:{...o,deleteConversation:P}}):Object.entries(h).map(([S,A])=>A?.length>0&&c.jsx(at,{locale:e,isDisabled:d,groupLabel:S,conversationStyles:f,groupedConversations:A,handleConversationClick:s,actions:{...o,deleteConversation:P,renameConversation:_},shareConversationProps:i,selectedConversationId:r},S))})}),l]})},dt=({onCloseModal:s,disableModalDividers:r,signOut:o,isSmallButton:l,locale:u,titles:d})=>c.jsxs(v.Popup,{heading:d?.popupTitle||"Log out?",portalId:"sign-out",containerClassName:"sign-out-popup",size:v.PopUpSize.SM,dividers:!r,onClose:s,closeButtonTitle:"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:u,children:d?.popupText}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:d?.popupCancel||"Cancel",isSmallButton:l,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary",title:d?.popupApply||"Sign Out",isSmallButton:l,onClick:f=>{f.stopPropagation(),o?.()}})]})]}),ht=({userInfo:s,signOutAction:r,styles:o,locale:l,titles:u})=>{const d=x=>x?.split(" ")?.map((C,M)=>M<2?C[0].toUpperCase():"")?.join("")??"",f=m.useMemo(()=>s?.name?d(s?.name):s?.email?.[0].toUpperCase()??"",[s]),[g,e]=m.useState(!1),n=s?.name?.split(" "),t=n?`${n?.[0]??""} ${n?.[1]?.[0]?n?.[1]?.[0]+".":""}`:s?.email??"",a=m.useCallback(()=>{e(!0)},[]),i=m.useCallback(()=>{e(!1)},[]),p=m.useMemo(()=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:L("cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",o?.initialStyles),children:f}),c.jsx("p",{className:L("h3 cursor-pointer overflow-hidden text-ellipsis",o?.userNameStyles),children:(o?.showShortName?t:s?.name)??s?.email??""})]}),[f,t,o,s]),h=m.useMemo(()=>c.jsxs("div",{className:L("py-1",o?.dropDownStyles),children:[o?.settingsIcon&&c.jsxs("button",{className:L("p-2 items-center flex gap-1 text-primary fill-primary body-1",o?.dropdownButtonStyles),title:u?.settings,children:[o?.settingsIcon,u?.settings||"Settings"]}),c.jsx("div",{className:L("h-0 border-t border-neutrals-600 my-2",o?.showSeparator?"block":"hidden")}),c.jsxs("button",{className:L("p-2 items-center flex gap-1 text-primary fill-primary body-1",o?.dropdownButtonStyles),title:u?.signOut,onClick:a,children:[o?.signOutIcon,u?.signOut||"Sign out",g&&c.jsx(dt,{onCloseModal:i,signOut:()=>r?.(),locale:l,disableModalDividers:o?.disableModalDividers,titles:u})]})]}),[o,u,a,g,i,l,r]);if(s)return c.jsx(v.Dropdown,{containerClassName:L("transition-opacity group-hover:opacity-100 shrink w-full",o?.dropdownContainerClassName),triggerButton:p,content:h,openedClassName:"action-menu-opened"})};exports.ActionMenu=Se;exports.ActionMenuItem=O;exports.ConversationList=ut;exports.User=ht;exports.getSharedConversationsGroup=ue;exports.transformSharedConversations=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),L=require("classnames"),m=require("react"),re=require("lodash"),v=require("@epam/statgpt-ui-components"),X=require("@tabler/icons-react"),Ae=require("jszip"),B=require("@epam/statgpt-shared-toolkit"),$=require("@epam/statgpt-dial-toolkit");var O=(s=>(s.DELETE="delete",s.EXPORT="export",s.SHARE="share",s.RENAME="rename",s))(O||{}),k=(s=>(s.SHARED="shared",s.TODAY="today",s.YESTERDAY="yesterday",s.WEEK="week",s.EARLIER="earlier",s))(k||{});const J=(s,r)=>s?.resources?.filter(o=>o?.parentPath===r)?.map(o=>{const l=`${o?.bucket}/${r}`,u=o?.url?.split("/")?.slice(1)?.join("/");return{...o,folderId:l,id:u,isShared:!0}})||[],ue=s=>({[k.SHARED]:s}),Ie={[k.TODAY]:[],[k.YESTERDAY]:[],[k.WEEK]:[],[k.EARLIER]:[]},de=(s,r)=>s.toDateString()===r.toDateString(),Pe=(s,r)=>{const o=new Date(s.getFullYear(),s.getMonth(),s.getDate()-1);return de(r,o)},je=(s,r)=>{const o=s.getTime()-r.getTime();return Math.floor(o/(1e3*60*60*24))},le=s=>s.updatedAt||Number(s.id?.split("-").pop()),Te=s=>{const r=new Date,o=re.cloneDeep(Ie);for(const l of s)if(l.updatedAt){const u=new Date(l.updatedAt);let d;de(r,u)?d=o[k.TODAY]:Pe(r,u)?d=o[k.YESTERDAY]:je(r,u)<=7?d=o[k.WEEK]:d=o[k.EARLIER],d?.some(f=>f.id===l.id)||d.push(l)}return o},he=s=>s?.sort((r,o)=>(le(o)||0)-(le(r)||0)),De=(s,r)=>s===k.SHARED?r?.shared||"Shared":s===k.TODAY?r?.today||"Today":s===k.YESTERDAY?r?.yesterday||"Yesterday":s===k.WEEK?r?.lastWeek||"Last week":r?.earlier||"Earlier",Oe=({onCloseModal:s,disableModalDividers:r,deleteConversation:o,isSmallButton:l,titles:u,locale:d})=>c.jsxs(v.Popup,{heading:u?.deleteTitle??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:v.PopUpSize.SM,dividers:!r,onClose:s,closeButtonTitle:u?.close??"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:d,children:u?.deleteMessage??"Are you sure you want to delete this conversation? This action cannot be undone."}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:u?.cancel??"Cancel",isSmallButton:l,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary text-button-primary-error",title:u?.delete??"Delete",isSmallButton:l,onClick:f=>{f.stopPropagation(),o()}})]})]}),Le=s=>{const r=Fe(B.getConversationAttachments(s)).map(o=>({...o,relativePath:"",contentLength:0}));return re.uniqBy(r,o=>K(o.relativePath,o.name))},ke=s=>s.endsWith("/"),Be=s=>{const r=s.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(o=>r.startsWith(o))},Ue=s=>{const r=K(...s.split("/").map(l=>decodeURIComponent(l))),o=r.lastIndexOf("/");return{absolutePath:r.slice(0,o),name:r.slice(o+1)}},Fe=s=>s?s.map(r=>{if(!r.url||Be(r.url)||ke(r.url))return null;const{absolutePath:o,name:l}=Ue(r.url);return{id:r.url,name:l,contentType:r.type,folderId:o,absolutePath:o}}).filter(Boolean):[];async function ze(s,r){const o=Le(s),l=new Ae;o.forEach(g=>{const e=encodeURI(K(g.absolutePath,g.name)),n=r(`${e}`.replace("files/","")),t=_e(g.folderId),a=K("res",t,g.name);l.file(a,n)});const u={version:5,history:[s].map($e)||[],folders:[]},d=JSON.stringify(u,null,2);return l.file("conversations/conversations_history.json",d),await l.generateAsync({type:"base64"})}const _e=s=>{const r=s.split("/");return r.length>2?K(...r.slice(2)):void 0},$e=s=>re.omit(s,["publicationInfo"]),K=(...s)=>s.filter(Boolean).join("/");function He(s,r){const o=document.createElement("a");o.download=r,o.href=s,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}var Ye=Object.defineProperty,ee=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,ce=(s,r,o)=>r in s?Ye(s,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[r]=o,se=(s,r)=>{for(var o in r||(r={}))pe.call(r,o)&&ce(s,o,r[o]);if(ee)for(var o of ee(r))me.call(r,o)&&ce(s,o,r[o]);return s},oe=(s,r)=>{var o={};for(var l in s)pe.call(s,l)&&r.indexOf(l)<0&&(o[l]=s[l]);if(s!=null&&ee)for(var l of ee(s))r.indexOf(l)<0&&me.call(s,l)&&(o[l]=s[l]);return o};var W;(s=>{const r=class w{constructor(e,n,t,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<w.MIN_VERSION||e>w.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 i=[];for(let h=0;h<this.size;h++)i.push(!1);for(let h=0;h<this.size;h++)this.modules.push(i.slice()),this.isFunction.push(i.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(t);if(this.drawCodewords(p),a==-1){let h=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const C=this.getPenaltyScore();C<h&&(a=x,h=C),this.applyMask(x)}}u(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(e,n){const t=s.QrSegment.makeSegments(e);return w.encodeSegments(t,n)}static encodeBinary(e,n){const t=s.QrSegment.makeBytes(e);return w.encodeSegments([t],n)}static encodeSegments(e,n,t=1,a=40,i=-1,p=!0){if(!(w.MIN_VERSION<=t&&t<=a&&a<=w.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");let h,x;for(h=t;;h++){const E=w.getNumDataCodewords(h,n)*8,R=f.getTotalBits(e,h);if(R<=E){x=R;break}if(h>=a)throw new RangeError("Data too long")}for(const E of[w.Ecc.MEDIUM,w.Ecc.QUARTILE,w.Ecc.HIGH])p&&x<=w.getNumDataCodewords(h,E)*8&&(n=E);let C=[];for(const E of e){o(E.mode.modeBits,4,C),o(E.numChars,E.mode.numCharCountBits(h),C);for(const R of E.getData())C.push(R)}u(C.length==x);const M=w.getNumDataCodewords(h,n)*8;u(C.length<=M),o(0,Math.min(4,M-C.length),C),o(0,(8-C.length%8)%8,C),u(C.length%8==0);for(let E=236;C.length<M;E^=253)o(E,8,C);let N=[];for(;N.length*8<C.length;)N.push(0);return C.forEach((E,R)=>N[R>>>3]|=E<<7-(R&7)),new w(h,n,N,i)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let t=0;t<n;t++)for(let a=0;a<n;a++)t==0&&a==0||t==0&&a==n-1||t==n-1&&a==0||this.drawAlignmentPattern(e[t],e[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let t=n;for(let i=0;i<10;i++)t=t<<1^(t>>>9)*1335;const a=(n<<10|t)^21522;u(a>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,l(a,i));this.setFunctionModule(8,7,l(a,6)),this.setFunctionModule(8,8,l(a,7)),this.setFunctionModule(7,8,l(a,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,l(a,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,l(a,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,l(a,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;u(n>>>18==0);for(let t=0;t<18;t++){const a=l(n,t),i=this.size-11+t%3,p=Math.floor(t/3);this.setFunctionModule(i,p,a),this.setFunctionModule(p,i,a)}}drawFinderPattern(e,n){for(let t=-4;t<=4;t++)for(let a=-4;a<=4;a++){const i=Math.max(Math.abs(a),Math.abs(t)),p=e+a,h=n+t;0<=p&&p<this.size&&0<=h&&h<this.size&&this.setFunctionModule(p,h,i!=2&&i!=4)}}drawAlignmentPattern(e,n){for(let t=-2;t<=2;t++)for(let a=-2;a<=2;a++)this.setFunctionModule(e+a,n+t,Math.max(Math.abs(a),Math.abs(t))!=1)}setFunctionModule(e,n,t){this.modules[n][e]=t,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,t=this.errorCorrectionLevel;if(e.length!=w.getNumDataCodewords(n,t))throw new RangeError("Invalid argument");const a=w.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n],i=w.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n],p=Math.floor(w.getNumRawDataModules(n)/8),h=a-p%a,x=Math.floor(p/a);let C=[];const M=w.reedSolomonComputeDivisor(i);for(let E=0,R=0;E<a;E++){let I=e.slice(R,R+x-i+(E<h?0:1));R+=I.length;const j=w.reedSolomonComputeRemainder(I,M);E<h&&I.push(0),C.push(I.concat(j))}let N=[];for(let E=0;E<C[0].length;E++)C.forEach((R,I)=>{(E!=x-i||I>=h)&&N.push(R[E])});return u(N.length==p),N}drawCodewords(e){if(e.length!=Math.floor(w.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let a=0;a<this.size;a++)for(let i=0;i<2;i++){const p=t-i,x=(t+1&2)==0?this.size-1-a:a;!this.isFunction[x][p]&&n<e.length*8&&(this.modules[x][p]=l(e[n>>>3],7-(n&7)),n++)}}u(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let t=0;t<this.size;t++){let a;switch(e){case 0:a=(t+n)%2==0;break;case 1:a=n%2==0;break;case 2:a=t%3==0;break;case 3:a=(t+n)%3==0;break;case 4:a=(Math.floor(t/3)+Math.floor(n/2))%2==0;break;case 5:a=t*n%2+t*n%3==0;break;case 6:a=(t*n%2+t*n%3)%2==0;break;case 7:a=((t+n)%2+t*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][t]&&a&&(this.modules[n][t]=!this.modules[n][t])}}getPenaltyScore(){let e=0;for(let i=0;i<this.size;i++){let p=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[i][C]==p?(h++,h==5?e+=w.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),p||(e+=this.finderPenaltyCountPatterns(x)*w.PENALTY_N3),p=this.modules[i][C],h=1);e+=this.finderPenaltyTerminateAndCount(p,h,x)*w.PENALTY_N3}for(let i=0;i<this.size;i++){let p=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][i]==p?(h++,h==5?e+=w.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),p||(e+=this.finderPenaltyCountPatterns(x)*w.PENALTY_N3),p=this.modules[C][i],h=1);e+=this.finderPenaltyTerminateAndCount(p,h,x)*w.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let p=0;p<this.size-1;p++){const h=this.modules[i][p];h==this.modules[i][p+1]&&h==this.modules[i+1][p]&&h==this.modules[i+1][p+1]&&(e+=w.PENALTY_N2)}let n=0;for(const i of this.modules)n=i.reduce((p,h)=>p+(h?1:0),n);const t=this.size*this.size,a=Math.ceil(Math.abs(n*20-t*10)/t)-1;return u(0<=a&&a<=9),e+=a*w.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let a=this.size-7;t.length<e;a-=n)t.splice(1,0,a);return t}}static getNumRawDataModules(e){if(e<w.MIN_VERSION||e>w.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return u(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(w.getNumRawDataModules(e)/8)-w.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*w.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let a=0;a<e-1;a++)n.push(0);n.push(1);let t=1;for(let a=0;a<e;a++){for(let i=0;i<n.length;i++)n[i]=w.reedSolomonMultiply(n[i],t),i+1<n.length&&(n[i]^=n[i+1]);t=w.reedSolomonMultiply(t,2)}return n}static reedSolomonComputeRemainder(e,n){let t=n.map(a=>0);for(const a of e){const i=a^t.shift();t.push(0),n.forEach((p,h)=>t[h]^=w.reedSolomonMultiply(p,i))}return t}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let t=0;for(let a=7;a>=0;a--)t=t<<1^(t>>>7)*285,t^=(n>>>a&1)*e;return u(t>>>8==0),t}finderPenaltyCountPatterns(e){const n=e[1];u(n<=this.size*3);const t=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(t&&e[0]>=n*4&&e[6]>=n?1:0)+(t&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,t){return e&&(this.finderPenaltyAddHistory(n,t),n=0),n+=this.size,this.finderPenaltyAddHistory(n,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=r;function o(g,e,n){if(e<0||e>31||g>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)n.push(g>>>t&1)}function l(g,e){return(g>>>e&1)!=0}function u(g){if(!g)throw new Error("Assertion error")}const d=class y{constructor(e,n,t){if(this.mode=e,this.numChars=n,this.bitData=t,n<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let n=[];for(const t of e)o(t,8,n);return new y(y.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const a=Math.min(e.length-t,3);o(parseInt(e.substring(t,t+a),10),a*3+1,n),t+=a}return new y(y.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],t;for(t=0;t+2<=e.length;t+=2){let a=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;a+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),o(a,11,n)}return t<e.length&&o(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new y(y.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)o(e,8,n);else if(e<16384)o(2,2,n),o(e,14,n);else if(e<1e6)o(6,3,n),o(e,21,n);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,n)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let t=0;for(const a of e){const i=a.mode.numCharCountBits(n);if(a.numChars>=1<<i)return 1/0;t+=4+i+a.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?n.push(e.charCodeAt(t)):(n.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return n}};d.NUMERIC_REGEX=/^[0-9]*$/,d.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,d.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let f=d;s.QrSegment=d})(W||(W={}));(s=>{(r=>{const o=class{constructor(u,d){this.ordinal=u,this.formatBits=d}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(s.QrCode||(s.QrCode={}))})(W||(W={}));(s=>{(r=>{const o=class{constructor(u,d){this.modeBits=u,this.numBitsCharCount=d}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(s.QrSegment||(s.QrSegment={}))})(W||(W={}));var V=W;var Qe={L:V.QrCode.Ecc.LOW,M:V.QrCode.Ecc.MEDIUM,Q:V.QrCode.Ecc.QUARTILE,H:V.QrCode.Ecc.HIGH},fe=128,ge="L",Ce="#FFFFFF",Ee="#000000",xe=!1,ve=1,Ge=4,We=0,Ve=.1;function we(s,r=0){const o=[];return s.forEach(function(l,u){let d=null;l.forEach(function(f,g){if(!f&&d!==null){o.push(`M${d+r} ${u+r}h${g-d}v1H${d+r}z`),d=null;return}if(g===l.length-1){if(!f)return;d===null?o.push(`M${g+r},${u+r} h1v1H${g+r}z`):o.push(`M${d+r},${u+r} h${g+1-d}v1H${d+r}z`);return}f&&d===null&&(d=g)})}),o.join("")}function Ne(s,r){return s.slice().map((o,l)=>l<r.y||l>=r.y+r.h?o:o.map((u,d)=>d<r.x||d>=r.x+r.w?u:!1))}function Xe(s,r,o,l){if(l==null)return null;const u=s.length+o*2,d=Math.floor(r*Ve),f=u/r,g=(l.width||d)*f,e=(l.height||d)*f,n=l.x==null?s.length/2-g/2:l.x*f,t=l.y==null?s.length/2-e/2:l.y*f,a=l.opacity==null?1:l.opacity;let i=null;if(l.excavate){let h=Math.floor(n),x=Math.floor(t),C=Math.ceil(g+n-h),M=Math.ceil(e+t-x);i={x:h,y:x,w:C,h:M}}const p=l.crossOrigin;return{x:n,y:t,h:e,w:g,excavation:i,opacity:a,crossOrigin:p}}function Ke(s,r){return r!=null?Math.max(Math.floor(r),0):s?Ge:We}function Re({value:s,level:r,minVersion:o,includeMargin:l,marginSize:u,imageSettings:d,size:f,boostLevel:g}){let e=m.useMemo(()=>{const h=(Array.isArray(s)?s:[s]).reduce((x,C)=>(x.push(...V.QrSegment.makeSegments(C)),x),[]);return V.QrCode.encodeSegments(h,Qe[r],o,void 0,void 0,g)},[s,r,o,g]);const{cells:n,margin:t,numCells:a,calculatedImageSettings:i}=m.useMemo(()=>{let p=e.getModules();const h=Ke(l,u),x=p.length+h*2,C=Xe(p,f,h,d);return{cells:p,margin:h,numCells:x,calculatedImageSettings:C}},[e,f,d,l,u]);return{qrcode:e,margin:t,cells:n,numCells:a,calculatedImageSettings:i}}var qe=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ze=m.forwardRef(function(r,o){const l=r,{value:u,size:d=fe,level:f=ge,bgColor:g=Ce,fgColor:e=Ee,includeMargin:n=xe,minVersion:t=ve,boostLevel:a,marginSize:i,imageSettings:p}=l,x=oe(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=x,M=oe(x,["style"]),N=p?.src,E=m.useRef(null),R=m.useRef(null),I=m.useCallback(U=>{E.current=U,typeof o=="function"?o(U):o&&(o.current=U)},[o]),[j,b]=m.useState(!1),{margin:T,cells:F,numCells:z,calculatedImageSettings:P}=Re({value:u,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:i,imageSettings:p,size:d});m.useEffect(()=>{if(E.current!=null){const U=E.current,S=U.getContext("2d");if(!S)return;let A=F;const D=R.current,Q=P!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;Q&&P.excavation!=null&&(A=Ne(F,P.excavation));const q=window.devicePixelRatio||1;U.height=U.width=d*q;const Z=d/z*q;S.scale(Z,Z),S.fillStyle=g,S.fillRect(0,0,z,z),S.fillStyle=e,qe?S.fill(new Path2D(we(A,T))):F.forEach(function(G,H){G.forEach(function(te,ne){te&&S.fillRect(ne+T,H+T,1,1)})}),P&&(S.globalAlpha=P.opacity),Q&&S.drawImage(D,P.x+T,P.y+T,P.w,P.h)}}),m.useEffect(()=>{b(!1)},[N]);const _=se({height:d,width:d},C);let Y=null;return N!=null&&(Y=m.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{b(!0)},ref:R,crossOrigin:P?.crossOrigin})),m.createElement(m.Fragment,null,m.createElement("canvas",se({style:_,height:d,width:d,ref:I,role:"img"},M)),Y)});Ze.displayName="QRCodeCanvas";var Me=m.forwardRef(function(r,o){const l=r,{value:u,size:d=fe,level:f=ge,bgColor:g=Ce,fgColor:e=Ee,includeMargin:n=xe,minVersion:t=ve,boostLevel:a,title:i,marginSize:p,imageSettings:h}=l,x=oe(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:M,numCells:N,calculatedImageSettings:E}=Re({value:u,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:p,imageSettings:h,size:d});let R=M,I=null;h!=null&&E!=null&&(E.excavation!=null&&(R=Ne(M,E.excavation)),I=m.createElement("image",{href:h.src,height:E.h,width:E.w,x:E.x+C,y:E.y+C,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const j=we(R,C);return m.createElement("svg",se({height:d,width:d,viewBox:`0 0 ${N} ${N}`,ref:o,role:"img"},x),!!i&&m.createElement("title",null,i),m.createElement("path",{fill:g,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),m.createElement("path",{fill:e,d:j,shapeRendering:"crispEdges"}),I)});Me.displayName="QRCodeSVG";const Je=(s,r)=>({invitationType:$.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(s)}`},...r]}),et=s=>{const r=s?.invitationLink?.split("/").at(-1)||"";return`/${B.SHARE_CONVERSATION_ROUTE}/${r}`},tt=(s,r)=>r?.find(o=>{const l=s?.id?.split("/")?.pop(),u=o?.url?.split("/")?.pop()||"";return u===l||decodeURI(u)===l}),nt=s=>s?.messages?.filter(o=>!!o?.custom_content?.attachments)?.flatMap(o=>o?.custom_content?.attachments?.map(l=>({url:l?.url||""}))||[])?.filter(o=>!!o?.url)||[],st=({conversation:s,locale:r,onCloseModal:o,modalDividers:l,getConversation:u,generateConversationLink:d,chatExpiration:f,chatExpirationDays:g,close:e,chatWarning:n,shareLink:t,shareCopyLink:a,shareCopiedLink:i,shareDescription:p,shareRemoveAccessToUsers:h,chatName:x,getSharedConversations:C,revokeSharedConversations:M,baseUrl:N,id:E,clientSharedPage:R,clientSharedProp:I})=>{const[j,b]=m.useState(null),[T,F]=m.useState(),[z,P]=m.useState(!1),[_,Y]=m.useState(!1),[U,S]=m.useState(),A=m.useMemo(()=>{const G=N||window.location.origin;if(N&&N!==window.location.origin&&R&&I){const H=j?.split(`/${B.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${G}/${R}?${I}=${H}`}return`${G}/${r}${j}`},[N,j,r,R,I]);m.useEffect(()=>{(async()=>{try{const H=decodeURI(s?s?.id:`${E?.[0]}/${r}/${E?.[1]}`),te=`${decodeURI(H)}`,ne=await u?.(te),ye=Je(H,nt(ne)),ae=await d?.(ye),ie=await C?.($.getSharedConversationsRequest($.ShareTarget.OTHERS));ae&&ie&&(P(!0),b(et(ae)),F(tt(s,ie?.resources)))}catch(H){P(!1),console.error("Error sharing conversation",H)}})()},[s,d,u,C,E,r]);const D=m.useCallback(()=>{o(),b(null),P(!1),Y(!1)},[o]),Q=m.useCallback(()=>{Y(!0),navigator.clipboard.writeText(A||"")},[A]),q=async()=>{try{S(!0),T&&await M?.({resources:[T]})}catch(G){S(!1),console.error("Error revoking shared conversation",G)}},Z=m.useCallback(()=>c.jsx(v.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:_?i??"Copied":a??"Copy link",disabled:_,onClick:Q}),[_,Q,i,a]);return c.jsxs(v.Popup,{heading:t??"Share link",portalId:"share",size:v.PopUpSize.SM,dividers:l,onClose:D,closeButtonTitle:e??"Close",children:[z?c.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[s?.name?c.jsxs("div",{className:"flex share-info w-full",children:[c.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:x??"Chat name:"}),c.jsx("h3",{className:"flex-1 min-w-0 truncate",title:s?.name,children:s?.name})]}):null,c.jsxs("div",{className:"flex share-info",children:[c.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:f??"Link expiration date:"}),c.jsxs("h3",{children:["3 ",g??"days"]})]}),c.jsx(Me,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:A,size:200}),c.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),c.jsx(v.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:A,value:A,inputId:"conversationLink",iconAfterInput:Z()})]}):c.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:c.jsx(v.Loader,{})}),z?s&&T?c.jsx("div",{className:"remove-access",children:c.jsx(v.Button,{title:h??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:U,onClick:q})}):c.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:n??"This chat has not been shared with anyone yet."}):c.jsx("div",{})]})},ot=({conversation:s,onCloseModal:r,renameConversation:o,locale:l,disableModalDividers:u,titles:d,isSmallButton:f})=>{const[g,e]=m.useState(s?.name||""),n=a=>{e(a)},t=()=>{const a=`${s?.folderId}/${encodeURIComponent(B.getClearedConversationName(g))}-${new Date().getTime()}`;o(`conversations/${s.id}`,`conversations/${a}`)};return c.jsxs(v.Popup,{heading:d?.renameTitle??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:v.PopUpSize.SM,dividers:!u,onClose:r,closeButtonTitle:d?.close??"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:l,children:c.jsx(v.Input,{inputId:"rename",value:g,onChange:n,cssClass:"w-full"})}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:d?.cancel??"Cancel",isSmallButton:f,onClick:a=>{a.stopPropagation(),r()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary text-button-primary",title:d?.save??"Rename",isSmallButton:f,disabled:!g,onClick:a=>{a.stopPropagation(),t()}})]})]})},Se=({conversation:s,conversationStyles:r,shareConversationProps:o,onConversationDelete:l,getConversation:u,getFileBlob:d,renameConversation:f,triggerButton:g,locale:e,isDisabled:n})=>{const t=m.useMemo(()=>{const b=[{key:O.DELETE,title:r?.titles?.delete??"Delete",icon:r.actionsIcons?.[O.DELETE]}];return s?.model?.id?.endsWith(B.ONBOARDING_MODEL_POSTFIX)?b:[...s.isShared?[]:[{key:O.SHARE,title:r?.titles?.share??"Share",icon:r.actionsIcons?.[O.SHARE]},{key:O.RENAME,title:r?.titles?.rename??"Rename",icon:r.actionsIcons?.[O.RENAME]}],{key:O.EXPORT,title:r?.titles?.export??"Export",icon:r.actionsIcons?.[O.EXPORT]},...b]},[s.isShared,s?.model?.id,r.titles,r.actionsIcons]),[a,i]=m.useState(v.PopUpState.Closed),[p,h]=m.useState(v.PopUpState.Closed),[x,C]=m.useState(v.PopUpState.Closed),M=m.useCallback(()=>{i(v.PopUpState.Closed)},[i]),N=m.useCallback(()=>{h(v.PopUpState.Closed)},[h]),E=m.useCallback(()=>{C(v.PopUpState.Closed)},[C]),R=m.useCallback(()=>{l(s),M()},[s,l,M]),I=m.useCallback((b,T)=>{f(b,T),E()},[f,E]),j=b=>{b===O.DELETE&&i(v.PopUpState.Opened),b===O.SHARE&&h(v.PopUpState.Opened),b===O.RENAME&&C(v.PopUpState.Opened),b===O.EXPORT&&u(decodeURI(s.id)).then(T=>{ze(T,d).then(F=>{He(`data:application/zip;base64,${F}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return c.jsxs(c.Fragment,{children:[c.jsx(v.Dropdown,{containerClassName:"ml-3 group-hover:visible invisible",triggerButton:g??c.jsx(rt,{disabled:n}),options:t,openedClassName:"action-menu-opened",onOptionSelect:j,disabled:n}),a===v.PopUpState.Opened&&c.jsx(Oe,{titles:r.titles,locale:e,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton,deleteConversation:R,onCloseModal:M}),p===v.PopUpState.Opened&&c.jsx(st,{conversation:s,locale:e,onCloseModal:N,...o}),x===v.PopUpState.Opened&&c.jsx(ot,{conversation:s,locale:e,titles:r.titles,renameConversation:I,onCloseModal:E,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton})]})},rt=({disabled:s})=>c.jsx("div",{className:L("flex items-center justify-center w-[24px]",s?"cursor-not-allowed":"cursor-pointer"),children:c.jsx(X.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),be=({conversation:s,selectedConversationId:r,searchQuery:o,onConversationClick:l,actions:u,locale:d,isDisabled:f,conversationStyles:g,shareConversationProps:e})=>{const n=m.useRef(null),t=B.getClearedConversationName(s?.name);return m.useEffect(()=>{if(s?.id===r&&n?.current){const a=n.current.parentElement?.parentElement?.parentElement;if(a){const i=n.current.getBoundingClientRect(),p=a.getBoundingClientRect(),h=i.height,x=p.height,M=i.top-p.top+a.scrollTop-(x/2-h/2);a.scrollTo({top:M,behavior:"smooth"})}}},[s,r]),c.jsxs("div",{ref:n,className:L("flex justify-between items-center py-2 px-3 border-transparent relative group border","conversation-item",r===s?.id&&"bg-hues-100 conversation-item-active",f?"cursor-not-allowed":"cursor-pointer hover:border-hues-600"),onClick:()=>!f&&l(s.folderId,s?.id),title:f?g?.titles?.noActionsAllowed:t,children:[c.jsxs("div",{className:"flex flex-1 min-w-0 items-center",children:[g.conversationItemIcon?g.conversationItemIcon:null,c.jsx("h3",{className:L("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",r===s?.id?"conversation-item-text-active":""),title:f?g?.titles?.noActionsAllowed:t,children:o?.length?c.jsx(v.HighlightText,{text:t,highlightText:o}):t})]}),c.jsx(Se,{locale:d,conversationStyles:g,conversation:s,onConversationDelete:u.deleteConversation,getConversation:u.getConversation,getFileBlob:u.getFileBlob,renameConversation:u.renameConversation,shareConversationProps:e,isDisabled:f})]})},at=({handleConversationClick:s,actions:r,selectedConversationId:o,groupLabel:l,conversationStyles:u,groupedConversations:d,shareConversationProps:f,locale:g,isDisabled:e})=>{const[n,t]=m.useState(!1),a=m.useCallback(()=>{t(i=>!i)},[t]);return c.jsxs("div",{children:[c.jsxs("div",{className:"inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",onClick:a,children:[c.jsx(X.IconCaretRightFilled,{className:L("w-3 h-3 conversation-group-items-arrow",n?"rotate-[90deg]":"rotate-0")}),c.jsx("span",{className:"body-3 conversation-group-items-title-text",children:De(l,u?.titles)})]}),!n&&c.jsx("div",{className:L("flex flex-col gap-y-3","conversation-group-items"),children:he(d).map(i=>c.jsx(be,{locale:g,isDisabled:e,conversationStyles:u,conversation:i,selectedConversationId:o,onConversationClick:s,actions:r,shareConversationProps:f},i.id||i.name))})]},l)},it=({searchQuery:s,isExpandedSearch:r,titles:o,searchIcon:l,onSearchConversations:u,toggleSearchField:d})=>c.jsx(c.Fragment,{children:r?c.jsx(v.InputWithIcon,{inputId:"conversations-search",placeholder:o?.searchPlaceholder??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:s,iconAfterInput:c.jsx(v.IconButton,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:d,icon:c.jsx(X.IconX,{})}),onChange:u}):c.jsx(v.Button,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:l||c.jsx(X.IconSearch,{className:"w-5 h-5"}),onClick:d})}),lt=({conversations:s,selectedConversationId:r,searchQuery:o,conversationStyles:l,handleConversationClick:u,actions:d,locale:f,shareConversationProps:g})=>{const[e,n]=m.useState([]);return m.useEffect(()=>{n(he(s?.filter(t=>B.getClearedConversationName(t?.name)?.includes(o||""))))},[s,o]),c.jsx(c.Fragment,{children:e?.length?e.map(t=>c.jsx(be,{locale:f,conversationStyles:l,conversation:t,searchQuery:o,selectedConversationId:r,onConversationClick:u,actions:d,shareConversationProps:g},t.id)):c.jsx("h3",{className:"text-neutrals-800",children:l?.titles?.noConversation??"No conversations yet"})})},ct=({titles:s})=>c.jsxs("div",{className:"p-8 text-center flex flex-col",children:[c.jsx("p",{className:"text-neutrals-800",children:s?.noConversation??"No conversations yet"}),c.jsx("p",{className:"text-sm text-neutrals-800 mt-2",children:s?.clickNewChat??'Click "New Chat" to start a conversation'})]}),ut=({handleConversationClick:s,selectedConversationId:r,actions:o,children:l,isCollapsed:u,isStreaming:d,conversationStyles:f,conversations:g,locale:e,sharedConversations:n,setConversations:t,setSharedConversations:a,shareConversationProps:i,handleSelectedConversationRemove:p})=>{const[h,x]=m.useState({}),[C,M]=m.useState(!0),[N,E]=m.useState(""),[R,I]=m.useState(!1),{getConversations:j,getSharedConversations:b,deleteConversation:T,renameConversation:F}=o,z=m.useMemo(()=>!!N?.length,[N]);m.useEffect(()=>{x({...ue(n),...Te(g)})},[g,n]),m.useEffect(()=>{async function S(){try{M(!0);const A=await j(e),D=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(A)),a(B.cleanConversationNames(J(D,e)))}catch(A){console.error("Error loading conversation",A)}finally{M(!1)}}S()},[j,t,e,b,a]);const P=m.useCallback(async S=>{try{await T(S);const A=await j(e),D=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(A)),a(B.cleanConversationNames(J(D,e))),r===S?.id&&p()}catch(A){console.error("Error deleting conversation",A)}},[T,j,e,b,t,a,r,p]),_=m.useCallback(async(S,A)=>{try{M(!0),await F(S,A);const D=await j(e),Q=await b($.getSharedConversationsRequest($.ShareTarget.ME));t(B.cleanConversationNames(D)),a(B.cleanConversationNames(J(Q,e)))}catch(D){console.error("Error renaming conversation",D)}finally{M(!1)}},[j,e,b,t,a,F]),Y=m.useCallback(S=>{E(S)},[E]),U=m.useCallback(()=>{I(S=>!S),E("")},[I]);return C?c.jsx(v.Loader,{}):c.jsxs(c.Fragment,{children:[!u&&c.jsxs("div",{className:L("flex justify-between items-center",R?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!R&&c.jsx("h3",{className:"text-neutrals-700 sm:body-2",children:f?.titles?.allChats??"All Chats"}),c.jsx(it,{searchQuery:N,searchIcon:f.searchIcon,titles:f.titles,isExpandedSearch:R,onSearchConversations:Y,toggleSearchField:U})]}),c.jsx("div",{className:L("scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",z?"gap-y-1":"gap-y-6"),children:u?null:c.jsx(c.Fragment,{children:g?.length===0&&n?.length===0?c.jsx(ct,{titles:f.titles}):z?c.jsx(lt,{locale:e,conversationStyles:f,conversations:[...n,...g],searchQuery:N,selectedConversationId:r,handleConversationClick:s,shareConversationProps:i,actions:{...o,deleteConversation:P}}):Object.entries(h).map(([S,A])=>A?.length>0&&c.jsx(at,{locale:e,isDisabled:d,groupLabel:S,conversationStyles:f,groupedConversations:A,handleConversationClick:s,actions:{...o,deleteConversation:P,renameConversation:_},shareConversationProps:i,selectedConversationId:r},S))})}),l]})},dt=({onCloseModal:s,disableModalDividers:r,signOut:o,isSmallButton:l,locale:u,titles:d})=>c.jsxs(v.Popup,{heading:d?.popupTitle||"Log out?",portalId:"sign-out",containerClassName:"sign-out-popup",size:v.PopUpSize.SM,dividers:!r,onClose:s,closeButtonTitle:"Cancel",children:[c.jsx("div",{className:"py-4 px-6 sm:px-0",lang:u,children:d?.popupText}),c.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[c.jsx(v.Button,{buttonClassName:"cancel-button",title:d?.popupCancel||"Cancel",isSmallButton:l,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(v.Button,{buttonClassName:"text-button-primary",title:d?.popupApply||"Sign Out",isSmallButton:l,onClick:f=>{f.stopPropagation(),o?.()}})]})]}),ht=({userInfo:s,signOutAction:r,styles:o,locale:l,titles:u})=>{const d=x=>x?.split(" ")?.map((C,M)=>M<2?C[0].toUpperCase():"")?.join("")??"",f=m.useMemo(()=>s?.name?d(s?.name):s?.email?.[0].toUpperCase()??"",[s]),[g,e]=m.useState(!1),n=s?.name?.split(" "),t=n?`${n?.[0]??""} ${n?.[1]?.[0]?n?.[1]?.[0]+".":""}`:s?.email??"",a=m.useCallback(()=>{e(!0)},[]),i=m.useCallback(()=>{e(!1)},[]),p=m.useMemo(()=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:L("cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",o?.initialStyles),children:f}),c.jsx("p",{className:L("h3 cursor-pointer overflow-hidden text-ellipsis",o?.userNameStyles),children:(o?.showShortName?t:s?.name)??s?.email??""})]}),[f,t,o,s]),h=m.useMemo(()=>c.jsxs("div",{className:L("py-1",o?.dropDownStyles),children:[o?.settingsIcon&&c.jsxs("button",{className:L("p-2 items-center flex gap-1 text-primary fill-primary body-1",o?.dropdownButtonStyles),title:u?.settings,children:[o?.settingsIcon,u?.settings||"Settings"]}),c.jsx("div",{className:L("h-0 border-t border-neutrals-600 my-2",o?.showSeparator?"block":"hidden")}),c.jsxs("button",{className:L("p-2 items-center flex gap-1 text-primary fill-primary body-1",o?.dropdownButtonStyles),title:u?.signOut,onClick:a,children:[o?.signOutIcon,u?.signOut||"Sign out",g&&c.jsx(dt,{onCloseModal:i,signOut:()=>r?.(),locale:l,disableModalDividers:o?.disableModalDividers,titles:u})]})]}),[o,u,a,g,i,l,r]);if(s)return c.jsx(v.Dropdown,{containerClassName:L("transition-opacity group-hover:opacity-100 shrink w-full",o?.dropdownContainerClassName),triggerButton:p,content:h,openedClassName:"action-menu-opened"})};exports.ActionMenu=Se;exports.ActionMenuItem=O;exports.ConversationList=ut;exports.User=ht;exports.getSharedConversationsGroup=ue;exports.transformSharedConversations=J;
|
package/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as y, jsx as m, Fragment as q } from "react/jsx-runtime";
|
|
2
2
|
import k from "classnames";
|
|
3
3
|
import x, { useState as T, useMemo as J, useEffect as ee, useCallback as B, useRef as ze } from "react";
|
|
4
|
-
import { cloneDeep as
|
|
4
|
+
import { cloneDeep as $e, uniqBy as _e, omit as He } from "lodash";
|
|
5
5
|
import { Popup as ae, PopUpSize as le, Button as Q, Loader as we, InputWithIcon as Ne, Input as Ye, PopUpState as z, Dropdown as Re, HighlightText as Qe, IconButton as Ge } from "@epam/statgpt-ui-components";
|
|
6
6
|
import { IconCheck as je, IconCopy as We, IconDotsVertical as Ve, IconCaretRightFilled as Xe, IconX as Ke, IconSearch as Ze } from "@tabler/icons-react";
|
|
7
7
|
import Je from "jszip";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { getConversationAttachments as qe, SHARE_CONVERSATION_ROUTE as ve, getClearedConversationName as fe, ONBOARDING_MODEL_POSTFIX as et, cleanConversationNames as K } from "@epam/statgpt-shared-toolkit";
|
|
9
|
+
import { InvitationType as tt, getSharedConversationsRequest as re, ShareTarget as se } from "@epam/statgpt-dial-toolkit";
|
|
10
10
|
var U = /* @__PURE__ */ ((o) => (o.DELETE = "delete", o.EXPORT = "export", o.SHARE = "share", o.RENAME = "rename", o))(U || {}), F = /* @__PURE__ */ ((o) => (o.SHARED = "shared", o.TODAY = "today", o.YESTERDAY = "yesterday", o.WEEK = "week", o.EARLIER = "earlier", o))(F || {});
|
|
11
11
|
const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) => {
|
|
12
12
|
const l = `${r?.bucket}/${s}`, c = r?.url?.split("/")?.slice(1)?.join("/");
|
|
@@ -16,37 +16,37 @@ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) =
|
|
|
16
16
|
id: c,
|
|
17
17
|
isShared: !0
|
|
18
18
|
};
|
|
19
|
-
}) || [],
|
|
19
|
+
}) || [], nt = (o) => ({
|
|
20
20
|
[F.SHARED]: o
|
|
21
|
-
}),
|
|
21
|
+
}), ot = {
|
|
22
22
|
[F.TODAY]: [],
|
|
23
23
|
[F.YESTERDAY]: [],
|
|
24
24
|
[F.WEEK]: [],
|
|
25
25
|
[F.EARLIER]: []
|
|
26
|
-
}, Me = (o, s) => o.toDateString() === s.toDateString(),
|
|
26
|
+
}, Me = (o, s) => o.toDateString() === s.toDateString(), rt = (o, s) => {
|
|
27
27
|
const r = new Date(
|
|
28
28
|
o.getFullYear(),
|
|
29
29
|
o.getMonth(),
|
|
30
30
|
o.getDate() - 1
|
|
31
31
|
);
|
|
32
32
|
return Me(s, r);
|
|
33
|
-
},
|
|
33
|
+
}, st = (o, s) => {
|
|
34
34
|
const r = o.getTime() - s.getTime();
|
|
35
35
|
return Math.floor(r / (1e3 * 60 * 60 * 24));
|
|
36
|
-
}, Ce = (o) => o.updatedAt || Number(o.id?.split("-").pop()),
|
|
37
|
-
const s = /* @__PURE__ */ new Date(), r =
|
|
36
|
+
}, Ce = (o) => o.updatedAt || Number(o.id?.split("-").pop()), it = (o) => {
|
|
37
|
+
const s = /* @__PURE__ */ new Date(), r = $e(ot);
|
|
38
38
|
for (const l of o)
|
|
39
39
|
if (l.updatedAt) {
|
|
40
40
|
const c = new Date(l.updatedAt);
|
|
41
41
|
let d;
|
|
42
|
-
Me(s, c) ? d = r[F.TODAY] :
|
|
42
|
+
Me(s, c) ? d = r[F.TODAY] : rt(s, c) ? d = r[F.YESTERDAY] : st(s, c) <= 7 ? d = r[F.WEEK] : d = r[F.EARLIER], d?.some(
|
|
43
43
|
(f) => f.id === l.id
|
|
44
44
|
) || d.push(l);
|
|
45
45
|
}
|
|
46
46
|
return r;
|
|
47
47
|
}, ye = (o) => o?.sort(
|
|
48
48
|
(s, r) => (Ce(r) || 0) - (Ce(s) || 0)
|
|
49
|
-
),
|
|
49
|
+
), at = (o, s) => o === F.SHARED ? s?.shared || "Shared" : o === F.TODAY ? s?.today || "Today" : o === F.YESTERDAY ? s?.yesterday || "Yesterday" : o === F.WEEK ? s?.lastWeek || "Last week" : s?.earlier || "Earlier", lt = ({
|
|
50
50
|
onCloseModal: o,
|
|
51
51
|
disableModalDividers: s,
|
|
52
52
|
deleteConversation: r,
|
|
@@ -91,24 +91,19 @@ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) =
|
|
|
91
91
|
] })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
|
-
),
|
|
95
|
-
const s =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})
|
|
106
|
-
);
|
|
107
|
-
return $e(
|
|
108
|
-
r,
|
|
109
|
-
(l) => te(l.relativePath, l.name)
|
|
94
|
+
), ct = (o) => {
|
|
95
|
+
const s = mt(
|
|
96
|
+
qe(o)
|
|
97
|
+
).map((r) => ({
|
|
98
|
+
...r,
|
|
99
|
+
relativePath: "",
|
|
100
|
+
contentLength: 0
|
|
101
|
+
}));
|
|
102
|
+
return _e(
|
|
103
|
+
s,
|
|
104
|
+
(r) => te(r.relativePath, r.name)
|
|
110
105
|
);
|
|
111
|
-
},
|
|
106
|
+
}, dt = (o) => o.endsWith("/"), ut = (o) => {
|
|
112
107
|
const s = o.toLowerCase();
|
|
113
108
|
return [
|
|
114
109
|
"data:",
|
|
@@ -121,7 +116,7 @@ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) =
|
|
|
121
116
|
"telnet://",
|
|
122
117
|
"api/files"
|
|
123
118
|
].some((r) => s.startsWith(r));
|
|
124
|
-
},
|
|
119
|
+
}, ht = (o) => {
|
|
125
120
|
const s = te(
|
|
126
121
|
...o.split("/").map((l) => decodeURIComponent(l))
|
|
127
122
|
), r = s.lastIndexOf("/");
|
|
@@ -129,10 +124,10 @@ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) =
|
|
|
129
124
|
absolutePath: s.slice(0, r),
|
|
130
125
|
name: s.slice(r + 1)
|
|
131
126
|
};
|
|
132
|
-
},
|
|
133
|
-
if (!s.url ||
|
|
127
|
+
}, mt = (o) => o ? o.map((s) => {
|
|
128
|
+
if (!s.url || ut(s.url) || dt(s.url))
|
|
134
129
|
return null;
|
|
135
|
-
const { absolutePath: r, name: l } =
|
|
130
|
+
const { absolutePath: r, name: l } = ht(s.url);
|
|
136
131
|
return {
|
|
137
132
|
id: s.url,
|
|
138
133
|
name: l,
|
|
@@ -141,28 +136,28 @@ const ue = (o, s) => o?.resources?.filter((r) => r?.parentPath === s)?.map((r) =
|
|
|
141
136
|
absolutePath: r
|
|
142
137
|
};
|
|
143
138
|
}).filter(Boolean) : [];
|
|
144
|
-
async function
|
|
145
|
-
const r =
|
|
139
|
+
async function ft(o, s) {
|
|
140
|
+
const r = ct(o), l = new Je();
|
|
146
141
|
r.forEach((p) => {
|
|
147
|
-
const e = encodeURI(te(p.absolutePath, p.name)), n = s(`${e}`.replace("files/", "")), t =
|
|
142
|
+
const e = encodeURI(te(p.absolutePath, p.name)), n = s(`${e}`.replace("files/", "")), t = pt(p.folderId), i = te("res", t, p.name);
|
|
148
143
|
l.file(i, n);
|
|
149
144
|
});
|
|
150
145
|
const c = {
|
|
151
146
|
version: 5,
|
|
152
|
-
history: [o].map(
|
|
147
|
+
history: [o].map(gt) || [],
|
|
153
148
|
folders: []
|
|
154
149
|
}, d = JSON.stringify(c, null, 2);
|
|
155
150
|
return l.file("conversations/conversations_history.json", d), await l.generateAsync({ type: "base64" });
|
|
156
151
|
}
|
|
157
|
-
const
|
|
152
|
+
const pt = (o) => {
|
|
158
153
|
const s = o.split("/");
|
|
159
154
|
return s.length > 2 ? te(...s.slice(2)) : void 0;
|
|
160
|
-
},
|
|
161
|
-
function
|
|
155
|
+
}, gt = (o) => He(o, ["publicationInfo"]), te = (...o) => o.filter(Boolean).join("/");
|
|
156
|
+
function Ct(o, s) {
|
|
162
157
|
const r = document.createElement("a");
|
|
163
158
|
r.download = s, r.href = o, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(o);
|
|
164
159
|
}
|
|
165
|
-
var
|
|
160
|
+
var Et = Object.defineProperty, ie = Object.getOwnPropertySymbols, Ae = Object.prototype.hasOwnProperty, Ie = Object.prototype.propertyIsEnumerable, Ee = (o, s, r) => s in o ? Et(o, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[s] = r, he = (o, s) => {
|
|
166
161
|
for (var r in s || (s = {}))
|
|
167
162
|
Ae.call(s, r) && Ee(o, r, s[r]);
|
|
168
163
|
if (ie)
|
|
@@ -714,12 +709,12 @@ var X;
|
|
|
714
709
|
})(o.QrSegment || (o.QrSegment = {}));
|
|
715
710
|
})(X || (X = {}));
|
|
716
711
|
var Z = X;
|
|
717
|
-
var
|
|
712
|
+
var wt = {
|
|
718
713
|
L: Z.QrCode.Ecc.LOW,
|
|
719
714
|
M: Z.QrCode.Ecc.MEDIUM,
|
|
720
715
|
Q: Z.QrCode.Ecc.QUARTILE,
|
|
721
716
|
H: Z.QrCode.Ecc.HIGH
|
|
722
|
-
}, be = 128, Se = "L", xe = "#FFFFFF", Pe = "#000000", De = !1, Oe = 1,
|
|
717
|
+
}, be = 128, Se = "L", xe = "#FFFFFF", Pe = "#000000", De = !1, Oe = 1, Nt = 4, Rt = 0, vt = 0.1;
|
|
723
718
|
function Te(o, s = 0) {
|
|
724
719
|
const r = [];
|
|
725
720
|
return o.forEach(function(l, c) {
|
|
@@ -746,10 +741,10 @@ function Te(o, s = 0) {
|
|
|
746
741
|
function Le(o, s) {
|
|
747
742
|
return o.slice().map((r, l) => l < s.y || l >= s.y + s.h ? r : r.map((c, d) => d < s.x || d >= s.x + s.w ? c : !1));
|
|
748
743
|
}
|
|
749
|
-
function
|
|
744
|
+
function Mt(o, s, r, l) {
|
|
750
745
|
if (l == null)
|
|
751
746
|
return null;
|
|
752
|
-
const c = o.length + r * 2, d = Math.floor(s *
|
|
747
|
+
const c = o.length + r * 2, d = Math.floor(s * vt), f = c / s, p = (l.width || d) * f, e = (l.height || d) * f, n = l.x == null ? o.length / 2 - p / 2 : l.x * f, t = l.y == null ? o.length / 2 - e / 2 : l.y * f, i = l.opacity == null ? 1 : l.opacity;
|
|
753
748
|
let a = null;
|
|
754
749
|
if (l.excavate) {
|
|
755
750
|
let u = Math.floor(n), E = Math.floor(t), g = Math.ceil(p + n - u), v = Math.ceil(e + t - E);
|
|
@@ -758,8 +753,8 @@ function vt(o, s, r, l) {
|
|
|
758
753
|
const h = l.crossOrigin;
|
|
759
754
|
return { x: n, y: t, h: e, w: p, excavation: a, opacity: i, crossOrigin: h };
|
|
760
755
|
}
|
|
761
|
-
function
|
|
762
|
-
return s != null ? Math.max(Math.floor(s), 0) : o ?
|
|
756
|
+
function yt(o, s) {
|
|
757
|
+
return s != null ? Math.max(Math.floor(s), 0) : o ? Nt : Rt;
|
|
763
758
|
}
|
|
764
759
|
function Be({
|
|
765
760
|
value: o,
|
|
@@ -775,7 +770,7 @@ function Be({
|
|
|
775
770
|
const u = (Array.isArray(o) ? o : [o]).reduce((E, g) => (E.push(...Z.QrSegment.makeSegments(g)), E), []);
|
|
776
771
|
return Z.QrCode.encodeSegments(
|
|
777
772
|
u,
|
|
778
|
-
|
|
773
|
+
wt[s],
|
|
779
774
|
r,
|
|
780
775
|
void 0,
|
|
781
776
|
void 0,
|
|
@@ -784,7 +779,7 @@ function Be({
|
|
|
784
779
|
}, [o, s, r, p]);
|
|
785
780
|
const { cells: n, margin: t, numCells: i, calculatedImageSettings: a } = x.useMemo(() => {
|
|
786
781
|
let h = e.getModules();
|
|
787
|
-
const u =
|
|
782
|
+
const u = yt(l, c), E = h.length + u * 2, g = Mt(
|
|
788
783
|
h,
|
|
789
784
|
f,
|
|
790
785
|
u,
|
|
@@ -805,14 +800,14 @@ function Be({
|
|
|
805
800
|
calculatedImageSettings: a
|
|
806
801
|
};
|
|
807
802
|
}
|
|
808
|
-
var
|
|
803
|
+
var At = (function() {
|
|
809
804
|
try {
|
|
810
805
|
new Path2D().addPath(new Path2D());
|
|
811
806
|
} catch {
|
|
812
807
|
return !1;
|
|
813
808
|
}
|
|
814
809
|
return !0;
|
|
815
|
-
})(),
|
|
810
|
+
})(), It = x.forwardRef(
|
|
816
811
|
function(s, r) {
|
|
817
812
|
const l = s, {
|
|
818
813
|
value: c,
|
|
@@ -837,11 +832,11 @@ var yt = (function() {
|
|
|
837
832
|
"marginSize",
|
|
838
833
|
"imageSettings"
|
|
839
834
|
]), { style: g } = E, v = me(E, ["style"]), N = h?.src, C = x.useRef(null), R = x.useRef(null), S = x.useCallback(
|
|
840
|
-
(
|
|
841
|
-
C.current =
|
|
835
|
+
($) => {
|
|
836
|
+
C.current = $, typeof r == "function" ? r($) : r && (r.current = $);
|
|
842
837
|
},
|
|
843
838
|
[r]
|
|
844
|
-
), [D, A] = x.useState(!1), { margin: O, cells:
|
|
839
|
+
), [D, A] = x.useState(!1), { margin: O, cells: _, numCells: H, calculatedImageSettings: P } = Be({
|
|
845
840
|
value: c,
|
|
846
841
|
level: f,
|
|
847
842
|
minVersion: t,
|
|
@@ -853,19 +848,19 @@ var yt = (function() {
|
|
|
853
848
|
});
|
|
854
849
|
x.useEffect(() => {
|
|
855
850
|
if (C.current != null) {
|
|
856
|
-
const
|
|
851
|
+
const $ = C.current, M = $.getContext("2d");
|
|
857
852
|
if (!M)
|
|
858
853
|
return;
|
|
859
|
-
let b =
|
|
854
|
+
let b = _;
|
|
860
855
|
const L = R.current, W = P != null && L !== null && L.complete && L.naturalHeight !== 0 && L.naturalWidth !== 0;
|
|
861
856
|
W && P.excavation != null && (b = Le(
|
|
862
|
-
|
|
857
|
+
_,
|
|
863
858
|
P.excavation
|
|
864
859
|
));
|
|
865
860
|
const ne = window.devicePixelRatio || 1;
|
|
866
|
-
|
|
861
|
+
$.height = $.width = d * ne;
|
|
867
862
|
const oe = d / H * ne;
|
|
868
|
-
M.scale(oe, oe), M.fillStyle = p, M.fillRect(0, 0, H, H), M.fillStyle = e,
|
|
863
|
+
M.scale(oe, oe), M.fillStyle = p, M.fillRect(0, 0, H, H), M.fillStyle = e, At ? M.fill(new Path2D(Te(b, O))) : _.forEach(function(V, G) {
|
|
869
864
|
V.forEach(function(ce, de) {
|
|
870
865
|
ce && M.fillRect(de + O, G + O, 1, 1);
|
|
871
866
|
});
|
|
@@ -906,7 +901,7 @@ var yt = (function() {
|
|
|
906
901
|
), j);
|
|
907
902
|
}
|
|
908
903
|
);
|
|
909
|
-
|
|
904
|
+
It.displayName = "QRCodeCanvas";
|
|
910
905
|
var ke = x.forwardRef(
|
|
911
906
|
function(s, r) {
|
|
912
907
|
const l = s, {
|
|
@@ -985,25 +980,25 @@ var ke = x.forwardRef(
|
|
|
985
980
|
}
|
|
986
981
|
);
|
|
987
982
|
ke.displayName = "QRCodeSVG";
|
|
988
|
-
const
|
|
989
|
-
invitationType:
|
|
983
|
+
const bt = (o, s) => ({
|
|
984
|
+
invitationType: tt.LINK,
|
|
990
985
|
resources: [
|
|
991
986
|
{
|
|
992
987
|
url: `conversations/${encodeURI(o)}`
|
|
993
988
|
},
|
|
994
989
|
...s
|
|
995
990
|
]
|
|
996
|
-
}),
|
|
991
|
+
}), St = (o) => {
|
|
997
992
|
const s = o?.invitationLink?.split("/").at(-1) || "";
|
|
998
993
|
return `/${ve}/${s}`;
|
|
999
|
-
},
|
|
994
|
+
}, xt = (o, s) => s?.find((r) => {
|
|
1000
995
|
const l = o?.id?.split("/")?.pop(), c = r?.url?.split("/")?.pop() || "";
|
|
1001
996
|
return c === l || decodeURI(c) === l;
|
|
1002
|
-
}),
|
|
997
|
+
}), Pt = (o) => o?.messages?.filter(
|
|
1003
998
|
(r) => !!r?.custom_content?.attachments
|
|
1004
999
|
)?.flatMap((r) => r?.custom_content?.attachments?.map((l) => ({
|
|
1005
1000
|
url: l?.url || ""
|
|
1006
|
-
})) || [])?.filter((r) => !!r?.url) || [],
|
|
1001
|
+
})) || [])?.filter((r) => !!r?.url) || [], Dt = ({
|
|
1007
1002
|
conversation: o,
|
|
1008
1003
|
locale: s,
|
|
1009
1004
|
onCloseModal: r,
|
|
@@ -1027,7 +1022,7 @@ const It = (o, s) => ({
|
|
|
1027
1022
|
clientSharedPage: R,
|
|
1028
1023
|
clientSharedProp: S
|
|
1029
1024
|
}) => {
|
|
1030
|
-
const [D, A] = T(null), [O,
|
|
1025
|
+
const [D, A] = T(null), [O, _] = T(), [H, P] = T(!1), [Y, j] = T(!1), [$, M] = T(), b = J(() => {
|
|
1031
1026
|
const V = N || window.location.origin;
|
|
1032
1027
|
if (N && N !== window.location.origin && R && S) {
|
|
1033
1028
|
const G = D?.split(`/${ve}/`)?.[1];
|
|
@@ -1038,14 +1033,14 @@ const It = (o, s) => ({
|
|
|
1038
1033
|
ee(() => {
|
|
1039
1034
|
(async () => {
|
|
1040
1035
|
try {
|
|
1041
|
-
const G = decodeURI(o ? o?.id : `${C?.[0]}/${s}/${C?.[1]}`), ce = `${decodeURI(G)}`, de = await c?.(ce), Ue =
|
|
1036
|
+
const G = decodeURI(o ? o?.id : `${C?.[0]}/${s}/${C?.[1]}`), ce = `${decodeURI(G)}`, de = await c?.(ce), Ue = bt(
|
|
1042
1037
|
G,
|
|
1043
|
-
|
|
1038
|
+
Pt(de)
|
|
1044
1039
|
), pe = await d?.(Ue), ge = await g?.(
|
|
1045
1040
|
re(se.OTHERS)
|
|
1046
1041
|
);
|
|
1047
|
-
pe && ge && (P(!0), A(
|
|
1048
|
-
|
|
1042
|
+
pe && ge && (P(!0), A(St(pe)), _(
|
|
1043
|
+
xt(
|
|
1049
1044
|
o,
|
|
1050
1045
|
ge?.resources
|
|
1051
1046
|
)
|
|
@@ -1139,14 +1134,14 @@ const It = (o, s) => ({
|
|
|
1139
1134
|
title: u ?? "Remove access to all users",
|
|
1140
1135
|
buttonClassName: "remove-access-button py-3 px-4",
|
|
1141
1136
|
isSmallButton: !0,
|
|
1142
|
-
disabled:
|
|
1137
|
+
disabled: $,
|
|
1143
1138
|
onClick: ne
|
|
1144
1139
|
}
|
|
1145
1140
|
) }) : /* @__PURE__ */ m("p", { className: "body-2 text-neutrals-800 share-footer", children: n ?? "This chat has not been shared with anyone yet." }) : /* @__PURE__ */ m("div", {})
|
|
1146
1141
|
]
|
|
1147
1142
|
}
|
|
1148
1143
|
);
|
|
1149
|
-
},
|
|
1144
|
+
}, Ot = ({
|
|
1150
1145
|
conversation: o,
|
|
1151
1146
|
onCloseModal: s,
|
|
1152
1147
|
renameConversation: r,
|
|
@@ -1212,7 +1207,7 @@ const It = (o, s) => ({
|
|
|
1212
1207
|
]
|
|
1213
1208
|
}
|
|
1214
1209
|
);
|
|
1215
|
-
},
|
|
1210
|
+
}, Tt = ({
|
|
1216
1211
|
conversation: o,
|
|
1217
1212
|
conversationStyles: s,
|
|
1218
1213
|
shareConversationProps: r,
|
|
@@ -1276,14 +1271,14 @@ const It = (o, s) => ({
|
|
|
1276
1271
|
Re,
|
|
1277
1272
|
{
|
|
1278
1273
|
containerClassName: "ml-3 group-hover:visible invisible",
|
|
1279
|
-
triggerButton: p ?? /* @__PURE__ */ m(
|
|
1274
|
+
triggerButton: p ?? /* @__PURE__ */ m(Lt, { disabled: n }),
|
|
1280
1275
|
options: t,
|
|
1281
1276
|
openedClassName: "action-menu-opened",
|
|
1282
1277
|
onOptionSelect: (A) => {
|
|
1283
1278
|
A === U.DELETE && a(z.Opened), A === U.SHARE && u(z.Opened), A === U.RENAME && g(z.Opened), A === U.EXPORT && c(decodeURI(o.id)).then((O) => {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
`data:application/zip;base64,${
|
|
1279
|
+
ft(O, d).then((_) => {
|
|
1280
|
+
Ct(
|
|
1281
|
+
`data:application/zip;base64,${_}`,
|
|
1287
1282
|
`chat_with_attachments_${(/* @__PURE__ */ new Date()).toLocaleDateString()}.dial`
|
|
1288
1283
|
);
|
|
1289
1284
|
});
|
|
@@ -1293,7 +1288,7 @@ const It = (o, s) => ({
|
|
|
1293
1288
|
}
|
|
1294
1289
|
),
|
|
1295
1290
|
i === z.Opened && /* @__PURE__ */ m(
|
|
1296
|
-
|
|
1291
|
+
lt,
|
|
1297
1292
|
{
|
|
1298
1293
|
titles: s.titles,
|
|
1299
1294
|
locale: e,
|
|
@@ -1304,7 +1299,7 @@ const It = (o, s) => ({
|
|
|
1304
1299
|
}
|
|
1305
1300
|
),
|
|
1306
1301
|
h === z.Opened && /* @__PURE__ */ m(
|
|
1307
|
-
|
|
1302
|
+
Dt,
|
|
1308
1303
|
{
|
|
1309
1304
|
conversation: o,
|
|
1310
1305
|
locale: e,
|
|
@@ -1313,7 +1308,7 @@ const It = (o, s) => ({
|
|
|
1313
1308
|
}
|
|
1314
1309
|
),
|
|
1315
1310
|
E === z.Opened && /* @__PURE__ */ m(
|
|
1316
|
-
|
|
1311
|
+
Ot,
|
|
1317
1312
|
{
|
|
1318
1313
|
conversation: o,
|
|
1319
1314
|
locale: e,
|
|
@@ -1325,7 +1320,7 @@ const It = (o, s) => ({
|
|
|
1325
1320
|
}
|
|
1326
1321
|
)
|
|
1327
1322
|
] });
|
|
1328
|
-
},
|
|
1323
|
+
}, Lt = ({ disabled: o }) => /* @__PURE__ */ m(
|
|
1329
1324
|
"div",
|
|
1330
1325
|
{
|
|
1331
1326
|
className: k(
|
|
@@ -1400,7 +1395,7 @@ const It = (o, s) => ({
|
|
|
1400
1395
|
)
|
|
1401
1396
|
] }),
|
|
1402
1397
|
/* @__PURE__ */ m(
|
|
1403
|
-
|
|
1398
|
+
Tt,
|
|
1404
1399
|
{
|
|
1405
1400
|
locale: d,
|
|
1406
1401
|
conversationStyles: p,
|
|
@@ -1416,7 +1411,7 @@ const It = (o, s) => ({
|
|
|
1416
1411
|
]
|
|
1417
1412
|
}
|
|
1418
1413
|
);
|
|
1419
|
-
},
|
|
1414
|
+
}, Bt = ({
|
|
1420
1415
|
handleConversationClick: o,
|
|
1421
1416
|
actions: s,
|
|
1422
1417
|
selectedConversationId: r,
|
|
@@ -1446,7 +1441,7 @@ const It = (o, s) => ({
|
|
|
1446
1441
|
)
|
|
1447
1442
|
}
|
|
1448
1443
|
),
|
|
1449
|
-
/* @__PURE__ */ m("span", { className: "body-3 conversation-group-items-title-text", children:
|
|
1444
|
+
/* @__PURE__ */ m("span", { className: "body-3 conversation-group-items-title-text", children: at(l, c?.titles) })
|
|
1450
1445
|
]
|
|
1451
1446
|
}
|
|
1452
1447
|
),
|
|
@@ -1476,7 +1471,7 @@ const It = (o, s) => ({
|
|
|
1476
1471
|
}
|
|
1477
1472
|
)
|
|
1478
1473
|
] }, l);
|
|
1479
|
-
},
|
|
1474
|
+
}, kt = ({
|
|
1480
1475
|
searchQuery: o,
|
|
1481
1476
|
isExpandedSearch: s,
|
|
1482
1477
|
titles: r,
|
|
@@ -1508,7 +1503,7 @@ const It = (o, s) => ({
|
|
|
1508
1503
|
iconBefore: l || /* @__PURE__ */ m(Ze, { className: "w-5 h-5" }),
|
|
1509
1504
|
onClick: d
|
|
1510
1505
|
}
|
|
1511
|
-
) }),
|
|
1506
|
+
) }), Ft = ({
|
|
1512
1507
|
conversations: o,
|
|
1513
1508
|
selectedConversationId: s,
|
|
1514
1509
|
searchQuery: r,
|
|
@@ -1543,10 +1538,10 @@ const It = (o, s) => ({
|
|
|
1543
1538
|
},
|
|
1544
1539
|
t.id
|
|
1545
1540
|
)) : /* @__PURE__ */ m("h3", { className: "text-neutrals-800", children: l?.titles?.noConversation ?? "No conversations yet" }) });
|
|
1546
|
-
},
|
|
1541
|
+
}, Ut = ({ titles: o }) => /* @__PURE__ */ y("div", { className: "p-8 text-center flex flex-col", children: [
|
|
1547
1542
|
/* @__PURE__ */ m("p", { className: "text-neutrals-800", children: o?.noConversation ?? "No conversations yet" }),
|
|
1548
1543
|
/* @__PURE__ */ m("p", { className: "text-sm text-neutrals-800 mt-2", children: o?.clickNewChat ?? 'Click "New Chat" to start a conversation' })
|
|
1549
|
-
] }),
|
|
1544
|
+
] }), Zt = ({
|
|
1550
1545
|
handleConversationClick: o,
|
|
1551
1546
|
selectedConversationId: s,
|
|
1552
1547
|
actions: r,
|
|
@@ -1566,12 +1561,12 @@ const It = (o, s) => ({
|
|
|
1566
1561
|
getConversations: D,
|
|
1567
1562
|
getSharedConversations: A,
|
|
1568
1563
|
deleteConversation: O,
|
|
1569
|
-
renameConversation:
|
|
1564
|
+
renameConversation: _
|
|
1570
1565
|
} = r, H = J(() => !!N?.length, [N]);
|
|
1571
1566
|
ee(() => {
|
|
1572
1567
|
E({
|
|
1573
|
-
...
|
|
1574
|
-
...
|
|
1568
|
+
...nt(n),
|
|
1569
|
+
...it(p)
|
|
1575
1570
|
});
|
|
1576
1571
|
}, [p, n]), ee(() => {
|
|
1577
1572
|
async function M() {
|
|
@@ -1628,7 +1623,7 @@ const It = (o, s) => ({
|
|
|
1628
1623
|
), Y = B(
|
|
1629
1624
|
async (M, b) => {
|
|
1630
1625
|
try {
|
|
1631
|
-
v(!0), await
|
|
1626
|
+
v(!0), await _(M, b);
|
|
1632
1627
|
const L = await D(e), W = await A(
|
|
1633
1628
|
re(se.ME)
|
|
1634
1629
|
);
|
|
@@ -1649,14 +1644,14 @@ const It = (o, s) => ({
|
|
|
1649
1644
|
A,
|
|
1650
1645
|
t,
|
|
1651
1646
|
i,
|
|
1652
|
-
|
|
1647
|
+
_
|
|
1653
1648
|
]
|
|
1654
1649
|
), j = B(
|
|
1655
1650
|
(M) => {
|
|
1656
1651
|
C(M);
|
|
1657
1652
|
},
|
|
1658
1653
|
[C]
|
|
1659
|
-
),
|
|
1654
|
+
), $ = B(() => {
|
|
1660
1655
|
S((M) => !M), C("");
|
|
1661
1656
|
}, [S]);
|
|
1662
1657
|
return g ? /* @__PURE__ */ m(we, {}) : /* @__PURE__ */ y(q, { children: [
|
|
@@ -1670,14 +1665,14 @@ const It = (o, s) => ({
|
|
|
1670
1665
|
children: [
|
|
1671
1666
|
!R && /* @__PURE__ */ m("h3", { className: "text-neutrals-700 sm:body-2", children: f?.titles?.allChats ?? "All Chats" }),
|
|
1672
1667
|
/* @__PURE__ */ m(
|
|
1673
|
-
|
|
1668
|
+
kt,
|
|
1674
1669
|
{
|
|
1675
1670
|
searchQuery: N,
|
|
1676
1671
|
searchIcon: f.searchIcon,
|
|
1677
1672
|
titles: f.titles,
|
|
1678
1673
|
isExpandedSearch: R,
|
|
1679
1674
|
onSearchConversations: j,
|
|
1680
|
-
toggleSearchField:
|
|
1675
|
+
toggleSearchField: $
|
|
1681
1676
|
}
|
|
1682
1677
|
)
|
|
1683
1678
|
]
|
|
@@ -1690,8 +1685,8 @@ const It = (o, s) => ({
|
|
|
1690
1685
|
"scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",
|
|
1691
1686
|
H ? "gap-y-1" : "gap-y-6"
|
|
1692
1687
|
),
|
|
1693
|
-
children: c ? null : /* @__PURE__ */ m(q, { children: p?.length === 0 && n?.length === 0 ? /* @__PURE__ */ m(
|
|
1694
|
-
|
|
1688
|
+
children: c ? null : /* @__PURE__ */ m(q, { children: p?.length === 0 && n?.length === 0 ? /* @__PURE__ */ m(Ut, { titles: f.titles }) : H ? /* @__PURE__ */ m(
|
|
1689
|
+
Ft,
|
|
1695
1690
|
{
|
|
1696
1691
|
locale: e,
|
|
1697
1692
|
conversationStyles: f,
|
|
@@ -1707,7 +1702,7 @@ const It = (o, s) => ({
|
|
|
1707
1702
|
}
|
|
1708
1703
|
) : Object.entries(u).map(
|
|
1709
1704
|
([M, b]) => b?.length > 0 && /* @__PURE__ */ m(
|
|
1710
|
-
|
|
1705
|
+
Bt,
|
|
1711
1706
|
{
|
|
1712
1707
|
locale: e,
|
|
1713
1708
|
isDisabled: d,
|
|
@@ -1730,7 +1725,7 @@ const It = (o, s) => ({
|
|
|
1730
1725
|
),
|
|
1731
1726
|
l
|
|
1732
1727
|
] });
|
|
1733
|
-
},
|
|
1728
|
+
}, zt = ({
|
|
1734
1729
|
onCloseModal: o,
|
|
1735
1730
|
disableModalDividers: s,
|
|
1736
1731
|
signOut: r,
|
|
@@ -1775,7 +1770,7 @@ const It = (o, s) => ({
|
|
|
1775
1770
|
] })
|
|
1776
1771
|
]
|
|
1777
1772
|
}
|
|
1778
|
-
),
|
|
1773
|
+
), Jt = ({
|
|
1779
1774
|
userInfo: o,
|
|
1780
1775
|
signOutAction: s,
|
|
1781
1776
|
styles: r,
|
|
@@ -1847,7 +1842,7 @@ const It = (o, s) => ({
|
|
|
1847
1842
|
r?.signOutIcon,
|
|
1848
1843
|
c?.signOut || "Sign out",
|
|
1849
1844
|
p && /* @__PURE__ */ m(
|
|
1850
|
-
|
|
1845
|
+
zt,
|
|
1851
1846
|
{
|
|
1852
1847
|
onCloseModal: a,
|
|
1853
1848
|
signOut: () => s?.(),
|
|
@@ -1883,10 +1878,10 @@ const It = (o, s) => ({
|
|
|
1883
1878
|
);
|
|
1884
1879
|
};
|
|
1885
1880
|
export {
|
|
1886
|
-
|
|
1881
|
+
Tt as ActionMenu,
|
|
1887
1882
|
U as ActionMenuItem,
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1883
|
+
Zt as ConversationList,
|
|
1884
|
+
Jt as User,
|
|
1885
|
+
nt as getSharedConversationsGroup,
|
|
1891
1886
|
ue as transformSharedConversations
|
|
1892
1887
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/statgpt-conversation-list",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@tabler/icons-react": "^3.34.1",
|
|
7
7
|
"@epam/ai-dial-shared": "^0.43.3",
|
|
8
|
-
"@epam/statgpt-ui-components": "0.3.0
|
|
8
|
+
"@epam/statgpt-ui-components": "0.3.0",
|
|
9
9
|
"classnames": "^2.5.1",
|
|
10
|
-
"@epam/statgpt-shared-toolkit": "0.3.0
|
|
11
|
-
"@epam/statgpt-dial-toolkit": "0.3.0
|
|
10
|
+
"@epam/statgpt-shared-toolkit": "0.3.0",
|
|
11
|
+
"@epam/statgpt-dial-toolkit": "0.3.0",
|
|
12
12
|
"jszip": "3.10.1",
|
|
13
13
|
"lodash": "^4.17.23"
|
|
14
14
|
},
|