lynkow 3.8.66 → 3.8.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1532,8 +1532,6 @@ interface CookieCategory {
1532
1532
  * Cookie banner texts
1533
1533
  */
1534
1534
  interface CookieTexts {
1535
- /** Title */
1536
- title: string;
1537
1535
  /** Description/message */
1538
1536
  description: string;
1539
1537
  /** "Accept all" button */
@@ -1558,15 +1556,30 @@ interface CookieConfig {
1558
1556
  /** Respect Do Not Track browser setting */
1559
1557
  respectDnt?: boolean;
1560
1558
  /** Banner position */
1561
- position: 'bottom' | 'top' | 'bottom-left' | 'bottom-right' | 'center';
1562
- /** Banner layout style */
1563
- layout: 'banner' | 'floating' | 'modal';
1559
+ position: 'bottom-left' | 'bottom-right';
1560
+ /** Banner layout style (always floating) */
1561
+ layout: 'floating';
1564
1562
  /** Theme */
1565
1563
  theme: 'light' | 'dark' | 'auto';
1566
1564
  /** Primary color for buttons (hex) */
1567
1565
  primaryColor?: string;
1568
1566
  /** Border radius in pixels for container and buttons */
1569
1567
  borderRadius?: number;
1568
+ /** Font size in pixels (11-17) */
1569
+ fontSize?: number;
1570
+ /** Per-theme color styles */
1571
+ themeStyles?: {
1572
+ light: {
1573
+ primaryColor: string;
1574
+ bgColor: string;
1575
+ textColor: string;
1576
+ };
1577
+ dark: {
1578
+ primaryColor: string;
1579
+ bgColor: string;
1580
+ textColor: string;
1581
+ };
1582
+ };
1570
1583
  /** Cookie categories */
1571
1584
  categories: CookieCategory[];
1572
1585
  /** Banner texts */
@@ -2105,6 +2118,8 @@ declare class ConsentService {
2105
2118
  */
2106
2119
  private updateConsentTheme;
2107
2120
  private resolveTheme;
2121
+ private resolveColors;
2122
+ private contrastColor;
2108
2123
  private createBannerHTML;
2109
2124
  private createPreferencesHTML;
2110
2125
  private attachBannerEvents;
package/dist/index.d.ts CHANGED
@@ -1532,8 +1532,6 @@ interface CookieCategory {
1532
1532
  * Cookie banner texts
1533
1533
  */
1534
1534
  interface CookieTexts {
1535
- /** Title */
1536
- title: string;
1537
1535
  /** Description/message */
1538
1536
  description: string;
1539
1537
  /** "Accept all" button */
@@ -1558,15 +1556,30 @@ interface CookieConfig {
1558
1556
  /** Respect Do Not Track browser setting */
1559
1557
  respectDnt?: boolean;
1560
1558
  /** Banner position */
1561
- position: 'bottom' | 'top' | 'bottom-left' | 'bottom-right' | 'center';
1562
- /** Banner layout style */
1563
- layout: 'banner' | 'floating' | 'modal';
1559
+ position: 'bottom-left' | 'bottom-right';
1560
+ /** Banner layout style (always floating) */
1561
+ layout: 'floating';
1564
1562
  /** Theme */
1565
1563
  theme: 'light' | 'dark' | 'auto';
1566
1564
  /** Primary color for buttons (hex) */
1567
1565
  primaryColor?: string;
1568
1566
  /** Border radius in pixels for container and buttons */
1569
1567
  borderRadius?: number;
1568
+ /** Font size in pixels (11-17) */
1569
+ fontSize?: number;
1570
+ /** Per-theme color styles */
1571
+ themeStyles?: {
1572
+ light: {
1573
+ primaryColor: string;
1574
+ bgColor: string;
1575
+ textColor: string;
1576
+ };
1577
+ dark: {
1578
+ primaryColor: string;
1579
+ bgColor: string;
1580
+ textColor: string;
1581
+ };
1582
+ };
1570
1583
  /** Cookie categories */
1571
1584
  categories: CookieCategory[];
1572
1585
  /** Banner texts */
@@ -2105,6 +2118,8 @@ declare class ConsentService {
2105
2118
  */
2106
2119
  private updateConsentTheme;
2107
2120
  private resolveTheme;
2121
+ private resolveColors;
2122
+ private contrastColor;
2108
2123
  private createBannerHTML;
2109
2124
  private createPreferencesHTML;
2110
2125
  private attachBannerEvents;
package/dist/index.js CHANGED
@@ -1,77 +1,68 @@
1
- 'use strict';var C=class i extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,o,r){super(e),this.code=t,this.status=n,this.details=o,this.cause=r,Error.captureStackTrace&&Error.captureStackTrace(this,i);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let s=await e.json();s.errors&&Array.isArray(s.errors)?(o=s.errors,n=s.errors[0]?.message||n):s.error?n=s.error:s.message&&(n=s.message);}catch{n=e.statusText||n;}let r=i.statusToCode(t);return new i(n,r,t,o)}static fromNetworkError(e){return e.name==="AbortError"?new i("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new i("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new i(e.message||"Unknown error","UNKNOWN",void 0,void 0,e)}static statusToCode(e){switch(e){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 429:return "RATE_LIMITED";default:return "UNKNOWN"}}toJSON(){return {name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}};function ye(i){return i instanceof C}function Ce(i){switch(i){case 400:return "BAD_REQUEST";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 422:return "VALIDATION_ERROR";case 429:return "TOO_MANY_REQUESTS";case 503:return "SERVICE_UNAVAILABLE";default:return "INTERNAL_ERROR"}}async function j(i,e){let t;try{t=await fetch(i,e);}catch(a){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let o=Ce(t.status),r=n.error||n.message||`HTTP error: ${t.status}`,s=n.errors||[{message:r}];throw new C(r,o,t.status,s)}function oe(i){let e=new URLSearchParams;for(let[t,n]of Object.entries(i))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var d={SHORT:300*1e3,MEDIUM:600*1e3,LONG:1800*1e3},g=class{config;cache;constructor(e){this.config=e,this.cache=e.cache;}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}${e}`;if(t&&Object.keys(t).length>0){let o=oe(t);return `${n}?${o}`}return n}async get(e,t,n){let o=n?.locale||this.config.locale,r=o?{...t,locale:o}:t,s=this.buildEndpointUrl(e,r),a=this.mergeFetchOptions(n?.fetchOptions);return j(s,{method:"GET",...a})}async getWithCache(e,t,n,o,r=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,o),r):this.get(t,n,o)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let o=this.buildEndpointUrl(e),r=this.mergeFetchOptions(n?.fetchOptions);return j(o,{method:"POST",...r,headers:{"Content-Type":"application/json",...r.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),o=this.mergeFetchOptions(t?.fetchOptions),r=await fetch(n,{method:"GET",...o});if(!r.ok)throw new Error(`HTTP error: ${r.status}`);return r.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var z="contents_",k=class extends g{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.category&&(n.category=e.category),e?.tag&&(n.tag=e.tag),e?.search&&(n.search=e.search),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order),e?.locale&&(n.locale=e.locale);let o=`${z}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${z}slug_${e}_${n||"default"}`;return this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(z);}};var q="categories_",E=class extends g{async list(e){let t=e?.locale||this.config.locale,n=`${q}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${q}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let o=`${q}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(o,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(q);}};var re="tags_",x=class extends g{async list(e){let t=e?.locale||this.config.locale,n=`${re}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(re);}};var T="pages_",S=class extends g{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${T}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(o,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${T}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,o=`${T}path_${e}_${n||"default"}`;return (await this.getWithCache(o,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,o=`${T}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(T);}};var W="globals_",L=class extends g{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${W}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,d.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${W}${e}_${n||"default"}`;return this.getWithCache(o,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(W);}};function N(i){return {_hp:"",_ts:i}}var se="forms_",O=class extends g{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${se}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let o=N(this.sessionStartTime),r={data:t,honeypot:o._hp,...o};return n?.recaptchaToken&&(r.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,r,n)}clearCache(){this.invalidateCache(se);}};var I="reviews_",P=class extends g{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.minRating&&(n.minRating=e.minRating),e?.maxRating&&(n.maxRating=e.maxRating),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order);let o=`${I}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${I}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${I}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=N(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let r=await this.post("/reviews",o,t);return this.invalidateCache(I),r}clearCache(){this.invalidateCache(I);}};var ie="site_",B=class extends g{async getConfig(){let e=`${ie}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ie);}};var G="legal_",$=class extends g{async list(e){let t=e?.locale||this.config.locale,n=`${G}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,d.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${G}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(G);}};var ae="cookies_",A=class extends g{async getConfig(){let e=`${ae}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,d.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/log",{preferences:e},t)}clearCache(){this.invalidateCache(ae);}};var _=class extends g{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}async llmsTxt(e){let t=e?.locale,n=t?`/${t}/llms.txt`:"/llms.txt";return this.getText(n,e)}async llmsFullTxt(e){let t=e?.locale,n=t?`/${t}/llms-full.txt`:"/llms-full.txt";return this.getText(n,e)}async getMarkdown(e,t){let n=e.startsWith("/")?e:`/${e}`;return this.getText(`${n}.md`,t)}};var V="paths_",F=class extends g{async list(e){let t=e?.locale||this.config.locale,n=`${V}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,o=`${V}resolve_${e}_${n||"default"}`;return this.getWithCache(o,"/resolve",{path:e},t,d.SHORT)}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof C&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(V);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ve=!c;function we(i,e){return c?i():e}async function be(i,e){return c?i():e}var X="lynkow-tracker",M=class{config;enabled=true;initialized=false;loading=false;loadPromise=null;constructor(e){this.config=e;}getTrackerUrl(){return `${this.config.baseUrl}/analytics/tracker.js`}loadTracker(){return !c||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(X)){let o=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(o),this.loading=false,e());},50);setTimeout(()=>{clearInterval(o),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=X,n.src=this.getTrackerUrl(),n.async=true,n.setAttribute("data-site-id",this.config.siteId),this.config.baseUrl&&n.setAttribute("data-api-url",this.config.baseUrl);try{let o=localStorage.getItem("_lkw_consent_mode");o&&n.setAttribute("data-consent-mode",o);}catch{}n.onload=()=>{this.loading=false,setTimeout(()=>{window.LynkowAnalytics?e():t(new Error("Tracker script loaded but LynkowAnalytics not found"));},0);},n.onerror=()=>{this.loading=false,t(new Error("Failed to load tracker script"));},document.head.appendChild(n);}),this.loadPromise)}async init(){if(!(!c||this.initialized))try{await this.loadTracker(),window.LynkowAnalytics&&!this.initialized&&(this.initialized=!0);}catch(e){console.error("[Lynkow] Failed to initialize analytics:",e);}}async trackEvent(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackPageview(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track({type:"pageview",path:e?.path||window.location.pathname,title:e?.title||document.title,referrer:e?.referrer||document.referrer}));}enable(){this.enabled=true;}disable(){this.enabled=false;}isEnabled(){return this.enabled}isInitialized(){return this.initialized&&!!window.LynkowAnalytics}getTracker(){if(c)return window.LynkowAnalytics}destroy(){if(!c)return;document.getElementById(X)?.remove(),this.initialized=false,this.loadPromise=null;}};function Re(i){let e=i.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(!e||(e[4]!==void 0?parseFloat(e[4]):1)===0)return null;let n=parseInt(e[1],10),o=parseInt(e[2],10),r=parseInt(e[3],10);return (.299*n+.587*o+.114*r)/255}function w(){if(!c)return "light";let i=document.documentElement,e=document.body;for(let t of [i,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let o=t.getAttribute(n)?.toLowerCase();if(o){if(o.includes("dark"))return "dark";if(o.includes("light"))return "light"}}if(i.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(i).colorScheme;if(t){let n=t.toLowerCase().trim();if(n.startsWith("dark"))return "dark";if(n.startsWith("light"))return "light"}}catch{}try{let t=getComputedStyle(e).backgroundColor,n=Re(t);if(n!==null)return n<.5?"dark":"light"}catch{}try{if(window.matchMedia("(prefers-color-scheme: dark)").matches)return "dark"}catch{}return "light"}function b(i){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let s=w();s!==e&&(e=s,i(s));},o=new MutationObserver(n),r={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};o.observe(document.documentElement,r),o.observe(document.body,r),t.push(()=>o.disconnect());try{let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n();s.addEventListener("change",a),t.push(()=>s.removeEventListener("change",a));}catch{}return ()=>t.forEach(s=>s())}var J="_lkw_consent",ce="lkw-script-",Y={necessary:true,analytics:false,marketing:false,preferences:false},U=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=null;constructor(e,t){this.config=e,this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/config`,t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},...this.config.fetchOptions});if(!t.ok)throw new Error(`Failed to fetch consent config: ${t.status}`);let n=await t.json();return this.configCache=n.data,this.configCache}async logConsent(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/log`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({visitorId:this.getOrCreateVisitorId(),action:t||this.inferAction(e),consentGiven:e,pageUrl:c?window.location.href:void 0}),...this.config.fetchOptions}).catch(()=>{});}getOrCreateVisitorId(){if(!c)return "server";let e="_lkw_vid";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}}inferAction(e){let t=Object.entries(e).filter(([r])=>r!=="necessary"),n=t.every(([,r])=>r===true),o=t.every(([,r])=>r===false);return n?"accept_all":o?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(J);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(J,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&this.getConfig().then(e=>{if(!e.enabled)return;try{e.consentMode&&localStorage.setItem("_lkw_consent_mode",e.consentMode);}catch{}let t=this.getStoredConsent();if(t){this.activateScripts(t);return}if(this.bannerElement)return;let n=document.createElement("div");n.innerHTML=this.createBannerHTML(e),this.bannerElement=n.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents(),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=b(o=>{this.updateConsentTheme(o);}));});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null,this.cleanupThemeObserverIfIdle());}showPreferences(){c&&(this.preferencesElement||this.getConfig().then(e=>{let t=this.getCategories(),n=document.createElement("div");n.innerHTML=this.createPreferencesHTML(e,t),this.preferencesElement=n.firstElementChild,document.body.appendChild(this.preferencesElement),this.attachPreferencesEvents(e),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=b(o=>{this.updateConsentTheme(o);}));}));}getCategories(){return c?this.getStoredConsent()||{...Y}:{...Y}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(J);}catch{}this.events.emit("consent-changed",{...Y}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let r=Array.from(o.children);for(let s=0;s<r.length;s++){let a=r[s],u=`${ce}${n.id}-${s}`;if(a.tagName==="SCRIPT"){let f=document.createElement("script");for(let p of Array.from(a.attributes))f.setAttribute(p.name,p.value);a.textContent&&(f.textContent=a.textContent),f.id=u,document.head.appendChild(f);}else a.id=u,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${ce}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}cleanupThemeObserverIfIdle(){!this.bannerElement&&!this.preferencesElement&&(this.themeCleanup?.(),this.themeCleanup=null);}updateConsentTheme(e){let t=e==="dark",n=t?"#1a1a1a":"#ffffff",o=t?"#ffffff":"#1a1a1a";if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=o),this.preferencesElement){let r=this.preferencesElement.querySelector(":scope > div");r&&(r.style.background=n,r.style.color=o);}}resolveTheme(e){return e==="auto"?w():e==="dark"?"dark":"light"}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",o=e.layout||"banner",r=e.primaryColor||"#0066cc",s=e.borderRadius??8,a={bottom:"bottom: 0; left: 0; right: 0;",top:"top: 0; left: 0; right: 0;","bottom-left":"bottom: 0; left: 0; right: 0;","bottom-right":"bottom: 0; left: 0; right: 0;",center:"top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px);"},u={bottom:`bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`bottom: 20px; left: 20px; max-width: 400px; border-radius: ${s}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 400px; border-radius: ${s}px;`,center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},f={center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,bottom:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-right":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},p;o==="floating"?p=u:o==="modal"?p=f:p=a;let l=p[t]||p.bottom||"",m=this.resolveTheme(n)==="dark",h=m?"#1a1a1a":"#ffffff",y=m?"#ffffff":"#1a1a1a",R=e.texts||{title:"Nous utilisons des cookies",description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
2
- ${o==="modal"?`
3
- <div id="lynkow-consent-backdrop" style="
4
- position: fixed;
5
- top: 0;
6
- left: 0;
7
- right: 0;
8
- bottom: 0;
9
- background: rgba(0,0,0,0.5);
10
- z-index: 99998;
11
- "></div>
12
- `:""}
1
+ 'use strict';var C=class s extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,o,r){super(e),this.code=t,this.status=n,this.details=o,this.cause=r,Error.captureStackTrace&&Error.captureStackTrace(this,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(o=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let r=s.statusToCode(t);return new s(n,r,t,o)}static fromNetworkError(e){return e.name==="AbortError"?new s("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new s("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new s(e.message||"Unknown error","UNKNOWN",void 0,void 0,e)}static statusToCode(e){switch(e){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 429:return "RATE_LIMITED";default:return "UNKNOWN"}}toJSON(){return {name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}};function fe(s){return s instanceof C}function ye(s){switch(s){case 400:return "BAD_REQUEST";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 422:return "VALIDATION_ERROR";case 429:return "TOO_MANY_REQUESTS";case 503:return "SERVICE_UNAVAILABLE";default:return "INTERNAL_ERROR"}}async function K(s,e){let t;try{t=await fetch(s,e);}catch(a){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let o=ye(t.status),r=n.error||n.message||`HTTP error: ${t.status}`,i=n.errors||[{message:r}];throw new C(r,o,t.status,i)}function ne(s){let e=new URLSearchParams;for(let[t,n]of Object.entries(s))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var d={SHORT:300*1e3,MEDIUM:600*1e3,LONG:1800*1e3},m=class{config;cache;constructor(e){this.config=e,this.cache=e.cache;}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}${e}`;if(t&&Object.keys(t).length>0){let o=ne(t);return `${n}?${o}`}return n}async get(e,t,n){let o=n?.locale||this.config.locale,r=o?{...t,locale:o}:t,i=this.buildEndpointUrl(e,r),a=this.mergeFetchOptions(n?.fetchOptions);return K(i,{method:"GET",...a})}async getWithCache(e,t,n,o,r=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,o),r):this.get(t,n,o)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let o=this.buildEndpointUrl(e),r=this.mergeFetchOptions(n?.fetchOptions);return K(o,{method:"POST",...r,headers:{"Content-Type":"application/json",...r.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),o=this.mergeFetchOptions(t?.fetchOptions),r=await fetch(n,{method:"GET",...o});if(!r.ok)throw new Error(`HTTP error: ${r.status}`);return r.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var j="contents_",R=class extends m{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.category&&(n.category=e.category),e?.tag&&(n.tag=e.tag),e?.search&&(n.search=e.search),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order),e?.locale&&(n.locale=e.locale);let o=`${j}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${j}slug_${e}_${n||"default"}`;return this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(j);}};var H="categories_",E=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${H}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${H}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let o=`${H}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(o,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(H);}};var oe="tags_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${oe}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(oe);}};var x="pages_",T=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${x}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(o,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${x}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,o=`${x}path_${e}_${n||"default"}`;return (await this.getWithCache(o,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,o=`${x}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(x);}};var z="globals_",S=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${z}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,d.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${z}${e}_${n||"default"}`;return this.getWithCache(o,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(z);}};function q(s){return {_hp:"",_ts:s}}var re="forms_",L=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${re}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let o=q(this.sessionStartTime),r={data:t,honeypot:o._hp,...o};return n?.recaptchaToken&&(r.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,r,n)}clearCache(){this.invalidateCache(re);}};var O="reviews_",I=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.minRating&&(n.minRating=e.minRating),e?.maxRating&&(n.maxRating=e.maxRating),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order);let o=`${O}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${O}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${O}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=q(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let r=await this.post("/reviews",o,t);return this.invalidateCache(O),r}clearCache(){this.invalidateCache(O);}};var se="site_",P=class extends m{async getConfig(){let e=`${se}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(se);}};var W="legal_",B=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${W}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,d.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${W}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(W);}};var ie="cookies_",$=class extends m{async getConfig(){let e=`${ie}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,d.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/log",{preferences:e},t)}clearCache(){this.invalidateCache(ie);}};var A=class extends m{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}async llmsTxt(e){let t=e?.locale,n=t?`/${t}/llms.txt`:"/llms.txt";return this.getText(n,e)}async llmsFullTxt(e){let t=e?.locale,n=t?`/${t}/llms-full.txt`:"/llms-full.txt";return this.getText(n,e)}async getMarkdown(e,t){let n=e.startsWith("/")?e:`/${e}`;return this.getText(`${n}.md`,t)}};var G="paths_",_=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${G}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,o=`${G}resolve_${e}_${n||"default"}`;return this.getWithCache(o,"/resolve",{path:e},t,d.SHORT)}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof C&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(G);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ce=!c;function ve(s,e){return c?s():e}async function we(s,e){return c?s():e}var V="lynkow-tracker",M=class{config;enabled=true;initialized=false;loading=false;loadPromise=null;constructor(e){this.config=e;}getTrackerUrl(){return `${this.config.baseUrl}/analytics/tracker.js`}loadTracker(){return !c||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(V)){let o=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(o),this.loading=false,e());},50);setTimeout(()=>{clearInterval(o),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=V,n.src=this.getTrackerUrl(),n.async=true,n.setAttribute("data-site-id",this.config.siteId),this.config.baseUrl&&n.setAttribute("data-api-url",this.config.baseUrl);try{let o=localStorage.getItem("_lkw_consent_mode");o&&n.setAttribute("data-consent-mode",o);}catch{}n.onload=()=>{this.loading=false,setTimeout(()=>{window.LynkowAnalytics?e():t(new Error("Tracker script loaded but LynkowAnalytics not found"));},0);},n.onerror=()=>{this.loading=false,t(new Error("Failed to load tracker script"));},document.head.appendChild(n);}),this.loadPromise)}async init(){if(!(!c||this.initialized))try{await this.loadTracker(),window.LynkowAnalytics&&!this.initialized&&(this.initialized=!0);}catch(e){console.error("[Lynkow] Failed to initialize analytics:",e);}}async trackEvent(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackPageview(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track({type:"pageview",path:e?.path||window.location.pathname,title:e?.title||document.title,referrer:e?.referrer||document.referrer}));}enable(){this.enabled=true;}disable(){this.enabled=false;}isEnabled(){return this.enabled}isInitialized(){return this.initialized&&!!window.LynkowAnalytics}getTracker(){if(c)return window.LynkowAnalytics}destroy(){if(!c)return;document.getElementById(V)?.remove(),this.initialized=false,this.loadPromise=null;}};function be(s){let e=s.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(!e||(e[4]!==void 0?parseFloat(e[4]):1)===0)return null;let n=parseInt(e[1],10),o=parseInt(e[2],10),r=parseInt(e[3],10);return (.299*n+.587*o+.114*r)/255}function w(){if(!c)return "light";let s=document.documentElement,e=document.body;for(let t of [s,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let o=t.getAttribute(n)?.toLowerCase();if(o){if(o.includes("dark"))return "dark";if(o.includes("light"))return "light"}}if(s.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(s).colorScheme;if(t){let n=t.toLowerCase().trim();if(n.startsWith("dark"))return "dark";if(n.startsWith("light"))return "light"}}catch{}try{let t=getComputedStyle(e).backgroundColor,n=be(t);if(n!==null)return n<.5?"dark":"light"}catch{}try{if(window.matchMedia("(prefers-color-scheme: dark)").matches)return "dark"}catch{}return "light"}function b(s){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let i=w();i!==e&&(e=i,s(i));},o=new MutationObserver(n),r={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};o.observe(document.documentElement,r),o.observe(document.body,r),t.push(()=>o.disconnect());try{let i=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n();i.addEventListener("change",a),t.push(()=>i.removeEventListener("change",a));}catch{}return ()=>t.forEach(i=>i())}var J="_lkw_consent",ae="lkw-script-",X={necessary:true,analytics:false,marketing:false,preferences:false},N=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=null;constructor(e,t){this.config=e,this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/config`,t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},...this.config.fetchOptions});if(!t.ok)throw new Error(`Failed to fetch consent config: ${t.status}`);let n=await t.json();return this.configCache=n.data,this.configCache}async logConsent(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/log`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({visitorId:this.getOrCreateVisitorId(),action:t||this.inferAction(e),consentGiven:e,pageUrl:c?window.location.href:void 0}),...this.config.fetchOptions}).catch(()=>{});}getOrCreateVisitorId(){if(!c)return "server";let e="_lkw_vid";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}}inferAction(e){let t=Object.entries(e).filter(([r])=>r!=="necessary"),n=t.every(([,r])=>r===true),o=t.every(([,r])=>r===false);return n?"accept_all":o?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(J);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(J,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&this.getConfig().then(e=>{if(!e.enabled)return;try{e.consentMode&&localStorage.setItem("_lkw_consent_mode",e.consentMode);}catch{}let t=this.getStoredConsent();if(t){this.activateScripts(t);return}if(this.bannerElement)return;let n=document.createElement("div");n.innerHTML=this.createBannerHTML(e),this.bannerElement=n.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents(),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=b(o=>{this.updateConsentTheme(o);}));});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null,this.cleanupThemeObserverIfIdle());}showPreferences(){c&&(this.preferencesElement||this.getConfig().then(e=>{let t=this.getCategories(),n=document.createElement("div");n.innerHTML=this.createPreferencesHTML(e,t),this.preferencesElement=n.firstElementChild,document.body.appendChild(this.preferencesElement),this.attachPreferencesEvents(e),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=b(o=>{this.updateConsentTheme(o);}));}));}getCategories(){return c?this.getStoredConsent()||{...X}:{...X}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(J);}catch{}this.events.emit("consent-changed",{...X}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let r=Array.from(o.children);for(let i=0;i<r.length;i++){let a=r[i],p=`${ae}${n.id}-${i}`;if(a.tagName==="SCRIPT"){let g=document.createElement("script");for(let u of Array.from(a.attributes))g.setAttribute(u.name,u.value);a.textContent&&(g.textContent=a.textContent),g.id=p,document.head.appendChild(g);}else a.id=p,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${ae}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}cleanupThemeObserverIfIdle(){!this.bannerElement&&!this.preferencesElement&&(this.themeCleanup?.(),this.themeCleanup=null);}updateConsentTheme(e){let t=this.configCache?this.resolveColors(this.configCache,e):{bgColor:e==="dark"?"#18181b":"#ffffff",textColor:e==="dark"?"#f4f4f5":"#1a1a1a"},{bgColor:n,textColor:o}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=o),this.preferencesElement){let r=this.preferencesElement.querySelector(":scope > div");r&&(r.style.background=n,r.style.color=o);}}resolveTheme(e){return e==="auto"?w():e==="dark"?"dark":"light"}resolveColors(e,t){if(e.themeStyles?.[t])return e.themeStyles[t];let n=t==="dark";return {primaryColor:e.primaryColor||"#0066cc",bgColor:n?"#18181b":"#ffffff",textColor:n?"#f4f4f5":"#1a1a1a"}}contrastColor(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*o)/255>.5?"#000000":"#ffffff"}createBannerHTML(e){let t=e.position||"bottom-right",n=e.theme||"light",o=e.borderRadius??8,r=e.fontSize??13,i={"bottom-left":`bottom: 20px; left: 20px; max-width: 680px; border-radius: ${o}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 680px; border-radius: ${o}px;`},a=i[t]||i["bottom-right"],p=this.resolveTheme(n),g=this.resolveColors(e,p),{primaryColor:u,bgColor:l,textColor:f}=g,h=e.texts||{description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
13
2
  <div id="lynkow-consent-banner" style="
14
3
  position: fixed;
15
- ${l}
4
+ ${a}
16
5
  z-index: 99999;
17
- padding: 20px;
18
- background: ${h};
19
- color: ${y};
6
+ padding: 16px 20px;
7
+ background: ${l};
8
+ color: ${f};
20
9
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
21
10
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
22
- font-size: 14px;
11
+ font-size: ${r}px;
23
12
  ">
24
- <div style="max-width: 1200px; margin: 0 auto;">
25
- <h3 style="margin: 0 0 10px 0; font-size: 16px;">${R.title}</h3>
26
- <p style="margin: 0 0 15px 0; line-height: 1.5;">
27
- ${R.description}
13
+ <div style="display: flex; align-items: center; gap: 16px;">
14
+ <p style="margin: 0; line-height: 1.5; flex: 1; min-width: 0;">
15
+ ${h.description}
28
16
  </p>
29
- <div style="display: flex; gap: 10px; flex-wrap: wrap;">
17
+ <div style="display: flex; gap: 8px; align-items: center; flex-shrink: 0;">
30
18
  <button id="lynkow-consent-accept" style="
31
- padding: 10px 20px;
32
- background: ${r};
33
- color: white;
19
+ padding: 8px 16px;
20
+ background: ${u};
21
+ color: ${this.contrastColor(u)};
34
22
  border: none;
35
- border-radius: ${s}px;
23
+ border-radius: ${o}px;
36
24
  cursor: pointer;
37
- font-size: 14px;
38
- ">${R.acceptAll}</button>
25
+ font-size: ${r}px;
26
+ white-space: nowrap;
27
+ ">${h.acceptAll}</button>
39
28
  <button id="lynkow-consent-reject" style="
40
- padding: 10px 20px;
29
+ padding: 8px 16px;
41
30
  background: transparent;
42
31
  color: inherit;
43
32
  border: 1px solid currentColor;
44
- border-radius: ${s}px;
33
+ border-radius: ${o}px;
45
34
  cursor: pointer;
46
- font-size: 14px;
47
- ">${R.rejectAll}</button>
35
+ font-size: ${r}px;
36
+ white-space: nowrap;
37
+ ">${h.rejectAll}</button>
48
38
  <button id="lynkow-consent-preferences" style="
49
- padding: 10px 20px;
39
+ padding: 8px 4px;
50
40
  background: transparent;
51
41
  color: inherit;
52
42
  border: none;
53
43
  cursor: pointer;
54
- font-size: 14px;
44
+ font-size: ${r}px;
55
45
  text-decoration: underline;
56
- ">${R.customize}</button>
46
+ white-space: nowrap;
47
+ ">${h.customize}</button>
57
48
  </div>
58
49
  </div>
59
50
  </div>
60
- `}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.primaryColor||"#0066cc",r=e.borderRadius??8,s=this.resolveTheme(n)==="dark",a=s?"#1a1a1a":"#ffffff",u=s?"#ffffff":"#1a1a1a",f=e.texts||{title:"Preferences de cookies",save:"Enregistrer"},l=(e.categories||[]).map(m=>`
61
- <label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${m.required?"not-allowed":"pointer"};">
51
+ `}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.borderRadius??8,r=e.fontSize??13,i=this.resolveTheme(n),a=this.resolveColors(e,i),{primaryColor:p,bgColor:g,textColor:u}=a,l=e.texts||{save:"Enregistrer"},h=(e.categories||[]).map(y=>`
52
+ <label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${y.required?"not-allowed":"pointer"};">
62
53
  <input
63
54
  type="checkbox"
64
- name="${m.id}"
65
- ${t[m.id]?"checked":""}
66
- ${m.required?"disabled checked":""}
67
- style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${o};"
55
+ name="${y.id}"
56
+ ${t[y.id]?"checked":""}
57
+ ${y.required?"disabled checked":""}
58
+ style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${p};"
68
59
  />
69
60
  <div style="flex: 1;">
70
- <strong style="opacity: ${m.required?"0.6":"1"};">
71
- ${m.name}${m.required?" (requis)":""}
61
+ <strong style="opacity: ${y.required?"0.6":"1"};">
62
+ ${y.name}${y.required?" (requis)":""}
72
63
  </strong>
73
64
  <p style="margin: 5px 0 0 0; font-size: 13px; opacity: 0.8;">
74
- ${m.description}
65
+ ${y.description}
75
66
  </p>
76
67
  </div>
77
68
  </label>
@@ -90,44 +81,42 @@
90
81
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
91
82
  ">
92
83
  <div style="
93
- background: ${a};
84
+ background: ${g};
94
85
  color: ${u};
95
86
  padding: 30px;
96
- border-radius: ${r}px;
87
+ border-radius: ${o}px;
97
88
  max-width: 500px;
98
89
  width: 90%;
99
90
  max-height: 80vh;
100
91
  overflow-y: auto;
101
92
  ">
102
- <h2 style="margin: 0 0 20px 0; font-size: 20px;">${f.title||"Preferences de cookies"}</h2>
103
-
104
93
  <form id="lynkow-consent-form">
105
- ${l}
94
+ ${h}
106
95
 
107
96
  <div style="display: flex; gap: 10px; margin-top: 25px; padding-top: 20px; border-top: 1px solid rgba(128,128,128,0.3);">
108
97
  <button type="submit" style="
109
98
  padding: 10px 20px;
110
- background: ${o};
111
- color: white;
99
+ background: ${p};
100
+ color: ${this.contrastColor(p)};
112
101
  border: none;
113
- border-radius: ${r}px;
102
+ border-radius: ${o}px;
114
103
  cursor: pointer;
115
- font-size: 14px;
116
- ">${f.save||"Enregistrer"}</button>
104
+ font-size: ${r}px;
105
+ ">${l.save||"Enregistrer"}</button>
117
106
  <button type="button" id="lynkow-consent-close" style="
118
107
  padding: 10px 20px;
119
108
  background: transparent;
120
109
  color: inherit;
121
110
  border: 1px solid currentColor;
122
- border-radius: ${r}px;
111
+ border-radius: ${o}px;
123
112
  cursor: pointer;
124
- font-size: 14px;
113
+ font-size: ${r}px;
125
114
  ">Annuler</button>
126
115
  </div>
127
116
  </form>
128
117
  </div>
129
118
  </div>
130
- `}attachBannerEvents(){let e=document.getElementById("lynkow-consent-accept"),t=document.getElementById("lynkow-consent-reject"),n=document.getElementById("lynkow-consent-preferences");e?.addEventListener("click",()=>{this.acceptAll();}),t?.addEventListener("click",()=>{this.rejectAll();}),n?.addEventListener("click",()=>{this.showPreferences();});}attachPreferencesEvents(e){let t=document.getElementById("lynkow-consent-form"),n=document.getElementById("lynkow-consent-close"),o=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",r=>{r.preventDefault();let s=new FormData(t),a={necessary:true,analytics:s.has("analytics"),marketing:s.has("marketing"),preferences:s.has("preferences")};this.setCategories(a),this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),n?.addEventListener("click",()=>{this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),o?.addEventListener("click",r=>{r.target===o&&(this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle());});}destroy(){this.themeCleanup?.(),this.themeCleanup=null,this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.removeInjectedScripts();}};var Q="lynkow-badge-container",Z="lynkow-badge-styles",K=class extends g{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(Q))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(Z)){let n=document.createElement("style");n.id=Z,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=Q,t.innerHTML=e.html,w()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=b(n=>{this.containerElement&&this.containerElement.classList.toggle("lynkow-badge-light",n==="light");});}catch{}}remove(){c&&(this.themeCleanup?.(),this.themeCleanup=null,this.containerElement?.remove(),this.containerElement=null,document.getElementById(Z)?.remove());}isVisible(){return c?document.getElementById(Q)!==null:false}destroy(){this.remove();}};var ee="lynkow-enhancements-styles",te="data-lynkow-clone",ke='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',Ee='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',xe=`
119
+ `}attachBannerEvents(){let e=document.getElementById("lynkow-consent-accept"),t=document.getElementById("lynkow-consent-reject"),n=document.getElementById("lynkow-consent-preferences");e?.addEventListener("click",()=>{this.acceptAll();}),t?.addEventListener("click",()=>{this.rejectAll();}),n?.addEventListener("click",()=>{this.showPreferences();});}attachPreferencesEvents(e){let t=document.getElementById("lynkow-consent-form"),n=document.getElementById("lynkow-consent-close"),o=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",r=>{r.preventDefault();let i=new FormData(t),a={necessary:true,analytics:i.has("analytics"),marketing:i.has("marketing"),preferences:i.has("preferences")};this.setCategories(a),this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),n?.addEventListener("click",()=>{this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),o?.addEventListener("click",r=>{r.target===o&&(this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle());});}destroy(){this.themeCleanup?.(),this.themeCleanup=null,this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.removeInjectedScripts();}};var Y="lynkow-badge-container",Q="lynkow-badge-styles",U=class extends m{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(Y))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(Q)){let n=document.createElement("style");n.id=Q,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=Y,t.innerHTML=e.html,w()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=b(n=>{this.containerElement&&this.containerElement.classList.toggle("lynkow-badge-light",n==="light");});}catch{}}remove(){c&&(this.themeCleanup?.(),this.themeCleanup=null,this.containerElement?.remove(),this.containerElement=null,document.getElementById(Q)?.remove());}isVisible(){return c?document.getElementById(Y)!==null:false}destroy(){this.remove();}};var Z="lynkow-enhancements-styles",ee="data-lynkow-clone",Re='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',Ee='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',ke=`
131
120
  /*
132
121
  * Lynkow Content Enhancements
133
122
  * These styles ensure that content from the Lynkow API is displayed correctly,
@@ -243,6 +232,6 @@
243
232
  color: #1a1a1a;
244
233
  }
245
234
  }
246
- `,D=class{initialized=false;observer=null;pendingFrame=null;handleWidgetResize=e=>{if(!e.data||e.data.type!=="lynkow-widget-resize")return;document.querySelectorAll('iframe[src*="/widgets/calendar/"]').forEach(n=>{n.contentWindow===e.source&&(n.style.height=e.data.height+"px");});};injectStyles(){if(!c||document.getElementById(ee))return;let e=document.createElement("style");e.id=ee,e.textContent=xe,document.head.appendChild(e);}async handleCopyClick(e){let t=e.closest(".code-block");if(!t)return;let n=t.querySelector("code");if(!n)return;let o=n.textContent||"";try{await navigator.clipboard.writeText(o),e.classList.add("copied"),e.innerHTML=Ee,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=ke;},2e3);}catch(r){console.error("Lynkow SDK: Failed to copy code",r);}}bindCodeBlockCopy(){if(!c)return;document.querySelectorAll("[data-copy-code]").forEach(t=>{t.dataset.lynkowBound||(t.dataset.lynkowBound="true",t.addEventListener("click",n=>{n.preventDefault(),this.handleCopyClick(t);}));});}activateScripts(e){if(!c)return;let n=(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])"),o=Array.from(n).filter(r=>!r.src&&r.isConnected);o.length!==0&&(document.head.querySelectorAll(`script[${te}]`).forEach(r=>r.remove()),o.forEach(r=>{r.setAttribute("data-lynkow-activated","true");let s=document.createElement("script"),a=r.attributes;for(let u=0;u<a.length;u++){let f=a[u];f&&(f.name==="type"&&f.value==="text/plain"||f.name!=="data-lynkow-activated"&&s.setAttribute(f.name,f.value));}s.textContent=r.textContent,s.setAttribute(te,""),document.head.appendChild(s);}));}init(){!c||this.initialized||(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),this.bindCodeBlockCopy();}));}),this.observer.observe(document.body,{childList:true,subtree:true})),this.initialized=true);}isInitialized(){return this.initialized}destroy(){c&&(window.removeEventListener("message",this.handleWidgetResize),this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.observer&&(this.observer.disconnect(),this.observer=null),document.getElementById(ee)?.remove(),document.head.querySelectorAll(`script[${te}]`).forEach(e=>e.remove()),this.initialized=false);}};var H=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:o="scale-down",quality:r=80,gravity:s}=t,a=this.parseImageUrl(e);return a?n.map(u=>{let f=[`w=${u}`,`fit=${o}`,"format=auto",`quality=${r}`,s&&`gravity=${s}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${f}/${a.relativePath} ${u}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let r=e.substring(0,t),s=e.substring(t+15),a=s.indexOf("/");if(a===-1)return null;let u=s.substring(a+1);return {cdnBase:r,relativePath:u}}let n=e.indexOf("/sites/");if(n!==-1){let r=e.substring(0,n),s=e.substring(n+1);return {cdnBase:r,relativePath:s}}let o=e.indexOf("/avatars/");if(o!==-1){let r=e.substring(0,o),s=e.substring(o+1);return {cdnBase:r,relativePath:s}}return null}};var Te=300*1e3,Se="lynkow_cache_",v=new Map;function le(i={}){let e=i.defaultTtl??Te,t=i.prefix??Se;function n(p){return `${t}${p}`}function o(p){return Date.now()>p.expiresAt}function r(p){let l=n(p);if(c)try{let h=localStorage.getItem(l);if(!h)return null;let y=JSON.parse(h);return o(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let m=v.get(l);return m?o(m)?(v.delete(l),null):m.value:null}function s(p,l,m=e){let h=n(p),y={value:l,expiresAt:Date.now()+m};if(c){try{localStorage.setItem(h,JSON.stringify(y));}catch{}return}v.set(h,y);}function a(p){let l=n(p);if(c){try{localStorage.removeItem(l);}catch{}return}v.delete(l);}function u(p){if(c){try{let l=[];for(let m=0;m<localStorage.length;m++){let h=localStorage.key(m);h&&h.startsWith(t)&&(!p||h.includes(p))&&l.push(h);}l.forEach(m=>localStorage.removeItem(m));}catch{}return}if(p)for(let l of v.keys())l.startsWith(t)&&l.includes(p)&&v.delete(l);else for(let l of v.keys())l.startsWith(t)&&v.delete(l);}async function f(p,l,m=e){let h=r(p);if(h!==null)return h;let y=await l();return s(p,y,m),y}return {get:r,set:s,remove:a,invalidate:u,getOrSet:f}}function de(i){let e=i.prefix||"[Lynkow]";return {debug(...t){i.debug&&console.debug(e,...t);},info(...t){console.info(e,...t);},warn(...t){console.warn(e,...t);},error(...t){console.error(e,...t);},log(t,...n){switch(t){case "debug":this.debug(...n);break;case "info":this.info(...n);break;case "warn":this.warn(...n);break;case "error":this.error(...n);break}}}}function pe(){let i=new Map;function e(s,a){return i.has(s)||i.set(s,new Set),i.get(s).add(a),()=>t(s,a)}function t(s,a){let u=i.get(s);u&&u.delete(a);}function n(s,a){let u=i.get(s);if(u)for(let f of u)try{f(a);}catch(p){console.error(`[Lynkow] Error in event listener for "${s}":`,p);}}function o(s,a){let u=(f=>{t(s,u),a(f);});return e(s,u)}function r(s){s?i.delete(s):i.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:r}}var me="lynkow_locale";function ne(i,e){let t=i.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function ue(i,e){if(!c)return e;let t=Le();if(t&&i.includes(t))return t;let n=Oe(i);if(n)return n;let o=document.documentElement.lang;if(o){let r=ne(o,i);if(r)return r;let s=o.split("-")[0]?.toLowerCase();if(s){let a=ne(s,i);if(a)return a}}return e}function Le(){if(!c)return null;try{return localStorage.getItem(me)}catch{return null}}function ge(i){if(c)try{localStorage.setItem(me,i);}catch{}}function Oe(i){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=ne(n,i);if(o)return o}}return null}function fe(i,e){return e.includes(i)}var he="https://api.lynkow.com";function Ie(i){if(!i.siteId)throw new Error("Lynkow SDK: siteId is required");let e=le(),t=de({debug:i.debug??false}),n=pe(),o=(i.baseUrl||he).replace(/\/$/,""),r={siteId:i.siteId,baseUrl:o,locale:i.locale,fetchOptions:i.fetchOptions||{},cache:e},s={locale:i.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new k(r),categories:new E(r),tags:new x(r),pages:new S(r),blocks:new L(r),forms:new O(r),reviews:new P(r),site:new B(r),legal:new $(r),cookies:new A(r),seo:new _(r),paths:new F(r),analytics:new M(r),consent:new U(r,n),branding:new K(r),enhancements:new D,media:new H};function u(l){r.locale=l;}async function f(){if(!s.initialized)try{let l=await a.site.getConfig();s.siteConfig=l;let m=l.defaultLocale||"fr";if(s.availableLocales=l.enabledLocales||[m],c&&!i.locale){let h=ue(s.availableLocales,m);s.locale=h,u(h);}s.initialized=!0,t.debug("Client initialized",{locale:s.locale,availableLocales:s.availableLocales}),c&&(a.analytics.init(),a.consent.hasConsented()||a.consent.show(),l.showBranding&&await a.branding.inject(),a.enhancements.init()),n.emit("ready",void 0);}catch(l){t.error("Failed to initialize client",l),n.emit("error",l);}}return c&&setTimeout(()=>{a.enhancements.init(),f();},0),{...a,globals:a.blocks,config:Object.freeze({siteId:i.siteId,baseUrl:o,debug:i.debug??false}),get locale(){return s.locale},get availableLocales(){return [...s.availableLocales]},setLocale(l){if(!fe(l,s.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${s.availableLocales.join(", ")}`);return}l!==s.locale&&(s.locale=l,u(l),c&&ge(l),e.invalidate(),n.emit("locale-changed",l),t.debug("Locale changed to",l));},clearCache(){e.invalidate(),t.debug("Cache cleared");},destroy(){a.analytics.destroy(),a.consent.destroy(),a.branding.destroy(),a.enhancements.destroy(),e.invalidate(),n.removeAllListeners(),t.debug("Client destroyed");},on(l,m){return n.on(l,m)}}}function Pe(i){if(!i.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:i.siteId,baseUrl:(i.baseUrl||he).replace(/\/$/,""),locale:i.locale,fetchOptions:i.fetchOptions||{}};return {contents:new k(e),categories:new E(e),tags:new x(e),pages:new S(e),blocks:new L(e),forms:new O(e),reviews:new P(e),site:new B(e),legal:new $(e),cookies:new A(e),seo:new _(e),paths:new F(e)}}function Be(i){return i.type==="content"}function $e(i){return i.type==="category"}
247
- exports.EnhancementsService=D;exports.LynkowError=C;exports.MediaHelperService=H;exports.browserOnly=we;exports.browserOnlyAsync=be;exports.createClient=Ie;exports.createLynkowClient=Pe;exports.detectSiteTheme=w;exports.isBrowser=c;exports.isCategoryResolve=$e;exports.isContentResolve=Be;exports.isLynkowError=ye;exports.isServer=ve;exports.onSiteThemeChange=b;//# sourceMappingURL=index.js.map
235
+ `,F=class{initialized=false;observer=null;pendingFrame=null;handleWidgetResize=e=>{if(!e.data||e.data.type!=="lynkow-widget-resize")return;document.querySelectorAll('iframe[src*="/widgets/calendar/"]').forEach(n=>{n.contentWindow===e.source&&(n.style.height=e.data.height+"px");});};injectStyles(){if(!c||document.getElementById(Z))return;let e=document.createElement("style");e.id=Z,e.textContent=ke,document.head.appendChild(e);}async handleCopyClick(e){let t=e.closest(".code-block");if(!t)return;let n=t.querySelector("code");if(!n)return;let o=n.textContent||"";try{await navigator.clipboard.writeText(o),e.classList.add("copied"),e.innerHTML=Ee,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Re;},2e3);}catch(r){console.error("Lynkow SDK: Failed to copy code",r);}}bindCodeBlockCopy(){if(!c)return;document.querySelectorAll("[data-copy-code]").forEach(t=>{t.dataset.lynkowBound||(t.dataset.lynkowBound="true",t.addEventListener("click",n=>{n.preventDefault(),this.handleCopyClick(t);}));});}activateScripts(e){if(!c)return;let n=(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])"),o=Array.from(n).filter(r=>!r.src&&r.isConnected);o.length!==0&&(document.head.querySelectorAll(`script[${ee}]`).forEach(r=>r.remove()),o.forEach(r=>{r.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=r.attributes;for(let p=0;p<a.length;p++){let g=a[p];g&&(g.name==="type"&&g.value==="text/plain"||g.name!=="data-lynkow-activated"&&i.setAttribute(g.name,g.value));}i.textContent=r.textContent,i.setAttribute(ee,""),document.head.appendChild(i);}));}init(){!c||this.initialized||(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),this.bindCodeBlockCopy();}));}),this.observer.observe(document.body,{childList:true,subtree:true})),this.initialized=true);}isInitialized(){return this.initialized}destroy(){c&&(window.removeEventListener("message",this.handleWidgetResize),this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.observer&&(this.observer.disconnect(),this.observer=null),document.getElementById(Z)?.remove(),document.head.querySelectorAll(`script[${ee}]`).forEach(e=>e.remove()),this.initialized=false);}};var D=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:o="scale-down",quality:r=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${o}`,"format=auto",`quality=${r}`,i&&`gravity=${i}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${g}/${a.relativePath} ${p}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let r=e.substring(0,t),i=e.substring(t+15),a=i.indexOf("/");if(a===-1)return null;let p=i.substring(a+1);return {cdnBase:r,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let r=e.substring(0,n),i=e.substring(n+1);return {cdnBase:r,relativePath:i}}let o=e.indexOf("/avatars/");if(o!==-1){let r=e.substring(0,o),i=e.substring(o+1);return {cdnBase:r,relativePath:i}}return null}};var xe=300*1e3,Te="lynkow_cache_",v=new Map;function ce(s={}){let e=s.defaultTtl??xe,t=s.prefix??Te;function n(u){return `${t}${u}`}function o(u){return Date.now()>u.expiresAt}function r(u){let l=n(u);if(c)try{let h=localStorage.getItem(l);if(!h)return null;let y=JSON.parse(h);return o(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let f=v.get(l);return f?o(f)?(v.delete(l),null):f.value:null}function i(u,l,f=e){let h=n(u),y={value:l,expiresAt:Date.now()+f};if(c){try{localStorage.setItem(h,JSON.stringify(y));}catch{}return}v.set(h,y);}function a(u){let l=n(u);if(c){try{localStorage.removeItem(l);}catch{}return}v.delete(l);}function p(u){if(c){try{let l=[];for(let f=0;f<localStorage.length;f++){let h=localStorage.key(f);h&&h.startsWith(t)&&(!u||h.includes(u))&&l.push(h);}l.forEach(f=>localStorage.removeItem(f));}catch{}return}if(u)for(let l of v.keys())l.startsWith(t)&&l.includes(u)&&v.delete(l);else for(let l of v.keys())l.startsWith(t)&&v.delete(l);}async function g(u,l,f=e){let h=r(u);if(h!==null)return h;let y=await l();return i(u,y,f),y}return {get:r,set:i,remove:a,invalidate:p,getOrSet:g}}function le(s){let e=s.prefix||"[Lynkow]";return {debug(...t){s.debug&&console.debug(e,...t);},info(...t){console.info(e,...t);},warn(...t){console.warn(e,...t);},error(...t){console.error(e,...t);},log(t,...n){switch(t){case "debug":this.debug(...n);break;case "info":this.info(...n);break;case "warn":this.warn(...n);break;case "error":this.error(...n);break}}}}function de(){let s=new Map;function e(i,a){return s.has(i)||s.set(i,new Set),s.get(i).add(a),()=>t(i,a)}function t(i,a){let p=s.get(i);p&&p.delete(a);}function n(i,a){let p=s.get(i);if(p)for(let g of p)try{g(a);}catch(u){console.error(`[Lynkow] Error in event listener for "${i}":`,u);}}function o(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function r(i){i?s.delete(i):s.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:r}}var pe="lynkow_locale";function te(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function ue(s,e){if(!c)return e;let t=Se();if(t&&s.includes(t))return t;let n=Le(s);if(n)return n;let o=document.documentElement.lang;if(o){let r=te(o,s);if(r)return r;let i=o.split("-")[0]?.toLowerCase();if(i){let a=te(i,s);if(a)return a}}return e}function Se(){if(!c)return null;try{return localStorage.getItem(pe)}catch{return null}}function me(s){if(c)try{localStorage.setItem(pe,s);}catch{}}function Le(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=te(n,s);if(o)return o}}return null}function ge(s,e){return e.includes(s)}var he="https://api.lynkow.com";function Oe(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=ce(),t=le({debug:s.debug??false}),n=de(),o=(s.baseUrl||he).replace(/\/$/,""),r={siteId:s.siteId,baseUrl:o,locale:s.locale,fetchOptions:s.fetchOptions||{},cache:e},i={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new R(r),categories:new E(r),tags:new k(r),pages:new T(r),blocks:new S(r),forms:new L(r),reviews:new I(r),site:new P(r),legal:new B(r),cookies:new $(r),seo:new A(r),paths:new _(r),analytics:new M(r),consent:new N(r,n),branding:new U(r),enhancements:new F,media:new D};function p(l){r.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let f=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[f],c&&!s.locale){let h=ue(i.availableLocales,f);i.locale=h,p(h);}i.initialized=!0,t.debug("Client initialized",{locale:i.locale,availableLocales:i.availableLocales}),c&&(a.analytics.init(),a.consent.hasConsented()||a.consent.show(),l.showBranding&&await a.branding.inject(),a.enhancements.init()),n.emit("ready",void 0);}catch(l){t.error("Failed to initialize client",l),n.emit("error",l);}}return c&&setTimeout(()=>{a.enhancements.init(),g();},0),{...a,globals:a.blocks,config:Object.freeze({siteId:s.siteId,baseUrl:o,debug:s.debug??false}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!ge(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&me(l),e.invalidate(),n.emit("locale-changed",l),t.debug("Locale changed to",l));},clearCache(){e.invalidate(),t.debug("Cache cleared");},destroy(){a.analytics.destroy(),a.consent.destroy(),a.branding.destroy(),a.enhancements.destroy(),e.invalidate(),n.removeAllListeners(),t.debug("Client destroyed");},on(l,f){return n.on(l,f)}}}function Ie(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||he).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new R(e),categories:new E(e),tags:new k(e),pages:new T(e),blocks:new S(e),forms:new L(e),reviews:new I(e),site:new P(e),legal:new B(e),cookies:new $(e),seo:new A(e),paths:new _(e)}}function Pe(s){return s.type==="content"}function Be(s){return s.type==="category"}
236
+ exports.EnhancementsService=F;exports.LynkowError=C;exports.MediaHelperService=D;exports.browserOnly=ve;exports.browserOnlyAsync=we;exports.createClient=Oe;exports.createLynkowClient=Ie;exports.detectSiteTheme=w;exports.isBrowser=c;exports.isCategoryResolve=Be;exports.isContentResolve=Pe;exports.isLynkowError=fe;exports.isServer=Ce;exports.onSiteThemeChange=b;//# sourceMappingURL=index.js.map
248
237
  //# sourceMappingURL=index.js.map