{"version":3,"file":"MagicPageSpeed.DOTebF6k.mjs","names":[],"sources":["https:/framerusercontent.com/modules/I4x0a7tVZnXletsnnnAJ/s3sPPOgvzJv3dGhlBlYG/MagicPageSpeed.js"],"sourcesContent":["// Component to inject speculation rules in the head of the webpage\n// Only active on live websites, does nothing on canvas\n// Defaults to taking no space on canvas like smooth scroll components\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 0\n * @framerIntrinsicHeight 0\n * @framerDefaultLayoutWidth 0\n * @framerDefaultLayoutHeight 0\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function MagicPageSpeed(props){const{rules=[{action:\"prerender\",pages:\"/*\",timing:\"balanced\"}],debug=false}=props;// Build speculation rules object for display\nconst speculationRules={prefetch:[],prerender:[]};rules.forEach(rule=>{const eagerness=rule.timing===\"instant\"?\"immediate\":rule.timing===\"quick\"?\"eager\":rule.timing===\"balanced\"?\"moderate\":\"conservative\";// Extract URL pattern from link object or string\nlet pagePattern=\"/*\";if(typeof rule.pages===\"string\"){pagePattern=rule.pages||\"/*\";}else if(rule.pages&&typeof rule.pages===\"object\"){// Try to extract href from link object\nif(rule.pages.href){pagePattern=rule.pages.href;}else if(rule.pages.webPageId){// For webPageId, we can't resolve the actual URL in canvas\n// but we can show a pattern that will work on live site\npagePattern=\"/*\";}}// Remove trailing slug and replace with wildcard\n// e.g., \"/blog/getting-started\" becomes \"/blog/*\"\nif(pagePattern!==\"/*\"&&pagePattern.includes(\"/\")){const segments=pagePattern.split(\"/\").filter(Boolean);if(segments.length>1){// Keep all segments except the last one, then add /*\npagePattern=\"/\"+segments.slice(0,-1).join(\"/\")+\"/*\";}else if(segments.length===1){// Single segment, just add /*\npagePattern=\"/\"+segments[0]+\"/*\";}}const ruleConfig={where:{href_matches:pagePattern},eagerness};if(rule.action===\"prefetch\"){speculationRules.prefetch?.push(ruleConfig);}else{speculationRules.prerender?.push(ruleConfig);}});// Remove empty arrays\nif(speculationRules.prefetch?.length===0){delete speculationRules.prefetch;}if(speculationRules.prerender?.length===0){delete speculationRules.prerender;}useEffect(()=>{if(typeof window===\"undefined\")return;if(RenderTarget.current()===RenderTarget.canvas)return;if(RenderTarget.current()===RenderTarget.thumbnail)return;if(RenderTarget.current()===RenderTarget.preview)return;let script=null;try{script=document.createElement(\"script\");script.type=\"speculationrules\";script.textContent=JSON.stringify(speculationRules);document.head.appendChild(script);}catch(error){console.error(\"Error creating speculation rules:\",error);}return()=>{if(script&&script.parentNode){script.parentNode.removeChild(script);}};},[rules]);// When debug is off, return minimal component (like smooth scroll)\nif(!debug){return null;}// When debug is on, show the JSON with proper sizing\nreturn /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",minWidth:200,minHeight:100,display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",justifyContent:\"flex-start\",backgroundColor:\"#f5f5f5\",padding:\"16px\",fontSize:\"12px\",fontFamily:\"monospace\",color:\"#333\",overflow:\"auto\",whiteSpace:\"pre\",borderRadius:\"4px\"},children:JSON.stringify(speculationRules,null,2)});}addPropertyControls(MagicPageSpeed,{debug:{type:ControlType.Boolean,title:\"Debug\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},rules:{type:ControlType.Array,title:\"Rules\",description:\"Visit google.com for help configuring speculation rules\",control:{type:ControlType.Object,controls:{action:{type:ControlType.Enum,title:\"Action\",description:\"Prefetch downloads resources in advance. Prerender fully loads and renders the page in the background.\",options:[\"prefetch\",\"prerender\"],optionTitles:[\"Prefetch\",\"Prerender\"],defaultValue:\"prerender\",displaySegmentedControl:true},pages:{type:ControlType.String,title:\"Pages\",description:\"This will match all pages with a similar URL pattern, not just the exact page you select.\"},timing:{type:ControlType.Enum,title:\"When\",options:[\"instant\",\"quick\",\"balanced\",\"patient\"],optionTitles:[\"Immediately\",\"On Hover\",\"Likely to Click\",\"When Visible\"],defaultValue:\"balanced\"}}},defaultValue:[{action:\"prerender\",pages:\"/*\",timing:\"balanced\"}]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MagicPageSpeed\",\"slots\":[],\"annotations\":{\"framerDefaultLayoutWidth\":\"0\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"0\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerDefaultLayoutHeight\":\"0\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 0\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MagicPageSpeed.map"],"mappings":"2LAWG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,OAAO,YAAY,MAAM,KAAK,OAAO,UAAU,CAAC,EAAE,QAAM,IAAO,EACxH,EAAiB,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC,EAWhD,OAXkD,EAAM,QAAQ,GAAM,CAAC,IAAM,EAAU,EAAK,SAAS,UAAU,YAAY,EAAK,SAAS,QAAQ,QAAQ,EAAK,SAAS,WAAW,WAAW,eACzL,EAAY,KAKhB,GALwB,OAAO,EAAK,OAAQ,SAAU,EAAY,EAAK,OAAO,KAAc,EAAK,OAAO,OAAO,EAAK,OAAQ,WACzH,EAAK,MAAM,KAAM,EAAY,EAAK,MAAM,KAAc,EAAK,MAAM,YAEpE,EAAY,OAET,IAAc,MAAM,EAAY,SAAS,GAAG,EAAE,CAAC,IAAM,EAAS,EAAY,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,EAAK,EAAS,OAAO,EAC3H,EAAY,IAAI,EAAS,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,EAAE,KAAc,EAAS,SAAS,IAC/E,EAAY,IAAI,EAAS,GAAG,KAAM,CAAC,IAAM,EAAW,CAAC,MAAM,CAAC,aAAa,CAAW,EAAE,WAAS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