sitetourkit 0.0.0-stage → 0.7.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.
@@ -0,0 +1,131 @@
1
+ import { a as TargetRef, P as Placement, L as Labels, b as Side, c as ScrollOptions, d as StorageKind } from './types-M-1II5wP.js';
2
+
3
+ /** Axis-aligned rectangle in viewport coordinates. */
4
+ interface Rect {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ }
10
+
11
+ type MarkerAnchor = `${"top" | "middle" | "bottom"}-${"start" | "center" | "end"}`;
12
+ interface HintInput {
13
+ target: TargetRef;
14
+ content: string;
15
+ /** Stable identity used for dismiss persistence; defaults to the list index. */
16
+ id?: string;
17
+ /** Where the marker dot sits on the target. */
18
+ markerPosition?: MarkerAnchor;
19
+ /** Popover placement relative to the marker. */
20
+ placement?: Placement;
21
+ }
22
+ interface Hint extends HintInput {
23
+ id: string;
24
+ markerPosition: MarkerAnchor;
25
+ placement: Placement;
26
+ dismissed: boolean;
27
+ }
28
+ interface HintsOptions {
29
+ hints?: HintInput[];
30
+ container?: Element;
31
+ /**
32
+ * Scope for resolving string selectors and scanning `[data-hint]`.
33
+ * Pass a `ShadowRoot` to hint elements inside a web component.
34
+ */
35
+ root?: Document | ShadowRoot | Element;
36
+ marker?: {
37
+ pulse?: boolean;
38
+ };
39
+ /** `buttonLabel` overrides `labels.hintDismiss` for this instance. */
40
+ popover?: {
41
+ button?: boolean;
42
+ buttonLabel?: string;
43
+ };
44
+ /**
45
+ * Label set, shared with tours: `createHints({ labels: ru })`. Only the
46
+ * hint-related entries are used (`hintDismiss`).
47
+ */
48
+ labels?: Partial<Labels>;
49
+ placement?: Placement;
50
+ placementPrecedence?: Side[];
51
+ markerPosition?: MarkerAnchor;
52
+ /**
53
+ * Scroll the hint's target into view when a popover is opened. Off by
54
+ * default: a click on a visible marker must not move the page. Turn it on
55
+ * for programmatic `open(i)` calls, where the marker may be off screen.
56
+ */
57
+ scroll?: Partial<ScrollOptions>;
58
+ /**
59
+ * Mark `<body>` with `tk-hints-open` while a popover is open, so host CSS
60
+ * can react (dim its own chrome, pause animations).
61
+ */
62
+ hostClasses?: boolean;
63
+ /** Render popover content as HTML (off by default, XSS-safe). */
64
+ allowHTML?: boolean;
65
+ /** Sanitizer applied to popover HTML when `allowHTML` is on (e.g. DOMPurify). */
66
+ sanitize?: (html: string) => string;
67
+ /** Persist dismissed hints under this key so they stay hidden after reload. */
68
+ rememberDismissed?: {
69
+ key: string;
70
+ storage?: StorageKind;
71
+ };
72
+ theme?: string;
73
+ zIndex?: number;
74
+ }
75
+ /** Per-call overrides for `Hints.open`. */
76
+ interface HintOpenOptions {
77
+ /** Scroll the target into view first (default: the instance's `scroll` policy). */
78
+ scroll?: boolean;
79
+ }
80
+ /** Type alias on purpose: closed `keyof` union, typos fail to compile. */
81
+ type HintsEvents = {
82
+ open: (e: {
83
+ index: number;
84
+ hint: Hint;
85
+ }) => void | Promise<void>;
86
+ dismiss: (e: {
87
+ index: number;
88
+ hint: Hint;
89
+ }) => void | Promise<void>;
90
+ };
91
+ interface Hints {
92
+ /** Mounts markers (scans `[data-hint]` when no hints are configured). */
93
+ render(): Hints;
94
+ /**
95
+ * Adds a hint at runtime (renders the instance first when needed).
96
+ * A persisted dismissal for the same `id` is respected.
97
+ * Returns the index of the new hint.
98
+ */
99
+ add(input: HintInput): number;
100
+ /** Removes a hint by index or id; an open popover for it is closed. */
101
+ remove(ref: number | string): void;
102
+ /**
103
+ * Opens the hint's popover (calling it for the open hint closes it).
104
+ * `{ scroll: true }` brings an off-screen marker into view first — the
105
+ * popover of a marker clamped at the edge would otherwise open outside
106
+ * the viewport.
107
+ */
108
+ open(index: number, options?: HintOpenOptions): void;
109
+ close(): void;
110
+ /** Shows the marker; a dismissed hint is revived (its dismissal is cleared). */
111
+ show(index: number): void;
112
+ hide(index: number): void;
113
+ hideAll(): void;
114
+ /** Hides the hint permanently (persisted with `rememberDismissed`). */
115
+ dismiss(index: number): void;
116
+ refresh(): void;
117
+ destroy(): void;
118
+ readonly hints: ReadonlyArray<Hint>;
119
+ on<E extends keyof HintsEvents & string>(event: E, handler: HintsEvents[E]): () => void;
120
+ once<E extends keyof HintsEvents & string>(event: E, handler: HintsEvents[E]): () => void;
121
+ }
122
+ /** Collects hints declared in HTML via `data-hint*` attributes. */
123
+ declare function fromHintAttributes(root?: ParentNode): HintInput[];
124
+ /** Marker anchor point on the target rect; start/end are logical (RTL-aware). */
125
+ declare function markerAnchorPoint(rect: Rect, anchor: MarkerAnchor, rtl: boolean): {
126
+ x: number;
127
+ y: number;
128
+ };
129
+ declare function createHints(options?: HintsOptions): Hints;
130
+
131
+ export { type Hint, type HintInput, type Hints, type HintsEvents, type HintsOptions, type MarkerAnchor, createHints, fromHintAttributes, markerAnchorPoint };
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * TourKit v0.7.1 | MIT License
3
+ * Dependency-free product tours. Independently implemented; contains no
4
+ * Intro.js source code. Not affiliated with Intro.js.
5
+ */
6
+ "use strict";var TourKitHints=(()=>{var K=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _e(t))!Te.call(e,s)&&s!==n&&K(e,s,{get:()=>t[s],enumerable:!(r=Se(t,s))||r.enumerable});return e};var Ae=e=>Pe(K({},"__esModule",{value:!0}),e);var Ke={};ke(Ke,{createHints:()=>we,fromHintAttributes:()=>j,markerAnchorPoint:()=>J});var N=class{constructor(){this._listeners=new Map}on(t,n){let r=this._listeners.get(t);return r||(r=new Set,this._listeners.set(t,r)),r.add(n),()=>this.off(t,n)}once(t,n){let r=this.on(t,(async s=>{r(),await n(s)}));return r}off(t,n){this._listeners.get(t)?.delete(n)}async emit(t,n){let r=this._listeners.get(t);if(r)for(let s of[...r])try{await s(n)}catch(a){console.error(`[tourkit] "${String(t)}" handler failed`,a)}}removeAll(){this._listeners.clear()}};function D(e,t){if(!e)return null;if(typeof e=="function")return e();if(typeof e!="string")return e;let n=t??(typeof document<"u"?document:null);return n?n.querySelector(e):null}var Z="Got it";var ee={block:"center",behavior:"smooth",padding:24};function B(e){return{get:t=>e.get(t)??null,set:(t,n)=>{e.set(t,n)},remove:t=>{e.delete(t)}}}var je=B(new Map),He=B(new Map),Me=B(new Map);function te(e,t){return{get(n){try{return e().getItem(n)??t.get(n)}catch{return t.get(n)}},set(n,r){try{e().setItem(n,r),t.remove(n)}catch{t.set(n,r)}},remove(n){t.remove(n);try{e().removeItem(n)}catch{}}}}function ne(e="local"){return e==="local"?te(()=>window.localStorage,He):e==="session"?te(()=>window.sessionStorage,Me):e}function T(e,t={},n=[]){let r=document.createElement(e);if(t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text),t.attrs)for(let[s,a]of Object.entries(t.attrs))a===void 0||a===!1||r.setAttribute(s,a===!0?"":String(a));if(t.on)for(let[s,a]of Object.entries(t.on))a&&r.addEventListener(s,a);for(let s of n)s!=null&&r.append(s);return r}function ie(e,t,n,r){if(!n){e.textContent=t;return}e.innerHTML=r?r(t):t}var Re=16;function oe(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(Le()),Re)}function Le(){return typeof performance<"u"?performance.now():Date.now()}function se(e){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(e);return}clearTimeout(e)}function ae(e){if(typeof e.checkVisibility=="function")return!e.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0});let t=getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"}var re=0;function le(e){return re+=1,`tk-${e}-${re}`}function ce(e){let t=0,n=()=>{t||(t=oe(()=>{t=0,e()}))};window.addEventListener("scroll",n,{capture:!0,passive:!0}),window.addEventListener("resize",n,{passive:!0});let r;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(n),r.observe(document.documentElement)),{setElements(s){if(r){r.disconnect(),r.observe(document.documentElement);for(let a of s)a&&r.observe(a)}},stop(){window.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("resize",n),r?.disconnect(),t&&se(t)}}}function F(){let e=document.documentElement;return{x:0,y:0,width:e.clientWidth||window.innerWidth,height:e.clientHeight||window.innerHeight}}function U(e){let t=e.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}function q(e,t,n){return Math.min(Math.max(e,t),n<t?t:n)}var Oe={gap:14,viewportPadding:8,arrowInset:14,rtl:!1},Ce=/^(center|(top|bottom|left|right)(-(start|center|end))?)$/;function W(e){return typeof e=="string"&&Ce.test(e)}function Ie(e){if(e==="center")return{side:"center",align:void 0};let[t,n]=e.split("-");return{side:t,align:n}}function Ne(e,t,n){switch(e){case"top":return t.y-n.y;case"bottom":return n.y+n.height-(t.y+t.height);case"left":return t.x-n.x;case"right":return n.x+n.width-(t.x+t.width)}}function ue(e,t,n,r,s){let a=(e==="top"||e==="bottom"?n.height:n.width)+s.gap+s.viewportPadding;return Ne(e,t,r)>=a}function de(e,t,n){let r=(s,a,m)=>q(s+(a-m)/2,s+n.viewportPadding,s+a-m-n.viewportPadding);return{side:"center",align:"center",x:r(t.x,t.width,e.width),y:r(t.y,t.height,e.height),arrow:null}}function me(e,t,n,r,s,a){let m={...Oe,...a};if(!t||e==="center")return de(n,r,m);let{side:b,align:l}=Ie(e),u="center";if(b!=="center"&&ue(b,t,n,r,m))u=b;else{let k=s.filter(P=>P!==b).find(P=>ue(P,t,n,r,m));k&&(u=k)}if(u==="center")return de(n,r,m);let d=u==="top"||u==="bottom",h=u==="top"?t.y-m.gap-n.height:u==="bottom"?t.y+t.height+m.gap:u==="left"?t.x-m.gap-n.width:t.x+t.width+m.gap,g=d?t.x:t.y,x=d?t.width:t.height,w=d?n.width:n.height,E=d?r.x:r.y,A=d?r.width:r.height,y=l??"center";m.rtl&&d&&y!=="center"&&(y=y==="start"?"end":"start");let S=y==="start"?g:y==="end"?g+x-w:g+(x-w)/2;S=q(S,E+m.viewportPadding,E+A-w-m.viewportPadding);let H=g+x/2,O=q(H-S,m.arrowInset,w-m.arrowInset);return{side:u,align:y,x:d?S:h,y:d?h:S,arrow:O}}function De(e,t){let n=e.getBoundingClientRect(),r=F();return n.top>=r.y+t&&n.left>=r.x&&n.bottom<=r.y+r.height-t&&n.right<=r.x+r.width}function fe(e,t){if(t.block==="off"||typeof e.scrollIntoView!="function"||De(e,t.padding))return;let n=e.style,r=n?.scrollMargin??"";n&&t.padding>0&&(n.scrollMargin=`${t.padding}px`);try{e.scrollIntoView({block:t.block,inline:"nearest",behavior:t.behavior})}finally{n&&t.padding>0&&(n.scrollMargin=r)}}var pe='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Fe(e){return e.isConnected?e===document.activeElement?!0:typeof e.checkVisibility=="function"?e.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0}):e.offsetParent!==null||getComputedStyle(e).position==="fixed":!1}function he(e){let t=[],n=r=>{r instanceof HTMLElement&&r.matches(pe)&&t.push(r);for(let s of r.querySelectorAll("*"))s.matches(pe)&&t.push(s),s.shadowRoot&&n(s.shadowRoot)};return n(e),t.filter(Fe)}function qe(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e instanceof HTMLElement?e:null}var R=[];function ge(e,t){let n={};R.push(n);let r=s=>{if(s.key!=="Tab"||R[R.length-1]!==n)return;let a=he(e),m=t?.();if(m&&m!==e&&!e.contains(m)&&m.isConnected&&a.push(...he(m)),a.length===0){s.preventDefault(),e.focus();return}let b=qe(),l=b?a.indexOf(b):-1,u=l===-1?s.shiftKey?a[a.length-1]:a[0]:a[(l+(s.shiftKey?-1:1)+a.length)%a.length];s.preventDefault(),u.focus()};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0);let s=R.indexOf(n);s!==-1&&R.splice(s,1)}}var L=new Map;var ve="tk-hints-open";function be(e){if(typeof document>"u")return()=>{};let t=(L.get(e)??0)+1;L.set(e,t),t===1&&document.body.classList.add(e);let n=!1;return()=>{if(n)return;n=!0;let r=(L.get(e)??1)-1;if(r>0){L.set(e,r);return}L.delete(e),document.body.classList.remove(e)}}var G="data-hint",ye="data-hint-position",xe="data-hint-placement",$e="data-hint-id",Ve=/^(top|middle|bottom)-(start|center|end|left|right)$/;function ze(e){let t=e.getAttribute(ye);if(t!==null){if(Ve.test(t))return t.replace("-left","-start").replace("-right","-end");console.warn(`[tourkit] unknown ${ye}="${t}"; using the default anchor.`)}}function j(e){return e===void 0&&typeof document>"u"?(console.warn("[tourkit] fromHintAttributes() found no document; returning no hints."),[]):Array.from((e??document).querySelectorAll(`[${G}]`)).filter(t=>t.getAttribute(G)&&!ae(t)).map(t=>{let n=t.getAttribute(xe);return n!==null&&!W(n)&&console.warn(`[tourkit] unknown ${xe}="${n}"; using the default.`),{target:t,content:t.getAttribute(G),id:t.getAttribute($e)??void 0,markerPosition:ze(t),placement:W(n)?n:void 0}})}function J(e,t,n){let[r,s]=t.split("-"),a=s;return n&&a!=="center"&&(a=a==="start"?"end":"start"),{x:a==="start"?e.x:a==="end"?e.x+e.width:e.x+e.width/2,y:r==="top"?e.y:r==="bottom"?e.y+e.height:e.y+e.height/2}}function we(e={}){let t=new N,n=e.placementPrecedence??["bottom","top","right","left"],r=e.markerPosition??"middle-end",s=e.marker?.pulse??!0,a=e.popover?.button??!0,m=e.popover?.buttonLabel??e.labels?.hintDismiss??Z,b=e.scroll!==void 0,l=[],u=null,d=null,h=null,g=[],x=null,w=null,E=null,A=null,y=le("hint-popover"),S=()=>ne(e.rememberDismissed?.storage),H=()=>{if(!e.rememberDismissed)return new Set;try{let i=S().get(e.rememberDismissed.key);return new Set(i?JSON.parse(i):[])}catch{return new Set}},O=()=>{if(!e.rememberDismissed)return;let i=H();for(let o of l)o.dismissed?i.add(o.id):i.delete(o.id);S().set(e.rememberDismissed.key,JSON.stringify([...i]))},$=()=>u!==null&&getComputedStyle(u).direction==="rtl",k=i=>{let o=g[i],c=l[i];if(!o||!c)return;let f=D(c.target,e.root);if(!f||!f.isConnected){o.style.display="none";return}let p=U(f);if(p.width===0&&p.height===0){o.style.display="none";return}c.dismissed||(o.style.display="");let v=J(p,c.markerPosition,$());o.style.left=`${Math.round(v.x)}px`,o.style.top=`${Math.round(v.y)}px`},P=()=>{if(!d||h===null)return;let i=g[h];if(!i)return;let o=U(i);d.style.visibility="hidden";let c={width:d.offsetWidth,height:d.offsetHeight},f=me(l[h].placement,o,c,F(),n,{gap:10,rtl:$()});d.style.left=`${Math.round(f.x)}px`,d.style.top=`${Math.round(f.y)}px`,d.style.visibility=""},C=()=>{l.forEach((i,o)=>k(o)),P()},_=()=>{if(h===null)return;let i=g[h];i?.setAttribute("aria-expanded","false"),i?.removeAttribute("aria-controls"),h=null,E?.(),E=null,d?.remove(),d=null,A?.(),A=null,i?.focus({preventScroll:!0})},Q=(i,o)=>{let c=l[i],f=g[i];if(!c||!f||c.dismissed||!u)return;if(h===i){_();return}if(_(),o?.scroll??b){let v=D(c.target,e.root);v&&fe(v,{...ee,...e.scroll}),C()}h=i,f.setAttribute("aria-expanded","true"),f.setAttribute("aria-controls",y);let p=T("div",{className:"tk-hint-popover__content"});ie(p,c.content,e.allowHTML??!1,e.sanitize),d=T("div",{className:"tk-hint-popover",attrs:{role:"dialog","aria-label":c.content,id:y,tabindex:-1}},[p,a?T("button",{className:"tk-button tk-button--primary tk-hint-popover__button",text:m,attrs:{type:"button"},on:{click:()=>M.dismiss(i)}}):null]),u.append(d),P(),E=ge(d),(d.querySelector(".tk-hint-popover__button")??d).focus({preventScroll:!0}),e.hostClasses!==!1&&(A=be(ve)),t.emit("open",{index:i,hint:c})},I=(i,o)=>{l[i]&&(g[i]?.classList.toggle("tk-hint--hidden",!o),!o&&h===i&&_())},X=(i,o,c)=>({...i,id:o,markerPosition:i.markerPosition??r,placement:i.placement??e.placement??"bottom",dismissed:c.has(o)}),Ee=()=>{let i=new Set(l.map(f=>f.id)),o=l.length,c=String(o);for(;i.has(c);)o+=1,c=String(o);return c},Y=i=>T("button",{className:`tk-hint${i.dismissed?" tk-hint--hidden":""}${s?"":" tk-hint--static"}`,attrs:{type:"button","aria-label":i.content,"aria-expanded":"false","aria-haspopup":"dialog"},on:{click:o=>{o.stopPropagation(),Q(l.indexOf(i))}}},[s?T("span",{className:"tk-hint__pulse",attrs:{"aria-hidden":"true"}}):null]),V=()=>{g.forEach((i,o)=>i?.setAttribute("data-hint-index",String(o)))},z=()=>{x?.setElements(l.map(i=>D(i.target,e.root)))},M={render(){if(u||typeof document>"u")return M;let i=e.hints?.length?e.hints:j(e.root),o=H();l=i.map((p,v)=>X(p,p.id??String(v),o)),u=T("div",{className:"tk-root tk-root--visible tk-hints"}),e.theme&&(u.dataset.tkTheme=e.theme),e.zIndex!==void 0&&u.style.setProperty("--tk-z",String(e.zIndex)),g=l.map(p=>{let v=Y(p);return u.append(v),v}),V(),(e.container??document.body).append(u),x=ce(C),z(),C();let c=p=>{d&&!d.contains(p.target)&&_()},f=p=>{p.key==="Escape"&&!p.defaultPrevented&&_()};return document.addEventListener("click",c),document.addEventListener("keydown",f),w=()=>{document.removeEventListener("click",c),document.removeEventListener("keydown",f)},M},add(i){if(typeof document>"u")return-1;u||M.render();let o=X(i,i.id??Ee(),H());l.push(o);let c=Y(o);g.push(c),u.append(c),V(),z();let f=l.length-1;return k(f),f},remove(i){let o=typeof i=="number"?i:l.findIndex(p=>p.id===i);if(!l[o])return;h===o&&_(),l.splice(o,1);let[f]=g.splice(o,1);f?.remove(),h!==null&&o<h&&(h-=1),V(),z()},open:Q,close:_,show(i){let o=l[i];o&&(o.dismissed&&(o.dismissed=!1,O()),I(i,!0),k(i))},hide:i=>I(i,!1),hideAll(){l.forEach((i,o)=>I(o,!1))},dismiss(i){let o=l[i];!o||o.dismissed||(o.dismissed=!0,I(i,!1),O(),t.emit("dismiss",{index:i,hint:o}))},refresh:C,destroy(){E?.(),E=null,_(),x?.stop(),x=null,w?.(),w=null,u?.remove(),u=null,g=[],l=[],h=null,t.removeAll()},get hints(){return l},on:(i,o)=>t.on(i,o),once:(i,o)=>t.once(i,o)};return M}return Ae(Ke);})();
7
+ //# sourceMappingURL=hints.global.js.map
package/dist/hints.js ADDED
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * TourKit v0.7.1 | MIT License
3
+ * Dependency-free product tours. Independently implemented; contains no
4
+ * Intro.js source code. Not affiliated with Intro.js.
5
+ */
6
+ var N=class{constructor(){this._listeners=new Map}on(t,n){let r=this._listeners.get(t);return r||(r=new Set,this._listeners.set(t,r)),r.add(n),()=>this.off(t,n)}once(t,n){let r=this.on(t,(async s=>{r(),await n(s)}));return r}off(t,n){this._listeners.get(t)?.delete(n)}async emit(t,n){let r=this._listeners.get(t);if(r)for(let s of[...r])try{await s(n)}catch(a){console.error(`[tourkit] "${String(t)}" handler failed`,a)}}removeAll(){this._listeners.clear()}};function D(e,t){if(!e)return null;if(typeof e=="function")return e();if(typeof e!="string")return e;let n=t??(typeof document<"u"?document:null);return n?n.querySelector(e):null}var Q="Got it";var X={block:"center",behavior:"smooth",padding:24};function K(e){return{get:t=>e.get(t)??null,set:(t,n)=>{e.set(t,n)},remove:t=>{e.delete(t)}}}var qe=K(new Map),we=K(new Map),Ee=K(new Map);function Y(e,t){return{get(n){try{return e().getItem(n)??t.get(n)}catch{return t.get(n)}},set(n,r){try{e().setItem(n,r),t.remove(n)}catch{t.set(n,r)}},remove(n){t.remove(n);try{e().removeItem(n)}catch{}}}}function Z(e="local"){return e==="local"?Y(()=>window.localStorage,we):e==="session"?Y(()=>window.sessionStorage,Ee):e}function T(e,t={},n=[]){let r=document.createElement(e);if(t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text),t.attrs)for(let[s,a]of Object.entries(t.attrs))a===void 0||a===!1||r.setAttribute(s,a===!0?"":String(a));if(t.on)for(let[s,a]of Object.entries(t.on))a&&r.addEventListener(s,a);for(let s of n)s!=null&&r.append(s);return r}function te(e,t,n,r){if(!n){e.textContent=t;return}e.innerHTML=r?r(t):t}var Se=16;function ne(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(_e()),Se)}function _e(){return typeof performance<"u"?performance.now():Date.now()}function re(e){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(e);return}clearTimeout(e)}function ie(e){if(typeof e.checkVisibility=="function")return!e.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0});let t=getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"}var ee=0;function oe(e){return ee+=1,`tk-${e}-${ee}`}function se(e){let t=0,n=()=>{t||(t=ne(()=>{t=0,e()}))};window.addEventListener("scroll",n,{capture:!0,passive:!0}),window.addEventListener("resize",n,{passive:!0});let r;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(n),r.observe(document.documentElement)),{setElements(s){if(r){r.disconnect(),r.observe(document.documentElement);for(let a of s)a&&r.observe(a)}},stop(){window.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("resize",n),r?.disconnect(),t&&re(t)}}}function F(){let e=document.documentElement;return{x:0,y:0,width:e.clientWidth||window.innerWidth,height:e.clientHeight||window.innerHeight}}function B(e){let t=e.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}function q(e,t,n){return Math.min(Math.max(e,t),n<t?t:n)}var Te={gap:14,viewportPadding:8,arrowInset:14,rtl:!1},ke=/^(center|(top|bottom|left|right)(-(start|center|end))?)$/;function U(e){return typeof e=="string"&&ke.test(e)}function Pe(e){if(e==="center")return{side:"center",align:void 0};let[t,n]=e.split("-");return{side:t,align:n}}function Ae(e,t,n){switch(e){case"top":return t.y-n.y;case"bottom":return n.y+n.height-(t.y+t.height);case"left":return t.x-n.x;case"right":return n.x+n.width-(t.x+t.width)}}function ae(e,t,n,r,s){let a=(e==="top"||e==="bottom"?n.height:n.width)+s.gap+s.viewportPadding;return Ae(e,t,r)>=a}function le(e,t,n){let r=(s,a,m)=>q(s+(a-m)/2,s+n.viewportPadding,s+a-m-n.viewportPadding);return{side:"center",align:"center",x:r(t.x,t.width,e.width),y:r(t.y,t.height,e.height),arrow:null}}function ce(e,t,n,r,s,a){let m={...Te,...a};if(!t||e==="center")return le(n,r,m);let{side:b,align:l}=Pe(e),u="center";if(b!=="center"&&ae(b,t,n,r,m))u=b;else{let k=s.filter(P=>P!==b).find(P=>ae(P,t,n,r,m));k&&(u=k)}if(u==="center")return le(n,r,m);let d=u==="top"||u==="bottom",h=u==="top"?t.y-m.gap-n.height:u==="bottom"?t.y+t.height+m.gap:u==="left"?t.x-m.gap-n.width:t.x+t.width+m.gap,g=d?t.x:t.y,x=d?t.width:t.height,w=d?n.width:n.height,E=d?r.x:r.y,A=d?r.width:r.height,y=l??"center";m.rtl&&d&&y!=="center"&&(y=y==="start"?"end":"start");let S=y==="start"?g:y==="end"?g+x-w:g+(x-w)/2;S=q(S,E+m.viewportPadding,E+A-w-m.viewportPadding);let H=g+x/2,O=q(H-S,m.arrowInset,w-m.arrowInset);return{side:u,align:y,x:d?S:h,y:d?h:S,arrow:O}}function He(e,t){let n=e.getBoundingClientRect(),r=F();return n.top>=r.y+t&&n.left>=r.x&&n.bottom<=r.y+r.height-t&&n.right<=r.x+r.width}function ue(e,t){if(t.block==="off"||typeof e.scrollIntoView!="function"||He(e,t.padding))return;let n=e.style,r=n?.scrollMargin??"";n&&t.padding>0&&(n.scrollMargin=`${t.padding}px`);try{e.scrollIntoView({block:t.block,inline:"nearest",behavior:t.behavior})}finally{n&&t.padding>0&&(n.scrollMargin=r)}}var de='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Me(e){return e.isConnected?e===document.activeElement?!0:typeof e.checkVisibility=="function"?e.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0}):e.offsetParent!==null||getComputedStyle(e).position==="fixed":!1}function me(e){let t=[],n=r=>{r instanceof HTMLElement&&r.matches(de)&&t.push(r);for(let s of r.querySelectorAll("*"))s.matches(de)&&t.push(s),s.shadowRoot&&n(s.shadowRoot)};return n(e),t.filter(Me)}function Re(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e instanceof HTMLElement?e:null}var R=[];function fe(e,t){let n={};R.push(n);let r=s=>{if(s.key!=="Tab"||R[R.length-1]!==n)return;let a=me(e),m=t?.();if(m&&m!==e&&!e.contains(m)&&m.isConnected&&a.push(...me(m)),a.length===0){s.preventDefault(),e.focus();return}let b=Re(),l=b?a.indexOf(b):-1,u=l===-1?s.shiftKey?a[a.length-1]:a[0]:a[(l+(s.shiftKey?-1:1)+a.length)%a.length];s.preventDefault(),u.focus()};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0);let s=R.indexOf(n);s!==-1&&R.splice(s,1)}}var L=new Map;var pe="tk-hints-open";function he(e){if(typeof document>"u")return()=>{};let t=(L.get(e)??0)+1;L.set(e,t),t===1&&document.body.classList.add(e);let n=!1;return()=>{if(n)return;n=!0;let r=(L.get(e)??1)-1;if(r>0){L.set(e,r);return}L.delete(e),document.body.classList.remove(e)}}var W="data-hint",ge="data-hint-position",ve="data-hint-placement",Le="data-hint-id",Oe=/^(top|middle|bottom)-(start|center|end|left|right)$/;function Ce(e){let t=e.getAttribute(ge);if(t!==null){if(Oe.test(t))return t.replace("-left","-start").replace("-right","-end");console.warn(`[tourkit] unknown ${ge}="${t}"; using the default anchor.`)}}function be(e){return e===void 0&&typeof document>"u"?(console.warn("[tourkit] fromHintAttributes() found no document; returning no hints."),[]):Array.from((e??document).querySelectorAll(`[${W}]`)).filter(t=>t.getAttribute(W)&&!ie(t)).map(t=>{let n=t.getAttribute(ve);return n!==null&&!U(n)&&console.warn(`[tourkit] unknown ${ve}="${n}"; using the default.`),{target:t,content:t.getAttribute(W),id:t.getAttribute(Le)??void 0,markerPosition:Ce(t),placement:U(n)?n:void 0}})}function ye(e,t,n){let[r,s]=t.split("-"),a=s;return n&&a!=="center"&&(a=a==="start"?"end":"start"),{x:a==="start"?e.x:a==="end"?e.x+e.width:e.x+e.width/2,y:r==="top"?e.y:r==="bottom"?e.y+e.height:e.y+e.height/2}}function Ie(e={}){let t=new N,n=e.placementPrecedence??["bottom","top","right","left"],r=e.markerPosition??"middle-end",s=e.marker?.pulse??!0,a=e.popover?.button??!0,m=e.popover?.buttonLabel??e.labels?.hintDismiss??Q,b=e.scroll!==void 0,l=[],u=null,d=null,h=null,g=[],x=null,w=null,E=null,A=null,y=oe("hint-popover"),S=()=>Z(e.rememberDismissed?.storage),H=()=>{if(!e.rememberDismissed)return new Set;try{let i=S().get(e.rememberDismissed.key);return new Set(i?JSON.parse(i):[])}catch{return new Set}},O=()=>{if(!e.rememberDismissed)return;let i=H();for(let o of l)o.dismissed?i.add(o.id):i.delete(o.id);S().set(e.rememberDismissed.key,JSON.stringify([...i]))},$=()=>u!==null&&getComputedStyle(u).direction==="rtl",k=i=>{let o=g[i],c=l[i];if(!o||!c)return;let f=D(c.target,e.root);if(!f||!f.isConnected){o.style.display="none";return}let p=B(f);if(p.width===0&&p.height===0){o.style.display="none";return}c.dismissed||(o.style.display="");let v=ye(p,c.markerPosition,$());o.style.left=`${Math.round(v.x)}px`,o.style.top=`${Math.round(v.y)}px`},P=()=>{if(!d||h===null)return;let i=g[h];if(!i)return;let o=B(i);d.style.visibility="hidden";let c={width:d.offsetWidth,height:d.offsetHeight},f=ce(l[h].placement,o,c,F(),n,{gap:10,rtl:$()});d.style.left=`${Math.round(f.x)}px`,d.style.top=`${Math.round(f.y)}px`,d.style.visibility=""},C=()=>{l.forEach((i,o)=>k(o)),P()},_=()=>{if(h===null)return;let i=g[h];i?.setAttribute("aria-expanded","false"),i?.removeAttribute("aria-controls"),h=null,E?.(),E=null,d?.remove(),d=null,A?.(),A=null,i?.focus({preventScroll:!0})},G=(i,o)=>{let c=l[i],f=g[i];if(!c||!f||c.dismissed||!u)return;if(h===i){_();return}if(_(),o?.scroll??b){let v=D(c.target,e.root);v&&ue(v,{...X,...e.scroll}),C()}h=i,f.setAttribute("aria-expanded","true"),f.setAttribute("aria-controls",y);let p=T("div",{className:"tk-hint-popover__content"});te(p,c.content,e.allowHTML??!1,e.sanitize),d=T("div",{className:"tk-hint-popover",attrs:{role:"dialog","aria-label":c.content,id:y,tabindex:-1}},[p,a?T("button",{className:"tk-button tk-button--primary tk-hint-popover__button",text:m,attrs:{type:"button"},on:{click:()=>M.dismiss(i)}}):null]),u.append(d),P(),E=fe(d),(d.querySelector(".tk-hint-popover__button")??d).focus({preventScroll:!0}),e.hostClasses!==!1&&(A=he(pe)),t.emit("open",{index:i,hint:c})},I=(i,o)=>{l[i]&&(g[i]?.classList.toggle("tk-hint--hidden",!o),!o&&h===i&&_())},j=(i,o,c)=>({...i,id:o,markerPosition:i.markerPosition??r,placement:i.placement??e.placement??"bottom",dismissed:c.has(o)}),xe=()=>{let i=new Set(l.map(f=>f.id)),o=l.length,c=String(o);for(;i.has(c);)o+=1,c=String(o);return c},J=i=>T("button",{className:`tk-hint${i.dismissed?" tk-hint--hidden":""}${s?"":" tk-hint--static"}`,attrs:{type:"button","aria-label":i.content,"aria-expanded":"false","aria-haspopup":"dialog"},on:{click:o=>{o.stopPropagation(),G(l.indexOf(i))}}},[s?T("span",{className:"tk-hint__pulse",attrs:{"aria-hidden":"true"}}):null]),V=()=>{g.forEach((i,o)=>i?.setAttribute("data-hint-index",String(o)))},z=()=>{x?.setElements(l.map(i=>D(i.target,e.root)))},M={render(){if(u||typeof document>"u")return M;let i=e.hints?.length?e.hints:be(e.root),o=H();l=i.map((p,v)=>j(p,p.id??String(v),o)),u=T("div",{className:"tk-root tk-root--visible tk-hints"}),e.theme&&(u.dataset.tkTheme=e.theme),e.zIndex!==void 0&&u.style.setProperty("--tk-z",String(e.zIndex)),g=l.map(p=>{let v=J(p);return u.append(v),v}),V(),(e.container??document.body).append(u),x=se(C),z(),C();let c=p=>{d&&!d.contains(p.target)&&_()},f=p=>{p.key==="Escape"&&!p.defaultPrevented&&_()};return document.addEventListener("click",c),document.addEventListener("keydown",f),w=()=>{document.removeEventListener("click",c),document.removeEventListener("keydown",f)},M},add(i){if(typeof document>"u")return-1;u||M.render();let o=j(i,i.id??xe(),H());l.push(o);let c=J(o);g.push(c),u.append(c),V(),z();let f=l.length-1;return k(f),f},remove(i){let o=typeof i=="number"?i:l.findIndex(p=>p.id===i);if(!l[o])return;h===o&&_(),l.splice(o,1);let[f]=g.splice(o,1);f?.remove(),h!==null&&o<h&&(h-=1),V(),z()},open:G,close:_,show(i){let o=l[i];o&&(o.dismissed&&(o.dismissed=!1,O()),I(i,!0),k(i))},hide:i=>I(i,!1),hideAll(){l.forEach((i,o)=>I(o,!1))},dismiss(i){let o=l[i];!o||o.dismissed||(o.dismissed=!0,I(i,!1),O(),t.emit("dismiss",{index:i,hint:o}))},refresh:C,destroy(){E?.(),E=null,_(),x?.stop(),x=null,w?.(),w=null,u?.remove(),u=null,g=[],l=[],h=null,t.removeAll()},get hints(){return l},on:(i,o)=>t.on(i,o),once:(i,o)=>t.once(i,o)};return M}export{Ie as createHints,be as fromHintAttributes,ye as markerAnchorPoint};
7
+ //# sourceMappingURL=hints.js.map
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * TourKit v0.7.1 | MIT License
3
+ * Dependency-free product tours. Independently implemented; contains no
4
+ * Intro.js source code. Not affiliated with Intro.js.
5
+ */
6
+ "use strict";var nt=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var zt=(n,t)=>{for(var e in t)nt(n,e,{get:t[e],enumerable:!0})},Wt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Dt(t))!Ft.call(n,i)&&i!==e&&nt(n,i,{get:()=>t[i],enumerable:!(o=Nt(t,i))||o.enumerable});return n};var Bt=n=>Wt(nt({},"__esModule",{value:!0}),n);var me={};zt(me,{DEFAULT_DATA_ATTRIBUTE:()=>W,Emitter:()=>O,TourEngine:()=>A,autoUpdate:()=>yt,bindTriggers:()=>Mt,createTour:()=>tt,defaultLabels:()=>ot,defaultPlacementConfig:()=>ct,fromDataAttributes:()=>M,getDefaultOptions:()=>S,getPersistedProgress:()=>dt,highlight:()=>Ht,isPlacement:()=>Z,memoryStorage:()=>gt,normalizeSteps:()=>B,parsePlacement:()=>ut,resolveDataAttribute:()=>q,resolvePlacement:()=>J,resolveStorage:()=>R,resolveTarget:()=>w,version:()=>fe});module.exports=Bt(me);var O=class{constructor(){this._listeners=new Map}on(t,e){let o=this._listeners.get(t);return o||(o=new Set,this._listeners.set(t,o)),o.add(e),()=>this.off(t,e)}once(t,e){let o=this.on(t,(async i=>{o(),await e(i)}));return o}off(t,e){this._listeners.get(t)?.delete(e)}async emit(t,e){let o=this._listeners.get(t);if(o)for(let i of[...o])try{await i(e)}catch(r){console.error(`[tourkit] "${String(t)}" handler failed`,r)}}removeAll(){this._listeners.clear()}};function w(n,t){if(!n)return null;if(typeof n=="function")return n();if(typeof n!="string")return n;let e=t??(typeof document<"u"?document:null);return e?e.querySelector(n):null}async function ht(n,t,e){try{return await t()}catch(o){return console.error(`[tourkit] step ${n} failed`,o),e}}var A=class{constructor(t,e=()=>{}){this._delegate=t;this._getScope=e;this.events=new O;this._state="idle";this._steps=[];this._queue=Promise.resolve()}get state(){return this._state}get index(){return this._index}get steps(){return this._steps}get isActive(){return this._state==="active"}setSteps(t){this._steps=t}_enqueue(t){let e=this._queue.then(t,t);return this._queue=e.catch(()=>{}),e}start(t,e=0){return this._enqueue(async()=>{if(this._state!=="idle"||t.length===0)return!1;this._steps=t,await this.events.emit("start",{steps:this._steps}),await this._delegate.mount(),this._state="active";let o=Math.min(Math.max(e,0),t.length-1);return await this._goTo(o)?!0:(await this._exit(!0),!1)})}next(){return this._enqueue(async()=>{if(!(this._state!=="active"||this._index===void 0)){if(this._index>=this._steps.length-1){await this._complete("finished");return}await this._goTo(this._index+1)}})}back(){return this._enqueue(async()=>{this._state!=="active"||this._index===void 0||this._index<=0||await this._goTo(this._index-1)})}goTo(t){return this._enqueue(async()=>{this._state==="active"&&(t<0||t>=this._steps.length||t===this._index||await this._goTo(t))})}skip(){return this._enqueue(async()=>this._state!=="active"?!1:(await this._complete("skipped"),this._state==="idle"))}complete(){return this._enqueue(async()=>this._state!=="active"?!1:(await this._complete("finished"),this._state==="idle"))}exit(t=!1){return this._enqueue(()=>this._exit(t))}reshow(){return this._enqueue(async()=>{if(this._state!=="active"||this._index===void 0)return;let t=Math.min(this._index,this._steps.length-1),e=this._steps[t];if(!e)return;this._index=t;let o=w(e.target,this._getScope());await this._delegate.showStep({index:t,step:e,target:o},"forward")})}forceIdle(){this._state="idle",this._index=void 0,this._queue=Promise.resolve()}async _complete(t){await this._requestExit()&&(await this.events.emit("complete",{reason:t}),await this._teardown())}async _goTo(t){let e=this._steps[t];if(!e)return!1;let o=this._index,i=o===void 0||t>=o?"forward":"backward",r=!1;if(await this.events.emit("beforeStepChange",{from:o,to:t,direction:i,step:e,cancel:()=>{r=!0}}),r)return!1;let a={index:t,step:e,target:w(e.target,this._getScope())};if(e.onBeforeShow){let s=e.onBeforeShow;if(await ht("onBeforeShow",()=>s(a),void 0)===!1)return!1}if(this._index=t,await this._delegate.showStep(a,i),e.onShown){let s=e.onShown;await ht("onShown",()=>s(a),void 0)}return await this.events.emit("stepChange",a),!0}async _exit(t){return this._state==="idle"||!t&&!await this._requestExit()?!1:(await this._teardown(),!0)}async _requestExit(){let t=!1;return await this.events.emit("beforeExit",{cancel:()=>{t=!0}}),!t}async _teardown(){await this._delegate.unmount(),this._index=void 0,this._state="idle",await this.events.emit("exit",{})}};var qt="Got it",ot={next:"Next",back:"Back",done:"Done",skip:"Close",stepOf:"{step} of {total}",stepAnnouncement:"Step {step} of {total}",dontShowAgain:"Don't show this again",hintDismiss:qt},Vt={block:"center",behavior:"smooth",padding:24};function S(){return{steps:[],labels:{...ot},buttons:{next:!0,back:!0,skip:!0,doneOnLast:!0,hideBackOnFirst:!1,hideNextOnLast:!1},bullets:!0,progress:!1,stepNumbers:!1,placement:"bottom",placementPrecedence:["bottom","top","right","left"],overlay:{opacity:.5,color:"#05070a",padding:8,radius:8,clickToExit:!0,transitionMs:300},keyboard:!0,exitOnEsc:!0,disableInteraction:!1,hostClasses:!0,lockScroll:!1,modal:!1,waitForTarget:{...ft},scroll:{...Vt},allowHTML:!1}}var ft={timeoutMs:1e4,onTimeout:"float"};function rt(n,t){return t===!1?!1:t===void 0?n===!1?!1:{...n}:{...n===!1?ft:n,...t}}function it(n,t){return{...n,...t,labels:{...n.labels,...t.labels},buttons:{...n.buttons,...t.buttons},overlay:{...n.overlay,...t.overlay},scroll:{...n.scroll,...t.scroll},waitForTarget:rt(n.waitForTarget,t.waitForTarget)}}function k(n,t,e){return n.replace("{step}",String(t)).replace("{total}",String(e))}function st(n){return{get:t=>n.get(t)??null,set:(t,e)=>{n.set(t,e)},remove:t=>{n.delete(t)}}}var gt=st(new Map),Kt=st(new Map),Ut=st(new Map);function mt(n,t){return{get(e){try{return n().getItem(e)??t.get(e)}catch{return t.get(e)}},set(e,o){try{n().setItem(e,o),t.remove(e)}catch{t.set(e,o)}},remove(e){t.remove(e);try{n().removeItem(e)}catch{}}}}function R(n="local"){return n==="local"?mt(()=>window.localStorage,Kt):n==="session"?mt(()=>window.sessionStorage,Ut):n}function m(n,t={},e=[]){let o=document.createElement(n);if(t.className&&(o.className=t.className),t.text!==void 0&&(o.textContent=t.text),t.attrs)for(let[i,r]of Object.entries(t.attrs))r===void 0||r===!1||o.setAttribute(i,r===!0?"":String(r));if(t.on)for(let[i,r]of Object.entries(t.on))r&&o.addEventListener(i,r);for(let i of e)i!=null&&o.append(i);return o}var Gt="http://www.w3.org/2000/svg";function K(n,t={}){let e=document.createElementNS(Gt,n);for(let[o,i]of Object.entries(t))e.setAttribute(o,i);return e}function at(n,t,e,o){if(!e){n.textContent=t;return}n.innerHTML=o?o(t):t}function U(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var jt=16;function x(n){return typeof requestAnimationFrame=="function"?requestAnimationFrame(n):setTimeout(()=>n(Zt()),jt)}function Zt(){return typeof performance<"u"?performance.now():Date.now()}function C(n){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(n);return}clearTimeout(n)}function vt(n){if(typeof n.checkVisibility=="function")return!n.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0});let t=getComputedStyle(n);return t.display==="none"||t.visibility==="hidden"}var _t=0;function lt(n){return _t+=1,`tk-${n}-${_t}`}function H(n){let t=0,e=()=>{t||(t=x(()=>{t=0,n()}))};window.addEventListener("scroll",e,{capture:!0,passive:!0}),window.addEventListener("resize",e,{passive:!0});let o;return typeof ResizeObserver<"u"&&(o=new ResizeObserver(e),o.observe(document.documentElement)),{setElements(i){if(o){o.disconnect(),o.observe(document.documentElement);for(let r of i)r&&o.observe(r)}},stop(){window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e),o?.disconnect(),t&&C(t)}}}function yt(n,t){let e=H(t);return e.setElements(n),()=>e.stop()}function b(){let n=document.documentElement;return{x:0,y:0,width:n.clientWidth||window.innerWidth,height:n.clientHeight||window.innerHeight}}function $(n){let t=n.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}function N(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function G(n){return{x:n.x+n.width/2,y:n.y+n.height/2,width:0,height:0}}function T(n,t){return n===null||t===null?n===t:n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height}function P(n,t,e){return n+(t-n)*e}function bt(n,t,e){return{x:P(n.x,t.x,e),y:P(n.y,t.y,e),width:P(n.width,t.width,e),height:P(n.height,t.height,e)}}function L(n,t,e){return Math.min(Math.max(n,t),e<t?t:e)}function xt(n){return n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2}function Jt(n,t){let e=n.getBoundingClientRect(),o=b();return e.top>=o.y+t&&e.left>=o.x&&e.bottom<=o.y+o.height-t&&e.right<=o.x+o.width}function D(n,t){if(t.block==="off"||typeof n.scrollIntoView!="function"||Jt(n,t.padding))return;let e=n.style,o=e?.scrollMargin??"";e&&t.padding>0&&(e.scrollMargin=`${t.padding}px`);try{n.scrollIntoView({block:t.block,inline:"nearest",behavior:t.behavior})}finally{e&&t.padding>0&&(e.scrollMargin=o)}}var wt='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function kt(){let n=document.activeElement;return()=>{n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}}function Xt(n){return n.isConnected?n===document.activeElement?!0:typeof n.checkVisibility=="function"?n.checkVisibility({checkVisibilityCSS:!0,visibilityProperty:!0}):n.offsetParent!==null||getComputedStyle(n).position==="fixed":!1}function St(n){let t=[],e=o=>{o instanceof HTMLElement&&o.matches(wt)&&t.push(o);for(let i of o.querySelectorAll("*"))i.matches(wt)&&t.push(i),i.shadowRoot&&e(i.shadowRoot)};return e(n),t.filter(Xt)}function Yt(){let n=document.activeElement;for(;n?.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n instanceof HTMLElement?n:null}var F=[];function Tt(n,t){let e={};F.push(e);let o=i=>{if(i.key!=="Tab"||F[F.length-1]!==e)return;let r=St(n),a=t?.();if(a&&a!==n&&!n.contains(a)&&a.isConnected&&r.push(...St(a)),r.length===0){i.preventDefault(),n.focus();return}let s=Yt(),u=s?r.indexOf(s):-1,d=u===-1?i.shiftKey?r[r.length-1]:r[0]:r[(u+(i.shiftKey?-1:1)+r.length)%r.length];i.preventDefault(),d.focus()};return document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("keydown",o,!0);let i=F.indexOf(e);i!==-1&&F.splice(i,1)}}var z=new Map,Et="tk-tour-active",Ot="tk-highlight-active";function j(n){if(typeof document>"u")return()=>{};let t=(z.get(n)??0)+1;z.set(n,t),t===1&&document.body.classList.add(n);let e=!1;return()=>{if(e)return;e=!0;let o=(z.get(n)??1)-1;if(o>0){z.set(n,o);return}z.delete(n),document.body.classList.remove(n)}}var I=class{constructor(t,e,o){this._current=null;this._stage=null;this._extras=[];this._radius=0;this._currentRadius=0;this._frame=0;this._paintedViewport=null;this._options=t,this.el=K("svg",{class:`tk-overlay${o?` ${o}`:""}`,"aria-hidden":"true"}),this._path=K("path",{class:"tk-overlay__path","fill-rule":"evenodd"}),this._path.addEventListener("click",()=>{this._options.clickToExit&&e.onBackdropClick()}),this._ring=K("path",{class:"tk-overlay__ring"}),this.el.append(this._path,this._ring),this._applyOptionStyles()}setOptions(t){this._options=t,this._applyOptionStyles()}_applyOptionStyles(){let t=this._options,e=S().overlay;t.color!==e.color?this.el.style.setProperty("--tk-overlay-color",t.color):this.el.style.removeProperty("--tk-overlay-color"),t.opacity!==e.opacity?this.el.style.setProperty("--tk-overlay-opacity",String(t.opacity)):this.el.style.removeProperty("--tk-overlay-opacity"),this._path.style.cursor=t.clickToExit?"pointer":""}setStage(t,e,o=[]){let i=t??G(b()),r=t?this._radiusFor(t):0,a=this._current??G(b()),s=this._current?this._currentRadius:0;if(this._stage=i,this._radius=r,this._extras=o,this._cancelAnimation(),!e||!this._current||this._options.transitionMs<=0||U()){this._paint(i,r);return}let u=performance.now(),d=this._options.transitionMs,c=h=>{let p=L((h-u)/d,0,1),l=xt(p);this._paint(bt(a,i,l),P(s,r,l)),p<1?this._frame=x(c):this._frame=0};this._frame=x(c)}refresh(t,e=[]){let o=t??G(b()),i=t?this._radiusFor(t):0,r=Qt(this._extras,e)&&T(this._paintedViewport,b());if(this._frame!==0){if(r&&T(this._stage,o)&&this._radius===i)return;this._cancelAnimation()}else if(r&&T(this._current,o)&&this._currentRadius===i)return;this._stage=o,this._radius=i,this._extras=e,this._paint(o,i)}destroy(){this._cancelAnimation(),this.el.remove()}_radiusFor(t){return Math.min(this._options.radius,t.width/2,t.height/2)}_cancelAnimation(){this._frame&&(C(this._frame),this._frame=0)}_paint(t,e){this._current=t,this._currentRadius=e;let o=b();this._paintedViewport=o;let i=`M0 0H${o.width}V${o.height}H0Z`,r=At(t,e),a=this._extras.map(u=>At(u,this._radiusFor(u))).join(" ");this._path.setAttribute("d",`${i} ${r}${a?` ${a}`:""}`);let s=[t.width>0&&t.height>0?r:"",a].filter(Boolean).join(" ");this._ring.setAttribute("d",s)}};function Qt(n,t){return n.length===t.length&&n.every((e,o)=>T(e,t[o]??null))}function At(n,t){let e=Math.max(0,Math.min(t,n.width/2,n.height/2)),{x:o,y:i,width:r,height:a}=n;return r<=0||a<=0?`M${o} ${i}h0v0h0Z`:`M${o+e} ${i}h${r-2*e}a${e} ${e} 0 0 1 ${e} ${e}v${a-2*e}a${e} ${e} 0 0 1 ${-e} ${e}h${-(r-2*e)}a${e} ${e} 0 0 1 ${-e} ${-e}v${-(a-2*e)}a${e} ${e} 0 0 1 ${e} ${-e}Z`}function Rt(){let n=document.documentElement,t=window.innerWidth-n.clientWidth,e=n.style.overflow,o=n.style.paddingRight;if(t>0){let i=parseFloat(getComputedStyle(n).paddingRight)||0;n.style.paddingRight=`${i+t}px`}return n.style.overflow="hidden",()=>{n.style.overflow=e,n.style.paddingRight=o}}var ct={gap:14,viewportPadding:8,arrowInset:14,rtl:!1},te=/^(center|(top|bottom|left|right)(-(start|center|end))?)$/;function Z(n){return typeof n=="string"&&te.test(n)}function ut(n){if(n==="center")return{side:"center",align:void 0};let[t,e]=n.split("-");return{side:t,align:e}}function ee(n,t,e){switch(n){case"top":return t.y-e.y;case"bottom":return e.y+e.height-(t.y+t.height);case"left":return t.x-e.x;case"right":return e.x+e.width-(t.x+t.width)}}function Ct(n,t,e,o,i){let r=(n==="top"||n==="bottom"?e.height:e.width)+i.gap+i.viewportPadding;return ee(n,t,o)>=r}function Pt(n,t,e){let o=(i,r,a)=>L(i+(r-a)/2,i+e.viewportPadding,i+r-a-e.viewportPadding);return{side:"center",align:"center",x:o(t.x,t.width,n.width),y:o(t.y,t.height,n.height),arrow:null}}function J(n,t,e,o,i,r){let a={...ct,...r};if(!t||n==="center")return Pt(e,o,a);let{side:s,align:u}=ut(n),d="center";if(s!=="center"&&Ct(s,t,e,o,a))d=s;else{let pt=i.filter(et=>et!==s).find(et=>Ct(et,t,e,o,a));pt&&(d=pt)}if(d==="center")return Pt(e,o,a);let c=d==="top"||d==="bottom",h=d==="top"?t.y-a.gap-e.height:d==="bottom"?t.y+t.height+a.gap:d==="left"?t.x-a.gap-e.width:t.x+t.width+a.gap,p=c?t.x:t.y,l=c?t.width:t.height,_=c?e.width:e.height,v=c?o.x:o.y,y=c?o.width:o.height,f=u??"center";a.rtl&&c&&f!=="center"&&(f=f==="start"?"end":"start");let g=f==="start"?p:f==="end"?p+l-_:p+(l-_)/2;g=L(g,v+a.viewportPadding,v+y-_-a.viewportPadding);let E=p+l/2,$t=L(E-g,a.arrowInset,_-a.arrowInset);return{side:d,align:f,x:c?g:h,y:c?h:g,arrow:$t}}var Lt=7,ne=["top","bottom","left","right","center"],X=class{constructor(t,e){this._options=t;this._callbacks=e;this._titleId=lt("title");this._contentId=lt("content");this._ctx=null;this._placement=null;this._contentCleanup=null;this._rtl=!1;this._arrow=m("div",{className:"tk-tooltip__arrow",attrs:{"aria-hidden":"true"}}),this._body=m("div",{className:"tk-tooltip__body"}),this.el=m("div",{className:"tk-tooltip",attrs:{role:"dialog",tabindex:-1,"aria-describedby":this._contentId}},[this._arrow,this._body]),this._releaseTrap=Tt(this.el,()=>{let o=this._ctx;return!o?.target||this._options.modal||(o.step.disableInteraction??this._options.disableInteraction)?null:o.target})}get placement(){return this._placement}setOptions(t){this._options=t}syncContext(t){this._ctx=t}render(t,e){this._runContentCleanup(),this._ctx=t;let{step:o,index:i}=t,r=this._options;this._rtl=this.el.isConnected&&getComputedStyle(this.el).direction==="rtl",this._placement=null,this.el.className=["tk-tooltip",r.classes?.tooltip??"",o.classes?.tooltip??""].filter(Boolean).join(" "),this._body.replaceChildren();let a=m("h2",{className:"tk-tooltip__title",attrs:{id:this._titleId}});o.title&&at(a,o.title,r.allowHTML,r.sanitize),o.title?(this.el.setAttribute("aria-labelledby",this._titleId),this.el.removeAttribute("aria-label")):(this.el.removeAttribute("aria-labelledby"),this.el.setAttribute("aria-label",k(r.labels.stepAnnouncement,i+1,e)));let s=m("div",{className:"tk-tooltip__header"},[o.title?a:null]);r.buttons.skip&&s.append(m("button",{className:"tk-tooltip__close",text:"\xD7",attrs:{type:"button","aria-label":r.labels.skip},on:{click:()=>this._callbacks.onSkip()}})),this._body.append(s);let u=m("div",{className:"tk-tooltip__content",attrs:{id:this._contentId}}),d=o.renderStep??r.renderStep;if(d)try{let f=d(t,u);typeof f=="function"&&(this._contentCleanup=f)}catch(f){console.error("[tourkit] renderStep failed",f)}else at(u,o.content,r.allowHTML,r.sanitize);if(this._body.append(u),r.showOnce?.checkbox&&this._body.append(m("label",{className:"tk-tooltip__once"},[m("input",{className:"tk-tooltip__once-box",attrs:{type:"checkbox",checked:this._callbacks.isShowOnceChecked()?"":void 0},on:{change:f=>this._callbacks.onShowOnceChange(f.target.checked)}}),m("span",{text:r.labels.dontShowAgain})])),r.stepNumbers&&this._body.append(m("div",{className:"tk-tooltip__step-number",text:k(r.labels.stepOf,i+1,e)})),r.progress){let f=Math.round((i+1)/e*100);this._body.append(m("div",{className:"tk-tooltip__progress",attrs:{role:"progressbar","aria-label":k(r.labels.stepAnnouncement,i+1,e),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":f,"aria-valuetext":k(r.labels.stepOf,i+1,e)}},Array.from({length:e},(g,E)=>m("span",{className:["tk-tooltip__progress-seg",E<i?"tk-tooltip__progress-seg--done":"",E===i?"tk-tooltip__progress-seg--current":""].filter(Boolean).join(" ")}))))}let c=m("div",{className:"tk-tooltip__footer"});r.bullets&&e>1&&c.append(m("div",{className:"tk-tooltip__bullets"},Array.from({length:e},(f,g)=>m("button",{className:`tk-tooltip__bullet${g===i?" tk-tooltip__bullet--active":""}`,text:g===i?String(g+1):void 0,attrs:{type:"button","aria-label":k(r.labels.stepAnnouncement,g+1,e),"aria-current":g===i?"step":void 0},on:{click:()=>this._callbacks.onBullet(g)}}))));let h=m("div",{className:"tk-tooltip__actions"}),p=r.classes?.button?` ${r.classes.button}`:"";r.buttons.back&&e>1&&!(r.buttons.hideBackOnFirst&&i===0)&&h.append(m("button",{className:`tk-button tk-button--ghost${p}`,text:r.labels.back,attrs:{type:"button",disabled:i===0?"":void 0},on:{click:()=>this._callbacks.onBack()}}));let _=i===e-1,v=_&&r.buttons.doneOnLast;r.buttons.next&&!(r.buttons.hideNextOnLast&&_&&!v)&&h.append(m("button",{className:`tk-button tk-button--primary${p}`,text:v?r.labels.done:r.labels.next,attrs:{type:"button","data-tk-action":v?"done":"next",disabled:_&&!r.buttons.doneOnLast?"":void 0},on:{click:()=>this._callbacks.onNext()}})),(h.childElementCount>0||c.childElementCount>0)&&(c.append(h),this._body.append(c))}measure(){return{width:this.el.offsetWidth,height:this.el.offsetHeight}}position(t,e){if(!this._ctx)return;let o=this._ctx.step.placement,i=e?.size??this.measure(),r=J(o,t,i,e?.viewport??b(),this._options.placementPrecedence,{rtl:this._rtl}),a=this._placement;if(this._placement=r,!(a!==null&&a.side===r.side&&a.align===r.align&&a.x===r.x&&a.y===r.y&&a.arrow===r.arrow)){for(let s of ne)this.el.classList.toggle(`tk-tooltip--${s}`,r.side===s);this.el.style.left=`${Math.round(r.x)}px`,this.el.style.top=`${Math.round(r.y)}px`,r.arrow===null?this._arrow.style.display="none":(this._arrow.style.display="",this._arrow.dataset.side=r.side,r.side==="top"||r.side==="bottom"?(this._arrow.style.left=`${Math.round(r.arrow-Lt)}px`,this._arrow.style.top=""):(this._arrow.style.top=`${Math.round(r.arrow-Lt)}px`,this._arrow.style.left=""))}}focus(){(this.el.querySelector(".tk-button--primary:not([disabled])")??this.el).focus({preventScroll:!0})}destroy(){this._runContentCleanup(),this._releaseTrap(),this.el.remove()}_runContentCleanup(){let t=this._contentCleanup;if(this._contentCleanup=null,!!t)try{t()}catch(e){console.error("[tourkit] renderStep cleanup failed",e)}}};var oe=180,It=n=>n.width===0&&n.height===0;function re(n){return n instanceof HTMLElement?n.isContentEditable||n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement:!1}var Y=class{constructor(t,e){this._options=t;this._hooks=e;this._root=null;this._overlay=null;this._tooltip=null;this._guards=[];this._live=null;this._ctx=null;this._autoUpdater=null;this._stopKeyboard=null;this._restoreFocus=null;this._guardStages=[];this._targetWatch=null;this._advance=null;this._inerted=[];this._modalApplied=!1;this._releaseScrollLock=null;this._releaseHostClass=null}setOptions(t){this._options=t,this._tooltip?.setOptions(t),this._overlay?.setOptions(t.overlay),this._root&&(t.theme?this._root.dataset.tkTheme=t.theme:delete this._root.dataset.tkTheme,t.zIndex!==void 0?this._root.style.setProperty("--tk-z",String(t.zIndex)):this._root.style.removeProperty("--tk-z"),this._overlay&&this._overlay.el.setAttribute("class",`tk-overlay${t.classes?.overlay?` ${t.classes.overlay}`:""}`),t.modal?(this._tooltip?.el.setAttribute("aria-modal","true"),this._applyInert()):(this._tooltip?.el.removeAttribute("aria-modal"),this._releaseInert()),this._syncScrollLock(),this._syncHostClass(),this._stopKeyboard?.(),this._stopKeyboard=null,this._bindKeyboard())}mount(){if(this._root)return;this._restoreFocus=kt();let t=this._options;this._root=m("div",{className:"tk-root"}),t.theme&&(this._root.dataset.tkTheme=t.theme),t.zIndex!==void 0&&this._root.style.setProperty("--tk-z",String(t.zIndex)),this._overlay=new I(t.overlay,{onBackdropClick:()=>this._hooks.onExitRequest()},t.classes?.overlay),this._tooltip=new X(t,{onNext:()=>this._hooks.onNext(),onBack:()=>this._hooks.onBack(),onSkip:()=>this._hooks.onSkip(),onBullet:e=>this._hooks.onGoTo(e),isShowOnceChecked:()=>this._hooks.isShowOnceChecked(),onShowOnceChange:e=>this._hooks.onShowOnceChange(e)}),this._live=m("div",{className:"tk-live",attrs:{"aria-live":"polite",role:"status"}}),this._root.append(this._overlay.el,this._tooltip.el,this._live),(t.container??document.body).append(this._root),t.modal&&(this._tooltip.el.setAttribute("aria-modal","true"),this._applyInert()),this._bindKeyboard(),this._syncHostClass(),this._autoUpdater=H(()=>this._sync()),x(()=>this._root?.classList.add("tk-root--visible"))}showStep(t,e){if(!this._root||!this._overlay||!this._tooltip)return;this._stopTargetWatch(),this._ctx=t,this._syncScrollLock(),t.target&&D(t.target,{...this._options.scroll,...t.step.scroll});let o=this._stageRect(),i=this._extraStages();this._overlay.setStage(o,!0,i),this._tooltip.render(t,this._hooks.getTotal()),this._tooltip.position(o),this._updateGuards(o,i),this._announce(t),this._tooltip.focus(),this._autoUpdater?.setElements([t.target,...this._extraTargets(),this._tooltip.el]),this._bindAdvance(),o===null&&t.step.target!==void 0&&t.step.waitForTarget!==!1&&this._startTargetWatch(t.step.waitForTarget)}refresh(){this._sync()}async unmount(){let t=this._root;t&&(this._teardownListeners(),t.classList.remove("tk-root--visible"),U()||await new Promise(e=>setTimeout(e,oe)),this._removeDom(),this._restoreFocus?.(),this._restoreFocus=null)}destroyNow(){this._teardownListeners(),this._removeDom(),this._restoreFocus?.(),this._restoreFocus=null}_teardownListeners(){this._stopTargetWatch(),this._unbindAdvance(),this._releaseInert(),this._releaseScroll(),this._autoUpdater?.stop(),this._autoUpdater=null,this._stopKeyboard?.(),this._stopKeyboard=null}_applyInert(){if(this._modalApplied||!this._root)return;this._modalApplied=!0;let t=this._root.parentElement;if(t){this._inerted=[];for(let e of Array.from(t.children))e!==this._root&&(this._inerted.push({el:e,hadInert:e.hasAttribute("inert")}),e.setAttribute("inert",""))}}_releaseInert(){if(this._modalApplied){this._modalApplied=!1;for(let{el:t,hadInert:e}of this._inerted)e||t.removeAttribute("inert");this._inerted=[]}}_syncScrollLock(){let t=this._ctx?.step.lockScroll??this._options.lockScroll;t!==(this._releaseScrollLock!==null)&&(t?this._releaseScrollLock=Rt():(this._releaseScrollLock?.(),this._releaseScrollLock=null))}_releaseScroll(){this._releaseScrollLock?.(),this._releaseScrollLock=null}_syncHostClass(){let t=this._root!==null&&this._options.hostClasses;t!==(this._releaseHostClass!==null)&&(t?this._releaseHostClass=j(Et):(this._releaseHostClass?.(),this._releaseHostClass=null))}_removeDom(){this._overlay?.destroy(),this._tooltip?.destroy(),this._root?.remove(),this._root=null,this._syncHostClass(),this._overlay=null,this._tooltip=null,this._guards=[],this._guardStages=[],this._live=null,this._ctx=null}_liveTarget(){if(!this._ctx)return null;let t=this._ctx.target;if(t&&t.isConnected)return t;let e=w(this._ctx.step.target,this._options.root),o=e&&e.isConnected?e:null;return o!==t&&(this._ctx={...this._ctx,target:o},this._tooltip?.syncContext(this._ctx),this._autoUpdater?.setElements([o,...this._extraTargets(),...this._tooltip?[this._tooltip.el]:[]]),o&&!this._targetWatch&&this._bindAdvance()),o}_targetRect(){let t=this._liveTarget();if(!t)return null;let e=$(t);return It(e)?null:e}_stageRect(){let t=this._targetRect();return t?N(t,this._options.overlay.padding):null}_extraTargets(){return(this._ctx?.step.highlight??[]).map(t=>w(t,this._options.root)).filter(t=>t!==null&&t.isConnected)}_extraStages(){return this._extraTargets().map(t=>$(t)).filter(t=>!It(t)).map(t=>N(t,this._options.overlay.padding))}_sync(){if(!this._ctx||!this._overlay||!this._tooltip)return;let t=this._stageRect(),e=this._extraStages();if(this._targetWatch&&t){this._stopTargetWatch(),this._presentAwaitedTarget();return}let o=this._tooltip.measure(),i=b();this._overlay.refresh(t,e),this._tooltip.position(t,{size:o,viewport:i}),this._updateGuards(t,e)}_presentAwaitedTarget(){let t=this._ctx;if(!t||!this._overlay||!this._tooltip)return;t.target&&D(t.target,{...this._options.scroll,...t.step.scroll});let e=this._stageRect(),o=this._extraStages();this._overlay.setStage(e,!0,o),this._tooltip.position(e),this._updateGuards(e,o),this._bindAdvance(),this._announce(t,!0)}_startTargetWatch(t){if(this._stopTargetWatch(),typeof MutationObserver>"u")return;let e=0,o=new MutationObserver(()=>{e||(e=x(()=>{e=0,this._sync()}))});o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]});let i=window.setTimeout(()=>{let r=t.onTimeout==="skip";this._stopTargetWatch(),r&&this._hooks.onNext()},t.timeoutMs);this._targetWatch={stop:()=>{o.disconnect(),e&&C(e),window.clearTimeout(i)}}}_stopTargetWatch(){this._targetWatch?.stop(),this._targetWatch=null}_bindAdvance(){this._unbindAdvance();let t=this._ctx;if(!t?.step.advanceOn||!t.target)return;if(this._options.modal||(t.step.disableInteraction??this._options.disableInteraction)){console.warn("[tourkit] advanceOn needs an interactive target; disableInteraction/modal blocks the event.");return}let o=t.step.advanceOn,i=o===!0?"click":o.event??"click",r=()=>{this._unbindAdvance(),this._hooks.onNext()};t.target.addEventListener(i,r,{capture:!0}),this._advance={el:t.target,event:i,handler:r}}_unbindAdvance(){this._advance&&(this._advance.el.removeEventListener(this._advance.event,this._advance.handler,{capture:!0}),this._advance=null)}_updateGuards(t,e){if(!this._root||!this._tooltip)return;let i=this._ctx?.step.disableInteraction??this._options.disableInteraction?[...t?[t]:[],...e]:[];if(!(this._guardStages.length===i.length&&this._guardStages.every((r,a)=>T(r,i[a]??null)))){for(this._guardStages=i;this._guards.length<i.length;){let r=m("div",{className:"tk-interaction-guard",attrs:{"aria-hidden":"true"}});this._tooltip.el.before(r),this._guards.push(r)}for(;this._guards.length>i.length;)this._guards.pop().remove();i.forEach((r,a)=>{let s=this._guards[a];s.style.left=`${r.x}px`,s.style.top=`${r.y}px`,s.style.width=`${r.width}px`,s.style.height=`${r.height}px`})}}_announce(t,e=!1){let o=this._live;if(!o)return;let i=this._hooks.getTotal(),r=k(this._options.labels.stepAnnouncement,t.index+1,i),a=t.step.title?`: ${t.step.title}`:"",s=`${r}${a}`;if(e&&o.textContent===s){o.textContent="",x(()=>{this._live===o&&(o.textContent=s)});return}o.textContent=s}_bindKeyboard(){if(!this._options.keyboard&&!this._options.exitOnEsc)return;let t=e=>{let o=document.activeElement,i=this._root?.contains(o)??!1;if(e.key==="Escape"){if(e.defaultPrevented||!this._options.exitOnEsc||!i&&re(o))return;e.preventDefault(),this._hooks.onExitRequest();return}if(!this._options.keyboard)return;let r=o===document.body||o===null;if(!(!i&&!r))switch(e.key){case"ArrowRight":e.preventDefault(),this._hooks.onNext();break;case"ArrowLeft":e.preventDefault(),this._hooks.onBack();break;case"Home":e.preventDefault(),this._hooks.onGoTo(0);break;case"End":e.preventDefault(),this._hooks.onGoTo(this._hooks.getTotal()-1);break}};document.addEventListener("keydown",t),this._stopKeyboard=()=>document.removeEventListener("keydown",t)}};function ie(n,t){let e=n.getAttribute(t);if(e!==null){if(Z(e))return e;console.warn(`[tourkit] unknown ${t}="${e}"; falling back to the tour default.`)}}function B(n,t){return n.filter(e=>!!e.content||!!(e.renderStep??t.renderStep)).map(e=>({...e,placement:e.placement??(e.target?t.placement:"center"),disableInteraction:e.disableInteraction??t.disableInteraction,lockScroll:e.lockScroll??t.lockScroll,waitForTarget:rt(t.waitForTarget,e.waitForTarget)}))}var W="data-tour";function q(n){return n===void 0?W:/^data-[a-z0-9-]*[a-z0-9]$/.test(n)?n:(console.warn(`[tourkit] invalid data attribute "${n}"; expected a lowercase name starting with "data-". Using "${W}".`),W)}function se(n){return{content:n,title:`${n}-title`,step:`${n}-step`,group:`${n}-group`,placement:`${n}-placement`,noInteraction:`${n}-no-interaction`,lockScroll:`${n}-lock-scroll`,advanceOn:`${n}-advance-on`,wait:`${n}-wait`,highlight:`${n}-highlight`}}function ae(n,t){let e=n.getAttribute(t);if(e!==null)return e===""||e==="click"?!0:{event:e}}function le(n,t){let e=n.getAttribute(t);if(e===null)return;if(e==="false"||e==="off")return!1;if(e==="")return{};let o=Number(e);if(Number.isFinite(o)&&o>=0)return{timeoutMs:o};console.warn(`[tourkit] unknown ${t}="${e}"; using the tour default.`)}function ce(n,t){let e=n.getAttribute(t);if(e===null)return;let o=e.split(",").map(i=>i.trim()).filter(Boolean);return o.length?o:void 0}function M(n,t={}){if(n===void 0&&typeof document>"u")return console.warn("[tourkit] fromDataAttributes() found no document; returning no steps."),[];let e=se(q(t.attribute)),o=Array.from((n??document).querySelectorAll(`[${e.content}]`)),i=new Map,r=[];for(let c of o){if(t.group!==void 0&&c.getAttribute(e.group)!==t.group||vt(c))continue;let h=c.getAttribute(e.content);if(!h)continue;let p={target:c,content:h,title:c.getAttribute(e.title)??void 0,placement:ie(c,e.placement),disableInteraction:c.hasAttribute(e.noInteraction)?!0:void 0,lockScroll:c.hasAttribute(e.lockScroll)?!0:void 0,highlight:ce(c,e.highlight),waitForTarget:le(c,e.wait),advanceOn:ae(c,e.advanceOn)},l=parseInt(c.getAttribute(e.step)??"",10);Number.isFinite(l)&&l>0?(i.has(l-1)&&console.warn(`[tourkit] duplicate ${e.step}="${l}"; the later element wins.`),i.set(l-1,p)):r.push(p)}let a=i.size+r.length,s=i.size?Math.max(...i.keys())+1:0,u=[];for(let c=0;c<Math.max(a,s)&&(i.size||r.length);c++){let h=i.get(c);h?(i.delete(c),u.push(h)):r.length&&u.push(r.shift())}let d=[...i.entries()].sort(([c],[h])=>c-h).map(([,c])=>c);return u.push(...d),u}var ue="1",de=()=>typeof window<"u"&&typeof document<"u";function dt(n,t){let e=R(t).get(n);if(e===null)return null;let o=parseInt(e,10);return Number.isFinite(o)&&o>=0?o:null}var Q=new Set;function tt(n={}){let t=it(S(),n),e=!1,o=()=>R(t.showOnce?.storage),i=()=>{t.showOnce&&o().set(t.showOnce.key,JSON.stringify({v:1,t:Date.now()}))},r=()=>{let l=t.showOnce;if(!l)return!1;let _=o().get(l.key);if(_===null)return!1;if(_===ue||l.ttlMs===void 0)return!0;let v;try{v=JSON.parse(_).t}catch{return!0}return typeof v!="number"||Date.now()-v<l.ttlMs?!0:(o().remove(l.key),!1)},a=new Y(t,{getTotal:()=>s.steps.length,onNext:()=>{s.next()},onBack:()=>{s.back()},onSkip:()=>{s.skip()},onGoTo:l=>{s.goTo(l)},onExitRequest:()=>{s.exit(!1)},isShowOnceChecked:()=>e,onShowOnceChange:l=>{e=l,t.showOnce&&(l?i():o().remove(t.showOnce.key))}}),s=new A(a,()=>t.root);s.events.on("complete",()=>i());let u=()=>R(t.persistProgress?.storage),d=()=>{t.persistProgress&&u().remove(t.persistProgress.key)};s.events.on("stepChange",({index:l})=>{t.persistProgress&&u().set(t.persistProgress.key,String(l))}),s.events.on("exit",()=>{d(),Q.delete(p)});let c=()=>t.steps.length>0?t.steps:M(t.root,{attribute:t.dataAttribute}),h=()=>{let l=B(c(),t);if(l.length===0){s.exit(!0);return}s.setSteps(l),s.reshow()},p={async start(l){if(!de())return console.warn("[tourkit] start() is a no-op outside the browser."),!1;if(t.showOnce&&(e=r(),e))return!1;let _=[...Q].filter(g=>g!==p);_.length>0&&(l?.replace?await Promise.all(_.map(g=>g.exit(!0))):console.warn("[tourkit] another tour is already running; exit it first (or use start({ replace: true })) to avoid two overlays and two focus traps."));let v=0;if(t.persistProgress){let{key:g,storage:E}=t.persistProgress;v=dt(g,E)??0}let y=B(c(),t),f=await s.start(y,v);return f&&Q.add(p),f},exit(l=!1){return s.exit(l)},complete(){return s.complete()},destroy(){a.destroyNow(),s.forceIdle(),s.events.removeAll(),Q.delete(p)},next:()=>s.next(),back:()=>s.back(),goTo:l=>s.goTo(l),refresh(l=!1){s.isActive&&(l?h():a.refresh())},get index(){return s.index},get steps(){return s.steps},get isActive(){return s.isActive},setOptions(l){return t=it(t,l),a.setOptions(t),s.isActive&&h(),p},on:(l,_)=>s.events.on(l,_),once:(l,_)=>s.events.once(l,_)};return p}var V=null,pe=()=>{};function Mt(n,t={}){if(typeof document>"u")return console.warn("[tourkit] bindTriggers() is a no-op outside the browser."),pe;let e=n??document,o=q(t.dataAttribute),i=`${o}-trigger`,r=null,a=s=>{let u=s.target?.closest?.(`[${i}]`);if(!u)return;s.preventDefault();let d=u.getAttribute(i)||void 0,c=t.steps?.length?t.steps:M(e,{group:d,attribute:o}),h=V,p=tt({...t,steps:c});V=p,r=p,(async()=>(h&&await h.exit(!0),V===p&&await p.start()))()};return e.addEventListener("click",a),()=>{e.removeEventListener("click",a),r&&(r.destroy(),V===r&&(V=null),r=null)}}var he={move:()=>{},refresh:()=>{},destroy:()=>{},isActive:!1};function Ht(n,t={}){if(typeof window>"u"||typeof document>"u")return console.warn("[tourkit] highlight() is a no-op outside the browser."),he;let e=S(),o={...e.overlay,...t.overlay},i=t.scroll===!1?!1:{...e.scroll,...t.scroll},r=t.exitOnEsc??!0,a=n,s=!0,u=m("div",{className:"tk-root tk-highlight"});t.theme&&(u.dataset.tkTheme=t.theme),t.zIndex!==void 0&&u.style.setProperty("--tk-z",String(t.zIndex));let d=new I(o,{onBackdropClick:()=>v.destroy()},t.classes?.overlay);u.append(d.el),(t.container??document.body).append(u),x(()=>u.classList.add("tk-root--visible"));let c=t.hostClasses===!1?null:j(Ot),h=()=>{let y=w(a,t.root);if(!y||!y.isConnected)return null;let f=$(y);return f.width===0&&f.height===0?null:N(f,o.padding)},p=(y,f=!0)=>{let g=w(a,t.root);g&&i&&f&&D(g,i),d.setStage(h(),y),l.setElements([g])},l=H(()=>d.refresh(h())),_=y=>{y.key==="Escape"&&r&&!y.defaultPrevented&&(y.preventDefault(),v.destroy())};document.addEventListener("keydown",_);let v={move(y,f){s&&(a=y,p(!0,f?.scroll??!0))},refresh(){s&&d.refresh(h())},destroy(){s&&(s=!1,document.removeEventListener("keydown",_),l.stop(),d.destroy(),u.remove(),c?.())},get isActive(){return s}};return p(!1),v}var fe="0.7.1";0&&(module.exports={DEFAULT_DATA_ATTRIBUTE,Emitter,TourEngine,autoUpdate,bindTriggers,createTour,defaultLabels,defaultPlacementConfig,fromDataAttributes,getDefaultOptions,getPersistedProgress,highlight,isPlacement,memoryStorage,normalizeSteps,parsePlacement,resolveDataAttribute,resolvePlacement,resolveStorage,resolveTarget,version});
7
+ //# sourceMappingURL=index.cjs.map