{"version":3,"file":"shared-lib.DA7_4vLr.mjs","names":["React.useState"],"sources":["https:/framerusercontent.com/modules/eZXTEvyv0PiGj5TUM2U6/gxia4nPciGhURMqeJ3ny/LanguagePair.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * LanguagePair — hreflang + <html lang> for the manually duplicated ET/EN site (aptus.ee).\n *\n * The site is built without Framer Localization: Estonian lives at the root\n * (aptus.ee/tootmise-juhtimine) and English under /en/ (aptus.ee/en/manufacturing-erp).\n * Framer emits no hreflang for manually duplicated pages, and its site-wide\n * lang attribute is wrong for half the pages. This component fixes both.\n *\n * API: ONE prop — siblingPath — the path of the same page in the other\n * language. The component reads its own path from location.pathname and\n * derives which side is ET and which is EN from the /en/ prefix.\n *\n * Usage:\n *  - Place ONE instance on every page (invisible on the live site; a small\n *    chip on the canvas so you can find it).\n *  - Static pages: type the sibling path into the prop\n *    (e.g. on /tootmise-juhtimine set siblingPath=\"/en/manufacturing-erp\").\n *  - CMS detail templates: bind siblingPath to the collection's\n *    \"Teise keele leht\" field.\n *  - Pages with no published sibling: leave siblingPath empty — no hreflang\n *    is emitted (pairs only), but <html lang> is still set correctly.\n *\n * The LanguageSwitcher below reads the tags this component injects, so the\n * header toggle always lands on the matching page, not the homepage.\n */function isEnglishPath(pathname){return pathname===\"/en\"||pathname.startsWith(\"/en/\");}function normalize(path){if(!path)return\"\";return path.startsWith(\"/\")?path:\"/\"+path;}export default function LanguagePair(props){const{siblingPath,siteUrl}=props;const onCanvas=RenderTarget.current()===RenderTarget.canvas;React.useEffect(()=>{if(onCanvas)return;const base=(siteUrl||\"https://aptus.ee\").replace(/\\/+$/,\"\");const ownPath=window.location.pathname;const isEn=isEnglishPath(ownPath);// Framer navigates client-side, so set lang per page, not per site.\ndocument.documentElement.lang=isEn?\"en\":\"et\";// Clear tags left over from a previous client-side navigation.\ndocument.querySelectorAll(\"link[data-language-pair]\").forEach(el=>el.remove());const added=[];const add=(hreflang,path)=>{const link=document.createElement(\"link\");link.rel=\"alternate\";link.hreflang=hreflang;link.href=base+normalize(path);link.setAttribute(\"data-language-pair\",\"true\");document.head.appendChild(link);added.push(link);};// Pairs only: hreflang must be bidirectional between PUBLISHED pages.\n// x-default points to English — an unmatched-language visitor is,\n// by definition, not an Estonian speaker.\nif(siblingPath){const etPath=isEn?siblingPath:ownPath;const enPath=isEn?ownPath:siblingPath;add(\"et\",etPath);add(\"en\",enPath);add(\"x-default\",enPath);}return()=>added.forEach(el=>el.remove());},[siblingPath,siteUrl,onCanvas]);if(onCanvas){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"inline-flex\",alignItems:\"center\",gap:6,padding:\"4px 8px\",borderRadius:6,background:\"rgba(0, 153, 255, 0.12)\",color:\"#0077cc\",font:\"500 11px/1.4 ui-monospace, monospace\",whiteSpace:\"nowrap\"},children:[\"hreflang ⇄ \",siblingPath||\"— (keelepaari pole)\"]});}return null;}addPropertyControls(LanguagePair,{siblingPath:{type:ControlType.String,title:\"Sibling path\",placeholder:\"/en/manufacturing-erp\"},siteUrl:{type:ControlType.String,title:\"Site URL\",defaultValue:\"https://aptus.ee\"}});/**\n * LanguageSwitcher — the header ET/EN toggle.\n *\n * Reads the link tags injected by LanguagePair to find the sibling page.\n * Falls back to \"/\" or \"/en/\" when the page has no published sibling.\n * Style is intentionally minimal — inherits font, exposes colors only.\n */export function LanguageSwitcher(props){const{color=\"#888888\",activeColor=\"#111111\",gap=8}=props;const onCanvas=RenderTarget.current()===RenderTarget.canvas;const isEn=!onCanvas&&typeof window!==\"undefined\"&&isEnglishPath(window.location.pathname);const[siblingPath,setSiblingPath]=React.useState(null);React.useEffect(()=>{if(onCanvas)return;// LanguagePair's effect may run after ours — retry briefly.\nlet tries=0;let timer;const want=isEn?\"et\":\"en\";const find=()=>{const link=document.querySelector(`link[data-language-pair][hreflang=\"${want}\"]`);if(link){try{setSiblingPath(new URL(link.href).pathname);}catch{}return;}if(++tries<20)timer=window.setTimeout(find,100);};find();return()=>window.clearTimeout(timer);},[onCanvas,isEn]);const target=siblingPath||(isEn?\"/\":\"/en/\");const etActive=onCanvas||!isEn;const linkStyle={color,textDecoration:\"none\",font:\"inherit\"};const activeStyle={color:activeColor,fontWeight:600,font:\"inherit\"};return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"inline-flex\",alignItems:\"center\",gap,font:\"inherit\"},children:[etActive?/*#__PURE__*/_jsx(\"span\",{style:activeStyle,children:\"ET\"}):/*#__PURE__*/_jsx(\"a\",{href:target,style:linkStyle,children:\"ET\"}),/*#__PURE__*/_jsx(\"span\",{style:{color,opacity:.4},children:\"/\"}),etActive?/*#__PURE__*/_jsx(\"a\",{href:onCanvas?\"/en/\":target,style:linkStyle,children:\"EN\"}):/*#__PURE__*/_jsx(\"span\",{style:activeStyle,children:\"EN\"})]});}addPropertyControls(LanguageSwitcher,{color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#888888\"},activeColor:{type:ControlType.Color,title:\"Active\",defaultValue:\"#111111\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:8,min:0,max:32}});\nexport const __FramerMetadata__ = {\"exports\":{\"LanguageSwitcher\":{\"type\":\"reactComponent\",\"name\":\"LanguageSwitcher\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"LanguagePair\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LanguagePair.map"],"mappings":"6MAwBG,SAAS,EAAc,EAAS,CAAC,OAAO,IAAW,OAAO,EAAS,WAAW,MAAM,CAAE,CAAC,SAAS,EAAU,EAAK,CAAmB,OAAd,EAAqB,EAAK,WAAW,GAAG,EAAE,EAAK,IAAI,EAAxC,EAA6C,CAAC,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,cAAY,WAAS,EAAY,EAA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