{"version":3,"file":"UnicornStudioEmbed.P3apTxI5.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","p","c","init_jsx_runtime","ce","de","RenderTarget","init_framer_Bf4_tcb2","ControlType","addPropertyControls","UnicornStudioEmbed","elementRef","sceneRef","scriptId","isEditingOrPreviewing","initializeScript","callback","script","initializeUnicornStudio","props","dataScript","query","projectId","production","cacheBuster","existingScene","scene","ourScene","scenes","init_UnicornStudioEmbed"],"sources":["https:/framerusercontent.com/modules/EBeJNkEq3kJKxw7mI83k/ZsDc4PadyOTOX9gN0MlQ/UnicornStudioEmbed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicHeight 400\n * @framerIntrinsicWidth 800\n */export default function UnicornStudioEmbed(props){const elementRef=useRef(null);const sceneRef=useRef(null);const scriptId=useRef(`unicorn-project-${Math.random().toString(36).substr(2,9)}`);useEffect(()=>{const isEditingOrPreviewing=[\"CANVAS\",\"PREVIEW\"].includes(RenderTarget.current());if(RenderTarget.current()===\"CANVAS\"){return;}const initializeScript=callback=>{const existingScript=document.querySelector('script[src^=\"https://cdn.jsdelivr.net/gh/hiunicornstudio\"]');if(!existingScript){const script=document.createElement(\"script\");script.src=\"https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js@v1.4.29/dist/unicornStudio.umd.js\";script.onload=callback;document.head.appendChild(script);}else{callback();}};const initializeUnicornStudio=()=>{if(props.projectJSON){try{// Create script element for JSON data\nconst dataScript=document.createElement(\"script\");dataScript.id=scriptId.current;dataScript.type=\"application/json\";dataScript.textContent=props.projectJSON;document.head.appendChild(dataScript);elementRef.current.setAttribute(\"data-us-project-src\",`${scriptId.current}`);}catch(e){console.error(\"Failed to parse project JSON:\",e);return;}}else if(props.projectId){const query=props.projectId.split(\"?\");const projectId=query[0];const production=query[1]&&query[1].includes(\"production\");const cacheBuster=isEditingOrPreviewing?\"?update=\"+Math.random():\"\";elementRef.current.setAttribute(\"data-us-project\",projectId+cacheBuster);if(production){elementRef.current.setAttribute(\"data-us-production\",1);}}if(window.UnicornStudio){const existingScene=window.UnicornStudio.scenes?.find(scene=>scene.element===elementRef.current||scene.element.contains(elementRef.current));if(existingScene){existingScene.destroy();}else{window.UnicornStudio.destroy();}window.UnicornStudio.init().then(scenes=>{const ourScene=scenes.find(scene=>scene.element===elementRef.current||scene.element.contains(elementRef.current));if(ourScene){sceneRef.current=ourScene;}});}};if(props.projectId||props.projectJSON){if(window.UnicornStudio){initializeUnicornStudio();}else{initializeScript(initializeUnicornStudio);}}return()=>{if(sceneRef.current){sceneRef.current.destroy();sceneRef.current=null;}// Clean up JSON script if it exists\nconst dataScript=document.getElementById(scriptId.current);if(dataScript){dataScript.remove();}};},[props.projectId,props.projectJSON]);if(RenderTarget.current()===\"CANVAS\"){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",height:\"100%\",backgroundColor:\"rgba(0, 0, 0, 0.15)\",color:\"#4B5563\",fontWeight:500,textAlign:\"center\",padding:\"16px\"},children:[/*#__PURE__*/_jsx(\"p\",{style:{fontSize:\"1.25rem\",marginBottom:\"12px\"},children:\"Scene will render in Preview and on your published site.\"}),!props.projectId&&!props.projectJSON?/*#__PURE__*/_jsx(\"p\",{style:{fontSize:\"1rem\",color:\"#EF4444\"},children:\"No project ID, please export your scene and add its project ID in the detail panel.\"}):\" \"]});}return /*#__PURE__*/_jsx(\"div\",{ref:elementRef,\"data-us-dpi\":props.dpi,\"data-us-scale\":props.scale,\"data-us-fps\":props.fps,\"data-us-altText\":props.altText,\"data-us-ariaLabel\":props.ariaLabel,\"data-us-lazyload\":props.lazyLoad?\"true\":\"\",style:{width:\"100%\",height:\"100%\",...props.style},children:props.header&&/*#__PURE__*/_jsx(\"h1\",{style:{width:\"1px\",height:\"1px\",margin:\"-1px\",padding:\"0\",overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",border:\"0\"},children:props.header})});}UnicornStudioEmbed.displayName=\"Unicorn Studio Embed\";addPropertyControls(UnicornStudioEmbed,{projectId:{type:ControlType.String,title:\"Project ID\"},projectJSON:{type:ControlType.String,title:\"Project JSON\"},scale:{type:ControlType.Number,title:\"Scale\",defaultValue:1,min:.25,max:1,step:.01},dpi:{type:ControlType.Number,title:\"DPI\",defaultValue:1.5,min:.5,max:2,step:.1},fps:{type:ControlType.Number,title:\"FPS\",defaultValue:60,min:10,max:120,step:5},header:{type:ControlType.String,title:\"H1 text\"},altText:{type:ControlType.String,title:\"Alt text\"},ariaLabel:{type:ControlType.String,title:\"Aria label\"},lazyLoad:{type:ControlType.Boolean,title:\"Lazy Load\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"UnicornStudioEmbed\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"800\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UnicornStudioEmbed.map"],"mappings":"A,8MAKG,SAAwBc,EAAmB,EAAM,CAAC,IAAMC,EAAWf,EAAO,IAAI,EAAQgB,EAAShB,EAAO,IAAI,EAAQiB,EAASjB,EAAO,mBAAmB,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAE8kB,OAF5kBQ,MAAc,CAAC,IAAMU,EAAsB,CAAC,SAAS,SAAS,CAAC,CAAC,SAASR,EAAa,QAAQ,CAAC,EAAE,GAAGA,EAAa,QAAQ,IAAI,SAAU,OAAQ,IAAMS,EAAiB,GAAU,CAA2G,GA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