lynkow 3.2.0 → 3.2.1

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/README.md CHANGED
@@ -182,6 +182,12 @@ const result = await lynkow.forms.submit(
182
182
  )
183
183
  ```
184
184
 
185
+ > ⚠️ **Important**: Always use the SDK instead of raw `fetch()` calls. The SDK handles response parsing, caching, spam protection fields, and error handling automatically.
186
+ >
187
+ > If you use `fetch()` directly:
188
+ > - GET forms: API returns the form object directly (not wrapped in `{ form: ... }`)
189
+ > - POST submit: Data must be wrapped in a `data` field: `{ data: { name: "...", email: "..." }, honeypot: "", _hp: "", _ts: Date.now() }`
190
+
185
191
  ### Reviews
186
192
 
187
193
  ```typescript
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var C=class o extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,i){super(e),this.code=t,this.status=n,this.details=r,this.cause=i,Error.captureStackTrace&&Error.captureStackTrace(this,o);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let s=await e.json();s.errors&&Array.isArray(s.errors)?(r=s.errors,n=s.errors[0]?.message||n):s.error?n=s.error:s.message&&(n=s.message);}catch{n=e.statusText||n;}let i=o.statusToCode(t);return new o(n,i,t,r)}static fromNetworkError(e){return e.name==="AbortError"?new o("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new o("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new o(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 le(o){return o instanceof C}function pe(o){switch(o){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(o,e){let t;try{t=await fetch(o,e);}catch(p){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:p instanceof Error?p.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let r=pe(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,s=n.errors||[{message:i}];throw new C(i,r,t.status,s)}function J(o){let e=new URLSearchParams;for(let[t,n]of Object.entries(o))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var l={SHORT:300*1e3,MEDIUM:600*1e3},u=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 r=J(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,i=r?{...t,locale:r}:t,s=this.buildEndpointUrl(e,i),p=this.mergeFetchOptions(n?.fetchOptions);return K(s,{method:"GET",...p})}async getWithCache(e,t,n,r,i=l.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),i):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),i=this.mergeFetchOptions(n?.fetchOptions);return K(r,{method:"POST",...i,headers:{"Content-Type":"application/json",...i.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),i=await fetch(n,{method:"GET",...r});if(!i.ok)throw new Error(`HTTP error: ${i.status}`);return i.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var q="contents_",b=class extends u{async list(e,t){let n={};e?.page&&(n.page=e.page),e?.perPage&&(n.perPage=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 r=`${q}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/contents",n,t,l.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${q}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,l.SHORT)}clearCache(){this.invalidateCache(q);}};var F="categories_",x=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${F}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,l.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${F}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,l.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),t?.perPage&&(n.limit=t.perPage);let r=`${F}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,l.SHORT)}clearCache(){this.invalidateCache(F);}};var Q="tags_",E=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${Q}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,l.SHORT)}clearCache(){this.invalidateCache(Q);}};var k="pages_",L=class extends u{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${k}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(r,"/pages",n,e,l.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${k}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,l.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,r=`${k}path_${e}_${n||"default"}`;return (await this.getWithCache(r,"/page-by-path",{path:e},t,l.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,r=`${k}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,l.SHORT)).data}clearCache(){this.invalidateCache(k);}};var M="globals_",T=class extends u{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${M}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,l.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${M}${e}_${n||"default"}`;return this.getWithCache(r,`/global/${encodeURIComponent(e)}`,void 0,t,l.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(M);}};function D(o){return {_hp:"",_ts:o}}var Y="forms_",S=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${Y}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,l.MEDIUM)).data}async submit(e,t,n){let r=D(this.sessionStartTime),i={...t,...r};return n?.recaptchaToken&&(i._recaptcha_token=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,i,n)}clearCache(){this.invalidateCache(Y);}};var O="reviews_",P=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),e?.perPage&&(n.perPage=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 r=`${O}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,l.SHORT)}async getBySlug(e){let t=`${O}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,l.SHORT)).data}async settings(){let e=`${O}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,l.MEDIUM)}async submit(e,t){let n=D(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let i=await this.post("/reviews",r,t);return this.invalidateCache(O),i}clearCache(){this.invalidateCache(O);}};var Z="site_",I=class extends u{async getConfig(){let e=`${Z}config`;return (await this.getWithCache(e,"/site",void 0,void 0,l.MEDIUM)).data}clearCache(){this.invalidateCache(Z);}};var W="legal_",$=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${W}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,l.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${W}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,l.SHORT)).data}clearCache(){this.invalidateCache(W);}};var ee="cookies_",B=class extends u{async getConfig(){let e=`${ee}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,l.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/log",{preferences:e},t)}clearCache(){this.invalidateCache(ee);}};var A=class extends u{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}};var z="paths_",_=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${z}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,l.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,r=`${z}resolve_${e}_${n||"default"}`;return this.getWithCache(r,"/resolve",{path:e},t,l.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(z);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",de=!c;function ge(o,e){return c?o():e}async function ue(o,e){return c?o():e}var j="lynkow-tracker",N=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(j)){let r=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(r),this.loading=false,e());},50);setTimeout(()=>{clearInterval(r),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=j,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),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 trackFunnelStep(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.trackFunnel(e.funnelId,e.stepNumber,e.stepName,e.funnelName));}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(j)?.remove(),this.initialized=false,this.loadPromise=null;}};var G="_lkw_consent",X={necessary:true,analytics:false,marketing:false,preferences:false},U=class{config;events;bannerElement=null;preferencesElement=null;configCache=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){let t=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/log`;await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:e}),...this.config.fetchOptions}).catch(()=>{});}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(G);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(G,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&(this.bannerElement||this.getConfig().then(e=>{if(!e.enabled)return;let t=document.createElement("div");t.innerHTML=this.createBannerHTML(e),this.bannerElement=t.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents();}));}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null);}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);}));}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),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n);}reset(){if(c){try{localStorage.removeItem(G);}catch{}this.events.emit("consent-changed",{...X}),this.show();}}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",r=e.layout||"banner",i=e.primaryColor||"#0066cc",s=e.borderRadius??8,p={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);"},m={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;`},h={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;`},g;r==="floating"?g=m:r==="modal"?g=h:g=p;let a=g[t]||g.bottom||"",d=n==="dark",f=d?"#1a1a1a":"#ffffff",y=d?"#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 `
1
+ 'use strict';var C=class o extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,i){super(e),this.code=t,this.status=n,this.details=r,this.cause=i,Error.captureStackTrace&&Error.captureStackTrace(this,o);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let s=await e.json();s.errors&&Array.isArray(s.errors)?(r=s.errors,n=s.errors[0]?.message||n):s.error?n=s.error:s.message&&(n=s.message);}catch{n=e.statusText||n;}let i=o.statusToCode(t);return new o(n,i,t,r)}static fromNetworkError(e){return e.name==="AbortError"?new o("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new o("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new o(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 le(o){return o instanceof C}function pe(o){switch(o){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(o,e){let t;try{t=await fetch(o,e);}catch(p){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:p instanceof Error?p.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let r=pe(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,s=n.errors||[{message:i}];throw new C(i,r,t.status,s)}function J(o){let e=new URLSearchParams;for(let[t,n]of Object.entries(o))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var l={SHORT:300*1e3,MEDIUM:600*1e3},u=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 r=J(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,i=r?{...t,locale:r}:t,s=this.buildEndpointUrl(e,i),p=this.mergeFetchOptions(n?.fetchOptions);return K(s,{method:"GET",...p})}async getWithCache(e,t,n,r,i=l.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),i):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),i=this.mergeFetchOptions(n?.fetchOptions);return K(r,{method:"POST",...i,headers:{"Content-Type":"application/json",...i.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),i=await fetch(n,{method:"GET",...r});if(!i.ok)throw new Error(`HTTP error: ${i.status}`);return i.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var q="contents_",b=class extends u{async list(e,t){let n={};e?.page&&(n.page=e.page),e?.perPage&&(n.perPage=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 r=`${q}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/contents",n,t,l.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${q}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,l.SHORT)}clearCache(){this.invalidateCache(q);}};var F="categories_",x=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${F}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,l.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${F}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,l.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),t?.perPage&&(n.limit=t.perPage);let r=`${F}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,l.SHORT)}clearCache(){this.invalidateCache(F);}};var Q="tags_",E=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${Q}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,l.SHORT)}clearCache(){this.invalidateCache(Q);}};var k="pages_",L=class extends u{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${k}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(r,"/pages",n,e,l.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${k}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,l.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,r=`${k}path_${e}_${n||"default"}`;return (await this.getWithCache(r,"/page-by-path",{path:e},t,l.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,r=`${k}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,l.SHORT)).data}clearCache(){this.invalidateCache(k);}};var M="globals_",T=class extends u{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${M}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,l.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${M}${e}_${n||"default"}`;return this.getWithCache(r,`/global/${encodeURIComponent(e)}`,void 0,t,l.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(M);}};function D(o){return {_hp:"",_ts:o}}var Y="forms_",S=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${Y}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,l.MEDIUM)).data}async submit(e,t,n){let r=D(this.sessionStartTime),i={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(i.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,i,n)}clearCache(){this.invalidateCache(Y);}};var O="reviews_",P=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),e?.perPage&&(n.perPage=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 r=`${O}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,l.SHORT)}async getBySlug(e){let t=`${O}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,l.SHORT)).data}async settings(){let e=`${O}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,l.MEDIUM)}async submit(e,t){let n=D(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let i=await this.post("/reviews",r,t);return this.invalidateCache(O),i}clearCache(){this.invalidateCache(O);}};var Z="site_",I=class extends u{async getConfig(){let e=`${Z}config`;return (await this.getWithCache(e,"/site",void 0,void 0,l.MEDIUM)).data}clearCache(){this.invalidateCache(Z);}};var W="legal_",$=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${W}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,l.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${W}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,l.SHORT)).data}clearCache(){this.invalidateCache(W);}};var ee="cookies_",B=class extends u{async getConfig(){let e=`${ee}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,l.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/log",{preferences:e},t)}clearCache(){this.invalidateCache(ee);}};var A=class extends u{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}};var z="paths_",_=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${z}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,l.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,r=`${z}resolve_${e}_${n||"default"}`;return this.getWithCache(r,"/resolve",{path:e},t,l.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(z);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",de=!c;function ge(o,e){return c?o():e}async function ue(o,e){return c?o():e}var j="lynkow-tracker",N=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(j)){let r=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(r),this.loading=false,e());},50);setTimeout(()=>{clearInterval(r),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=j,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),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 trackFunnelStep(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.trackFunnel(e.funnelId,e.stepNumber,e.stepName,e.funnelName));}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(j)?.remove(),this.initialized=false,this.loadPromise=null;}};var G="_lkw_consent",X={necessary:true,analytics:false,marketing:false,preferences:false},U=class{config;events;bannerElement=null;preferencesElement=null;configCache=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){let t=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/log`;await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:e}),...this.config.fetchOptions}).catch(()=>{});}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(G);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(G,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&(this.bannerElement||this.getConfig().then(e=>{if(!e.enabled)return;let t=document.createElement("div");t.innerHTML=this.createBannerHTML(e),this.bannerElement=t.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents();}));}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null);}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);}));}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),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n);}reset(){if(c){try{localStorage.removeItem(G);}catch{}this.events.emit("consent-changed",{...X}),this.show();}}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",r=e.layout||"banner",i=e.primaryColor||"#0066cc",s=e.borderRadius??8,p={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);"},m={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;`},h={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;`},g;r==="floating"?g=m:r==="modal"?g=h:g=p;let a=g[t]||g.bottom||"",d=n==="dark",f=d?"#1a1a1a":"#ffffff",y=d?"#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
2
  ${r==="modal"?`
3
3
  <div id="lynkow-consent-backdrop" style="
4
4
  position: fixed;