@epam/statgpt-conversation-list 0.2.0-rc.2 → 0.2.0-rc.20

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