{"version":3,"file":"PreferredSourceButton.CeHO-lqp.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/HdbJaGx1w5VRQrdVwOaE/9lbwPqy6FFTFf5uKOb8S/PreferredSourceButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{createPortal}from\"react-dom\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Google \"Add as preferred source\" button for Framer.\n *\n * Loads https://news.google.com/swg/js/v1/publisher.js and calls init() on\n * mount, so the button also appears after Framer's client-side page\n * transitions (init() re-scans for containers that are not yet initialized).\n *\n * Placement \"floating\" pins the button to a corner of the viewport on wide\n * screens by portaling it to document.body — that keeps it out of the parent\n * stack's flow and out of any ancestor stacking context. Below the breakpoint\n * it renders inline instead, wherever the layer sits in the layout, so phones\n * don't get a third floating control competing with the WhatsApp bubble.\n *\n * Docs: https://developers.google.com/search/docs/appearance/preferred-sources\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */const SCRIPT_ID=\"google-preferred-source-lib\";const SCRIPT_SRC=\"https://news.google.com/swg/js/v1/publisher.js\";function getQueue(){const scope=window;if(!scope.PREFERRED_SOURCE){scope.PREFERRED_SOURCE=[];}return scope.PREFERRED_SOURCE;}function loadLibrary(){if(document.getElementById(SCRIPT_ID))return;const script=document.createElement(\"script\");script.id=SCRIPT_ID;script.async=true;script.src=SCRIPT_SRC;document.head.appendChild(script);}export default function PreferredSourceButton(props){const{variant=\"official\",placement=\"inline\",corner=\"bottom-left\",offsetX=24,offsetY=24,breakpoint=810,label=\"Add Bond Media as a preferred source\",theme=\"light\",lang=\"\",domain=\"\",background=\"#FFFFFF\",textColor=\"#111111\",borderColor=\"#DADCE0\",radius=24,fontSize=15,style}=props;const apiRef=useRef(null);const[,forceRender]=useState(0);const isCanvas=RenderTarget.current()===RenderTarget.canvas;// Only float once mounted on the client and only above the breakpoint.\nconst[mounted,setMounted]=useState(false);const[isWide,setIsWide]=useState(true);useEffect(()=>{setMounted(true);const mq=window.matchMedia(`(min-width: ${breakpoint}px)`);const sync=()=>setIsWide(mq.matches);sync();mq.addEventListener(\"change\",sync);return()=>mq.removeEventListener(\"change\",sync);},[breakpoint]);const isFloating=placement===\"floating\"&&mounted&&isWide&&!isCanvas;useEffect(()=>{if(isCanvas)return;getQueue().push(api=>{apiRef.current=api;api.init(lang?{theme,lang}:{theme});forceRender(n=>n+1);});loadLibrary();},[isCanvas,theme,lang,isFloating]);// ----- Google's own button, rendered into the container it looks for -----\nif(variant===\"official\"){const containerProps={\"google-add-preferred-source-btn\":\"\",\"data-theme\":theme};if(lang)containerProps[\"data-lang\"]=lang;const container=/*#__PURE__*/_jsx(\"div\",{...containerProps,style:{width:\"100%\",minWidth:260,minHeight:60,...isFloating?null:style},children:isCanvas?/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",height:60,border:\"1px dashed #DADCE0\",borderRadius:8,color:\"#5F6368\",fontSize:13},children:placement===\"floating\"?\"Google preferred source button (floats on the live site)\":\"Google preferred source button (published site only)\"}):null});if(isFloating){return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(\"div\",{style:floatStyle(corner,offsetX,offsetY),children:container}),document.body);}return container;}// ----- Your own styling, driving the same API -----\nconst host=domain||(typeof window!==\"undefined\"?window.location.hostname.replace(/^www\\./,\"\"):\"\");// Deeplink fallback for when the library is blocked or still loading.\nconst href=`https://www.google.com/preferences/source?q=${encodeURIComponent(host)}`;const handleClick=event=>{const api=apiRef.current;if(!api)return;// fall through to the deeplink\nevent.preventDefault();api.addPreferredSource(lang?{theme,language:lang}:{theme});};const anchor=/*#__PURE__*/_jsxs(\"a\",{href:href,target:\"_blank\",rel:\"noopener\",onClick:handleClick,style:{display:\"inline-flex\",alignItems:\"center\",gap:8,padding:\"10px 16px\",background,color:textColor,border:`1px solid ${borderColor}`,borderRadius:radius,fontSize,fontWeight:500,lineHeight:1.2,textDecoration:\"none\",whiteSpace:\"nowrap\",cursor:\"pointer\",...isFloating?null:style},children:[/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"9\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M12 8v8M8 12h8\"})]}),label]});if(isFloating){return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(\"div\",{style:floatStyle(corner,offsetX,offsetY),children:anchor}),document.body);}return anchor;}function floatStyle(corner,offsetX,offsetY){const[vertical,horizontal]=corner.split(\"-\");return{position:\"fixed\",[vertical]:offsetY,[horizontal]:offsetX,zIndex:10,pointerEvents:\"auto\"};}addPropertyControls(PreferredSourceButton,{variant:{type:ControlType.Enum,title:\"Button\",defaultValue:\"official\",options:[\"official\",\"custom\"],optionTitles:[\"Google's button\",\"Custom\"]},placement:{type:ControlType.Enum,title:\"Placement\",defaultValue:\"inline\",options:[\"inline\",\"floating\"],optionTitles:[\"In place\",\"Floating\"],description:\"Floating pins it to the viewport above the breakpoint, and falls back to in place below it.\"},corner:{type:ControlType.Enum,title:\"Corner\",defaultValue:\"bottom-left\",options:[\"bottom-left\",\"bottom-right\",\"top-left\",\"top-right\"],optionTitles:[\"Bottom left\",\"Bottom right\",\"Top left\",\"Top right\"],hidden:p=>p.placement!==\"floating\"},offsetX:{type:ControlType.Number,title:\"Offset X\",defaultValue:24,min:0,max:200,hidden:p=>p.placement!==\"floating\"},offsetY:{type:ControlType.Number,title:\"Offset Y\",defaultValue:24,min:0,max:200,hidden:p=>p.placement!==\"floating\"},breakpoint:{type:ControlType.Number,title:\"Float above\",defaultValue:810,min:0,max:1600,unit:\"px\",hidden:p=>p.placement!==\"floating\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Add Bond Media as a preferred source\",hidden:p=>p.variant!==\"custom\"},theme:{type:ControlType.Enum,title:\"Theme\",defaultValue:\"light\",options:[\"light\",\"dark\"],optionTitles:[\"Light\",\"Dark\"]},lang:{type:ControlType.String,title:\"Language\",defaultValue:\"\",placeholder:\"auto (e.g. en)\"},domain:{type:ControlType.String,title:\"Domain\",defaultValue:\"\",placeholder:\"auto (e.g. bondmedia.ae)\",description:\"Fallback link only. Empty uses the current host.\",hidden:p=>p.variant!==\"custom\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\",hidden:p=>p.variant!==\"custom\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#111111\",hidden:p=>p.variant!==\"custom\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#DADCE0\",hidden:p=>p.variant!==\"custom\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:24,min:0,max:40,hidden:p=>p.variant!==\"custom\"},fontSize:{type:ControlType.Number,title:\"Font size\",defaultValue:15,min:10,max:32,hidden:p=>p.variant!==\"custom\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PreferredSourceButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PreferredSourceButton.map"],"mappings":"mOAiBmH,SAAS,GAAU,CAAC,IAAM,EAAM,EAA8D,MAAvD,CAA4B,EAAM,mBAAiB,CAAC,EAAU,EAAM,gBAAiB,CAAC,SAAS,GAAa,CAAC,GAAG,SAAS,eAAe,CAAS,EAAE,OAAO,IAAM,EAAO,SAAS,cAAc,QAAQ,EAAE,EAAO,GAAG,EAAU,EAAO,MAAM,GAAK,EAAO,IAAI,EAAW,SAAS,KAAK,YAAY,CAAM,CAAE,CAAC,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,UAAQ,WAAW,YAAU,SAAS,SAAO,cAAc,UAAQ,GAAG,UAAQ,GAAG,aAAW,IA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