@swan-admin/swan-web-component 1.0.73 → 1.0.74

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.
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react"),o=require("react/jsx-runtime"),r=require("./Header-Bf7ClSfT.js");function t(e){var o=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,Object.freeze(o)}var i=t(e);let n=0;const s={...i}.useId;function p(e){return r.generateUtilityClass("MuiSvgIcon",e)}r.generateUtilityClasses("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const c=r.styled("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(e,o)=>{const{ownerState:t}=e;return[o.root,"inherit"!==t.color&&o[`color${r.capitalize(t.color)}`],o[`fontSize${r.capitalize(t.fontSize)}`]]}})(r.memoTheme(({theme:e})=>({userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:e.transitions?.create?.("fill",{duration:(e.vars??e).transitions?.duration?.shorter}),variants:[{props:e=>!e.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:e.typography?.pxToRem?.(20)||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:e.typography?.pxToRem?.(24)||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:e.typography?.pxToRem?.(35)||"2.1875rem"}},...Object.entries((e.vars??e).palette).filter(([,e])=>e&&e.main).map(([o])=>({props:{color:o},style:{color:(e.vars??e).palette?.[o]?.main}})),{props:{color:"action"},style:{color:(e.vars??e).palette?.action?.active}},{props:{color:"disabled"},style:{color:(e.vars??e).palette?.action?.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}))),l=i.forwardRef(function(e,t){const n=r.useDefaultProps({props:e,name:"MuiSvgIcon"}),{children:s,className:l,color:a="inherit",component:f="svg",fontSize:u="medium",htmlColor:y,inheritViewBox:m=!1,titleAccess:d,viewBox:h="0 0 24 24",...v}=n,S=i.isValidElement(s)&&"svg"===s.type,g={...n,color:a,component:f,fontSize:u,instanceFontSize:e.fontSize,inheritViewBox:m,viewBox:h,hasSvgAsChild:S},T={};m||(T.viewBox=h);const P=(e=>{const{color:o,fontSize:t,classes:i}=e,n={root:["root","inherit"!==o&&`color${r.capitalize(o)}`,`fontSize${r.capitalize(t)}`]};return r.composeClasses(n,p,i)})(g);return o.jsxs(c,{as:f,className:r.clsx(P.root,l),focusable:"false",color:y,"aria-hidden":!d||void 0,role:d?"img":void 0,ref:t,...T,...v,...S&&s.props,ownerState:g,children:[S?s.props.children:s,d?o.jsx("title",{children:d}):null]})});"production"!==process.env.NODE_ENV&&(l.propTypes={children:r.PropTypes.node,classes:r.PropTypes.object,className:r.PropTypes.string,color:r.PropTypes.oneOfType([r.PropTypes.oneOf(["inherit","action","disabled","primary","secondary","error","info","success","warning"]),r.PropTypes.string]),component:r.PropTypes.elementType,fontSize:r.PropTypes.oneOfType([r.PropTypes.oneOf(["inherit","large","medium","small"]),r.PropTypes.string]),htmlColor:r.PropTypes.string,inheritViewBox:r.PropTypes.bool,shapeRendering:r.PropTypes.string,sx:r.PropTypes.oneOfType([r.PropTypes.arrayOf(r.PropTypes.oneOfType([r.PropTypes.func,r.PropTypes.object,r.PropTypes.bool])),r.PropTypes.func,r.PropTypes.object]),titleAccess:r.PropTypes.string,viewBox:r.PropTypes.string}),l.muiName="SvgIcon",exports.createSvgIcon=function(e,r){function t(t,i){return o.jsx(l,{"data-testid":"production"!==process.env.NODE_ENV?`${r}Icon`:void 0,ref:i,...t,children:e})}return"production"!==process.env.NODE_ENV&&(t.displayName=`${r}Icon`),t.muiName=l.muiName,i.memo(i.forwardRef(t))},exports.useId=function(e){if(void 0!==s){const o=s();return e??o}return function(e){const[o,r]=i.useState(e),t=e||o;return i.useEffect(()=>{null==o&&(n+=1,r(`mui-${n}`))},[o]),t}(e)};
2
+ //# sourceMappingURL=createSvgIcon-CSumJvXf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSvgIcon-CSumJvXf.js","sources":["../../node_modules/@mui/utils/esm/useId/useId.js","../../node_modules/@mui/material/esm/SvgIcon/svgIconClasses.js","../../node_modules/@mui/material/esm/SvgIcon/SvgIcon.js","../../node_modules/@mui/material/esm/utils/createSvgIcon.js"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nlet globalId = 0;\n\n// TODO React 17: Remove `useGlobalId` once React 17 support is removed\nfunction useGlobalId(idOverride) {\n const [defaultId, setDefaultId] = React.useState(idOverride);\n const id = idOverride || defaultId;\n React.useEffect(() => {\n if (defaultId == null) {\n // Fallback to this default id when possible.\n // Use the incrementing value for client-side rendering only.\n // We can't use it server-side.\n // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem\n globalId += 1;\n setDefaultId(`mui-${globalId}`);\n }\n }, [defaultId]);\n return id;\n}\n\n// See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why\nconst safeReact = {\n ...React\n};\nconst maybeReactUseId = safeReact.useId;\n\n/**\n *\n * @example <div id={useId()} />\n * @param idOverride\n * @returns {string}\n */\nexport default function useId(idOverride) {\n // React.useId() is only available from React 17.0.0.\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? reactId;\n }\n\n // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.\n return useGlobalId(idOverride);\n}","import generateUtilityClasses from '@mui/utils/generateUtilityClasses';\nimport generateUtilityClass from '@mui/utils/generateUtilityClass';\nexport function getSvgIconUtilityClass(slot) {\n return generateUtilityClass('MuiSvgIcon', slot);\n}\nconst svgIconClasses = generateUtilityClasses('MuiSvgIcon', ['root', 'colorPrimary', 'colorSecondary', 'colorAction', 'colorError', 'colorDisabled', 'fontSizeInherit', 'fontSizeSmall', 'fontSizeMedium', 'fontSizeLarge']);\nexport default svgIconClasses;","'use client';\n\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport clsx from 'clsx';\nimport composeClasses from '@mui/utils/composeClasses';\nimport capitalize from \"../utils/capitalize.js\";\nimport { styled } from \"../zero-styled/index.js\";\nimport memoTheme from \"../utils/memoTheme.js\";\nimport { useDefaultProps } from \"../DefaultPropsProvider/index.js\";\nimport { getSvgIconUtilityClass } from \"./svgIconClasses.js\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst useUtilityClasses = ownerState => {\n const {\n color,\n fontSize,\n classes\n } = ownerState;\n const slots = {\n root: ['root', color !== 'inherit' && `color${capitalize(color)}`, `fontSize${capitalize(fontSize)}`]\n };\n return composeClasses(slots, getSvgIconUtilityClass, classes);\n};\nconst SvgIconRoot = styled('svg', {\n name: 'MuiSvgIcon',\n slot: 'Root',\n overridesResolver: (props, styles) => {\n const {\n ownerState\n } = props;\n return [styles.root, ownerState.color !== 'inherit' && styles[`color${capitalize(ownerState.color)}`], styles[`fontSize${capitalize(ownerState.fontSize)}`]];\n }\n})(memoTheme(({\n theme\n}) => ({\n userSelect: 'none',\n width: '1em',\n height: '1em',\n display: 'inline-block',\n flexShrink: 0,\n transition: theme.transitions?.create?.('fill', {\n duration: (theme.vars ?? theme).transitions?.duration?.shorter\n }),\n variants: [{\n props: props => !props.hasSvgAsChild,\n style: {\n // the <svg> will define the property that has `currentColor`\n // for example heroicons uses fill=\"none\" and stroke=\"currentColor\"\n fill: 'currentColor'\n }\n }, {\n props: {\n fontSize: 'inherit'\n },\n style: {\n fontSize: 'inherit'\n }\n }, {\n props: {\n fontSize: 'small'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(20) || '1.25rem'\n }\n }, {\n props: {\n fontSize: 'medium'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(24) || '1.5rem'\n }\n }, {\n props: {\n fontSize: 'large'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(35) || '2.1875rem'\n }\n },\n // TODO v5 deprecate color prop, v6 remove for sx\n ...Object.entries((theme.vars ?? theme).palette).filter(([, value]) => value && value.main).map(([color]) => ({\n props: {\n color\n },\n style: {\n color: (theme.vars ?? theme).palette?.[color]?.main\n }\n })), {\n props: {\n color: 'action'\n },\n style: {\n color: (theme.vars ?? theme).palette?.action?.active\n }\n }, {\n props: {\n color: 'disabled'\n },\n style: {\n color: (theme.vars ?? theme).palette?.action?.disabled\n }\n }, {\n props: {\n color: 'inherit'\n },\n style: {\n color: undefined\n }\n }]\n})));\nconst SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(inProps, ref) {\n const props = useDefaultProps({\n props: inProps,\n name: 'MuiSvgIcon'\n });\n const {\n children,\n className,\n color = 'inherit',\n component = 'svg',\n fontSize = 'medium',\n htmlColor,\n inheritViewBox = false,\n titleAccess,\n viewBox = '0 0 24 24',\n ...other\n } = props;\n const hasSvgAsChild = /*#__PURE__*/React.isValidElement(children) && children.type === 'svg';\n const ownerState = {\n ...props,\n color,\n component,\n fontSize,\n instanceFontSize: inProps.fontSize,\n inheritViewBox,\n viewBox,\n hasSvgAsChild\n };\n const more = {};\n if (!inheritViewBox) {\n more.viewBox = viewBox;\n }\n const classes = useUtilityClasses(ownerState);\n return /*#__PURE__*/_jsxs(SvgIconRoot, {\n as: component,\n className: clsx(classes.root, className),\n focusable: \"false\",\n color: htmlColor,\n \"aria-hidden\": titleAccess ? undefined : true,\n role: titleAccess ? 'img' : undefined,\n ref: ref,\n ...more,\n ...other,\n ...(hasSvgAsChild && children.props),\n ownerState: ownerState,\n children: [hasSvgAsChild ? children.props.children : children, titleAccess ? /*#__PURE__*/_jsx(\"title\", {\n children: titleAccess\n }) : null]\n });\n});\nprocess.env.NODE_ENV !== \"production\" ? SvgIcon.propTypes /* remove-proptypes */ = {\n // ┌────────────────────────────── Warning ──────────────────────────────┐\n // │ These PropTypes are generated from the TypeScript type definitions. │\n // │ To update them, edit the d.ts file and run `pnpm proptypes`. │\n // └─────────────────────────────────────────────────────────────────────┘\n /**\n * Node passed into the SVG element.\n */\n children: PropTypes.node,\n /**\n * Override or extend the styles applied to the component.\n */\n classes: PropTypes.object,\n /**\n * @ignore\n */\n className: PropTypes.string,\n /**\n * The color of the component.\n * It supports both default and custom theme colors, which can be added as shown in the\n * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).\n * You can use the `htmlColor` prop to apply a color attribute to the SVG element.\n * @default 'inherit'\n */\n color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'action', 'disabled', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),\n /**\n * The component used for the root node.\n * Either a string to use a HTML element or a component.\n */\n component: PropTypes.elementType,\n /**\n * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.\n * @default 'medium'\n */\n fontSize: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), PropTypes.string]),\n /**\n * Applies a color attribute to the SVG element.\n */\n htmlColor: PropTypes.string,\n /**\n * If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox`\n * prop will be ignored.\n * Useful when you want to reference a custom `component` and have `SvgIcon` pass that\n * `component`'s viewBox to the root node.\n * @default false\n */\n inheritViewBox: PropTypes.bool,\n /**\n * The shape-rendering attribute. The behavior of the different options is described on the\n * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/shape-rendering).\n * If you are having issues with blurry icons you should investigate this prop.\n */\n shapeRendering: PropTypes.string,\n /**\n * The system prop that allows defining system overrides as well as additional CSS styles.\n */\n sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),\n /**\n * Provides a human-readable title for the element that contains it.\n * https://www.w3.org/TR/SVG-access/#Equivalent\n */\n titleAccess: PropTypes.string,\n /**\n * Allows you to redefine what the coordinates without units mean inside an SVG element.\n * For example, if the SVG element is 500 (width) by 200 (height),\n * and you pass viewBox=\"0 0 50 20\",\n * this means that the coordinates inside the SVG will go from the top left corner (0,0)\n * to bottom right (50,20) and each unit will be worth 10px.\n * @default '0 0 24 24'\n */\n viewBox: PropTypes.string\n} : void 0;\nSvgIcon.muiName = 'SvgIcon';\nexport default SvgIcon;","'use client';\n\nimport * as React from 'react';\nimport SvgIcon from \"../SvgIcon/index.js\";\n\n/**\n * Private module reserved for @mui packages.\n */\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function createSvgIcon(path, displayName) {\n function Component(props, ref) {\n return /*#__PURE__*/_jsx(SvgIcon, {\n \"data-testid\": process.env.NODE_ENV !== 'production' ? `${displayName}Icon` : undefined,\n ref: ref,\n ...props,\n children: path\n });\n }\n if (process.env.NODE_ENV !== 'production') {\n // Need to set `displayName` on the inner component for React.memo.\n // React prior to 16.14 ignores `displayName` on the wrapper.\n Component.displayName = `${displayName}Icon`;\n }\n Component.muiName = SvgIcon.muiName;\n return /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(Component));\n}"],"names":["globalId","maybeReactUseId","React","useId","getSvgIconUtilityClass","slot","generateUtilityClass","generateUtilityClasses","SvgIconRoot","styled","name","overridesResolver","props","styles","ownerState","root","color","capitalize","fontSize","memoTheme","theme","userSelect","width","height","display","flexShrink","transition","transitions","create","duration","vars","shorter","variants","hasSvgAsChild","style","fill","typography","pxToRem","Object","entries","palette","filter","value","main","map","action","active","disabled","undefined","SvgIcon","forwardRef","inProps","ref","useDefaultProps","children","className","component","htmlColor","inheritViewBox","titleAccess","viewBox","other","isValidElement","type","instanceFontSize","more","classes","slots","composeClasses","useUtilityClasses","_jsxs","as","clsx","focusable","role","_jsx","process","env","NODE_ENV","propTypes","PropTypes","node","object","string","oneOfType","oneOf","elementType","bool","shapeRendering","sx","arrayOf","func","muiName","path","displayName","Component","memo","idOverride","reactId","defaultId","setDefaultId","useState","id","useEffect","useGlobalId"],"mappings":"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","x_google_ignoreList":[0,1,2,3]}
@@ -0,0 +1,2 @@
1
+ import*as o from"react";import{jsxs as e,jsx as r}from"react/jsx-runtime";import{r as t,o as n,p as i,q as s,n as l,H as a,x as c,G as p,P as f}from"./Header-C65iSMsF.js";let m=0;const d={...o}.useId;function u(e){if(void 0!==d){const o=d();return e??o}return function(e){const[r,t]=o.useState(e),n=e||r;return o.useEffect(()=>{null==r&&(m+=1,t(`mui-${m}`))},[r]),n}(e)}function h(o){return t("MuiSvgIcon",o)}n("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const S=s("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(o,e)=>{const{ownerState:r}=o;return[e.root,"inherit"!==r.color&&e[`color${a(r.color)}`],e[`fontSize${a(r.fontSize)}`]]}})(p(({theme:o})=>({userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:o.transitions?.create?.("fill",{duration:(o.vars??o).transitions?.duration?.shorter}),variants:[{props:o=>!o.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:o.typography?.pxToRem?.(20)||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:o.typography?.pxToRem?.(24)||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:o.typography?.pxToRem?.(35)||"2.1875rem"}},...Object.entries((o.vars??o).palette).filter(([,o])=>o&&o.main).map(([e])=>({props:{color:e},style:{color:(o.vars??o).palette?.[e]?.main}})),{props:{color:"action"},style:{color:(o.vars??o).palette?.action?.active}},{props:{color:"disabled"},style:{color:(o.vars??o).palette?.action?.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}))),v=o.forwardRef(function(t,n){const s=i({props:t,name:"MuiSvgIcon"}),{children:p,className:f,color:m="inherit",component:d="svg",fontSize:u="medium",htmlColor:v,inheritViewBox:y=!1,titleAccess:g,viewBox:z="0 0 24 24",...x}=s,w=o.isValidElement(p)&&"svg"===p.type,N={...s,color:m,component:d,fontSize:u,instanceFontSize:t.fontSize,inheritViewBox:y,viewBox:z,hasSvgAsChild:w},b={};y||(b.viewBox=z);const O=(o=>{const{color:e,fontSize:r,classes:t}=o,n={root:["root","inherit"!==e&&`color${a(e)}`,`fontSize${a(r)}`]};return c(n,h,t)})(N);return e(S,{as:d,className:l(O.root,f),focusable:"false",color:v,"aria-hidden":!g||void 0,role:g?"img":void 0,ref:n,...b,...x,...w&&p.props,ownerState:N,children:[w?p.props.children:p,g?r("title",{children:g}):null]})});function y(e,t){function n(o,n){return r(v,{"data-testid":"production"!==process.env.NODE_ENV?`${t}Icon`:void 0,ref:n,...o,children:e})}return"production"!==process.env.NODE_ENV&&(n.displayName=`${t}Icon`),n.muiName=v.muiName,o.memo(o.forwardRef(n))}"production"!==process.env.NODE_ENV&&(v.propTypes={children:f.node,classes:f.object,className:f.string,color:f.oneOfType([f.oneOf(["inherit","action","disabled","primary","secondary","error","info","success","warning"]),f.string]),component:f.elementType,fontSize:f.oneOfType([f.oneOf(["inherit","large","medium","small"]),f.string]),htmlColor:f.string,inheritViewBox:f.bool,shapeRendering:f.string,sx:f.oneOfType([f.arrayOf(f.oneOfType([f.func,f.object,f.bool])),f.func,f.object]),titleAccess:f.string,viewBox:f.string}),v.muiName="SvgIcon";export{y as c,u};
2
+ //# sourceMappingURL=createSvgIcon-KYNE9Cmr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSvgIcon-KYNE9Cmr.js","sources":["../../node_modules/@mui/utils/esm/useId/useId.js","../../node_modules/@mui/material/esm/SvgIcon/svgIconClasses.js","../../node_modules/@mui/material/esm/SvgIcon/SvgIcon.js","../../node_modules/@mui/material/esm/utils/createSvgIcon.js"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nlet globalId = 0;\n\n// TODO React 17: Remove `useGlobalId` once React 17 support is removed\nfunction useGlobalId(idOverride) {\n const [defaultId, setDefaultId] = React.useState(idOverride);\n const id = idOverride || defaultId;\n React.useEffect(() => {\n if (defaultId == null) {\n // Fallback to this default id when possible.\n // Use the incrementing value for client-side rendering only.\n // We can't use it server-side.\n // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem\n globalId += 1;\n setDefaultId(`mui-${globalId}`);\n }\n }, [defaultId]);\n return id;\n}\n\n// See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why\nconst safeReact = {\n ...React\n};\nconst maybeReactUseId = safeReact.useId;\n\n/**\n *\n * @example <div id={useId()} />\n * @param idOverride\n * @returns {string}\n */\nexport default function useId(idOverride) {\n // React.useId() is only available from React 17.0.0.\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? reactId;\n }\n\n // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.\n return useGlobalId(idOverride);\n}","import generateUtilityClasses from '@mui/utils/generateUtilityClasses';\nimport generateUtilityClass from '@mui/utils/generateUtilityClass';\nexport function getSvgIconUtilityClass(slot) {\n return generateUtilityClass('MuiSvgIcon', slot);\n}\nconst svgIconClasses = generateUtilityClasses('MuiSvgIcon', ['root', 'colorPrimary', 'colorSecondary', 'colorAction', 'colorError', 'colorDisabled', 'fontSizeInherit', 'fontSizeSmall', 'fontSizeMedium', 'fontSizeLarge']);\nexport default svgIconClasses;","'use client';\n\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport clsx from 'clsx';\nimport composeClasses from '@mui/utils/composeClasses';\nimport capitalize from \"../utils/capitalize.js\";\nimport { styled } from \"../zero-styled/index.js\";\nimport memoTheme from \"../utils/memoTheme.js\";\nimport { useDefaultProps } from \"../DefaultPropsProvider/index.js\";\nimport { getSvgIconUtilityClass } from \"./svgIconClasses.js\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst useUtilityClasses = ownerState => {\n const {\n color,\n fontSize,\n classes\n } = ownerState;\n const slots = {\n root: ['root', color !== 'inherit' && `color${capitalize(color)}`, `fontSize${capitalize(fontSize)}`]\n };\n return composeClasses(slots, getSvgIconUtilityClass, classes);\n};\nconst SvgIconRoot = styled('svg', {\n name: 'MuiSvgIcon',\n slot: 'Root',\n overridesResolver: (props, styles) => {\n const {\n ownerState\n } = props;\n return [styles.root, ownerState.color !== 'inherit' && styles[`color${capitalize(ownerState.color)}`], styles[`fontSize${capitalize(ownerState.fontSize)}`]];\n }\n})(memoTheme(({\n theme\n}) => ({\n userSelect: 'none',\n width: '1em',\n height: '1em',\n display: 'inline-block',\n flexShrink: 0,\n transition: theme.transitions?.create?.('fill', {\n duration: (theme.vars ?? theme).transitions?.duration?.shorter\n }),\n variants: [{\n props: props => !props.hasSvgAsChild,\n style: {\n // the <svg> will define the property that has `currentColor`\n // for example heroicons uses fill=\"none\" and stroke=\"currentColor\"\n fill: 'currentColor'\n }\n }, {\n props: {\n fontSize: 'inherit'\n },\n style: {\n fontSize: 'inherit'\n }\n }, {\n props: {\n fontSize: 'small'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(20) || '1.25rem'\n }\n }, {\n props: {\n fontSize: 'medium'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(24) || '1.5rem'\n }\n }, {\n props: {\n fontSize: 'large'\n },\n style: {\n fontSize: theme.typography?.pxToRem?.(35) || '2.1875rem'\n }\n },\n // TODO v5 deprecate color prop, v6 remove for sx\n ...Object.entries((theme.vars ?? theme).palette).filter(([, value]) => value && value.main).map(([color]) => ({\n props: {\n color\n },\n style: {\n color: (theme.vars ?? theme).palette?.[color]?.main\n }\n })), {\n props: {\n color: 'action'\n },\n style: {\n color: (theme.vars ?? theme).palette?.action?.active\n }\n }, {\n props: {\n color: 'disabled'\n },\n style: {\n color: (theme.vars ?? theme).palette?.action?.disabled\n }\n }, {\n props: {\n color: 'inherit'\n },\n style: {\n color: undefined\n }\n }]\n})));\nconst SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(inProps, ref) {\n const props = useDefaultProps({\n props: inProps,\n name: 'MuiSvgIcon'\n });\n const {\n children,\n className,\n color = 'inherit',\n component = 'svg',\n fontSize = 'medium',\n htmlColor,\n inheritViewBox = false,\n titleAccess,\n viewBox = '0 0 24 24',\n ...other\n } = props;\n const hasSvgAsChild = /*#__PURE__*/React.isValidElement(children) && children.type === 'svg';\n const ownerState = {\n ...props,\n color,\n component,\n fontSize,\n instanceFontSize: inProps.fontSize,\n inheritViewBox,\n viewBox,\n hasSvgAsChild\n };\n const more = {};\n if (!inheritViewBox) {\n more.viewBox = viewBox;\n }\n const classes = useUtilityClasses(ownerState);\n return /*#__PURE__*/_jsxs(SvgIconRoot, {\n as: component,\n className: clsx(classes.root, className),\n focusable: \"false\",\n color: htmlColor,\n \"aria-hidden\": titleAccess ? undefined : true,\n role: titleAccess ? 'img' : undefined,\n ref: ref,\n ...more,\n ...other,\n ...(hasSvgAsChild && children.props),\n ownerState: ownerState,\n children: [hasSvgAsChild ? children.props.children : children, titleAccess ? /*#__PURE__*/_jsx(\"title\", {\n children: titleAccess\n }) : null]\n });\n});\nprocess.env.NODE_ENV !== \"production\" ? SvgIcon.propTypes /* remove-proptypes */ = {\n // ┌────────────────────────────── Warning ──────────────────────────────┐\n // │ These PropTypes are generated from the TypeScript type definitions. │\n // │ To update them, edit the d.ts file and run `pnpm proptypes`. │\n // └─────────────────────────────────────────────────────────────────────┘\n /**\n * Node passed into the SVG element.\n */\n children: PropTypes.node,\n /**\n * Override or extend the styles applied to the component.\n */\n classes: PropTypes.object,\n /**\n * @ignore\n */\n className: PropTypes.string,\n /**\n * The color of the component.\n * It supports both default and custom theme colors, which can be added as shown in the\n * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).\n * You can use the `htmlColor` prop to apply a color attribute to the SVG element.\n * @default 'inherit'\n */\n color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'action', 'disabled', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),\n /**\n * The component used for the root node.\n * Either a string to use a HTML element or a component.\n */\n component: PropTypes.elementType,\n /**\n * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.\n * @default 'medium'\n */\n fontSize: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), PropTypes.string]),\n /**\n * Applies a color attribute to the SVG element.\n */\n htmlColor: PropTypes.string,\n /**\n * If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox`\n * prop will be ignored.\n * Useful when you want to reference a custom `component` and have `SvgIcon` pass that\n * `component`'s viewBox to the root node.\n * @default false\n */\n inheritViewBox: PropTypes.bool,\n /**\n * The shape-rendering attribute. The behavior of the different options is described on the\n * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/shape-rendering).\n * If you are having issues with blurry icons you should investigate this prop.\n */\n shapeRendering: PropTypes.string,\n /**\n * The system prop that allows defining system overrides as well as additional CSS styles.\n */\n sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),\n /**\n * Provides a human-readable title for the element that contains it.\n * https://www.w3.org/TR/SVG-access/#Equivalent\n */\n titleAccess: PropTypes.string,\n /**\n * Allows you to redefine what the coordinates without units mean inside an SVG element.\n * For example, if the SVG element is 500 (width) by 200 (height),\n * and you pass viewBox=\"0 0 50 20\",\n * this means that the coordinates inside the SVG will go from the top left corner (0,0)\n * to bottom right (50,20) and each unit will be worth 10px.\n * @default '0 0 24 24'\n */\n viewBox: PropTypes.string\n} : void 0;\nSvgIcon.muiName = 'SvgIcon';\nexport default SvgIcon;","'use client';\n\nimport * as React from 'react';\nimport SvgIcon from \"../SvgIcon/index.js\";\n\n/**\n * Private module reserved for @mui packages.\n */\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function createSvgIcon(path, displayName) {\n function Component(props, ref) {\n return /*#__PURE__*/_jsx(SvgIcon, {\n \"data-testid\": process.env.NODE_ENV !== 'production' ? `${displayName}Icon` : undefined,\n ref: ref,\n ...props,\n children: path\n });\n }\n if (process.env.NODE_ENV !== 'production') {\n // Need to set `displayName` on the inner component for React.memo.\n // React prior to 16.14 ignores `displayName` on the wrapper.\n Component.displayName = `${displayName}Icon`;\n }\n Component.muiName = SvgIcon.muiName;\n return /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(Component));\n}"],"names":["globalId","maybeReactUseId","React","useId","idOverride","undefined","reactId","defaultId","setDefaultId","useState","id","useEffect","useGlobalId","getSvgIconUtilityClass","slot","generateUtilityClass","generateUtilityClasses","SvgIconRoot","styled","name","overridesResolver","props","styles","ownerState","root","color","capitalize","fontSize","memoTheme","theme","userSelect","width","height","display","flexShrink","transition","transitions","create","duration","vars","shorter","variants","hasSvgAsChild","style","fill","typography","pxToRem","Object","entries","palette","filter","value","main","map","action","active","disabled","SvgIcon","forwardRef","inProps","ref","useDefaultProps","children","className","component","htmlColor","inheritViewBox","titleAccess","viewBox","other","isValidElement","type","instanceFontSize","more","classes","slots","composeClasses","useUtilityClasses","_jsxs","as","clsx","focusable","role","_jsx","createSvgIcon","path","displayName","Component","process","env","NODE_ENV","muiName","memo","propTypes","PropTypes","node","object","string","oneOfType","oneOf","elementType","bool","shapeRendering","sx","arrayOf","func"],"mappings":"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","x_google_ignoreList":[0,1,2,3]}
package/dist/faceScan.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("./Header-DyVbEgG9.js"),n=require("./arrow-right-CC1_17IM.js"),o=require("./LoadingScreen-CDhtnDGT.js"),r=require("@tensorflow-models/pose-detection"),s=require("@tensorflow/tfjs");function c(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}require("react-dom");var i=c(r);function l({stage:t,videoLoading:n,setVideoLoading:o,videoError:r,setVideoError:s,children:c,gender:i,config:l}){return-1===t?e.jsxs("div",{className:"text-center p-[16px] w-full h-full",style:{background:l?.style?.base?.backgroundColor},children:[e.jsxs("div",{className:"w-full",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:l}),e.jsxs("h2",{style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:["Make sure your face is fully visible"," "]}),n&&e.jsx("div",{className:"mb-4 flex items-center justify-center",style:{fontFamily:l?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:l?.style?.subheading?.subheadingFontSize||"14px",color:l?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:l?.style?.subheading?.subheadingFontWeight||"normal"},children:"Loading video..."}),r&&e.jsx("div",{className:"mb-4 text-red-600",style:{fontFamily:l?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:l?.style?.subheading?.subheadingFontSize||"14px",color:"#ff0000",fontWeight:l?.style?.subheading?.subheadingFontWeight||"normal"},children:"Video failed to load. Please refresh the page or check your connection."}),!r&&e.jsx("div",{className:" w-[100px] mx-auto",children:e.jsx("video",{src:i===a.GenderType.Male?a.maleGlassesOffVideo:a.glassesOffVideo,autoPlay:!0,loop:!0,controls:!1,muted:!0,playsInline:!0,className:"h-full w-full object-contain border-none",onCanPlay:()=>o(!1),onLoadStart:()=>o(!0),onError:()=>s(!0),"aria-label":"Instructional video: Please remove your glasses before starting the scan."})})]}),c]}):e.jsx("div",{className:"text-center p-[16px] w-full h-full",style:{background:l?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"w-full",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:l}),e.jsx("h3",{className:"mb-[0.5rem]",style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:a.directionMessages[t]}),e.jsxs("div",{className:"max-w-[400px] justify-center gap-1 mx-auto flex items-center",children:[e.jsx("div",{className:` w-[120px] overflow-hidden ${0===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.forward:a.FACE_SCAN_HEADSHOT.female.forward,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${1===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.left:a.FACE_SCAN_HEADSHOT.female.left,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${2===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.right:a.FACE_SCAN_HEADSHOT.female.right,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${3===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.smile:a.FACE_SCAN_HEADSHOT.female.smile,type:"video/mp4"})})})]})]})})}function d({resetScanState:t,loading:o,config:r}){return e.jsx("div",{className:"fixed top-[0] left-[0] z-[999] flex justify-center items-center w-full h-full",style:{background:r?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"flex flex-col w-full items-center p-[1rem] rounded-lg ",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:r}),e.jsxs("div",{className:"flex flex-col items-center w-full",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 ",style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:"Your Scan Failed"}),e.jsx("p",{className:"mb-[1.5rem]",style:{fontFamily:r?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:r?.style?.subheading?.subheadingFontSize||"14px",color:r?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:r?.style?.subheading?.subheadingFontWeight||"normal"},children:"Please click below to reset your scan."}),e.jsx(a.SpecificButton,{disabled:o,className:"w-full h-[45px] shadow-[0px_1px_2px_0px_#00000040] text-[16px]",buttonText:"Reset Scan",postfixIcon:e.jsx(n.ArrowRight,{}),buttonFunc:()=>t?.(),resolvedConfig:r})]})]})})}let u=null;function f({faceScanId:e,onValidPose:n,onScanComplete:r,onModelReady:c,onStartRecording:l,shopDomain:d}){const f=t.useRef(null),[h,g]=t.useState(0),[m,p]=t.useState(0),[y,S]=t.useState(!1),[x,b]=t.useState(!1),v=t.useRef(null),w=t.useRef(h),F=t.useRef(m),j=t.useRef([]),C=t.useRef(""),_=t.useRef(0),N=t.useRef(!1),I=t.useRef(0),k=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,T=t.useMemo(()=>["Face front","Turn head fully left","Turn head fully right","Smile facing front"],[]),E=t.useMemo(()=>function(e,t){let a;return(...n)=>{a&&clearTimeout(a),a=setTimeout(()=>e(...n),t)}}(e=>{a.qo.capture(`${d}/face_scan_pose_detection`,e)},4e3),[d]),D=t.useCallback((t,a,n,o,r,s)=>{const c=Date.now();if(!(c-I.current<4e3)){I.current=c;try{const c=t[0]||[0,0,0],i=t[2]||[0,0,0],l=t[5]||[0,0,0],d=t[9]||[0,0,0],u=t[10]||[0,0,0],f=t.map(e=>e[2]).filter(e=>e>0),h=f.length>0?f.reduce((e,t)=>e+t,0)/f.length:0,g=a.map(e=>e[2]).filter(e=>e>0),m=g.length>0?g.reduce((e,t)=>e+t,0)/g.length:0,p=Math.abs(i[0]-l[0]),y=c[0]-l[0],S=i[0]-c[0];let x="frontal";1===n?x="left":2===n?x="right":3===n&&(x="frontal_smile");const b={faceScanId:e,stage:n,timestamp:(new Date).toISOString(),data:JSON.stringify({headValid:o,bodyInvalid:r,consecutiveValid:s,avgFaceScore:parseFloat(h.toFixed(3)),avgBodyScore:parseFloat(m.toFixed(3)),faceKeypointsDetected:f.length,bodyKeypointsDetected:g.length,eyeDistance:parseFloat(p.toFixed(2)),noseToRightRatio:parseFloat((y/p).toFixed(3)),noseToLeftRatio:parseFloat((S/p).toFixed(3)),noseScore:parseFloat(c[2].toFixed(3)),leftEyeScore:parseFloat(i[2].toFixed(3)),rightEyeScore:parseFloat(l[2].toFixed(3)),leftMouthScore:parseFloat(d[2].toFixed(3)),rightMouthScore:parseFloat(u[2].toFixed(3)),expectedPosition:x})};E(b)}catch(e){console.warn("Failed to track pose detection:",e)}}},[e,E]),A=()=>{a.qo.capture(`${d}/face_scan_detection_started`,{faceScanId:e,stage:w.current,timestamp:(new Date).toISOString(),stageName:T[w.current]}),setTimeout(()=>{b(!0)},1500)},M=async()=>{try{console.log("Initializing TensorFlow..."),await s.setBackend("webgl"),await s.ready(),console.log("TensorFlow initialized, loading models...");const e=await(async()=>{if(u)return u;const e=await i.createDetector(i.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),t=document.createElement("canvas");t.width=a.videoConstraints.width,t.height=a.videoConstraints.height;const n=t.getContext("2d");n&&(n.fillStyle="black",n.fillRect(0,0,t.width,t.height));try{await e.estimatePoses(t)}catch(e){console.log(e,"at time of preload")}return u=e,e})();console.log(e,"detector"),f.current=e,console.log("Pose detection model loaded successfully"),S(!0),c?.()}catch(e){console.error("Error initializing face scan:",e)}};return t.useEffect(()=>(M(),()=>{(async()=>{try{S(!1),f.current&&(await f.current.dispose(),f.current=null)}catch(e){console.error("Error disposing resources:",e)}finally{g(0),p(0),w.current=0,F.current=0,j.current=[]}})()}),[]),t.useEffect(()=>{w.current=h},[h]),t.useEffect(()=>{F.current=m},[m]),{faceScanDetector:async(t,s)=>{if(f.current&&t.current&&y&&x)try{const c=await f.current.estimatePoses(t.current);if(c.length>0){const t=[],i=[];if(c[0].keypoints.forEach((e,a)=>{const n=e.score??0,o=[e.x??-1,e.y??-1,n];a<=10?t.push(o):i.push(o)}),s?.current){const e=s.current.getContext("2d"),{width:t,height:a}=s.current;if(e){e.clearRect(0,0,t,a);const n=Math.min(F.current/2,1),o=.35*a;e.beginPath(),e.strokeStyle="#00ff00",e.lineWidth=6,e.arc(t/2,a/2,o+10,-Math.PI/2,-Math.PI/2+2*n*Math.PI),e.stroke()}}const u=((e,t)=>{if(t[0][2]<.2||t[2][2]<.2||t[5][2]<.2)return!1;const a=.5*(t[10][1]+t[9][1])-.5*(t[5][1]+t[2][1]),n=(.5*(t[10][1]+t[9][1])-t[0][1])/a,o=n>.7||n<.3,r=Math.abs(t[2][1]-t[5][1])<.5*a&&Math.abs(t[9][1]-t[10][1])<.5*a,s=t[2][0]-t[5][0],c=t[0][0]-t[5][0],i=c>.4*s&&c<.6*s,l=c>.85*s,d=t[2][0]-t[0][0]>.85*s;switch(e){case 0:case 3:return!o&&r&&i;case 1:return!o&&r&&l;case 2:return!o&&r&&d;default:return!1}})(w.current,t),f=i.slice(2).filter(e=>e[2]>.7).length<=2;j.current.push(u&&f),j.current.length>10&&j.current.shift();if(j.current.filter(Boolean).length>=2){const e=F.current+1;p(e)}else p(Math.max(0,F.current-1));if(F.current>=2){n?.();const t=w.current+1;p(0),j.current=[],g(t),b(!1),(async()=>{if(await o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/Sound-effect.mp3`),a.qo.capture(`${d}/face_scan_detection_stage_completed`,{faceScanId:e,completedStage:w.current,nextStage:t,timestamp:(new Date).toISOString(),totalStages:4,stageName:T[w.current]}),1===t&&l&&l(),t>=4)r?.();else{let e=null;switch(t){case 1:e="Left.mp3";break;case 2:e="Right.mp3";break;case 3:e="Smile.mp3";break;default:e=null}e&&await o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/${e}`),A()}})()}D(t,i,w.current,u,f,F.current)}}catch(e){console.error("Pose detection error:",e)}},scanStage:h,setScanStage:g,consecutiveValid:m,isModelLoaded:y,resetScan:()=>{a.qo.capture(`${d}/face_scan_reset`,{faceScanId:e,stage:w.current,timestamp:(new Date).toISOString(),stageName:T[w.current],consecutiveValid:F.current}),g(0),p(0),b(!1),w.current=0,F.current=0,j.current=[],C.current="",_.current=0,N.current=!1,v.current&&(speechSynthesis.cancel(),v.current=null)},enableVoiceCommands:()=>{if(N.current=!0,k&&"speechSynthesis"in window){const e=new SpeechSynthesisUtterance("");e.volume=0,speechSynthesis.speak(e)}},startScanSequence:A,isScanningActive:x}}exports.FaceScan=({userDetails:r,onComplete:s,onScanError:c,onRetry:i,config:u,isError:h,isSuccess:g})=>{const m=t.useRef(null),p=t.useRef(null),y=t.useRef(null),S=t.useRef([]),x=t.useRef(null),[b,v]=t.useState(!1),[w,F]=t.useState(!1),[j,C]=t.useState(!1),[_,N]=t.useState(!0),[I,k]=t.useState(!1),[T,E]=t.useState(!1),[D,A]=t.useState(!1),[M,R]=t.useState(a.generateUuid()),O=a.useLocalConfig(u),{email:P,gender:z,deviceFocalLength:$,shopDomain:H,callbackUrl:W}=r,q=t.useMemo(()=>a.videoTypes.filter(e=>MediaRecorder.isTypeSupported(e)),[]),L=t.useCallback(()=>{console.log("Stopping recording..."),y.current&&"recording"===y.current.state&&y.current.stop(),y.current=null},[]),V=async()=>{if(v(!0),console.log("upload final video"),S.current){if(0===S.current.length)return console.error("No video data recorded"),A(!0),void v(!1);const e=new File(S.current,`${M}.webm`,{type:"video/webm"}),t=e.size,n=(t/1048576).toFixed(2),r=Math.round(t/1e4),s={video_size_mb:parseFloat(n),video_size_bytes:t,blob_count:S.current.length,estimated_duration_seconds:r},c=[{gender:z},{face_scan_id:M},{focal_length:`${$}`},{customer_store_url:H},{scan_type:"face_scan"},{callback_url:W}];a.handleScanTimeCapture({eventName:`${H}/face_scan_meta_data`,faceScanId:M,email:P,data:JSON.stringify({metaData:c,videoData:s})});const i=Date.now();a.handleScanTimeCapture({eventName:`${H}/face_scan_upload_start`,faceScanId:M,email:P,startTime:i});try{const t=await o.swan.fileUpload.faceScanFileUploader({file:e,objectKey:M,email:P,arrayMetaData:c,contentType:e.type}),n=Date.now(),r=n-i;a.handleScanTimeCapture({eventName:`${H}/face_scan_upload_complete`,faceScanId:M,email:P,completionTime:n,uploadDuration:r}),console.log("✅ Upload successful",t),o.swan.measurement.handlFaceScaneSocket({faceScanId:M,onOpen:()=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"open",type:"faceScan_recommendation",email:P}),console.log("websocket connect open")},onError:e=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"error",type:"faceScan_recommendation",email:P}),ee(e)},onSuccess:e=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"success",type:"faceScan_recommendation",email:P}),te(e)},onClose:()=>{console.log("websocket connect close"),a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"close",type:"faceScan_recommendation",email:P})}})}catch(e){ee(e)}}},U=t.useCallback(()=>{console.log("Starting recording for stages 1-3...");const e=m.current?.srcObject;if(!e)return;const t=e.getVideoTracks()[0].getSettings(),{width:n=a.videoConstraints.width,height:o=a.videoConstraints.height}=t,r=document.createElement("canvas"),s=r.getContext("2d");n>o?(r.width=o,r.height=n):(r.width=n,r.height=o);const c=document.createElement("video");c.srcObject=e,c.muted=!0,c.playsInline=!0,c.play();const i=()=>{n>o?(s?.save(),s?.translate(r.width,0),s?.rotate(Math.PI/2),s?.drawImage(c,0,0,o,n),s?.restore()):s?.drawImage(c,0,0,n,o),requestAnimationFrame(i)};i();const l=r.captureStream(30),d=q.length>0?{mimeType:q[0]}:{};let u;try{u=new MediaRecorder(l,d)}catch(e){return console.error("MediaRecorder init failed:",e),A(!0),void v(!1)}S.current=[],u.ondataavailable=e=>{e?.data&&e.data.size>0&&S.current&&S.current.push(e.data)},u.onstop=()=>{console.log("Recording stopped, total blobs:",S?.current?.length),V()},u.start(100),y.current=u,console.log("Recording started successfully (portrait normalized)")},[q,V]),{faceScanDetector:B,scanStage:G,setScanStage:J,resetScan:K,isModelLoaded:X,startScanSequence:Y}=f({faceScanId:M,shopDomain:H,onScanComplete:()=>{L()},onModelReady:()=>{F(!0)},onStartRecording:()=>{console.log("Stage 0 completed - starting recording for stages 1-3"),U()}}),Q=t.useCallback(()=>{X&&(J(0),o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/Face-forward.mp3`),setTimeout(()=>{C(!0),setTimeout(()=>{Y()},200)},200))},[J,C,Y,X]),Z=t.useCallback(()=>{C(!1),N(!0),L(),K(),i?.(),S.current=[],y.current&&(y.current=null),A(!1),J(-1),R(a.generateUuid()),m.current&&x.current&&(m.current.srcObject=x.current,console.log("Camera stream restored after reset"))},[J,C,N,L,K,R]),ee=e=>{console.log(e,"ws error"),c?.(e),A(!0),v(!1),N(!1),a.handleScanTimeCapture({eventName:`${H}/faceScan`,faceScanId:M,status:"failed",email:P,data:JSON.stringify(e)})},te=e=>{console.log(e,"ws success"),e&&"intermediate"===e?.resultType&&a.handleScanTimeCapture({eventName:`${H}/faceScan_success/intermediate`,faceScanId:M,status:"success",email:P,data:JSON.stringify(e)}),s?.(e)};t.useEffect(()=>{if(!h&&!g)return navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:a.videoConstraints}).then(e=>{x.current=e,m.current&&(m.current.srcObject=e,console.log("Webcam initialized"))}).catch(e=>console.error("Error accessing webcam:",e)),()=>{x.current&&x.current.getTracks().forEach(e=>e.stop())}},[h,g]),t.useEffect(()=>{if(!w||!j)return;const e=setInterval(()=>{B(m,p)},500);return()=>clearInterval(e)},[B,w,j]);return console.log("Model ready:",w,"Has error:",D,"Is scanning:",j,"showLoader",b),t.useEffect(()=>{J(-1),h||g||(a.qo.init(a.posthogPublicKey,{api_host:a.posthogPublicHost}),a.qo.capture("$pageview"))},[h,g]),h?e.jsx(d,{config:O}):g?e.jsx("div",{className:"fixed z-[9] w-full h-full",style:{background:O?.style?.base?.primaryColor},children:e.jsx(o.LoadingScreen,{url:O?.loader})}):e.jsxs(e.Fragment,{children:[e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:""}),b&&!D&&e.jsx("div",{className:"fixed z-[9] w-full h-full",style:{background:O?.style?.base?.primaryColor},children:e.jsx(o.LoadingScreen,{url:O?.loader})}),e.jsx("div",{className:"h-full flex-col relative w-full flex justify-center items-center text-center rounded-t-[20px]",style:{background:O?.style?.base?.backgroundColor},children:e.jsx("div",{className:"flex-1 w-full max-w-md overflow-hidden",children:e.jsxs("div",{className:"w-full h-full",children:[e.jsx("video",{ref:m,autoPlay:!0,playsInline:!0,muted:!0,width:a.videoConstraints.width,height:a.videoConstraints.height,className:"w-full h-full object-cover fixed left-0 top-0 z-0",style:{transform:"scaleX(-1)"}}),e.jsx("canvas",{ref:p,width:a.videoConstraints.width,height:a.videoConstraints.height,style:{transform:"scaleX(-1)",opacity:"0"}})]})})}),!b&&D&&e.jsx(d,{loading:b,resetScanState:Z,config:O}),_&&!D&&!b&&e.jsx(o.Drawer,{open:!0,className:"face-scan-small camera-draw",anchor:"bottom",onClose:(e,t)=>{},hideBackdrop:!0,children:e.jsx(l,{stage:G,videoLoading:I,setVideoLoading:k,videoError:T,setVideoError:E,gender:z,config:O,children:e.jsx("div",{className:"flex justify-center w-full p-[1rem]",children:e.jsx(a.SpecificButton,{disabled:b||!X,className:"!w-[60px] !h-[35px] !py-0 !px-0",buttonText:j?"Reset":X?"Start":"Loading...",postfixIcon:j?e.jsx(n.ArrowRight,{}):"",buttonFunc:j?Z:Q,resolvedConfig:O})})})})]})};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("./Header-Bf7ClSfT.js"),n=require("./arrow-right-CC1_17IM.js"),o=require("./LoadingScreen-C9vDF8N6.js"),r=require("@tensorflow-models/pose-detection"),s=require("@tensorflow/tfjs");function c(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}require("react-dom");var i=c(r);function l({stage:t,videoLoading:n,setVideoLoading:o,videoError:r,setVideoError:s,children:c,gender:i,config:l}){return-1===t?e.jsxs("div",{className:"text-center p-[16px] w-full h-full",style:{background:l?.style?.base?.backgroundColor},children:[e.jsxs("div",{className:"w-full",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:l}),e.jsxs("h2",{style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:["Make sure your face is fully visible"," "]}),n&&e.jsx("div",{className:"mb-4 flex items-center justify-center",style:{fontFamily:l?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:l?.style?.subheading?.subheadingFontSize||"14px",color:l?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:l?.style?.subheading?.subheadingFontWeight||"normal"},children:"Loading video..."}),r&&e.jsx("div",{className:"mb-4 text-red-600",style:{fontFamily:l?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:l?.style?.subheading?.subheadingFontSize||"14px",color:"#ff0000",fontWeight:l?.style?.subheading?.subheadingFontWeight||"normal"},children:"Video failed to load. Please refresh the page or check your connection."}),!r&&e.jsx("div",{className:" w-[100px] mx-auto",children:e.jsx("video",{src:i===a.GenderType.Male?a.maleGlassesOffVideo:a.glassesOffVideo,autoPlay:!0,loop:!0,controls:!1,muted:!0,playsInline:!0,className:"h-full w-full object-contain border-none",onCanPlay:()=>o(!1),onLoadStart:()=>o(!0),onError:()=>s(!0),"aria-label":"Instructional video: Please remove your glasses before starting the scan."})})]}),c]}):e.jsx("div",{className:"text-center p-[16px] w-full h-full",style:{background:l?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"w-full",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:l}),e.jsx("h3",{className:"mb-[0.5rem]",style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:a.directionMessages[t]}),e.jsxs("div",{className:"max-w-[400px] justify-center gap-1 mx-auto flex items-center",children:[e.jsx("div",{className:` w-[120px] overflow-hidden ${0===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.forward:a.FACE_SCAN_HEADSHOT.female.forward,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${1===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.left:a.FACE_SCAN_HEADSHOT.female.left,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${2===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.right:a.FACE_SCAN_HEADSHOT.female.right,type:"video/mp4"})})}),e.jsx("div",{className:` w-[120px] overflow-hidden ${3===t?"opacity-100":"opacity-0 hidden"} `,children:e.jsx("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e.jsx("source",{src:i===a.GenderType.Male?a.FACE_SCAN_HEADSHOT.male.smile:a.FACE_SCAN_HEADSHOT.female.smile,type:"video/mp4"})})})]})]})})}function d({resetScanState:t,loading:o,config:r}){return e.jsx("div",{className:"fixed top-[0] left-[0] z-[999] flex justify-center items-center w-full h-full",style:{background:r?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"flex flex-col w-full items-center p-[1rem] rounded-lg ",children:[e.jsx(a.Header,{noTitle:!0,resolvedConfig:r}),e.jsxs("div",{className:"flex flex-col items-center w-full",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 ",style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:"Your Scan Failed"}),e.jsx("p",{className:"mb-[1.5rem]",style:{fontFamily:r?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:r?.style?.subheading?.subheadingFontSize||"14px",color:r?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:r?.style?.subheading?.subheadingFontWeight||"normal"},children:"Please click below to reset your scan."}),e.jsx(a.SpecificButton,{disabled:o,className:"w-full h-[45px] shadow-[0px_1px_2px_0px_#00000040] text-[16px]",buttonText:"Reset Scan",postfixIcon:e.jsx(n.ArrowRight,{}),buttonFunc:()=>t?.(),resolvedConfig:r})]})]})})}let u=null;function f({faceScanId:e,onValidPose:n,onScanComplete:r,onModelReady:c,onStartRecording:l,shopDomain:d}){const f=t.useRef(null),[h,g]=t.useState(0),[m,p]=t.useState(0),[y,S]=t.useState(!1),[x,b]=t.useState(!1),v=t.useRef(null),w=t.useRef(h),F=t.useRef(m),j=t.useRef([]),C=t.useRef(""),_=t.useRef(0),N=t.useRef(!1),I=t.useRef(0),k=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,T=t.useMemo(()=>["Face front","Turn head fully left","Turn head fully right","Smile facing front"],[]),E=t.useMemo(()=>function(e,t){let a;return(...n)=>{a&&clearTimeout(a),a=setTimeout(()=>e(...n),t)}}(e=>{a.qo.capture(`${d}/face_scan_pose_detection`,e)},4e3),[d]),D=t.useCallback((t,a,n,o,r,s)=>{const c=Date.now();if(!(c-I.current<4e3)){I.current=c;try{const c=t[0]||[0,0,0],i=t[2]||[0,0,0],l=t[5]||[0,0,0],d=t[9]||[0,0,0],u=t[10]||[0,0,0],f=t.map(e=>e[2]).filter(e=>e>0),h=f.length>0?f.reduce((e,t)=>e+t,0)/f.length:0,g=a.map(e=>e[2]).filter(e=>e>0),m=g.length>0?g.reduce((e,t)=>e+t,0)/g.length:0,p=Math.abs(i[0]-l[0]),y=c[0]-l[0],S=i[0]-c[0];let x="frontal";1===n?x="left":2===n?x="right":3===n&&(x="frontal_smile");const b={faceScanId:e,stage:n,timestamp:(new Date).toISOString(),data:JSON.stringify({headValid:o,bodyInvalid:r,consecutiveValid:s,avgFaceScore:parseFloat(h.toFixed(3)),avgBodyScore:parseFloat(m.toFixed(3)),faceKeypointsDetected:f.length,bodyKeypointsDetected:g.length,eyeDistance:parseFloat(p.toFixed(2)),noseToRightRatio:parseFloat((y/p).toFixed(3)),noseToLeftRatio:parseFloat((S/p).toFixed(3)),noseScore:parseFloat(c[2].toFixed(3)),leftEyeScore:parseFloat(i[2].toFixed(3)),rightEyeScore:parseFloat(l[2].toFixed(3)),leftMouthScore:parseFloat(d[2].toFixed(3)),rightMouthScore:parseFloat(u[2].toFixed(3)),expectedPosition:x})};E(b)}catch(e){console.warn("Failed to track pose detection:",e)}}},[e,E]),A=()=>{a.qo.capture(`${d}/face_scan_detection_started`,{faceScanId:e,stage:w.current,timestamp:(new Date).toISOString(),stageName:T[w.current]}),setTimeout(()=>{b(!0)},1500)},M=async()=>{try{console.log("Initializing TensorFlow..."),await s.setBackend("webgl"),await s.ready(),console.log("TensorFlow initialized, loading models...");const e=await(async()=>{if(u)return u;const e=await i.createDetector(i.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),t=document.createElement("canvas");t.width=a.videoConstraints.width,t.height=a.videoConstraints.height;const n=t.getContext("2d");n&&(n.fillStyle="black",n.fillRect(0,0,t.width,t.height));try{await e.estimatePoses(t)}catch(e){console.log(e,"at time of preload")}return u=e,e})();console.log(e,"detector"),f.current=e,console.log("Pose detection model loaded successfully"),S(!0),c?.()}catch(e){console.error("Error initializing face scan:",e)}};return t.useEffect(()=>(M(),()=>{(async()=>{try{S(!1),f.current&&(await f.current.dispose(),f.current=null)}catch(e){console.error("Error disposing resources:",e)}finally{g(0),p(0),w.current=0,F.current=0,j.current=[]}})()}),[]),t.useEffect(()=>{w.current=h},[h]),t.useEffect(()=>{F.current=m},[m]),{faceScanDetector:async(t,s)=>{if(f.current&&t.current&&y&&x)try{const c=await f.current.estimatePoses(t.current);if(c.length>0){const t=[],i=[];if(c[0].keypoints.forEach((e,a)=>{const n=e.score??0,o=[e.x??-1,e.y??-1,n];a<=10?t.push(o):i.push(o)}),s?.current){const e=s.current.getContext("2d"),{width:t,height:a}=s.current;if(e){e.clearRect(0,0,t,a);const n=Math.min(F.current/2,1),o=.35*a;e.beginPath(),e.strokeStyle="#00ff00",e.lineWidth=6,e.arc(t/2,a/2,o+10,-Math.PI/2,-Math.PI/2+2*n*Math.PI),e.stroke()}}const u=((e,t)=>{if(t[0][2]<.2||t[2][2]<.2||t[5][2]<.2)return!1;const a=.5*(t[10][1]+t[9][1])-.5*(t[5][1]+t[2][1]),n=(.5*(t[10][1]+t[9][1])-t[0][1])/a,o=n>.7||n<.3,r=Math.abs(t[2][1]-t[5][1])<.5*a&&Math.abs(t[9][1]-t[10][1])<.5*a,s=t[2][0]-t[5][0],c=t[0][0]-t[5][0],i=c>.4*s&&c<.6*s,l=c>.85*s,d=t[2][0]-t[0][0]>.85*s;switch(e){case 0:case 3:return!o&&r&&i;case 1:return!o&&r&&l;case 2:return!o&&r&&d;default:return!1}})(w.current,t),f=i.slice(2).filter(e=>e[2]>.7).length<=2;j.current.push(u&&f),j.current.length>10&&j.current.shift();if(j.current.filter(Boolean).length>=2){const e=F.current+1;p(e)}else p(Math.max(0,F.current-1));if(F.current>=2){n?.();const t=w.current+1;p(0),j.current=[],g(t),b(!1),(async()=>{if(await o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/Sound-effect.mp3`),a.qo.capture(`${d}/face_scan_detection_stage_completed`,{faceScanId:e,completedStage:w.current,nextStage:t,timestamp:(new Date).toISOString(),totalStages:4,stageName:T[w.current]}),1===t&&l&&l(),t>=4)r?.();else{let e=null;switch(t){case 1:e="Left.mp3";break;case 2:e="Right.mp3";break;case 3:e="Smile.mp3";break;default:e=null}e&&await o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/${e}`),A()}})()}D(t,i,w.current,u,f,F.current)}}catch(e){console.error("Pose detection error:",e)}},scanStage:h,setScanStage:g,consecutiveValid:m,isModelLoaded:y,resetScan:()=>{a.qo.capture(`${d}/face_scan_reset`,{faceScanId:e,stage:w.current,timestamp:(new Date).toISOString(),stageName:T[w.current],consecutiveValid:F.current}),g(0),p(0),b(!1),w.current=0,F.current=0,j.current=[],C.current="",_.current=0,N.current=!1,v.current&&(speechSynthesis.cancel(),v.current=null)},enableVoiceCommands:()=>{if(N.current=!0,k&&"speechSynthesis"in window){const e=new SpeechSynthesisUtterance("");e.volume=0,speechSynthesis.speak(e)}},startScanSequence:A,isScanningActive:x}}exports.FaceScan=({userDetails:r,onComplete:s,onScanError:c,onRetry:i,config:u,isError:h,isSuccess:g})=>{const m=t.useRef(null),p=t.useRef(null),y=t.useRef(null),S=t.useRef([]),x=t.useRef(null),[b,v]=t.useState(!1),[w,F]=t.useState(!1),[j,C]=t.useState(!1),[_,N]=t.useState(!0),[I,k]=t.useState(!1),[T,E]=t.useState(!1),[D,A]=t.useState(!1),[M,R]=t.useState(a.generateUuid()),O=a.useLocalConfig(u),{email:P,gender:z,deviceFocalLength:$,shopDomain:H,callbackUrl:W}=r,q=t.useMemo(()=>a.videoTypes.filter(e=>MediaRecorder.isTypeSupported(e)),[]),L=t.useCallback(()=>{console.log("Stopping recording..."),y.current&&"recording"===y.current.state&&y.current.stop(),y.current=null},[]),V=async()=>{if(v(!0),console.log("upload final video"),S.current){if(0===S.current.length)return console.error("No video data recorded"),A(!0),void v(!1);const e=new File(S.current,`${M}.webm`,{type:"video/webm"}),t=e.size,n=(t/1048576).toFixed(2),r=Math.round(t/1e4),s={video_size_mb:parseFloat(n),video_size_bytes:t,blob_count:S.current.length,estimated_duration_seconds:r},c=[{gender:z},{face_scan_id:M},{focal_length:`${$}`},{customer_store_url:H},{scan_type:"face_scan"},{callback_url:W}];a.handleScanTimeCapture({eventName:`${H}/face_scan_meta_data`,faceScanId:M,email:P,data:JSON.stringify({metaData:c,videoData:s})});const i=Date.now();a.handleScanTimeCapture({eventName:`${H}/face_scan_upload_start`,faceScanId:M,email:P,startTime:i});try{const t=await o.swan.fileUpload.faceScanFileUploader({file:e,objectKey:M,email:P,arrayMetaData:c,contentType:e.type}),n=Date.now(),r=n-i;a.handleScanTimeCapture({eventName:`${H}/face_scan_upload_complete`,faceScanId:M,email:P,completionTime:n,uploadDuration:r}),console.log("✅ Upload successful",t),o.swan.measurement.handlFaceScaneSocket({faceScanId:M,onOpen:()=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"open",type:"faceScan_recommendation",email:P}),console.log("websocket connect open")},onError:e=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"error",type:"faceScan_recommendation",email:P}),ee(e)},onSuccess:e=>{a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"success",type:"faceScan_recommendation",email:P}),te(e)},onClose:()=>{console.log("websocket connect close"),a.handleWebSocketCapture({eventName:`${H}/webSocket`,faceScanID:M,connection:"close",type:"faceScan_recommendation",email:P})}})}catch(e){ee(e)}}},U=t.useCallback(()=>{console.log("Starting recording for stages 1-3...");const e=m.current?.srcObject;if(!e)return;const t=e.getVideoTracks()[0].getSettings(),{width:n=a.videoConstraints.width,height:o=a.videoConstraints.height}=t,r=document.createElement("canvas"),s=r.getContext("2d");n>o?(r.width=o,r.height=n):(r.width=n,r.height=o);const c=document.createElement("video");c.srcObject=e,c.muted=!0,c.playsInline=!0,c.play();const i=()=>{n>o?(s?.save(),s?.translate(r.width,0),s?.rotate(Math.PI/2),s?.drawImage(c,0,0,o,n),s?.restore()):s?.drawImage(c,0,0,n,o),requestAnimationFrame(i)};i();const l=r.captureStream(30),d=q.length>0?{mimeType:q[0]}:{};let u;try{u=new MediaRecorder(l,d)}catch(e){return console.error("MediaRecorder init failed:",e),A(!0),void v(!1)}S.current=[],u.ondataavailable=e=>{e?.data&&e.data.size>0&&S.current&&S.current.push(e.data)},u.onstop=()=>{console.log("Recording stopped, total blobs:",S?.current?.length),V()},u.start(100),y.current=u,console.log("Recording started successfully (portrait normalized)")},[q,V]),{faceScanDetector:B,scanStage:G,setScanStage:J,resetScan:K,isModelLoaded:X,startScanSequence:Y}=f({faceScanId:M,shopDomain:H,onScanComplete:()=>{L()},onModelReady:()=>{F(!0)},onStartRecording:()=>{console.log("Stage 0 completed - starting recording for stages 1-3"),U()}}),Q=t.useCallback(()=>{X&&(J(0),o.speechService.playAudio(`${a.voiceOverAssetsPath}face-scan-vos/Face-forward.mp3`),setTimeout(()=>{C(!0),setTimeout(()=>{Y()},200)},200))},[J,C,Y,X]),Z=t.useCallback(()=>{C(!1),N(!0),L(),K(),i?.(),S.current=[],y.current&&(y.current=null),A(!1),J(-1),R(a.generateUuid()),m.current&&x.current&&(m.current.srcObject=x.current,console.log("Camera stream restored after reset"))},[J,C,N,L,K,R]),ee=e=>{console.log(e,"ws error"),c?.(e),A(!0),v(!1),N(!1),a.handleScanTimeCapture({eventName:`${H}/faceScan`,faceScanId:M,status:"failed",email:P,data:JSON.stringify(e)})},te=e=>{console.log(e,"ws success"),e&&"intermediate"===e?.resultType&&a.handleScanTimeCapture({eventName:`${H}/faceScan_success/intermediate`,faceScanId:M,status:"success",email:P,data:JSON.stringify(e)}),s?.(e)};t.useEffect(()=>{if(!h&&!g)return navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:a.videoConstraints}).then(e=>{x.current=e,m.current&&(m.current.srcObject=e,console.log("Webcam initialized"))}).catch(e=>console.error("Error accessing webcam:",e)),()=>{x.current&&x.current.getTracks().forEach(e=>e.stop())}},[h,g]),t.useEffect(()=>{if(!w||!j)return;const e=setInterval(()=>{B(m,p)},500);return()=>clearInterval(e)},[B,w,j]);return console.log("Model ready:",w,"Has error:",D,"Is scanning:",j,"showLoader",b),t.useEffect(()=>{J(-1),h||g||(a.qo.init(a.posthogPublicKey,{api_host:a.posthogPublicHost}),a.qo.capture("$pageview"))},[h,g]),h?e.jsx(d,{config:O}):g?e.jsx("div",{className:"fixed z-[9] w-full h-full",style:{background:O?.style?.base?.primaryColor},children:e.jsx(o.LoadingScreen,{url:O?.loader})}):e.jsxs(e.Fragment,{children:[e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:""}),b&&!D&&e.jsx("div",{className:"fixed z-[9] w-full h-full",style:{background:O?.style?.base?.primaryColor},children:e.jsx(o.LoadingScreen,{url:O?.loader})}),e.jsx("div",{className:"h-full flex-col relative w-full flex justify-center items-center text-center rounded-t-[20px]",style:{background:O?.style?.base?.backgroundColor},children:e.jsx("div",{className:"flex-1 w-full max-w-md overflow-hidden",children:e.jsxs("div",{className:"w-full h-full",children:[e.jsx("video",{ref:m,autoPlay:!0,playsInline:!0,muted:!0,width:a.videoConstraints.width,height:a.videoConstraints.height,className:"w-full h-full object-cover fixed left-0 top-0 z-0",style:{transform:"scaleX(-1)"}}),e.jsx("canvas",{ref:p,width:a.videoConstraints.width,height:a.videoConstraints.height,style:{transform:"scaleX(-1)",opacity:"0"}})]})})}),!b&&D&&e.jsx(d,{loading:b,resetScanState:Z,config:O}),_&&!D&&!b&&e.jsx(o.Drawer,{open:!0,className:"face-scan-small camera-draw",anchor:"bottom",onClose:(e,t)=>{},hideBackdrop:!0,children:e.jsx(l,{stage:G,videoLoading:I,setVideoLoading:k,videoError:T,setVideoError:E,gender:z,config:O,children:e.jsx("div",{className:"flex justify-center w-full p-[1rem]",children:e.jsx(a.SpecificButton,{disabled:b||!X,className:"!w-[60px] !h-[35px] !py-0 !px-0",buttonText:j?"Reset":X?"Start":"Loading...",postfixIcon:j?e.jsx(n.ArrowRight,{}):"",buttonFunc:j?Z:Q,resolvedConfig:O})})})})]})};
2
2
  //# sourceMappingURL=faceScan.js.map
package/dist/faceScan.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as a}from"react/jsx-runtime";import{useRef as n,useState as o,useMemo as r,useCallback as c,useEffect as l}from"react";import{ab as s,av as i,aw as d,a6 as u,ax as h,ay as f,S as m,az as g,aA as p,aB as y,aC as S,a7 as b,aD as w,aE as v,aF as x,aG as F,aH as N}from"./Header-CGdVhD4h.js";import{A as _}from"./arrow-right-DXQbS3wL.js";import{s as I,L as k,D as M,a as D}from"./LoadingScreen-DFKUWqQS.js";import*as z from"@tensorflow-models/pose-detection";import{setBackend as C,ready as P}from"@tensorflow/tfjs";import"react-dom";function T({stage:a,videoLoading:n,setVideoLoading:o,videoError:r,setVideoError:c,children:l,gender:m,config:g}){return-1===a?e("div",{className:"text-center p-[16px] w-full h-full",style:{background:g?.style?.base?.backgroundColor},children:[e("div",{className:"w-full",children:[t(s,{noTitle:!0,resolvedConfig:g}),e("h2",{style:{fontFamily:g?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:g?.style?.heading?.headingFontSize||"32px",color:g?.style?.heading?.headingColor||"#000",fontWeight:g?.style?.heading?.headingFontWeight||"normal"},children:["Make sure your face is fully visible"," "]}),n&&t("div",{className:"mb-4 flex items-center justify-center",style:{fontFamily:g?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:g?.style?.subheading?.subheadingFontSize||"14px",color:g?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:g?.style?.subheading?.subheadingFontWeight||"normal"},children:"Loading video..."}),r&&t("div",{className:"mb-4 text-red-600",style:{fontFamily:g?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:g?.style?.subheading?.subheadingFontSize||"14px",color:"#ff0000",fontWeight:g?.style?.subheading?.subheadingFontWeight||"normal"},children:"Video failed to load. Please refresh the page or check your connection."}),!r&&t("div",{className:" w-[100px] mx-auto",children:t("video",{src:m===u.Male?i:d,autoPlay:!0,loop:!0,controls:!1,muted:!0,playsInline:!0,className:"h-full w-full object-contain border-none",onCanPlay:()=>o(!1),onLoadStart:()=>o(!0),onError:()=>c(!0),"aria-label":"Instructional video: Please remove your glasses before starting the scan."})})]}),l]}):t("div",{className:"text-center p-[16px] w-full h-full",style:{background:g?.style?.base?.backgroundColor},children:e("div",{className:"w-full",children:[t(s,{noTitle:!0,resolvedConfig:g}),t("h3",{className:"mb-[0.5rem]",style:{fontFamily:g?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:g?.style?.heading?.headingFontSize||"32px",color:g?.style?.heading?.headingColor||"#000",fontWeight:g?.style?.heading?.headingFontWeight||"normal"},children:h[a]}),e("div",{className:"max-w-[400px] justify-center gap-1 mx-auto flex items-center",children:[t("div",{className:` w-[120px] overflow-hidden ${0===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.forward:f.female.forward,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${1===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.left:f.female.left,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${2===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.right:f.female.right,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${3===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.smile:f.female.smile,type:"video/mp4"})})})]})]})})}function $({resetScanState:a,loading:n,config:o}){return t("div",{className:"fixed top-[0] left-[0] z-[999] flex justify-center items-center w-full h-full",style:{background:o?.style?.base?.backgroundColor},children:e("div",{className:"flex flex-col w-full items-center p-[1rem] rounded-lg ",children:[t(s,{noTitle:!0,resolvedConfig:o}),e("div",{className:"flex flex-col items-center w-full",children:[t("h2",{className:"text-xl font-semibold text-gray-800 ",style:{fontFamily:o?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:o?.style?.heading?.headingFontSize||"32px",color:o?.style?.heading?.headingColor||"#000",fontWeight:o?.style?.heading?.headingFontWeight||"normal"},children:"Your Scan Failed"}),t("p",{className:"mb-[1.5rem]",style:{fontFamily:o?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:o?.style?.subheading?.subheadingFontSize||"14px",color:o?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:o?.style?.subheading?.subheadingFontWeight||"normal"},children:"Please click below to reset your scan."}),t(m,{disabled:n,className:"w-full h-[45px] shadow-[0px_1px_2px_0px_#00000040] text-[16px]",buttonText:"Reset Scan",postfixIcon:t(_,{}),buttonFunc:()=>a?.(),resolvedConfig:o})]})]})})}let j=null;function E({faceScanId:e,onValidPose:t,onScanComplete:a,onModelReady:s,onStartRecording:i,shopDomain:d}){const u=n(null),[h,f]=o(0),[m,S]=o(0),[b,w]=o(!1),[v,x]=o(!1),F=n(null),N=n(h),_=n(m),k=n([]),M=n(""),D=n(0),T=n(!1),$=n(0),E=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,R=r(()=>["Face front","Turn head fully left","Turn head fully right","Smile facing front"],[]),L=r(()=>function(e,t){let a;return(...n)=>{a&&clearTimeout(a),a=setTimeout(()=>e(...n),t)}}(e=>{g.capture(`${d}/face_scan_pose_detection`,e)},4e3),[d]),O=c((t,a,n,o,r,c)=>{const l=Date.now();if(!(l-$.current<4e3)){$.current=l;try{const l=t[0]||[0,0,0],s=t[2]||[0,0,0],i=t[5]||[0,0,0],d=t[9]||[0,0,0],u=t[10]||[0,0,0],h=t.map(e=>e[2]).filter(e=>e>0),f=h.length>0?h.reduce((e,t)=>e+t,0)/h.length:0,m=a.map(e=>e[2]).filter(e=>e>0),g=m.length>0?m.reduce((e,t)=>e+t,0)/m.length:0,p=Math.abs(s[0]-i[0]),y=l[0]-i[0],S=s[0]-l[0];let b="frontal";1===n?b="left":2===n?b="right":3===n&&(b="frontal_smile");const w={faceScanId:e,stage:n,timestamp:(new Date).toISOString(),data:JSON.stringify({headValid:o,bodyInvalid:r,consecutiveValid:c,avgFaceScore:parseFloat(f.toFixed(3)),avgBodyScore:parseFloat(g.toFixed(3)),faceKeypointsDetected:h.length,bodyKeypointsDetected:m.length,eyeDistance:parseFloat(p.toFixed(2)),noseToRightRatio:parseFloat((y/p).toFixed(3)),noseToLeftRatio:parseFloat((S/p).toFixed(3)),noseScore:parseFloat(l[2].toFixed(3)),leftEyeScore:parseFloat(s[2].toFixed(3)),rightEyeScore:parseFloat(i[2].toFixed(3)),leftMouthScore:parseFloat(d[2].toFixed(3)),rightMouthScore:parseFloat(u[2].toFixed(3)),expectedPosition:b})};L(w)}catch(e){console.warn("Failed to track pose detection:",e)}}},[e,L]),W=()=>{g.capture(`${d}/face_scan_detection_started`,{faceScanId:e,stage:N.current,timestamp:(new Date).toISOString(),stageName:R[N.current]}),setTimeout(()=>{x(!0)},1500)},V=async()=>{try{console.log("Initializing TensorFlow..."),await C("webgl"),await P(),console.log("TensorFlow initialized, loading models...");const e=await(async()=>{if(j)return j;const e=await z.createDetector(z.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),t=document.createElement("canvas");t.width=y.width,t.height=y.height;const a=t.getContext("2d");a&&(a.fillStyle="black",a.fillRect(0,0,t.width,t.height));try{await e.estimatePoses(t)}catch(e){console.log(e,"at time of preload")}return j=e,e})();console.log(e,"detector"),u.current=e,console.log("Pose detection model loaded successfully"),w(!0),s?.()}catch(e){console.error("Error initializing face scan:",e)}};return l(()=>(V(),()=>{(async()=>{try{w(!1),u.current&&(await u.current.dispose(),u.current=null)}catch(e){console.error("Error disposing resources:",e)}finally{f(0),S(0),N.current=0,_.current=0,k.current=[]}})()}),[]),l(()=>{N.current=h},[h]),l(()=>{_.current=m},[m]),{faceScanDetector:async(n,o)=>{if(u.current&&n.current&&b&&v)try{const r=await u.current.estimatePoses(n.current);if(r.length>0){const n=[],c=[];if(r[0].keypoints.forEach((e,t)=>{const a=e.score??0,o=[e.x??-1,e.y??-1,a];t<=10?n.push(o):c.push(o)}),o?.current){const e=o.current.getContext("2d"),{width:t,height:a}=o.current;if(e){e.clearRect(0,0,t,a);const n=Math.min(_.current/2,1),o=.35*a;e.beginPath(),e.strokeStyle="#00ff00",e.lineWidth=6,e.arc(t/2,a/2,o+10,-Math.PI/2,-Math.PI/2+2*n*Math.PI),e.stroke()}}const l=((e,t)=>{if(t[0][2]<.2||t[2][2]<.2||t[5][2]<.2)return!1;const a=.5*(t[10][1]+t[9][1])-.5*(t[5][1]+t[2][1]),n=(.5*(t[10][1]+t[9][1])-t[0][1])/a,o=n>.7||n<.3,r=Math.abs(t[2][1]-t[5][1])<.5*a&&Math.abs(t[9][1]-t[10][1])<.5*a,c=t[2][0]-t[5][0],l=t[0][0]-t[5][0],s=l>.4*c&&l<.6*c,i=l>.85*c,d=t[2][0]-t[0][0]>.85*c;switch(e){case 0:case 3:return!o&&r&&s;case 1:return!o&&r&&i;case 2:return!o&&r&&d;default:return!1}})(N.current,n),s=c.slice(2).filter(e=>e[2]>.7).length<=2;k.current.push(l&&s),k.current.length>10&&k.current.shift();if(k.current.filter(Boolean).length>=2){const e=_.current+1;S(e)}else S(Math.max(0,_.current-1));if(_.current>=2){t?.();const n=N.current+1;S(0),k.current=[],f(n),x(!1),(async()=>{if(await I.playAudio(`${p}face-scan-vos/Sound-effect.mp3`),g.capture(`${d}/face_scan_detection_stage_completed`,{faceScanId:e,completedStage:N.current,nextStage:n,timestamp:(new Date).toISOString(),totalStages:4,stageName:R[N.current]}),1===n&&i&&i(),n>=4)a?.();else{let e=null;switch(n){case 1:e="Left.mp3";break;case 2:e="Right.mp3";break;case 3:e="Smile.mp3";break;default:e=null}e&&await I.playAudio(`${p}face-scan-vos/${e}`),W()}})()}O(n,c,N.current,l,s,_.current)}}catch(e){console.error("Pose detection error:",e)}},scanStage:h,setScanStage:f,consecutiveValid:m,isModelLoaded:b,resetScan:()=>{g.capture(`${d}/face_scan_reset`,{faceScanId:e,stage:N.current,timestamp:(new Date).toISOString(),stageName:R[N.current],consecutiveValid:_.current}),f(0),S(0),x(!1),N.current=0,_.current=0,k.current=[],M.current="",D.current=0,T.current=!1,F.current&&(speechSynthesis.cancel(),F.current=null)},enableVoiceCommands:()=>{if(T.current=!0,E&&"speechSynthesis"in window){const e=new SpeechSynthesisUtterance("");e.volume=0,speechSynthesis.speak(e)}},startScanSequence:W,isScanningActive:v}}const R=({userDetails:s,onComplete:i,onScanError:d,onRetry:u,config:h,isError:f,isSuccess:z})=>{const C=n(null),P=n(null),j=n(null),R=n([]),L=n(null),[O,W]=o(!1),[V,A]=o(!1),[U,B]=o(!1),[J,q]=o(!0),[H,K]=o(!1),[X,G]=o(!1),[Y,Q]=o(!1),[Z,ee]=o(S()),te=b(h),{email:ae,gender:ne,deviceFocalLength:oe,shopDomain:re,callbackUrl:ce}=s,le=r(()=>w.filter(e=>MediaRecorder.isTypeSupported(e)),[]),se=c(()=>{console.log("Stopping recording..."),j.current&&"recording"===j.current.state&&j.current.stop(),j.current=null},[]),ie=async()=>{if(W(!0),console.log("upload final video"),R.current){if(0===R.current.length)return console.error("No video data recorded"),Q(!0),void W(!1);const e=new File(R.current,`${Z}.webm`,{type:"video/webm"}),t=e.size,a=(t/1048576).toFixed(2),n=Math.round(t/1e4),o={video_size_mb:parseFloat(a),video_size_bytes:t,blob_count:R.current.length,estimated_duration_seconds:n},r=[{gender:ne},{face_scan_id:Z},{focal_length:`${oe}`},{customer_store_url:re},{scan_type:"face_scan"},{callback_url:ce}];F({eventName:`${re}/face_scan_meta_data`,faceScanId:Z,email:ae,data:JSON.stringify({metaData:r,videoData:o})});const c=Date.now();F({eventName:`${re}/face_scan_upload_start`,faceScanId:Z,email:ae,startTime:c});try{const t=await D.fileUpload.faceScanFileUploader({file:e,objectKey:Z,email:ae,arrayMetaData:r,contentType:e.type}),a=Date.now();F({eventName:`${re}/face_scan_upload_complete`,faceScanId:Z,email:ae,completionTime:a,uploadDuration:a-c}),console.log("✅ Upload successful",t),D.measurement.handlFaceScaneSocket({faceScanId:Z,onOpen:()=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"open",type:"faceScan_recommendation",email:ae}),console.log("websocket connect open")},onError:e=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"error",type:"faceScan_recommendation",email:ae}),be(e)},onSuccess:e=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"success",type:"faceScan_recommendation",email:ae}),we(e)},onClose:()=>{console.log("websocket connect close"),N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"close",type:"faceScan_recommendation",email:ae})}})}catch(e){be(e)}}},de=c(()=>{console.log("Starting recording for stages 1-3...");const e=C.current?.srcObject;if(!e)return;const t=e.getVideoTracks()[0].getSettings(),{width:a=y.width,height:n=y.height}=t,o=document.createElement("canvas"),r=o.getContext("2d");a>n?(o.width=n,o.height=a):(o.width=a,o.height=n);const c=document.createElement("video");c.srcObject=e,c.muted=!0,c.playsInline=!0,c.play();const l=()=>{a>n?(r?.save(),r?.translate(o.width,0),r?.rotate(Math.PI/2),r?.drawImage(c,0,0,n,a),r?.restore()):r?.drawImage(c,0,0,a,n),requestAnimationFrame(l)};l();const s=o.captureStream(30),i=le.length>0?{mimeType:le[0]}:{};let d;try{d=new MediaRecorder(s,i)}catch(e){return console.error("MediaRecorder init failed:",e),Q(!0),void W(!1)}R.current=[],d.ondataavailable=e=>{e?.data&&e.data.size>0&&R.current&&R.current.push(e.data)},d.onstop=()=>{console.log("Recording stopped, total blobs:",R?.current?.length),ie()},d.start(100),j.current=d,console.log("Recording started successfully (portrait normalized)")},[le,ie]),{faceScanDetector:ue,scanStage:he,setScanStage:fe,resetScan:me,isModelLoaded:ge,startScanSequence:pe}=E({faceScanId:Z,shopDomain:re,onScanComplete:()=>{se()},onModelReady:()=>{A(!0)},onStartRecording:()=>{console.log("Stage 0 completed - starting recording for stages 1-3"),de()}}),ye=c(()=>{ge&&(fe(0),I.playAudio(`${p}face-scan-vos/Face-forward.mp3`),setTimeout(()=>{B(!0),setTimeout(()=>{pe()},200)},200))},[fe,B,pe,ge]),Se=c(()=>{B(!1),q(!0),se(),me(),u?.(),R.current=[],j.current&&(j.current=null),Q(!1),fe(-1),ee(S()),C.current&&L.current&&(C.current.srcObject=L.current,console.log("Camera stream restored after reset"))},[fe,B,q,se,me,ee]),be=e=>{console.log(e,"ws error"),d?.(e),Q(!0),W(!1),q(!1),F({eventName:`${re}/faceScan`,faceScanId:Z,status:"failed",email:ae,data:JSON.stringify(e)})},we=e=>{console.log(e,"ws success"),e&&"intermediate"===e?.resultType&&F({eventName:`${re}/faceScan_success/intermediate`,faceScanId:Z,status:"success",email:ae,data:JSON.stringify(e)}),i?.(e)};l(()=>{if(!f&&!z)return navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:y}).then(e=>{L.current=e,C.current&&(C.current.srcObject=e,console.log("Webcam initialized"))}).catch(e=>console.error("Error accessing webcam:",e)),()=>{L.current&&L.current.getTracks().forEach(e=>e.stop())}},[f,z]),l(()=>{if(!V||!U)return;const e=setInterval(()=>{ue(C,P)},500);return()=>clearInterval(e)},[ue,V,U]);return console.log("Model ready:",V,"Has error:",Y,"Is scanning:",U,"showLoader",O),l(()=>{fe(-1),f||z||(g.init(v,{api_host:x}),g.capture("$pageview"))},[f,z]),f?t($,{config:te}):z?t("div",{className:"fixed z-[9] w-full h-full",style:{background:te?.style?.base?.primaryColor},children:t(k,{url:te?.loader})}):e(a,{children:[t("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:""}),O&&!Y&&t("div",{className:"fixed z-[9] w-full h-full",style:{background:te?.style?.base?.primaryColor},children:t(k,{url:te?.loader})}),t("div",{className:"h-full flex-col relative w-full flex justify-center items-center text-center rounded-t-[20px]",style:{background:te?.style?.base?.backgroundColor},children:t("div",{className:"flex-1 w-full max-w-md overflow-hidden",children:e("div",{className:"w-full h-full",children:[t("video",{ref:C,autoPlay:!0,playsInline:!0,muted:!0,width:y.width,height:y.height,className:"w-full h-full object-cover fixed left-0 top-0 z-0",style:{transform:"scaleX(-1)"}}),t("canvas",{ref:P,width:y.width,height:y.height,style:{transform:"scaleX(-1)",opacity:"0"}})]})})}),!O&&Y&&t($,{loading:O,resetScanState:Se,config:te}),J&&!Y&&!O&&t(M,{open:!0,className:"face-scan-small camera-draw",anchor:"bottom",onClose:(e,t)=>{},hideBackdrop:!0,children:t(T,{stage:he,videoLoading:H,setVideoLoading:K,videoError:X,setVideoError:G,gender:ne,config:te,children:t("div",{className:"flex justify-center w-full p-[1rem]",children:t(m,{disabled:O||!ge,className:"!w-[60px] !h-[35px] !py-0 !px-0",buttonText:U?"Reset":ge?"Start":"Loading...",postfixIcon:U?t(_,{}):"",buttonFunc:U?Se:ye,resolvedConfig:te})})})})]})};export{R as FaceScan};
1
+ import{jsxs as e,jsx as t,Fragment as a}from"react/jsx-runtime";import{useRef as n,useState as o,useMemo as r,useCallback as c,useEffect as l}from"react";import{ab as s,av as i,aw as d,a6 as u,ax as h,ay as f,S as m,az as g,aA as p,aB as y,aC as S,a7 as b,aD as w,aE as v,aF as x,aG as F,aH as N}from"./Header-C65iSMsF.js";import{A as _}from"./arrow-right-DXQbS3wL.js";import{s as I,L as k,D as M,a as D}from"./LoadingScreen-DGyU-r8n.js";import*as z from"@tensorflow-models/pose-detection";import{setBackend as C,ready as P}from"@tensorflow/tfjs";import"react-dom";function T({stage:a,videoLoading:n,setVideoLoading:o,videoError:r,setVideoError:c,children:l,gender:m,config:g}){return-1===a?e("div",{className:"text-center p-[16px] w-full h-full",style:{background:g?.style?.base?.backgroundColor},children:[e("div",{className:"w-full",children:[t(s,{noTitle:!0,resolvedConfig:g}),e("h2",{style:{fontFamily:g?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:g?.style?.heading?.headingFontSize||"32px",color:g?.style?.heading?.headingColor||"#000",fontWeight:g?.style?.heading?.headingFontWeight||"normal"},children:["Make sure your face is fully visible"," "]}),n&&t("div",{className:"mb-4 flex items-center justify-center",style:{fontFamily:g?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:g?.style?.subheading?.subheadingFontSize||"14px",color:g?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:g?.style?.subheading?.subheadingFontWeight||"normal"},children:"Loading video..."}),r&&t("div",{className:"mb-4 text-red-600",style:{fontFamily:g?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:g?.style?.subheading?.subheadingFontSize||"14px",color:"#ff0000",fontWeight:g?.style?.subheading?.subheadingFontWeight||"normal"},children:"Video failed to load. Please refresh the page or check your connection."}),!r&&t("div",{className:" w-[100px] mx-auto",children:t("video",{src:m===u.Male?i:d,autoPlay:!0,loop:!0,controls:!1,muted:!0,playsInline:!0,className:"h-full w-full object-contain border-none",onCanPlay:()=>o(!1),onLoadStart:()=>o(!0),onError:()=>c(!0),"aria-label":"Instructional video: Please remove your glasses before starting the scan."})})]}),l]}):t("div",{className:"text-center p-[16px] w-full h-full",style:{background:g?.style?.base?.backgroundColor},children:e("div",{className:"w-full",children:[t(s,{noTitle:!0,resolvedConfig:g}),t("h3",{className:"mb-[0.5rem]",style:{fontFamily:g?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:g?.style?.heading?.headingFontSize||"32px",color:g?.style?.heading?.headingColor||"#000",fontWeight:g?.style?.heading?.headingFontWeight||"normal"},children:h[a]}),e("div",{className:"max-w-[400px] justify-center gap-1 mx-auto flex items-center",children:[t("div",{className:` w-[120px] overflow-hidden ${0===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.forward:f.female.forward,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${1===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.left:f.female.left,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${2===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.right:f.female.right,type:"video/mp4"})})}),t("div",{className:` w-[120px] overflow-hidden ${3===a?"opacity-100":"opacity-0 hidden"} `,children:t("video",{className:"h-full w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:t("source",{src:m===u.Male?f.male.smile:f.female.smile,type:"video/mp4"})})})]})]})})}function $({resetScanState:a,loading:n,config:o}){return t("div",{className:"fixed top-[0] left-[0] z-[999] flex justify-center items-center w-full h-full",style:{background:o?.style?.base?.backgroundColor},children:e("div",{className:"flex flex-col w-full items-center p-[1rem] rounded-lg ",children:[t(s,{noTitle:!0,resolvedConfig:o}),e("div",{className:"flex flex-col items-center w-full",children:[t("h2",{className:"text-xl font-semibold text-gray-800 ",style:{fontFamily:o?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:o?.style?.heading?.headingFontSize||"32px",color:o?.style?.heading?.headingColor||"#000",fontWeight:o?.style?.heading?.headingFontWeight||"normal"},children:"Your Scan Failed"}),t("p",{className:"mb-[1.5rem]",style:{fontFamily:o?.style?.subheading?.subheadingFontFamily||"'Inter', sans-serif",fontSize:o?.style?.subheading?.subheadingFontSize||"14px",color:o?.style?.subheading?.subheadingColor||"#4b5563",fontWeight:o?.style?.subheading?.subheadingFontWeight||"normal"},children:"Please click below to reset your scan."}),t(m,{disabled:n,className:"w-full h-[45px] shadow-[0px_1px_2px_0px_#00000040] text-[16px]",buttonText:"Reset Scan",postfixIcon:t(_,{}),buttonFunc:()=>a?.(),resolvedConfig:o})]})]})})}let j=null;function E({faceScanId:e,onValidPose:t,onScanComplete:a,onModelReady:s,onStartRecording:i,shopDomain:d}){const u=n(null),[h,f]=o(0),[m,S]=o(0),[b,w]=o(!1),[v,x]=o(!1),F=n(null),N=n(h),_=n(m),k=n([]),M=n(""),D=n(0),T=n(!1),$=n(0),E=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,R=r(()=>["Face front","Turn head fully left","Turn head fully right","Smile facing front"],[]),L=r(()=>function(e,t){let a;return(...n)=>{a&&clearTimeout(a),a=setTimeout(()=>e(...n),t)}}(e=>{g.capture(`${d}/face_scan_pose_detection`,e)},4e3),[d]),O=c((t,a,n,o,r,c)=>{const l=Date.now();if(!(l-$.current<4e3)){$.current=l;try{const l=t[0]||[0,0,0],s=t[2]||[0,0,0],i=t[5]||[0,0,0],d=t[9]||[0,0,0],u=t[10]||[0,0,0],h=t.map(e=>e[2]).filter(e=>e>0),f=h.length>0?h.reduce((e,t)=>e+t,0)/h.length:0,m=a.map(e=>e[2]).filter(e=>e>0),g=m.length>0?m.reduce((e,t)=>e+t,0)/m.length:0,p=Math.abs(s[0]-i[0]),y=l[0]-i[0],S=s[0]-l[0];let b="frontal";1===n?b="left":2===n?b="right":3===n&&(b="frontal_smile");const w={faceScanId:e,stage:n,timestamp:(new Date).toISOString(),data:JSON.stringify({headValid:o,bodyInvalid:r,consecutiveValid:c,avgFaceScore:parseFloat(f.toFixed(3)),avgBodyScore:parseFloat(g.toFixed(3)),faceKeypointsDetected:h.length,bodyKeypointsDetected:m.length,eyeDistance:parseFloat(p.toFixed(2)),noseToRightRatio:parseFloat((y/p).toFixed(3)),noseToLeftRatio:parseFloat((S/p).toFixed(3)),noseScore:parseFloat(l[2].toFixed(3)),leftEyeScore:parseFloat(s[2].toFixed(3)),rightEyeScore:parseFloat(i[2].toFixed(3)),leftMouthScore:parseFloat(d[2].toFixed(3)),rightMouthScore:parseFloat(u[2].toFixed(3)),expectedPosition:b})};L(w)}catch(e){console.warn("Failed to track pose detection:",e)}}},[e,L]),W=()=>{g.capture(`${d}/face_scan_detection_started`,{faceScanId:e,stage:N.current,timestamp:(new Date).toISOString(),stageName:R[N.current]}),setTimeout(()=>{x(!0)},1500)},V=async()=>{try{console.log("Initializing TensorFlow..."),await C("webgl"),await P(),console.log("TensorFlow initialized, loading models...");const e=await(async()=>{if(j)return j;const e=await z.createDetector(z.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),t=document.createElement("canvas");t.width=y.width,t.height=y.height;const a=t.getContext("2d");a&&(a.fillStyle="black",a.fillRect(0,0,t.width,t.height));try{await e.estimatePoses(t)}catch(e){console.log(e,"at time of preload")}return j=e,e})();console.log(e,"detector"),u.current=e,console.log("Pose detection model loaded successfully"),w(!0),s?.()}catch(e){console.error("Error initializing face scan:",e)}};return l(()=>(V(),()=>{(async()=>{try{w(!1),u.current&&(await u.current.dispose(),u.current=null)}catch(e){console.error("Error disposing resources:",e)}finally{f(0),S(0),N.current=0,_.current=0,k.current=[]}})()}),[]),l(()=>{N.current=h},[h]),l(()=>{_.current=m},[m]),{faceScanDetector:async(n,o)=>{if(u.current&&n.current&&b&&v)try{const r=await u.current.estimatePoses(n.current);if(r.length>0){const n=[],c=[];if(r[0].keypoints.forEach((e,t)=>{const a=e.score??0,o=[e.x??-1,e.y??-1,a];t<=10?n.push(o):c.push(o)}),o?.current){const e=o.current.getContext("2d"),{width:t,height:a}=o.current;if(e){e.clearRect(0,0,t,a);const n=Math.min(_.current/2,1),o=.35*a;e.beginPath(),e.strokeStyle="#00ff00",e.lineWidth=6,e.arc(t/2,a/2,o+10,-Math.PI/2,-Math.PI/2+2*n*Math.PI),e.stroke()}}const l=((e,t)=>{if(t[0][2]<.2||t[2][2]<.2||t[5][2]<.2)return!1;const a=.5*(t[10][1]+t[9][1])-.5*(t[5][1]+t[2][1]),n=(.5*(t[10][1]+t[9][1])-t[0][1])/a,o=n>.7||n<.3,r=Math.abs(t[2][1]-t[5][1])<.5*a&&Math.abs(t[9][1]-t[10][1])<.5*a,c=t[2][0]-t[5][0],l=t[0][0]-t[5][0],s=l>.4*c&&l<.6*c,i=l>.85*c,d=t[2][0]-t[0][0]>.85*c;switch(e){case 0:case 3:return!o&&r&&s;case 1:return!o&&r&&i;case 2:return!o&&r&&d;default:return!1}})(N.current,n),s=c.slice(2).filter(e=>e[2]>.7).length<=2;k.current.push(l&&s),k.current.length>10&&k.current.shift();if(k.current.filter(Boolean).length>=2){const e=_.current+1;S(e)}else S(Math.max(0,_.current-1));if(_.current>=2){t?.();const n=N.current+1;S(0),k.current=[],f(n),x(!1),(async()=>{if(await I.playAudio(`${p}face-scan-vos/Sound-effect.mp3`),g.capture(`${d}/face_scan_detection_stage_completed`,{faceScanId:e,completedStage:N.current,nextStage:n,timestamp:(new Date).toISOString(),totalStages:4,stageName:R[N.current]}),1===n&&i&&i(),n>=4)a?.();else{let e=null;switch(n){case 1:e="Left.mp3";break;case 2:e="Right.mp3";break;case 3:e="Smile.mp3";break;default:e=null}e&&await I.playAudio(`${p}face-scan-vos/${e}`),W()}})()}O(n,c,N.current,l,s,_.current)}}catch(e){console.error("Pose detection error:",e)}},scanStage:h,setScanStage:f,consecutiveValid:m,isModelLoaded:b,resetScan:()=>{g.capture(`${d}/face_scan_reset`,{faceScanId:e,stage:N.current,timestamp:(new Date).toISOString(),stageName:R[N.current],consecutiveValid:_.current}),f(0),S(0),x(!1),N.current=0,_.current=0,k.current=[],M.current="",D.current=0,T.current=!1,F.current&&(speechSynthesis.cancel(),F.current=null)},enableVoiceCommands:()=>{if(T.current=!0,E&&"speechSynthesis"in window){const e=new SpeechSynthesisUtterance("");e.volume=0,speechSynthesis.speak(e)}},startScanSequence:W,isScanningActive:v}}const R=({userDetails:s,onComplete:i,onScanError:d,onRetry:u,config:h,isError:f,isSuccess:z})=>{const C=n(null),P=n(null),j=n(null),R=n([]),L=n(null),[O,W]=o(!1),[V,A]=o(!1),[U,B]=o(!1),[J,q]=o(!0),[H,K]=o(!1),[X,G]=o(!1),[Y,Q]=o(!1),[Z,ee]=o(S()),te=b(h),{email:ae,gender:ne,deviceFocalLength:oe,shopDomain:re,callbackUrl:ce}=s,le=r(()=>w.filter(e=>MediaRecorder.isTypeSupported(e)),[]),se=c(()=>{console.log("Stopping recording..."),j.current&&"recording"===j.current.state&&j.current.stop(),j.current=null},[]),ie=async()=>{if(W(!0),console.log("upload final video"),R.current){if(0===R.current.length)return console.error("No video data recorded"),Q(!0),void W(!1);const e=new File(R.current,`${Z}.webm`,{type:"video/webm"}),t=e.size,a=(t/1048576).toFixed(2),n=Math.round(t/1e4),o={video_size_mb:parseFloat(a),video_size_bytes:t,blob_count:R.current.length,estimated_duration_seconds:n},r=[{gender:ne},{face_scan_id:Z},{focal_length:`${oe}`},{customer_store_url:re},{scan_type:"face_scan"},{callback_url:ce}];F({eventName:`${re}/face_scan_meta_data`,faceScanId:Z,email:ae,data:JSON.stringify({metaData:r,videoData:o})});const c=Date.now();F({eventName:`${re}/face_scan_upload_start`,faceScanId:Z,email:ae,startTime:c});try{const t=await D.fileUpload.faceScanFileUploader({file:e,objectKey:Z,email:ae,arrayMetaData:r,contentType:e.type}),a=Date.now();F({eventName:`${re}/face_scan_upload_complete`,faceScanId:Z,email:ae,completionTime:a,uploadDuration:a-c}),console.log("✅ Upload successful",t),D.measurement.handlFaceScaneSocket({faceScanId:Z,onOpen:()=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"open",type:"faceScan_recommendation",email:ae}),console.log("websocket connect open")},onError:e=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"error",type:"faceScan_recommendation",email:ae}),be(e)},onSuccess:e=>{N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"success",type:"faceScan_recommendation",email:ae}),we(e)},onClose:()=>{console.log("websocket connect close"),N({eventName:`${re}/webSocket`,faceScanID:Z,connection:"close",type:"faceScan_recommendation",email:ae})}})}catch(e){be(e)}}},de=c(()=>{console.log("Starting recording for stages 1-3...");const e=C.current?.srcObject;if(!e)return;const t=e.getVideoTracks()[0].getSettings(),{width:a=y.width,height:n=y.height}=t,o=document.createElement("canvas"),r=o.getContext("2d");a>n?(o.width=n,o.height=a):(o.width=a,o.height=n);const c=document.createElement("video");c.srcObject=e,c.muted=!0,c.playsInline=!0,c.play();const l=()=>{a>n?(r?.save(),r?.translate(o.width,0),r?.rotate(Math.PI/2),r?.drawImage(c,0,0,n,a),r?.restore()):r?.drawImage(c,0,0,a,n),requestAnimationFrame(l)};l();const s=o.captureStream(30),i=le.length>0?{mimeType:le[0]}:{};let d;try{d=new MediaRecorder(s,i)}catch(e){return console.error("MediaRecorder init failed:",e),Q(!0),void W(!1)}R.current=[],d.ondataavailable=e=>{e?.data&&e.data.size>0&&R.current&&R.current.push(e.data)},d.onstop=()=>{console.log("Recording stopped, total blobs:",R?.current?.length),ie()},d.start(100),j.current=d,console.log("Recording started successfully (portrait normalized)")},[le,ie]),{faceScanDetector:ue,scanStage:he,setScanStage:fe,resetScan:me,isModelLoaded:ge,startScanSequence:pe}=E({faceScanId:Z,shopDomain:re,onScanComplete:()=>{se()},onModelReady:()=>{A(!0)},onStartRecording:()=>{console.log("Stage 0 completed - starting recording for stages 1-3"),de()}}),ye=c(()=>{ge&&(fe(0),I.playAudio(`${p}face-scan-vos/Face-forward.mp3`),setTimeout(()=>{B(!0),setTimeout(()=>{pe()},200)},200))},[fe,B,pe,ge]),Se=c(()=>{B(!1),q(!0),se(),me(),u?.(),R.current=[],j.current&&(j.current=null),Q(!1),fe(-1),ee(S()),C.current&&L.current&&(C.current.srcObject=L.current,console.log("Camera stream restored after reset"))},[fe,B,q,se,me,ee]),be=e=>{console.log(e,"ws error"),d?.(e),Q(!0),W(!1),q(!1),F({eventName:`${re}/faceScan`,faceScanId:Z,status:"failed",email:ae,data:JSON.stringify(e)})},we=e=>{console.log(e,"ws success"),e&&"intermediate"===e?.resultType&&F({eventName:`${re}/faceScan_success/intermediate`,faceScanId:Z,status:"success",email:ae,data:JSON.stringify(e)}),i?.(e)};l(()=>{if(!f&&!z)return navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:y}).then(e=>{L.current=e,C.current&&(C.current.srcObject=e,console.log("Webcam initialized"))}).catch(e=>console.error("Error accessing webcam:",e)),()=>{L.current&&L.current.getTracks().forEach(e=>e.stop())}},[f,z]),l(()=>{if(!V||!U)return;const e=setInterval(()=>{ue(C,P)},500);return()=>clearInterval(e)},[ue,V,U]);return console.log("Model ready:",V,"Has error:",Y,"Is scanning:",U,"showLoader",O),l(()=>{fe(-1),f||z||(g.init(v,{api_host:x}),g.capture("$pageview"))},[f,z]),f?t($,{config:te}):z?t("div",{className:"fixed z-[9] w-full h-full",style:{background:te?.style?.base?.primaryColor},children:t(k,{url:te?.loader})}):e(a,{children:[t("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:""}),O&&!Y&&t("div",{className:"fixed z-[9] w-full h-full",style:{background:te?.style?.base?.primaryColor},children:t(k,{url:te?.loader})}),t("div",{className:"h-full flex-col relative w-full flex justify-center items-center text-center rounded-t-[20px]",style:{background:te?.style?.base?.backgroundColor},children:t("div",{className:"flex-1 w-full max-w-md overflow-hidden",children:e("div",{className:"w-full h-full",children:[t("video",{ref:C,autoPlay:!0,playsInline:!0,muted:!0,width:y.width,height:y.height,className:"w-full h-full object-cover fixed left-0 top-0 z-0",style:{transform:"scaleX(-1)"}}),t("canvas",{ref:P,width:y.width,height:y.height,style:{transform:"scaleX(-1)",opacity:"0"}})]})})}),!O&&Y&&t($,{loading:O,resetScanState:Se,config:te}),J&&!Y&&!O&&t(M,{open:!0,className:"face-scan-small camera-draw",anchor:"bottom",onClose:(e,t)=>{},hideBackdrop:!0,children:t(T,{stage:he,videoLoading:H,setVideoLoading:K,videoError:X,setVideoError:G,gender:ne,config:te,children:t("div",{className:"flex justify-center w-full p-[1rem]",children:t(m,{disabled:O||!ge,className:"!w-[60px] !h-[35px] !py-0 !px-0",buttonText:U?"Reset":ge?"Start":"Loading...",postfixIcon:U?t(_,{}):"",buttonFunc:U?Se:ye,resolvedConfig:te})})})})]})};export{R as FaceScan};
2
2
  //# sourceMappingURL=faceScan.mjs.map