@qratilabs/qrati-connect 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/element/{AuthLayout-BQsxj8DA.js → AuthLayout-Cb29YL2A.js} +1 -1
  4. package/element/{ContentsPage-BswZWICC.js → ContentsPage-Dy9C3p31.js} +3 -3
  5. package/element/{CuratePage-l_53kq1u.js → CuratePage-BUmxwjzW.js} +1 -1
  6. package/element/{Dialog-xRPAHU1U.js → Dialog-Dv2w7GiN.js} +1 -1
  7. package/element/{DotLottiePlayer-DWbmlHl0.js → DotLottiePlayer-BM_SpbNm.js} +1 -1
  8. package/element/{EventHeaderAdminButtons-DpqqYPmp.js → EventHeaderAdminButtons-BjztFxCi.js} +1 -1
  9. package/element/{FolderBreadcrumb-DgOZR2JO.js → FolderBreadcrumb-D_vuN164.js} +1 -1
  10. package/element/{ForgotPasswordPage-CIz3_X-3.js → ForgotPasswordPage-CLTfCRSc.js} +1 -1
  11. package/element/{InputField-DybXE_Ab.js → InputField-Dpa6h5y6.js} +1 -1
  12. package/element/{LazyLoadImage-8X8b06AJ.js → LazyLoadImage-btDC6I6Y.js} +1 -1
  13. package/element/{LeaderboardPage-Bphjksy_.js → LeaderboardPage-C35B-9Gu.js} +1 -1
  14. package/element/LoginPage-r5G2G0oG.js +1 -0
  15. package/element/{NCMVHL6D-CBCgRwdZ.js → NCMVHL6D-2v69SxO0.js} +1 -1
  16. package/element/{PublicEvents-RN-_fsl2.js → PublicEvents-CKFcMhSD.js} +1 -1
  17. package/element/RegisterPage-DiL8319w.js +1 -0
  18. package/element/{SocialLoginButton-DpBl7dWg.js → SocialLoginButton-Cm1XFx8_.js} +1 -1
  19. package/element/{UploadPage-B7BieTEU.js → UploadPage-9jnk9Zmk.js} +1 -1
  20. package/element/{VideoPlayer-Bk8Hao3q.js → VideoPlayer-D9AI4cZc.js} +1 -1
  21. package/element/element.es.js +1 -1
  22. package/element/{heic2any-DLQd-wQs.js → heic2any-DQvpqzo3.js} +1 -1
  23. package/element/{index-DI8B7D73.js → index-BHVViZaJ.js} +1 -1
  24. package/element/{index-JyoNGo8S.js → index-BKOpkw1h.js} +9 -9
  25. package/element/{index.esm-CAQX5kI5.js → index.esm-Hfm1g5lN.js} +1 -1
  26. package/element/{photoswipe-Coj-X7bR.js → photoswipe-C58kAXHU.js} +1 -1
  27. package/element/{tslib.es6-C9bR68b3.js → tslib.es6-khl_spk_.js} +1 -1
  28. package/element/{useOrgAccess-CnN4aiYB.js → useOrgAccess-D2Xgijq3.js} +1 -1
  29. package/element/web.es.js +1 -1
  30. package/package.json +12 -11
  31. package/react/{IbMHxVCj.js → 7c7bXPlP.js} +1 -1
  32. package/react/B0dDfEtH.js +1 -0
  33. package/react/{CZp0lmKh.js → B1r-QO-6.js} +1 -1
  34. package/react/{Y9TU3Znq.js → BDG18AiE.js} +1 -1
  35. package/react/{DBnzOELO.js → BE5TseI4.js} +3 -3
  36. package/react/{CXu6PHUW.js → BUZRB64M.js} +1 -1
  37. package/react/{Ply2G2qz.js → BUkcR85F.js} +1 -1
  38. package/react/{Pcjql-py.js → Bdifa0jH.js} +1 -1
  39. package/react/{BO8jvMXn.js → Brhsb0-T.js} +1 -1
  40. package/react/{B1neVlFZ.js → C5-YA8nT.js} +1 -1
  41. package/react/{Gbk2zO2l.js → C92qhyHF.js} +1 -1
  42. package/react/{D6nR1wv_.js → CJ6agILN.js} +1 -1
  43. package/react/{fuEo08KS.js → Ck1QkDXW.js} +1 -1
  44. package/react/{Dwry3hNI.js → CyVAYliQ.js} +1 -1
  45. package/react/{rZy1FKOQ.js → D7D-fe1-.js} +1 -1
  46. package/react/{CfZ5_7x-.js → DGkkW9h-.js} +1 -1
  47. package/react/{DyklTvwE.js → DT_P8FaG.js} +1 -1
  48. package/react/{jRrpvD0D.js → DW2r0IAI.js} +1 -1
  49. package/react/DzJMp-c4.js +1 -0
  50. package/react/{DrqnWQLs.js → IujfE24r.js} +1 -1
  51. package/react/{D_imcCpv.js → Lyg2aTtz.js} +3 -3
  52. package/react/{DvDETl8u.js → Z6p4C64a.js} +1 -1
  53. package/react/{DvOl03h5.js → gTevyE5I.js} +1 -1
  54. package/react/index.es.js +1 -2
  55. package/react/styles.css +1 -0
  56. package/umd/web.umd.js +106 -106
  57. package/element/LoginPage-CHzBIQEq.js +0 -1
  58. package/element/RegisterPage-7WLryyTX.js +0 -1
  59. package/react/BbIY3X7C.js +0 -1
  60. package/react/CN2vdtYT.js +0 -1
@@ -1 +1 @@
1
- import{c as e,T as r,P as t,a,D as o,Q as s}from"./Pcjql-py.js";import{a5 as l,a6 as n,a7 as c}from"./DBnzOELO.js";var u=u=>{const[i,d]=e({prefix:"TanstackQueryDevtools"}),m=l(),v=n(()=>{const e=i.theme_preference||r;return"system"!==e?e:m()});return c(s.Provider,{value:u,get children(){return c(t,{localStore:i,setLocalStore:d,get children(){return c(a.Provider,{value:v,get children(){return c(o,{localStore:i,setLocalStore:d})}})}})}})};export{u as default};
1
+ import{c as e,T as r,P as t,a,D as o,Q as s}from"./Bdifa0jH.js";import{a5 as l,a6 as n,a7 as c}from"./BE5TseI4.js";var u=u=>{const[i,d]=e({prefix:"TanstackQueryDevtools"}),m=l(),v=n(()=>{const e=i.theme_preference||r;return"system"!==e?e:m()});return c(s.Provider,{value:u,get children(){return c(t,{localStore:i,setLocalStore:d,get children(){return c(a.Provider,{value:v,get children(){return c(o,{localStore:i,setLocalStore:d})}})}})}})};export{u as default};
@@ -1 +1 @@
1
- import{P as e,j as s,I as r,g as a,T as o}from"./DBnzOELO.js";const l=(s,r)=>{const a=new Map;s?.forEach(e=>{a.set(e._id,e)});const o=[];let l=a.get(r);for(;l;)o.unshift({_id:l._id,name:l.name,href:e.FOLDER_EVENTS(l?._id),color:l.color}),l=a.get(l.parentFolderId);return o},c=({folder:e})=>s.jsxs("li",{className:"qc:flex qc:items-center",children:[s.jsx(r,{name:"material-symbols:arrow-forward-ios-rounded",size:"sm"}),s.jsxs(a,{to:e.href,className:"qc:flex qc:items-center qc:gap-2 qc:rounded qc:px-4 qc:py-1 qc:transition-colors qc:hover:bg-primary/10",children:[s.jsx(r,{name:"material-symbols:folder",size:"lg",style:{color:e.color}}),s.jsx(o,{variant:"h5",color:"secondary",className:"qc:whitespace-nowrap",children:e.name})]})]},e.name),n=({homeLink:e,data:o})=>s.jsxs("ol",{role:"list",className:"scrollbar-hide qc:flex qc:max-w-full qc:items-center qc:space-x-3 qc:overflow-y-scroll",children:[s.jsx("li",{children:s.jsxs(a,{to:e,className:"qc:text-foreground",children:[s.jsx(r,{name:"material-symbols:home-outline-rounded",size:"lg"}),s.jsx("span",{className:"qc:sr-only",children:"Home"})]})}),o?.map(e=>s.jsx(c,{folder:e},e._id))]});export{n as F,l as g};
1
+ import{P as e,j as s,I as r,g as a,T as o}from"./BE5TseI4.js";const l=(s,r)=>{const a=new Map;s?.forEach(e=>{a.set(e._id,e)});const o=[];let l=a.get(r);for(;l;)o.unshift({_id:l._id,name:l.name,href:e.FOLDER_EVENTS(l?._id),color:l.color}),l=a.get(l.parentFolderId);return o},c=({folder:e})=>s.jsxs("li",{className:"qc:flex qc:items-center",children:[s.jsx(r,{name:"material-symbols:arrow-forward-ios-rounded",size:"sm"}),s.jsxs(a,{to:e.href,className:"qc:flex qc:items-center qc:gap-2 qc:rounded qc:px-4 qc:py-1 qc:transition-colors qc:hover:bg-primary/10",children:[s.jsx(r,{name:"material-symbols:folder",size:"lg",style:{color:e.color}}),s.jsx(o,{variant:"h5",color:"secondary",className:"qc:whitespace-nowrap",children:e.name})]})]},e.name),n=({homeLink:e,data:o})=>s.jsxs("ol",{role:"list",className:"scrollbar-hide qc:flex qc:max-w-full qc:items-center qc:space-x-3 qc:overflow-y-scroll",children:[s.jsx("li",{children:s.jsxs(a,{to:e,className:"qc:text-foreground",children:[s.jsx(r,{name:"material-symbols:home-outline-rounded",size:"lg"}),s.jsx("span",{className:"qc:sr-only",children:"Home"})]})}),o?.map(e=>s.jsx(c,{folder:e},e._id))]});export{n as F,l as g};
@@ -1 +1 @@
1
- import{j as e,u as r,T as o,J as n,k as a,i as t,a4 as s,P as l}from"./DBnzOELO.js";import i,{useState as c}from"react";import{I as d}from"./CZp0lmKh.js";import{u,o as m,c as f,C as p,a as h,b as g}from"./-74yB4f5.js";const v=({count:r=1,currentStep:o=0,disabled:n,onStepClick:a})=>{const t=n||!a;return e.jsx("ol",{role:"list",className:"qc:flex qc:items-center qc:space-x-4 qc:pl-1.5",children:Array.from({length:r}).map((r,n)=>e.jsx("li",{children:n<o?e.jsx("button",{className:"qc:bg-primary qc:block qc:size-3 qc:rounded-full",disabled:t,onClick:()=>a&&a(n)}):n===o?e.jsxs("button",{className:"qc:relative qc:flex qc:items-center qc:justify-center","aria-current":"step",disabled:t,onClick:()=>a&&a(n),children:[e.jsx("span",{className:"qc:absolute qc:flex qc:size-6 qc:p-px","aria-hidden":"true",children:e.jsx("span",{className:"qc:bg-primary qc:size-full qc:rounded-full qc:bg-opacity-40"})}),e.jsx("span",{className:"qc:bg-primary qc:relative qc:block qc:size-3 qc:rounded-full","aria-hidden":"true"})]}):e.jsx("button",{className:"qc:block qc:size-3 qc:rounded-full qc:bg-text-secondary-light",disabled:t,onClick:()=>a&&a(n)})},`progress-dot-${n}`))})},q={email:""},w=f().shape({email:h().required("Please enter your email").email("Enter a valid email")}),x=({onCodeSent:s})=>{const[l,i]=c(!1),[f,h]=c(null),{props:{organizationId:g}}=r(),{control:v,handleSubmit:x,formState:{errors:y}}=u({mode:"onSubmit",defaultValues:q,resolver:m(w)});return e.jsxs("div",{className:"w-full space-y-6",children:[e.jsx(o,{variant:"h5",align:"center",children:"Reset password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-4 qc:lg:space-y-8",onSubmit:x(async e=>{h(null),i(!0);try{await a.post(t.SEND_PASSWORD_RESET_CODE,{json:{email:e.email?.toLowerCase()},headers:{"x-org-id":g}}),s(e.email.toLowerCase())}catch(e){console.error("Error sending verification code:",e),h(e.message||e||"An error occurred while sending the code. Please try again.")}i(!1)}),children:[e.jsx(p,{name:"email",control:v,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Email",disabled:l,type:"email",value:r,onChange:o,onBlur:n,error:y.email?.message})}),e.jsx(n,{fullWidth:!0,type:"submit",loading:l,children:"Send verification code"})]}),f&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:f})]})};var y=function(e){return"object"==typeof e&&null!==e},b=function(e){var r=e.value,o=void 0===r?"":r,n=e.numInputs,a=void 0===n?4:n,t=e.onChange,s=e.onPaste,l=e.renderInput,c=e.shouldAutoFocus,d=void 0!==c&&c,u=e.inputType,m=void 0===u?"text":u,f=e.renderSeparator,p=e.placeholder,h=e.containerStyle,g=e.inputStyle,v=e.skipDefaultStyles,q=void 0!==v&&v,w=i.useState(0),x=w[0],b=w[1],j=i.useRef([]),S=function(){return o?o.toString().split(""):[]},C="number"===m||"tel"===m;i.useEffect(function(){j.current=j.current.slice(0,a)},[a]),i.useEffect(function(){var e;d&&(null===(e=j.current[0])||void 0===e||e.focus())},[d]);var P=function(){if("string"==typeof p){if(p.length===a)return p;p.length>0&&console.error("Length of the placeholder should be equal to the number of inputs.")}},N=function(e){return(C?!isNaN(Number(e)):"string"==typeof e)&&1===e.trim().length},D=function(e){var r=e.target.value;N(r)&&(R(r),I(x+1))},E=function(e){var r=e.nativeEvent,o=e.target.value;if(!N(o)){if(o.length===a)o.split("").some(function(e){return!N(e)})||(O(o.split("")),I(a-1));null===r.data&&"deleteContentBackward"===r.inputType&&(e.preventDefault(),R(""),I(x-1)),e.target.value=""}},k=function(){b(x-1)},A=function(e){var r=S();[e.code,e.key].includes("Backspace")?(e.preventDefault(),R(""),I(x-1)):"Delete"===e.code?(e.preventDefault(),R("")):"ArrowLeft"===e.code?(e.preventDefault(),I(x-1)):"ArrowRight"===e.code||e.key===r[x]?(e.preventDefault(),I(x+1)):("Spacebar"===e.code||"Space"===e.code||"ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()},I=function(e){var r,o,n=Math.max(Math.min(a-1,e),0);j.current[n]&&(null===(r=j.current[n])||void 0===r||r.focus(),null===(o=j.current[n])||void 0===o||o.select(),b(n))},R=function(e){var r=S();r[x]=e[0],O(r)},O=function(e){var r=e.join("");t(r)},B=function(e){var r;e.preventDefault();var o=S(),n=x,t=e.clipboardData.getData("text/plain").slice(0,a-x).split("");if(!C||!t.some(function(e){return isNaN(Number(e))})){for(var s=0;s<a;++s)s>=x&&t.length>0&&(o[s]=null!==(r=t.shift())&&void 0!==r?r:"",n++);I(n),O(o)}};return i.createElement("div",{style:Object.assign({display:"flex",alignItems:"center"},y(h)&&h),className:"string"==typeof h?h:void 0,onPaste:s},Array.from({length:a},function(e,r){return r}).map(function(e){var r,o,n;return i.createElement(i.Fragment,{key:e},l({value:null!==(r=S()[e])&&void 0!==r?r:"",placeholder:null!==(n=null===(o=P())||void 0===o?void 0:o[e])&&void 0!==n?n:void 0,ref:function(r){return j.current[e]=r},onChange:D,onFocus:function(r){return function(e){return function(r){b(r),e.target.select()}}(r)(e)},onBlur:k,onKeyDown:A,onPaste:B,autoComplete:"off","aria-label":"Please enter OTP character ".concat(e+1),style:Object.assign(q?{}:{width:"1em",textAlign:"center"},y(g)?g:{}),className:"string"==typeof g?g:void 0,type:m,inputMode:C?"numeric":"text",onInput:E},e),e<a-1&&("function"==typeof f?f(e):f))}))};const j={code:""},S=f().shape({code:h().required("Please enter the code")}),C=({email:s,onCodeVerified:l})=>{const{props:{organizationId:i}}=r(),[d,f]=c(!1),[h,g]=c(null),{control:v,handleSubmit:q,watch:w}=u({mode:"onSubmit",defaultValues:j,resolver:m(S)});return e.jsxs("div",{className:"qc:space-y-4 qc:lg:space-y-8",children:[e.jsxs(o,{variant:"h5",align:"center",children:["Enter the code sent to ",e.jsx("span",{className:"qc:text-primary qc:font-medium",children:s})]}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:flex qc:w-full qc:flex-col qc:items-center qc:gap-4 qc:lg:gap-8",onSubmit:q(async e=>{g(null),f(!0);try{await a.post(t.VERIFY_PASSWORD_RESET_CODE,{json:{email:s,code:e.code},headers:{"x-org-id":i}}),l&&l()}catch(e){console.error(e.message),g("An error occurred while verifying the code. Please try again.")}f(!1)}),children:[e.jsx(p,{name:"code",control:v,render:({field:{value:r,onChange:o}})=>e.jsx(b,{value:r,onChange:o,numInputs:6,shouldAutoFocus:!0,inputType:"number",isInputNum:!0,containerStyle:"qc:flex qc:gap-4",inputStyle:"qc:rounded qc:border qc:focus:border-primary qc:text-foreground qc:bg-white qc:disabled:border-border qc:disabled:text-gray-400 otp-input qc:text-xl qc:focus:outline-none qc:focus:ring-0 qc:focus:boder-none",renderInput:r=>e.jsx("input",{...r})})}),e.jsx(n,{fullWidth:!0,type:"submit",disabled:w("code").length<6,loading:d,children:"Submit"})]}),h&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:h})]})},P={password:"",confirmPassword:""},N=f().shape({password:h().required("Please enter your password").min(8,"Min password length is 8"),confirmPassword:h().required("Please confirm your password").min(8,"Min password length is 8").oneOf([g("password"),null],"Passwords do not match")}),D=({email:s,onPasswordReset:l})=>{const{props:{organizationId:i}}=r(),[f,h]=c({showPassword:!1,showConfirmPassword:!1}),[g,v]=c(!1),[q,w]=c(null),{control:x,handleSubmit:y,formState:{errors:b}}=u({defaultValues:P,mode:"onSubmit",resolver:m(N)});return e.jsxs("div",{className:"qc:w-full qc:space-y-4",children:[e.jsx(o,{variant:"h5",align:"center",children:"Set new password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-8",onSubmit:y(async e=>{w(null),v(!0);try{const r=await a.post(t.RESET_PASSWORD,{json:{email:s.toLowerCase(),password:e.password},headers:{"x-org-id":i}});r.error?w(r.error):l()}catch{w("An error occurred while resetting the password. Please try again.")}v(!1)}),children:[e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"password",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"New password",disabled:g,type:f.showPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.password?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showPassword:!f.showPassword})})]}),e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"confirmPassword",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Confirm new password",disabled:g,type:f.showConfirmPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.confirmPassword?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showConfirmPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showConfirmPassword:!f.showConfirmPassword})})]}),e.jsx(n,{fullWidth:!0,type:"submit",color:"primary",loading:g,children:"Reset password"})]}),q&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:q})]})},E=()=>{const r=s(),[o,n]=c(null),[a,t]=c(0);return e.jsxs("div",{className:"space-y-9",children:[(({index:a})=>{switch(a){case 0:return e.jsx(x,{onCodeSent:e=>{n(e),t(1)}});case 1:return e.jsx(C,{email:o,onCodeVerified:()=>t(2)});case 2:return e.jsx(D,{email:o,onPasswordReset:()=>{r(l.LOGIN)}})}})({index:a}),e.jsx("div",{className:"qc:mt-8 qc:flex qc:justify-center",children:e.jsx(v,{count:3,currentStep:a})})]})};export{E as default};
1
+ import{j as e,u as r,T as o,J as n,k as a,i as t,a4 as s,P as l}from"./BE5TseI4.js";import c,{useState as i}from"react";import{I as d}from"./B1r-QO-6.js";import{u,o as m,c as f,C as p,a as h,b as g}from"./-74yB4f5.js";const v=({count:r=1,currentStep:o=0,disabled:n,onStepClick:a})=>{const t=n||!a;return e.jsx("ol",{role:"list",className:"qc:flex qc:items-center qc:space-x-4 qc:pl-1.5",children:Array.from({length:r}).map((r,n)=>e.jsx("li",{children:n<o?e.jsx("button",{className:"qc:bg-primary qc:block qc:size-3 qc:rounded-full",disabled:t,onClick:()=>a&&a(n)}):n===o?e.jsxs("button",{className:"qc:relative qc:flex qc:items-center qc:justify-center","aria-current":"step",disabled:t,onClick:()=>a&&a(n),children:[e.jsx("span",{className:"qc:absolute qc:flex qc:size-6 qc:p-px","aria-hidden":"true",children:e.jsx("span",{className:"qc:bg-primary qc:size-full qc:rounded-full qc:bg-opacity-40"})}),e.jsx("span",{className:"qc:bg-primary qc:relative qc:block qc:size-3 qc:rounded-full","aria-hidden":"true"})]}):e.jsx("button",{className:"qc:block qc:size-3 qc:rounded-full qc:bg-text-secondary-light",disabled:t,onClick:()=>a&&a(n)})},`progress-dot-${n}`))})},q={email:""},w=f().shape({email:h().required("Please enter your email").email("Enter a valid email")}),x=({onCodeSent:s})=>{const[l,c]=i(!1),[f,h]=i(null),{props:{organizationId:g}}=r(),{control:v,handleSubmit:x,formState:{errors:y}}=u({mode:"onSubmit",defaultValues:q,resolver:m(w)});return e.jsxs("div",{className:"w-full space-y-6",children:[e.jsx(o,{variant:"h5",align:"center",children:"Reset password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-4 qc:lg:space-y-8",onSubmit:x(async e=>{h(null),c(!0);try{await a.post(t.SEND_PASSWORD_RESET_CODE,{json:{email:e.email?.toLowerCase()},headers:{"x-org-id":g}}),s(e.email.toLowerCase())}catch(e){console.error("Error sending verification code:",e),h(e.message||e||"An error occurred while sending the code. Please try again.")}c(!1)}),children:[e.jsx(p,{name:"email",control:v,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Email",disabled:l,type:"email",value:r,onChange:o,onBlur:n,error:y.email?.message})}),e.jsx(n,{fullWidth:!0,type:"submit",loading:l,children:"Send verification code"})]}),f&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:f})]})};var y=function(e){return"object"==typeof e&&null!==e},b=function(e){var r=e.value,o=void 0===r?"":r,n=e.numInputs,a=void 0===n?4:n,t=e.onChange,s=e.onPaste,l=e.renderInput,i=e.shouldAutoFocus,d=void 0!==i&&i,u=e.inputType,m=void 0===u?"text":u,f=e.renderSeparator,p=e.placeholder,h=e.containerStyle,g=e.inputStyle,v=e.skipDefaultStyles,q=void 0!==v&&v,w=c.useState(0),x=w[0],b=w[1],j=c.useRef([]),S=function(){return o?o.toString().split(""):[]},C="number"===m||"tel"===m;c.useEffect(function(){j.current=j.current.slice(0,a)},[a]),c.useEffect(function(){var e;d&&(null===(e=j.current[0])||void 0===e||e.focus())},[d]);var P=function(){if("string"==typeof p){if(p.length===a)return p;p.length>0&&console.error("Length of the placeholder should be equal to the number of inputs.")}},N=function(e){return(C?!isNaN(Number(e)):"string"==typeof e)&&1===e.trim().length},D=function(e){var r=e.target.value;N(r)&&(R(r),I(x+1))},E=function(e){var r=e.nativeEvent,o=e.target.value;if(!N(o)){if(o.length===a)o.split("").some(function(e){return!N(e)})||(O(o.split("")),I(a-1));null===r.data&&"deleteContentBackward"===r.inputType&&(e.preventDefault(),R(""),I(x-1)),e.target.value=""}},k=function(){b(x-1)},A=function(e){var r=S();[e.code,e.key].includes("Backspace")?(e.preventDefault(),R(""),I(x-1)):"Delete"===e.code?(e.preventDefault(),R("")):"ArrowLeft"===e.code?(e.preventDefault(),I(x-1)):"ArrowRight"===e.code||e.key===r[x]?(e.preventDefault(),I(x+1)):("Spacebar"===e.code||"Space"===e.code||"ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()},I=function(e){var r,o,n=Math.max(Math.min(a-1,e),0);j.current[n]&&(null===(r=j.current[n])||void 0===r||r.focus(),null===(o=j.current[n])||void 0===o||o.select(),b(n))},R=function(e){var r=S();r[x]=e[0],O(r)},O=function(e){var r=e.join("");t(r)},B=function(e){var r;e.preventDefault();var o=S(),n=x,t=e.clipboardData.getData("text/plain").slice(0,a-x).split("");if(!C||!t.some(function(e){return isNaN(Number(e))})){for(var s=0;s<a;++s)s>=x&&t.length>0&&(o[s]=null!==(r=t.shift())&&void 0!==r?r:"",n++);I(n),O(o)}};return c.createElement("div",{style:Object.assign({display:"flex",alignItems:"center"},y(h)&&h),className:"string"==typeof h?h:void 0,onPaste:s},Array.from({length:a},function(e,r){return r}).map(function(e){var r,o,n;return c.createElement(c.Fragment,{key:e},l({value:null!==(r=S()[e])&&void 0!==r?r:"",placeholder:null!==(n=null===(o=P())||void 0===o?void 0:o[e])&&void 0!==n?n:void 0,ref:function(r){return j.current[e]=r},onChange:D,onFocus:function(r){return function(e){return function(r){b(r),e.target.select()}}(r)(e)},onBlur:k,onKeyDown:A,onPaste:B,autoComplete:"off","aria-label":"Please enter OTP character ".concat(e+1),style:Object.assign(q?{}:{width:"1em",textAlign:"center"},y(g)?g:{}),className:"string"==typeof g?g:void 0,type:m,inputMode:C?"numeric":"text",onInput:E},e),e<a-1&&("function"==typeof f?f(e):f))}))};const j={code:""},S=f().shape({code:h().required("Please enter the code")}),C=({email:s,onCodeVerified:l})=>{const{props:{organizationId:c}}=r(),[d,f]=i(!1),[h,g]=i(null),{control:v,handleSubmit:q,watch:w}=u({mode:"onSubmit",defaultValues:j,resolver:m(S)});return e.jsxs("div",{className:"qc:space-y-4 qc:lg:space-y-8",children:[e.jsxs(o,{variant:"h5",align:"center",children:["Enter the code sent to ",e.jsx("span",{className:"qc:text-primary qc:font-medium",children:s})]}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:flex qc:w-full qc:flex-col qc:items-center qc:gap-4 qc:lg:gap-8",onSubmit:q(async e=>{g(null),f(!0);try{await a.post(t.VERIFY_PASSWORD_RESET_CODE,{json:{email:s,code:e.code},headers:{"x-org-id":c}}),l&&l()}catch(e){console.error(e.message),g("An error occurred while verifying the code. Please try again.")}f(!1)}),children:[e.jsx(p,{name:"code",control:v,render:({field:{value:r,onChange:o}})=>e.jsx(b,{value:r,onChange:o,numInputs:6,shouldAutoFocus:!0,inputType:"number",isInputNum:!0,containerStyle:"qc:flex qc:gap-4",inputStyle:"qc:rounded qc:border qc:focus:border-primary qc:text-foreground qc:bg-white qc:disabled:border-border qc:disabled:text-gray-400 otp-input qc:text-xl qc:focus:outline-none qc:focus:ring-0 qc:focus:boder-none",renderInput:r=>e.jsx("input",{...r})})}),e.jsx(n,{fullWidth:!0,type:"submit",disabled:w("code").length<6,loading:d,children:"Submit"})]}),h&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:h})]})},P={password:"",confirmPassword:""},N=f().shape({password:h().required("Please enter your password").min(8,"Min password length is 8"),confirmPassword:h().required("Please confirm your password").min(8,"Min password length is 8").oneOf([g("password"),null],"Passwords do not match")}),D=({email:s,onPasswordReset:l})=>{const{props:{organizationId:c}}=r(),[f,h]=i({showPassword:!1,showConfirmPassword:!1}),[g,v]=i(!1),[q,w]=i(null),{control:x,handleSubmit:y,formState:{errors:b}}=u({defaultValues:P,mode:"onSubmit",resolver:m(N)});return e.jsxs("div",{className:"qc:w-full qc:space-y-4",children:[e.jsx(o,{variant:"h5",align:"center",children:"Set new password"}),e.jsxs("form",{noValidate:!0,autoComplete:"off",className:"qc:w-full qc:space-y-8",onSubmit:y(async e=>{w(null),v(!0);try{const r=await a.post(t.RESET_PASSWORD,{json:{email:s.toLowerCase(),password:e.password},headers:{"x-org-id":c}});r.error?w(r.error):l()}catch{w("An error occurred while resetting the password. Please try again.")}v(!1)}),children:[e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"password",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"New password",disabled:g,type:f.showPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.password?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showPassword:!f.showPassword})})]}),e.jsxs("div",{className:"qc:relative",children:[e.jsx(p,{name:"confirmPassword",control:x,render:({field:{value:r,onChange:o,onBlur:n}})=>e.jsx(d,{label:"Confirm new password",disabled:g,type:f.showConfirmPassword?"text":"password",value:r,onChange:o,onBlur:n,error:b.confirmPassword?.message})}),e.jsx(n,{variant:"ghost",color:"primary",className:"qc:absolute qc:-right-4 qc:top-7",icon:f.showConfirmPassword?"mdi:eye-outline":"mdi:eye-off-outline",onClick:()=>h({...f,showConfirmPassword:!f.showConfirmPassword})})]}),e.jsx(n,{fullWidth:!0,type:"submit",color:"primary",loading:g,children:"Reset password"})]}),q&&e.jsx(o,{variant:"h3",align:"center",color:"color",children:q})]})},E=()=>{const r=s(),[o,n]=i(null),[a,t]=i(0);return e.jsxs("div",{className:"qc:space-y-9 qc:bg-background",children:[(({index:a})=>{switch(a){case 0:return e.jsx(x,{onCodeSent:e=>{n(e),t(1)}});case 1:return e.jsx(C,{email:o,onCodeVerified:()=>t(2)});case 2:return e.jsx(D,{email:o,onPasswordReset:()=>{r(l.LOGIN)}})}})({index:a}),e.jsx("div",{className:"qc:mt-8 qc:flex qc:justify-center",children:e.jsx(v,{count:3,currentStep:a})})]})};export{E as default};