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.
- package/CHANGELOG.md +436 -0
- package/LICENSE +21 -0
- package/README.md +323 -2
- package/dist/compat-introjs.cjs +7 -0
- package/dist/compat-introjs.d.cts +118 -0
- package/dist/compat-introjs.d.ts +118 -0
- package/dist/compat-introjs.global.js +7 -0
- package/dist/compat-introjs.js +7 -0
- package/dist/hints.cjs +7 -0
- package/dist/hints.d.cts +131 -0
- package/dist/hints.d.ts +131 -0
- package/dist/hints.global.js +7 -0
- package/dist/hints.js +7 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +613 -0
- package/dist/index.d.ts +613 -0
- package/dist/index.global.js +7 -0
- package/dist/index.js +7 -0
- package/dist/inject-styles.cjs +680 -0
- package/dist/inject-styles.d.cts +20 -0
- package/dist/inject-styles.d.ts +20 -0
- package/dist/inject-styles.js +680 -0
- package/dist/locales.cjs +7 -0
- package/dist/locales.d.cts +28 -0
- package/dist/locales.d.ts +28 -0
- package/dist/locales.global.js +7 -0
- package/dist/locales.js +7 -0
- package/dist/styles.css +673 -0
- package/dist/types-M-1II5wP.d.cts +257 -0
- package/dist/types-M-1II5wP.d.ts +257 -0
- package/package.json +195 -4
|
@@ -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 TourKit=(()=>{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});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";return Bt(me);})();
|
|
7
|
+
//# sourceMappingURL=index.global.js.map
|
package/dist/index.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 P=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 lt(n,t,e){try{return await t()}catch(o){return console.error(`[tourkit] step ${n} failed`,o),e}}var L=class{constructor(t,e=()=>{}){this._delegate=t;this._getScope=e;this.events=new P;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 lt("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 lt("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 Lt="Got it",ct={next:"Next",back:"Back",done:"Done",skip:"Close",stepOf:"{step} of {total}",stepAnnouncement:"Step {step} of {total}",dontShowAgain:"Don't show this again",hintDismiss:Lt},It={block:"center",behavior:"smooth",padding:24};function k(){return{steps:[],labels:{...ct},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:{...ut},scroll:{...It},allowHTML:!1}}var ut={timeoutMs:1e4,onTimeout:"float"};function Q(n,t){return t===!1?!1:t===void 0?n===!1?!1:{...n}:{...n===!1?ut:n,...t}}function tt(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:Q(n.waitForTarget,t.waitForTarget)}}function S(n,t,e){return n.replace("{step}",String(t)).replace("{total}",String(e))}function et(n){return{get:t=>n.get(t)??null,set:(t,e)=>{n.set(t,e)},remove:t=>{n.delete(t)}}}var Mt=et(new Map),Ht=et(new Map),$t=et(new Map);function dt(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 I(n="local"){return n==="local"?dt(()=>window.localStorage,Ht):n==="session"?dt(()=>window.sessionStorage,$t):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 Nt="http://www.w3.org/2000/svg";function B(n,t={}){let e=document.createElementNS(Nt,n);for(let[o,i]of Object.entries(t))e.setAttribute(o,i);return e}function nt(n,t,e,o){if(!e){n.textContent=t;return}n.innerHTML=o?o(t):t}function q(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var Dt=16;function x(n){return typeof requestAnimationFrame=="function"?requestAnimationFrame(n):setTimeout(()=>n(Ft()),Dt)}function Ft(){return typeof performance<"u"?performance.now():Date.now()}function O(n){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(n);return}clearTimeout(n)}function ht(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 pt=0;function ot(n){return pt+=1,`tk-${n}-${pt}`}function M(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&&O(t)}}}function zt(n,t){let e=M(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 H(n){let t=n.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}function $(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function V(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 A(n,t,e){return n+(t-n)*e}function ft(n,t,e){return{x:A(n.x,t.x,e),y:A(n.y,t.y,e),width:A(n.width,t.width,e),height:A(n.height,t.height,e)}}function R(n,t,e){return Math.min(Math.max(n,t),e<t?t:e)}function mt(n){return n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2}function Wt(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 N(n,t){if(t.block==="off"||typeof n.scrollIntoView!="function"||Wt(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 gt='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function vt(){let n=document.activeElement;return()=>{n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}}function Bt(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 _t(n){let t=[],e=o=>{o instanceof HTMLElement&&o.matches(gt)&&t.push(o);for(let i of o.querySelectorAll("*"))i.matches(gt)&&t.push(i),i.shadowRoot&&e(i.shadowRoot)};return e(n),t.filter(Bt)}function qt(){let n=document.activeElement;for(;n?.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n instanceof HTMLElement?n:null}var D=[];function yt(n,t){let e={};D.push(e);let o=i=>{if(i.key!=="Tab"||D[D.length-1]!==e)return;let r=_t(n),a=t?.();if(a&&a!==n&&!n.contains(a)&&a.isConnected&&r.push(..._t(a)),r.length===0){i.preventDefault(),n.focus();return}let s=qt(),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=D.indexOf(e);i!==-1&&D.splice(i,1)}}var F=new Map,bt="tk-tour-active",xt="tk-highlight-active";function K(n){if(typeof document>"u")return()=>{};let t=(F.get(n)??0)+1;F.set(n,t),t===1&&document.body.classList.add(n);let e=!1;return()=>{if(e)return;e=!0;let o=(F.get(n)??1)-1;if(o>0){F.set(n,o);return}F.delete(n),document.body.classList.remove(n)}}var C=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=B("svg",{class:`tk-overlay${o?` ${o}`:""}`,"aria-hidden":"true"}),this._path=B("path",{class:"tk-overlay__path","fill-rule":"evenodd"}),this._path.addEventListener("click",()=>{this._options.clickToExit&&e.onBackdropClick()}),this._ring=B("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=k().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??V(b()),r=t?this._radiusFor(t):0,a=this._current??V(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||q()){this._paint(i,r);return}let u=performance.now(),d=this._options.transitionMs,c=h=>{let p=R((h-u)/d,0,1),l=mt(p);this._paint(ft(a,i,l),A(s,r,l)),p<1?this._frame=x(c):this._frame=0};this._frame=x(c)}refresh(t,e=[]){let o=t??V(b()),i=t?this._radiusFor(t):0,r=Vt(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&&(O(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=wt(t,e),a=this._extras.map(u=>wt(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 Vt(n,t){return n.length===t.length&&n.every((e,o)=>T(e,t[o]??null))}function wt(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 St(){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 Et={gap:14,viewportPadding:8,arrowInset:14,rtl:!1},Kt=/^(center|(top|bottom|left|right)(-(start|center|end))?)$/;function rt(n){return typeof n=="string"&&Kt.test(n)}function Ot(n){if(n==="center")return{side:"center",align:void 0};let[t,e]=n.split("-");return{side:t,align:e}}function Ut(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 kt(n,t,e,o,i){let r=(n==="top"||n==="bottom"?e.height:e.width)+i.gap+i.viewportPadding;return Ut(n,t,o)>=r}function Tt(n,t,e){let o=(i,r,a)=>R(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 it(n,t,e,o,i,r){let a={...Et,...r};if(!t||n==="center")return Tt(e,o,a);let{side:s,align:u}=Ot(n),d="center";if(s!=="center"&&kt(s,t,e,o,a))d=s;else{let at=i.filter(Y=>Y!==s).find(Y=>kt(Y,t,e,o,a));at&&(d=at)}if(d==="center")return Tt(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=R(g,v+a.viewportPadding,v+y-_-a.viewportPadding);let E=p+l/2,Pt=R(E-g,a.arrowInset,_-a.arrowInset);return{side:d,align:f,x:c?g:h,y:c?h:g,arrow:Pt}}var At=7,Gt=["top","bottom","left","right","center"],U=class{constructor(t,e){this._options=t;this._callbacks=e;this._titleId=ot("title");this._contentId=ot("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=yt(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&&nt(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",S(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 nt(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:S(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":S(r.labels.stepAnnouncement,i+1,e),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":f,"aria-valuetext":S(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":S(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=it(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 Gt)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-At)}px`,this._arrow.style.top=""):(this._arrow.style.top=`${Math.round(r.arrow-At)}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 jt=180,Rt=n=>n.width===0&&n.height===0;function Zt(n){return n instanceof HTMLElement?n.isContentEditable||n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement:!1}var G=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=vt();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 C(t.overlay,{onBackdropClick:()=>this._hooks.onExitRequest()},t.classes?.overlay),this._tooltip=new U(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=M(()=>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&&N(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"),q()||await new Promise(e=>setTimeout(e,jt)),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=St():(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=K(bt):(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=H(t);return Rt(e)?null:e}_stageRect(){let t=this._targetRect();return t?$(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=>H(t)).filter(t=>!Rt(t)).map(t=>$(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&&N(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&&O(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=S(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&&Zt(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 Jt(n,t){let e=n.getAttribute(t);if(e!==null){if(rt(e))return e;console.warn(`[tourkit] unknown ${t}="${e}"; falling back to the tour default.`)}}function Z(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:Q(t.waitForTarget,e.waitForTarget)}))}var j="data-tour";function J(n){return n===void 0?j:/^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 "${j}".`),j)}function Xt(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 Yt(n,t){let e=n.getAttribute(t);if(e!==null)return e===""||e==="click"?!0:{event:e}}function Qt(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 te(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 z(n,t={}){if(n===void 0&&typeof document>"u")return console.warn("[tourkit] fromDataAttributes() found no document; returning no steps."),[];let e=Xt(J(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||ht(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:Jt(c,e.placement),disableInteraction:c.hasAttribute(e.noInteraction)?!0:void 0,lockScroll:c.hasAttribute(e.lockScroll)?!0:void 0,highlight:te(c,e.highlight),waitForTarget:Qt(c,e.wait),advanceOn:Yt(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 ee="1",ne=()=>typeof window<"u"&&typeof document<"u";function Ct(n,t){let e=I(t).get(n);if(e===null)return null;let o=parseInt(e,10);return Number.isFinite(o)&&o>=0?o:null}var X=new Set;function st(n={}){let t=tt(k(),n),e=!1,o=()=>I(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(_===ee||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 G(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 L(a,()=>t.root);s.events.on("complete",()=>i());let u=()=>I(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(),X.delete(p)});let c=()=>t.steps.length>0?t.steps:z(t.root,{attribute:t.dataAttribute}),h=()=>{let l=Z(c(),t);if(l.length===0){s.exit(!0);return}s.setSteps(l),s.reshow()},p={async start(l){if(!ne())return console.warn("[tourkit] start() is a no-op outside the browser."),!1;if(t.showOnce&&(e=r(),e))return!1;let _=[...X].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=Ct(g,E)??0}let y=Z(c(),t),f=await s.start(y,v);return f&&X.add(p),f},exit(l=!1){return s.exit(l)},complete(){return s.complete()},destroy(){a.destroyNow(),s.forceIdle(),s.events.removeAll(),X.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=tt(t,l),a.setOptions(t),s.isActive&&h(),p},on:(l,_)=>s.events.on(l,_),once:(l,_)=>s.events.once(l,_)};return p}var W=null,oe=()=>{};function re(n,t={}){if(typeof document>"u")return console.warn("[tourkit] bindTriggers() is a no-op outside the browser."),oe;let e=n??document,o=J(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:z(e,{group:d,attribute:o}),h=W,p=st({...t,steps:c});W=p,r=p,(async()=>(h&&await h.exit(!0),W===p&&await p.start()))()};return e.addEventListener("click",a),()=>{e.removeEventListener("click",a),r&&(r.destroy(),W===r&&(W=null),r=null)}}var ie={move:()=>{},refresh:()=>{},destroy:()=>{},isActive:!1};function se(n,t={}){if(typeof window>"u"||typeof document>"u")return console.warn("[tourkit] highlight() is a no-op outside the browser."),ie;let e=k(),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 C(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:K(xt),h=()=>{let y=w(a,t.root);if(!y||!y.isConnected)return null;let f=H(y);return f.width===0&&f.height===0?null:$(f,o.padding)},p=(y,f=!0)=>{let g=w(a,t.root);g&&i&&f&&N(g,i),d.setStage(h(),y),l.setElements([g])},l=M(()=>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 mn="0.7.1";export{j as DEFAULT_DATA_ATTRIBUTE,P as Emitter,L as TourEngine,zt as autoUpdate,re as bindTriggers,st as createTour,ct as defaultLabels,Et as defaultPlacementConfig,z as fromDataAttributes,k as getDefaultOptions,Ct as getPersistedProgress,se as highlight,rt as isPlacement,Mt as memoryStorage,Z as normalizeSteps,Ot as parsePlacement,J as resolveDataAttribute,it as resolvePlacement,I as resolveStorage,w as resolveTarget,mn as version};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|