lynkow 1.31.11 → 1.31.13
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 +72 -4
- package/dist/index.d.ts +72 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2250,9 +2250,12 @@ interface JsonLdNode {
|
|
|
2250
2250
|
/**
|
|
2251
2251
|
* Stable `@id` for this node. Server-generated (pattern `own-<8hex>`) when
|
|
2252
2252
|
* the caller omits it on create. Safe to treat as an opaque string; the
|
|
2253
|
-
* public API rewrites it to an absolute URL
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2253
|
+
* public API rewrites it to an absolute URL in the resolved graph,
|
|
2254
|
+
* with the prefix determined by the node's effective {@link scope}
|
|
2255
|
+
* (`<site-url>#<id>` for site-scoped entries like `Organization`,
|
|
2256
|
+
* `<page-url>#<id>` for page-scoped entries like `Article`).
|
|
2257
|
+
* Never starts with the reserved `auto:` prefix, which is reserved
|
|
2258
|
+
* for nodes Lynkow injects automatically.
|
|
2256
2259
|
*/
|
|
2257
2260
|
id: string;
|
|
2258
2261
|
/**
|
|
@@ -2276,6 +2279,19 @@ interface JsonLdNode {
|
|
|
2276
2279
|
data: Record<string, unknown>;
|
|
2277
2280
|
/** Whether the node was created from a Lynkow typed preset or from raw JSON-LD. */
|
|
2278
2281
|
source: JsonLdNodeSource;
|
|
2282
|
+
/**
|
|
2283
|
+
* Optional `@id` scope override. When omitted, the cascade infers
|
|
2284
|
+
* the default from the level the entry was declared at:
|
|
2285
|
+
* - `site` for entries at site or category level (Organization,
|
|
2286
|
+
* LocalBusiness for a section, Publisher).
|
|
2287
|
+
* - `page` for entries at page or content level (Article, Product,
|
|
2288
|
+
* custom Person).
|
|
2289
|
+
* Set explicitly to opt out of the default - e.g. `scope: 'site'`
|
|
2290
|
+
* on a content-level Organization that should still be stable
|
|
2291
|
+
* across pages. The resolved `@id` becomes `<site-url>#<id>` for
|
|
2292
|
+
* `site` scope and `<page-url>#<id>` for `page` scope.
|
|
2293
|
+
*/
|
|
2294
|
+
scope?: 'site' | 'page';
|
|
2279
2295
|
}
|
|
2280
2296
|
/**
|
|
2281
2297
|
* Cascade configuration stored at any level (site, category, page, content).
|
|
@@ -6550,5 +6566,57 @@ declare function onSiteThemeChange(callback: (theme: 'dark' | 'light') => void):
|
|
|
6550
6566
|
* ```
|
|
6551
6567
|
*/
|
|
6552
6568
|
declare function renderJsonLdGraph(nodes: object[] | null | undefined): string;
|
|
6569
|
+
/**
|
|
6570
|
+
* Concatenate the server-resolved `@graph` with custom client-side nodes
|
|
6571
|
+
* (e.g. ad-hoc Review entries derived from props your Next.js page already
|
|
6572
|
+
* has, or per-page schema.org additions that don't fit the cascade).
|
|
6573
|
+
*
|
|
6574
|
+
* Use this instead of a raw `[...server, ...custom]` spread so:
|
|
6575
|
+
* - `null` / `undefined` inputs are tolerated, returning a defensively
|
|
6576
|
+
* empty array — the result is always safe to pass to {@link renderJsonLdGraph}.
|
|
6577
|
+
* - `@id` collisions between the server graph and your custom nodes are
|
|
6578
|
+
* detected and emit a `console.warn`. Google merges schema.org entities
|
|
6579
|
+
* that share an `@id`, which can produce duplicate properties (e.g. two
|
|
6580
|
+
* `aggregateRating` on a single LocalBusiness) and downgrade rich
|
|
6581
|
+
* results. The recommended pattern is to prefix custom `@id` values with
|
|
6582
|
+
* the page URL (e.g. `'https://example.com/reviews#review-42'`) so they
|
|
6583
|
+
* are guaranteed unique site-wide.
|
|
6584
|
+
*
|
|
6585
|
+
* The function does not deduplicate, reorder, or rewrite ids - it only
|
|
6586
|
+
* concatenates and warns. The intent is to keep the merge transparent so
|
|
6587
|
+
* you can debug the resulting graph by reading top to bottom.
|
|
6588
|
+
*
|
|
6589
|
+
* @param server - Server-resolved graph from `content.structuredData?.graph`
|
|
6590
|
+
* or `page.structuredData?.graph`. `null` / `undefined`
|
|
6591
|
+
* treated as an empty array.
|
|
6592
|
+
* @param custom - Additional nodes you want to inject. Each entry should
|
|
6593
|
+
* be a fully-formed schema.org object (with at least
|
|
6594
|
+
* `@type` and a unique `@id`). `null` / `undefined`
|
|
6595
|
+
* treated as an empty array.
|
|
6596
|
+
* @returns Concatenated graph ready for {@link renderJsonLdGraph}.
|
|
6597
|
+
* @throws Never throws. `console.warn` is the only side effect on
|
|
6598
|
+
* collisions.
|
|
6599
|
+
*
|
|
6600
|
+
* @example
|
|
6601
|
+
* ```tsx
|
|
6602
|
+
* import { mergeIntoGraph, renderJsonLdGraph } from 'lynkow'
|
|
6603
|
+
* import { lynkow } from '@/lib/lynkow'
|
|
6604
|
+
*
|
|
6605
|
+
* export default async function ReviewsPage() {
|
|
6606
|
+
* const page = await lynkow.pages.getBySlug('reviews')
|
|
6607
|
+
* const customNodes = [
|
|
6608
|
+
* {
|
|
6609
|
+
* '@context': 'https://schema.org',
|
|
6610
|
+
* '@id': 'https://example.com/reviews#breadcrumb-extra',
|
|
6611
|
+
* '@type': 'BreadcrumbList',
|
|
6612
|
+
* 'itemListElement': [ ],
|
|
6613
|
+
* },
|
|
6614
|
+
* ]
|
|
6615
|
+
* const merged = mergeIntoGraph(page.structuredData?.graph, customNodes)
|
|
6616
|
+
* return <div dangerouslySetInnerHTML={{ __html: renderJsonLdGraph(merged) }} />
|
|
6617
|
+
* }
|
|
6618
|
+
* ```
|
|
6619
|
+
*/
|
|
6620
|
+
declare function mergeIntoGraph(server: object[] | null | undefined, custom: object[] | null | undefined): object[];
|
|
6553
6621
|
|
|
6554
|
-
export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchProfilePublic, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, onSiteThemeChange, renderJsonLdGraph };
|
|
6622
|
+
export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchProfilePublic, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, mergeIntoGraph, onSiteThemeChange, renderJsonLdGraph };
|
package/dist/index.d.ts
CHANGED
|
@@ -2250,9 +2250,12 @@ interface JsonLdNode {
|
|
|
2250
2250
|
/**
|
|
2251
2251
|
* Stable `@id` for this node. Server-generated (pattern `own-<8hex>`) when
|
|
2252
2252
|
* the caller omits it on create. Safe to treat as an opaque string; the
|
|
2253
|
-
* public API rewrites it to an absolute URL
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2253
|
+
* public API rewrites it to an absolute URL in the resolved graph,
|
|
2254
|
+
* with the prefix determined by the node's effective {@link scope}
|
|
2255
|
+
* (`<site-url>#<id>` for site-scoped entries like `Organization`,
|
|
2256
|
+
* `<page-url>#<id>` for page-scoped entries like `Article`).
|
|
2257
|
+
* Never starts with the reserved `auto:` prefix, which is reserved
|
|
2258
|
+
* for nodes Lynkow injects automatically.
|
|
2256
2259
|
*/
|
|
2257
2260
|
id: string;
|
|
2258
2261
|
/**
|
|
@@ -2276,6 +2279,19 @@ interface JsonLdNode {
|
|
|
2276
2279
|
data: Record<string, unknown>;
|
|
2277
2280
|
/** Whether the node was created from a Lynkow typed preset or from raw JSON-LD. */
|
|
2278
2281
|
source: JsonLdNodeSource;
|
|
2282
|
+
/**
|
|
2283
|
+
* Optional `@id` scope override. When omitted, the cascade infers
|
|
2284
|
+
* the default from the level the entry was declared at:
|
|
2285
|
+
* - `site` for entries at site or category level (Organization,
|
|
2286
|
+
* LocalBusiness for a section, Publisher).
|
|
2287
|
+
* - `page` for entries at page or content level (Article, Product,
|
|
2288
|
+
* custom Person).
|
|
2289
|
+
* Set explicitly to opt out of the default - e.g. `scope: 'site'`
|
|
2290
|
+
* on a content-level Organization that should still be stable
|
|
2291
|
+
* across pages. The resolved `@id` becomes `<site-url>#<id>` for
|
|
2292
|
+
* `site` scope and `<page-url>#<id>` for `page` scope.
|
|
2293
|
+
*/
|
|
2294
|
+
scope?: 'site' | 'page';
|
|
2279
2295
|
}
|
|
2280
2296
|
/**
|
|
2281
2297
|
* Cascade configuration stored at any level (site, category, page, content).
|
|
@@ -6550,5 +6566,57 @@ declare function onSiteThemeChange(callback: (theme: 'dark' | 'light') => void):
|
|
|
6550
6566
|
* ```
|
|
6551
6567
|
*/
|
|
6552
6568
|
declare function renderJsonLdGraph(nodes: object[] | null | undefined): string;
|
|
6569
|
+
/**
|
|
6570
|
+
* Concatenate the server-resolved `@graph` with custom client-side nodes
|
|
6571
|
+
* (e.g. ad-hoc Review entries derived from props your Next.js page already
|
|
6572
|
+
* has, or per-page schema.org additions that don't fit the cascade).
|
|
6573
|
+
*
|
|
6574
|
+
* Use this instead of a raw `[...server, ...custom]` spread so:
|
|
6575
|
+
* - `null` / `undefined` inputs are tolerated, returning a defensively
|
|
6576
|
+
* empty array — the result is always safe to pass to {@link renderJsonLdGraph}.
|
|
6577
|
+
* - `@id` collisions between the server graph and your custom nodes are
|
|
6578
|
+
* detected and emit a `console.warn`. Google merges schema.org entities
|
|
6579
|
+
* that share an `@id`, which can produce duplicate properties (e.g. two
|
|
6580
|
+
* `aggregateRating` on a single LocalBusiness) and downgrade rich
|
|
6581
|
+
* results. The recommended pattern is to prefix custom `@id` values with
|
|
6582
|
+
* the page URL (e.g. `'https://example.com/reviews#review-42'`) so they
|
|
6583
|
+
* are guaranteed unique site-wide.
|
|
6584
|
+
*
|
|
6585
|
+
* The function does not deduplicate, reorder, or rewrite ids - it only
|
|
6586
|
+
* concatenates and warns. The intent is to keep the merge transparent so
|
|
6587
|
+
* you can debug the resulting graph by reading top to bottom.
|
|
6588
|
+
*
|
|
6589
|
+
* @param server - Server-resolved graph from `content.structuredData?.graph`
|
|
6590
|
+
* or `page.structuredData?.graph`. `null` / `undefined`
|
|
6591
|
+
* treated as an empty array.
|
|
6592
|
+
* @param custom - Additional nodes you want to inject. Each entry should
|
|
6593
|
+
* be a fully-formed schema.org object (with at least
|
|
6594
|
+
* `@type` and a unique `@id`). `null` / `undefined`
|
|
6595
|
+
* treated as an empty array.
|
|
6596
|
+
* @returns Concatenated graph ready for {@link renderJsonLdGraph}.
|
|
6597
|
+
* @throws Never throws. `console.warn` is the only side effect on
|
|
6598
|
+
* collisions.
|
|
6599
|
+
*
|
|
6600
|
+
* @example
|
|
6601
|
+
* ```tsx
|
|
6602
|
+
* import { mergeIntoGraph, renderJsonLdGraph } from 'lynkow'
|
|
6603
|
+
* import { lynkow } from '@/lib/lynkow'
|
|
6604
|
+
*
|
|
6605
|
+
* export default async function ReviewsPage() {
|
|
6606
|
+
* const page = await lynkow.pages.getBySlug('reviews')
|
|
6607
|
+
* const customNodes = [
|
|
6608
|
+
* {
|
|
6609
|
+
* '@context': 'https://schema.org',
|
|
6610
|
+
* '@id': 'https://example.com/reviews#breadcrumb-extra',
|
|
6611
|
+
* '@type': 'BreadcrumbList',
|
|
6612
|
+
* 'itemListElement': [ ],
|
|
6613
|
+
* },
|
|
6614
|
+
* ]
|
|
6615
|
+
* const merged = mergeIntoGraph(page.structuredData?.graph, customNodes)
|
|
6616
|
+
* return <div dangerouslySetInnerHTML={{ __html: renderJsonLdGraph(merged) }} />
|
|
6617
|
+
* }
|
|
6618
|
+
* ```
|
|
6619
|
+
*/
|
|
6620
|
+
declare function mergeIntoGraph(server: object[] | null | undefined, custom: object[] | null | undefined): object[];
|
|
6553
6621
|
|
|
6554
|
-
export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchProfilePublic, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, onSiteThemeChange, renderJsonLdGraph };
|
|
6622
|
+
export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchProfilePublic, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, mergeIntoGraph, onSiteThemeChange, renderJsonLdGraph };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var C=class s extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,o){super(e),this.code=t,this.status=n,this.details=r,this.cause=o,Error.captureStackTrace&&Error.captureStackTrace(this,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(r=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let o=s.statusToCode(t);return new s(n,o,t,r)}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 we(s){return s instanceof C}function be(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 W(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 r=be(t.status),o=n.error||n.message||`HTTP error: ${t.status}`,i=n.errors||[{message:o}];throw new C(o,r,t.status,i)}function se(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 r=se(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,o=r?{...t,locale:r}:t,i=this.buildEndpointUrl(e,o),a=this.mergeFetchOptions(n?.fetchOptions);return W(i,{method:"GET",...a})}async getWithCache(e,t,n,r,o=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),o):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),o=this.mergeFetchOptions(n?.fetchOptions);return W(r,{method:"POST",...o,headers:{"Content-Type":"application/json",...o.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),o=await fetch(n,{method:"GET",...r});if(!o.ok)throw new Error(`HTTP error: ${o.status}`);return o.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var G="contents_",b=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 r=`${G}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${G}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(G);}};var j="categories_",R=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${j}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${j}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 r=`${j}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(j);}};var ie="tags_",x=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${ie}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(ie);}};var F="pages_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${F}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(r,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${F}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,r=`${F}path_${e}_${n||"default"}`;return (await this.getWithCache(r,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,r=`${F}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(F);}};var J="globals_",E=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${J}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,r=`${J}${e}_${n||"default"}`;return this.getWithCache(r,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(J);}};function K(s){return {_hp:"",_ts:s}}var ae="forms_",S=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${ae}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let r=K(this.sessionStartTime),o={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(o.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,o,n)}clearCache(){this.invalidateCache(ae);}};var D="reviews_",T=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 r=`${D}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${D}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${D}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=K(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let o=await this.post("/reviews",r,t);return this.invalidateCache(D),o}clearCache(){this.invalidateCache(D);}};var ce="site_",L=class extends m{async getConfig(){let e=`${ce}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ce);}};var V="legal_",O=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${V}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,r=`${V}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(V);}};var le="cookies_",I=class extends m{async getConfig(){let e=`${le}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(le);}};var P=class extends m{async sitemap(e){return this.getText("/sitemap.xml",e)}async sitemapPart(e,t){return this.getText(`/sitemap-${e}.xml`,t)}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 X="paths_",B=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${X}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,r=`${X}resolve_${e}_${n||"default"}`;return this.getWithCache(r,"/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(X);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Re=!c;function xe(s,e){return c?s():e}async function ke(s,e){return c?s():e}var Y="lynkow-tracker",q=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(Y)){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=Y,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 r=localStorage.getItem("_lkw_consent_mode");r&&n.setAttribute("data-consent-mode",r);}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(Y)?.remove(),this.initialized=false,this.loadPromise=null;}};function Ee(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),r=parseInt(e[2],10),o=parseInt(e[3],10);return (.299*n+.587*r+.114*o)/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 r=t.getAttribute(n)?.toLowerCase();if(r){if(r.includes("dark"))return "dark";if(r.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=Ee(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 $(s){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let i=w();i!==e&&(e=i,s(i));},r=new MutationObserver(n),o={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};r.observe(document.documentElement,o),r.observe(document.body,o),t.push(()=>r.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 z="_lkw_consent",Se=365*24*60*60*1e3,de="lkw-script-",Q={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(([o])=>o!=="necessary"),n=t.every(([,o])=>o===true),r=t.every(([,o])=>o===false);return n?"accept_all":r?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(z);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>Se?(localStorage.removeItem(z),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(z,JSON.stringify({choices:e,timestamp:Date.now()}));}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;this.injectBannerStylesOnce();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=$(r=>{this.updateConsentTheme(r);}));});}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=$(r=>{this.updateConsentTheme(r);}));}));}getCategories(){return c?this.getStoredConsent()||{...Q}:{...Q}}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(z);}catch{}this.events.emit("consent-changed",{...Q}),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 r=document.createElement("div");r.innerHTML=n.script;let o=Array.from(r.children);for(let i=0;i<o.length;i++){let a=o[i],p=`${de}${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(`${de}${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:r}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=r),this.preferencesElement){let o=this.preferencesElement.querySelector(":scope > div");o&&(o.style.background=n,o.style.color=r);}}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),r=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"}injectBannerStylesOnce(){if(document.getElementById("lynkow-consent-styles"))return;let e=document.createElement("style");e.id="lynkow-consent-styles",e.textContent=`
|
|
1
|
+
'use strict';var C=class s extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,o){super(e),this.code=t,this.status=n,this.details=r,this.cause=o,Error.captureStackTrace&&Error.captureStackTrace(this,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(r=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let o=s.statusToCode(t);return new s(n,o,t,r)}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 we(s){return s instanceof C}function be(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 W(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 r=be(t.status),o=n.error||n.message||`HTTP error: ${t.status}`,i=n.errors||[{message:o}];throw new C(o,r,t.status,i)}function se(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 r=se(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,o=r?{...t,locale:r}:t,i=this.buildEndpointUrl(e,o),a=this.mergeFetchOptions(n?.fetchOptions);return W(i,{method:"GET",...a})}async getWithCache(e,t,n,r,o=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),o):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),o=this.mergeFetchOptions(n?.fetchOptions);return W(r,{method:"POST",...o,headers:{"Content-Type":"application/json",...o.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),o=await fetch(n,{method:"GET",...r});if(!o.ok)throw new Error(`HTTP error: ${o.status}`);return o.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var G="contents_",b=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 r=`${G}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${G}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(G);}};var j="categories_",R=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${j}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${j}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 r=`${j}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(j);}};var ie="tags_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${ie}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(ie);}};var F="pages_",x=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${F}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(r,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${F}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,r=`${F}path_${e}_${n||"default"}`;return (await this.getWithCache(r,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,r=`${F}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(F);}};var J="globals_",E=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${J}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,r=`${J}${e}_${n||"default"}`;return this.getWithCache(r,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(J);}};function K(s){return {_hp:"",_ts:s}}var ae="forms_",S=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${ae}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let r=K(this.sessionStartTime),o={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(o.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,o,n)}clearCache(){this.invalidateCache(ae);}};var D="reviews_",T=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 r=`${D}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${D}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${D}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=K(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let o=await this.post("/reviews",r,t);return this.invalidateCache(D),o}clearCache(){this.invalidateCache(D);}};var ce="site_",L=class extends m{async getConfig(){let e=`${ce}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ce);}};var V="legal_",O=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${V}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,r=`${V}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(V);}};var le="cookies_",I=class extends m{async getConfig(){let e=`${le}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(le);}};var P=class extends m{async sitemap(e){return this.getText("/sitemap.xml",e)}async sitemapPart(e,t){return this.getText(`/sitemap-${e}.xml`,t)}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 X="paths_",B=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${X}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,r=`${X}resolve_${e}_${n||"default"}`;return this.getWithCache(r,"/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(X);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Re=!c;function ke(s,e){return c?s():e}async function xe(s,e){return c?s():e}var Y="lynkow-tracker",q=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(Y)){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=Y,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 r=localStorage.getItem("_lkw_consent_mode");r&&n.setAttribute("data-consent-mode",r);}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(Y)?.remove(),this.initialized=false,this.loadPromise=null;}};function Ee(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),r=parseInt(e[2],10),o=parseInt(e[3],10);return (.299*n+.587*r+.114*o)/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 r=t.getAttribute(n)?.toLowerCase();if(r){if(r.includes("dark"))return "dark";if(r.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=Ee(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 $(s){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let i=w();i!==e&&(e=i,s(i));},r=new MutationObserver(n),o={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};r.observe(document.documentElement,o),r.observe(document.body,o),t.push(()=>r.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 z="_lkw_consent",Se=365*24*60*60*1e3,de="lkw-script-",Q={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(([o])=>o!=="necessary"),n=t.every(([,o])=>o===true),r=t.every(([,o])=>o===false);return n?"accept_all":r?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(z);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>Se?(localStorage.removeItem(z),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(z,JSON.stringify({choices:e,timestamp:Date.now()}));}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;this.injectBannerStylesOnce();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=$(r=>{this.updateConsentTheme(r);}));});}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=$(r=>{this.updateConsentTheme(r);}));}));}getCategories(){return c?this.getStoredConsent()||{...Q}:{...Q}}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(z);}catch{}this.events.emit("consent-changed",{...Q}),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 r=document.createElement("div");r.innerHTML=n.script;let o=Array.from(r.children);for(let i=0;i<o.length;i++){let a=o[i],p=`${de}${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(`${de}${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:r}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=r),this.preferencesElement){let o=this.preferencesElement.querySelector(":scope > div");o&&(o.style.background=n,o.style.color=r);}}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),r=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"}injectBannerStylesOnce(){if(document.getElementById("lynkow-consent-styles"))return;let e=document.createElement("style");e.id="lynkow-consent-styles",e.textContent=`
|
|
2
2
|
#lynkow-consent-banner {
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
max-height: calc(100vh - 40px);
|
|
@@ -278,6 +278,6 @@
|
|
|
278
278
|
color: #1a1a1a;
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
`,M=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(te))return;let e=document.createElement("style");e.id=te,e.textContent=Ie,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 r=n.textContent||"";try{await navigator.clipboard.writeText(r),e.classList.add("copied"),e.innerHTML=Oe,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Le;},2e3);}catch(o){console.error("Lynkow SDK: Failed to copy code",o);}}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])"),r=Array.from(n).filter(o=>!o.src&&o.isConnected&&Te.has(o.type.toLowerCase()));r.length!==0&&(document.head.querySelectorAll(`script[${ne}]`).forEach(o=>o.remove()),r.forEach(o=>{o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=o.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=o.textContent,i.setAttribute(ne,""),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(te)?.remove(),document.head.querySelectorAll(`script[${ne}]`).forEach(e=>e.remove()),this.initialized=false);}};var U=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:r="scale-down",quality:o=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${r}`,"format=auto",`quality=${o}`,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 r=[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/${r}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let o=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:o,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let o=e.substring(0,n),i=e.substring(n+1);return {cdnBase:o,relativePath:i}}let r=e.indexOf("/avatars/");if(r!==-1){let o=e.substring(0,r),i=e.substring(r+1);return {cdnBase:o,relativePath:i}}return null}};var A=class extends m{async search(e,t){return this.get("/search",{q:e,locale:t?.locale,category:t?.category,tag:t?.tag,page:t?.page,limit:t?.limit},t)}async getConfig(e){return this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)}async listProfiles(e){return (await this.getWithCache("search-profiles","/search/profiles",void 0,e,d.MEDIUM)).data}async searchByProfile(e,t,n){return this.get(`/search/${encodeURIComponent(e)}`,{q:t,locale:n?.locale,category:n?.category,tag:n?.tag,page:n?.page,limit:n?.limit},n)}};var Pe=300*1e3,Be="lynkow_cache_",v=new Map;function pe(s={}){let e=s.defaultTtl??Pe,t=s.prefix??Be;function n(u){return `${t}${u}`}function r(u){return Date.now()>u.expiresAt}function o(u){let l=n(u);if(c)try{let f=localStorage.getItem(l);if(!f)return null;let y=JSON.parse(f);return r(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let h=v.get(l);return h?r(h)?(v.delete(l),null):h.value:null}function i(u,l,h=e){let f=n(u),y={value:l,expiresAt:Date.now()+h};if(c){try{localStorage.setItem(f,JSON.stringify(y));}catch{}return}v.set(f,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 h=0;h<localStorage.length;h++){let f=localStorage.key(h);f&&f.startsWith(t)&&(!u||f.includes(u))&&l.push(f);}l.forEach(h=>localStorage.removeItem(h));}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,h=e){let f=o(u);if(f!==null)return f;let y=await l();return i(u,y,h),y}return {get:o,set:i,remove:a,invalidate:p,getOrSet:g}}function me(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 ue(){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 r(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function o(i){i?s.delete(i):s.clear();}return {on:e,off:t,emit:n,once:r,removeAllListeners:o}}var ge="lynkow_locale";function re(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function he(s,e){if(!c)return e;let t=$e();if(t&&s.includes(t))return t;let n=Ae(s);if(n)return n;let r=document.documentElement.lang;if(r){let o=re(r,s);if(o)return o;let i=r.split("-")[0]?.toLowerCase();if(i){let a=re(i,s);if(a)return a}}return e}function $e(){if(!c)return null;try{return localStorage.getItem(ge)}catch{return null}}function fe(s){if(c)try{localStorage.setItem(ge,s);}catch{}}function Ae(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let r=re(n,s);if(r)return r}}return null}function ye(s,e){return e.includes(s)}var Ce="https://api.lynkow.com";function _e(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=s.cache===true?pe():void 0,t=me({debug:s.debug??false}),n=ue(),r=(s.baseUrl||Ce).replace(/\/$/,""),o={siteId:s.siteId,baseUrl:r,locale:s.locale,fetchOptions:s.fetchOptions||{},...e?{cache:e}:{}},i={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new b(o),categories:new R(o),tags:new x(o),pages:new k(o),blocks:new E(o),forms:new S(o),reviews:new T(o),site:new L(o),legal:new O(o),cookies:new I(o),seo:new P(o),paths:new B(o),analytics:new q(o),consent:new N(o,n),branding:new H(o),enhancements:new M,media:new U,search:new A(o)};function p(l){o.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let h=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[h],c&&!s.locale){let f=he(i.availableLocales,h);i.locale=f,p(f);}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:r,debug:s.debug??false,cache:s.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!ye(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&fe(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,h){return n.on(l,h)}}}function Fe(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||Ce).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new x(e),pages:new k(e),blocks:new E(e),forms:new S(e),reviews:new T(e),site:new L(e),legal:new O(e),cookies:new I(e),seo:new P(e),paths:new B(e),search:new A(e)}}function De(s){return s.type==="content"}function qe(s){return s.type==="category"}function Ne(s){if(!s||s.length===0)return "";let e=s.map(r=>{let{["@context"]:o,...i}=r;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}
|
|
282
|
-
exports.AnalyticsService=q;exports.BlocksService=E;exports.BrandingService=H;exports.CategoriesService=R;exports.ConsentService=N;exports.ContentsService=b;exports.CookiesService=I;exports.EnhancementsService=M;exports.FormsService=S;exports.LegalService=O;exports.LynkowError=C;exports.MediaHelperService=U;exports.PagesService=
|
|
281
|
+
`,M=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(te))return;let e=document.createElement("style");e.id=te,e.textContent=Ie,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 r=n.textContent||"";try{await navigator.clipboard.writeText(r),e.classList.add("copied"),e.innerHTML=Oe,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Le;},2e3);}catch(o){console.error("Lynkow SDK: Failed to copy code",o);}}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])"),r=Array.from(n).filter(o=>!o.src&&o.isConnected&&Te.has(o.type.toLowerCase()));r.length!==0&&(document.head.querySelectorAll(`script[${ne}]`).forEach(o=>o.remove()),r.forEach(o=>{o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=o.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=o.textContent,i.setAttribute(ne,""),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(te)?.remove(),document.head.querySelectorAll(`script[${ne}]`).forEach(e=>e.remove()),this.initialized=false);}};var U=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:r="scale-down",quality:o=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${r}`,"format=auto",`quality=${o}`,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 r=[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/${r}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let o=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:o,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let o=e.substring(0,n),i=e.substring(n+1);return {cdnBase:o,relativePath:i}}let r=e.indexOf("/avatars/");if(r!==-1){let o=e.substring(0,r),i=e.substring(r+1);return {cdnBase:o,relativePath:i}}return null}};var A=class extends m{async search(e,t){return this.get("/search",{q:e,locale:t?.locale,category:t?.category,tag:t?.tag,page:t?.page,limit:t?.limit},t)}async getConfig(e){return this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)}async listProfiles(e){return (await this.getWithCache("search-profiles","/search/profiles",void 0,e,d.MEDIUM)).data}async searchByProfile(e,t,n){return this.get(`/search/${encodeURIComponent(e)}`,{q:t,locale:n?.locale,category:n?.category,tag:n?.tag,page:n?.page,limit:n?.limit},n)}};var Pe=300*1e3,Be="lynkow_cache_",v=new Map;function pe(s={}){let e=s.defaultTtl??Pe,t=s.prefix??Be;function n(u){return `${t}${u}`}function r(u){return Date.now()>u.expiresAt}function o(u){let l=n(u);if(c)try{let f=localStorage.getItem(l);if(!f)return null;let y=JSON.parse(f);return r(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let h=v.get(l);return h?r(h)?(v.delete(l),null):h.value:null}function i(u,l,h=e){let f=n(u),y={value:l,expiresAt:Date.now()+h};if(c){try{localStorage.setItem(f,JSON.stringify(y));}catch{}return}v.set(f,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 h=0;h<localStorage.length;h++){let f=localStorage.key(h);f&&f.startsWith(t)&&(!u||f.includes(u))&&l.push(f);}l.forEach(h=>localStorage.removeItem(h));}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,h=e){let f=o(u);if(f!==null)return f;let y=await l();return i(u,y,h),y}return {get:o,set:i,remove:a,invalidate:p,getOrSet:g}}function me(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 ue(){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 r(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function o(i){i?s.delete(i):s.clear();}return {on:e,off:t,emit:n,once:r,removeAllListeners:o}}var ge="lynkow_locale";function re(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function he(s,e){if(!c)return e;let t=$e();if(t&&s.includes(t))return t;let n=Ae(s);if(n)return n;let r=document.documentElement.lang;if(r){let o=re(r,s);if(o)return o;let i=r.split("-")[0]?.toLowerCase();if(i){let a=re(i,s);if(a)return a}}return e}function $e(){if(!c)return null;try{return localStorage.getItem(ge)}catch{return null}}function fe(s){if(c)try{localStorage.setItem(ge,s);}catch{}}function Ae(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let r=re(n,s);if(r)return r}}return null}function ye(s,e){return e.includes(s)}var Ce="https://api.lynkow.com";function _e(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=s.cache===true?pe():void 0,t=me({debug:s.debug??false}),n=ue(),r=(s.baseUrl||Ce).replace(/\/$/,""),o={siteId:s.siteId,baseUrl:r,locale:s.locale,fetchOptions:s.fetchOptions||{},...e?{cache:e}:{}},i={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new b(o),categories:new R(o),tags:new k(o),pages:new x(o),blocks:new E(o),forms:new S(o),reviews:new T(o),site:new L(o),legal:new O(o),cookies:new I(o),seo:new P(o),paths:new B(o),analytics:new q(o),consent:new N(o,n),branding:new H(o),enhancements:new M,media:new U,search:new A(o)};function p(l){o.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let h=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[h],c&&!s.locale){let f=he(i.availableLocales,h);i.locale=f,p(f);}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:r,debug:s.debug??false,cache:s.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!ye(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&fe(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,h){return n.on(l,h)}}}function Fe(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||Ce).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new k(e),pages:new x(e),blocks:new E(e),forms:new S(e),reviews:new T(e),site:new L(e),legal:new O(e),cookies:new I(e),seo:new P(e),paths:new B(e),search:new A(e)}}function De(s){return s.type==="content"}function qe(s){return s.type==="category"}function Ne(s){if(!s||s.length===0)return "";let e=s.map(r=>{let{["@context"]:o,...i}=r;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}function He(s,e){let t=s??[],n=e??[];if(n.length===0)return [...t];let r=new Set;for(let o of t){let i=o?.["@id"];typeof i=="string"&&r.add(i);}for(let o of n){let i=o?.["@id"];typeof i=="string"&&r.has(i)&&console.warn(`[lynkow] @id collision in mergeIntoGraph: "${i}" appears in both the server graph and your custom nodes. Google may merge them, which can duplicate properties on the rendered entity. Prefix custom @ids with the page URL to make them unique.`);}return [...t,...n]}
|
|
282
|
+
exports.AnalyticsService=q;exports.BlocksService=E;exports.BrandingService=H;exports.CategoriesService=R;exports.ConsentService=N;exports.ContentsService=b;exports.CookiesService=I;exports.EnhancementsService=M;exports.FormsService=S;exports.LegalService=O;exports.LynkowError=C;exports.MediaHelperService=U;exports.PagesService=x;exports.PathsService=B;exports.ReviewsService=T;exports.SearchService=A;exports.SeoService=P;exports.SiteService=L;exports.TagsService=k;exports.browserOnly=ke;exports.browserOnlyAsync=xe;exports.createClient=_e;exports.createLynkowClient=Fe;exports.detectSiteTheme=w;exports.isBrowser=c;exports.isCategoryResolve=qe;exports.isContentResolve=De;exports.isLynkowError=we;exports.isServer=Re;exports.mergeIntoGraph=He;exports.onSiteThemeChange=$;exports.renderJsonLdGraph=Ne;//# sourceMappingURL=index.js.map
|
|
283
283
|
//# sourceMappingURL=index.js.map
|