@swan-admin/swan-web-component 1.0.121 → 1.0.123

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 (169) hide show
  1. package/dist/BodyScan-CCRXkFFL.mjs +3 -0
  2. package/dist/BodyScan-CCRXkFFL.mjs.map +1 -0
  3. package/dist/BodyScan-RBxSYdGc.js +3 -0
  4. package/dist/BodyScan-RBxSYdGc.js.map +1 -0
  5. package/dist/FaceScan-DQvhrp3K.mjs +3 -0
  6. package/dist/FaceScan-DQvhrp3K.mjs.map +1 -0
  7. package/dist/{FaceScan-BRdpV_Yn.js → FaceScan-Dva9De8x.js} +3 -2
  8. package/dist/{FaceScan-BRdpV_Yn.js.map → FaceScan-Dva9De8x.js.map} +1 -1
  9. package/dist/{Modal-BPtRtRVC.js → Modal-CZgyeNwW.mjs} +3 -2
  10. package/dist/Modal-CZgyeNwW.mjs.map +1 -0
  11. package/dist/{Modal-HTYYx7sM.js → Modal-CmbYIXgn.js} +3 -2
  12. package/dist/{Modal-YZScjwEm.js.map → Modal-CmbYIXgn.js.map} +1 -1
  13. package/dist/bodyScan.d.ts +2 -2
  14. package/dist/bodyScan.js +2 -1
  15. package/dist/bodyScan.mjs +2 -1
  16. package/dist/faceScan.js +2 -1
  17. package/dist/faceScan.mjs +2 -1
  18. package/dist/index.css +1 -1
  19. package/dist/index.js +2 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +2 -1
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/{pose-detection.esm-Bc8T4UAD.js → pose-detection.esm-DFB9u8DH.js} +2 -1
  24. package/dist/{pose-detection.esm-Bc8T4UAD.js.map → pose-detection.esm-DFB9u8DH.js.map} +1 -1
  25. package/dist/{pose-detection.esm-DC0_P6R7.js → pose-detection.esm-EvS-BndH.mjs} +2 -1
  26. package/dist/pose-detection.esm-EvS-BndH.mjs.map +1 -0
  27. package/package.json +3 -2
  28. package/dist/BodyScan-3YoMZG7n.js +0 -2
  29. package/dist/BodyScan-8qgqyl5-.js +0 -2
  30. package/dist/BodyScan-B0qqqK3C.js +0 -2
  31. package/dist/BodyScan-B1VBoA6S.js +0 -2
  32. package/dist/BodyScan-B1afPG1Q.js +0 -2
  33. package/dist/BodyScan-B1afPG1Q.js.map +0 -1
  34. package/dist/BodyScan-B4-sO3R2.js +0 -2
  35. package/dist/BodyScan-B87W6dpH.js +0 -2
  36. package/dist/BodyScan-B8pglBAp.js +0 -2
  37. package/dist/BodyScan-BEFwluXG.js +0 -2
  38. package/dist/BodyScan-BHgnqB6A.js +0 -2
  39. package/dist/BodyScan-BLvWlYnA.js +0 -2
  40. package/dist/BodyScan-BMAkl5Iw.js +0 -2
  41. package/dist/BodyScan-BMTK6e-E.js +0 -2
  42. package/dist/BodyScan-BQri8pAO.js +0 -2
  43. package/dist/BodyScan-BVNPC7bJ.js +0 -2
  44. package/dist/BodyScan-BfLKF5PU.js +0 -2
  45. package/dist/BodyScan-BjYHCskz.js +0 -2
  46. package/dist/BodyScan-BoAbG01d.js +0 -2
  47. package/dist/BodyScan-Bq64fsmL.js +0 -2
  48. package/dist/BodyScan-Bre1BIHK.js +0 -2
  49. package/dist/BodyScan-BsDJmy0G.js +0 -2
  50. package/dist/BodyScan-ByMGumuH.js +0 -2
  51. package/dist/BodyScan-C0V-EDdB.js +0 -2
  52. package/dist/BodyScan-C1dWJ2qu.js +0 -2
  53. package/dist/BodyScan-C43x2o2T.js +0 -2
  54. package/dist/BodyScan-C57PuQgF.js +0 -2
  55. package/dist/BodyScan-C9hQU-dK.js +0 -2
  56. package/dist/BodyScan-CA4rNyqL.js +0 -2
  57. package/dist/BodyScan-CH-_x55M.js +0 -2
  58. package/dist/BodyScan-CKH_WyTt.js +0 -2
  59. package/dist/BodyScan-CKmPcrkx.js +0 -2
  60. package/dist/BodyScan-CLpL3Uwx.js +0 -2
  61. package/dist/BodyScan-CM12T_-T.js +0 -2
  62. package/dist/BodyScan-CNhb6UOX.js +0 -2
  63. package/dist/BodyScan-CWsaPB8W.js +0 -2
  64. package/dist/BodyScan-CXwtxfOd.js +0 -2
  65. package/dist/BodyScan-CYn7eLoz.js +0 -2
  66. package/dist/BodyScan-CYnHFqsR.js +0 -2
  67. package/dist/BodyScan-CZTiQzpy.js +0 -2
  68. package/dist/BodyScan-Cc68SnU1.js +0 -2
  69. package/dist/BodyScan-CfS4bPCN.js +0 -2
  70. package/dist/BodyScan-CiG19l_n.js +0 -2
  71. package/dist/BodyScan-CjvyMLT9.js +0 -2
  72. package/dist/BodyScan-CkmrPAq9.js +0 -2
  73. package/dist/BodyScan-CoObDhac.js +0 -2
  74. package/dist/BodyScan-Cyfo46EK.js +0 -2
  75. package/dist/BodyScan-Cz9ggKm6.js +0 -2
  76. package/dist/BodyScan-D6Y_W5e2.js +0 -2
  77. package/dist/BodyScan-DCEgmVbG.js +0 -2
  78. package/dist/BodyScan-DEDdENv7.js +0 -2
  79. package/dist/BodyScan-DEdrK-ld.js +0 -2
  80. package/dist/BodyScan-DHMf2V5R.js +0 -2
  81. package/dist/BodyScan-DK9UmNBr.js +0 -2
  82. package/dist/BodyScan-DPCd26i-.js +0 -2
  83. package/dist/BodyScan-DPCd26i-.js.map +0 -1
  84. package/dist/BodyScan-DPSQ1hKh.js +0 -2
  85. package/dist/BodyScan-DVKnmJuJ.js +0 -2
  86. package/dist/BodyScan-DX_KbG5U.js +0 -2
  87. package/dist/BodyScan-DbfP9-G3.js +0 -2
  88. package/dist/BodyScan-DeBJWo0L.js +0 -2
  89. package/dist/BodyScan-DgZpiChn.js +0 -2
  90. package/dist/BodyScan-DkPwUgVu.js +0 -2
  91. package/dist/BodyScan-DntA0MBx.js +0 -2
  92. package/dist/BodyScan-DxidLEhk.js +0 -2
  93. package/dist/BodyScan-DyDxGqfI.js +0 -2
  94. package/dist/BodyScan-Dysj7b77.js +0 -2
  95. package/dist/BodyScan-DzyamZmb.js +0 -2
  96. package/dist/BodyScan-Ehsr_cYc.js +0 -2
  97. package/dist/BodyScan-MSB66I12.js +0 -2
  98. package/dist/BodyScan-Ot6nAH1j.js +0 -2
  99. package/dist/BodyScan-Srq29PK8.js +0 -2
  100. package/dist/BodyScan-SzaquTgH.js +0 -2
  101. package/dist/BodyScan-TPpfyief.js +0 -2
  102. package/dist/BodyScan-XW2vsiE3.js +0 -2
  103. package/dist/BodyScan-eUuIC3jY.js +0 -2
  104. package/dist/BodyScan-enDyqSjO.js +0 -2
  105. package/dist/BodyScan-iOXndWaO.js +0 -2
  106. package/dist/BodyScan-qVHOWabf.js +0 -2
  107. package/dist/BodyScan-t9qdQAL-.js +0 -2
  108. package/dist/BodyScan-twE2YOwy.js +0 -2
  109. package/dist/BodyScan-z6h5fueJ.js +0 -2
  110. package/dist/FaceScan-3rVSqkKB.js +0 -2
  111. package/dist/FaceScan-6Aoz5uUy.js +0 -2
  112. package/dist/FaceScan-7fl5pLnb.js +0 -2
  113. package/dist/FaceScan-9kUfXRSv.js +0 -2
  114. package/dist/FaceScan-AHZ-ajep.js +0 -2
  115. package/dist/FaceScan-B0pFv4Us.js +0 -2
  116. package/dist/FaceScan-BE0PB0fZ.js +0 -2
  117. package/dist/FaceScan-BWSeJEqI.js +0 -2
  118. package/dist/FaceScan-BdjT7nMG.js +0 -2
  119. package/dist/FaceScan-Bji5lGcQ.js +0 -2
  120. package/dist/FaceScan-Bji5lGcQ.js.map +0 -1
  121. package/dist/FaceScan-BmDNM8tt.js +0 -2
  122. package/dist/FaceScan-CNoW9DIE.js +0 -2
  123. package/dist/FaceScan-CPf6-siO.js +0 -2
  124. package/dist/FaceScan-CQayY4q-.js +0 -2
  125. package/dist/FaceScan-CQkfSMC2.js +0 -2
  126. package/dist/FaceScan-CaxQ6fGF.js +0 -2
  127. package/dist/FaceScan-CxDcvM4f.js +0 -2
  128. package/dist/FaceScan-D2PL8KpZ.js +0 -2
  129. package/dist/FaceScan-D3T_l4nN.js +0 -2
  130. package/dist/FaceScan-DCm43Nrq.js +0 -2
  131. package/dist/FaceScan-DKP93c3l.js +0 -2
  132. package/dist/FaceScan-DW6Ix1a1.js +0 -2
  133. package/dist/FaceScan-DYJVZoZ4.js +0 -2
  134. package/dist/FaceScan-Da2XEApH.js +0 -2
  135. package/dist/FaceScan-DrW2yUSA.js +0 -2
  136. package/dist/FaceScan-DxnydFcx.js +0 -2
  137. package/dist/FaceScan-Gm4F4cO1.js +0 -2
  138. package/dist/FaceScan-Nhc7myLG.js +0 -2
  139. package/dist/FaceScan-VFLJ9h_T.js +0 -2
  140. package/dist/FaceScan-iUXyDuza.js +0 -2
  141. package/dist/LoadingScreen-BILrJVZm.js +0 -2
  142. package/dist/LoadingScreen-FKDLJRUj.js +0 -2
  143. package/dist/Modal-4T_aWWPQ.js +0 -2
  144. package/dist/Modal-BHfJVhRi.js +0 -2
  145. package/dist/Modal-BitizIvu.js +0 -2
  146. package/dist/Modal-BpgpPVxR.js +0 -2
  147. package/dist/Modal-BzH-_ch3.js +0 -2
  148. package/dist/Modal-CB_MHF7l.js +0 -2
  149. package/dist/Modal-CDiBoVXR.js +0 -2
  150. package/dist/Modal-CWoUZTh4.js +0 -2
  151. package/dist/Modal-CaPtqgjI.js +0 -2
  152. package/dist/Modal-CbZJwbLZ.js +0 -2
  153. package/dist/Modal-DRjJKUrw.js +0 -2
  154. package/dist/Modal-DU2Jymve.js +0 -2
  155. package/dist/Modal-D_XGokez.js +0 -2
  156. package/dist/Modal-DnweWp6L.js +0 -2
  157. package/dist/Modal-Do--CErH.js +0 -2
  158. package/dist/Modal-Do--CErH.js.map +0 -1
  159. package/dist/Modal-YZScjwEm.js +0 -2
  160. package/dist/fonts/Switzer-Regular.eot +0 -0
  161. package/dist/fonts/Switzer-Regular.svg +0 -0
  162. package/dist/fonts/Switzer-Regular.ttf +0 -0
  163. package/dist/fonts/Switzer-Regular.woff +0 -0
  164. package/dist/fonts/Switzer-Regular.woff2 +0 -0
  165. package/dist/interfaces-B5ysRXpa.d.ts +0 -209
  166. package/dist/interfaces-CaaERZjZ.d.ts +0 -209
  167. package/dist/pose-detection.esm-D08ZA0zl.js +0 -18
  168. package/dist/pose-detection.esm-DejsYGYM.js +0 -18
  169. package/dist/pose-detection.esm-DejsYGYM.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"BodyScan-B1afPG1Q.js","sources":["../src/utils/context/mediaContext.tsx","../src/Icons/SwitchIcon.tsx","../src/components/bodyScan/LevelScreen.tsx","../src/components/bodyScan/CameraScanChild.tsx","../src/customHooks/useTensorFlow.ts","../src/components/bodyScan/ScanningComponent.tsx","../src/components/bodyScan/AngleDetector.tsx","../src/components/bodyScan/CameraPermission.tsx","../src/components/bodyScan/VideoPlayer.tsx","../src/components/bodyScan/ScanErrorMessage.tsx","../src/components/Signup.tsx","../src/components/bodyScan/BodyScanSteps.tsx","../src/components/bodyScan/BodyScan.tsx","../src/customHooks/useGyroSensor.ts"],"sourcesContent":["\"use client\"\nimport React, {\n createContext,\n Dispatch,\n ReactNode,\n SetStateAction,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from \"react\";\n\nexport const MEDIA_TYPES = {\n DESKTOP: \"DESKTOP\",\n TAB: \"TAB\",\n MOBILE: \"MOBILE\",\n};\n\ninterface MediaContextType {\n size: number[];\n setSize: Dispatch<SetStateAction<number[]>>;\n clearInputs: boolean;\n setClearInputs: Dispatch<SetStateAction<boolean>>;\n media: string;\n}\n\nexport const MediaContext = createContext<MediaContextType | undefined>(\n undefined\n);\n\nfunction MediaContextProvider({ children }: { children: ReactNode }) {\n const [size, setSize] = useState([window?.innerWidth, window?.innerHeight]);\n const [clearInputs, setClearInputs] = useState(false);\n\n const updateSize = () => {\n setSize([window?.innerWidth, window?.innerHeight]);\n };\n useEffect(() => {\n updateSize();\n }, []);\n useLayoutEffect(() => {\n window.addEventListener(\"resize\", updateSize);\n return () => window.removeEventListener(\"resize\", updateSize);\n }, [updateSize]);\n let media = MEDIA_TYPES.DESKTOP;\n if (size[0] > 768 && size[0] < 1024) {\n media = MEDIA_TYPES.TAB;\n }\n if (size[0] < 768) {\n media = MEDIA_TYPES.MOBILE;\n }\n\n const mediaDetails = useMemo(\n () => ({\n size,\n setSize,\n clearInputs,\n setClearInputs,\n media,\n }),\n [size, clearInputs, media]\n );\n\n return (\n <MediaContext.Provider value={mediaDetails}>\n {children}\n </MediaContext.Provider>\n );\n}\n\nexport default MediaContextProvider;\n","import React from \"react\";\n\nfunction SwitchIcon({ size = 16 }: { size?: number }) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968\"\n stroke=\"white\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nexport default React.memo(SwitchIcon);\n","/* eslint-disable no-nested-ternary */\n\nimport React, { useCallback, useContext, useMemo } from \"react\";\nimport Header from \"../Header\";\nimport cn from \"clsx\";\nimport { LevelScreenProps } from \"../../types/interfaces\";\nimport SwitchIcon from \"../../Icons/SwitchIcon\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { useConfig } from \"../../utils/context/configContext\";\n\nfunction LevelScreen({ angle, countdown, isScanning, isInTargetRange, stabilityScore, children }: Omit<LevelScreenProps, \"config\">) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\tconst config = useConfig();\n\n\tconst getProximityToTarget = useCallback(() => {\n\t\tif (angle < 80) return Math.max(0, Math.min(100, (angle - 60) * 10));\n\t\tif (angle > 95) return Math.max(0, Math.min(100, (105 - angle) * 10));\n\t\treturn 100;\n\t}, [angle]);\n\n\tconst backgroundColor = useMemo(() => {\n\t\tif (isScanning) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n\t\tconst proximity = getProximityToTarget();\n\t\tif (proximity === 0) return config?.style?.angleDetector?.successAngleLowBackground || \"#ffffff\";\n\t\tif (proximity === 100) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n const r = Math.round(255 - (255 - 139) * (proximity / 100));\n const g = Math.round(255 - (255 - 92) * (proximity / 100));\n const b = Math.round(255 - (255 - 246) * (proximity / 100));\n return `rgb(${r}, ${g}, ${b})`;\n }, [isScanning, getProximityToTarget]);\n\n\tconst handelTextColour = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/70` : `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t}\n\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/40` : `text-[${config?.style?.angleDetector?.successAngleTextDarkColor}]/70`;\n\t}, []);\n\n\tconst getTextColor = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t\treturn handelTextColour(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\n\tconst handelColourCode = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t}\n\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextDarkColor;\n\t}, []);\n\tconst getColorCode = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t\treturn handelColourCode(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\tconst cd = countdown;\n\tfunction fixVh() {\n\t\tdocument.documentElement.style.setProperty(\"--real-vh\", window.innerHeight + \"px\");\n\t}\n\tfixVh();\n\twindow.addEventListener(\"resize\", fixVh);\n\treturn (\n\t\t<div\n\t\t\tclassName=\"flex common-ui-main w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto\"\n\t\t\tstyle={{ backgroundColor }}\n\t\t\tdata-testid=\"level-screen\"\n\t\t\tdata-angle-state={isScanning ? \"locked\" : isInTargetRange ? \"target\" : \"adjusting\"}\n\t\t>\n\t\t\t<div className=\"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]\">\n\t\t\t\t<div className=\"flex justify-start \">\n\t\t\t\t\t<Header noTitle />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{cd !== null ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`text-[3rem] font-bold text-[${getColorCode()}]`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{cd}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : isScanning ? (\n\t\t\t\t<div className=\"relative flex flex-col items-center justify-center\">\n\t\t\t\t\t<div className=\"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]\">\n\t\t\t\t\t\t<div className=\"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\tclassName={cn(\"relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] \", isInTargetRange ? \"bg-[#fff]/20 border-[#fff]\" : \"bg-[#fff]/10 border-[#fff]\")}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\ttransform: `translateY(${(90 - angle) * 3}px)`,\n\t\t\t\t\t\ttransition: \"transform 0.2s ease-out\",\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div className={`h-[1rem] w-[1rem] rounded-[9999px] bg-[${getColorCode()}]/80`}\n style={{\n\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t}}\n />\n\t\t\t\t\t<div\n\t\t\t\t\t\t// className=\" text-[#fff]\"\n\t\t\t\t\t\tclassName={cn(\"mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SwitchIcon size={30} />\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{\" \"}\n\t\t\t\t\t\t\t{translate?.(LanguageKeys.startLevelCheck)}\n\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{cd !== null && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] text-center\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.leavePhone)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{isInTargetRange && cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] w-[12rem]\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`h-[.375rem] w-full bg-[${getColorCode()}]/20 rounded-[9999px] overflow-hidden`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}33`, // 20% opacity\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={`h-full bg-[${getColorCode()}]/70 transition-all duration-300 rounded-[9999px]`}\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: `${angle}%`,\n\t\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n {cd === null && !isScanning && (\n <div className=\"absolute bottom-[5rem] text-center\">\n <div className={cn(\"text-[1.5rem] font-light\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n >\n {Math.round(angle)}°\n </div>\n </div>\n )}\n\n\t\t\t{cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-[.75rem] opacity-50\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.placePhoneUpright)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\nexport default React.memo(LevelScreen);\n","import { useContext } from \"react\";\nimport Webcam from \"react-webcam\";\nimport { CameraScanChildProps } from \"../../types/interfaces\";\nimport { MEDIA_TYPES, MediaContext } from \"../../utils/context/mediaContext\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { pauseIcon, voiceOverAssetsPath } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\n\n\n\nfunction CameraScanChild({\n resetScan,\n loadingCam,\n onUserMedia,\n onPause,\n pause,\n onReScan,\n recordingStarted,\n startSendingVideoFrames,\n showPause,\n webcamRef,\n onUserMediaError,\n resetDetector,\n videoConstraints,\n webcamKey,\n faceDone,\n isScanning,\n}: Omit<CameraScanChildProps, \"config\">) {\n const { media } = useContext(MediaContext) || {};\n const { translate } = useContext(LanguageContext) || {};\n\n return (\n <div className=\"App w-screen h-[100vh] relative common-ui-main\" data-testid=\"camera-scan\" data-scan-phase={faceDone ? \"spinning\" : recordingStarted ? \"pose-detecting\" : isScanning ? \"starting\" : \"ready\"}>\n <span\n onClick={() => {\n resetScan();\n resetDetector();\n }}\n className=\"fixed right-[20px] top-[20px] z-[999]\"\n >\n <X className=\"text-[#fff]\" />\n </span>\n\n <div className=\"w-full h-full overflow-hidden \">\n {media === MEDIA_TYPES.MOBILE && (\n <Webcam\n key={webcamKey}\n audio={false}\n ref={webcamRef}\n screenshotQuality={1}\n videoConstraints={videoConstraints}\n mirrored\n screenshotFormat=\"image/jpeg\"\n onUserMedia={onUserMedia}\n onUserMediaError={onUserMediaError}\n style={{\n position: \"fixed\",\n top: 0,\n bottom: 0,\n zIndex: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n }}\n />\n )}\n </div>\n\n <div className=\"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center\">\n {showPause && (\n <SpecificButton\n className=\"!w-[180px] !h-[40px] !py-[0] mx-auto \"\n prefix={pauseIcon}\n buttonText={translate?.(LanguageKeys.pause)}\n buttonFunc={onPause}\n btnSecondary\n />\n )}\n\n {pause ? (\n <div>\n <SpecificButton\n className=\"!w-[180px] !h-[40px] !py-[0] mx-auto\"\n buttonText={translate?.(LanguageKeys.restart)}\n buttonFunc={onReScan}\n btnSecondary\n />\n </div>\n ) : !recordingStarted ? (\n <SpecificButton\n data-testid=\"start-scan-btn\"\n className={`!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] ${\n loadingCam ? \"!opacity-50\" : \"\"\n }`}\n buttonText={translate?.(LanguageKeys.startScan)}\n buttonFunc={startSendingVideoFrames}\n disabled={loadingCam}\n />\n ) : null}\n </div>\n\n <audio\n id=\"audioElement\"\n crossOrigin=\"anonymous\"\n preload=\"auto\"\n style={{\n position: \"absolute\",\n zIndex: -99999,\n }}\n src={`${voiceOverAssetsPath}scanAudioInstructions/silence.mp3`}\n />\n </div>\n );\n}\n\nexport default CameraScanChild;\n","import { useState, useRef, useEffect } from \"react\";\n// We keep this, but we will make it optional in the logic below\n\ntype KeypointTuple = [number, number, number];\n\n// GLOBAL SINGLETONS (Persist across component re-mounts)\n// This prevents reloading the heavy model if the user navigates away and back.\nlet globalLoadingPromise: Promise<boolean> | null = null;\nlet globalDetector: any = null;\nlet globalPoseLib: any = null;\n\nexport default function useTensorFlow() {\n const [consecutiveFronts, setConsecutiveFronts] = useState(0);\n const [spinPhase, setSpinPhase] = useState(0);\n const [isLoaded, setIsLoaded] = useState(false);\n\n const spinPhaseRef = useRef(0);\n const consecutiveFrontsRef = useRef(0);\n const mounted = useRef(true);\n\n useEffect(() => {\n mounted.current = true; // Reset on mount\n\n // 1. If already loaded globally, just use it.\n if (globalDetector) {\n setIsLoaded(true);\n return;\n }\n\n // 2. If not loading, start the process.\n if (!globalLoadingPromise) {\n globalLoadingPromise = loadDependenciesGlobal();\n }\n\n // 3. Wait for the global promise to resolve.\n globalLoadingPromise.then((success) => {\n if (success && mounted.current) {\n setIsLoaded(true);\n }\n });\n\n return () => {\n mounted.current = false;\n };\n }, []);\n\n /**\n * Loads TensorFlow/MediaPipe dynamically.\n * This logic is ISOLATED from the server.\n */\n async function loadDependenciesGlobal(): Promise<boolean> {\n // GUARDRAIL 1: Strict Environment Check\n // Ensure we are in a browser environment with media capabilities\n if (\n typeof window === 'undefined' || \n typeof navigator === 'undefined'\n ) {\n return false;\n }\n \n try {\n console.log(\"Starting TensorFlow preload...\");\n \n // GUARDRAIL 2: Dynamic Imports\n // These heavy modules are only fetched by the browser, never the server.\n const [poseLib, tfjsCore, tfjsBackend] = await Promise.all([\n import(\"@tensorflow-models/pose-detection\"),\n import(\"@tensorflow/tfjs-core\"),\n import(\"@tensorflow/tfjs-backend-webgl\") // Triggers backend registration side-effect\n ]);\n \n globalPoseLib = poseLib;\n \n // Explicitly set the backend to WebGL for performance\n await tfjsCore.setBackend('webgl');\n await tfjsCore.ready();\n console.log(\"TensorFlow backend ready (WebGL)\");\n\n // GUARDRAIL 3: Zero-Config Asset Loading\n // If TENSORFLOW_SOLUTION_PATH fails or is missing, we must fallback \n // to a CDN so the user doesn't have to copy files manually.\n const modelConfig = {\n runtime: \"mediapipe\",\n modelType: \"full\",\n solutionPath:\"https://cdn.jsdelivr.net/npm/@mediapipe/pose\", // Fallback for Zero Config\n } as const;\n\n try {\n globalDetector = await globalPoseLib.createDetector(\n globalPoseLib.SupportedModels.BlazePose,\n modelConfig\n );\n console.log(\"MediaPipe detector created successfully\");\n } catch (mediapipeError) {\n console.warn(\"MediaPipe failed, falling back to TFJS runtime:\", mediapipeError);\n \n // Fallback to TFJS runtime (slower but works without external assets)\n globalDetector = await globalPoseLib.createDetector(\n globalPoseLib.SupportedModels.BlazePose,\n {\n runtime: \"tfjs\",\n modelType: \"full\",\n }\n );\n console.log(\"TFJS detector created successfully\");\n }\n \n return true;\n } catch (error) {\n console.error(\"Failed to load TensorFlow dependencies:\", error);\n globalLoadingPromise = null; // Reset so retry is possible\n return false;\n }\n }\n\n function isFrontFrame(body: KeypointTuple[]) {\n // Guardrail: Ensure points exist before filtering\n if (!body || body.length === 0) return false;\n return body.filter((p) => p[2] > 0.7).length === 22;\n }\n\n const poseDetector = async (callback: () => void, webcamRef: any) => {\n // GUARDRAIL 4: Runtime Safety\n // Check if everything is truly ready before calculating\n if (!globalDetector || !mounted.current || !webcamRef?.current?.video) {\n return;\n }\n \n // Check if video is actually playing and has data\n const video = webcamRef.current.video;\n if (video.readyState < 2) return; \n\n try {\n const poses = await globalDetector.estimatePoses(\n video,\n { flipHorizontal: false }\n );\n\n if (!poses || !poses.length) return;\n\n const keypoints = poses[0].keypoints;\n \n // Standardize keypoints\n const body: KeypointTuple[] = keypoints\n .slice(11) // Ignore face keypoints (0-10)\n .map((kp: any) => [\n kp.x > 0 && kp.x < 720 ? kp.x : -1,\n kp.y > 0 && kp.y < 1280 ? kp.y : -1,\n kp.score ?? 0,\n ]);\n\n if (spinPhaseRef.current === 0 && !isFrontFrame(body)) {\n setConsecutiveFronts((prev) => prev + 1);\n }\n\n if (spinPhaseRef.current === 1 && isFrontFrame(body)) {\n setConsecutiveFronts((prev) => prev + 1);\n }\n\n if (spinPhaseRef.current === 2) callback();\n } catch (err) {\n console.error(\"Pose detection error:\", err);\n }\n };\n\n useEffect(() => {\n consecutiveFrontsRef.current = consecutiveFronts;\n if (consecutiveFronts > 6 && spinPhaseRef.current < 2) {\n setSpinPhase((s) => s + 1);\n setConsecutiveFronts(0);\n }\n }, [consecutiveFronts]);\n\n useEffect(() => {\n spinPhaseRef.current = spinPhase;\n }, [spinPhase]);\n\n const resetDetector = () => {\n spinPhaseRef.current = 0;\n consecutiveFrontsRef.current = 0;\n setConsecutiveFronts(0);\n setSpinPhase(0);\n };\n\n const retryLoading = async () => {\n if (!globalDetector && !globalLoadingPromise) {\n globalLoadingPromise = loadDependenciesGlobal();\n const success = await globalLoadingPromise;\n if (success && mounted.current) {\n setIsLoaded(true);\n }\n }\n };\n\n return { \n poseDetector, \n isLoaded,\n spinPhase,\n resetDetector,\n retryLoading\n };\n}","/* eslint-disable no-use-before-define */\nimport React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport CameraScanChild from \"./CameraScanChild\";\nimport posthog from \"../../utils/posthog\";\nimport Webcam from \"react-webcam\";\nimport { ScanningComponentProps } from \"../../types/interfaces\";\nimport useTensorFlow from \"../../customHooks/useTensorFlow\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport {\n\tgenerateUuid,\n\tgetCurrentTimeInSeconds,\n\tgetPreferredMediaRecorderTypes,\n\tgetRecordingExtension,\n\tgetRecordingMimeType,\n\tgetSupportedMediaRecorderTypes,\n\thandleScanTimeCapture,\n\trescanSupportCaptureEvent,\n} from \"../../utils/utils\";\nimport speechService from \"../../utils/service/speechService\";\nimport { videoConstraintsExact, videoConstraintsFallback, videoTypes, voiceOverAssetsPath } from \"../../utils/constants\";\n\nlet audioTimeoutId: ReturnType<typeof setTimeout> | undefined;\nlet lastVideoPlayed: {\n\tskipCount: number;\n\tno_of_times_skipped: number;\n\taudioName: string;\n} | null = null;\n\nfunction ScanningComponent({ setIsScanLocked, resetDetector, scanID, setIsVideoUploaded, setScanFailsError, setScanStartTime, setScanUniqueKey, userDetails }: Omit<ScanningComponentProps, \"config\">) {\n\tconst { email, shopDomain, gender, heightInCm } = userDetails;\n\tconst webcamRef = useRef<Webcam | null>(null);\n\tconst mediaRecorderRef = useRef<MediaRecorder | null>(null);\n\tconst recordedFpsRef = useRef<number | null>(null);\n\tconst [recordedChunks, setRecordedChunks] = useState<Blob[]>([]);\n\tconst [loadingCam, setLoadingCam] = useState(true);\n\tconst [recordingStarted, setRecordingStarted] = useState(false);\n\tconst [faceDone, setFaceDone] = useState(false);\n\tconst [mediaRecorderStopped, setMediaRecorderStopped] = useState(true);\n\tconst [isScanning, setIsScanning] = useState(false);\n\tconst captureVideoTimeOutHandle = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst [audioSource, setAudioSource] = useState(\"\");\n\tconst [audioSourceList, setAudioSourceList] = useState<string[]>([]);\n\tconst [emptyAudioSource, setEmptyAudioSource] = useState(\"\");\n\tconst [startAgain, setStartAgain] = useState(false);\n\tconst [showRestart, setRestart] = useState(false);\n\tconst [pause, setPause] = useState(false);\n\tconst [events, setEvents] = useState<any>([]);\n\tconst [showPause, setShowPause] = useState(false);\n\tconst allowAudioToPlay = useRef(true);\n\tconst { poseDetector } = useTensorFlow();\n\tconst firstScan = useRef(true);\n\tconst poseStoppedRef = useRef(false);\n\tconst counterRef = useRef(0);\n\tconst consecutiveFalseRef = useRef(0);\n\tconst poseListenerRegistered = useRef(false);\n\tconst isConnectingRef = useRef(false);\n\tconst brilliantPlayedRef = useRef(false);\n\tconst postPoseProcessRef = useRef<() => void>(() => {});\n\tconst startSendingVideoFramesRef = useRef<() => void>(() => {});\n\tconst idRef = useRef<string | null>(null);\n\tconst [supportedTypes, setSupportedTypes] = useState<string[]>([]);\n\tconst [webcamKey, setWebcamKey] = useState(0);\n\tconst [currentVideoConstraints, setCurrentVideoConstraints] = useState<MediaTrackConstraints>(videoConstraintsExact);\n\tconst { setStartGyro, uploadScanFile, setUploadLoading, swan, onScanStart, onCaptureComplete } = useContext(ParamsContext);\n\n\t// Refs to avoid stale closures in callbacks after pause/restart\n\tconst scanIDRef = useRef(scanID);\n\tuseEffect(() => {\n\t\tscanIDRef.current = scanID;\n\t}, [scanID]);\n\n\tconst eventsRef = useRef(events);\n\tuseEffect(() => {\n\t\teventsRef.current = events;\n\t}, [events]);\n\n\tconst resetScan = () => {\n\t\tposeStoppedRef.current = false;\n\t\tclearTimeout(audioTimeoutId);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tsetScanUniqueKey(generateUuid());\n\t\tsetScanFailsError(\"\");\n\t\tsetUploadLoading?.(false);\n\t\tsetRecordedChunks([]);\n\t\trecordedFpsRef.current = null;\n\t\tsetLoadingCam(true);\n\t\tsetRecordingStarted(false);\n\t\tsetFaceDone(false);\n\t\tsetMediaRecorderStopped(true);\n\t\tsetIsScanning(false);\n\t\tcaptureVideoTimeOutHandle.current = null;\n\t\tsetAudioSource(\"\");\n\t\tsetAudioSourceList([]);\n\t\tsetEmptyAudioSource(\"\");\n\t\tsetStartAgain(!startAgain);\n\t\tsetStartGyro(false);\n\t\tspeechService.stopAudio();\n\t\tsetRestart(false);\n\t\tsetPause(false);\n\t\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tbrilliantPlayedRef.current = false;\n\t\tif (mediaRecorderRef.current !== null) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\n\t\tsetEvents([]);\n\t\tallowAudioToPlay.current = true;\n\t\tsetShowPause(false);\n\t\tsetIsVideoUploaded(false);\n\t\tif (webcamRef.current?.stream) {\n\t\t\tsetLoadingCam(false);\n\t\t}\n\t};\n\n\tconst handleRestart = async () => {\n\t\trescanSupportCaptureEvent({\n\t\t\teventName: `${shopDomain}/rescan`,\n\t\t\temail,\n\t\t\tscanID: scanIDRef.current,\n\t\t\theight: heightInCm,\n\t\t\tgender,\n\t\t\tstatus: false,\n\t\t});\n\t\tswan.poseDetection.disconnect();\n\t\tresetScan();\n\t\tawait handleSocket();\n\t};\n\n\tconst handleUserMedia = useCallback(() => {\n\t\tsetTimeout(() => {\n\t\t\tsetLoadingCam(false);\n\t\t}, 1000);\n\t}, []);\n\n\tconst handleUserMediaError = useCallback(\n\t\t(error: string | DOMException) => {\n\t\t\tconsole.log(\"camera error\", error);\n\t\t\t// Retry once with relaxed constraints for broader device compatibility.\n\t\t\tif (currentVideoConstraints === videoConstraintsExact) {\n\t\t\t\tsetCurrentVideoConstraints(videoConstraintsFallback);\n\t\t\t\tsetWebcamKey((prev) => prev + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetLoadingCam(false);\n\t\t},\n\t\t[currentVideoConstraints],\n\t);\n\n\tconst handlePause = useCallback(() => {\n\t\tallowAudioToPlay.current = false;\n\t\tsetPause(true);\n\t\tsetShowPause(false);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tif (mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.pause();\n\t\t}\n\t\tspeechService.stopAudio();\n\t\tswan.poseDetection.disconnect();\n\t\tposthog.capture(`${shopDomain}/pose_detection_disconnected`, {\n\t\t\tscanID: scanID,\n\t\t\temail,\n\t\t\tid: idRef.current,\n\t\t\treason: \"pause\",\n\t\t});\n\t\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tbrilliantPlayedRef.current = false;\n\t\tif (mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\t\tsetEvents([]);\n\t\tclearTimeout(audioTimeoutId);\n\t}, [mediaRecorderRef, events, speechService, allowAudioToPlay]);\n\n\t// const supportedTypes = videoTypes.filter((type) => MediaRecorder.isTypeSupported(type));\n\tconst preferredVideoTypes = useMemo(() => getPreferredMediaRecorderTypes(), []);\n\tconst recordingMimeType = getRecordingMimeType(supportedTypes);\n\tconst recordingExtension = getRecordingExtension(recordingMimeType);\n\n\tconst stopRecording = useCallback(async () => {\n\t\tallowAudioToPlay.current = true;\n\t\tawait speechService.playAudio(`${voiceOverAssetsPath}SpotOn.mp3`);\n\t\tsetPause(false);\n\t\tsetShowPause(false);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tsetRecordingStarted(false);\n\t}, [captureVideoTimeOutHandle, speechService]);\n\n\tconst handleSocket = useCallback(async () => {\n\t\t// Guard against React StrictMode double-mount: skip if already connecting or connected\n\t\tif (isConnectingRef.current || idRef.current) return;\n\t\tisConnectingRef.current = true;\n\t\ttry {\n\t\t\tidRef.current = await swan.poseDetection.connect();\n\n\t\t\tposthog.capture(`${shopDomain}/pose_detection_connected`, {\n\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\temail,\n\t\t\t\tid: idRef.current,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.log(error, \"while connecting websocket\");\n\t\t\tposthog.capture(`${shopDomain}/pose_detection_connect_failed`, {\n\t\t\t\tscanID: scanID,\n\t\t\t\temail,\n\t\t\t\terror: String(error),\n\t\t\t});\n\t\t} finally {\n\t\t\tisConnectingRef.current = false;\n\t\t}\n\t}, [scanID, shopDomain, email]);\n\n\tconst handleReScan = useCallback(async () => {\n\t\trescanSupportCaptureEvent({\n\t\t\teventName: `${shopDomain}/rescan`,\n\t\t\temail,\n\t\t\tscanID: scanID,\n\t\t\theight: heightInCm,\n\t\t\tgender,\n\t\t\tstatus: false,\n\t\t});\n\t\tallowAudioToPlay.current = false;\n\t\tswan.poseDetection.disconnect();\n\t\tposthog.capture(`${shopDomain}/pose_detection_disconnected`, {\n\t\t\tscanID: scanID,\n\t\t\temail,\n\t\t\tid: idRef.current,\n\t\t\treason: \"rescan\",\n\t\t});\n\t\tidRef.current = null; // reset so handleSocket guard allows reconnection\n\t\tresetScan();\n\t\tawait handleSocket();\n\t\tstartSendingVideoFramesRef.current();\n\t}, [handleSocket, scanID, email]);\n\n\tconst handleSpinDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tif (data && data.size > 0 && allowAudioToPlay.current) {\n\t\t\t\tsetRecordedChunks((prev) => prev.concat(data));\n\t\t\t\tif (!poseStoppedRef.current && webcamRef.current) {\n\t\t\t\t\tposeStoppedRef.current = true;\n\t\t\t\t\tposeDetector(() => {\n\t\t\t\t\t\tstopRecording();\n\t\t\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\t\t\teventName: `${shopDomain}/tensorFlow`,\n\t\t\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\tmessage: \"recording stopped by tensorflow \",\n\t\t\t\t\t\t});\n\t\t\t\t\t}, webcamRef);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[stopRecording, handleScanTimeCapture, shopDomain, email, webcamRef],\n\t);\n\n\tconst playAudio = useCallback(async () => {\n\t\tconst lastAudio = audioSourceList[audioSourceList.length - 1];\n\t\tif (lastAudio && allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(voiceOverAssetsPath + lastAudio);\n\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\taudioTimeoutId = setTimeout(playAudio, 2000);\n\t\t\t}\n\t\t}\n\t}, [audioSourceList, allowAudioToPlay]);\n\n\tconst handleStartCaptureClick = useCallback(() => {\n\t\tif (mediaRecorderRef && mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\t\tsetRecordingStarted(true);\n\t\ttry {\n\t\t\tif (webcamRef && webcamRef.current && webcamRef.current.stream) {\n\t\t\t\t// Capture FPS from stream settings\n\t\t\t\tconst videoTrack = webcamRef.current.stream.getVideoTracks()[0];\n\t\t\t\tif (videoTrack) {\n\t\t\t\t\tconst settings = videoTrack.getSettings();\n\t\t\t\t\trecordedFpsRef.current = settings.frameRate || null;\n\t\t\t\t}\n\n\t\t\t\tconst mediaRecorderOptions: MediaRecorderOptions = {\n\t\t\t\t\tvideoBitsPerSecond: 1_500_000,\n\t\t\t\t};\n\t\t\t\tif (supportedTypes[0]) {\n\t\t\t\t\tmediaRecorderOptions.mimeType = supportedTypes[0];\n\t\t\t\t}\n\t\t\t\tmediaRecorderRef.current = new MediaRecorder(webcamRef.current.stream, mediaRecorderOptions);\n\t\t\t\tmediaRecorderRef.current.addEventListener(\"dataavailable\", handleSpinDataAvailable);\n\n\t\t\t\t// Mark recorder as fully stopped only after all dataavailable events have fired\n\t\t\t\tmediaRecorderRef.current.addEventListener(\"stop\", () => {\n\t\t\t\t\tsetMediaRecorderStopped(true);\n\t\t\t\t});\n\n\t\t\t\tsetEvents([...events, handleSpinDataAvailable]);\n\t\t\t\tmediaRecorderRef.current.start(1000);\n\t\t\t\tsetMediaRecorderStopped(false);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.log(\"error while using media recorder\", e);\n\t\t}\n\t}, [webcamRef, supportedTypes, handleSpinDataAvailable, events]);\n\n\tconst postPoseProcess = useCallback(async () => {\n\t\tif (captureVideoTimeOutHandle.current) {\n\t\t\tclearTimeout(captureVideoTimeOutHandle.current);\n\t\t}\n\t\thandleStartCaptureClick();\n\t\tif (allowAudioToPlay.current) {\n\t\t\tcaptureVideoTimeOutHandle.current = setTimeout(async () => {\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}SpotOn.mp3`);\n\t\t\t\t\tsetRecordingStarted(false);\n\t\t\t\t}\n\t\t\t}, 15000);\n\t\t}\n\t\tsetFaceDone(true);\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}Spin.mp3`);\n\t\t}\n\t}, [handleStartCaptureClick, allowAudioToPlay, speechService]);\n\n\tuseEffect(() => {\n\t\tpostPoseProcessRef.current = postPoseProcess;\n\t}, [postPoseProcess]);\n\n\tconst handleDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tconst connected = swan.poseDetection.connected();\n\t\t\tif (data.size > 0 && connected) {\n\t\t\t\tif (!poseListenerRegistered.current) {\n\t\t\t\t\tposeListenerRegistered.current = true;\n\t\t\t\t\tswan.poseDetection.poseStatus(async (data: any) => {\n\t\t\t\t\t\tif (data && data.audio && data.audio.length > 0) {\n\t\t\t\t\t\t\tconst audio = document.querySelector(\"#audioElement\") as HTMLAudioElement | null;\n\n\t\t\t\t\t\t\tposthog.capture(`${shopDomain}/pose_instruction_received`, {\n\t\t\t\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\t\taudio: data.audio,\n\t\t\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\t\t\tsid: data.sid,\n\t\t\t\t\t\t\t\tcounter: counterRef.current,\n\t\t\t\t\t\t\t\tconsecutiveFalse: consecutiveFalseRef.current,\n\t\t\t\t\t\t\t\ttype: \"body_scan_instruction\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (data.status === true && data.sid === idRef.current) {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current = 0;\n\t\t\t\t\t\t\t\tif (counterRef.current < 2) {\n\t\t\t\t\t\t\t\t\tcounterRef.current += 1;\n\t\t\t\t\t\t\t\t\tif (counterRef.current === 1 && !brilliantPlayedRef.current) {\n\t\t\t\t\t\t\t\t\t\tbrilliantPlayedRef.current = true;\n\t\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\t\tspeechService.stopAudio();\n\t\t\t\t\t\t\t\t\t\tawait speechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t} else if (counterRef.current === 2 && audio?.paused) {\n\t\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetEmptyAudioSource(data.audio);\n\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\t\t\t\t\t\tposthog.capture(`${shopDomain}/pose_detection_disconnected`, {\n\t\t\t\t\t\t\t\t\t\tscanID: scanID,\n\t\t\t\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\t\t\t\tid: idRef.current,\n\t\t\t\t\t\t\t\t\t\treason: \"pose_confirmed\",\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tposeListenerRegistered.current = false;\n\t\t\t\t\t\t\t\t\tsetTimeout(() => postPoseProcessRef.current(), 1000);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current += 1;\n\t\t\t\t\t\t\t\tif (consecutiveFalseRef.current >= 3) {\n\t\t\t\t\t\t\t\t\tcounterRef.current = 0;\n\t\t\t\t\t\t\t\t\tbrilliantPlayedRef.current = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (audio?.paused && (!lastVideoPlayed || lastVideoPlayed?.audioName !== data.audio)) {\n\t\t\t\t\t\t\t\t\tlastVideoPlayed = {\n\t\t\t\t\t\t\t\t\t\tskipCount: 2,\n\t\t\t\t\t\t\t\t\t\tno_of_times_skipped: 0,\n\t\t\t\t\t\t\t\t\t\taudioName: data.audio,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t} else if (lastVideoPlayed?.audioName === data.audio && audio?.paused) {\n\t\t\t\t\t\t\t\t\tif (lastVideoPlayed && lastVideoPlayed.no_of_times_skipped >= lastVideoPlayed.skipCount) {\n\t\t\t\t\t\t\t\t\t\tlastVideoPlayed.no_of_times_skipped = 0;\n\t\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tif (lastVideoPlayed) lastVideoPlayed.no_of_times_skipped += 1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (webcamRef?.current && webcamRef.current.getScreenshot() !== null) {\n\t\t\t\t\tconsole.log(\"[videoEmit] sending frame with scanId:\", scanIDRef.current);\n\t\t\t\t\tswan.poseDetection.videoEmit({\n\t\t\t\t\t\timage: webcamRef.current.getScreenshot() || \"\",\n\t\t\t\t\t\tscanId: scanIDRef.current,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[webcamRef, scanID, swan, speechService, shopDomain, email],\n\t);\n\n\tconst startSendingVideoFrames = useCallback(async () => {\n\t\tsetIsScanning(true);\n\t\tsetStartGyro(true);\n\t\tonScanStart?.();\n\t\tif (firstScan.current) {\n\t\t\tfirstScan.current = false;\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: \"scan started\",\n\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t}\n\t\tsetScanStartTime(getCurrentTimeInSeconds());\n\t\tsetLoadingCam(true);\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}StartScan.mp3`);\n\t\t}\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`);\n\t\t}\n\t\tif (allowAudioToPlay.current) {\n\t\t\tsetIsScanning(false);\n\t\t\tsetRecordingStarted(true);\n\t\t\tsetRestart(true);\n\t\t\tsetShowPause(true);\n\t\t\thandleUserMedia();\n\t\t}\n\t\ttry {\n\t\t\tif (webcamRef && webcamRef.current && webcamRef.current.stream && allowAudioToPlay.current) {\n\t\t\t\t// Capture FPS from stream settings\n\t\t\t\tconst videoTrack = webcamRef.current.stream.getVideoTracks()[0];\n\t\t\t\tif (videoTrack) {\n\t\t\t\t\tconst settings = videoTrack.getSettings();\n\t\t\t\t\trecordedFpsRef.current = settings.frameRate || null;\n\t\t\t\t}\n\n\t\t\t\tconst mediaRecorderOptions: MediaRecorderOptions = {\n\t\t\t\t\tvideoBitsPerSecond: 1_500_000,\n\t\t\t\t};\n\t\t\t\tif (supportedTypes[0]) {\n\t\t\t\t\tmediaRecorderOptions.mimeType = supportedTypes[0];\n\t\t\t\t}\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\tmediaRecorderRef.current = new MediaRecorder(webcamRef.current.stream, mediaRecorderOptions);\n\t\t\t\t}\n\t\t\t\tif (allowAudioToPlay.current && mediaRecorderRef.current) {\n\t\t\t\t\tmediaRecorderRef.current.addEventListener(\"dataavailable\", handleDataAvailable);\n\t\t\t\t}\n\n\t\t\t\tsetEvents([...eventsRef.current, handleDataAvailable]);\n\t\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.start(1000);\n\t\t\t\tsetMediaRecorderStopped(false);\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\taudioTimeoutId = setTimeout(playAudio, 2000);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.log(\"error ----------\", err);\n\t\t}\n\t}, [webcamRef, supportedTypes, handleDataAvailable, playAudio, allowAudioToPlay, onScanStart]);\n\n\tuseEffect(() => {\n\t\tstartSendingVideoFramesRef.current = startSendingVideoFrames;\n\t}, [startSendingVideoFrames]);\n\n\tuseEffect(() => {\n\t\tif (shopDomain) {\n\t\t\tsetIsScanLocked(true);\n\t\t\thandleSocket();\n\t\t}\n\t\treturn () => {\n\t\t\t// Capture then reset id so next genuine mount can reconnect.\n\t\t\t// Do NOT reset isConnectingRef here — keeping it true blocks the\n\t\t\t// StrictMode second-mount call while the first connect is still awaiting.\n\t\t\tconst prevId = idRef.current;\n\t\t\tidRef.current = null;\n\t\t\tif (prevId) {\n\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\tposthog.capture(`${shopDomain}/pose_detection_disconnected`, {\n\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\temail,\n\t\t\t\t\tid: prevId,\n\t\t\t\t\treason: \"unmount\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tevents.forEach((el: any) => {\n\t\t\t\tmediaRecorderRef?.current?.removeEventListener(\"dataavailable\", el);\n\t\t\t});\n\t\t};\n\t}, [shopDomain]);\n\tuseEffect(() => {\n\t\taudioSourceList.push(audioSource);\n\t}, [audioSource]);\n\n\tuseEffect(() => {\n\t\tsetAudioSourceList([]);\n\t}, [emptyAudioSource]);\n\tuseEffect(() => {\n\t\tconst bypassChecksToBackup = recordedChunks.length && recordedChunks.length > 0;\n\t\tif (!mediaRecorderStopped && bypassChecksToBackup && !recordingStarted && allowAudioToPlay.current && !pause) {\n\t\t\tif (mediaRecorderRef && mediaRecorderRef.current) {\n\t\t\t\tif (!recordingStarted) {\n\t\t\t\t\tmediaRecorderRef.current.stop();\n\t\t\t\t\t// mediaRecorderStopped will be set by the \"stop\" event listener\n\t\t\t\t\t// which fires AFTER all dataavailable events are done\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [mediaRecorderStopped, recordingStarted, recordedChunks, pause]);\n\n\tuseEffect(() => {\n\t\tconst bypassChecksToBackup = recordedChunks.length && recordedChunks.length > 0;\n\t\tif (mediaRecorderStopped && bypassChecksToBackup && !recordingStarted) {\n\t\t\tif (mediaRecorderRef && mediaRecorderRef.current && allowAudioToPlay.current && !pause) {\n\t\t\t\tif (!recordingStarted) {\n\t\t\t\t\tconst videoFile = new File(recordedChunks, `${scanID}.${recordingExtension}`, {\n\t\t\t\t\t\ttype: recordingMimeType,\n\t\t\t\t\t});\n\t\t\t\t\tonCaptureComplete?.();\n\t\t\t\t\tsetUploadLoading?.(true);\n\t\t\t\t\tsetScanFailsError(\"\");\n\t\t\t\t\t// Pass FPS captured at recording time\n\t\t\t\t\tuploadScanFile?.(videoFile, recordedFpsRef.current);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [mediaRecorderStopped, recordingStarted, recordedChunks, pause, mediaRecorderRef, allowAudioToPlay]);\n\tuseEffect(() => {\n\t\tstartSendingVideoFramesRef.current = startSendingVideoFrames;\n\t}, [startSendingVideoFrames]);\n\n\tuseEffect(() => {\n\t\tconst supported = getSupportedMediaRecorderTypes(preferredVideoTypes, videoTypes);\n\t\tsetSupportedTypes(supported);\n\t}, [preferredVideoTypes]);\n\tuseEffect(() => {\n\t\tresetScan();\n\t}, []);\n\n\treturn (\n\t\t<CameraScanChild\n\t\t\tresetDetector={resetDetector}\n\t\t\tresetScan={resetScan}\n\t\t\tloadingCam={loadingCam}\n\t\t\tonPause={handlePause}\n\t\t\tshowRestart={showRestart}\n\t\t\tpause={pause}\n\t\t\tonReScan={handleRestart}\n\t\t\trecordingStarted={recordingStarted}\n\t\t\tisScanning={isScanning}\n\t\t\tstartSendingVideoFrames={startSendingVideoFrames}\n\t\t\tfaceDone={faceDone}\n\t\t\tstopRecording={stopRecording}\n\t\t\tshowPause={showPause}\n\t\t\twebcamRef={webcamRef}\n\t\t\tonUserMedia={handleUserMedia}\n\t\t\tonUserMediaError={handleUserMediaError}\n\t\t\tvideoConstraints={currentVideoConstraints}\n\t\t\twebcamKey={webcamKey}\n\t\t/>\n\t);\n}\n\nexport default React.memo(ScanningComponent);\n","/* eslint-disable no-use-before-define */\n\nimport { useEffect, useState, useRef } from \"react\";\nimport { IOSDeviceOrientationEvent } from \"../../customHooks/useGyroSensor\";\nimport LevelScreen from \"./LevelScreen\";\nimport ScanningComponent from \"./ScanningComponent\";\nimport { AngleDetectorProps } from \"../../types/interfaces\";\n\nexport default function AngleDetector({\n scanID,\n userDetails,\n setIsVideoUploaded,\n setScanFailsError,\n setScanStartTime,\n setScanUniqueKey,\n}: Omit<AngleDetectorProps, \"config\">) {\n const [angle, setAngle] = useState(90);\n const [calibrationOffset, setCalibrationOffset] = useState(0);\n const [countdown, setCountdown] = useState<number | null>(null);\n const [isScanning, setIsScanning] = useState(false);\n const [stabilityScore, setStabilityScore] = useState(0);\n const lastAnglesRef = useRef<number[]>([]);\n const [isScanLocked, setIsScanLocked] = useState(false);\n const calibratedAngle = angle - calibrationOffset;\n const isInTargetRange = calibratedAngle >= 80 && calibratedAngle <= 95;\n\n const resetDetector = () => {\n setAngle(90);\n setCalibrationOffset(0);\n setCountdown(null);\n setIsScanning(false);\n setStabilityScore(0);\n setIsScanLocked(false);\n lastAnglesRef.current = [];\n };\n\n useEffect(() => {\n if (typeof window !== \"undefined\" && window.DeviceOrientationEvent) {\n const handleOrientation = (event: DeviceOrientationEvent) => {\n if (event.beta !== null) {\n let newAngle = Math.abs(event.beta);\n if (event.gamma !== null) {\n newAngle *= Math.cos((event.gamma * Math.PI) / 180);\n }\n newAngle = Math.max(0, Math.min(180, newAngle));\n setAngle(newAngle);\n }\n };\n\n const requestPermission = async () => {\n const DeviceOrientation =\n DeviceOrientationEvent as unknown as IOSDeviceOrientationEvent;\n\n if (\n DeviceOrientation &&\n typeof DeviceOrientation.requestPermission === \"function\"\n ) {\n try {\n const permission = await DeviceOrientation.requestPermission();\n if (permission === \"granted\") {\n // wrappedHandler = timeout(handleOrientation, 2000);\n window.addEventListener(\"deviceorientation\", handleOrientation);\n }\n } catch (e) {\n console.error(\"Permission error\", e);\n }\n } else {\n // wrappedHandler = handleOrientation;\n window.addEventListener(\"deviceorientation\", handleOrientation);\n }\n\n return () => {\n if (handleOrientation) {\n window.removeEventListener(\"deviceorientation\", handleOrientation);\n }\n };\n };\n\n document.addEventListener(\"click\", requestPermission, { once: true });\n }\n }, []);\n\n useEffect(() => {\n lastAnglesRef.current = [\n ...lastAnglesRef.current.slice(-4),\n calibratedAngle,\n ];\n\n if (lastAnglesRef.current.length >= 5) {\n const variation =\n Math.max(...lastAnglesRef.current) - Math.min(...lastAnglesRef.current);\n if (isInTargetRange && variation < 2) {\n setStabilityScore((prev) => Math.min(100, prev + 10));\n } else {\n setStabilityScore((prev) => Math.max(0, prev - 20));\n }\n }\n\n if (!isInTargetRange && (countdown !== null || isScanning)) {\n resetCountdown();\n }\n }, [calibratedAngle, isInTargetRange, countdown, isScanning]);\n\n\tuseEffect(() => {\n\t\tif (stabilityScore >= 100 && countdown === null && !isScanning ) {\n\t\t\tstartCountdown();\n\t\t}\n\t\tif (stabilityScore < 50 && countdown !== null) {\n\t\t\tresetCountdown();\n\t\t}\n\t}, [stabilityScore, countdown, isScanning]);\n\n const startCountdown = () => {\n setCountdown(3);\n const timer = setInterval(() => {\n setCountdown((prev) => {\n if (prev === null || prev <= 1) {\n clearInterval(timer);\n setIsScanning(true);\n return null;\n }\n return prev - 1;\n });\n }, 1000);\n };\n\n const resetCountdown = () => {\n setCountdown(null);\n if (!isScanLocked) {\n setIsScanning(false);\n }\n };\n\n\n return (\n <LevelScreen\n angle={calibratedAngle}\n countdown={countdown}\n isScanning={isScanning}\n isInTargetRange={isInTargetRange}\n stabilityScore={stabilityScore}\n >\n {isScanning && (\n <ScanningComponent\n setIsScanLocked={setIsScanLocked}\n resetDetector={resetDetector}\n scanID={scanID}\n userDetails={userDetails}\n setIsVideoUploaded={setIsVideoUploaded}\n setScanFailsError={setScanFailsError}\n setScanStartTime={setScanStartTime}\n setScanUniqueKey={setScanUniqueKey}\n />\n )}\n </LevelScreen>\n );\n}\n","import { useEffect, useState, useRef, useCallback, Dispatch, SetStateAction } from \"react\";\nimport Webcam from \"react-webcam\";\nimport Modal from \"../Modal\";\nimport LoadingScreen from \"../LoadingScreen\";\nimport { checkCameraPermission } from \"../../utils/utils\";\nimport { videoConstraints } from \"../../utils/constants\";\n\n\nfunction CameraPermission({ setShowDrawer, config,loader }: { setShowDrawer?: Dispatch<SetStateAction<boolean>>; config?: any,loader?:string }) {\n\tconst [showDeniedModal, setShowDeniedModal] = useState({\n\t\tdisabled: false,\n\t\tmessage: \"\",\n\t});\n\tconst [loading, setLoading] = useState(true);\n\tconst webcamRef = useRef(null);\n\n\tconst handleCameraPermission = useCallback(async () => {\n\t\tconst permission = await checkCameraPermission();\n\t\tsetShowDeniedModal(permission);\n\t\tsetLoading(false);\n\t}, []);\n\n\tuseEffect(() => {\n\t\thandleCameraPermission();\n\t}, []);\n\n\tif (loading) {\n\t\treturn <LoadingScreen url={loader} loaderType=\"black\" />\n\t}\n\n\tif (showDeniedModal?.disabled) {\n\t\treturn <Modal config={config} message={showDeniedModal?.message} />;\n\t}\n\treturn (\n\t\t<Webcam\n\t\t\taudio={false}\n\t\t\tref={webcamRef}\n\t\t\tscreenshotQuality={1}\n\t\t\tvideoConstraints={videoConstraints}\n\t\t\tmirrored\n\t\t\tonUserMedia={() => setShowDrawer?.(true)}\n\t\t\tscreenshotFormat=\"image/jpeg\"\n\t\t\tstyle={{\n\t\t\t\tposition: \"relative\",\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tzIndex: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100%\",\n\t\t\t\tobjectFit: \"cover\",\n\t\t\t}}\n\t\t/>\n\t);\n}\n\nexport default CameraPermission;\n","\nimport React, { useEffect, useRef } from \"react\";\nimport videojs from \"video.js\";\nimport type Player from \"video.js/dist/types/player\";\nimport { videoPoster } from \"../../utils/constants\";\n\nfunction VideoPlayer({ link, onReady, wrapperClassName = \"[&_video]:rounded-t-[20px] w-full h-full\" }: { link?: string; wrapperClassName?: string; onReady?: (args: Player) => void }) {\n\tconst videoReference = useRef<HTMLVideoElement | null>(null);\n\tconst playerReference = useRef<Player | null>(null);\n\n\tlet videoJsOptions: any = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tresponsive: true,\n\t\tfluid: true,\n\t\tmuted: true,\n\t\tnavigationUI: \"hide\",\n\t\tpreload: \"metadata\",\n\t\tposter: videoPoster,\n\t};\n\n\tuseEffect(() => {\n\t\tif (!playerReference.current && link && videoReference?.current) {\n\t\t\tconst player = videojs(videoReference.current, {\n\t\t\t\t...videoJsOptions,\n\t\t\t});\n\t\t\tplayer.ready(() => {\n\t\t\t\tplayerReference.current = player;\n\n\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t...videoJsOptions,\n\t\t\t\t\tsources: [{ src: link, type: \"application/x-mpegURL\" }],\n\t\t\t\t};\n\n\t\t\t\tplayer.autoplay(updatedOptions.autoplay);\n\t\t\t\tplayer.src(updatedOptions.sources);\n\n\t\t\t\tonReady?.(player);\n\t\t\t});\n\t\t}\n\t}, [link, videoReference]);\n\n\tuseEffect(() => {\n\t\tconst player = playerReference.current;\n\t\treturn () => {\n\t\t\tif (player && !player.isDisposed()) {\n\t\t\t\tplayer.dispose();\n\t\t\t\tplayerReference.current = null;\n\t\t\t}\n\t\t};\n\t}, [playerReference]);\n\n\treturn (\n\t\t<div className={wrapperClassName}>\n\t\t\t<video ref={videoReference} muted className=\"video-js\" playsInline onDrag={(e) => e.preventDefault()} />\n\t\t</div>\n\t);\n}\nexport default VideoPlayer;\n","import { useContext, useState } from \"react\";\nimport {Dialog} from \"@mui/material\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport Header from \"../Header\";\nimport VideoPlayer from \"./VideoPlayer\";\nimport { ScanErrorMessageProps } from \"../../types/interfaces\";\nimport { generateUuid, handleErrorMessage } from \"../../utils/utils\";\nimport { GENDER, VIDEO_POSTER_GENDER_BASED } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\nimport { useConfig } from \"../../utils/context/configContext\";\n\nfunction ScanErrorMessage({ scanFailsError, onNext, gender, setScanUniqueKey, setIsVideoUploaded }: ScanErrorMessageProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\tconst resolvedConfig = useConfig();\n\tconst [showModal, setShowModal] = useState(false);\n\n\tconst handleBtnClick = () => {\n\t\tif (onNext) {\n\t\t\tonNext?.();\n\t\t} else {\n\t\t\tsetScanUniqueKey?.(generateUuid());\n\t\t}\n\t\tsetIsVideoUploaded?.(false);\n\t};\n\n\tconst handleShowModal = () => {\n\t\tsetShowModal(!showModal);\n\t};\n\n\n\treturn (\n\t\t<>\n\t\t\t<div data-testid=\"scan-error-message\" className=\"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto\" style={{ background: resolvedConfig?.style?.base?.backgroundColor }}>\n\t\t\t\t<div className=\"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]\">\n\t\t\t\t\t<Header noTitle />\n\t\t\t\t</div>\n\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t{scanFailsError && (\n\t\t\t\t\t\t<div className=\"px-[1rem]\">\n\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\tclassName=\"text-center\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.heading?.headingFontFamily || \"SeriouslyNostalgic Fn\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.heading?.headingFontSize || \"32px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.heading?.headingColor || \"#000\",\n\t\t\t\t\t\t\t\t\tfontWeight: resolvedConfig?.style?.heading?.headingFontWeight || \"normal\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.issueWithScan)}\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.reason)}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{handleErrorMessage(scanFailsError)}\n\t\t\t\t\t\t\t</p>\n\n\t\t\t\t\t\t\t<img className=\"my-[0.5rem] aspect-[2/1.4] w-full object-cover\" onClick={handleShowModal} src={VIDEO_POSTER_GENDER_BASED[gender]} alt=\"icon\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{scanFailsError && (\n\t\t\t\t\t<div className=\"p-[1rem] flex gap-[0.5rem]\">\n\t\t\t\t\t\t<SpecificButton data-testid=\"scan-again-btn\" disabled={false} buttonText={translate?.(LanguageKeys.scanAgain)} className=\"!shadow-none\" buttonFunc={handleBtnClick} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t{showModal && (\n\t\t\t\t<Dialog className=\"w-screen h-screen video-modal\" onClose={handleShowModal} open={showModal}>\n\t\t\t\t\t<div className=\"flex justifyEnd \">\n\t\t\t\t\t\t<span className=\"closeBtn\" onClick={handleShowModal}>\n\t\t\t\t\t\t\t<X className=\"absolute right-[8px] top-[8px] text-white z-[9]\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"aspect-video object-cover rounded-[20px] \">\n\t\t\t\t\t\t<VideoPlayer link={gender ? GENDER[gender].PRE_LINK : GENDER.male.PRE_LINK} wrapperClassName=\"w-screen h-screen fixed top-[0] left-[0]\" />\n\t\t\t\t\t</div>\n\t\t\t\t</Dialog>\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport default ScanErrorMessage;\n","import { useCallback, useContext, useEffect, useState } from \"react\";\nimport {Box,Drawer} from \"@mui/material\";\nimport posthog from \"../utils/posthog\";\nimport Header from \"./Header\";\nimport CameraPermission from \"./bodyScan/CameraPermission\";\nimport { SignUpProps } from \"../types/interfaces\";\nimport { CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN, CLOTHING_CUSTOM_SCAN, maleMeasurementProgress, measurementProgress } from \"../utils/constants\";\nimport { GenderType } from \"../utils/enums\";\nimport SpecificButton from \"../atoms/specificButton/SpecificButton\";\nimport { LanguageContext } from \"../utils/context/languageContext\";\nimport { LanguageKeys } from \"../utils/languageKeys\";\n\nfunction SignUp({\n\tscanId,\n\tuserDetails,\n\tconfig,\n\tisVideoUploadedCorrect,\n\tisMeasurementAvailable,\n\tonComplete,\n\tisSuccess,\n\tonCustomScanSuccess,\n\tswan,\n}: SignUpProps) {\n\tconst { gender, shopDomain, heightInCm, deviceFocalLength, userName, email, scanType } = userDetails || {};\n\tconst isCustom = [CLOTHING_CUSTOM_SCAN, CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN].includes(scanType ?? \"\");\n\tconst [showDrawer, setShowDrawer] = useState(true);\n\tconst handlePostHogEvent = () => {\n\t\tposthog.capture(shopDomain??\"\", {\n\t\t\tscanID: scanId,\n\t\t\temail: email,\n\t\t\theight: heightInCm,\n\t\t\tfocalLength: deviceFocalLength,\n\t\t\tclothesFit: \"0\",\n\t\t\tgender: gender,\n\t\t});\n\t};\n\n\tconst handleSignUp = useCallback(async () => {\n\t\ttry {\n\t\t\tif (isCustom) {\n\t\t\t\tawait swan?.auth.addUser({\n\t\t\t\t\tscanId,\n\t\t\t\t\temail,\n\t\t\t\t\tname: userName,\n\t\t\t\t\tgender,\n\t\t\t\t\theight: heightInCm,\n\t\t\t\t});\n\t\t\t\tonCustomScanSuccess?.();\n\t\t\t}\n\t\t\thandlePostHogEvent();\n\t\t} catch (error) {\n\t\t\tconsole.log(error);\n\t\t}\n\t}, [isCustom]);\n\n\tconst { translate } = useContext(LanguageContext) || {};\n\n\tuseEffect(() => {\n\t\tif (isVideoUploadedCorrect || isMeasurementAvailable) {\n\t\t\thandleSignUp();\n\t\t}\n\t}, [isVideoUploadedCorrect, isMeasurementAvailable]);\n\n\tconst showNextButton = isSuccess || isVideoUploadedCorrect || isMeasurementAvailable;\n\n\treturn (\n\t\t<Box className=\"flex h-full w-full flex-col common-ui-main\">\n\t\t\t<div className=\"h-full w-full flex-col items-center justify-center flex\">\n\t\t\t\t<CameraPermission loader={config?.loader} setShowDrawer={setShowDrawer} />\n\t\t\t\t<Drawer\n\t\t\t\t\topen={showDrawer}\n\t\t\t\t\tonClose={(_, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]\"\n\t\t\t\t\t\tstyle={{ background: config?.style?.base?.backgroundColor }}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"w-full h-full flex flex-col\">\n\t\t\t\t\t\t\t<Header title={translate?.(LanguageKeys.measurementsBeingTaken)} />\n\t\t\t\t\t\t\t<div className=\"flex items-center justify-center flex-1\">\n\t\t\t\t\t\t\t\t<video preload=\"auto\" className=\"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none\" muted loop autoPlay playsInline>\n\t\t\t\t\t\t\t\t\t<source src={gender === GenderType.Male ? maleMeasurementProgress : measurementProgress} type=\"video/mp4\" />\n\t\t\t\t\t\t\t\t</video>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{showNextButton && <SpecificButton className=\"!w-[180px] mx-auto\" buttonText={translate?.(LanguageKeys.next)} buttonFunc={()=>{onComplete?.()\n\t\t\t\t\t\t\t}} />}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Drawer>\n\t\t\t</div>\n\t\t</Box>\n\t);\n}\nexport default SignUp;\n","\"use client\";\nimport { useContext } from \"react\";\nimport AngleDetector from \"./AngleDetector\";\nimport CameraPermission from \"./CameraPermission\";\nimport Modal from \"../Modal\";\nimport { Drawer } from \"@mui/material\";\nimport ScanErrorMessage from \"./ScanErrorMessage\";\nimport LoadingScreen from \"../LoadingScreen\";\nimport SignUp from \"../Signup\";\nimport { useConfig } from \"../../utils/context/configContext\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\n\nexport const BodyScanSteps = () => {\n\tconst {\n\t\tuserDetails,\n\t\tonRetry,\n\t\tisError,\n\t\tisSuccess,\n\t\tgender,\n\t\tscanUniqueKey,\n\t\tscanFailsError,\n\t\tsetScanUniqueKey,\n\t\tsetIsVideoUploaded,\n\t\tisMeasurementAvailable,\n\t\tisVideoUploadedCorrect,\n\t\tloading,\n\t\tshowDeniedModal,\n\t\tuploadLoading,\n\t\tsetScanFailsError,\n\t\tsetScanStartTime,\n\t\tresetScan,\n\t\tonCustomScanSuccess,\n\t\tswan,\n\t\tonComplete,\n\t} = useContext(ParamsContext);\n\tconst resolvedConfig = useConfig();\n\n\tif (isError) {\n\t\treturn (\n\t\t\t<div data-scan-state=\"error\">\n\t\t\t\t<CameraPermission />\n\t\t\t\t<Drawer\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t\topen={true}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<ScanErrorMessage scanFailsError onNext={onRetry} gender={gender} />\n\t\t\t\t</Drawer>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (isSuccess) {\n\t\treturn <div data-scan-state=\"success\"><SignUp isSuccess onComplete={onComplete} /></div>;\n\t}\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div data-scan-state=\"loading\" className=\"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full\" style={{ background: resolvedConfig?.style?.base?.backgroundColor }}>\n\t\t\t\t<LoadingScreen url={resolvedConfig?.loader} loaderType=\"black\" />\n\t\t\t</div>\n\t\t);\n\t}\n\tif (showDeniedModal.disabled) {\n\t\treturn <div data-scan-state=\"camera-denied\"><Modal /></div>;\n\t}\n\n\tif (!uploadLoading && !scanFailsError && !isMeasurementAvailable && !isVideoUploadedCorrect) {\n\t\treturn (\n\t\t\t<div data-scan-state=\"scanning\">\n\t\t\t<AngleDetector\n\t\t\t\tscanID={scanUniqueKey}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\tsetScanFailsError={setScanFailsError}\n\t\t\t\tsetScanStartTime={setScanStartTime}\n\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\tif ((uploadLoading || isMeasurementAvailable || isVideoUploadedCorrect) && !scanFailsError) {\n\t\treturn (\n\t\t\t<div data-scan-state=\"processing\">\n\t\t\t<SignUp\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tonCustomScanSuccess={onCustomScanSuccess}\n\t\t\t\tswan={swan}\n\t\t\t\tonComplete={onComplete}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\treturn (\n\t\t<div data-scan-state=\"error-retry\">\n\t\t\t<CameraPermission />\n\t\t\t<Drawer\n\t\t\t\tanchor=\"bottom\"\n\t\t\t\topen\n\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<ScanErrorMessage\n\t\t\t\t\tscanFailsError={scanFailsError}\n\t\t\t\t\tonNext={() => {\n\t\t\t\t\t\tonRetry?.();\n\t\t\t\t\t\tresetScan();\n\t\t\t\t\t}}\n\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\tgender={gender}\n\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t/>\n\t\t\t</Drawer>\n\t\t</div>\n\t);\n};\n","\"use client\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport useGyroSensor from \"../../customHooks/useGyroSensor\";\nimport usePosthogPageview from \"../../customHooks/usePosthogPageview\";\nimport {\n\tcheckCameraPermission,\n\tcreateObjectMetadataArray,\n\tgenerateUuid,\n\tgetCurrentTimeInSeconds,\n\tgetVideoFPS,\n\thandleErrorMessage,\n\thandleScanTimeCapture,\n\thandleWebSocketCapture,\n} from \"../../utils/utils\";\nimport LanguageContextProvider from \"../../utils/context/languageContext\";\nimport { ConfigProvider } from \"../../utils/context/configContext\";\nimport { getSwanService } from \"../../utils/service/swanService\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport MediaContextProvider from \"../../utils/context/mediaContext\";\nimport { BodyScanProps, UserDetails } from \"../../types/interfaces\";\nimport { BodyScanSteps } from \"./BodyScanSteps\";\n\nconst clothesFit = \"0\";\n\nexport const BodyScan: React.FC<BodyScanProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonRetry,\n\t\tonScanStart,\n\t\tonCaptureComplete,\n\t\tonUploadStart,\n\t\tonUploadEnd,\n\t\tonMeasurementSocketStart,\n\t\tonMeasurementSocketClose,\n\t\tonIntermediateScanSuccess,\n\t\tonScanError,\n\t\tonScanSuccess,\n\t\tonCustomScanSuccess,\n\t\tonComplete,\n\t\tisError,\n\t\tisSuccess,\n\t} = props;\n\tconst userDetails: UserDetails = {\n\t\temail: \"\",\n\t\tshopDomain: \"\",\n\t\tgender: \"male\",\n\t\theightInCm: 0,\n\t\tscanType: \"\",\n\t\tdeviceFocalLength: 0,\n\t\tdeviceModelName: \"\",\n\t\tsourceTag: \"\",\n\t\tcallbackUrl: null,\n\t\t...(props.userDetails ?? {}),\n\t};\n\tconst token = props.token ?? \"\";\n\tconst { gender, scanType, shopDomain, heightInCm, email, deviceFocalLength, deviceModelName, callbackUrl, sourceTag } = userDetails;\n\tconst swan = useMemo(() => getSwanService(token), [token]);\n\tconst [uploadLoading, setUploadLoading] = useState(false);\n\tconst [isVideoUploadedCorrect, setIsVideoUploadedCorrect] = useState(false);\n\tconst [isMeasurementAvailable, setIsMeasurementAvailable] = useState(false);\n\tconst [showDeniedModal, setShowDeniedModal] = useState({\n\t\tdisabled: false,\n\t\tmessage: \"\",\n\t});\n\tconst [scanFailsError, setScanFailsError] = useState(\"\");\n\tconst [isVideoUploaded, setIsVideoUploaded] = useState(false);\n\tconst [loading, setLoading] = useState(true);\n\tconst [startGyro, setStartGyro] = useState(false);\n\tconst [scanUniqueKey, setScanUniqueKey] = useState(\"\");\n\tconst [scanStartTime, setScanStartTime] = useState<number | null>(getCurrentTimeInSeconds());\n\tconst { gyroData } = useGyroSensor(startGyro);\n\tusePosthogPageview();\n\n\tconst resetScan = useCallback(() => {\n\t\tsetScanUniqueKey(generateUuid());\n\t\tsetScanFailsError(\"\");\n\t\tsetUploadLoading(false);\n\t\tsetIsVideoUploaded(false);\n\t}, []);\n\n\tconst onError = (data: any) => {\n\t\tonScanError?.({ ...data, message: handleErrorMessage(data) });\n\t\tclearScanStartTimeAndScanId();\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(data);\n\t\tsetIsVideoUploadedCorrect(false);\n\t\thandleScanTimeCapture({\n\t\t\teventName: `${shopDomain}/measurement_failed/fit-view`,\n\t\t\tscanID: scanUniqueKey,\n\t\t\tstatus: \"failed\",\n\t\t\temail,\n\t\t\tmessage: handleErrorMessage(data),\n\t\t});\n\t\tif (scanStartTime)\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\temail,\n\t\t\t});\n\t};\n\n\tconst clearScanStartTimeAndScanId = () => {\n\t\tsetScanStartTime(null);\n\t\tsetScanUniqueKey(\"\");\n\t};\n\n\tconst onSuccess = useCallback(\n\t\tasync (data: any) => {\n\t\t\tif (data && data?.scanStatus === \"success\" && data?.resultType === \"intermediate\" && data?.code === 200) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/measurement_success/intermediate`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\t\tonIntermediateScanSuccess?.(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonScanSuccess?.(data);\n\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\tclearScanStartTimeAndScanId();\n\t\t\tconst scanIdToSet = scanUniqueKey;\n\t\t\tsetIsMeasurementAvailable(true);\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/measurement_success/fit-view`,\n\t\t\t\tscanID: scanIdToSet,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tif (scanStartTime)\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\t\tscanID: scanIdToSet,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t},\n\t\t[scanType, shopDomain, scanUniqueKey],\n\t);\n\n\tconst handleMeasurementRecommendation = (scanId?: string) => {\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploadedCorrect(false);\n\t\tswan.measurement.handleMeasurementSocket({\n\t\t\tscanId: scanId || scanUniqueKey,\n\t\t\tonPreopen: () => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"pre_open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonOpen: () => {\n\t\t\t\tonMeasurementSocketStart?.();\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonClose: () => {\n\t\t\t\tonMeasurementSocketClose?.();\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"close\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tonError(err);\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"error\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonSuccess: (data) => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"success\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tonSuccess(data);\n\t\t\t},\n\t\t});\n\t};\n\n\tconst uploadScanFile = useCallback(\n\t\tasync (file: File, recordedFps?: number | null) => {\n\t\t\tconst fileSizeInMB = Number((file.size / (1024 * 1024)).toFixed(2));\n\t\t\t// Use FPS captured at recording time, fallback to calculation if not available\n\t\t\tconst videoFps = recordedFps !== undefined && recordedFps !== null ? recordedFps : await getVideoFPS(file);\n\t\t\tconst arrayMetaData = createObjectMetadataArray({\n\t\t\t\tgender,\n\t\t\t\tfocal_length: `${deviceFocalLength}`,\n\t\t\t\theight: `${heightInCm}`,\n\t\t\t\tcustomer_store_url: shopDomain,\n\t\t\t\tclothes_fit: clothesFit,\n\t\t\t\tscan_type: scanType,\n\t\t\t\tcallback_url: callbackUrl,\n\t\t\t\tsource_tag: sourceTag,\n\t\t\t});\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/body_scan_meta_data`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\temail,\n\t\t\t\tdata: JSON.stringify([...arrayMetaData, { fileSizeInMB, video_fps: videoFps || 0 }]),\n\t\t\t});\n\t\t\tonUploadStart?.();\n\t\t\ttry {\n\t\t\t\tawait swan.fileUpload.uploadFileFrontend({\n\t\t\t\t\tfile,\n\t\t\t\t\tarrayMetaData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tawait swan.fileUpload.setDeviceInfo({\n\t\t\t\t\tmodel: deviceModelName,\n\t\t\t\t\tdetection: \"manual\",\n\t\t\t\t\tgyro: gyroData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t});\n\t\t\t\tconsole.log(\"video successfully uploaded\");\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_success`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetScanStartTime(getCurrentTimeInSeconds());\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tsetIsVideoUploaded(true);\n\t\t\t\t}, 3000);\n\t\t\t} catch (error:any) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_failed`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\tsetScanFailsError(handleErrorMessage(error));\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\tonScanError?.({...error, message: handleErrorMessage(error) });\n\t\t\t\tclearScanStartTimeAndScanId();\n\t\t\t} finally {\n\t\t\t\tsetStartGyro(false);\n\t\t\t\tonUploadEnd?.();\n\t\t\t}\n\t\t},\n\t\t[scanUniqueKey, gyroData, onUploadStart, onUploadEnd],\n\t);\n\t// const checkMeasurementStatus = useCallback(\n\t// \tasync (scanId: string) => {\n\t// \t\ttry {\n\t// \t\t\tconst res = await swan.measurement.getMeasurementResult(scanId);\n\t// \t\t\tconst isMeasured = res?.data?.isMeasured;\n\t// \t\t\tconst tempScanStartTime = scanStartTime || getCurrentTimeInSeconds();\n\t// \t\t\tconst currentTimeInSeconds = getCurrentTimeInSeconds();\n\t// \t\t\tconst fiveMinutesInSeconds = 5 * 60;\n\t// \t\t\tsetLoading(false);\n\t// \t\t\tif (isMeasured === false) {\n\t// \t\t\t\tclearScanStartTimeAndScanId();\n\t// \t\t\t\tsetScanUniqueKey(generateUuid());\n\t// \t\t\t\treturn;\n\t// \t\t\t}\n\t// \t\t\tsetUploadLoading(true);\n\t// \t\t\tif (isMeasured === true) {\n\t// \t\t\t\tawait onSuccess(null);\n\t// \t\t\t} else if (isMeasured === null && tempScanStartTime > currentTimeInSeconds + fiveMinutesInSeconds) {\n\t// \t\t\t\tonError(res?.data?.error);\n\t// \t\t\t} else {\n\t// \t\t\t\thandleMeasurementRecommendation(scanId);\n\t// \t\t\t}\n\t// \t\t} catch (error) {\n\t// \t\t\tconsole.log(error);\n\t// \t\t\tclearScanStartTimeAndScanId();\n\t// \t\t\tsetScanUniqueKey(generateUuid());\n\t// \t\t\tsetUploadLoading(false);\n\t// \t\t}\n\t// \t},\n\t// \t[onError, onSuccess, setScanUniqueKey],\n\t// );\n\n\tconst handleCameraPermission = useCallback(async () => {\n\t\tif (+heightInCm < 152.4 || +heightInCm > 213.36) {\n\t\t\tonScanError?.({\n\t\t\t\tmessage: \"Height must be between 152.4cm (5ft) and 213.36cm (7ft)\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst permission = await checkCameraPermission();\n\t\tif (permission.disabled) {\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\t// const scanId = scanUniqueKey;\n\t\t\t// if (scanId) {\n\t\t\t// \tcheckMeasurementStatus(scanId);\n\t\t\t// } else {\n\t\t\t// \tsetLoading(false);\n\t\t\t// }\n\t\t\tsetLoading(false);\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t}\n\t\tsetShowDeniedModal(permission);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploaded(false);\n\t}, [email, scanUniqueKey, setScanUniqueKey, shopDomain]);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (shopDomain) {\n\t\t\thandleCameraPermission();\n\t\t}\n\t}, [shopDomain, heightInCm, isError, isSuccess]);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (isVideoUploaded && shopDomain && scanUniqueKey) {\n\t\t\thandleMeasurementRecommendation();\n\t\t}\n\t}, [isVideoUploaded, shopDomain, scanUniqueKey, isError, isSuccess]);\n\treturn (\n\t\t<div data-testid=\"body-scan-root\">\n\t\t<LanguageContextProvider>\n\t\t\t<ConfigProvider config={config}>\n\t\t\t\t<MediaContextProvider>\n\t\t\t\t\t<ParamsContext.Provider\n\t\t\t\t\t\tvalue={{\n\t\t\t\t\t\t\tuserDetails,\n\t\t\t\t\t\t\tonRetry,\n\t\t\t\t\t\t\tonScanError,\n\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t\tisSuccess,\n\t\t\t\t\t\t\tonScanSuccess,\n\t\t\t\t\t\t\tgender,\n\t\t\t\t\t\t\tscanUniqueKey,\n\t\t\t\t\t\t\tscanFailsError,\n\t\t\t\t\t\t\tsetScanUniqueKey,\n\t\t\t\t\t\t\tsetIsVideoUploaded,\n\t\t\t\t\t\t\tisMeasurementAvailable,\n\t\t\t\t\t\t\tisVideoUploadedCorrect,\n\t\t\t\t\t\t\tloading,\n\t\t\t\t\t\t\tshowDeniedModal,\n\t\t\t\t\t\t\tuploadLoading,\n\t\t\t\t\t\t\tsetStartGyro,\n\t\t\t\t\t\t\tuploadScanFile,\n\t\t\t\t\t\t\tsetUploadLoading,\n\t\t\t\t\t\t\tresetScan,\n\t\t\t\t\t\t\tsetScanFailsError,\n\t\t\t\t\t\t\tsetScanStartTime,\n\t\t\t\t\t\t\tonScanStart,\n\t\t\t\t\t\t\tonCaptureComplete,\n\t\t\t\t\t\t\tonCustomScanSuccess,\n\t\t\t\t\t\t\tonComplete,\n\t\t\t\t\t\t\tswan,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BodyScanSteps />\n\t\t\t\t\t</ParamsContext.Provider>\n\t\t\t\t</MediaContextProvider>\n\t\t\t</ConfigProvider>\n\t\t</LanguageContextProvider>\n\t\t</div>\n\t);\n};\n","import { useCallback, useEffect, useState } from \"react\";\n\ninterface GyroDataItem {\n alpha?: string;\n beta?: string;\n gamma?: string;\n timestamp?: string;\n}\n\nexport interface IOSDeviceOrientationEvent extends DeviceOrientationEvent {\n requestPermission?: () => Promise<PermissionState>;\n}\n\nfunction useGyroSensor(startGyro: boolean) {\n const [gyroData, setGyroData] = useState<GyroDataItem[]>([]);\n const [permissionGranted, setPermissionGranted] = useState(false);\n\n const handleOrientation = useCallback((event: DeviceOrientationEvent) => {\n try {\n const { alpha, beta, gamma } = event;\n setGyroData((prev: GyroDataItem[]) => [\n ...prev,\n {\n alpha: alpha?.toString() || undefined,\n beta: beta?.toString() || undefined,\n gamma: gamma?.toString() || undefined,\n timestamp: new Date().toISOString(),\n },\n ]);\n } catch (error) {\n console.log(error);\n }\n }, []);\n\n const requestPermission = useCallback(async () => {\n const DeviceOrientation =\n DeviceOrientationEvent as unknown as IOSDeviceOrientationEvent;\n\n if (\n typeof DeviceOrientation !== \"undefined\" &&\n typeof DeviceOrientation.requestPermission === \"function\"\n ) {\n try {\n const response = await DeviceOrientation.requestPermission();\n if (response === \"granted\") {\n setPermissionGranted(true);\n } else {\n console.warn(\"Device orientation permission denied.\");\n }\n } catch (error) {\n console.error(\"Error requesting device orientation permission:\", error);\n }\n } else {\n // Permission not required on non-iOS devices\n setPermissionGranted(true);\n }\n }, []);\n\n useEffect(() => {\n if (startGyro && permissionGranted) {\n window.addEventListener(\"deviceorientation\", handleOrientation);\n } else {\n setGyroData([]);\n }\n return () => {\n window.removeEventListener(\"deviceorientation\", handleOrientation);\n };\n }, [startGyro, permissionGranted, handleOrientation]);\n\n useEffect(() => {\n if (startGyro) {\n requestPermission();\n }\n }, [startGyro, requestPermission]);\n\n return { gyroData };\n}\n\nexport default useGyroSensor;\n"],"names":["MEDIA_TYPES","MediaContext","createContext","undefined","MediaContextProvider","children","size","setSize","useState","window","innerWidth","innerHeight","clearInputs","setClearInputs","updateSize","useEffect","useLayoutEffect","addEventListener","removeEventListener","media","mediaDetails","useMemo","_jsx","Provider","value","SwitchIcon","React","memo","_jsxs","width","height","viewBox","fill","xmlns","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","LevelScreen","angle","countdown","isScanning","isInTargetRange","stabilityScore","translate","useContext","LanguageContext","config","useConfig","getProximityToTarget","useCallback","Math","max","min","backgroundColor","style","angleDetector","successAngleBackground","proximity","successAngleLowBackground","round","handelTextColour","isLight","successAngleTextLightColor","successAngleTextDarkColor","getTextColor","handelColourCode","getColorCode","cd","fixVh","document","documentElement","setProperty","className","Header","noTitle","border","fontFamily","base","baseFontFamily","color","cn","transform","transition","LanguageKeys","startLevelCheck","leavePhone","placePhoneUpright","CameraScanChild","resetScan","loadingCam","onUserMedia","onPause","pause","onReScan","recordingStarted","startSendingVideoFrames","showPause","webcamRef","onUserMediaError","resetDetector","videoConstraints","webcamKey","faceDone","onClick","X","Webcam","audio","ref","screenshotQuality","mirrored","screenshotFormat","position","top","bottom","zIndex","objectFit","SpecificButton","prefix","pauseIcon","buttonText","buttonFunc","btnSecondary","restart","startScan","disabled","id","crossOrigin","preload","src","voiceOverAssetsPath","audioTimeoutId","globalLoadingPromise","globalDetector","globalPoseLib","lastVideoPlayed","ScanningComponent","setIsScanLocked","scanID","setIsVideoUploaded","setScanFailsError","setScanStartTime","setScanUniqueKey","userDetails","email","shopDomain","gender","heightInCm","useRef","mediaRecorderRef","recordedFpsRef","recordedChunks","setRecordedChunks","setLoadingCam","setRecordingStarted","setFaceDone","mediaRecorderStopped","setMediaRecorderStopped","setIsScanning","captureVideoTimeOutHandle","audioSource","setAudioSource","audioSourceList","setAudioSourceList","emptyAudioSource","setEmptyAudioSource","startAgain","setStartAgain","showRestart","setRestart","setPause","events","setEvents","setShowPause","allowAudioToPlay","poseDetector","consecutiveFronts","setConsecutiveFronts","spinPhase","setSpinPhase","isLoaded","setIsLoaded","spinPhaseRef","consecutiveFrontsRef","mounted","async","loadDependenciesGlobal","navigator","console","log","poseLib","tfjsCore","tfjsBackend","Promise","all","import","setBackend","ready","modelConfig","runtime","modelType","solutionPath","createDetector","SupportedModels","BlazePose","mediapipeError","warn","error","isFrontFrame","body","length","filter","p","current","then","success","s","callback","video","readyState","poses","estimatePoses","flipHorizontal","keypoints","slice","map","kp","x","y","score","prev","err","retryLoading","useTensorFlow","firstScan","poseStoppedRef","counterRef","consecutiveFalseRef","poseListenerRegistered","isConnectingRef","brilliantPlayedRef","postPoseProcessRef","startSendingVideoFramesRef","idRef","supportedTypes","setSupportedTypes","setWebcamKey","currentVideoConstraints","setCurrentVideoConstraints","videoConstraintsExact","setStartGyro","uploadScanFile","setUploadLoading","swan","onScanStart","onCaptureComplete","ParamsContext","scanIDRef","eventsRef","clearTimeout","generateUuid","speechService","stopAudio","stop","forEach","el","stream","handleUserMedia","setTimeout","handleUserMediaError","videoConstraintsFallback","handlePause","poseDetection","disconnect","posthog","capture","reason","preferredVideoTypes","getPreferredMediaRecorderTypes","recordingMimeType","getRecordingMimeType","recordingExtension","getRecordingExtension","stopRecording","playAudio","handleSocket","connect","String","rescanSupportCaptureEvent","eventName","status","handleSpinDataAvailable","data","concat","handleScanTimeCapture","message","lastAudio","handleStartCaptureClick","videoTrack","getVideoTracks","settings","getSettings","frameRate","mediaRecorderOptions","videoBitsPerSecond","mimeType","MediaRecorder","start","e","postPoseProcess","handleDataAvailable","connected","poseStatus","querySelector","sid","counter","consecutiveFalse","type","paused","audioName","no_of_times_skipped","skipCount","getScreenshot","videoEmit","image","scanId","getCurrentTimeInSeconds","prevId","push","bypassChecksToBackup","videoFile","File","supported","getSupportedMediaRecorderTypes","videoTypes","AngleDetector","setAngle","calibrationOffset","setCalibrationOffset","setCountdown","setStabilityScore","lastAnglesRef","isScanLocked","calibratedAngle","DeviceOrientationEvent","handleOrientation","event","beta","newAngle","abs","gamma","cos","PI","requestPermission","DeviceOrientation","once","variation","resetCountdown","startCountdown","timer","setInterval","clearInterval","CameraPermission","setShowDrawer","loader","showDeniedModal","setShowDeniedModal","loading","setLoading","handleCameraPermission","permission","checkCameraPermission","LoadingScreen","url","loaderType","Modal","VideoPlayer","link","onReady","wrapperClassName","videoReference","playerReference","videoJsOptions","autoplay","controls","responsive","fluid","muted","navigationUI","poster","videoPoster","player","videojs","updatedOptions","sources","isDisposed","dispose","playsInline","onDrag","preventDefault","ScanErrorMessage","scanFailsError","onNext","resolvedConfig","showModal","setShowModal","handleShowModal","_Fragment","background","heading","headingFontFamily","fontSize","headingFontSize","headingColor","fontWeight","headingFontWeight","issueWithScan","baseFontSize","baseTextColor","handleErrorMessage","VIDEO_POSTER_GENDER_BASED","alt","scanAgain","Dialog","onClose","open","GENDER","PRE_LINK","male","SignUp","isVideoUploadedCorrect","isMeasurementAvailable","onComplete","isSuccess","onCustomScanSuccess","deviceFocalLength","userName","scanType","isCustom","CLOTHING_CUSTOM_SCAN","CLOTHING_BANNER_SCAN","CLOTHING_CUSTOM_FIT_SCAN","includes","showDrawer","handleSignUp","auth","addUser","name","focalLength","clothesFit","showNextButton","Box","Drawer","_","anchor","title","measurementsBeingTaken","loop","autoPlay","GenderType","Male","maleMeasurementProgress","measurementProgress","next","BodyScanSteps","onRetry","isError","scanUniqueKey","uploadLoading","BodyScan","props","onUploadStart","onUploadEnd","onMeasurementSocketStart","onMeasurementSocketClose","onIntermediateScanSuccess","onScanError","onScanSuccess","deviceModelName","sourceTag","callbackUrl","token","getSwanService","setIsVideoUploadedCorrect","setIsMeasurementAvailable","isVideoUploaded","startGyro","scanStartTime","gyroData","setGyroData","permissionGranted","setPermissionGranted","alpha","toString","timestamp","Date","toISOString","useGyroSensor","usePosthogPageview","clearScanStartTimeAndScanId","onSuccess","scanStatus","resultType","code","scanIdToSet","completionTime","handleMeasurementRecommendation","measurement","handleMeasurementSocket","onPreopen","handleWebSocketCapture","connection","onOpen","onError","file","recordedFps","fileSizeInMB","Number","toFixed","videoFps","getVideoFPS","arrayMetaData","createObjectMetadataArray","focal_length","customer_store_url","clothes_fit","scan_type","callback_url","source_tag","JSON","stringify","video_fps","fileUpload","uploadFileFrontend","setDeviceInfo","model","detection","gyro","LanguageContextProvider","ConfigProvider"],"mappings":"wsBAYO,MAAMA,GACF,UADEA,GAEN,MAFMA,GAGH,SAWGC,GAAeC,OAC1BC,GAGF,SAASC,IAAqBC,SAAEA,IAC9B,MAAOC,EAAMC,GAAWC,EAAS,CAACC,QAAQC,WAAYD,QAAQE,eACvDC,EAAaC,GAAkBL,GAAS,GAEzCM,EAAa,KACjBP,EAAQ,CAACE,QAAQC,WAAYD,QAAQE,eAEvCI,EAAU,KACRD,KACC,IACHE,EAAgB,KACdP,OAAOQ,iBAAiB,SAAUH,GAC3B,IAAML,OAAOS,oBAAoB,SAAUJ,IACjD,CAACA,IACJ,IAAIK,EAAQnB,GACRM,EAAK,GAAK,KAAOA,EAAK,GAAK,OAC7Ba,EAAQnB,IAENM,EAAK,GAAK,MACZa,EAAQnB,IAGV,MAAMoB,EAAeC,EACnB,KAAA,CACEf,OACAC,UACAK,cACAC,iBACAM,UAEF,CAACb,EAAMM,EAAaO,IAGtB,OACEG,EAACrB,GAAasB,SAAQ,CAACC,MAAOJ,EAAYf,SACvCA,GAGP,CClBA,IAAAoB,GAAeC,EAAMC,KAhDrB,UAAoBrB,KAAEA,EAAO,KAC3B,OACEsB,EAAA,MAAA,CACEC,MAAOvB,EACPwB,OAAQxB,EACRyB,QAAQ,YACRC,KAAK,OACLC,MAAM,6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L,sBACAF,aACAnL,QACAzP,SAEDiB,EAAC2b,GAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import a,{useState as r,useCallback as s,useEffect as o,createContext as c,useLayoutEffect as i,useMemo as l,useContext as d,useRef as u}from"react";import{L as m,u as p,H as f,b as h,S as g,z as y,a as v,i as w,P as x,o as b,s as S,j as C,k as N,l as D,p as I,A as k,x as F,B as T,q as E,f as L,r as M,D as _,c as $,M as U,v as j,E as A,I as P,V as z,J as V,K as R,N as B,G as q,O as K,Q as O,R as W,h as H,n as J,w as G,T as Q,t as Y,C as X,y as Z}from"./Modal-D_XGokez.js";import ee from"clsx";import te from"react-webcam";import{X as ne}from"lucide-react";import{Dialog as ae,Box as re,Drawer as se}from"@mui/material";import oe from"video.js";const ce="DESKTOP",ie="TAB",le="MOBILE",de=c(void 0);function ue({children:t}){const[n,a]=r([window?.innerWidth,window?.innerHeight]),[s,c]=r(!1),d=()=>{a([window?.innerWidth,window?.innerHeight])};o(()=>{d()},[]),i(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[d]);let u=ce;n[0]>768&&n[0]<1024&&(u=ie),n[0]<768&&(u=le);const m=l(()=>({size:n,setSize:a,clearInputs:s,setClearInputs:c,media:u}),[n,s,u]);return e(de.Provider,{value:m,children:t})}var me=a.memo(function({size:n=16}){return t("svg",{width:n,height:n,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("path",{d:"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});var pe=a.memo(function({angle:n,countdown:a,isScanning:r,isInTargetRange:o,stabilityScore:c,children:i}){const{translate:u}=d(m)||{},g=p(),y=s(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),v=l(()=>{if(r)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=y();if(0===e)return g?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[r,y]),w=s((e,t)=>t>70?e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${g?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),x=s((e=!1)=>{const t=y();return r?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:w(e,t)},[r,y]),b=s((e,t)=>t>70||e?g?.style?.angleDetector?.successAngleTextLightColor:g?.style?.angleDetector?.successAngleTextDarkColor,[]),S=s((e=!1)=>{const t=y();return r?g?.style?.angleDetector?.successAngleTextLightColor:b(e,t)},[r,y]),C=a;function N(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return N(),window.addEventListener("resize",N),t("div",{className:"flex common-ui-main w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto",style:{backgroundColor:v},"data-testid":"level-screen","data-angle-state":r?"locked":o?"target":"adjusting",children:[e("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e("div",{className:"flex justify-start ",children:e(f,{noTitle:!0})})}),null!==C?e("div",{className:"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300",style:{border:`2px solid ${S()}`},children:e("div",{className:`text-[3rem] font-bold text-[${S()}]`,style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:C})}):t("div",r?{className:"relative flex flex-col items-center justify-center",children:[e("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),i]}:{className:ee("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",o?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-n)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${S()}`},children:[e("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${S()}]/80`,style:{backgroundColor:`${S()}B3`}}),t("div",{className:ee("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",x()),style:{color:S()},children:[e(me,{size:30}),t("p",{style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",u?.(h.startLevelCheck),e("br",{})]})]})]}),null!==C&&e("div",{className:"absolute bottom-[8rem] text-center",children:e("div",{className:ee("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",x()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.leavePhone)})}),o&&null===C&&!r&&e("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e("div",{className:`h-[.375rem] w-full bg-[${S()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${S()}33`},children:e("div",{className:`h-full bg-[${S()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${S()}B3`}})})}),null===C&&!r&&e("div",{className:"absolute bottom-[5rem] text-center",children:t("div",{className:ee("text-[1.5rem] font-light",x()),style:{color:S()},children:[Math.round(n),"°"]})}),null===C&&!r&&e("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e("div",{className:ee("text-[.75rem] opacity-50",x()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.placePhoneUpright)})})]})});function fe({resetScan:n,loadingCam:a,onUserMedia:r,onPause:s,pause:o,onReScan:c,recordingStarted:i,startSendingVideoFrames:l,showPause:u,webcamRef:p,onUserMediaError:f,resetDetector:w,videoConstraints:x,webcamKey:b,faceDone:S,isScanning:C}){const{media:N}=d(de)||{},{translate:D}=d(m)||{};return t("div",{className:"App w-screen h-[100vh] relative common-ui-main","data-testid":"camera-scan","data-scan-phase":S?"spinning":i?"pose-detecting":C?"starting":"ready",children:[e("span",{onClick:()=>{n(),w()},className:"fixed right-[20px] top-[20px] z-[999]",children:e(ne,{className:"text-[#fff]"})}),e("div",{className:"w-full h-full overflow-hidden ",children:N===le&&e(te,{audio:!1,ref:p,screenshotQuality:1,videoConstraints:x,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:r,onUserMediaError:f,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},b)}),t("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[u&&e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:y,buttonText:D?.(h.pause),buttonFunc:s,btnSecondary:!0}),o?e("div",{children:e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:D?.(h.restart),buttonFunc:c,btnSecondary:!0})}):i?null:e(g,{"data-testid":"start-scan-btn",className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(a?"!opacity-50":""),buttonText:D?.(h.startScan),buttonFunc:l,disabled:a})]}),e("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${v}scanAudioInstructions/silence.mp3`})]})}let he=null,ge=null,ye=null;let ve,we=null,xe=null;var be=a.memo(function({setIsScanLocked:t,resetDetector:n,scanID:a,setIsVideoUploaded:c,setScanFailsError:i,setScanStartTime:m,setScanUniqueKey:p,userDetails:f}){const{gender:h,heightInCm:g,email:y,shopDomain:_}=f,$=u(null),U=u(null),j=u(null),[A,P]=r([]),[z,V]=r(!0),[R,B]=r(!1),[q,K]=r(!1),[O,W]=r(!0),[H,J]=r(!1),G=u(null),[Q,Y]=r(""),[X,Z]=r([]),[ee,te]=r(""),[ne,ae]=r(!1),[re,se]=r(!1),[oe,ce]=r(!1),[ie,le]=r([]),[de,ue]=r(!1),me=u(!0),{poseDetector:pe}=function(){const[e,t]=r(0),[n,a]=r(0),[s,c]=r(!1),i=u(0),l=u(0),d=u(!0);async function m(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,n]=await Promise.all([import("./pose-detection.esm-DejsYGYM.js"),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);ye=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const a={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{ge=await ye.createDetector(ye.SupportedModels.BlazePose,a),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),ge=await ye.createDetector(ye.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),console.log("TFJS detector created successfully")}return!0}catch(e){return console.error("Failed to load TensorFlow dependencies:",e),he=null,!1}}function p(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return o(()=>{if(d.current=!0,!ge)return he||(he=m()),he.then(e=>{e&&d.current&&c(!0)}),()=>{d.current=!1};c(!0)},[]),o(()=>{l.current=e,e>6&&i.current<2&&(a(e=>e+1),t(0))},[e]),o(()=>{i.current=n},[n]),{poseDetector:async(e,n)=>{if(!ge||!d.current||!n?.current?.video)return;const a=n.current.video;if(!(a.readyState<2))try{const n=await ge.estimatePoses(a,{flipHorizontal:!1});if(!n||!n.length)return;const r=n[0].keypoints.slice(11).map(e=>[e.x>0&&e.x<720?e.x:-1,e.y>0&&e.y<1280?e.y:-1,e.score??0]);0!==i.current||p(r)||t(e=>e+1),1===i.current&&p(r)&&t(e=>e+1),2===i.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:s,spinPhase:n,resetDetector:()=>{i.current=0,l.current=0,t(0),a(0)},retryLoading:async()=>{ge||he||(he=m(),await he&&d.current&&c(!0))}}}(),be=u(!0),Se=u(!1),Ce=u(0),Ne=u(0),De=u(!1),Ie=u(!1),ke=u(!1),Fe=u(()=>{}),Te=u(()=>{}),[Ee,Le]=r([]),[Me,_e]=r(0),[$e,Ue]=r(w),{setStartGyro:je,uploadScanFile:Ae,setUploadLoading:Pe,swan:ze,onScanStart:Ve,onCaptureComplete:Re}=d(x),Be=()=>{Se.current=!1,clearTimeout(ve),G.current&&clearTimeout(G.current),p(L()),i(""),Pe?.(!1),P([]),j.current=null,V(!0),B(!1),K(!1),W(!0),J(!1),G.current=null,Y(""),Z([]),te(""),ae(!ne),je(!1),S.stopAudio(),se(!1),ce(!1),Ce.current=0,Ne.current=0,De.current=!1,ke.current=!1,null!==U.current&&U.current.stop(),ie.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),le([]),me.current=!0,ue(!1),c(!1),$.current?.stream&&V(!1)},qe=s(()=>{setTimeout(()=>{V(!1)},1e3)},[]),Ke=s(e=>{if(console.log("camera error",e),$e===w)return Ue(b),void _e(e=>e+1);V(!1)},[$e]),Oe=s(()=>{me.current=!1,ce(!0),ue(!1),G.current&&clearTimeout(G.current),U.current&&U.current.pause(),S.stopAudio(),ze.poseDetection.disconnect(),Ce.current=0,Ne.current=0,De.current=!1,ke.current=!1,U.current&&U.current.stop(),ie.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),le([]),clearTimeout(ve)},[U,ie,S,me]),We=l(()=>C(),[]),He=N(Ee),Je=D(He),Ge=s(async()=>{me.current=!0,await S.playAudio(`${v}SpotOn.mp3`),ce(!1),ue(!1),G.current&&clearTimeout(G.current),B(!1)},[G,S]),Qe=s(async()=>{if(!Ie.current&&!we){Ie.current=!0;try{we=await ze.poseDetection.connect(),I.capture(`${_}/pose_detection_connected`,{scanID:a,email:y,id:we})}catch(e){console.log(e,"while connecting websocket")}finally{Ie.current=!1}}},[a,_,y]),Ye=s(async()=>{k({eventName:`${_}/rescan`,email:y,scanID:a,height:g,gender:h,status:!1}),me.current=!1,ze.poseDetection.disconnect(),we=null,Be(),await Qe(),Te.current()},[Qe,a,y]),Xe=s(({data:e})=>{e&&e.size>0&&me.current&&(P(t=>t.concat(e)),!Se.current&&$.current&&(Se.current=!0,pe(()=>{Ge(),F({eventName:`${_}/tensorFlow`,scanID:a,email:y,message:"recording stopped by tensorflow "})},$)))},[Ge,F,_,a,y,$]),Ze=s(async()=>{const e=X[X.length-1];e&&me.current&&(await S.playAudio(v+e),me.current&&(ve=setTimeout(Ze,2e3)))},[X,me]),et=s(()=>{U&&U.current&&U.current.stop(),B(!0);try{if($&&$.current&&$.current.stream){const e=$.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();j.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};Ee[0]&&(t.mimeType=Ee[0]),U.current=new MediaRecorder($.current.stream,t),U.current.addEventListener("dataavailable",Xe),U.current.addEventListener("stop",()=>{W(!0)}),le([...ie,Xe]),U.current.start(1e3),W(!1)}}catch(e){console.log("error while using media recorder",e)}},[$,Ee,Xe,ie]),tt=s(async()=>{G.current&&clearTimeout(G.current),et(),me.current&&(G.current=setTimeout(async()=>{me.current&&(await S.playAudio(`${v}SpotOn.mp3`),B(!1))},15e3)),K(!0),me.current&&await S.playAudio(`${v}Spin.mp3`)},[et,me,S]);o(()=>{Fe.current=tt},[tt]);const nt=s(({data:e})=>{e.size>0&&ze.poseDetection.connected()&&(De.current||(De.current=!0,ze.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){I.capture(`${_}/pose_instruction_received`,{scanID:a,email:y,audio:e.audio,status:e.status,sid:e.sid,counter:Ce.current,consecutiveFalse:Ne.current,type:"body_scan_instruction"});const t=document.querySelector("#audioElement");!0===e.status&&e.sid===we?(Ne.current=0,Ce.current<2?(Ce.current+=1,1!==Ce.current||ke.current?2===Ce.current&&t?.paused&&S.playAudio(v+e.audio):(ke.current=!0,S.stopAudio(),await S.playAudio(v+e.audio))):(te(e.audio),clearTimeout(ve),ze.poseDetection.disconnect(),De.current=!1,setTimeout(()=>Fe.current(),1e3))):(Ne.current+=1,Ne.current>=3&&(Ce.current=0,ke.current=!1),!t?.paused||xe&&xe?.audioName===e.audio?xe?.audioName===e.audio&&t?.paused&&(xe&&xe.no_of_times_skipped>=xe.skipCount?(xe.no_of_times_skipped=0,S.playAudio(v+e.audio)):xe&&(xe.no_of_times_skipped+=1)):(xe={skipCount:2,no_of_times_skipped:0,audioName:e.audio},S.playAudio(v+e.audio)))}})),$?.current&&null!==$.current.getScreenshot()&&ze.poseDetection.videoEmit({image:$.current.getScreenshot()||"",scanId:a}))},[$,a,ze,we,S,_,y]),at=s(async()=>{J(!0),je(!0),Ve?.(),be.current&&(be.current=!1,F({eventName:"scan started",scanID:a,status:"success",email:y})),m(T()),V(!0),me.current&&await S.playAudio(`${v}StartScan.mp3`),me.current&&await S.playAudio(`${v}LiftArmsAndHoldAtHip.mp3`),me.current&&(J(!1),B(!0),se(!0),ue(!0),qe());try{if($&&$.current&&$.current.stream&&me.current){const e=$.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();j.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};Ee[0]&&(t.mimeType=Ee[0]),me.current&&(U.current=new MediaRecorder($.current.stream,t)),me.current&&U.current&&U.current.addEventListener("dataavailable",nt),le([...ie,nt]),U.current&&U.current.start(1e3),W(!1),me.current&&(ve=setTimeout(Ze,2e3))}}catch(e){console.log("error ----------",e)}},[$,Ee,nt,ie,Ze,me,Ve]);return o(()=>(_&&(t(!0),Qe()),()=>{const e=we;we=null,e&&(ze.poseDetection.disconnect(),I.capture(`${_}/pose_detection_disconnected`,{scanID:a,email:y,id:e})),ie.forEach(e=>{U?.current?.removeEventListener("dataavailable",e)})}),[_]),o(()=>{X.push(Q)},[Q]),o(()=>{Z([])},[ee]),o(()=>{const e=A.length&&A.length>0;O||!e||R||!me.current||oe||U&&U.current&&(R||U.current.stop())},[O,R,A,oe]),o(()=>{const e=A.length&&A.length>0;if(O&&e&&!R&&U&&U.current&&me.current&&!oe&&!R){const e=new File(A,`${a}.${Je}`,{type:He});Re?.(),Pe?.(!0),i(""),Ae?.(e,j.current)}},[O,R,A,oe,U,me]),o(()=>{Te.current=at},[at]),o(()=>{const e=E(We,M);Le(e)},[We]),o(()=>{Be()},[]),e(fe,{resetDetector:n,resetScan:Be,loadingCam:z,onPause:Oe,showRestart:re,pause:oe,onReScan:Ye,recordingStarted:R,isScanning:H,startSendingVideoFrames:at,faceDone:q,stopRecording:Ge,showPause:de,webcamRef:$,onUserMedia:qe,onUserMediaError:Ke,videoConstraints:$e,webcamKey:Me})});function Se({scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i}){const[l,d]=r(90),[m,p]=r(0),[f,h]=r(null),[g,y]=r(!1),[v,w]=r(0),x=u([]),[b,S]=r(!1),C=l-m,N=C>=80&&C<=95;o(()=>{if("undefined"!=typeof window&&window.DeviceOrientationEvent){const e=e=>{if(null!==e.beta){let t=Math.abs(e.beta);null!==e.gamma&&(t*=Math.cos(e.gamma*Math.PI/180)),t=Math.max(0,Math.min(180,t)),d(t)}},t=async()=>{const t=DeviceOrientationEvent;if(t&&"function"==typeof t.requestPermission)try{"granted"===await t.requestPermission()&&window.addEventListener("deviceorientation",e)}catch(e){console.error("Permission error",e)}else window.addEventListener("deviceorientation",e);return()=>{e&&window.removeEventListener("deviceorientation",e)}};document.addEventListener("click",t,{once:!0})}},[]),o(()=>{if(x.current=[...x.current.slice(-4),C],x.current.length>=5){const e=Math.max(...x.current)-Math.min(...x.current);w(N&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}N||null===f&&!g||I()},[C,N,f,g]),o(()=>{v>=100&&null===f&&!g&&D(),v<50&&null!==f&&I()},[v,f,g]);const D=()=>{h(3);const e=setInterval(()=>{h(t=>null===t||t<=1?(clearInterval(e),y(!0),null):t-1)},1e3)},I=()=>{h(null),b||y(!1)};return e(pe,{angle:C,countdown:f,isScanning:g,isInTargetRange:N,stabilityScore:v,children:g&&e(be,{setIsScanLocked:S,resetDetector:()=>{d(90),p(0),h(null),y(!1),w(0),S(!1),x.current=[]},scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i})})}function Ce({setShowDrawer:t,config:n,loader:a}){const[c,i]=r({disabled:!1,message:""}),[l,d]=r(!0),m=u(null),p=s(async()=>{const e=await _();i(e),d(!1)},[]);return o(()=>{p()},[]),l?e($,{url:a,loaderType:"black"}):c?.disabled?e(U,{config:n,message:c?.message}):e(te,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:j,mirrored:!0,onUserMedia:()=>t?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function Ne({link:t,onReady:n,wrapperClassName:a="[&_video]:rounded-t-[20px] w-full h-full"}){const r=u(null),s=u(null);let c={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:A};return o(()=>{if(!s.current&&t&&r?.current){const e=oe(r.current,{...c});e.ready(()=>{s.current=e;const a={...c,sources:[{src:t,type:"application/x-mpegURL"}]};e.autoplay(a.autoplay),e.src(a.sources),n?.(e)})}},[t,r]),o(()=>{const e=s.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),s.current=null)}},[s]),e("div",{className:a,children:e("video",{ref:r,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function De({scanFailsError:a,onNext:s,gender:o,setScanUniqueKey:c,setIsVideoUploaded:i}){const{translate:l}=d(m)||{},u=p(),[y,v]=r(!1),w=()=>{v(!y)};return t(n,{children:[t("div",{"data-testid":"scan-error-message",className:"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:u?.style?.base?.backgroundColor},children:[e("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e(f,{noTitle:!0})}),e("div",{className:"flex-1",children:a&&t("div",{className:"px-[1rem]",children:[e("h2",{className:"text-center",style:{fontFamily:u?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:u?.style?.heading?.headingFontSize||"32px",color:u?.style?.heading?.headingColor||"#000",fontWeight:u?.style?.heading?.headingFontWeight||"normal"},children:l?.(h.issueWithScan)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:l?.(h.reason)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:P(a)}),e("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:w,src:z[o],alt:"icon"})]})}),a&&e("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e(g,{"data-testid":"scan-again-btn",disabled:!1,buttonText:l?.(h.scanAgain),className:"!shadow-none",buttonFunc:()=>{s?s?.():c?.(L()),i?.(!1)}})})]}),y&&t(ae,{className:"w-screen h-screen video-modal",onClose:w,open:y,children:[e("div",{className:"flex justifyEnd ",children:e("span",{className:"closeBtn",onClick:w,children:e(ne,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e("div",{className:"aspect-video object-cover rounded-[20px] ",children:e(Ne,{link:o?V[o].PRE_LINK:V.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function Ie({scanId:n,userDetails:a,config:c,isVideoUploadedCorrect:i,isMeasurementAvailable:l,onComplete:u,isSuccess:p,onCustomScanSuccess:y,swan:v}){const{gender:w,shopDomain:x,heightInCm:b,deviceFocalLength:S,userName:C,email:N,scanType:D}=a||{},k=[K,O,W].includes(D??""),[F,T]=r(!0),E=s(async()=>{try{k&&(await(v?.auth.addUser({scanId:n,email:N,name:C,gender:w,height:b})),y?.()),I.capture(x??"",{scanID:n,email:N,height:b,focalLength:S,clothesFit:"0",gender:w})}catch(e){console.log(e)}},[k]),{translate:L}=d(m)||{};o(()=>{(i||l)&&E()},[i,l]);const M=p||i||l;return e(re,{className:"flex h-full w-full flex-col common-ui-main",children:t("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e(Ce,{loader:c?.loader,setShowDrawer:T}),e(se,{open:F,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e("div",{className:"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]",style:{background:c?.style?.base?.backgroundColor},children:t("div",{className:"w-full h-full flex flex-col",children:[e(f,{title:L?.(h.measurementsBeingTaken)}),e("div",{className:"flex items-center justify-center flex-1",children:e("video",{preload:"auto",className:"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e("source",{src:w===q.Male?R:B,type:"video/mp4"})})}),M&&e(g,{className:"!w-[180px] mx-auto",buttonText:L?.(h.next),buttonFunc:()=>{u?.()}})]})})})]})})}const ke=()=>{const{userDetails:n,onRetry:a,isError:r,isSuccess:s,gender:o,scanUniqueKey:c,scanFailsError:i,setScanUniqueKey:l,setIsVideoUploaded:u,isMeasurementAvailable:m,isVideoUploadedCorrect:f,loading:h,showDeniedModal:g,uploadLoading:y,setScanFailsError:v,setScanStartTime:w,resetScan:b,onCustomScanSuccess:S,swan:C,onComplete:N}=d(x),D=p();return r?t("div",{"data-scan-state":"error",children:[e(Ce,{}),e(se,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:!0,onNext:a,gender:o})})]}):s?e("div",{"data-scan-state":"success",children:e(Ie,{isSuccess:!0,onComplete:N})}):h?e("div",{"data-scan-state":"loading",className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:D?.style?.base?.backgroundColor},children:e($,{url:D?.loader,loaderType:"black"})}):g.disabled?e("div",{"data-scan-state":"camera-denied",children:e(U,{})}):y||i||m||f?(y||m||f)&&!i?e("div",{"data-scan-state":"processing",children:e(Ie,{scanId:c,isMeasurementAvailable:m,userDetails:n,isVideoUploadedCorrect:f,onCustomScanSuccess:S,swan:C,onComplete:N})}):t("div",{"data-scan-state":"error-retry",children:[e(Ce,{}),e(se,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:i,onNext:()=>{a?.(),b()},setScanUniqueKey:l,gender:o,setIsVideoUploaded:u})})]}):e("div",{"data-scan-state":"scanning",children:e(Se,{scanID:c,userDetails:n,setIsVideoUploaded:u,setScanFailsError:v,setScanStartTime:w,setScanUniqueKey:l})})},Fe=t=>{const{config:n,onRetry:a,onScanStart:c,onCaptureComplete:i,onUploadStart:d,onUploadEnd:u,onMeasurementSocketStart:m,onMeasurementSocketClose:p,onIntermediateScanSuccess:f,onScanError:h,onScanSuccess:g,onCustomScanSuccess:y,onComplete:v,isError:w,isSuccess:b}=t,S={email:"",shopDomain:"",gender:"male",heightInCm:0,scanType:"",deviceFocalLength:0,deviceModelName:"",sourceTag:"",callbackUrl:null,...t.userDetails??{}},C=t.token??"",{gender:N,scanType:D,shopDomain:I,heightInCm:k,email:E,deviceFocalLength:M,deviceModelName:$,callbackUrl:U,sourceTag:j}=S,A=l(()=>H(C),[C]),[z,V]=r(!1),[R,B]=r(!1),[q,K]=r(!1),[O,W]=r({disabled:!1,message:""}),[ee,te]=r(""),[ne,ae]=r(!1),[re,se]=r(!0),[oe,ce]=r(!1),[ie,le]=r(""),[de,me]=r(T()),{gyroData:pe}=function(e){const[t,n]=r([]),[a,c]=r(!1),i=s(e=>{try{const{alpha:t,beta:a,gamma:r}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:a?.toString()||void 0,gamma:r?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),l=s(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?c(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else c(!0)},[]);return o(()=>(e&&a?window.addEventListener("deviceorientation",i):n([]),()=>{window.removeEventListener("deviceorientation",i)}),[e,a,i]),o(()=>{e&&l()},[e,l]),{gyroData:t}}(oe);J();const fe=s(()=>{le(L()),te(""),V(!1),ae(!1)},[]),he=()=>{me(null),le("")},ge=s(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return F({eventName:`${I}/measurement_success/intermediate`,scanID:ie,status:"success",email:E}),B(!0),void f?.(e);g?.(e),B(!0),he();const t=ie;K(!0),F({eventName:`${I}/measurement_success/fit-view`,scanID:t,status:"success",email:E}),de&&F({eventName:`${I}/scan_completion_time`,scanID:t,status:"success",completionTime:T()-de,email:E})},[D,I,ie]),ye=e=>{K(!1),te(""),B(!1),A.measurement.handleMeasurementSocket({scanId:ie,onPreopen:()=>{Z({eventName:`${I}/webSocket`,scanID:ie,connection:"pre_open",type:"measurement_recommendation",email:E})},onOpen:()=>{m?.(),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"open",type:"measurement_recommendation",email:E})},onClose:()=>{p?.(),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"close",type:"measurement_recommendation",email:E})},onError:e=>{var t;t=e,h?.({...t,message:P(t)}),he(),K(!1),te(t),B(!1),F({eventName:`${I}/measurement_failed/fit-view`,scanID:ie,status:"failed",email:E,message:P(t)}),de&&F({eventName:`${I}/scan_completion_time`,scanID:ie,status:"failed",completionTime:T()-de,email:E}),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"error",type:"measurement_recommendation",email:E})},onSuccess:e=>{Z({eventName:`${I}/webSocket`,scanID:ie,connection:"success",type:"measurement_recommendation",email:E}),ge(e)}})},ve=s(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),a=null!=t?t:await G(e),r=Q({gender:N,focal_length:`${M}`,height:`${k}`,customer_store_url:I,clothes_fit:"0",scan_type:D,callback_url:U,source_tag:j});F({eventName:`${I}/body_scan_meta_data`,scanID:ie,email:E,data:JSON.stringify([...r,{fileSizeInMB:n,video_fps:a||0}])}),d?.();try{await A.fileUpload.uploadFileFrontend({file:e,arrayMetaData:r,scanId:ie,email:E}),await A.fileUpload.setDeviceInfo({model:$,detection:"manual",gyro:pe,scanId:ie}),console.log("video successfully uploaded"),ae(!1),F({eventName:`${I}/scan_success`,scanID:ie,status:"success",email:E,data:JSON.stringify(r)}),F({eventName:"scan finished",scanID:ie,status:"success",email:E}),me(T()),setTimeout(()=>{ae(!0)},3e3)}catch(e){F({eventName:"scan finished",scanID:ie,status:"failed",email:E,message:P(e)}),F({eventName:`${I}/scan_failed`,scanID:ie,status:"failed",email:E,message:P(e),data:JSON.stringify(r)}),te(P(e)),ae(!1),h?.({...e,message:P(e)}),he()}finally{ce(!1),u?.()}},[ie,pe,d,u]),we=s(async()=>{if(+k<152.4||+k>213.36)return void h?.({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await _();e.disabled?(F({eventName:`${I}/camera_activation`,scanID:ie,status:"failed",email:E}),se(!1)):(se(!1),F({eventName:`${I}/camera_activation`,scanID:ie,status:"success",email:E})),W(e),te(""),ae(!1)},[E,ie,le,I]);return o(()=>{w||b||I&&we()},[I,k,w,b]),o(()=>{w||b||ne&&I&&ie&&ye()},[ne,I,ie,w,b]),e("div",{"data-testid":"body-scan-root",children:e(Y,{children:e(X,{config:n,children:e(ue,{children:e(x.Provider,{value:{userDetails:S,onRetry:a,onScanError:h,isError:w,isSuccess:b,onScanSuccess:g,gender:N,scanUniqueKey:ie,scanFailsError:ee,setScanUniqueKey:le,setIsVideoUploaded:ae,isMeasurementAvailable:q,isVideoUploadedCorrect:R,loading:re,showDeniedModal:O,uploadLoading:z,setStartGyro:ce,uploadScanFile:ve,setUploadLoading:V,resetScan:fe,setScanFailsError:te,setScanStartTime:me,onScanStart:c,onCaptureComplete:i,onCustomScanSuccess:y,onComplete:v,swan:A},children:e(ke,{})})})})})})};export{Fe as B};
2
- //# sourceMappingURL=BodyScan-B4-sO3R2.js.map
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),s=require("./Modal-DnweWp6L.js"),n=require("clsx"),a=require("react-webcam"),r=require("lucide-react"),o=require("@mui/material"),c=require("video.js");const i="DESKTOP",l="TAB",u="MOBILE",d=t.createContext(void 0);function m({children:s}){const[n,a]=t.useState([window?.innerWidth,window?.innerHeight]),[r,o]=t.useState(!1),c=()=>{a([window?.innerWidth,window?.innerHeight])};t.useEffect(()=>{c()},[]),t.useLayoutEffect(()=>(window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[c]);let m=i;n[0]>768&&n[0]<1024&&(m=l),n[0]<768&&(m=u);const p=t.useMemo(()=>({size:n,setSize:a,clearInputs:r,setClearInputs:o,media:m}),[n,r,m]);return e.jsx(d.Provider,{value:p,children:s})}var p=t.memo(function({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});var f=t.memo(function({angle:a,countdown:r,isScanning:o,isInTargetRange:c,stabilityScore:i,children:l}){const{translate:u}=t.useContext(s.LanguageContext)||{},d=s.useConfig(),m=t.useCallback(()=>a<80?Math.max(0,Math.min(100,10*(a-60))):a>95?Math.max(0,Math.min(100,10*(105-a))):100,[a]),f=t.useMemo(()=>{if(o)return d?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=m();if(0===e)return d?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return d?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[o,m]),h=t.useCallback((e,t)=>t>70?e?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${d?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),g=t.useCallback((e=!1)=>{const t=m();return o?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]`:h(e,t)},[o,m]),x=t.useCallback((e,t)=>t>70||e?d?.style?.angleDetector?.successAngleTextLightColor:d?.style?.angleDetector?.successAngleTextDarkColor,[]),v=t.useCallback((e=!1)=>{const t=m();return o?d?.style?.angleDetector?.successAngleTextLightColor:x(e,t)},[o,m]),S=r;function y(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return y(),window.addEventListener("resize",y),e.jsxs("div",{className:"flex common-ui-main w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto",style:{backgroundColor:f},"data-testid":"level-screen","data-angle-state":o?"locked":c?"target":"adjusting",children:[e.jsx("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e.jsx("div",{className:"flex justify-start ",children:e.jsx(s.Header,{noTitle:!0})})}),null!==S?e.jsx("div",{className:"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300",style:{border:`2px solid ${v()}`},children:e.jsx("div",{className:`text-[3rem] font-bold text-[${v()}]`,style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:v()},children:S})}):o?e.jsxs("div",{className:"relative flex flex-col items-center justify-center",children:[e.jsx("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e.jsx("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),l]}):e.jsxs("div",{className:n("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",c?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-a)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${v()}`},children:[e.jsx("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${v()}]/80`,style:{backgroundColor:`${v()}B3`}}),e.jsxs("div",{className:n("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",g()),style:{color:v()},children:[e.jsx(p,{size:30}),e.jsxs("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",u?.(s.LanguageKeys.startLevelCheck),e.jsx("br",{})]})]})]}),null!==S&&e.jsx("div",{className:"absolute bottom-[8rem] text-center",children:e.jsx("div",{className:n("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",g()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:v()},children:u?.(s.LanguageKeys.leavePhone)})}),c&&null===S&&!o&&e.jsx("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e.jsx("div",{className:`h-[.375rem] w-full bg-[${v()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${v()}33`},children:e.jsx("div",{className:`h-full bg-[${v()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${a}%`,backgroundColor:`${v()}B3`}})})}),null===S&&!o&&e.jsx("div",{className:"absolute bottom-[5rem] text-center",children:e.jsxs("div",{className:n("text-[1.5rem] font-light",g()),style:{color:v()},children:[Math.round(a),"°"]})}),null===S&&!o&&e.jsx("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e.jsx("div",{className:n("text-[.75rem] opacity-50",g()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:v()},children:u?.(s.LanguageKeys.placePhoneUpright)})})]})});function h({resetScan:n,loadingCam:o,onUserMedia:c,onPause:i,pause:l,onReScan:m,recordingStarted:p,startSendingVideoFrames:f,showPause:h,webcamRef:g,onUserMediaError:x,resetDetector:v,videoConstraints:S,webcamKey:y,faceDone:C,isScanning:b}){const{media:w}=t.useContext(d)||{},{translate:j}=t.useContext(s.LanguageContext)||{};return e.jsxs("div",{className:"App w-screen h-[100vh] relative common-ui-main",style:{background:"#000"},"data-testid":"camera-scan","data-scan-phase":C?"spinning":p?"pose-detecting":b?"starting":"ready",children:[e.jsx("span",{onClick:()=>{n(),v()},className:"fixed right-[20px] top-[20px] z-[999]",children:e.jsx(r.X,{className:"text-[#fff]"})}),e.jsx("div",{className:"w-full h-full overflow-hidden ",children:w===u&&e.jsx(a,{audio:!1,ref:g,screenshotQuality:1,videoConstraints:S,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:c,onUserMediaError:x,style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",objectFit:"cover",zIndex:0}},y)}),e.jsxs("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[h&&e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:s.pauseIcon,buttonText:j?.(s.LanguageKeys.pause),buttonFunc:i,btnSecondary:!0}),l?e.jsx("div",{children:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:j?.(s.LanguageKeys.restart),buttonFunc:m,btnSecondary:!0})}):p?null:e.jsx(s.SpecificButton,{"data-testid":"start-scan-btn",className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(o?"!opacity-50":""),buttonText:j?.(s.LanguageKeys.startScan),buttonFunc:f,disabled:o})]}),e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${s.voiceOverAssetsPath}scanAudioInstructions/silence.mp3`})]})}let g,x=null,v=null,S=null;let y=null;var C=t.memo(function({setIsScanLocked:n,resetDetector:a,scanID:r,setIsVideoUploaded:o,setScanFailsError:c,setScanStartTime:i,setScanUniqueKey:l,userDetails:u}){const{gender:d,heightInCm:m,email:p,shopDomain:f}=u,C=t.useRef(null),b=t.useRef(null),w=t.useRef(null),[j,k]=t.useState([]),[E,N]=t.useState(!0),[D,T]=t.useState(!1),[I,L]=t.useState(!1),[M,F]=t.useState(!0),[_,P]=t.useState(!1),A=t.useRef(null),[R,$]=t.useState(""),[U,O]=t.useState([]),[z,K]=t.useState(""),[q,B]=t.useState(!1),[V,W]=t.useState(!1),[H,G]=t.useState(!1),[J,Q]=t.useState([]),[X,Y]=t.useState(!1),Z=t.useRef(!0),{poseDetector:ee}=function(){const[e,s]=t.useState(0),[n,a]=t.useState(0),[r,o]=t.useState(!1),c=t.useRef(0),i=t.useRef(0),l=t.useRef(!0);async function u(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,s]=await Promise.all([Promise.resolve().then(function(){return require("./pose-detection.esm-Bc8T4UAD.js")}),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);S=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const n={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{v=await S.createDetector(S.SupportedModels.BlazePose,n),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),v=await S.createDetector(S.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),console.log("TFJS detector created successfully")}return!0}catch(e){return console.error("Failed to load TensorFlow dependencies:",e),x=null,!1}}function d(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return t.useEffect(()=>{if(l.current=!0,!v)return x||(x=u()),x.then(e=>{e&&l.current&&o(!0)}),()=>{l.current=!1};o(!0)},[]),t.useEffect(()=>{i.current=e,e>6&&c.current<2&&(a(e=>e+1),s(0))},[e]),t.useEffect(()=>{c.current=n},[n]),{poseDetector:async(e,t)=>{if(!v||!l.current||!t?.current?.video)return;const n=t.current.video;if(!(n.readyState<2))try{const t=await v.estimatePoses(n,{flipHorizontal:!1});if(!t||!t.length)return;const a=t[0].keypoints.slice(11).map(e=>[e.x>0&&e.x<720?e.x:-1,e.y>0&&e.y<1280?e.y:-1,e.score??0]);0!==c.current||d(a)||s(e=>e+1),1===c.current&&d(a)&&s(e=>e+1),2===c.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:r,spinPhase:n,resetDetector:()=>{c.current=0,i.current=0,s(0),a(0)},retryLoading:async()=>{v||x||(x=u(),await x&&l.current&&o(!0))}}}(),te=t.useRef(!0),se=t.useRef(!1),ne=t.useRef(0),ae=t.useRef(0),re=t.useRef(!1),oe=t.useRef(!1),ce=t.useRef(!1),ie=t.useRef(()=>{}),le=t.useRef(()=>{}),ue=t.useRef(null),[de,me]=t.useState([]),[pe,fe]=t.useState(0),[he,ge]=t.useState(s.videoConstraintsExact),{setStartGyro:xe,uploadScanFile:ve,setUploadLoading:Se,swan:ye,onScanStart:Ce,onCaptureComplete:be}=t.useContext(s.ParamsContext),we=()=>{se.current=!1,clearTimeout(g),A.current&&clearTimeout(A.current),l(s.generateUuid()),c(""),Se?.(!1),k([]),w.current=null,N(!0),T(!1),L(!1),F(!0),P(!1),A.current=null,$(""),O([]),K(""),B(!q),xe(!1),s.speechService.stopAudio(),W(!1),G(!1),ne.current=0,ae.current=0,re.current=!1,ce.current=!1,null!==b.current&&b.current.stop(),J.forEach(e=>{b.current&&b.current.removeEventListener("dataavailable",e)}),Q([]),Z.current=!0,Y(!1),o(!1),C.current?.stream&&N(!1)},je=t.useCallback(()=>{setTimeout(()=>{N(!1)},1e3)},[]),ke=t.useCallback(e=>{if(console.log("camera error",e),he===s.videoConstraintsExact)return ge(s.videoConstraintsFallback),void fe(e=>e+1);N(!1)},[he]),Ee=t.useCallback(()=>{Z.current=!1,G(!0),Y(!1),A.current&&clearTimeout(A.current),b.current&&b.current.pause(),s.speechService.stopAudio(),ye.poseDetection.disconnect(),ne.current=0,ae.current=0,re.current=!1,ce.current=!1,b.current&&b.current.stop(),J.forEach(e=>{b.current&&b.current.removeEventListener("dataavailable",e)}),Q([]),clearTimeout(g)},[b,J,s.speechService,Z]),Ne=t.useMemo(()=>s.getPreferredMediaRecorderTypes(),[]),De=s.getRecordingMimeType(de),Te=s.getRecordingExtension(De),Ie=t.useCallback(async()=>{Z.current=!0,await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),G(!1),Y(!1),A.current&&clearTimeout(A.current),T(!1)},[A,s.speechService]),Le=t.useCallback(async()=>{if(!oe.current&&!ue.current){oe.current=!0;try{ue.current=await ye.poseDetection.connect(),s.posthog.capture(`${f}/pose_detection_connected`,{scanID:r,email:p,id:ue.current})}catch(e){console.log(e,"while connecting websocket")}finally{oe.current=!1}}},[r,f,p]),Me=t.useCallback(async()=>{s.rescanSupportCaptureEvent({eventName:`${f}/rescan`,email:p,scanID:r,height:m,gender:d,status:!1}),Z.current=!1,ye.poseDetection.disconnect(),ue.current=null,we(),await Le(),le.current()},[Le,r,p]),Fe=t.useCallback(({data:e})=>{e&&e.size>0&&Z.current&&(k(t=>t.concat(e)),!se.current&&C.current&&(se.current=!0,ee(()=>{Ie(),s.handleScanTimeCapture({eventName:`${f}/tensorFlow`,scanID:r,email:p,message:"recording stopped by tensorflow "})},C)))},[Ie,s.handleScanTimeCapture,f,r,p,C]),_e=t.useCallback(async()=>{const e=U[U.length-1];e&&Z.current&&(await s.speechService.playAudio(s.voiceOverAssetsPath+e),Z.current&&(g=setTimeout(_e,2e3)))},[U,Z]),Pe=t.useCallback(()=>{b&&b.current&&b.current.stop(),T(!0);try{if(C&&C.current&&C.current.stream){const e=C.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();w.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};de[0]&&(t.mimeType=de[0]),b.current=new MediaRecorder(C.current.stream,t),b.current.addEventListener("dataavailable",Fe),b.current.addEventListener("stop",()=>{F(!0)}),Q([...J,Fe]),b.current.start(1e3),F(!1)}}catch(e){console.log("error while using media recorder",e)}},[C,de,Fe,J]),Ae=t.useCallback(async()=>{A.current&&clearTimeout(A.current),Pe(),Z.current&&(A.current=setTimeout(async()=>{Z.current&&(await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),T(!1))},15e3)),L(!0),Z.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}Spin.mp3`)},[Pe,Z,s.speechService]);t.useEffect(()=>{ie.current=Ae},[Ae]);const Re=t.useCallback(({data:e})=>{const t=ye.poseDetection.connected();e.size>0&&t&&(re.current||(re.current=!0,ye.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");s.posthog.capture(`${f}/pose_instruction_received`,{scanID:r,email:p,audio:e.audio,status:e.status,sid:e.sid,counter:ne.current,consecutiveFalse:ae.current,type:"body_scan_instruction"}),!0===e.status&&e.sid===ue.current?(ae.current=0,ne.current<2?(ne.current+=1,1!==ne.current||ce.current?2===ne.current&&t?.paused&&s.speechService.playAudio(s.voiceOverAssetsPath+e.audio):(ce.current=!0,s.speechService.stopAudio(),await s.speechService.playAudio(s.voiceOverAssetsPath+e.audio))):(K(e.audio),clearTimeout(g),ye.poseDetection.disconnect(),re.current=!1,setTimeout(()=>ie.current(),1e3))):(ae.current+=1,ae.current>=3&&(ne.current=0,ce.current=!1),!t?.paused||y&&y?.audioName===e.audio?y?.audioName===e.audio&&t?.paused&&(y&&y.no_of_times_skipped>=y.skipCount?(y.no_of_times_skipped=0,s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)):y&&(y.no_of_times_skipped+=1)):(y={skipCount:2,no_of_times_skipped:0,audioName:e.audio},s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)))}})),C?.current&&null!==C.current.getScreenshot()&&ye.poseDetection.videoEmit({image:C.current.getScreenshot()||"",scanId:r}))},[C,r,ye,s.speechService,f,p]),$e=t.useCallback(async()=>{P(!0),xe(!0),Ce?.(),te.current&&(te.current=!1,s.handleScanTimeCapture({eventName:"scan started",scanID:r,status:"success",email:p})),i(s.getCurrentTimeInSeconds()),N(!0),Z.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}StartScan.mp3`),Z.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`),Z.current&&(P(!1),T(!0),W(!0),Y(!0),je());try{if(C&&C.current&&C.current.stream&&Z.current){const e=C.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();w.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};de[0]&&(t.mimeType=de[0]),Z.current&&(b.current=new MediaRecorder(C.current.stream,t)),Z.current&&b.current&&b.current.addEventListener("dataavailable",Re),Q([...J,Re]),b.current&&b.current.start(1e3),F(!1),Z.current&&(g=setTimeout(_e,2e3))}}catch(e){console.log("error ----------",e)}},[C,de,Re,J,_e,Z,Ce]);return t.useEffect(()=>(f&&(n(!0),Le()),()=>{const e=ue.current;ue.current=null,e&&(ye.poseDetection.disconnect(),s.posthog.capture(`${f}/pose_detection_disconnected`,{scanID:r,email:p,id:e})),J.forEach(e=>{b?.current?.removeEventListener("dataavailable",e)})}),[f]),t.useEffect(()=>{U.push(R)},[R]),t.useEffect(()=>{O([])},[z]),t.useEffect(()=>{const e=j.length&&j.length>0;M||!e||D||!Z.current||H||b&&b.current&&(D||b.current.stop())},[M,D,j,H]),t.useEffect(()=>{const e=j.length&&j.length>0;if(M&&e&&!D&&b&&b.current&&Z.current&&!H&&!D){const e=new File(j,`${r}.${Te}`,{type:De});be?.(),Se?.(!0),c(""),ve?.(e,w.current)}},[M,D,j,H,b,Z]),t.useEffect(()=>{le.current=$e},[$e]),t.useEffect(()=>{const e=s.getSupportedMediaRecorderTypes(Ne,s.videoTypes);me(e)},[Ne]),t.useEffect(()=>{we()},[]),e.jsx(h,{resetDetector:a,resetScan:we,loadingCam:E,onPause:Ee,showRestart:V,pause:H,onReScan:Me,recordingStarted:D,isScanning:_,startSendingVideoFrames:$e,faceDone:I,stopRecording:Ie,showPause:X,webcamRef:C,onUserMedia:je,onUserMediaError:ke,videoConstraints:he,webcamKey:pe})});function b({scanID:s,userDetails:n,setIsVideoUploaded:a,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:c}){const[i,l]=t.useState(90),[u,d]=t.useState(0),[m,p]=t.useState(null),[h,g]=t.useState(!1),[x,v]=t.useState(0),S=t.useRef([]),[y,b]=t.useState(!1),w=i-u,j=w>=80&&w<=95;t.useEffect(()=>{if("undefined"!=typeof window&&window.DeviceOrientationEvent){const e=e=>{if(null!==e.beta){let t=Math.abs(e.beta);null!==e.gamma&&(t*=Math.cos(e.gamma*Math.PI/180)),t=Math.max(0,Math.min(180,t)),l(t)}},t=async()=>{const t=DeviceOrientationEvent;if(t&&"function"==typeof t.requestPermission)try{"granted"===await t.requestPermission()&&window.addEventListener("deviceorientation",e)}catch(e){console.error("Permission error",e)}else window.addEventListener("deviceorientation",e);return()=>{e&&window.removeEventListener("deviceorientation",e)}};document.addEventListener("click",t,{once:!0})}},[]),t.useEffect(()=>{if(S.current=[...S.current.slice(-4),w],S.current.length>=5){const e=Math.max(...S.current)-Math.min(...S.current);v(j&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}j||null===m&&!h||E()},[w,j,m,h]),t.useEffect(()=>{x>=100&&null===m&&!h&&k(),x<50&&null!==m&&E()},[x,m,h]);const k=()=>{p(3);const e=setInterval(()=>{p(t=>null===t||t<=1?(clearInterval(e),g(!0),null):t-1)},1e3)},E=()=>{p(null),y||g(!1)};return e.jsx(f,{angle:w,countdown:m,isScanning:h,isInTargetRange:j,stabilityScore:x,children:h&&e.jsx(C,{setIsScanLocked:b,resetDetector:()=>{l(90),d(0),p(null),g(!1),v(0),b(!1),S.current=[]},scanID:s,userDetails:n,setIsVideoUploaded:a,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:c})})}function w({setShowDrawer:n,config:r,loader:o}){const[c,i]=t.useState({disabled:!1,message:""}),[l,u]=t.useState(!0),d=t.useRef(null),m=t.useCallback(async()=>{const e=await s.checkCameraPermission();i(e),u(!1)},[]);return t.useEffect(()=>{m()},[]),l?e.jsx(s.LoadingScreen,{url:o,loaderType:"black"}):c?.disabled?e.jsx(s.Modal,{config:r,message:c?.message}):e.jsx(a,{audio:!1,ref:d,screenshotQuality:1,videoConstraints:s.videoConstraints,mirrored:!0,onUserMedia:()=>n?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function j({link:n,onReady:a,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const o=t.useRef(null),i=t.useRef(null);let l={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:s.videoPoster};return t.useEffect(()=>{if(!i.current&&n&&o?.current){const e=c(o.current,{...l});e.ready(()=>{i.current=e;const t={...l,sources:[{src:n,type:"application/x-mpegURL"}]};e.autoplay(t.autoplay),e.src(t.sources),a?.(e)})}},[n,o]),t.useEffect(()=>{const e=i.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),i.current=null)}},[i]),e.jsx("div",{className:r,children:e.jsx("video",{ref:o,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function k({scanFailsError:n,onNext:a,gender:c,setScanUniqueKey:i,setIsVideoUploaded:l}){const{translate:u}=t.useContext(s.LanguageContext)||{},d=s.useConfig(),[m,p]=t.useState(!1),f=()=>{p(!m)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"scan-error-message",className:"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:d?.style?.base?.backgroundColor},children:[e.jsx("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e.jsx(s.Header,{noTitle:!0})}),e.jsx("div",{className:"flex-1",children:n&&e.jsxs("div",{className:"px-[1rem]",children:[e.jsx("h2",{className:"text-center",style:{fontFamily:d?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:d?.style?.heading?.headingFontSize||"32px",color:d?.style?.heading?.headingColor||"#000",fontWeight:d?.style?.heading?.headingFontWeight||"normal"},children:u?.(s.LanguageKeys.issueWithScan)}),e.jsx("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:u?.(s.LanguageKeys.reason)}),e.jsx("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:s.handleErrorMessage(n)}),e.jsx("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:f,src:s.VIDEO_POSTER_GENDER_BASED[c],alt:"icon"})]})}),n&&e.jsx("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e.jsx(s.SpecificButton,{"data-testid":"scan-again-btn",disabled:!1,buttonText:u?.(s.LanguageKeys.scanAgain),className:"!shadow-none",buttonFunc:()=>{a?a?.():i?.(s.generateUuid()),l?.(!1)}})})]}),m&&e.jsxs(o.Dialog,{className:"w-screen h-screen video-modal",onClose:f,open:m,children:[e.jsx("div",{className:"flex justifyEnd ",children:e.jsx("span",{className:"closeBtn",onClick:f,children:e.jsx(r.X,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e.jsx("div",{className:"aspect-video object-cover rounded-[20px] ",children:e.jsx(j,{link:c?s.GENDER[c].PRE_LINK:s.GENDER.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function E({scanId:n,userDetails:a,config:r,isVideoUploadedCorrect:c,isMeasurementAvailable:i,onComplete:l,isSuccess:u,onCustomScanSuccess:d,swan:m}){const{gender:p,shopDomain:f,heightInCm:h,deviceFocalLength:g,userName:x,email:v,scanType:S}=a||{},y=[s.CLOTHING_CUSTOM_SCAN,s.CLOTHING_BANNER_SCAN,s.CLOTHING_CUSTOM_FIT_SCAN].includes(S??""),[C,b]=t.useState(!0),j=t.useCallback(async()=>{try{y&&(await(m?.auth.addUser({scanId:n,email:v,name:x,gender:p,height:h})),d?.()),s.posthog.capture(f??"",{scanID:n,email:v,height:h,focalLength:g,clothesFit:"0",gender:p})}catch(e){console.log(e)}},[y]),{translate:k}=t.useContext(s.LanguageContext)||{};t.useEffect(()=>{(c||i)&&j()},[c,i]);const E=u||c||i;return e.jsx(o.Box,{className:"flex h-full w-full flex-col common-ui-main",children:e.jsxs("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e.jsx(w,{loader:r?.loader,setShowDrawer:b}),e.jsx(o.Drawer,{open:C,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e.jsx("div",{className:"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]",style:{background:r?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsx(s.Header,{title:k?.(s.LanguageKeys.measurementsBeingTaken)}),e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx("video",{preload:"auto",className:"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:p===s.GenderType.Male?s.maleMeasurementProgress:s.measurementProgress,type:"video/mp4"})})}),E&&e.jsx(s.SpecificButton,{className:"!w-[180px] mx-auto",buttonText:k?.(s.LanguageKeys.next),buttonFunc:()=>{l?.()}})]})})})]})})}const N=()=>{const{userDetails:n,onRetry:a,isError:r,isSuccess:c,gender:i,scanUniqueKey:l,scanFailsError:u,setScanUniqueKey:d,setIsVideoUploaded:m,isMeasurementAvailable:p,isVideoUploadedCorrect:f,loading:h,showDeniedModal:g,uploadLoading:x,setScanFailsError:v,setScanStartTime:S,resetScan:y,onCustomScanSuccess:C,swan:j,onComplete:N}=t.useContext(s.ParamsContext),D=s.useConfig();return r?e.jsxs("div",{"data-scan-state":"error",children:[e.jsx(w,{}),e.jsx(o.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(k,{scanFailsError:!0,onNext:a,gender:i})})]}):c?e.jsx("div",{"data-scan-state":"success",children:e.jsx(E,{isSuccess:!0,onComplete:N})}):h?e.jsx("div",{"data-scan-state":"loading",className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:D?.style?.base?.backgroundColor},children:e.jsx(s.LoadingScreen,{url:D?.loader,loaderType:"black"})}):g.disabled?e.jsx("div",{"data-scan-state":"camera-denied",children:e.jsx(s.Modal,{})}):x||u||p||f?(x||p||f)&&!u?e.jsx("div",{"data-scan-state":"processing",children:e.jsx(E,{scanId:l,isMeasurementAvailable:p,userDetails:n,isVideoUploadedCorrect:f,onCustomScanSuccess:C,swan:j,onComplete:N})}):e.jsxs("div",{"data-scan-state":"error-retry",children:[e.jsx(w,{}),e.jsx(o.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(k,{scanFailsError:u,onNext:()=>{a?.(),y()},setScanUniqueKey:d,gender:i,setIsVideoUploaded:m})})]}):e.jsx("div",{"data-scan-state":"scanning",children:e.jsx(b,{scanID:l,userDetails:n,setIsVideoUploaded:m,setScanFailsError:v,setScanStartTime:S,setScanUniqueKey:d})})};exports.BodyScan=n=>{const{config:a,onRetry:r,onScanStart:o,onCaptureComplete:c,onUploadStart:i,onUploadEnd:l,onMeasurementSocketStart:u,onMeasurementSocketClose:d,onIntermediateScanSuccess:p,onScanError:f,onScanSuccess:h,onCustomScanSuccess:g,onComplete:x,isError:v,isSuccess:S}=n,y={email:"",shopDomain:"",gender:"male",heightInCm:0,scanType:"",deviceFocalLength:0,deviceModelName:"",sourceTag:"",callbackUrl:null,...n.userDetails??{}},C=n.token??"",{gender:b,scanType:w,shopDomain:j,heightInCm:k,email:E,deviceFocalLength:D,deviceModelName:T,callbackUrl:I,sourceTag:L}=y,M=t.useMemo(()=>s.getSwanService(C),[C]),[F,_]=t.useState(!1),[P,A]=t.useState(!1),[R,$]=t.useState(!1),[U,O]=t.useState({disabled:!1,message:""}),[z,K]=t.useState(""),[q,B]=t.useState(!1),[V,W]=t.useState(!0),[H,G]=t.useState(!1),[J,Q]=t.useState(""),[X,Y]=t.useState(s.getCurrentTimeInSeconds()),{gyroData:Z}=function(e){const[s,n]=t.useState([]),[a,r]=t.useState(!1),o=t.useCallback(e=>{try{const{alpha:t,beta:s,gamma:a}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:s?.toString()||void 0,gamma:a?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),c=t.useCallback(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?r(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else r(!0)},[]);return t.useEffect(()=>(e&&a?window.addEventListener("deviceorientation",o):n([]),()=>{window.removeEventListener("deviceorientation",o)}),[e,a,o]),t.useEffect(()=>{e&&c()},[e,c]),{gyroData:s}}(H);s.usePosthogPageview();const ee=t.useCallback(()=>{Q(s.generateUuid()),K(""),_(!1),B(!1)},[]),te=()=>{Y(null),Q("")},se=t.useCallback(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return s.handleScanTimeCapture({eventName:`${j}/measurement_success/intermediate`,scanID:J,status:"success",email:E}),A(!0),void p?.(e);h?.(e),A(!0),te();const t=J;$(!0),s.handleScanTimeCapture({eventName:`${j}/measurement_success/fit-view`,scanID:t,status:"success",email:E}),X&&s.handleScanTimeCapture({eventName:`${j}/scan_completion_time`,scanID:t,status:"success",completionTime:s.getCurrentTimeInSeconds()-X,email:E})},[w,j,J]),ne=e=>{$(!1),K(""),A(!1),M.measurement.handleMeasurementSocket({scanId:J,onPreopen:()=>{s.handleWebSocketCapture({eventName:`${j}/webSocket`,scanID:J,connection:"pre_open",type:"measurement_recommendation",email:E})},onOpen:()=>{u?.(),s.handleWebSocketCapture({eventName:`${j}/webSocket`,scanID:J,connection:"open",type:"measurement_recommendation",email:E})},onClose:()=>{d?.(),s.handleWebSocketCapture({eventName:`${j}/webSocket`,scanID:J,connection:"close",type:"measurement_recommendation",email:E})},onError:e=>{var t;t=e,f?.({...t,message:s.handleErrorMessage(t)}),te(),$(!1),K(t),A(!1),s.handleScanTimeCapture({eventName:`${j}/measurement_failed/fit-view`,scanID:J,status:"failed",email:E,message:s.handleErrorMessage(t)}),X&&s.handleScanTimeCapture({eventName:`${j}/scan_completion_time`,scanID:J,status:"failed",completionTime:s.getCurrentTimeInSeconds()-X,email:E}),s.handleWebSocketCapture({eventName:`${j}/webSocket`,scanID:J,connection:"error",type:"measurement_recommendation",email:E})},onSuccess:e=>{s.handleWebSocketCapture({eventName:`${j}/webSocket`,scanID:J,connection:"success",type:"measurement_recommendation",email:E}),se(e)}})},ae=t.useCallback(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),a=null!=t?t:await s.getVideoFPS(e),r=s.createObjectMetadataArray({gender:b,focal_length:`${D}`,height:`${k}`,customer_store_url:j,clothes_fit:"0",scan_type:w,callback_url:I,source_tag:L});s.handleScanTimeCapture({eventName:`${j}/body_scan_meta_data`,scanID:J,email:E,data:JSON.stringify([...r,{fileSizeInMB:n,video_fps:a||0}])}),i?.();try{await M.fileUpload.uploadFileFrontend({file:e,arrayMetaData:r,scanId:J,email:E}),await M.fileUpload.setDeviceInfo({model:T,detection:"manual",gyro:Z,scanId:J}),console.log("video successfully uploaded"),B(!1),s.handleScanTimeCapture({eventName:`${j}/scan_success`,scanID:J,status:"success",email:E,data:JSON.stringify(r)}),s.handleScanTimeCapture({eventName:"scan finished",scanID:J,status:"success",email:E}),Y(s.getCurrentTimeInSeconds()),setTimeout(()=>{B(!0)},3e3)}catch(e){s.handleScanTimeCapture({eventName:"scan finished",scanID:J,status:"failed",email:E,message:s.handleErrorMessage(e)}),s.handleScanTimeCapture({eventName:`${j}/scan_failed`,scanID:J,status:"failed",email:E,message:s.handleErrorMessage(e),data:JSON.stringify(r)}),K(s.handleErrorMessage(e)),B(!1),f?.({...e,message:s.handleErrorMessage(e)}),te()}finally{G(!1),l?.()}},[J,Z,i,l]),re=t.useCallback(async()=>{if(+k<152.4||+k>213.36)return void f?.({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await s.checkCameraPermission();e.disabled?(s.handleScanTimeCapture({eventName:`${j}/camera_activation`,scanID:J,status:"failed",email:E}),W(!1)):(W(!1),s.handleScanTimeCapture({eventName:`${j}/camera_activation`,scanID:J,status:"success",email:E})),O(e),K(""),B(!1)},[E,J,Q,j]);return t.useEffect(()=>{v||S||j&&re()},[j,k,v,S]),t.useEffect(()=>{v||S||q&&j&&J&&ne()},[q,j,J,v,S]),e.jsx("div",{"data-testid":"body-scan-root",children:e.jsx(s.LanguageContextProvider,{children:e.jsx(s.ConfigProvider,{config:a,children:e.jsx(m,{children:e.jsx(s.ParamsContext.Provider,{value:{userDetails:y,onRetry:r,onScanError:f,isError:v,isSuccess:S,onScanSuccess:h,gender:b,scanUniqueKey:J,scanFailsError:z,setScanUniqueKey:Q,setIsVideoUploaded:B,isMeasurementAvailable:R,isVideoUploadedCorrect:P,loading:V,showDeniedModal:U,uploadLoading:F,setStartGyro:G,uploadScanFile:ae,setUploadLoading:_,resetScan:ee,setScanFailsError:K,setScanStartTime:Y,onScanStart:o,onCaptureComplete:c,onCustomScanSuccess:g,onComplete:x,swan:M},children:e.jsx(N,{})})})})})})};
2
- //# sourceMappingURL=BodyScan-B87W6dpH.js.map
@@ -1,2 +0,0 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import r,{useState as a,useCallback as s,useEffect as o,createContext as c,useLayoutEffect as i,useMemo as l,useContext as d,useRef as u}from"react";import{L as m,u as p,H as f,b as h,S as g,z as y,a as v,i as w,P as x,o as b,s as S,j as C,k as N,l as D,p as I,A as k,x as F,B as T,q as E,f as L,r as M,D as _,c as $,M as U,v as A,E as j,I as P,V as z,J as V,K as R,N as B,G as q,O as K,Q as O,R as W,h as H,n as J,w as G,T as Q,t as Y,C as X,y as Z}from"./Modal-CbZJwbLZ.js";import ee from"clsx";import te from"react-webcam";import{X as ne}from"lucide-react";import{Dialog as re,Box as ae,Drawer as se}from"@mui/material";import oe from"video.js";const ce="DESKTOP",ie="TAB",le="MOBILE",de=c(void 0);function ue({children:t}){const[n,r]=a([window?.innerWidth,window?.innerHeight]),[s,c]=a(!1),d=()=>{r([window?.innerWidth,window?.innerHeight])};o(()=>{d()},[]),i(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[d]);let u=ce;n[0]>768&&n[0]<1024&&(u=ie),n[0]<768&&(u=le);const m=l(()=>({size:n,setSize:r,clearInputs:s,setClearInputs:c,media:u}),[n,s,u]);return e(de.Provider,{value:m,children:t})}var me=r.memo(function({size:n=16}){return t("svg",{width:n,height:n,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("path",{d:"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});var pe=r.memo(function({angle:n,countdown:r,isScanning:a,isInTargetRange:o,stabilityScore:c,children:i}){const{translate:u}=d(m)||{},g=p(),y=s(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),v=l(()=>{if(a)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=y();if(0===e)return g?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[a,y]),w=s((e,t)=>t>70?e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${g?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),x=s((e=!1)=>{const t=y();return a?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:w(e,t)},[a,y]),b=s((e,t)=>t>70||e?g?.style?.angleDetector?.successAngleTextLightColor:g?.style?.angleDetector?.successAngleTextDarkColor,[]),S=s((e=!1)=>{const t=y();return a?g?.style?.angleDetector?.successAngleTextLightColor:b(e,t)},[a,y]),C=r;function N(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return N(),window.addEventListener("resize",N),t("div",{className:"flex common-ui-main w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto",style:{backgroundColor:v},"data-testid":"level-screen","data-angle-state":a?"locked":o?"target":"adjusting",children:[e("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e("div",{className:"flex justify-start ",children:e(f,{noTitle:!0})})}),null!==C?e("div",{className:"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300",style:{border:`2px solid ${S()}`},children:e("div",{className:`text-[3rem] font-bold text-[${S()}]`,style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:C})}):t("div",a?{className:"relative flex flex-col items-center justify-center",children:[e("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),i]}:{className:ee("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",o?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-n)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${S()}`},children:[e("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${S()}]/80`,style:{backgroundColor:`${S()}B3`}}),t("div",{className:ee("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",x()),style:{color:S()},children:[e(me,{size:30}),t("p",{style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",u?.(h.startLevelCheck),e("br",{})]})]})]}),null!==C&&e("div",{className:"absolute bottom-[8rem] text-center",children:e("div",{className:ee("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",x()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.leavePhone)})}),o&&null===C&&!a&&e("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e("div",{className:`h-[.375rem] w-full bg-[${S()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${S()}33`},children:e("div",{className:`h-full bg-[${S()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${S()}B3`}})})}),null===C&&!a&&e("div",{className:"absolute bottom-[5rem] text-center",children:t("div",{className:ee("text-[1.5rem] font-light",x()),style:{color:S()},children:[Math.round(n),"°"]})}),null===C&&!a&&e("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e("div",{className:ee("text-[.75rem] opacity-50",x()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.placePhoneUpright)})})]})});function fe({resetScan:n,loadingCam:r,onUserMedia:a,onPause:s,pause:o,onReScan:c,recordingStarted:i,startSendingVideoFrames:l,showPause:u,webcamRef:p,onUserMediaError:f,resetDetector:w,videoConstraints:x,webcamKey:b,faceDone:S,isScanning:C}){const{media:N}=d(de)||{},{translate:D}=d(m)||{};return t("div",{className:"App w-screen h-[100vh] relative common-ui-main","data-testid":"camera-scan","data-scan-phase":S?"spinning":i?"pose-detecting":C?"starting":"ready",children:[e("span",{onClick:()=>{n(),w()},className:"fixed right-[20px] top-[20px] z-[999]",children:e(ne,{className:"text-[#fff]"})}),e("div",{className:"w-full h-full overflow-hidden ",children:N===le&&e(te,{audio:!1,ref:p,screenshotQuality:1,videoConstraints:x,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:a,onUserMediaError:f,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},b)}),t("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[u&&e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:y,buttonText:D?.(h.pause),buttonFunc:s,btnSecondary:!0}),o?e("div",{children:e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:D?.(h.restart),buttonFunc:c,btnSecondary:!0})}):i?null:e(g,{"data-testid":"start-scan-btn",className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(r?"!opacity-50":""),buttonText:D?.(h.startScan),buttonFunc:l,disabled:r})]}),e("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${v}scanAudioInstructions/silence.mp3`})]})}let he=null,ge=null,ye=null;let ve,we=null,xe=null;var be=r.memo(function({setIsScanLocked:t,resetDetector:n,scanID:r,setIsVideoUploaded:c,setScanFailsError:i,setScanStartTime:m,setScanUniqueKey:p,userDetails:f}){const{gender:h,heightInCm:g,email:y,shopDomain:_}=f,$=u(null),U=u(null),A=u(null),[j,P]=a([]),[z,V]=a(!0),[R,B]=a(!1),[q,K]=a(!1),[O,W]=a(!0),[H,J]=a(!1),G=u(null),[Q,Y]=a(""),[X,Z]=a([]),[ee,te]=a(""),[ne,re]=a(!1),[ae,se]=a(!1),[oe,ce]=a(!1),[ie,le]=a([]),[de,ue]=a(!1),me=u(!0),{poseDetector:pe}=function(){const[e,t]=a(0),[n,r]=a(0),[s,c]=a(!1),i=u(0),l=u(0),d=u(!0);async function m(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,n]=await Promise.all([import("./pose-detection.esm-DejsYGYM.js"),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);ye=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const r={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{ge=await ye.createDetector(ye.SupportedModels.BlazePose,r),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),ge=await ye.createDetector(ye.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),console.log("TFJS detector created successfully")}return!0}catch(e){return console.error("Failed to load TensorFlow dependencies:",e),he=null,!1}}function p(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return o(()=>{if(d.current=!0,!ge)return he||(he=m()),he.then(e=>{e&&d.current&&c(!0)}),()=>{d.current=!1};c(!0)},[]),o(()=>{l.current=e,e>6&&i.current<2&&(r(e=>e+1),t(0))},[e]),o(()=>{i.current=n},[n]),{poseDetector:async(e,n)=>{if(!ge||!d.current||!n?.current?.video)return;const r=n.current.video;if(!(r.readyState<2))try{const n=await ge.estimatePoses(r,{flipHorizontal:!1});if(!n||!n.length)return;const a=n[0].keypoints.slice(11).map(e=>[e.x>0&&e.x<720?e.x:-1,e.y>0&&e.y<1280?e.y:-1,e.score??0]);0!==i.current||p(a)||t(e=>e+1),1===i.current&&p(a)&&t(e=>e+1),2===i.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:s,spinPhase:n,resetDetector:()=>{i.current=0,l.current=0,t(0),r(0)},retryLoading:async()=>{ge||he||(he=m(),await he&&d.current&&c(!0))}}}(),be=u(!0),Se=u(!1),Ce=u(0),Ne=u(0),De=u(!1),Ie=u(!1),ke=u(!1),Fe=u(!1),Te=u(0),Ee=u(()=>{}),Le=u(()=>{}),[Me,_e]=a([]),[$e,Ue]=a(0),[Ae,je]=a(w),{setStartGyro:Pe,uploadScanFile:ze,setUploadLoading:Ve,swan:Re,onScanStart:Be,onCaptureComplete:qe}=d(x),Ke=()=>{Se.current=!1,clearTimeout(ve),G.current&&clearTimeout(G.current),p(L()),i(""),Ve?.(!1),P([]),A.current=null,V(!0),B(!1),K(!1),W(!0),J(!1),G.current=null,Y(""),Z([]),te(""),re(!ne),Pe(!1),S.stopAudio(),se(!1),ce(!1),Ce.current=0,Ne.current=0,De.current=!1,ke.current=!1,Fe.current=!1,Te.current=0,xe=null,we=null,null!==U.current&&U.current.stop(),ie.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),le([]),me.current=!0,ue(!1),c(!1),$.current?.stream&&V(!1)},Oe=s(()=>{setTimeout(()=>{V(!1)},1e3)},[]),We=s(e=>{if(console.log("camera error",e),Ae===w)return je(b),void Ue(e=>e+1);V(!1)},[Ae]),He=s(()=>{me.current=!1,Fe.current=!1,ce(!0),ue(!1),G.current&&clearTimeout(G.current),U.current&&U.current.pause(),S.stopAudio(),Re.poseDetection.disconnect(),Ce.current=0,Ne.current=0,De.current=!1,ke.current=!1,U.current&&U.current.stop(),ie.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),le([]),clearTimeout(ve)},[U,ie,S,me]),Je=l(()=>C(),[]),Ge=N(Me),Qe=D(Ge),Ye=s(async()=>{me.current=!0,await S.playAudio(`${v}SpotOn.mp3`),ce(!1),ue(!1),G.current&&clearTimeout(G.current),B(!1)},[G,S]),Xe=s(async()=>{if(!Ie.current&&!we){Ie.current=!0;try{we=await Re.poseDetection.connect(),I.capture(`${_}/pose_detection_connected`,{scanID:r,email:y,id:we})}catch(e){console.log(e,"while connecting websocket"),i("Could not connect. Please try again.")}finally{Ie.current=!1}}},[r,_,y,i]),Ze=s(async()=>{k({eventName:`${_}/rescan`,email:y,scanID:r,height:g,gender:h,status:!1}),me.current=!1,Re.poseDetection.disconnect(),we=null,Ke(),await Xe(),Le.current()},[Xe,r,y]),et=s(({data:e})=>{e&&e.size>0&&me.current&&(P(t=>t.concat(e)),!Se.current&&$.current&&(Se.current=!0,pe(()=>{Ye(),F({eventName:`${_}/tensorFlow`,scanID:r,email:y,message:"recording stopped by tensorflow "})},$)))},[Ye,F,_,r,y,$]),tt=s(async()=>{const e=X[X.length-1];e&&me.current&&(await S.playAudio(v+e),me.current&&(ve=setTimeout(tt,2e3)))},[X,me]),nt=s(()=>{U&&U.current&&U.current.stop(),B(!0);try{if($&&$.current&&$.current.stream){const e=$.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();A.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};Me[0]&&(t.mimeType=Me[0]),U.current=new MediaRecorder($.current.stream,t),U.current.addEventListener("dataavailable",et),U.current.addEventListener("stop",()=>{W(!0)}),le([...ie,et]),U.current.start(1e3),W(!1)}}catch(e){console.log("error while using media recorder",e)}},[$,Me,et,ie]),rt=s(async()=>{G.current&&clearTimeout(G.current),nt(),me.current&&(G.current=setTimeout(async()=>{me.current&&(await S.playAudio(`${v}SpotOn.mp3`),B(!1))},15e3)),K(!0),me.current&&await S.playAudio(`${v}Spin.mp3`)},[nt,me,S]);o(()=>{Ee.current=rt},[rt]);const at=s(({data:e})=>{e.size>0&&Re.poseDetection.connected()?(Te.current=0,De.current||(De.current=!0,Re.poseDetection.poseStatus(async e=>{e&&e.audio&&e.audio.length>0&&(I.capture(`${_}/pose_instruction_received`,{scanID:r,email:y,audio:e.audio,status:e.status,sid:e.sid,counter:Ce.current,consecutiveFalse:Ne.current,type:"body_scan_instruction"}),!0===e.status?(Ne.current=0,Ce.current<2?(Ce.current+=1,1!==Ce.current||ke.current?2!==Ce.current||Fe.current||(Fe.current=!0,S.playAudio(v+e.audio).finally(()=>{Fe.current=!1})):(ke.current=!0,S.stopAudio(),Fe.current=!0,await S.playAudio(v+e.audio),Fe.current=!1)):(te(e.audio),clearTimeout(ve),Re.poseDetection.disconnect(),De.current=!1,setTimeout(()=>Ee.current(),1e3))):(Ne.current+=1,Ne.current>=3&&(Ce.current=0,ke.current=!1),Fe.current||xe&&xe?.audioName===e.audio?xe?.audioName!==e.audio||Fe.current||(xe&&xe.no_of_times_skipped>=xe.skipCount?(xe.no_of_times_skipped=0,Fe.current=!0,S.playAudio(v+e.audio).finally(()=>{Fe.current=!1})):xe&&(xe.no_of_times_skipped+=1)):(xe={skipCount:2,no_of_times_skipped:0,audioName:e.audio},Fe.current=!0,S.playAudio(v+e.audio).finally(()=>{Fe.current=!1}))))})),$?.current&&null!==$.current.getScreenshot()&&Re.poseDetection.videoEmit({image:$.current.getScreenshot()||"",scanId:r})):e.size>0&&(Te.current+=1,Te.current>=5&&(me.current=!1,S.stopAudio(),Re.poseDetection.disconnect(),U.current&&U.current.stop(),i("Connection lost during scan. Please try again.")))},[$,r,Re,we,S,_,y,i]),st=s(async()=>{J(!0),Pe(!0),Be?.(),be.current&&(be.current=!1,F({eventName:"scan started",scanID:r,status:"success",email:y})),m(T()),V(!0),me.current&&await S.playAudio(`${v}StartScan.mp3`),me.current&&await S.playAudio(`${v}LiftArmsAndHoldAtHip.mp3`),me.current&&(J(!1),B(!0),se(!0),ue(!0),Oe());try{if($&&$.current&&$.current.stream&&me.current){const e=$.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();A.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};Me[0]&&(t.mimeType=Me[0]),me.current&&(U.current=new MediaRecorder($.current.stream,t)),me.current&&U.current&&U.current.addEventListener("dataavailable",at),le([...ie,at]),U.current&&U.current.start(1e3),W(!1),me.current&&(ve=setTimeout(tt,2e3))}}catch(e){console.log("error ----------",e)}},[$,Me,at,ie,tt,me,Be]);return o(()=>(_&&(t(!0),Xe()),()=>{const e=we;we=null,e&&(Re.poseDetection.disconnect(),I.capture(`${_}/pose_detection_disconnected`,{scanID:r,email:y,id:e})),ie.forEach(e=>{U?.current?.removeEventListener("dataavailable",e)})}),[_]),o(()=>{X.push(Q)},[Q]),o(()=>{Z([])},[ee]),o(()=>{const e=j.length&&j.length>0;O||!e||R||!me.current||oe||U&&U.current&&(R||U.current.stop())},[O,R,j,oe]),o(()=>{const e=j.length&&j.length>0;if(O&&e&&!R&&U&&U.current&&me.current&&!oe&&!R){const e=new File(j,`${r}.${Qe}`,{type:Ge});qe?.(),Ve?.(!0),i(""),ze?.(e,A.current)}},[O,R,j,oe,U,me]),o(()=>{Le.current=st},[st]),o(()=>{const e=E(Je,M);_e(e)},[Je]),o(()=>{Ke()},[]),e(fe,{resetDetector:n,resetScan:Ke,loadingCam:z,onPause:He,showRestart:ae,pause:oe,onReScan:Ze,recordingStarted:R,isScanning:H,startSendingVideoFrames:st,faceDone:q,stopRecording:Ye,showPause:de,webcamRef:$,onUserMedia:Oe,onUserMediaError:We,videoConstraints:Ae,webcamKey:$e})});function Se({scanID:t,userDetails:n,setIsVideoUploaded:r,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i}){const[l,d]=a(90),[m,p]=a(0),[f,h]=a(null),[g,y]=a(!1),[v,w]=a(0),x=u([]),[b,S]=a(!1),C=l-m,N=C>=80&&C<=95;o(()=>{if("undefined"!=typeof window&&window.DeviceOrientationEvent){const e=e=>{if(null!==e.beta){let t=Math.abs(e.beta);null!==e.gamma&&(t*=Math.cos(e.gamma*Math.PI/180)),t=Math.max(0,Math.min(180,t)),d(t)}},t=async()=>{const t=DeviceOrientationEvent;if(t&&"function"==typeof t.requestPermission)try{"granted"===await t.requestPermission()&&window.addEventListener("deviceorientation",e)}catch(e){console.error("Permission error",e)}else window.addEventListener("deviceorientation",e);return()=>{e&&window.removeEventListener("deviceorientation",e)}};document.addEventListener("click",t,{once:!0})}},[]),o(()=>{if(x.current=[...x.current.slice(-4),C],x.current.length>=5){const e=Math.max(...x.current)-Math.min(...x.current);w(N&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}N||null===f&&!g||I()},[C,N,f,g]),o(()=>{v>=100&&null===f&&!g&&D(),v<50&&null!==f&&I()},[v,f,g]);const D=()=>{h(3);const e=setInterval(()=>{h(t=>null===t||t<=1?(clearInterval(e),y(!0),null):t-1)},1e3)},I=()=>{h(null),b||y(!1)};return e(pe,{angle:C,countdown:f,isScanning:g,isInTargetRange:N,stabilityScore:v,children:g&&e(be,{setIsScanLocked:S,resetDetector:()=>{d(90),p(0),h(null),y(!1),w(0),S(!1),x.current=[]},scanID:t,userDetails:n,setIsVideoUploaded:r,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i})})}function Ce({setShowDrawer:t,config:n,loader:r}){const[c,i]=a({disabled:!1,message:""}),[l,d]=a(!0),m=u(null),p=s(async()=>{const e=await _();i(e),d(!1)},[]);return o(()=>{p()},[]),l?e($,{url:r,loaderType:"black"}):c?.disabled?e(U,{config:n,message:c?.message}):e(te,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:A,mirrored:!0,onUserMedia:()=>t?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function Ne({link:t,onReady:n,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const a=u(null),s=u(null);let c={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:j};return o(()=>{if(!s.current&&t&&a?.current){const e=oe(a.current,{...c});e.ready(()=>{s.current=e;const r={...c,sources:[{src:t,type:"application/x-mpegURL"}]};e.autoplay(r.autoplay),e.src(r.sources),n?.(e)})}},[t,a]),o(()=>{const e=s.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),s.current=null)}},[s]),e("div",{className:r,children:e("video",{ref:a,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function De({scanFailsError:r,onNext:s,gender:o,setScanUniqueKey:c,setIsVideoUploaded:i}){const{translate:l}=d(m)||{},u=p(),[y,v]=a(!1),w=()=>{v(!y)};return t(n,{children:[t("div",{"data-testid":"scan-error-message",className:"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:u?.style?.base?.backgroundColor},children:[e("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e(f,{noTitle:!0})}),e("div",{className:"flex-1",children:r&&t("div",{className:"px-[1rem]",children:[e("h2",{className:"text-center",style:{fontFamily:u?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:u?.style?.heading?.headingFontSize||"32px",color:u?.style?.heading?.headingColor||"#000",fontWeight:u?.style?.heading?.headingFontWeight||"normal"},children:l?.(h.issueWithScan)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:l?.(h.reason)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:P(r)}),e("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:w,src:z[o],alt:"icon"})]})}),r&&e("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e(g,{"data-testid":"scan-again-btn",disabled:!1,buttonText:l?.(h.scanAgain),className:"!shadow-none",buttonFunc:()=>{s?s?.():c?.(L()),i?.(!1)}})})]}),y&&t(re,{className:"w-screen h-screen video-modal",onClose:w,open:y,children:[e("div",{className:"flex justifyEnd ",children:e("span",{className:"closeBtn",onClick:w,children:e(ne,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e("div",{className:"aspect-video object-cover rounded-[20px] ",children:e(Ne,{link:o?V[o].PRE_LINK:V.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function Ie({scanId:n,userDetails:r,config:c,isVideoUploadedCorrect:i,isMeasurementAvailable:l,onComplete:u,isSuccess:p,onCustomScanSuccess:y,swan:v}){const{gender:w,shopDomain:x,heightInCm:b,deviceFocalLength:S,userName:C,email:N,scanType:D}=r||{},k=[K,O,W].includes(D??""),[F,T]=a(!0),E=s(async()=>{try{k&&(await(v?.auth.addUser({scanId:n,email:N,name:C,gender:w,height:b})),y?.()),I.capture(x??"",{scanID:n,email:N,height:b,focalLength:S,clothesFit:"0",gender:w})}catch(e){console.log(e)}},[k]),{translate:L}=d(m)||{};o(()=>{(i||l)&&E()},[i,l]);const M=p||i||l;return e(ae,{className:"flex h-full w-full flex-col common-ui-main",children:t("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e(Ce,{loader:c?.loader,setShowDrawer:T}),e(se,{open:F,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e("div",{className:"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]",style:{background:c?.style?.base?.backgroundColor},children:t("div",{className:"w-full h-full flex flex-col",children:[e(f,{title:L?.(h.measurementsBeingTaken)}),e("div",{className:"flex items-center justify-center flex-1",children:e("video",{preload:"auto",className:"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e("source",{src:w===q.Male?R:B,type:"video/mp4"})})}),M&&e(g,{className:"!w-[180px] mx-auto",buttonText:L?.(h.next),buttonFunc:()=>{u?.()}})]})})})]})})}const ke=()=>{const{userDetails:n,onRetry:r,isError:a,isSuccess:s,gender:o,scanUniqueKey:c,scanFailsError:i,setScanUniqueKey:l,setIsVideoUploaded:u,isMeasurementAvailable:m,isVideoUploadedCorrect:f,loading:h,showDeniedModal:g,uploadLoading:y,setScanFailsError:v,setScanStartTime:w,resetScan:b,onCustomScanSuccess:S,swan:C,onComplete:N}=d(x),D=p();return a?t("div",{"data-scan-state":"error",children:[e(Ce,{}),e(se,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:!0,onNext:r,gender:o})})]}):s?e("div",{"data-scan-state":"success",children:e(Ie,{isSuccess:!0,onComplete:N})}):h?e("div",{"data-scan-state":"loading",className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:D?.style?.base?.backgroundColor},children:e($,{url:D?.loader,loaderType:"black"})}):g.disabled?e("div",{"data-scan-state":"camera-denied",children:e(U,{})}):y||i||m||f?(y||m||f)&&!i?e("div",{"data-scan-state":"processing",children:e(Ie,{scanId:c,isMeasurementAvailable:m,userDetails:n,isVideoUploadedCorrect:f,onCustomScanSuccess:S,swan:C,onComplete:N})}):t("div",{"data-scan-state":"error-retry",children:[e(Ce,{}),e(se,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:i,onNext:()=>{r?.(),b()},setScanUniqueKey:l,gender:o,setIsVideoUploaded:u})})]}):e("div",{"data-scan-state":"scanning",children:e(Se,{scanID:c,userDetails:n,setIsVideoUploaded:u,setScanFailsError:v,setScanStartTime:w,setScanUniqueKey:l})})},Fe=t=>{const{config:n,onRetry:r,onScanStart:c,onCaptureComplete:i,onUploadStart:d,onUploadEnd:u,onMeasurementSocketStart:m,onMeasurementSocketClose:p,onIntermediateScanSuccess:f,onScanError:h,onScanSuccess:g,onCustomScanSuccess:y,onComplete:v,isError:w,isSuccess:b}=t,S={email:"",shopDomain:"",gender:"male",heightInCm:0,scanType:"",deviceFocalLength:0,deviceModelName:"",sourceTag:"",callbackUrl:null,...t.userDetails??{}},C=t.token??"",{gender:N,scanType:D,shopDomain:I,heightInCm:k,email:E,deviceFocalLength:M,deviceModelName:$,callbackUrl:U,sourceTag:A}=S,j=l(()=>H(C),[C]),[z,V]=a(!1),[R,B]=a(!1),[q,K]=a(!1),[O,W]=a({disabled:!1,message:""}),[ee,te]=a(""),[ne,re]=a(!1),[ae,se]=a(!0),[oe,ce]=a(!1),[ie,le]=a(""),[de,me]=a(T()),{gyroData:pe}=function(e){const[t,n]=a([]),[r,c]=a(!1),i=s(e=>{try{const{alpha:t,beta:r,gamma:a}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:r?.toString()||void 0,gamma:a?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),l=s(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?c(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else c(!0)},[]);return o(()=>(e&&r?window.addEventListener("deviceorientation",i):n([]),()=>{window.removeEventListener("deviceorientation",i)}),[e,r,i]),o(()=>{e&&l()},[e,l]),{gyroData:t}}(oe);J();const fe=s(()=>{le(L()),te(""),V(!1),re(!1)},[]),he=()=>{me(null),le("")},ge=s(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return F({eventName:`${I}/measurement_success/intermediate`,scanID:ie,status:"success",email:E}),B(!0),void f?.(e);g?.(e),B(!0),he();const t=ie;K(!0),F({eventName:`${I}/measurement_success/fit-view`,scanID:t,status:"success",email:E}),de&&F({eventName:`${I}/scan_completion_time`,scanID:t,status:"success",completionTime:T()-de,email:E})},[D,I,ie]),ye=e=>{K(!1),te(""),B(!1),j.measurement.handleMeasurementSocket({scanId:ie,onPreopen:()=>{Z({eventName:`${I}/webSocket`,scanID:ie,connection:"pre_open",type:"measurement_recommendation",email:E})},onOpen:()=>{m?.(),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"open",type:"measurement_recommendation",email:E})},onClose:()=>{p?.(),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"close",type:"measurement_recommendation",email:E})},onError:e=>{var t;t=e,h?.({...t,message:P(t)}),he(),K(!1),te(t),B(!1),F({eventName:`${I}/measurement_failed/fit-view`,scanID:ie,status:"failed",email:E,message:P(t)}),de&&F({eventName:`${I}/scan_completion_time`,scanID:ie,status:"failed",completionTime:T()-de,email:E}),Z({eventName:`${I}/webSocket`,scanID:ie,connection:"error",type:"measurement_recommendation",email:E})},onSuccess:e=>{Z({eventName:`${I}/webSocket`,scanID:ie,connection:"success",type:"measurement_recommendation",email:E}),ge(e)}})},ve=s(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),r=null!=t?t:await G(e),a=Q({gender:N,focal_length:`${M}`,height:`${k}`,customer_store_url:I,clothes_fit:"0",scan_type:D,callback_url:U,source_tag:A});F({eventName:`${I}/body_scan_meta_data`,scanID:ie,email:E,data:JSON.stringify([...a,{fileSizeInMB:n,video_fps:r||0}])}),d?.();try{await j.fileUpload.uploadFileFrontend({file:e,arrayMetaData:a,scanId:ie,email:E}),await j.fileUpload.setDeviceInfo({model:$,detection:"manual",gyro:pe,scanId:ie}),console.log("video successfully uploaded"),re(!1),F({eventName:`${I}/scan_success`,scanID:ie,status:"success",email:E,data:JSON.stringify(a)}),F({eventName:"scan finished",scanID:ie,status:"success",email:E}),me(T()),setTimeout(()=>{re(!0)},3e3)}catch(e){F({eventName:"scan finished",scanID:ie,status:"failed",email:E,message:P(e)}),F({eventName:`${I}/scan_failed`,scanID:ie,status:"failed",email:E,message:P(e),data:JSON.stringify(a)}),te(P(e)),re(!1),h?.({...e,message:P(e)}),he()}finally{ce(!1),u?.()}},[ie,pe,d,u]),we=s(async()=>{if(+k<152.4||+k>213.36)return void h?.({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await _();e.disabled?(F({eventName:`${I}/camera_activation`,scanID:ie,status:"failed",email:E}),se(!1)):(se(!1),F({eventName:`${I}/camera_activation`,scanID:ie,status:"success",email:E})),W(e),te(""),re(!1)},[E,ie,le,I]);return o(()=>{w||b||I&&we()},[I,k,w,b]),o(()=>{w||b||ne&&I&&ie&&ye()},[ne,I,ie,w,b]),e("div",{"data-testid":"body-scan-root",children:e(Y,{children:e(X,{config:n,children:e(ue,{children:e(x.Provider,{value:{userDetails:S,onRetry:r,onScanError:h,isError:w,isSuccess:b,onScanSuccess:g,gender:N,scanUniqueKey:ie,scanFailsError:ee,setScanUniqueKey:le,setIsVideoUploaded:re,isMeasurementAvailable:q,isVideoUploadedCorrect:R,loading:ae,showDeniedModal:O,uploadLoading:z,setStartGyro:ce,uploadScanFile:ve,setUploadLoading:V,resetScan:fe,setScanFailsError:te,setScanStartTime:me,onScanStart:c,onCaptureComplete:i,onCustomScanSuccess:y,onComplete:v,swan:j},children:e(ke,{})})})})})})};export{Fe as B};
2
- //# sourceMappingURL=BodyScan-B8pglBAp.js.map