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