{"version":3,"file":"Optical_Parameter_Converter_NA_Angle_F_number_.Bm-eWU7c.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/vrZ9GLJqqmA25AeuIxvF/Hpf5OI2LCEkFbaAQqvsA/Optical_Parameter_Converter_NA_Angle_F_number_.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function OpticalParameterConverter(props){const[focalLengthInput,setFocalLengthInput]=useState(\"105\");const[apertureDiameterInput,setApertureDiameterInput]=useState(\"46.256\");const[fNumberInput,setFNumberInput]=useState(\"\");const[naInput,setNaInput]=useState(\"\");const[angleInput,setAngleInput]=useState(\"\");const[errors,setErrors]=useState({});const[results,setResults]=useState({fNumber:null,na:null,angle:null});// Flags to check if user has manually entered optional inputs\nconst isFNumberManual=useRef(false);const isNAManual=useRef(false);const isAngleManual=useRef(false);const calculateResults=()=>{let newErrors={};let newResults={fNumber:null,na:null,angle:null};const focalLength=parseFloat(focalLengthInput);const apertureDiameter=parseFloat(apertureDiameterInput);let fNumber=parseFloat(fNumberInput);let na=parseFloat(naInput);let angleDegrees=parseFloat(angleInput);// Validate base inputs\nif(isNaN(focalLength)||focalLength<=0||isNaN(apertureDiameter)||apertureDiameter<=0){newErrors.base=\"Focal length and aperture diameter must be positive numbers.\";setErrors(newErrors);setResults(newResults);return;}// Calculate F-number from focal length and aperture diameter unless manually entered\nif(!isFNumberManual.current){fNumber=focalLength/apertureDiameter;setFNumberInput(fNumber.toFixed(2));}// Calculate NA from F-number unless manually entered\nif(!isNAManual.current){na=1/(2*fNumber);setNaInput(na.toFixed(4));}// Calculate Full Angle from NA unless manually entered\nif(!isAngleManual.current){angleDegrees=2*(Math.asin(na)*(180/Math.PI));setAngleInput(angleDegrees.toFixed(2));}newResults={fNumber,na,angle:angleDegrees};setErrors(newErrors);setResults(newResults);};// Recalculate whenever inputs change\nuseEffect(()=>{calculateResults();},[focalLengthInput,apertureDiameterInput,fNumberInput,naInput,angleInput]);// Reset manual flags when base inputs change\nuseEffect(()=>{isFNumberManual.current=false;isNAManual.current=false;isAngleManual.current=false;},[focalLengthInput,apertureDiameterInput]);const resetInputs=()=>{setFocalLengthInput(\"105\");setApertureDiameterInput(\"46.256\");setFNumberInput(\"\");setNaInput(\"\");setAngleInput(\"\");setErrors({});setResults({fNumber:null,na:null,angle:null});isFNumberManual.current=false;isNAManual.current=false;isAngleManual.current=false;};const handleFNumberChange=value=>{setFNumberInput(value);isFNumberManual.current=value!==\"\";};const handleNAChange=value=>{setNaInput(value);isNAManual.current=value!==\"\";};const handleAngleChange=value=>{setAngleInput(value);isAngleManual.current=value!==\"\";};const inputStyle={width:\"100%\",padding:\"8px\",backgroundColor:props.inputBackgroundColor,color:props.textColor,border:\"none\",borderRadius:\"4px\",fontSize:\"14px\",marginTop:\"4px\"};const labelStyle={color:props.labelColor,fontSize:\"14px\",marginBottom:\"4px\"};const primaryButtonStyle={marginTop:\"10px\",padding:\"10px\",backgroundColor:props.primaryButtonColor,color:props.textColor,border:\"none\",borderRadius:\"4px\",cursor:\"pointer\",width:\"100%\",fontSize:\"16px\"};const secondaryButtonStyle={marginTop:\"10px\",padding:\"10px\",backgroundColor:props.secondaryButtonColor,color:props.textColor,border:\"none\",borderRadius:\"4px\",cursor:\"pointer\",width:\"100%\",fontSize:\"16px\"};return /*#__PURE__*/_jsxs(\"div\",{style:{fontFamily:\"Arial, sans-serif\",padding:\"20px\",backgroundColor:props.backgroundColor,color:props.textColor,borderRadius:`${props.borderRadius}px`,boxShadow:\"0 4px 6px rgba(0,0,0,0.1)\",width:\"100%\",maxWidth:\"400px\"},children:[/*#__PURE__*/_jsx(\"h2\",{style:{color:props.textColor,marginBottom:\"20px\"},children:props.title}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Focal Length (mm):\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",value:focalLengthInput,onChange:e=>setFocalLengthInput(e.target.value),style:inputStyle})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Aperture Diameter (mm):\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",value:apertureDiameterInput,onChange:e=>setApertureDiameterInput(e.target.value),style:inputStyle})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"F-number (F#):\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",value:fNumberInput,onChange:e=>handleFNumberChange(e.target.value),style:inputStyle,placeholder:\"Calculated from focal length and aperture diameter\"})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Numerical Aperture (NA):\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",value:naInput,onChange:e=>handleNAChange(e.target.value),style:inputStyle,placeholder:\"Calculated from F-number\"})]}),/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"label\",{style:labelStyle,children:\"Full Angle (degrees):\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",value:angleInput,onChange:e=>handleAngleChange(e.target.value),style:inputStyle,placeholder:\"Calculated from NA\"})]}),errors.base&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"red\",fontSize:\"12px\",marginBottom:\"10px\"},children:errors.base}),/*#__PURE__*/_jsxs(\"div\",{style:{marginTop:\"20px\",backgroundColor:props.resultBackgroundColor,padding:\"10px\",borderRadius:\"4px\"},role:\"status\",\"aria-live\":\"polite\",children:[/*#__PURE__*/_jsx(\"h3\",{children:\"Results:\"}),results.fNumber!==null&&/*#__PURE__*/_jsxs(\"p\",{children:[\"F-number (F#): \",results.fNumber.toFixed(2)]}),results.na!==null&&/*#__PURE__*/_jsxs(\"p\",{children:[\"Numerical Aperture (NA): \",results.na.toFixed(4)]}),results.angle!==null&&/*#__PURE__*/_jsxs(\"p\",{children:[\"Full Angle: \",results.angle.toFixed(2),\" degrees\"]})]}),/*#__PURE__*/_jsx(\"button\",{onClick:resetInputs,style:secondaryButtonStyle,children:\"Reset\"})]});}OpticalParameterConverter.displayName=\"Optical Parameter Converter\";addPropertyControls(OpticalParameterConverter,{title:{type:ControlType.String,title:\"Calculator Title\",defaultValue:\"Optical Parameter Converter\"},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#1E1E2E\"},inputBackgroundColor:{type:ControlType.Color,title:\"Input Background\",defaultValue:\"#2D2B55\"},resultBackgroundColor:{type:ControlType.Color,title:\"Result Background\",defaultValue:\"#2D2B55\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#A6A6A6\"},primaryButtonColor:{type:ControlType.Color,title:\"Primary Button Color\",defaultValue:\"#7E57C2\"},secondaryButtonColor:{type:ControlType.Color,title:\"Secondary Button Color\",defaultValue:\"#4A4A4A\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:20,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OpticalParameterConverter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Optical_Parameter_Converter_NA_Angle_F_number_.map"],"mappings":"yRAA0J,SAAwB,EAA0B,EAAM,CAAC,GAAK,CAAC,EAAiB,EAAoB,CAACA,EAAS,OAAY,CAAC,EAAsB,EAAyB,CAACA,EAAS,UAAe,CAAC,EAAa,EAAgB,CAACA,EAAS,IAAS,CAAC,EAAQ,EAAW,CAACA,EAAS,IAAS,CAAC,EAAW,EAAc,CAACA,EAAS,IAAS,CAAC,E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