{"version":3,"file":"UnicornStudioEmbed_1.xT2wWKuC.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","_e","de","p","c","init_jsx_runtime","ce","RenderTarget","init_framer_BkYB2Gqq","addPropertyControls","ControlType","UnicornStudioEmbed","VERSION","props","elementRef","sceneRef","scriptId","versionError","setVersionError","isValidVersion","v","isEditingOrPreviewing","sdkVersion","initializeScript","scriptSrc","script","callback","waitForLoad","initializeUnicornStudio","dataScript","query","projectId","production","cacheBuster","US","s","args","scene","init_UnicornStudioEmbed_1"],"sources":["https:/framerusercontent.com/modules/rTPK9VQ15VOQe8PeNQiv/4pHE8xpeVgYBMxX8Mdx4/UnicornStudioEmbed_1.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const VERSION=\"2.1.0-1\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicHeight 400\n * @framerIntrinsicWidth 800\n */export default function UnicornStudioEmbed(props){const{sdkVersion=VERSION}=props;const elementRef=useRef(null);const sceneRef=useRef(null);const scriptId=useRef(`unicorn-project-${Math.random().toString(36).substr(2,9)}`);const[versionError,setVersionError]=useState(null);// simple semver check: 1.2.3\nconst isValidVersion=v=>/^\\d+\\.\\d+\\.\\d+(-beta)?$/.test(v.trim());useEffect(()=>{const isEditingOrPreviewing=[\"CANVAS\",\"PREVIEW\"].includes(RenderTarget.current());// validate version first\nif(!isValidVersion(sdkVersion)){console.error(`[UnicornStudioEmbed] Invalid SDK version \"${sdkVersion}\". Expected format: x.y.z (e.g. 1.5.3)`);setVersionError(`Invalid SDK version \"${sdkVersion}\". Use x.y.z (e.g. 1.5.3).`);return;}else{setVersionError(null);}if(RenderTarget.current()===\"CANVAS\"){return;}const initializeScript=callback=>{const cdnPrefix=\"https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js\";const scriptSrc=`${cdnPrefix}@v${sdkVersion}/dist/unicornStudio.umd.js`;// check if any unicornstudio.js script is already on the page\nconst existingScript=document.querySelector('script[src^=\"https://cdn.jsdelivr.net/gh/hiunicornstudio/unicornstudio.js\"]');// IMPORTANT:\n// If there is already a script but it's for a different version,\n// we might want to load the desired one anyway. For now, if it's\n// present AND window.UnicornStudio exists, we just use it.\nif(!existingScript){const script=document.createElement(\"script\");script.src=scriptSrc;script.onload=callback;script.onerror=()=>console.error(\"Failed to load UnicornStudio script at \"+scriptSrc);document.body.appendChild(script);}else{if(window.UnicornStudio){callback();}else{const waitForLoad=setInterval(()=>{if(window.UnicornStudio){clearInterval(waitForLoad);callback();}},100);}}};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.body.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\");}}const US=window.UnicornStudio;if(!US||!elementRef.current)return;// 1) Clean up only our previous scene\nUS.scenes?.find(s=>s.element===elementRef.current)?.destroy();// 2) Prepare args\nconst args={element:elementRef.current,dpi:props.dpi,scale:props.scale,fps:props.fps,lazyLoad:!!props.lazyLoad,fixed:!!props.fixed,altText:props.altText,ariaLabel:props.ariaLabel};// If you passed JSON via a <script type=\"application/json\" id=...>\nif(props.projectJSON){// ensure script tag exists (your current code already does this)\nargs.filePath=scriptId.current;}else{args.projectId=props.projectId// your parsed id\n;}// 3) Create only this scene\nUS.addScene(args).then(scene=>{sceneRef.current=scene;});};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,sdkVersion]);// CANVAS mode stays the same\nif(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.\"}):\" \"]});}// runtime render\nreturn /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:[/*#__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,...props.lazyLoad?{\"data-us-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})}),versionError?/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:8,background:\"rgba(239, 68, 68, 0.12)\",border:\"1px solid rgba(239, 68, 68, 0.5)\",borderRadius:6,padding:\"8px 10px\",fontSize:12,color:\"#991B1B\",pointerEvents:\"none\"},children:versionError}):null]});}UnicornStudioEmbed.displayName=\"Unicorn Studio Embed\";addPropertyControls(UnicornStudioEmbed,{projectId:{type:ControlType.String,title:\"Project ID\"},projectJSON:{type:ControlType.String,title:\"Project JSON\"},sdkVersion:{type:ControlType.String,title:\"SDK version\",defaultValue:VERSION,placeholder:VERSION},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},fixed:{type:ControlType.Boolean,title:\"Fixed\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"UnicornStudioEmbed\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"800\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UnicornStudioEmbed_1.map"],"mappings":"A,qNAKG,SAAwBgB,EAAmB,EAAM,CAAC,GAAK,CAAC,aAAWC,GAASC,EAAYC,EAAWnB,EAAO,IAAI,EAAQoB,EAASpB,EAAO,IAAI,EAAQqB,EAASrB,EAAO,mBAAmB,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAO,CAACsB,EAAaC,GAAiBtB,EAAS,IAAI,EAC7QuB,EAAe,GAAG,0BAA0B,KAAKC,EAAE,KAAK,CAAC,EAgB/D,OAhBiEd,MAAc,CAAC,IAAMe,EAAsB,CAAC,SAAS,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