{"version":3,"file":"HTMLManualEmbed.DJPRYyTw.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/LhbFitKcPa2q4wcQYeN1/yfasZ1CdX6diapfY0eae/HTMLManualEmbed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useMemo,useRef,useState}from\"react\";export default function HTMLManualEmbed(props){const{source=\"file\",file=\"\",url=\"\",code=\"\",heightMode=\"fill\",fixedHeight=640,minHeight=400,permissions=\"full\",showScrollbars=true,radius=0,background=\"#0A0A0A\",title=\"Embedded HTML\",loadOnCanvas=true,style}=props;const frameRef=useRef(null);const[measuredHeight,setMeasuredHeight]=useState(fixedHeight);const onCanvas=RenderTarget.current()===RenderTarget.canvas;const src=source===\"file\"?file:source===\"url\"?url.trim():\"\";const srcDoc=source===\"code\"?code:\"\";const hasSource=Boolean(src||srcDoc);// A changed source must fully remount the iframe, otherwise the old\n// document's scripts keep running alongside the new one.\nconst frameKey=useMemo(()=>`${source}:${src||srcDoc.length}`,[source,src,srcDoc]);// Omitting the sandbox attribute entirely is what keeps downloads, the\n// clipboard API and localStorage working. \"Restricted\" is here for embedding\n// markup you don't control.\nconst sandbox=permissions===\"restricted\"?\"allow-scripts allow-forms allow-popups allow-modals allow-downloads\":undefined;/* ---------------------------------------------------------------- height */useEffect(()=>{if(heightMode!==\"auto\")return;let raf=0;let observer=null;const commit=h=>{if(!h||h<1)return;setMeasuredHeight(prev=>Math.abs(prev-h)>2?h:prev);};// Path 1: same-origin, read the document directly.\nconst measure=()=>{const frame=frameRef.current;if(!frame)return;try{const doc=frame.contentDocument;if(!doc||!doc.body)return;commit(Math.max(doc.body.scrollHeight,doc.documentElement.scrollHeight));}catch{// Cross-origin. Path 2 handles it.\n}};const handleLoad=()=>{measure();try{const doc=frameRef.current?.contentDocument;if(doc&&\"ResizeObserver\"in window){observer=new ResizeObserver(()=>{cancelAnimationFrame(raf);raf=requestAnimationFrame(measure);});observer.observe(doc.documentElement);}}catch{/* cross-origin */}};// Path 2: the document reports its own height.\nconst handleMessage=event=>{const data=event.data;if(data&&typeof data===\"object\"&&data.type===\"embed:height\"&&typeof data.height===\"number\"){commit(data.height);}};const frame=frameRef.current;frame?.addEventListener(\"load\",handleLoad);window.addEventListener(\"message\",handleMessage);const poll=window.setInterval(measure,750);return()=>{frame?.removeEventListener(\"load\",handleLoad);window.removeEventListener(\"message\",handleMessage);window.clearInterval(poll);cancelAnimationFrame(raf);observer?.disconnect();};},[heightMode,frameKey]);const resolvedHeight=heightMode===\"fill\"?\"100%\":heightMode===\"fixed\"?fixedHeight:Math.max(minHeight,measuredHeight);const container={...style,width:\"100%\",height:resolvedHeight,background,borderRadius:radius,overflow:\"hidden\",position:\"relative\"};/* ------------------------------------------------------------ empty state */if(!hasSource||onCanvas&&!loadOnCanvas){return /*#__PURE__*/_jsx(\"div\",{style:{...container,background:\"#0A0A0A\"},children:/*#__PURE__*/_jsxs(\"div\",{style:emptyWrap,children:[/*#__PURE__*/_jsx(\"div\",{style:emptyRule}),/*#__PURE__*/_jsx(\"div\",{style:emptyTitle,children:hasSource?\"Preview paused\":\"No HTML yet\"}),/*#__PURE__*/_jsx(\"div\",{style:emptyBody,children:hasSource?\"Turn on Load on canvas, or open Preview to run it.\":\"Pick a source in the panel on the right. Upload file is the one you want for a full manual.\"})]})});}/* ----------------------------------------------------------------- iframe */return /*#__PURE__*/_jsx(\"div\",{style:container,children:/*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src||undefined,srcDoc:srcDoc||undefined,title:title,sandbox:sandbox,allow:\"clipboard-write; clipboard-read; fullscreen; accelerometer; gyroscope\",allowFullScreen:true,scrolling:showScrollbars?\"auto\":\"no\",referrerPolicy:\"no-referrer-when-downgrade\",style:{display:\"block\",width:\"100%\",height:\"100%\",border:\"none\",background:\"transparent\",colorScheme:\"normal\"}},frameKey)});}/* -------------------------------------------------------------- empty state */const emptyWrap={position:\"absolute\",inset:0,display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",justifyContent:\"center\",gap:10,padding:\"28px 32px\",fontFamily:\"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace\"};const emptyRule={width:28,height:3,background:\"#C8FF00\"};const emptyTitle={color:\"#F2F2F2\",fontSize:13,fontWeight:700,letterSpacing:\"0.14em\",textTransform:\"uppercase\"};const emptyBody={color:\"#8A8A8A\",fontSize:12,lineHeight:1.6,maxWidth:380};/* ---------------------------------------------------------------- controls */addPropertyControls(HTMLManualEmbed,{source:{type:ControlType.Enum,title:\"Source\",options:[\"file\",\"url\",\"code\"],optionTitles:[\"Upload file\",\"URL\",\"Paste code\"],defaultValue:\"file\",displaySegmentedControl:true},file:{type:ControlType.File,title:\"HTML file\",allowedFileTypes:[\"html\",\"htm\"],hidden:props=>props.source!==\"file\"},url:{type:ControlType.String,title:\"URL\",defaultValue:\"\",placeholder:\"https://example.com/manual.html\",hidden:props=>props.source!==\"url\"},code:{type:ControlType.String,title:\"HTML\",defaultValue:\"\",displayTextArea:true,placeholder:\"<!doctype html> …\",description:\"For small widgets only. Upload the file for anything large.\",hidden:props=>props.source!==\"code\"},heightMode:{type:ControlType.Enum,title:\"Height\",options:[\"fill\",\"fixed\",\"auto\"],optionTitles:[\"Fill frame\",\"Fixed\",\"Fit content\"],defaultValue:\"fill\",displaySegmentedControl:true},fixedHeight:{type:ControlType.Number,title:\"Height\",defaultValue:640,min:100,max:8e3,step:10,unit:\"px\",displayStepper:true,hidden:props=>props.heightMode!==\"fixed\"},minHeight:{type:ControlType.Number,title:\"Min height\",defaultValue:400,min:0,max:4e3,step:10,unit:\"px\",hidden:props=>props.heightMode!==\"auto\"},permissions:{type:ControlType.Enum,title:\"Permissions\",options:[\"full\",\"restricted\"],optionTitles:[\"Full\",\"Restricted\"],defaultValue:\"full\",displaySegmentedControl:true,description:\"Full removes the sandbox so downloads, clipboard and localStorage work. Use Restricted only for markup you don't control.\"},showScrollbars:{type:ControlType.Boolean,title:\"Scrolling\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},loadOnCanvas:{type:ControlType.Boolean,title:\"Load on canvas\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"Turn off to keep the editor fast with heavy documents.\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#0A0A0A\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:80,step:1,unit:\"px\"},title:{type:ControlType.String,title:\"Label\",defaultValue:\"Embedded HTML\",description:\"Accessible name for the frame.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HTMLManualEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HTMLManualEmbed.map"],"mappings":"4NAA+K,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,SAAO,OAAO,OAAK,GAAG,MAAI,GAAG,OAAK,GAAG,aAAW,OAAO,cAAY,IAAI,YAAU,IAAI,cAAY,OAAO,iBAAe,GAAK,SAAO,EAAE,aAAW,UAAU,QAAM,gBAAgB,eAAa,GAAK,SAAO,EAAY,EAASA,EAAO,IAAI,EAAO,CAAC,EAAe,GAAmBC,EAAS,CAAW,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAa,EAAI,IAAS,OAAO,EAAK,IAAS,MAAM,EAAI,KAAK,EAAE,GAAS,EAAO,IAAS,OAAO,EAAK,GAAS,EAAU,GAAQ,GAAK,GAEjsB,EAASC,MAAY,GAAG,EAAO,GAAG,GAAK,EAAO,SAAS,CAAC,EAAO,EAAI,CAAM,CAAC,EAG1E,EAAQ,IAAc,aAAa,sEAAsE,IAAA,GAAuF,MAAc,CAAC,GAAG,IAAa,OAAO,OAAO,IAAI,EAAI,EAAM,EAAS,KAAW,EAAO,GAAG,CAAI,CAAC,GAAG,EAAE,GAAS,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