{"version":3,"file":"PasswordProtection.DzekL3L1.mjs","names":["useState","_Fragment","__esmMin","_e","l","p","c","init_jsx_runtime","init_npm_react_18_3_1","ce","withPasswordProtection","hashedCorrectPassword","password","setPassword","showContent","setShowContent","showForm","setShowForm","userPassword","sha256","Component","props","event","init_PasswordProtection","data","str","hashArray","byte"],"sources":["https:/framerusercontent.com/modules/Dtk1f6yEIsNJW7W7LZCG/fowKFy1yJa6l7B1WhH3D/PasswordProtection.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";const sha256=str=>{const encoder=new TextEncoder;const data=encoder.encode(str);return crypto.subtle.digest(\"SHA-256\",data).then(hashArray=>{const hashHex=Array.from(new Uint8Array(hashArray)).map(byte=>byte.toString(16).padStart(2,\"0\")).join(\"\");return hashHex;});};export function withPasswordProtection(Component){const hashedCorrectPassword=\"1238aa7925f7ad54ea70f8059cb1c2fe5eab7e64ff6f80cc7f359dfe33e89bbb\"// Encrypt your desired password using this link https://workat.tech/developer-tools/sha256-hash-generator than replace its value above, do not remove the double quotes\n;return function WithPasswordProtection(props){const[password,setPassword]=useState(\"\");const[showContent,setShowContent]=useState(false);const[showForm,setShowForm]=useState(false);useEffect(()=>{const userPassword=localStorage.getItem(\"userPassword\");const checkPassword=async()=>{if(userPassword){const hashedUserPassword=await sha256(userPassword);if(hashedUserPassword===hashedCorrectPassword){setShowContent(true);console.log(\"Password validation successful\");}}setShowForm(true);};checkPassword();},[]);const handleSubmit=async event=>{event.preventDefault();const hashedPassword=await sha256(password);if(hashedPassword===hashedCorrectPassword){setShowContent(true);console.log(\"Password validation successful\");// Store the user input password in local storage\nlocalStorage.setItem(\"userPassword\",password);}else{console.log(\"Incorrect password\");}};const formStyle={display:\"flex\",justifyContent:\"center\",alignItems:\"center\",height:\"100vh\",opacity:showForm?1:0,transition:\"opacity 1s ease\",width:\"100%\"};const inputStyle={padding:\"10px\",borderRadius:\"10px 0 0 10px\",border:\"1px solid #ccc\",borderRight:\"none\",fontSize:\"16px\",width:\"200px\",maxWidth:\"100%\",height:\"45px\",outline:\"none\"};const buttonStyle={padding:\"11px 20px\",borderRadius:\"0 10px 10px 0\",border:\"none\",background:\"#000\",color:\"#fff\",fontSize:\"16px\",cursor:\"pointer\",boxShadow:\"none\",height:\"45px\"};const wrapperStyle={boxShadow:\"rgba(0, 0, 0, 0.26) 0px 0.637473px 1.147451px -1.125px, rgba(0, 0, 0, 0.24) 0px 1.930942px 3.475695px -2.25px, rgba(0, 0, 0, 0.192) 0px 5.104227px 9.187608px -3.375px, rgba(0, 0, 0, 0.03) 0px 16px 28.8px -4.5px\",borderRadius:\"10px\"};return /*#__PURE__*/_jsx(_Fragment,{children:showContent?/*#__PURE__*/_jsx(Component,{...props}):/*#__PURE__*/_jsx(\"form\",{onSubmit:handleSubmit,style:formStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:wrapperStyle,children:[/*#__PURE__*/_jsx(\"input\",{type:\"password\",placeholder:\"Enter password\",style:inputStyle,value:password,onChange:e=>setPassword(e.target.value)}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",style:buttonStyle,children:\"Submit\"})]})})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withPasswordProtection\":{\"type\":\"reactHoc\",\"name\":\"withPasswordProtection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PasswordProtection.map"],"mappings":"A,uIAAgY,SAAgBU,EAAuB,EAAU,CAAC,IAAMC,EAAsB,mEAC7c,OAAO,SAAgC,EAAM,CAAC,GAAK,CAACC,EAASC,GAAab,EAAS,EAAE,EAAO,CAACc,EAAYC,GAAgBf,EAAS,EAAK,EAAO,CAACgB,EAASC,GAAajB,EAAS,EAAK,EAC+qB,OAD7qBS,MAAc,CAAC,IAAMS,EAAa,aAAa,QAAQ,cAAc,GAA6O,SAA9M,CAAIA,GAAqE,MAAxBC,EAAO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