import{arrayType as e,booleanType as t,functionType as n,objectType as r,someType as i,stringType as a}from"../_util/type.mjs";import o from"../_util/classNames.mjs";import s from"../_util/props-util/initDefaultProps.mjs";import c from"../_util/PortalWrapper.mjs";import{triggerProps as l}from"../vc-trigger/interface.mjs";import u from"../vc-trigger/index.mjs";import d from"../_util/hooks/useMergedState.mjs";import f from"./Mask.mjs";import p from"./TourStep/index.mjs";import m from"./hooks/useTarget.mjs";import{getPlacements as h}from"./placements.mjs";import{Fragment as g,computed as _,createVNode as v,defineComponent as y,ref as b,shallowRef as x,toRefs as S,watch as C,watchEffect as w}from"vue";var T={left:`50%`,top:`50%`,width:`1px`,height:`1px`},E=()=>{let{builtinPlacements:o,popupAlign:s}=l();return{builtinPlacements:o,popupAlign:s,steps:e(),open:t(),defaultCurrent:{type:Number},current:{type:Number},onChange:n(),onClose:n(),onFinish:n(),mask:i([Boolean,Object],!0),arrow:i([Boolean,Object],!0),rootClassName:{type:String},placement:a(`bottom`),prefixCls:{type:String,default:`rc-tour`},renderPanel:n(),gap:r(),animated:i([Boolean,Object]),scrollIntoViewOptions:i([Boolean,Object],!0),zIndex:{type:Number,default:1001}}},D=y({name:`Tour`,inheritAttrs:!1,props:s(E(),{}),setup(e){let{defaultCurrent:t,placement:n,mask:r,scrollIntoViewOptions:i,open:a,gap:s,arrow:l}=S(e),y=b(),[E,D]=d(0,{value:_(()=>e.current),defaultValue:t.value}),[O,k]=d(void 0,{value:_(()=>e.open),postState:t=>E.value<0||E.value>=e.steps.length?!1:t??!0}),A=x(O.value);w(()=>{O.value&&!A.value&&D(0),A.value=O.value});let j=_(()=>e.steps[E.value]||{}),M=_(()=>j.value.placement??n.value),N=_(()=>O.value&&(j.value.mask??r.value)),P=_(()=>j.value.scrollIntoViewOptions??i.value),[F,I]=m(_(()=>j.value.target),a,s,P),L=_(()=>I.value?j.value.arrow===void 0?l.value:j.value.arrow:!1),R=_(()=>typeof L.value==`object`&&L.value.pointAtCenter);C(R,()=>{y.value?.forcePopupAlign()}),C(E,()=>{y.value?.forcePopupAlign()});let z=t=>{D(t),e.onChange?.(t)};return()=>{let{prefixCls:t,steps:n,onClose:r,onFinish:i,rootClassName:a,renderPanel:s,animated:l,zIndex:d,...m}=e;if(I.value===void 0)return null;let b=()=>{k(!1),r?.(E.value)},x=typeof N.value==`boolean`?N.value:!!N.value,S=typeof N.value==`boolean`?void 0:N.value,C=()=>I.value||document.body,w=()=>v(p,{arrow:L.value,key:`content`,prefixCls:t,total:n.length,renderPanel:s,onPrev:()=>{z(E.value-1)},onNext:()=>{z(E.value+1)},onClose:b,current:E.value,onFinish:()=>{b(),i?.()},...j.value},null),D=_(()=>{let e=F.value||T,t={};return Object.keys(e).forEach(n=>{typeof e[n]==`number`?t[n]=`${e[n]}px`:t[n]=e[n]}),t});return O.value?v(g,null,[v(f,{zIndex:d,prefixCls:t,pos:F.value,showMask:x,style:S?.style,fill:S?.color,open:O.value,animated:l,rootClassName:a},null),v(u,{...m,arrow:!!m.arrow,builtinPlacements:j.value.target?m.builtinPlacements??h(R.value):void 0,ref:y,popupStyle:j.value.target?j.value.style:{...j.value.style,position:`fixed`,left:T.left,top:T.top,transform:`translate(-50%, -50%)`},popupPlacement:M.value,popupVisible:O.value,popupClassName:o(a,j.value.className),prefixCls:t,popup:w,forceRender:!1,destroyPopupOnHide:!0,zIndex:d,mask:!1,getTriggerDOMNode:C},{default:()=>[v(c,{visible:O.value,autoLock:!0},{default:()=>[v(`div`,{class:o(a,`${t}-target-placeholder`),style:{...D.value,position:`fixed`,pointerEvents:`none`}},null)]})]})]):null}}});export{D as default,E as tourProps};