more-desk-one 0.0.28 → 0.0.32

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),D=require("more-sso-sdk"),Se=require("@radix-ui/react-popover");function ye(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const m=ye(a),Z=ye(Se);let Ce=null;function Te(t){Ce=t}function Ee(t){Ce?.(t)}let we=[],ne=null;function Ae(t){we.push(t),ne&&t(ne)}function Me(t){ne=t,we.forEach(s=>s(t))}const _e=a.createContext(void 0),Le=({children:t,token:s})=>{const[r,i]=a.useState(s),[o,c]=a.useState(!0),[h,u]=a.useState(null);return a.useEffect(()=>{Te(i)},[]),e.jsx(_e.Provider,{value:{accessToken:r,isChatScreen:o,setIsChatScreen:c,profileInfo:h,setProfileInfo:u},children:t})},$=()=>{const t=a.useContext(_e);if(!t)throw new Error("useSdkContext must be used inside SDKProvider");return t},He=t=>m.createElement("svg",{width:36,height:36,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M15.8261 8.67349C12.4046 8.67349 9.63062 11.447 9.63062 14.8685C9.63062 18.29 12.4046 21.064 15.8261 21.064C16.1656 21.064 16.4991 21.0365 16.8241 20.984C15.0221 20.4765 13.7006 18.8205 13.7006 16.856C13.7006 14.4875 15.6206 12.568 17.9886 12.568C19.8251 12.568 21.3921 13.722 22.0031 15.345C22.0151 15.188 22.0211 15.029 22.0211 14.8685C22.0211 11.447 19.2476 8.67349 15.8261 8.67349Z",fill:"#B72402"}),m.createElement("path",{d:"M17.9984 7.621C13.0309 7.621 9.00342 11.6485 9.00342 16.616C9.00342 20.526 11.4949 23.8495 14.9744 25.0915V27.785C14.9744 28.228 15.4404 28.515 15.8349 28.3125C17.5759 27.4215 21.5219 25.332 23.5549 23.696C23.6114 23.65 23.6674 23.6065 23.7214 23.5605C23.7624 23.527 23.8009 23.494 23.8394 23.4605C25.7724 21.8115 26.9964 19.356 26.9964 16.616C26.9964 11.6485 22.9689 7.621 17.9989 7.621H17.9984ZM15.8274 21.064C15.5379 21.064 15.2539 21.0435 14.9749 21.005C11.9559 20.59 9.63092 18.0015 9.63092 14.8675C9.63092 11.4465 12.4039 8.6735 15.8274 8.6735C19.2509 8.6735 22.0214 11.4465 22.0214 14.8675C22.0214 15.0265 22.0164 15.185 22.0034 15.341C21.8319 17.6225 20.4259 19.5555 18.4544 20.48C17.9424 20.7205 17.3919 20.892 16.8154 20.9845C16.4929 21.036 16.1624 21.064 15.8269 21.064H15.8274Z",fill:"#FA4B16"})),Ie=t=>m.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M14.4167 3.58334L14.4167 5.13334L5.58341 5.13333L5.58341 3.58333L14.4167 3.58334ZM2.66675 4.5L6.06675 8.01667L2.68341 11.5167L1.56675 10.4L3.86675 8.01667L1.55008 5.61667L2.66675 4.5ZM14.4167 7.25L14.4167 8.81667L7.48341 8.81667L7.48341 7.25L14.4167 7.25ZM14.4167 10.8667L14.4167 12.4333L5.58341 12.4333L5.58341 10.8667L14.4167 10.8667Z",fill:"#172128"})),Re=t=>m.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M13.25 14.45L8.7667 9.98335C8.44448 10.238 8.06414 10.4378 7.6257 10.5827C7.18725 10.7276 6.71203 10.8 6.20003 10.8C4.92048 10.8 3.8367 10.3556 2.9487 9.46668C2.0607 8.57779 1.6167 7.50557 1.6167 6.25001C1.6167 4.99446 2.06114 3.92223 2.95003 3.03335C3.83892 2.14446 4.91392 1.70001 6.17503 1.70001C7.43614 1.70001 8.50837 2.14446 9.3917 3.03335C10.275 3.92223 10.7167 4.99529 10.7167 6.25251C10.7167 6.75085 10.6473 7.2139 10.5084 7.64168C10.3695 8.06946 10.1611 8.47223 9.88337 8.85001L14.3834 13.3167L13.25 14.45ZM6.1892 9.23335C7.02142 9.23335 7.72298 8.94307 8.29387 8.36251C8.86464 7.78196 9.15003 7.07779 9.15003 6.25001C9.15003 5.42223 8.86381 4.71807 8.29137 4.13751C7.71892 3.55696 7.0182 3.26668 6.1892 3.26668C5.35109 3.26668 4.64059 3.55696 4.0577 4.13751C3.47481 4.71807 3.18337 5.42223 3.18337 6.25001C3.18337 7.07779 3.47398 7.78196 4.0552 8.36251C4.63642 8.94307 5.34775 9.23335 6.1892 9.23335Z",fill:"#172128"})),$e=t=>m.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M10.0417 19.3958V17.7292H16.0625V16.6042H12.7292V9.70833H16.0625V8.77083C16.0625 7.10417 15.4757 5.67014 14.3021 4.46875C13.1285 3.26736 11.7049 2.66667 10.0312 2.66667C8.38542 2.66667 6.95833 3.26736 5.75 4.46875C4.54167 5.67014 3.9375 7.10417 3.9375 8.77083V9.70833H7.27083V16.6042H1.97917V8.775C1.97917 7.66722 2.19229 6.62306 2.61854 5.6425C3.04479 4.66195 3.62132 3.80319 4.34812 3.06625C5.07493 2.32931 5.92903 1.74861 6.91042 1.32417C7.89167 0.899722 8.93667 0.6875 10.0454 0.6875C11.154 0.6875 12.1944 0.899306 13.1667 1.32292C14.1389 1.74653 14.9868 2.32424 15.7104 3.05604C16.4342 3.78785 17.0036 4.64278 17.4187 5.62083C17.834 6.59889 18.0417 7.64889 18.0417 8.77083V19.3958H10.0417ZM3.9375 14.625H5.3125V11.6875H3.9375V14.625ZM14.7083 14.625H16.0625V11.6875H14.7083V14.625Z",fill:"#172128"})),De=t=>m.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M1.58334 12.6167V11.0333H14.4333V12.6167H1.58334ZM1.58334 8.78333V7.21666H14.4333V8.78333H1.58334ZM1.58334 4.96666V3.38333H14.4333V4.96666H1.58334Z",fill:"#172128"})),Pe=t=>m.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M12.7833 10.679C12.7833 11.9375 12.3239 12.9861 11.4053 13.825C10.4867 14.6639 9.39228 15.0834 8.12194 15.0834C6.85172 15.0834 5.76105 14.6639 4.84994 13.825C3.93883 12.9861 3.48328 11.9389 3.48328 10.6834V4.08336C3.48328 3.17869 3.81383 2.42197 4.47494 1.81319C5.13605 1.20441 5.92083 0.900024 6.82928 0.900024C7.73783 0.900024 8.52117 1.20441 9.17928 1.81319C9.8375 2.42197 10.1666 3.17869 10.1666 4.08336V10.35C10.1666 10.8935 9.96383 11.3543 9.55828 11.7325C9.15272 12.1109 8.673 12.3 8.11911 12.3C7.56533 12.3 7.09033 12.1127 6.69411 11.738C6.298 11.3634 6.09994 10.9007 6.09994 10.35V4.18336H7.54994V10.35C7.54994 10.4945 7.60711 10.6139 7.72144 10.7084C7.83578 10.8028 7.97267 10.85 8.13211 10.85C8.29155 10.85 8.42883 10.8036 8.54394 10.7109C8.65905 10.6181 8.71661 10.4978 8.71661 10.35V4.10002C8.72772 3.59714 8.54439 3.17975 8.16661 2.84786C7.78883 2.51597 7.34322 2.35002 6.82978 2.35002C6.31633 2.35002 5.87189 2.51352 5.49644 2.84052C5.121 3.16752 4.93328 3.5818 4.93328 4.08336V10.6834C4.94439 11.5417 5.26367 12.2507 5.89111 12.8105C6.51855 13.3702 7.2715 13.65 8.14994 13.65C9.01294 13.65 9.762 13.3695 10.3971 12.8084C11.0323 12.2472 11.3444 11.5389 11.3333 10.6834V3.70002H12.7833V10.679Z",fill:"white"})),Ve=t=>m.createElement("svg",{width:41,height:12,viewBox:"0 0 41 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("g",{clipPath:"url(#clip0_100_2379)"},m.createElement("path",{d:"M21.1825 7.56627H22.1696V5.46029C21.9697 5.38454 21.6628 5.35825 21.4373 5.35825C20.6381 5.35825 19.9407 5.89477 19.9261 6.85195H19.8885L19.4834 5.40815H17.7463V11.7965H20.0681V8.80642C20.0681 8.10324 20.2821 7.56672 21.1825 7.56672V7.56627Z",fill:"#172128"}),m.createElement("path",{d:"M2.31875 8.00074C2.31875 7.40005 2.55889 7.11976 3.04271 7.11976C3.48584 7.11976 3.69989 7.3996 3.69989 8.00074V11.7956H6.0217V8.00074C6.0217 7.40005 6.26184 7.11976 6.74256 7.11976C7.18835 7.11976 7.4024 7.3996 7.4024 8.00074V11.7956H9.72111V7.32385C9.72111 6.14831 9.12761 5.21786 7.68013 5.21786C6.74212 5.21786 6.14862 5.53603 5.78111 6.25036H5.75502C5.4627 5.62605 4.8661 5.21786 3.98028 5.21786C3.04227 5.21786 2.45761 5.53603 2.10426 6.25036H2.07817L1.80043 5.40725H3.8147e-05V11.7956H2.31875V8.00074Z",fill:"#172128"}),m.createElement("path",{d:"M10.1851 8.7301C10.1851 10.8129 11.8701 12 13.7227 12C15.5753 12 17.2837 10.8129 17.2837 8.7301V8.47342C17.2837 6.37903 15.5726 5.20349 13.7227 5.20349C11.8728 5.20349 10.1851 6.38215 10.1851 8.47342V8.7301ZM13.7346 7.02071C14.5975 7.02071 14.9765 7.70919 14.9765 8.59017C14.9765 9.47116 14.597 10.1743 13.7346 10.1743C12.8722 10.1743 12.4928 9.47116 12.4928 8.59017C12.4928 7.70919 12.8749 7.02071 13.7346 7.02071Z",fill:"#172128"}),m.createElement("path",{d:"M25.7969 5.20346C23.9324 5.20346 22.3867 6.43158 22.3867 8.47339V8.73007C22.3867 10.8623 24.0602 12 25.8982 12C27.3545 12 28.7874 11.2589 29.0797 9.70151H26.975C26.8101 10.1333 26.3669 10.2764 25.9618 10.2764C25.2264 10.2764 24.7837 9.76301 24.7315 9.08611H29.0912C29.1173 8.87044 29.1173 8.60173 29.1173 8.38293C29.1173 6.08444 27.3686 5.20346 25.7969 5.20346ZM24.7576 7.75862C24.8067 7.19848 25.137 6.71143 25.846 6.71143H25.8491C26.4948 6.71143 26.8623 7.19581 26.8623 7.75862H24.7576Z",fill:"#172128"}),m.createElement("path",{d:"M34.376 3.1975C33.6653 3.44883 32.9979 3.86058 32.4292 4.43319C31.8605 5.00581 31.4523 5.67824 31.2028 6.39435C30.9538 5.67824 30.5448 5.00581 29.9765 4.43275C29.4082 3.86013 28.7408 3.44838 28.0301 3.19705C28.7408 2.94572 29.4082 2.53398 29.9769 1.96136C30.5452 1.38874 30.9538 0.716307 31.2033 -0.000244141C31.4527 0.716307 31.8613 1.3883 32.4301 1.96136C32.9984 2.53398 33.6657 2.94572 34.3764 3.19705L34.376 3.1975Z",fill:"url(#paint0_linear_100_2379)"}),m.createElement("path",{d:"M35.4872 12.0001C34.8667 12.0001 34.2696 11.7715 33.9119 11.3869C33.5895 11.0621 33.4108 10.6655 33.4108 10.1722V10.1C33.4108 8.82507 34.4611 8.12769 35.9051 8.12769C36.4061 8.12769 36.9077 8.17581 37.3729 8.34426V7.94721C37.3729 6.92497 37.0027 6.27571 35.8812 6.27571C35.1413 6.27571 34.4492 6.5404 34.4134 7.38217H33.6854V7.30998C33.8287 6.0471 34.7835 5.61441 35.8578 5.61441C37.1708 5.61441 38.0898 6.17945 38.0898 7.93563V11.808H37.5768C37.4932 11.5915 37.4335 11.3508 37.3499 11.1347H37.326C36.932 11.6516 36.1682 12.0005 35.488 12.0005L35.4872 12.0001ZM37.3729 9.54697V9.01803C36.8718 8.84958 36.3823 8.76536 35.8812 8.76536C35.01 8.76536 34.1507 9.13834 34.1507 10.0643C34.1507 10.9061 34.7831 11.3152 35.6066 11.3152C36.43 11.3152 37.3729 10.5937 37.3729 9.54742V9.54697Z",fill:"#172128"}),m.createElement("path",{d:"M40.9998 3.77446C40.9998 4.09931 40.7371 4.3395 40.4152 4.3395C40.0932 4.3395 39.8305 4.09887 39.8305 3.77446V3.7504C39.8305 3.40148 40.0932 3.19739 40.4152 3.19739C40.7371 3.19739 40.9998 3.40193 40.9998 3.7504V3.77446ZM40.0569 11.8076V5.79444H40.7729V11.8076H40.0569Z",fill:"#172128"})),m.createElement("defs",null,m.createElement("linearGradient",{id:"paint0_linear_100_2379",x1:31.3237,y1:301678e-10,x2:34.1742,y2:2.06507,gradientUnits:"userSpaceOnUse"},m.createElement("stop",{stopColor:"#FA4B16"}),m.createElement("stop",{offset:1,stopColor:"#8E64EF"})),m.createElement("clipPath",{id:"clip0_100_2379"},m.createElement("rect",{width:41,height:12,fill:"white"})))),Oe=t=>m.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},m.createElement("path",{d:"M14.4241 8.00167C12.9851 8.50672 11.6338 9.33413 10.4822 10.4848C9.33067 11.6355 8.50415 12.9868 7.9991 14.4258C7.49495 12.9868 6.66664 11.6355 5.51596 10.4839C4.36528 9.33324 3.01402 8.50582 1.575 8.00078C3.01402 7.49573 4.36528 6.66832 5.51686 5.51764C6.66754 4.36696 7.49495 3.01569 8 1.57578C8.50504 3.01569 9.33246 4.36606 10.484 5.51764C11.6347 6.66832 12.986 7.49573 14.425 8.00078L14.4241 8.00167Z",fill:"url(#paint0_linear_100_2352)"}),m.createElement("defs",null,m.createElement("linearGradient",{id:"paint0_linear_100_2352",x1:8.24377,y1:1.57633,x2:13.9855,y2:5.76743,gradientUnits:"userSpaceOnUse"},m.createElement("stop",{stopColor:"#FA4B16"}),m.createElement("stop",{offset:1,stopColor:"#8E64EF"}))));function Ue({children:t,side:s="top",align:r="end"}){const{setIsChatScreen:i,isChatScreen:o}=$(),c=()=>{o||i(!0)};return e.jsxs(Z.Root,{children:[e.jsx(Z.Trigger,{asChild:!0,className:"data-[state=open]:mhb-outline data-[state=open]:mhb-outline-neutral-110",children:e.jsx("button",{type:"button",className:"mhb-h-12 mhb-w-12 mhb-rounded-[16px] mhb-bg-neutral-10 mhb-flex mhb-items-center mhb-justify-center",onClick:c,children:e.jsx($e,{className:"mhb-h-5 mhb-w-5"})})}),e.jsx(Z.Portal,{children:e.jsx(Z.Content,{side:s,align:r,sideOffset:12,className:`mhb-popover
1
+ "use strict";var Te=Object.create;var ce=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Ie=(t,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of Ae(n))!He.call(t,l)&&l!==s&&ce(t,l,{get:()=>n[l],enumerable:!(r=Me(n,l))||r.enumerable});return t};var ie=(t,n,s)=>(s=t!=null?Te(Le(t)):{},Ie(n||!t||!t.__esModule?ce(s,"default",{value:t,enumerable:!0}):s,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),Re=require("@radix-ui/react-popover");function we(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return n.default=t,Object.freeze(n)}const c=we(e),F=we(Re);let $e=[];function De(t){$e.forEach(n=>n(t))}const Ee=e.createContext(void 0),Ve=({children:t,token:n})=>{const[s,r]=e.useState(n||""),[l,i]=e.useState(!0),[m,h]=e.useState(null);return e.useEffect(()=>{},[]),e.createElement(Ee.Provider,{value:{accessToken:s,isChatScreen:l,setIsChatScreen:i,profileInfo:m,setProfileInfo:h}},t)},$=()=>{const t=e.useContext(Ee);if(!t)throw new Error("useSdkContext must be used inside SDKProvider");return t},Oe=t=>c.createElement("svg",{width:36,height:36,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M15.8261 8.67349C12.4046 8.67349 9.63062 11.447 9.63062 14.8685C9.63062 18.29 12.4046 21.064 15.8261 21.064C16.1656 21.064 16.4991 21.0365 16.8241 20.984C15.0221 20.4765 13.7006 18.8205 13.7006 16.856C13.7006 14.4875 15.6206 12.568 17.9886 12.568C19.8251 12.568 21.3921 13.722 22.0031 15.345C22.0151 15.188 22.0211 15.029 22.0211 14.8685C22.0211 11.447 19.2476 8.67349 15.8261 8.67349Z",fill:"#B72402"}),c.createElement("path",{d:"M17.9984 7.621C13.0309 7.621 9.00342 11.6485 9.00342 16.616C9.00342 20.526 11.4949 23.8495 14.9744 25.0915V27.785C14.9744 28.228 15.4404 28.515 15.8349 28.3125C17.5759 27.4215 21.5219 25.332 23.5549 23.696C23.6114 23.65 23.6674 23.6065 23.7214 23.5605C23.7624 23.527 23.8009 23.494 23.8394 23.4605C25.7724 21.8115 26.9964 19.356 26.9964 16.616C26.9964 11.6485 22.9689 7.621 17.9989 7.621H17.9984ZM15.8274 21.064C15.5379 21.064 15.2539 21.0435 14.9749 21.005C11.9559 20.59 9.63092 18.0015 9.63092 14.8675C9.63092 11.4465 12.4039 8.6735 15.8274 8.6735C19.2509 8.6735 22.0214 11.4465 22.0214 14.8675C22.0214 15.0265 22.0164 15.185 22.0034 15.341C21.8319 17.6225 20.4259 19.5555 18.4544 20.48C17.9424 20.7205 17.3919 20.892 16.8154 20.9845C16.4929 21.036 16.1624 21.064 15.8269 21.064H15.8274Z",fill:"#FA4B16"})),Pe=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M14.4167 3.58334L14.4167 5.13334L5.58341 5.13333L5.58341 3.58333L14.4167 3.58334ZM2.66675 4.5L6.06675 8.01667L2.68341 11.5167L1.56675 10.4L3.86675 8.01667L1.55008 5.61667L2.66675 4.5ZM14.4167 7.25L14.4167 8.81667L7.48341 8.81667L7.48341 7.25L14.4167 7.25ZM14.4167 10.8667L14.4167 12.4333L5.58341 12.4333L5.58341 10.8667L14.4167 10.8667Z",fill:"#172128"})),je=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M13.25 14.45L8.7667 9.98335C8.44448 10.238 8.06414 10.4378 7.6257 10.5827C7.18725 10.7276 6.71203 10.8 6.20003 10.8C4.92048 10.8 3.8367 10.3556 2.9487 9.46668C2.0607 8.57779 1.6167 7.50557 1.6167 6.25001C1.6167 4.99446 2.06114 3.92223 2.95003 3.03335C3.83892 2.14446 4.91392 1.70001 6.17503 1.70001C7.43614 1.70001 8.50837 2.14446 9.3917 3.03335C10.275 3.92223 10.7167 4.99529 10.7167 6.25251C10.7167 6.75085 10.6473 7.2139 10.5084 7.64168C10.3695 8.06946 10.1611 8.47223 9.88337 8.85001L14.3834 13.3167L13.25 14.45ZM6.1892 9.23335C7.02142 9.23335 7.72298 8.94307 8.29387 8.36251C8.86464 7.78196 9.15003 7.07779 9.15003 6.25001C9.15003 5.42223 8.86381 4.71807 8.29137 4.13751C7.71892 3.55696 7.0182 3.26668 6.1892 3.26668C5.35109 3.26668 4.64059 3.55696 4.0577 4.13751C3.47481 4.71807 3.18337 5.42223 3.18337 6.25001C3.18337 7.07779 3.47398 7.78196 4.0552 8.36251C4.63642 8.94307 5.34775 9.23335 6.1892 9.23335Z",fill:"#172128"})),Ue=t=>c.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M10.0417 19.3958V17.7292H16.0625V16.6042H12.7292V9.70833H16.0625V8.77083C16.0625 7.10417 15.4757 5.67014 14.3021 4.46875C13.1285 3.26736 11.7049 2.66667 10.0312 2.66667C8.38542 2.66667 6.95833 3.26736 5.75 4.46875C4.54167 5.67014 3.9375 7.10417 3.9375 8.77083V9.70833H7.27083V16.6042H1.97917V8.775C1.97917 7.66722 2.19229 6.62306 2.61854 5.6425C3.04479 4.66195 3.62132 3.80319 4.34812 3.06625C5.07493 2.32931 5.92903 1.74861 6.91042 1.32417C7.89167 0.899722 8.93667 0.6875 10.0454 0.6875C11.154 0.6875 12.1944 0.899306 13.1667 1.32292C14.1389 1.74653 14.9868 2.32424 15.7104 3.05604C16.4342 3.78785 17.0036 4.64278 17.4187 5.62083C17.834 6.59889 18.0417 7.64889 18.0417 8.77083V19.3958H10.0417ZM3.9375 14.625H5.3125V11.6875H3.9375V14.625ZM14.7083 14.625H16.0625V11.6875H14.7083V14.625Z",fill:"#172128"})),Fe=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M1.58334 12.6167V11.0333H14.4333V12.6167H1.58334ZM1.58334 8.78333V7.21666H14.4333V8.78333H1.58334ZM1.58334 4.96666V3.38333H14.4333V4.96666H1.58334Z",fill:"#172128"})),Ze=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M12.7833 10.679C12.7833 11.9375 12.3239 12.9861 11.4053 13.825C10.4867 14.6639 9.39228 15.0834 8.12194 15.0834C6.85172 15.0834 5.76105 14.6639 4.84994 13.825C3.93883 12.9861 3.48328 11.9389 3.48328 10.6834V4.08336C3.48328 3.17869 3.81383 2.42197 4.47494 1.81319C5.13605 1.20441 5.92083 0.900024 6.82928 0.900024C7.73783 0.900024 8.52117 1.20441 9.17928 1.81319C9.8375 2.42197 10.1666 3.17869 10.1666 4.08336V10.35C10.1666 10.8935 9.96383 11.3543 9.55828 11.7325C9.15272 12.1109 8.673 12.3 8.11911 12.3C7.56533 12.3 7.09033 12.1127 6.69411 11.738C6.298 11.3634 6.09994 10.9007 6.09994 10.35V4.18336H7.54994V10.35C7.54994 10.4945 7.60711 10.6139 7.72144 10.7084C7.83578 10.8028 7.97267 10.85 8.13211 10.85C8.29155 10.85 8.42883 10.8036 8.54394 10.7109C8.65905 10.6181 8.71661 10.4978 8.71661 10.35V4.10002C8.72772 3.59714 8.54439 3.17975 8.16661 2.84786C7.78883 2.51597 7.34322 2.35002 6.82978 2.35002C6.31633 2.35002 5.87189 2.51352 5.49644 2.84052C5.121 3.16752 4.93328 3.5818 4.93328 4.08336V10.6834C4.94439 11.5417 5.26367 12.2507 5.89111 12.8105C6.51855 13.3702 7.2715 13.65 8.14994 13.65C9.01294 13.65 9.762 13.3695 10.3971 12.8084C11.0323 12.2472 11.3444 11.5389 11.3333 10.6834V3.70002H12.7833V10.679Z",fill:"white"})),Be=t=>c.createElement("svg",{width:41,height:12,viewBox:"0 0 41 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("g",{clipPath:"url(#clip0_100_2379)"},c.createElement("path",{d:"M21.1825 7.56627H22.1696V5.46029C21.9697 5.38454 21.6628 5.35825 21.4373 5.35825C20.6381 5.35825 19.9407 5.89477 19.9261 6.85195H19.8885L19.4834 5.40815H17.7463V11.7965H20.0681V8.80642C20.0681 8.10324 20.2821 7.56672 21.1825 7.56672V7.56627Z",fill:"#172128"}),c.createElement("path",{d:"M2.31875 8.00074C2.31875 7.40005 2.55889 7.11976 3.04271 7.11976C3.48584 7.11976 3.69989 7.3996 3.69989 8.00074V11.7956H6.0217V8.00074C6.0217 7.40005 6.26184 7.11976 6.74256 7.11976C7.18835 7.11976 7.4024 7.3996 7.4024 8.00074V11.7956H9.72111V7.32385C9.72111 6.14831 9.12761 5.21786 7.68013 5.21786C6.74212 5.21786 6.14862 5.53603 5.78111 6.25036H5.75502C5.4627 5.62605 4.8661 5.21786 3.98028 5.21786C3.04227 5.21786 2.45761 5.53603 2.10426 6.25036H2.07817L1.80043 5.40725H3.8147e-05V11.7956H2.31875V8.00074Z",fill:"#172128"}),c.createElement("path",{d:"M10.1851 8.7301C10.1851 10.8129 11.8701 12 13.7227 12C15.5753 12 17.2837 10.8129 17.2837 8.7301V8.47342C17.2837 6.37903 15.5726 5.20349 13.7227 5.20349C11.8728 5.20349 10.1851 6.38215 10.1851 8.47342V8.7301ZM13.7346 7.02071C14.5975 7.02071 14.9765 7.70919 14.9765 8.59017C14.9765 9.47116 14.597 10.1743 13.7346 10.1743C12.8722 10.1743 12.4928 9.47116 12.4928 8.59017C12.4928 7.70919 12.8749 7.02071 13.7346 7.02071Z",fill:"#172128"}),c.createElement("path",{d:"M25.7969 5.20346C23.9324 5.20346 22.3867 6.43158 22.3867 8.47339V8.73007C22.3867 10.8623 24.0602 12 25.8982 12C27.3545 12 28.7874 11.2589 29.0797 9.70151H26.975C26.8101 10.1333 26.3669 10.2764 25.9618 10.2764C25.2264 10.2764 24.7837 9.76301 24.7315 9.08611H29.0912C29.1173 8.87044 29.1173 8.60173 29.1173 8.38293C29.1173 6.08444 27.3686 5.20346 25.7969 5.20346ZM24.7576 7.75862C24.8067 7.19848 25.137 6.71143 25.846 6.71143H25.8491C26.4948 6.71143 26.8623 7.19581 26.8623 7.75862H24.7576Z",fill:"#172128"}),c.createElement("path",{d:"M34.376 3.1975C33.6653 3.44883 32.9979 3.86058 32.4292 4.43319C31.8605 5.00581 31.4523 5.67824 31.2028 6.39435C30.9538 5.67824 30.5448 5.00581 29.9765 4.43275C29.4082 3.86013 28.7408 3.44838 28.0301 3.19705C28.7408 2.94572 29.4082 2.53398 29.9769 1.96136C30.5452 1.38874 30.9538 0.716307 31.2033 -0.000244141C31.4527 0.716307 31.8613 1.3883 32.4301 1.96136C32.9984 2.53398 33.6657 2.94572 34.3764 3.19705L34.376 3.1975Z",fill:"url(#paint0_linear_100_2379)"}),c.createElement("path",{d:"M35.4872 12.0001C34.8667 12.0001 34.2696 11.7715 33.9119 11.3869C33.5895 11.0621 33.4108 10.6655 33.4108 10.1722V10.1C33.4108 8.82507 34.4611 8.12769 35.9051 8.12769C36.4061 8.12769 36.9077 8.17581 37.3729 8.34426V7.94721C37.3729 6.92497 37.0027 6.27571 35.8812 6.27571C35.1413 6.27571 34.4492 6.5404 34.4134 7.38217H33.6854V7.30998C33.8287 6.0471 34.7835 5.61441 35.8578 5.61441C37.1708 5.61441 38.0898 6.17945 38.0898 7.93563V11.808H37.5768C37.4932 11.5915 37.4335 11.3508 37.3499 11.1347H37.326C36.932 11.6516 36.1682 12.0005 35.488 12.0005L35.4872 12.0001ZM37.3729 9.54697V9.01803C36.8718 8.84958 36.3823 8.76536 35.8812 8.76536C35.01 8.76536 34.1507 9.13834 34.1507 10.0643C34.1507 10.9061 34.7831 11.3152 35.6066 11.3152C36.43 11.3152 37.3729 10.5937 37.3729 9.54742V9.54697Z",fill:"#172128"}),c.createElement("path",{d:"M40.9998 3.77446C40.9998 4.09931 40.7371 4.3395 40.4152 4.3395C40.0932 4.3395 39.8305 4.09887 39.8305 3.77446V3.7504C39.8305 3.40148 40.0932 3.19739 40.4152 3.19739C40.7371 3.19739 40.9998 3.40193 40.9998 3.7504V3.77446ZM40.0569 11.8076V5.79444H40.7729V11.8076H40.0569Z",fill:"#172128"})),c.createElement("defs",null,c.createElement("linearGradient",{id:"paint0_linear_100_2379",x1:31.3237,y1:301678e-10,x2:34.1742,y2:2.06507,gradientUnits:"userSpaceOnUse"},c.createElement("stop",{stopColor:"#FA4B16"}),c.createElement("stop",{offset:1,stopColor:"#8E64EF"})),c.createElement("clipPath",{id:"clip0_100_2379"},c.createElement("rect",{width:41,height:12,fill:"white"})))),Ge=t=>c.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},c.createElement("path",{d:"M14.4241 8.00167C12.9851 8.50672 11.6338 9.33413 10.4822 10.4848C9.33067 11.6355 8.50415 12.9868 7.9991 14.4258C7.49495 12.9868 6.66664 11.6355 5.51596 10.4839C4.36528 9.33324 3.01402 8.50582 1.575 8.00078C3.01402 7.49573 4.36528 6.66832 5.51686 5.51764C6.66754 4.36696 7.49495 3.01569 8 1.57578C8.50504 3.01569 9.33246 4.36606 10.484 5.51764C11.6347 6.66832 12.986 7.49573 14.425 8.00078L14.4241 8.00167Z",fill:"url(#paint0_linear_100_2352)"}),c.createElement("defs",null,c.createElement("linearGradient",{id:"paint0_linear_100_2352",x1:8.24377,y1:1.57633,x2:13.9855,y2:5.76743,gradientUnits:"userSpaceOnUse"},c.createElement("stop",{stopColor:"#FA4B16"}),c.createElement("stop",{offset:1,stopColor:"#8E64EF"}))));function Ke({children:t,side:n="top",align:s="end"}){const{setIsChatScreen:r,isChatScreen:l}=$(),i=()=>{l||r(!0)};return c.createElement(F.Root,null,c.createElement(F.Trigger,{asChild:!0,className:"data-[state=open]:mhb-outline data-[state=open]:mhb-outline-neutral-110"},c.createElement("button",{type:"button",className:"mhb-h-12 mhb-w-12 mhb-rounded-[16px] mhb-bg-neutral-10 mhb-flex mhb-items-center mhb-justify-center",onClick:i},c.createElement(Ue,{className:"mhb-h-5 mhb-w-5"}))),c.createElement(F.Portal,null,c.createElement(F.Content,{side:n,align:s,sideOffset:12,className:`mhb-popover
2
2
  mhb-flex mhb-flex-col
3
3
  mhb-h-[460px] mhb-max-h-[460px]
4
4
  mhb-w-[323px]
@@ -6,7 +6,7 @@
6
6
  mhb-rounded-[16px]
7
7
  mhb-border mhb-border-neutral-10
8
8
  mhb-shadow-[0_4px_20px_rgba(23,33,40,0.05)]
9
- mhb-overflow-hidden`,children:e.jsx("div",{className:"mhb-popover-children mhb-h-full mhb-flex mhb-flex-col",children:t})})})]})}const Fe=({forwardedRef:t,onChangeHandler:s})=>e.jsxs("div",{className:"mhb-h-[48px] mhb-flex mhb-rounded-[9999px] mhb-bg-neutral-10 mhb-items-center mhb-gap-3 mhb-px-3",children:[e.jsx(Re,{className:"mhb-h-4 mhb-w-4"}),e.jsx("input",{ref:t,onChange:s,type:"text",placeholder:"Search your chats",className:`
9
+ mhb-overflow-hidden`},c.createElement("div",{className:"mhb-popover-children mhb-h-full mhb-flex mhb-flex-col"},t))))}const qe=({forwardedRef:t,onChangeHandler:n})=>e.createElement("div",{className:"mhb-h-[48px] mhb-flex mhb-rounded-[9999px] mhb-bg-neutral-10 mhb-items-center mhb-gap-3 mhb-px-3"},e.createElement(je,{className:"mhb-h-4 mhb-w-4"}),e.createElement("input",{ref:t,onChange:n,type:"text",placeholder:"Search your chats",className:`
10
10
  mhb-input
11
11
  mhb-flex-1
12
12
  mhb-w-full
@@ -19,7 +19,7 @@
19
19
  mhb-overflow-visible
20
20
  placeholder:mhb-text-neutral-40
21
21
  focus:mhb-outline-none
22
- `})]}),Ze=a.forwardRef((t,s)=>e.jsx(Fe,{...t,forwardedRef:s})),J=({className:t="mhb-w-8 mhb-h-8"})=>e.jsx("div",{className:"mhb-flex mhb-items-center mhb-justify-center",children:e.jsx("svg",{className:`${t} mhb-animate-spin mhb-text-neutral-110`,viewBox:"0 0 50 50",children:e.jsx("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:"60"})})});let T=null,X=0,re=!1,Be=0;const I={};let B=!1,q="",ve="",G="",ae=[],ee=!1;function qe(){const s={host:new URL(q).hostname,"x-api-key":G},r={},i=btoa(JSON.stringify(s)),o=btoa(JSON.stringify(r)),c=`${ve}?header=${i}&payload=${o}`;return new WebSocket(c,["graphql-ws"])}const je=()=>{re=!1,T=qe(),B=!1,T.onopen=()=>{X=0,T?.send(JSON.stringify({type:"connection_init"}))},T.onmessage=t=>{const s=JSON.parse(t.data);if(B)s.type==="error"||(s.type==="data"&&I[s.id]?I[s.id].callback(s.payload.data):s.type==="complete"&&I[s.id]&&delete I[s.id]);else if(s.type==="connection_ack"){B=!0;for(const r in I)T?.send(JSON.stringify(I[r].message))}},T.onclose=()=>{if(re)return;const t=Math.min(1e3*Math.pow(2,X)+Math.random()*1e3,3e4);setTimeout(()=>{X++,je()},t)},T.onerror=()=>{T?.close()}},me=(t,s=null)=>{ae.forEach(({resolve:r,reject:i})=>{t?i(t):s&&r(s)}),ae=[]},Ge=()=>new Promise((t,s)=>{ae.push({resolve:t,reject:s})}),Ke=t=>{q=t.apiURL,G=t.apiKey,ve=t.apiURL.replace("https://","wss://").replace("appsync-api","appsync-realtime-api"),je();const s=async(r,i={},o)=>{const h=await(await fetch(q,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":G,...o?{Authorization:`Bearer ${o}`}:{}},body:JSON.stringify({query:r,variables:i})})).json(),u=Array.isArray(h.errors)?h.errors:[];if(u.some(l=>{const d=l.message?.toLowerCase()??"";return d.includes("unauthorized")||d.includes("jwt")||d.includes("expired")})){if(ee){const l=await Ge();return s(r,i,l)}ee=!0;try{let l;if(process.env.NODE_ENV==="development"){const d=await new Promise(v=>{Ae(A=>v(A))});l=await D.SSOAuthorization.getDevToken(d.employee_id)}else{const d=window.location.href,v=encodeURIComponent(d);l=await D.SSOAuthorization.getToken(v)}if(!l?.token)throw new Error("Refresh did not return an access token");return Ee(l.token),me(null,l.token),s(r,i,l.token)}catch(l){throw me(l,null),l}finally{ee=!1}}if(u.length>0)throw new Error(u.map(l=>l.message).join(", "));return h.data};return{executeGraphql:s,subscribe:(r,i={},o)=>{if(!r.trim().startsWith("subscription"))return()=>{};const c=`${++Be}`,h={id:c,type:"start",payload:{data:JSON.stringify({query:r,variables:i}),extensions:{authorization:{host:new URL(q).hostname,"x-api-key":G}}}};return I[c]={message:h,callback:o},B&&T?.readyState===WebSocket.OPEN&&T.send(JSON.stringify(h)),()=>{T?.readyState===WebSocket.OPEN&&T.send(JSON.stringify({id:c,type:"stop"})),delete I[c]}},close:()=>{re=!0,T?.close()}}};let R;const ze=t=>{R||(R=Ke(t))},O=async(t,s={},r)=>{if(!R)throw new Error("client is not created");return R.executeGraphql(t,s,r)},K=async(t,s={},r)=>{if(!R)throw new Error("client is not created");return R.executeGraphql(t,s,r)},de=(t,s={},r)=>{if(!R)throw new Error("client is not created");return R.subscribe(t,s,r)},ue=`query AssistHistory($limit: Int, $offset: Int , $ticket_id: Int) {
22
+ `})),ze=e.forwardRef((t,n)=>e.createElement(qe,{...t,forwardedRef:n})),W=({className:t="mhb-w-8 mhb-h-8"})=>e.createElement("div",{className:"mhb-flex mhb-items-center mhb-justify-center"},e.createElement("svg",{className:`${t} mhb-animate-spin mhb-text-neutral-110`,viewBox:"0 0 50 50"},e.createElement("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:"60"})));let N=null,Q=0,te=!1,We=0;const I={};let Z=!1,B="",Ce="",G="",oe=!1;function Je(){const n={host:new URL(B).hostname,"x-api-key":G},s={},r=btoa(JSON.stringify(n)),l=btoa(JSON.stringify(s)),i=`${Ce}?header=${r}&payload=${l}`;return new WebSocket(i,["graphql-ws"])}const ve=()=>{te=!1,N=Je(),Z=!1,N.onopen=()=>{Q=0,N?.send(JSON.stringify({type:"connection_init"}))},N.onmessage=t=>{const n=JSON.parse(t.data);if(Z)n.type==="error"||(n.type==="data"&&I[n.id]?I[n.id].callback(n.payload.data):n.type==="complete"&&I[n.id]&&delete I[n.id]);else if(n.type==="connection_ack"){Z=!0;for(const s in I)N?.send(JSON.stringify(I[s].message))}},N.onclose=()=>{if(te)return;const t=Math.min(1e3*Math.pow(2,Q)+Math.random()*1e3,3e4);setTimeout(()=>{Q++,ve()},t)},N.onerror=()=>{N?.close()}},Ye=()=>new Promise((t,n)=>{}),Qe=t=>{B=t.apiURL,G=t.apiKey,Ce=t.apiURL.replace("https://","wss://").replace("appsync-api","appsync-realtime-api"),ve();const n=async(s,r={},l)=>{const m=await(await fetch(B,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":G,...l?{Authorization:`Bearer ${l}`}:{}},body:JSON.stringify({query:s,variables:r})})).json(),h=Array.isArray(m.errors)?m.errors:[];if(h.some(o=>{const p=o.message?.toLowerCase()??"";return p.includes("unauthorized")||p.includes("jwt")||p.includes("expired")})){if(oe){const o=await Ye();return n(s,r,o)}oe=!0}if(h.length>0)throw new Error(h.map(o=>o.message).join(", "));return m.data};return{executeGraphql:n,subscribe:(s,r={},l)=>{if(!s.trim().startsWith("subscription"))return()=>{};const i=`${++We}`,m={id:i,type:"start",payload:{data:JSON.stringify({query:s,variables:r}),extensions:{authorization:{host:new URL(B).hostname,"x-api-key":G}}}};return I[i]={message:m,callback:l},Z&&N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify(m)),()=>{N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify({id:i,type:"stop"})),delete I[i]}},close:()=>{te=!0,N?.close()}}};let R;const Xe=t=>{R||(R=Qe(t))},P=async(t,n={},s)=>{if(!R)throw new Error("client is not created");return R.executeGraphql(t,n,s)},K=async(t,n={},s)=>{if(!R)throw new Error("client is not created");return R.executeGraphql(t,n,s)},me=(t,n={},s)=>{if(!R)throw new Error("client is not created");return R.subscribe(t,n,s)},he=`query AssistHistory($limit: Int, $offset: Int , $ticket_id: Int) {
23
23
  assistHistory(limit: $limit, offset: $offset, ticket_id: $ticket_id) {
24
24
  message_id
25
25
  text
@@ -37,7 +37,7 @@
37
37
  user_name
38
38
  user_type
39
39
  }
40
- }}`,be=`query EmployeeAssistTickets($search_key: String $limit: Int, $offset: Int) {
40
+ }}`,ue=`query EmployeeAssistTickets($search_key: String $limit: Int, $offset: Int) {
41
41
  EmployeeAssistTickets(search_key: $search_key limit: $limit, offset: $offset) {
42
42
  ticket_id
43
43
  parent_id
@@ -69,12 +69,12 @@
69
69
  chat_handover
70
70
  is_new
71
71
  }
72
- }`,Je=`query AllowedTocreateTicket {
72
+ }`,et=`query AllowedTocreateTicket {
73
73
  AllowedTocreateTicket {
74
74
  allowed
75
75
  count
76
76
  }
77
- }`,pe=10,We=()=>{const[t,s]=a.useState([]),[r,i]=a.useState(!0),[o,c]=a.useState(null),[h,u]=a.useState(!1),[y,l]=a.useState(""),d=a.useRef(!0),{accessToken:v}=$(),A=()=>{O(be,{limit:pe,search_key:y},v).then(async b=>{s(b?.EmployeeAssistTickets??[])}).catch(b=>{c(b)}).finally(()=>{i(!1)})};return a.useEffect(()=>{if(d.current){d.current=!1,A();return}const b=setTimeout(()=>{A()},400);return()=>clearTimeout(b)},[y]),{ticketData:t,loading:r,error:o,getNextPageTicketData:b=>{v&&(h||(u(!0),O(be,{limit:pe,offset:b},v).then(async w=>{const{EmployeeAssistTickets:M}=w;s(L=>[...L,...M])}).catch(w=>{c(w)}).finally(()=>{u(!1)})))},isLoadingMore:h,setSearchText:l}};function te(t){return(t?new Date(t):new Date).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:"Asia/Kolkata"})}function Ye(t,s="Asia/Kolkata",r="en-GB"){const i=new Date(t);if(Number.isNaN(i.getTime()))return"";const o=new Intl.DateTimeFormat(r,{day:"2-digit",month:"short",year:"2-digit",timeZone:s}).formatToParts(i),c=o.find(l=>l.type==="day")?.value??"",h=o.find(l=>l.type==="month")?.value??"",u=o.find(l=>l.type==="year")?.value??"",y=new Intl.DateTimeFormat(r,{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:s}).format(i);return`${c} ${h} ‘${u}, ${y}`}const ie=(t,s)=>{sessionStorage.setItem(t,JSON.stringify(s))},V=t=>{const s=sessionStorage.getItem(t);return s?JSON.parse(s):null},Qe=()=>{const t=a.useRef(null),s=a.useRef(null),r=a.useRef(null),{ticketData:i,loading:o,getNextPageTicketData:c,isLoadingMore:h,setSearchText:u}=We(),{setIsChatScreen:y,profileInfo:l}=$();a.useLayoutEffect(()=>{t.current},[i.length]);const d=S=>{const b=S.currentTarget;if(r.current?.blur(),b.scrollHeight<=b.clientHeight)return;const w=b.scrollHeight-b.scrollTop-b.clientHeight,M=i.length;s.current!==M&&w<=20&&!o&&(s.current=M,c(M))},v=S=>{ie("userAndTicket",{ticket_id:S,employee_id:l?.employee_id}),y(b=>!b)},A=S=>{S.preventDefault();const b=r.current?.value?.trim();u(b??null)};return e.jsxs("div",{className:"mhb-flex mhb-flex-col mhb-h-full mhb-min-h-0",children:[e.jsx("div",{className:"mhb-searchbarContainer mhb-flex mhb-flex-col mhb-border-b mhb-border-neutral-20",children:e.jsx(Ze,{ref:r,onChangeHandler:A})}),e.jsx("div",{ref:t,onScroll:d,className:"mhb-history-main-container mhb-no-scrollbar mhb-py-3 mhb-flex mhb-flex-col mhb-gap-1 mhb-overflow-y-auto mhb-flex-1 mhb-min-h-0",children:o?e.jsx(J,{}):e.jsxs(e.Fragment,{children:[i.map(S=>e.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-history-container mhb-p-3 mhb-flex mhb-flex-col mhb-rounded-[12px] mhb-bg-neutral-10 mhb-gap-2 mhb-items-start",onClick:()=>v(S.ticket_id),children:[e.jsx("div",{className:"mhb-flex mhb-items-start",children:e.jsx("p",{className:"mhb-typography-para-thick-30 mhb-text-neutral-110 mhb-m-0 mhb-min-w-0 mhb-break-words mhb-whitespace-normal mhb-text-left",children:S.title})}),e.jsx("p",{className:"mhb-typography-para-30 mhb-text-neutral-60 mhb-m-0",children:Ye(S.created_at)})]},S.ticket_id)),h&&e.jsx(J,{})]})})]})},Xe=()=>{const[t,s]=a.useState(!1),[r,i]=a.useState(null),{accessToken:o}=$();return{loading:t,error:r,getAllowedToChat:async()=>{try{return s(!0),await O(Je,{},o)}catch(h){i(h)}finally{s(!1)}}}},ke=({toastMsg:t})=>e.jsxs("div",{id:"toast-simple",className:"mhb-border-red-60 mhb-fixed mhb-bottom-6 mhb-right-6 mhb-z-50 mhb-flex mhb-max-w-xs mhb-items-center mhb-space-x-4 mhb-divide-x mhb-divide-gray-200 mhb-rounded-lg mhb-border mhb-bg-white mhb-p-4 mhb-text-gray-700 mhb-shadow-lg dark:mhb-divide-gray-700 dark:mhb-border-gray-600 dark:mhb-bg-gray-800 dark:mhb-text-gray-300",role:"alert",children:[e.jsx("svg",{className:"mhb-text-red-60 mhb-h-3 mhb-w-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:e.jsx("path",{stroke:"currentColor",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),e.jsx("div",{className:"mhb-text-red-60 mhb-typography-label-thick-30 mhb-ps-4",children:t})]}),et=({isChatScreen:t,setIsChatScreen:s})=>{const[r,i]=a.useState(""),{getAllowedToChat:o,loading:c}=Xe(),h=a.useRef();a.useEffect(()=>()=>clearTimeout(h.current),[]);const u=()=>{s(l=>!l)},y=async()=>{(await o())?.AllowedTocreateTicket?.allowed?(sessionStorage.removeItem("userAndTicket"),s(d=>!d)):(i("You have reached the chat limit. A new chat will be available once an agent closes one."),h.current=setTimeout(()=>{i("")},1500))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mhb-header mhb-border-b mhb-border-neutral-20 mhb-flex mhb-items-center mhb-justify-between",children:[e.jsx(He,{className:"h-[36px] w-[36px] fill-current"}),e.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t?e.jsx("div",{className:"mhb-btn-reset mhb-p-3 mhb-invisible mhb-typography-para-thick-30",children:"new chat"}):e.jsx("button",{type:"button",onClick:y,disabled:c,className:"mhb-btn-reset mhb-p-3 mhb-bg-neutral-10 mhb-typography-para-thick-30 mhb-rounded-[9999px]",children:c?e.jsx(J,{className:"mhb-w-4 mhb-h-4"}):"new chat"}),e.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-flex mhb-items-center mhb-justify-center mhb-rounded-full mhb-bg-neutral-10",onClick:u,children:t?e.jsx(De,{className:"mhb-h-[16px] mhb-w-[16px] fill-current"}):e.jsx(Ie,{className:"mhb-h-[16px] mhb-w-[16px]"})})]})]}),r&&e.jsx("div",{className:"mhb-ml-[12px]",children:e.jsx(ke,{toastMsg:r})})]})},fe=`
77
+ }`,be=10,tt=()=>{const[t,n]=e.useState([]),[s,r]=e.useState(!0),[l,i]=e.useState(null),[m,h]=e.useState(!1),[d,o]=e.useState(""),p=e.useRef(!0),{accessToken:S}=$(),A=()=>{P(ue,{limit:be,search_key:d},S).then(async u=>{n(u?.EmployeeAssistTickets??[])}).catch(u=>{i(u)}).finally(()=>{r(!1)})};return e.useEffect(()=>{if(p.current){p.current=!1,A();return}const u=setTimeout(()=>{A()},400);return()=>clearTimeout(u)},[d]),{ticketData:t,loading:s,error:l,getNextPageTicketData:u=>{S&&(m||(h(!0),P(ue,{limit:be,offset:u},S).then(async w=>{const{EmployeeAssistTickets:M}=w;n(L=>[...L,...M])}).catch(w=>{i(w)}).finally(()=>{h(!1)})))},isLoadingMore:m,setSearchText:o}};function X(t){return(t?new Date(t):new Date).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:"Asia/Kolkata"})}function nt(t,n="Asia/Kolkata",s="en-GB"){const r=new Date(t);if(Number.isNaN(r.getTime()))return"";const l=new Intl.DateTimeFormat(s,{day:"2-digit",month:"short",year:"2-digit",timeZone:n}).formatToParts(r),i=l.find(o=>o.type==="day")?.value??"",m=l.find(o=>o.type==="month")?.value??"",h=l.find(o=>o.type==="year")?.value??"",d=new Intl.DateTimeFormat(s,{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:n}).format(r);return`${i} ${m} ‘${h}, ${d}`}const ne={};function _e(){try{if(typeof window>"u")return null;if(window.sessionStorage)return window.sessionStorage}catch{}try{if(window.localStorage)return window.localStorage}catch{}return null}function ae(t,n){const s=JSON.stringify(n),r=_e();r?r.setItem(t,s):ne[t]=s}function V(t){const n=_e();if(n){const s=n.getItem(t);return s?JSON.parse(s):null}return ne[t]?JSON.parse(ne[t]):null}const de=()=>{const t=e.useRef(null),n=e.useRef(null),s=e.useRef(null),{ticketData:r,loading:l,getNextPageTicketData:i,isLoadingMore:m,setSearchText:h}=tt(),{setIsChatScreen:d,profileInfo:o}=$();e.useLayoutEffect(()=>{t.current},[r.length]);const p=k=>{const u=k.currentTarget;if(s.current?.blur(),u.scrollHeight<=u.clientHeight)return;const w=u.scrollHeight-u.scrollTop-u.clientHeight,M=r.length;n.current!==M&&w<=20&&!l&&(n.current=M,i(M))},S=k=>{ae("userAndTicket",{ticket_id:k,employee_id:o?.employee_id}),d(u=>!u)},A=k=>{k.preventDefault();const u=s.current?.value?.trim();h(u??null)};return e.createElement("div",{className:"mhb-flex mhb-flex-col mhb-h-full mhb-min-h-0"},e.createElement("div",{className:"mhb-searchbarContainer mhb-flex mhb-flex-col mhb-border-b mhb-border-neutral-20"},e.createElement(ze,{ref:s,onChangeHandler:A})),e.createElement("div",{ref:t,onScroll:p,className:"mhb-history-main-container mhb-no-scrollbar mhb-py-3 mhb-flex mhb-flex-col mhb-gap-1 mhb-overflow-y-auto mhb-flex-1 mhb-min-h-0"},l?e.createElement(W,null):e.createElement(e.Fragment,null,r.map(k=>e.createElement("button",{type:"button",key:k.ticket_id,className:"mhb-btn-reset mhb-history-container mhb-p-3 mhb-flex mhb-flex-col mhb-rounded-[12px] mhb-bg-neutral-10 mhb-gap-2 mhb-items-start",onClick:()=>S(k.ticket_id)},e.createElement("div",{className:"mhb-flex mhb-items-start"},e.createElement("p",{className:"mhb-typography-para-thick-30 mhb-text-neutral-110 mhb-m-0 mhb-min-w-0 mhb-break-words mhb-whitespace-normal mhb-text-left"},k.title)),e.createElement("p",{className:"mhb-typography-para-30 mhb-text-neutral-60 mhb-m-0"},nt(k.created_at)))),m&&e.createElement(W,null))))},at=()=>{const[t,n]=e.useState(!1),[s,r]=e.useState(null),{accessToken:l}=$();return{loading:t,error:s,getAllowedToChat:async()=>{try{return n(!0),await P(et,{},l)}catch(m){r(m)}finally{n(!1)}}}},ke=({toastMsg:t})=>e.createElement("div",{id:"toast-simple",className:"mhb-border-red-60 mhb-fixed mhb-bottom-6 mhb-right-6 mhb-z-50 mhb-flex mhb-max-w-xs mhb-items-center mhb-space-x-4 mhb-divide-x mhb-divide-gray-200 mhb-rounded-lg mhb-border mhb-bg-white mhb-p-4 mhb-text-gray-700 mhb-shadow-lg dark:mhb-divide-gray-700 dark:mhb-border-gray-600 dark:mhb-bg-gray-800 dark:mhb-text-gray-300",role:"alert"},e.createElement("svg",{className:"mhb-text-red-60 mhb-h-3 mhb-w-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14"},e.createElement("path",{stroke:"currentColor",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})),e.createElement("div",{className:"mhb-text-red-60 mhb-typography-label-thick-30 mhb-ps-4"},t)),pe=({isChatScreen:t,setIsChatScreen:n})=>{const[s,r]=e.useState(""),{getAllowedToChat:l,loading:i}=at(),m=e.useRef();e.useEffect(()=>()=>clearTimeout(m.current),[]);const h=()=>{n(o=>!o)},d=async()=>{(await l())?.AllowedTocreateTicket?.allowed?(sessionStorage.removeItem("userAndTicket"),n(p=>!p)):(r("You have reached the chat limit. A new chat will be available once an agent closes one."),m.current=setTimeout(()=>{r("")},1500))};return e.createElement(e.Fragment,null,e.createElement("div",{className:"mhb-header mhb-border-b mhb-border-neutral-20 mhb-flex mhb-items-center mhb-justify-between"},e.createElement(Oe,{className:"h-[36px] w-[36px] fill-current"}),e.createElement("div",{className:"mhb-flex mhb-gap-2 mhb-items-center"},t?e.createElement("div",{className:"mhb-btn-reset mhb-p-3 mhb-invisible mhb-typography-para-thick-30"},"new chat"):e.createElement("button",{type:"button",onClick:d,disabled:i,className:"mhb-btn-reset mhb-p-3 mhb-bg-neutral-10 mhb-typography-para-thick-30 mhb-rounded-[9999px]"},i?e.createElement(W,{className:"mhb-w-4 mhb-h-4"}):"new chat"),e.createElement("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-flex mhb-items-center mhb-justify-center mhb-rounded-full mhb-bg-neutral-10",onClick:h},t?e.createElement(Fe,{className:"mhb-h-[16px] mhb-w-[16px] fill-current"}):e.createElement(Pe,{className:"mhb-h-[16px] mhb-w-[16px]"})))),s&&e.createElement("div",{className:"mhb-ml-[12px]"},e.createElement(ke,{toastMsg:s})))},fe=`
78
78
  mutation AssistChat(
79
79
  $message: String!
80
80
  $ticket_id: Int
@@ -106,7 +106,7 @@ mutation AssistChat(
106
106
  }
107
107
  }
108
108
  }
109
- `,tt=`
109
+ `,st=`
110
110
  mutation GetPresignedLink(
111
111
  $files: [String!]!
112
112
  $signature_type: String!
@@ -115,7 +115,7 @@ mutation AssistChat(
115
115
  filename
116
116
  url
117
117
  }
118
- }`,st=`
118
+ }`,rt=`
119
119
  mutation AssistRating(
120
120
  $ticket_id: Int!
121
121
  $rating :Int
@@ -124,7 +124,7 @@ mutation AssistChat(
124
124
  status
125
125
  message
126
126
  }
127
- }`,nt=`subscription onAssistChat($ticket_id: Int!) {
127
+ }`,lt=`subscription onAssistChat($ticket_id: Int!) {
128
128
  onAssistChat(ticket_id: $ticket_id) {
129
129
  message_id
130
130
  text
@@ -142,12 +142,12 @@ mutation AssistChat(
142
142
  user_type
143
143
  }
144
144
  }
145
- }`,rt=`subscription onTicketUpdate($ticket_id: Int!) {
145
+ }`,ct=`subscription onTicketUpdate($ticket_id: Int!) {
146
146
  onTicketUpdate(ticket_id: $ticket_id){
147
147
  status_id
148
148
  }
149
- }`,se=10,at=()=>{const[t,s]=a.useState([]),[r,i]=a.useState(!0),[o,c]=a.useState(null),[h,u]=a.useState(!1),[y,l]=a.useState(!1),[d,v]=a.useState(!0),[A,S]=a.useState(!1),{accessToken:b,profileInfo:w}=$(),M=V("userAndTicket")?.ticket_id,L=V("userAndTicket")?.employee_id,Y=a.useMemo(()=>t.find(f=>f.ticket_id!=null)?.ticket_id??null,[t]);let E=M??Y??null;return a.useEffect(()=>{if(Array.isArray(t)&&t?.length>0){const f=t[t.length-1];!f?.handover&&f?.user?.user_type==="employee"?l(!0):l(!1)}},[t]),a.useEffect(()=>{if(!E||!w)return;if(L&&w?.employee_id!=L){sessionStorage.removeItem("userAndTicket");return}const f=de(nt,{ticket_id:E},j=>{const k=j;if(k?.onAssistChat?.user?.user_type==="agent"||k?.onAssistChat?.user?.user_type==="bot")if(k?.onAssistChat?.system){const N={message_id:Math.random(),text:"handover to agent",attachments:null,ticket_id:null,system:!0,handover:null,created_at:null,end:null,user:null},_={...k?.onAssistChat,system:!1};s(n=>[...n,_,N]),l(!1)}else s(N=>[...N,k.onAssistChat]),l(!1)});return()=>f()},[E,w]),a.useEffect(()=>{if(!E)return;const f=de(rt,{ticket_id:E},j=>{j?.onTicketUpdate?.status_id===3&&S(!0)});return()=>f()},[E]),a.useEffect(()=>{if(!b||!w)return;L&&w?.employee_id!==L&&(sessionStorage.removeItem("userAndTicket"),E=null);const f={...E&&{ticket_id:E},limit:se};O(ue,f,b).then(async j=>{s(j?.assistHistory??[])}).catch(j=>{c(j)}).finally(()=>{i(!1)})},[w]),{historyData:t,msgLoading:r,msgError:o,isSending:y,sendMessage:f=>{const j=t.find(_=>_.ticket_id!=null)?.ticket_id??null,k=t.find(_=>_.handover==!0)?.handover??!1,N={...j&&{ticket_id:j},message:f,handover:k,attachments:[],text:f,message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}};l(!0),s(_=>[..._,N]),K(fe,N,b).then(async _=>{const n=_;if(n.assistChat.user.user_type!=="employee"&&n.assistChat.system){const x={message_id:Math.random(),text:"handover to agent",attachments:null,ticket_id:null,system:!0,handover:null,created_at:null,end:null,user:null},g={...n.assistChat,system:!1};s(C=>[...C,g,x]),l(!1)}!V("userAndTicket")&&n.assistChat?.ticket_id&&w&&ie("userAndTicket",{ticket_id:n.assistChat?.ticket_id,employee_id:w.employee_id})}).catch(()=>{s(_=>_.slice(0,-1)),l(!1)})},getNextPageData:f=>{if(!b||h)return;const j=V("userAndTicket")?.ticket_id,k={...j&&{ticket_id:j},limit:se,offset:f};u(!0),O(ue,k,b).then(async N=>{const n=N?.assistHistory??[];s(x=>[...n,...x]),n.length<se&&v(!1)}).catch(N=>{c(N)}).finally(()=>{u(!1)})},isLoadingMore:h,upload:async f=>{l(!0);const j={files:f.files.map(k=>`${f.ticketId}/${k.name}`),signature_type:f.signature_type};try{const k=await K(tt,j,b);for(const[p,H]of f.files.entries()){const U=k.GetPresignedLink[p]?.url;U&&await fetch(U,{method:"PUT",body:H,headers:{"Content-Type":H.type}})}const N=t.find(p=>p.handover)?.handover??!1,_=f.files.map(p=>({url:URL.createObjectURL(p),filename:p.name})),n={ticket_id:f.ticketId,handover:N,attachments:_,text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}};s(p=>[...p,n]);const x={ticket_id:f.ticketId,handover:N,attachments:f.files.map(p=>`${f.ticketId}/${p.name}`),message:"",text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}},C=await K(fe,x,b);C.assistChat.user.user_type!=="employee"&&s(p=>[...p,C.assistChat]),!V("userAndTicket")&&C.assistChat?.ticket_id&&w&&ie("userAndTicket",{ticket_id:C.assistChat.ticket_id,employee_id:w.employee_id})}catch{s(N=>N.slice(0,-1))}finally{l(!1)}},hasMore:d,isChatResolved:A}},xe=({url:t,msg:s,isFirstInGroup:r,fileType:i,imageRemoveHandler:o,isPreview:c})=>{const h=async()=>{const u=s?.attachments?.[0];if(!u?.url)return;const l=await(await fetch(u.url)).blob(),d=URL.createObjectURL(l),v=document.createElement("a");v.href=d,v.download=u.filename||"download.pdf",v.click(),URL.revokeObjectURL(d)};return e.jsxs(e.Fragment,{children:[(i==="jpg"||i==="jpeg"||i==="png")&&e.jsx("div",{className:"mhb-flex mhb-items-center mhb-gap-2",children:e.jsx("div",{className:`mhb-rounded-[16px] mhb-bg-white ${s?.user?.user_type==="customer"?"mhb-ml-auto":"mhb-mr-auto"} ${r?s?.user?.user_type==="customer"?"mhb-rounded-tr-[4px]":"mhb-rounded-tl-[4px]":""}`,children:e.jsx("div",{className:"mhb-relative mhb-overflow-hidden mhb-rounded-[16px] mhb-bg-neutral-10 mhb-px-1 mhb-py-1",children:e.jsx("div",{className:"mhb-flex mhb-w-fit mhb-space-x-1",children:e.jsxs("div",{className:"mhb-h-[44px] mhb-w-[44px] mhb-flex-shrink-0 mhb-rounded-[12px] mhb-bg-white mhb-relative",children:[e.jsx("img",{src:t,alt:"Attachment",className:"mhb-h-[42px] mhb-w-[42px] mhb-rounded-[12px] mhb-object-cover"}),c&&e.jsx("button",{type:"button",onClick:o,className:"mhb-absolute mhb-top-0 mhb-right-0 mhb-translate-x-1/2 mhb--translate-y-1/2 mhb-h-[18px] mhb-w-[18px] mhb-rounded-full mhb-bg-neutral-60 mhb-text-white mhb-flex mhb-items-center mhb-justify-center mhb-text-[10px]",children:"✕"})]})})})})}),i==="pdf"&&e.jsxs("div",{className:"mhb-relative mhb-flex mhb-items-center mhb-gap-2",children:[e.jsxs("button",{className:"mhb-flex mhb-w-full mhb-items-center mhb-justify-between mhb-gap-3 mhb-rounded-[20px] mhb-border mhb-border-neutral-10 mhb-bg-white p-3 focus:mhb-outline-none",onClick:h,children:[e.jsx("div",{className:"mhb-relative mhb-flex mhb-h-[36px] mhb-w-[36px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-bg-neutral-20",children:e.jsx("p",{className:"mhb-absolute mhb-text-white mhb-typography-para-40",children:"pdf"})}),e.jsx("p",{className:"mhb-max-w-[50px] mhb-overflow-hidden mhb-text-ellipsis mhb-whitespace-nowrap mhb-text-neutral-110 mhb-typography-para-thick-30",children:s?.attachments?.[0]?.filename||"file.pdf"})]}),c&&e.jsx("button",{type:"button",onClick:o,className:"mhb-absolute mhb-top-0 mhb-right-0 mhb-translate-x-1/2 mhb--translate-y-1/2 mhb-h-[18px] mhb-w-[18px] mhb-rounded-full mhb-bg-neutral-60 mhb-text-white mhb-flex mhb-items-center mhb-justify-center mhb-text-[10px]",children:"✕"})]})]})},it=()=>{const[t,s]=a.useState(!1),{setIsChatScreen:r,accessToken:i}=$();return{rate:async c=>{try{s(!0),(await K(st,c,i)).AssistRating.status==="success"&&(sessionStorage.removeItem("userAndTicket"),r(u=>!u))}catch(h){throw h}finally{s(!1)}},isProgress:t}};function lt({historyData:t}){const[s,r]=a.useState(0),{rate:i,isProgress:o}=it(),c=a.useMemo(()=>t.find(y=>y.ticket_id!=null)?.ticket_id??null,[t]),h=y=>{r(y)},u=()=>{i({ticket_id:c,rating:s})};return e.jsxs("div",{className:"mhb-flex mhb-flex-col mhb-justify-center",children:[e.jsx("p",{className:"mhb-self-center mhb-text-neutral-110 mhb-typography-head-50",children:"how was your experience?"}),e.jsx("p",{className:"mhb-self-center mhb-text-neutral-60 mhb-typography-para-30",children:"Help us improve with your valuable feedback"}),e.jsx("div",{className:"mhb-mx-3 mhb-mt-4 mhb-flex mhb-items-center mhb-justify-center mhb-gap-1 mhb-rounded-[12px] mhb-border mhb-border-neutral-10 mhb-py-3",children:[1,2,3,4,5].map(y=>{const l=s>=y;return e.jsx("button",{disabled:o,type:"button",onClick:()=>h(y),className:"focus:mhb-outline-none",children:e.jsx("svg",{className:`mhb-h-[32px] mhb-w-[32px] transition-colors ${l?"mhb-fill-orange-60":"mhb-fill-neutral-10"}`,viewBox:"0 0 22 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z"})})},y)})}),s>0?e.jsx("div",{className:"mhb-flex mhb-flex-col mhb-justify-center mhb-gap-4 mhb-p-4",children:e.jsx("button",{className:"mhb-flex mhb-h-[48px] mhb-items-center mhb-justify-center mhb-rounded-[9999px] mhb-bg-orange-60 mhb-text-white mhb-typography-label-thick-30 focus:mhb-outline-none",title:"Submit",onClick:u,disabled:o,type:"button",children:"Submit"})}):null]})}const ge=["image/jpeg","image/jpg","image/png"],ot=()=>{const[t,s]=a.useState(""),[r,i]=a.useState(null),o=a.useRef(null),c=a.useRef(null),h=a.useRef(null),u=a.useRef(0),y=a.useRef(0),l=a.useRef(!1),{historyData:d,sendMessage:v,getNextPageData:A,isLoadingMore:S,isSending:b,upload:w,msgLoading:M,hasMore:L,isChatResolved:Y}=at();a.useLayoutEffect(()=>{const n=o.current;if(n)if(l.current){const x=u.current,g=y.current,p=n.scrollHeight-x;n.scrollTop=g+p,l.current=!1}else n.scrollTop=n.scrollHeight},[d?.length]);const E=async()=>{const n=c.current?.value?.trim()||"";L||(l.current=!1),!(!n&&!r)&&(r&&(w(r),i(null)),n&&v(n),c.current&&(c.current.value=""))},oe=n=>{b||n.key==="Enter"&&(n.preventDefault(),E())},ce=n=>{const x=n.currentTarget;if(x.scrollHeight>x.clientHeight&&x.scrollTop<=20&&!S){const C=d.length;u.current=x.scrollHeight,y.current=x.scrollTop,l.current=!0,A(C)}},he=n=>{const x=Array.from(n.target.files||[]),g=x.filter(H=>ge.includes(H.type));if(x.filter(H=>!ge.includes(H.type)).length>0){s("Only JPG and PNG files are allowed. Other files like videos are not supported."),setTimeout(()=>s(null),3e3),n.target.value="";return}const p=d[d?.length-1]?.ticket_id;g.length>0&&p&&i({files:g,signature_type:"upload",ticketId:p})},f=()=>{h.current?.click()},j=a.useMemo(()=>d?.some(n=>n.handover==!0),[d]),k=n=>n?n.type==="application/pdf"?"pdf":n.type.startsWith("image/")?n.type.split("/")[1]:"":"";function N(n){return n.split(`
150
- `).map((g,C)=>{if(/^\s*-\s*\[\s*\]/.test(g)){const p=g.replace(/^\s*-\s*\[\s*\]\s*/,"");return e.jsxs("div",{className:"mhb-flex mhb-gap-2",children:[e.jsx("input",{type:"checkbox",disabled:!0}),e.jsx("span",{children:_(p)})]},C)}if(/^\s*[-•]/.test(g)){const p=g.replace(/^\s*[-•]\s*/,"");return e.jsxs("div",{className:"mhb-flex mhb-gap-2",children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:_(p)})]},C)}if(/^\s*\d+[\.\)]/.test(g)){const p=g.replace(/^\s*\d+[\.\)]\s*/,"");return e.jsxs("div",{className:"mhb-flex mhb-gap-2",children:[e.jsx("span",{children:g.match(/\d+/)?.[0]}),e.jsx("span",{children:_(p)})]},C)}return e.jsx("div",{children:_(g)},C)})}function _(n){return n.split(/(\*\*.*?\*\*)/g).map((g,C)=>g.startsWith("**")&&g.endsWith("**")?e.jsx("strong",{children:g.slice(2,-2)},C):e.jsx("span",{children:g},C))}return e.jsxs("div",{className:"mhb-flex mhb-h-full mhb-flex-col mhb-overflow-hidden mhb-bg-white",children:[e.jsx(e.Fragment,{children:M?e.jsx("div",{className:"mhb-py-3",children:e.jsx(J,{})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:o,className:"mhb-flex-grow mhb-overflow-y-auto mhb-py-3 [&>*]:[mhb-overflow-anchor:none]",onScroll:ce,children:e.jsxs("div",{className:"mhb-flex mhb-min-h-full mhb-flex-col mhb-justify-end mhb-gap-1",children:[d?.map((n,x)=>{const g="user"in n&&x===0||d[x-1]?.user?.user_type!==n?.user?.user_type,C=new Date(n.created_at??""),p=x>0?new Date(d[x-1].created_at??""):null,H=!p||C.getDate()!==p.getDate()||C.getMonth()!==p.getMonth()||C.getFullYear()!==p.getFullYear(),U=p&&C.getTime()-p.getTime()>120*1e3,P=n.hasOwnProperty("user")&&(g||H||U),Ne=n?.attachments?.some(F=>{const Q=F.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase();return["jpg","jpeg","png"].includes(Q||"")});return e.jsxs("div",{children:[n.system&&e.jsxs("div",{className:"mhb-mb-1 mhb-mt-2 mhb-flex mhb-w-full mhb-items-center mhb-gap-1",children:[e.jsx("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"}),e.jsx("p",{className:"mhb-bg-neutral-110 mhb-typography-para-40 mhb-flex mhb-h-[24px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-px-2 mhb-text-white",children:"One of our agent will join the chat shortly."}),e.jsx("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"})]}),e.jsx("div",{className:`mhb-flex ${n?.user?.user_type==="bot"||n?.user?.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:e.jsxs("div",{className:"mhb-max-w-[75%",children:[P&&e.jsx("div",{className:`mhb-mb-1 mhb-flex mhb-items-center ${n?.user?.user_type==="bot"||n?.user?.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:n?.user?.user_type==="bot"?e.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[e.jsxs("div",{className:"mhb-flex mhb-items-center mhb-gap-1",children:[e.jsx(Oe,{}),e.jsx("div",{className:"mhb-mb-1",children:e.jsx(Ve,{})})]}),e.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-[2px] mhb-items-center",children:[e.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),e.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:te(n.created_at)})]})]}):n?.user?.user_type==="employee"?e.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[e.jsxs("div",{className:"mhb-flex mhb-gap-1",children:[e.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:te(n.created_at)}),e.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60 mhb-flex mhb-self-center"})]}),e.jsx(D.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"})]}):n?.user?.user_type==="agent"?e.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[e.jsx(D.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"}),e.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-1 mhb-items-center",children:[e.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),e.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:te(n.created_at)})]})]}):null}),e.jsx("div",{className:"mhb-flex mhb-overflow-hidden mhb-min-w-0",children:Array.isArray(n?.attachments)&&n?.attachments?.length>0?e.jsx("div",{className:`mhb-p-1 mhb-rounded-[16px] ${n?.user?.user_type==="bot"||n?.user?.user_type==="agent"?`mhb-bg-orange-60 ${P?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"}`:`mhb-bg-neutral-10 ${P?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"}`} ${Ne?"mhb-overflow-x-auto mhb-flex":"mhb-flex mhb-flex-col mhb-gap-1"}`,children:n.attachments.map((F,Q)=>e.jsx("div",{children:e.jsx(xe,{url:F.url,msg:n,isFirstInGroup:!1,fileType:F?.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase()||""})},Q))}):n?.text&&!n.system?e.jsx("div",{className:`mhb-whitespace-pre-line mhb-break-words mhb-rounded-[16px] mhb-p-3
151
- mhb-typography-para-30 ${n?.user?.user_type==="bot"||n?.user?.user_type==="agent"?`mhb-bg-orange-60 mhb-text-white ${P?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"} `:`mhb-bg-neutral-10 mhb-text-neutral-110 mhb-ml-auto ${P?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"} `}
152
- `,children:N(n?.text)}):null})]})})]},n.message_id)}),b&&d?.every(n=>n.handover===!1||n.handover===null)&&e.jsxs("span",{className:"mhb-loading","aria-label":"Loading",children:[e.jsx("span",{className:"dot"}),e.jsx("span",{className:"dot"}),e.jsx("span",{className:"dot"})]})]})}),Y?e.jsx("div",{className:"mhb-p-3 mhb-flex",children:e.jsx(lt,{historyData:d})}):d?.some(n=>n.status_id===3||n.status_id===12)?e.jsxs("div",{className:"mhb-mb-1 mhb-mt-2 mhb-flex mhb-w-full mhb-items-center mhb-gap-1 mhb-pb-3",children:[e.jsx("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"}),e.jsx("p",{className:"mhb-bg-neutral-110 mhb-typography-para-40 mhb-flex mhb-h-[24px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-px-2 mhb-text-white",children:"This chat has ended."}),e.jsx("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"})]}):e.jsx("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2",children:e.jsxs("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3",children:[e.jsx("div",{className:"mhb-flex mhb-flex-1",children:r?r?.files?.map((n,x)=>e.jsx(xe,{url:URL.createObjectURL(n),msg:{attachments:[{url:URL.createObjectURL(n),filename:n.name}],user:{user_type:"employee"}},isFirstInGroup:!1,fileType:k(n),isPreview:!0,imageRemoveHandler:()=>i(null)},x)):e.jsx("textarea",{ref:c,placeholder:"Type your message here...",className:"mhb-btn-reset mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",onKeyDown:oe})}),e.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-justify-end mhb-items-end",children:[j&&e.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-rounded-full mhb-bg-neutral-100 mhb-flex mhb-items-center mhb-justify-center mhb-outline-none",disabled:b,onClick:f,children:[e.jsx(Pe,{className:"h-[16px] w-[16px] mhb-fill-current"}),e.jsx("input",{type:"file",accept:".jpg,.jpeg,.png",ref:h,onChange:he,className:"hidden"})]}),e.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-rounded-[9999px] mhb-bg-orange-60 mhb-flex mhb-p-3 mhb-items-center mhb-justify-center mhb-shadow-[0_4px_12px_0_rgba(250,75,22,0.50)] mhb-outline-none",disabled:b,onClick:E,children:e.jsx("p",{className:"mhb-typography-label-thick-30 mhb-text-white",children:"Send"})})]})]})})]})}),t&&e.jsx(ke,{toastMsg:t})]})};function ct({side:t="top",align:s="end"}){const{isChatScreen:r,setIsChatScreen:i,accessToken:o,setProfileInfo:c}=$(),h=async()=>{const u=await D.SSOAuthorization.getProfileDetails();c(u),Me(u)};return a.useEffect(()=>{o&&h()},[]),e.jsx("div",{className:"mhb-root",children:e.jsx(Ue,{side:t,align:s,children:e.jsxs("div",{className:"mhb-h-full mhb-w-full mhb-flex mhb-flex-col mhb-min-h-0",children:[e.jsx(et,{isChatScreen:r,setIsChatScreen:i}),o?r?e.jsx(ot,{}):e.jsx(Qe,{}):e.jsx("div",{children:"Please provide valid credentials"})]})})})}function ht(t){const{apiKey:s,accessToken:r}=t;if(!s||!r)throw new Error("Missing parameters: apiKey, and accessToken are required")}let le=null,W=!1,z=[];function mt(){for(const t of z)t()}function dt(t){W||(ht(t),D.SSOAuthorization.init({env:t.env,redirectUrl:t.redirectUrl,app:t.app,idp:t.idp}),le=t,W=!0,mt(),ze({apiKey:t.apiKey,apiURL:t.apiURL}))}function ut(t){const[s,r]=a.useState({initialized:W,sdkOptions:le});return a.useEffect(()=>{const i=()=>{r({initialized:W,sdkOptions:le})};return z.push(i),()=>{z=z.filter(o=>o!==i)}},[]),!s.initialized||!s.sdkOptions?null:e.jsx(Le,{token:s.sdkOptions.accessToken,children:e.jsx(ct,{...t})})}exports.ChatButton=ut;exports.init=dt;
149
+ }`,ee=10,it=()=>{const[t,n]=e.useState([]),[s,r]=e.useState(!0),[l,i]=e.useState(null),[m,h]=e.useState(!1),[d,o]=e.useState(!1),[p,S]=e.useState(!0),[A,k]=e.useState(!1),{accessToken:u,profileInfo:w}=$(),M=V("userAndTicket")?.ticket_id,L=V("userAndTicket")?.employee_id,J=e.useMemo(()=>t.find(f=>f.ticket_id!=null)?.ticket_id??null,[t]);let T=M??J??null;return e.useEffect(()=>{if(Array.isArray(t)&&t?.length>0){const f=t[t.length-1];!f?.handover&&f?.user?.user_type==="employee"?o(!0):o(!1)}},[t]),e.useEffect(()=>{if(!T||!w)return;if(L&&w?.employee_id!=L){sessionStorage.removeItem("userAndTicket");return}const f=me(lt,{ticket_id:T},C=>{const v=C;if(v?.onAssistChat?.user?.user_type==="agent"||v?.onAssistChat?.user?.user_type==="bot")if(v?.onAssistChat?.system){const _={message_id:Math.random(),text:"handover to agent",attachments:null,ticket_id:null,system:!0,handover:null,created_at:null,end:null,user:null},E={...v?.onAssistChat,system:!1};n(a=>[...a,E,_]),o(!1)}else n(_=>[..._,v.onAssistChat]),o(!1)});return()=>f()},[T,w]),e.useEffect(()=>{if(!T)return;const f=me(ct,{ticket_id:T},C=>{C?.onTicketUpdate?.status_id===3&&k(!0)});return()=>f()},[T]),e.useEffect(()=>{if(!u||!w)return;L&&w?.employee_id!==L&&(sessionStorage.removeItem("userAndTicket"),T=null);const f={...T&&{ticket_id:T},limit:ee};P(he,f,u).then(async C=>{n(C?.assistHistory??[])}).catch(C=>{i(C)}).finally(()=>{r(!1)})},[w]),{historyData:t,msgLoading:s,msgError:l,isSending:d,sendMessage:f=>{const C=t.find(E=>E.ticket_id!=null)?.ticket_id??null,v=t.find(E=>E.handover==!0)?.handover??!1,_={...C&&{ticket_id:C},message:f,handover:v,attachments:[],text:f,message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}};o(!0),n(E=>[...E,_]),K(fe,_,u).then(async E=>{const a=E;if(a.assistChat.user.user_type!=="employee"&&a.assistChat.system){const g={message_id:Math.random(),text:"handover to agent",attachments:null,ticket_id:null,system:!0,handover:null,created_at:null,end:null,user:null},y={...a.assistChat,system:!1};n(x=>[...x,y,g]),o(!1)}!V("userAndTicket")&&a.assistChat?.ticket_id&&w&&ae("userAndTicket",{ticket_id:a.assistChat?.ticket_id,employee_id:w.employee_id})}).catch(()=>{n(E=>E.slice(0,-1)),o(!1)})},getNextPageData:f=>{if(!u||m)return;const C=V("userAndTicket")?.ticket_id,v={...C&&{ticket_id:C},limit:ee,offset:f};h(!0),P(he,v,u).then(async _=>{const a=_?.assistHistory??[];n(g=>[...a,...g]),a.length<ee&&S(!1)}).catch(_=>{i(_)}).finally(()=>{h(!1)})},isLoadingMore:m,upload:async f=>{o(!0);const C={files:f.files.map(v=>`${f.ticketId}/${v.name}`),signature_type:f.signature_type};try{const v=await K(st,C,u);for(const[b,H]of f.files.entries()){const j=v.GetPresignedLink[b]?.url;j&&await fetch(j,{method:"PUT",body:H,headers:{"Content-Type":H.type}})}const _=t.find(b=>b.handover)?.handover??!1,E=f.files.map(b=>({url:URL.createObjectURL(b),filename:b.name})),a={ticket_id:f.ticketId,handover:_,attachments:E,text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}};n(b=>[...b,a]);const g={ticket_id:f.ticketId,handover:_,attachments:f.files.map(b=>`${f.ticketId}/${b.name}`),message:"",text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:w?.full_name,user_type:"employee"}},x=await K(fe,g,u);x.assistChat.user.user_type!=="employee"&&n(b=>[...b,x.assistChat]),!V("userAndTicket")&&x.assistChat?.ticket_id&&w&&ae("userAndTicket",{ticket_id:x.assistChat.ticket_id,employee_id:w.employee_id})}catch{n(_=>_.slice(0,-1))}finally{o(!1)}},hasMore:p,isChatResolved:A}},ge=({url:t,msg:n,isFirstInGroup:s,fileType:r,imageRemoveHandler:l,isPreview:i})=>{const m=async()=>{const h=n?.attachments?.[0];if(!h?.url)return;const o=await(await fetch(h.url)).blob(),p=URL.createObjectURL(o),S=document.createElement("a");S.href=p,S.download=h.filename||"download.pdf",S.click(),URL.revokeObjectURL(p)};return e.createElement(e.Fragment,null,(r==="jpg"||r==="jpeg"||r==="png")&&e.createElement("div",{className:"mhb-flex mhb-items-center mhb-gap-2"},e.createElement("div",{className:`mhb-rounded-[16px] mhb-bg-white ${n?.user?.user_type==="customer"?"mhb-ml-auto":"mhb-mr-auto"} ${s?n?.user?.user_type==="customer"?"mhb-rounded-tr-[4px]":"mhb-rounded-tl-[4px]":""}`},e.createElement("div",{className:"mhb-relative mhb-overflow-hidden mhb-rounded-[16px] mhb-bg-neutral-10 mhb-px-1 mhb-py-1"},e.createElement("div",{className:"mhb-flex mhb-w-fit mhb-space-x-1"},e.createElement("div",{className:"mhb-h-[44px] mhb-w-[44px] mhb-flex-shrink-0 mhb-rounded-[12px] mhb-bg-white mhb-relative"},e.createElement("img",{src:t,alt:"Attachment",className:"mhb-h-[42px] mhb-w-[42px] mhb-rounded-[12px] mhb-object-cover"}),i&&e.createElement("button",{type:"button",onClick:l,className:"mhb-absolute mhb-top-0 mhb-right-0 mhb-translate-x-1/2 mhb--translate-y-1/2 mhb-h-[18px] mhb-w-[18px] mhb-rounded-full mhb-bg-neutral-60 mhb-text-white mhb-flex mhb-items-center mhb-justify-center mhb-text-[10px]"},"✕")))))),r==="pdf"&&e.createElement("div",{className:"mhb-relative mhb-flex mhb-items-center mhb-gap-2"},e.createElement("button",{className:"mhb-flex mhb-w-full mhb-items-center mhb-justify-between mhb-gap-3 mhb-rounded-[20px] mhb-border mhb-border-neutral-10 mhb-bg-white p-3 focus:mhb-outline-none",onClick:m},e.createElement("div",{className:"mhb-relative mhb-flex mhb-h-[36px] mhb-w-[36px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-bg-neutral-20"},e.createElement("p",{className:"mhb-absolute mhb-text-white mhb-typography-para-40"},"pdf")),e.createElement("p",{className:"mhb-max-w-[50px] mhb-overflow-hidden mhb-text-ellipsis mhb-whitespace-nowrap mhb-text-neutral-110 mhb-typography-para-thick-30"},n?.attachments?.[0]?.filename||"file.pdf")),i&&e.createElement("button",{type:"button",onClick:l,className:"mhb-absolute mhb-top-0 mhb-right-0 mhb-translate-x-1/2 mhb--translate-y-1/2 mhb-h-[18px] mhb-w-[18px] mhb-rounded-full mhb-bg-neutral-60 mhb-text-white mhb-flex mhb-items-center mhb-justify-center mhb-text-[10px]"},"✕")))},ot=()=>{const[t,n]=e.useState(!1),{setIsChatScreen:s,accessToken:r}=$();return{rate:async i=>{try{n(!0),(await K(rt,i,r)).AssistRating.status==="success"&&(sessionStorage.removeItem("userAndTicket"),s(h=>!h))}catch(m){throw m}finally{n(!1)}},isProgress:t}};function mt({historyData:t}){const[n,s]=e.useState(0),{rate:r,isProgress:l}=ot(),i=e.useMemo(()=>t.find(d=>d.ticket_id!=null)?.ticket_id??null,[t]),m=d=>{s(d)},h=()=>{r({ticket_id:i,rating:n})};return e.createElement("div",{className:"mhb-flex mhb-flex-col mhb-justify-center"},e.createElement("p",{className:"mhb-self-center mhb-text-neutral-110 mhb-typography-head-50"},"how was your experience?"),e.createElement("p",{className:"mhb-self-center mhb-text-neutral-60 mhb-typography-para-30"},"Help us improve with your valuable feedback"),e.createElement("div",{className:"mhb-mx-3 mhb-mt-4 mhb-flex mhb-items-center mhb-justify-center mhb-gap-1 mhb-rounded-[12px] mhb-border mhb-border-neutral-10 mhb-py-3"},[1,2,3,4,5].map(d=>{const o=n>=d;return e.createElement("button",{key:d,disabled:l,type:"button",onClick:()=>m(d),className:"focus:mhb-outline-none"},e.createElement("svg",{className:`mhb-h-[32px] mhb-w-[32px] transition-colors ${o?"mhb-fill-orange-60":"mhb-fill-neutral-10"}`,viewBox:"0 0 22 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},e.createElement("path",{d:"M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z"})))})),n>0?e.createElement("div",{className:"mhb-flex mhb-flex-col mhb-justify-center mhb-gap-4 mhb-p-4"},e.createElement("button",{className:"mhb-flex mhb-h-[48px] mhb-items-center mhb-justify-center mhb-rounded-[9999px] mhb-bg-orange-60 mhb-text-white mhb-typography-label-thick-30 focus:mhb-outline-none",title:"Submit",onClick:h,disabled:l,type:"button"},"Submit")):null)}const ye=["image/jpeg","image/jpg","image/png"],xe=()=>{const[t,n]=e.useState(""),[s,r]=e.useState(null),l=e.useRef(null),i=e.useRef(null),m=e.useRef(null),h=e.useRef(0),d=e.useRef(0),o=e.useRef(!1),{historyData:p,sendMessage:S,getNextPageData:A,isLoadingMore:k,isSending:u,upload:w,msgLoading:M,hasMore:L,isChatResolved:J}=it();e.useLayoutEffect(()=>{const a=l.current;if(a)if(o.current){const g=h.current,y=d.current,b=a.scrollHeight-g;a.scrollTop=y+b,o.current=!1}else a.scrollTop=a.scrollHeight},[p?.length]);const T=async()=>{const a=i.current?.value?.trim()||"";L||(o.current=!1),!(!a&&!s)&&(s&&(w(s),r(null)),a&&S(a),i.current&&(i.current.value=""))},se=a=>{u||a.key==="Enter"&&(a.preventDefault(),T())},re=a=>{const g=a.currentTarget;if(g.scrollHeight>g.clientHeight&&g.scrollTop<=20&&!k){const x=p.length;h.current=g.scrollHeight,d.current=g.scrollTop,o.current=!0,A(x)}},le=a=>{const g=Array.from(a.target.files||[]),y=g.filter(H=>ye.includes(H.type));if(g.filter(H=>!ye.includes(H.type)).length>0){n("Only JPG and PNG files are allowed. Other files like videos are not supported."),setTimeout(()=>n(null),3e3),a.target.value="";return}const b=p[p?.length-1]?.ticket_id;y.length>0&&b&&r({files:y,signature_type:"upload",ticketId:b})},f=()=>{m.current?.click()},C=e.useMemo(()=>p?.some(a=>a.handover==!0),[p]),v=a=>a?a.type==="application/pdf"?"pdf":a.type.startsWith("image/")?a.type.split("/")[1]:"":"";function _(a){return a.split(`
150
+ `).map((y,x)=>{if(/^\s*-\s*\[\s*\]/.test(y)){const b=y.replace(/^\s*-\s*\[\s*\]\s*/,"");return e.createElement("div",{key:x,className:"mhb-flex mhb-gap-2"},e.createElement("input",{type:"checkbox",disabled:!0}),e.createElement("span",null,E(b)))}if(/^\s*[-•]/.test(y)){const b=y.replace(/^\s*[-•]\s*/,"");return e.createElement("div",{key:x,className:"mhb-flex mhb-gap-2"},e.createElement("span",null,"•"),e.createElement("span",null,E(b)))}if(/^\s*\d+[\.\)]/.test(y)){const b=y.replace(/^\s*\d+[\.\)]\s*/,"");return e.createElement("div",{key:x,className:"mhb-flex mhb-gap-2"},e.createElement("span",null,y.match(/\d+/)?.[0]),e.createElement("span",null,E(b)))}return e.createElement("div",{key:x},E(y))})}function E(a){return a.split(/(\*\*.*?\*\*)/g).map((y,x)=>y.startsWith("**")&&y.endsWith("**")?e.createElement("strong",{key:x},y.slice(2,-2)):e.createElement("span",{key:x},y))}return e.createElement("div",{className:"mhb-flex mhb-h-full mhb-flex-col mhb-overflow-hidden mhb-bg-white"},e.createElement(e.Fragment,null,M?e.createElement("div",{className:"mhb-py-3"},e.createElement(W,null)):e.createElement(e.Fragment,null,e.createElement("div",{ref:l,className:"mhb-flex-grow mhb-overflow-y-auto mhb-py-3 [&>*]:[mhb-overflow-anchor:none]",onScroll:re},e.createElement("div",{className:"mhb-flex mhb-min-h-full mhb-flex-col mhb-justify-end mhb-gap-1"},p?.map((a,g)=>{const y="user"in a&&g===0||p[g-1]?.user?.user_type!==a?.user?.user_type,x=new Date(a.created_at??""),b=g>0?new Date(p[g-1].created_at??""):null,H=!b||x.getDate()!==b.getDate()||x.getMonth()!==b.getMonth()||x.getFullYear()!==b.getFullYear(),j=b&&x.getTime()-b.getTime()>120*1e3,D=a.hasOwnProperty("user")&&(y||H||j),Ne=a?.attachments?.some(U=>{const Y=U.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase();return["jpg","jpeg","png"].includes(Y||"")});return e.createElement("div",{key:a.message_id},a.system&&e.createElement("div",{className:"mhb-mb-1 mhb-mt-2 mhb-flex mhb-w-full mhb-items-center mhb-gap-1"},e.createElement("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"}),e.createElement("p",{className:"mhb-bg-neutral-110 mhb-typography-para-40 mhb-flex mhb-h-[24px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-px-2 mhb-text-white"},"One of our agent will join the chat shortly."),e.createElement("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"})),e.createElement("div",{className:`mhb-flex ${a?.user?.user_type==="bot"||a?.user?.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`},e.createElement("div",{className:"mhb-max-w-[75%"},D&&e.createElement("div",{className:`mhb-mb-1 mhb-flex mhb-items-center ${a?.user?.user_type==="bot"||a?.user?.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`},a?.user?.user_type==="bot"?e.createElement("div",{className:"mhb-flex mhb-gap-2 mhb-items-center"},e.createElement("div",{className:"mhb-flex mhb-items-center mhb-gap-1"},e.createElement(Ge,null),e.createElement("div",{className:"mhb-mb-1"},e.createElement(Be,null))),e.createElement("div",{className:"mhb-flex mhb-gap-1 mhb-mt-[2px] mhb-items-center"},e.createElement("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),e.createElement("p",{className:"mhb-typography-para-40 mhb-text-neutral-60"},X(a.created_at)))):a?.user?.user_type==="employee"?e.createElement("div",{className:"mhb-flex mhb-gap-2 mhb-items-center"},e.createElement("div",{className:"mhb-flex mhb-gap-1"},e.createElement("p",{className:"mhb-typography-para-40 mhb-text-neutral-60"},X(a.created_at)),e.createElement("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60 mhb-flex mhb-self-center"}))):a?.user?.user_type==="agent"?e.createElement("div",{className:"mhb-flex mhb-gap-2 mhb-items-center"},e.createElement("div",{className:"mhb-flex mhb-gap-1 mhb-mt-1 mhb-items-center"},e.createElement("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),e.createElement("p",{className:"mhb-typography-para-40 mhb-text-neutral-60"},X(a.created_at)))):null),e.createElement("div",{className:"mhb-flex mhb-overflow-hidden mhb-min-w-0"},Array.isArray(a?.attachments)&&a?.attachments?.length>0?e.createElement("div",{className:`mhb-p-1 mhb-rounded-[16px] ${a?.user?.user_type==="bot"||a?.user?.user_type==="agent"?`mhb-bg-orange-60 ${D?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"}`:`mhb-bg-neutral-10 ${D?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"}`} ${Ne?"mhb-overflow-x-auto mhb-flex":"mhb-flex mhb-flex-col mhb-gap-1"}`},a.attachments.map((U,Y)=>e.createElement("div",{key:Y},e.createElement(ge,{url:U.url,msg:a,isFirstInGroup:!1,fileType:U?.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase()||""})))):a?.text&&!a.system?e.createElement("div",{className:`mhb-whitespace-pre-line mhb-break-words mhb-rounded-[16px] mhb-p-3
151
+ mhb-typography-para-30 ${a?.user?.user_type==="bot"||a?.user?.user_type==="agent"?`mhb-bg-orange-60 mhb-text-white ${D?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"} `:`mhb-bg-neutral-10 mhb-text-neutral-110 mhb-ml-auto ${D?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"} `}
152
+ `},_(a?.text)):null))))}),u&&p?.every(a=>a.handover===!1||a.handover===null)&&e.createElement("span",{className:"mhb-loading","aria-label":"Loading"},e.createElement("span",{className:"dot"}),e.createElement("span",{className:"dot"}),e.createElement("span",{className:"dot"})))),J?e.createElement("div",{className:"mhb-p-3 mhb-flex"},e.createElement(mt,{historyData:p})):p?.some(a=>a.status_id===3||a.status_id===12)?e.createElement("div",{className:"mhb-mb-1 mhb-mt-2 mhb-flex mhb-w-full mhb-items-center mhb-gap-1 mhb-pb-3"},e.createElement("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"}),e.createElement("p",{className:"mhb-bg-neutral-110 mhb-typography-para-40 mhb-flex mhb-h-[24px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-px-2 mhb-text-white"},"This chat has ended."),e.createElement("div",{className:"mhb-bg-neutral-10 mhb-h-[1px] mhb-flex-grow"})):e.createElement("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2"},e.createElement("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3"},e.createElement("div",{className:"mhb-flex mhb-flex-1"},s?s?.files?.map((a,g)=>e.createElement(ge,{key:g,url:URL.createObjectURL(a),msg:{attachments:[{url:URL.createObjectURL(a),filename:a.name}],user:{user_type:"employee"}},isFirstInGroup:!1,fileType:v(a),isPreview:!0,imageRemoveHandler:()=>r(null)})):e.createElement("textarea",{ref:i,placeholder:"Type your message here...",className:"mhb-btn-reset mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",onKeyDown:se})),e.createElement("div",{className:"mhb-flex mhb-gap-1 mhb-justify-end mhb-items-end"},C&&e.createElement("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-rounded-full mhb-bg-neutral-100 mhb-flex mhb-items-center mhb-justify-center mhb-outline-none",disabled:u,onClick:f},e.createElement(Ze,{className:"h-[16px] w-[16px] mhb-fill-current"}),e.createElement("input",{type:"file",accept:".jpg,.jpeg,.png",ref:m,onChange:le,className:"hidden"})),e.createElement("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-rounded-[9999px] mhb-bg-orange-60 mhb-flex mhb-p-3 mhb-items-center mhb-justify-center mhb-shadow-[0_4px_12px_0_rgba(250,75,22,0.50)] mhb-outline-none",disabled:u,onClick:T},e.createElement("p",{className:"mhb-typography-label-thick-30 mhb-text-white"},"Send"))))))),t&&e.createElement(ke,{toastMsg:t}))};function ht({side:t="top",align:n="end"}){const{isChatScreen:s,setIsChatScreen:r,accessToken:l,setProfileInfo:i}=$(),m=Se();return e.useEffect(()=>{if(!l||m)return;async function h(){try{const d=await import("more-sso-sdk");if(d?.SSOAuthorization?.getProfileDetails){const o=await d.SSOAuthorization.getProfileDetails();i(o),De(o)}}catch(d){console.warn("[MoreDeskOne] Profile fetch skipped",d)}}h()},[l,m,i]),m?e.createElement("div",{className:"mhb-root mhb-flex mhb-flex-col",style:{position:"fixed",inset:0,height:"100vh",width:"100vw"}},e.createElement("div",{className:"mhb-h-full mhb-w-full mhb-flex mhb-flex-col mhb-min-h-0"},e.createElement("div",{className:"mhb-popover-children mhb-h-full mhb-flex mhb-flex-col"},e.createElement(pe,{isChatScreen:s,setIsChatScreen:r}),l?s?e.createElement(xe,null):e.createElement(de,null):e.createElement("div",null,"Please provide valid credentials")))):e.createElement("div",{className:"mhb-root"},e.createElement(Ke,{side:t,align:n},e.createElement("div",{className:"mhb-h-full mhb-w-full mhb-flex mhb-flex-col mhb-min-h-0"},e.createElement(pe,{isChatScreen:s,setIsChatScreen:r}),l?s?e.createElement(xe,null):e.createElement(de,null):e.createElement("div",null,"Please provide valid credentials"))))}function ut(t){const{apiKey:n,accessToken:s}=t;if(!n||!s)throw new Error("Missing parameters: apiKey, and accessToken are required")}let q=null,O=!1,z=[];function bt(){z.forEach(t=>t())}function Se(){return typeof window>"u"?!1:!!window.ReactNativeWebView}function dt(){return typeof window<"u"&&typeof document<"u"}async function pt(t){if(!O){if(ut(t),q=t,O=!0,dt()&&!Se())try{const n=await import("more-sso-sdk");n?.SSOAuthorization&&n.SSOAuthorization.init({env:t.env,redirectUrl:t.redirectUrl,app:t.app,idp:t.idp})}catch(n){console.warn("[MoreDeskOne] SSO skipped (not installed or not needed):",n)}Xe({apiKey:t.apiKey,apiURL:t.apiURL}),bt()}}function ft(t){const[n,s]=e.useState({initialized:O,sdkOptions:q});return e.useEffect(()=>{const r=()=>{s({initialized:O,sdkOptions:q})};return z.push(r),O&&q&&r(),()=>{z=z.filter(l=>l!==r)}},[]),!n.initialized||!n.sdkOptions?null:e.createElement(Ve,{token:n?.sdkOptions?.accessToken},e.createElement(ht,{...t}))}exports.ChatButton=ft;exports.init=pt;
153
153
  //# sourceMappingURL=index.cjs.map