{"version":3,"file":"UnicornStudioEmbed.DmlPhhQ-.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/vbaJXlyVEeIvuEevvudG/J8HpitZNu6FDMkO5HDhL/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.unicorn.studio\"]');if(!existingScript){const script=document.createElement(\"script\");script.src=\"https://cdn.unicorn.studio/v1.3.2/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){var _window_UnicornStudio_scenes;const existingScene=(_window_UnicornStudio_scenes=window.UnicornStudio.scenes)===null||_window_UnicornStudio_scenes===void 0?void 0:_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\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"800\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UnicornStudioEmbed.map"],"mappings":"2UAKG,SAAwB,EAAmB,EAAM,CAAC,IAAM,EAAWA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAO,EAASA,EAAO,mBAAmB,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAE6kB,OAF5kB,MAAc,CAAC,IAAM,EAAsB,CAAC,SAAS,UAAU,CAAC,SAAS,EAAa,SAAS,CAAC,CAAC,GAAG,EAAa,SAAS,GAAG,SAAU,OAAQ,IAAM,EAAiB,GAAU,CAA0F,GAApE,SAAS,cAAc,4CAA4C,CAAsM,GAAU,KAA5L,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,IAAI,yDAAyD,EAAO,OAAO,EAAS,SAAS,KAAK,YAAY,EAAO,GAA2B,MAA4B,CAAC,GAAG,EAAM,YAAa,GAAG,CAC3tB,IAAM,EAAW,SAAS,cAAc,SAAS,CAAC,EAAW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