物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11350 lines
316 KiB

  1. /**
  2. * vue v3.4.27
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. */
  6. /*! #__NO_SIDE_EFFECTS__ */
  7. // @__NO_SIDE_EFFECTS__
  8. function makeMap(str, expectsLowerCase) {
  9. const set = new Set(str.split(','))
  10. return val => set.has(val)
  11. }
  12. const EMPTY_OBJ = Object.freeze({})
  13. const EMPTY_ARR = Object.freeze([])
  14. function NOOP() {
  15. }
  16. const NO = () => false
  17. function isOn(key) {
  18. return key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 // uppercase letter
  19. && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97)
  20. }
  21. const isModelListener = key => key.startsWith('onUpdate:')
  22. const extend = Object.assign
  23. function remove(arr, el) {
  24. const i = arr.indexOf(el)
  25. if (i > -1)
  26. arr.splice(i, 1)
  27. }
  28. const hasOwnProperty$1 = Object.prototype.hasOwnProperty
  29. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key)
  30. const isArray = Array.isArray
  31. const isMap = val => toTypeString(val) === '[object Map]'
  32. const isSet = val => toTypeString(val) === '[object Set]'
  33. const isDate = val => toTypeString(val) === '[object Date]'
  34. const isRegExp = val => toTypeString(val) === '[object RegExp]'
  35. const isFunction = val => typeof val === 'function'
  36. const isString = val => typeof val === 'string'
  37. const isSymbol = val => typeof val === 'symbol'
  38. const isObject = val => val !== null && typeof val === 'object'
  39. function isPromise(val) {
  40. return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch)
  41. }
  42. const objectToString = Object.prototype.toString
  43. const toTypeString = value => objectToString.call(value)
  44. function toRawType(value) {
  45. return toTypeString(value).slice(8, -1)
  46. }
  47. const isPlainObject = val => toTypeString(val) === '[object Object]'
  48. const isIntegerKey = key => isString(key) && key !== 'NaN' && key[0] !== '-' && `${Number.parseInt(key, 10)}` === key
  49. const isReservedProp = /* @__PURE__ */ makeMap(
  50. // the leading comma is intentional so empty string "" is also included
  51. ',key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted',
  52. )
  53. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  54. 'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo',
  55. )
  56. function cacheStringFunction(fn) {
  57. const cache = /* @__PURE__ */ Object.create(null)
  58. return (str) => {
  59. const hit = cache[str]
  60. return hit || (cache[str] = fn(str))
  61. }
  62. }
  63. const camelizeRE = /-(\w)/g
  64. const camelize = cacheStringFunction((str) => {
  65. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
  66. })
  67. const hyphenateRE = /\B([A-Z])/g
  68. const hyphenate = cacheStringFunction(
  69. str => str.replace(hyphenateRE, '-$1').toLowerCase(),
  70. )
  71. const capitalize = cacheStringFunction((str) => {
  72. return str.charAt(0).toUpperCase() + str.slice(1)
  73. })
  74. const toHandlerKey = cacheStringFunction((str) => {
  75. const s = str ? `on${capitalize(str)}` : ``
  76. return s
  77. })
  78. const hasChanged = (value, oldValue) => !Object.is(value, oldValue)
  79. function invokeArrayFns(fns, arg) {
  80. for (let i = 0; i < fns.length; i++)
  81. fns[i](arg)
  82. }
  83. function def(obj, key, value, writable = false) {
  84. Object.defineProperty(obj, key, {
  85. configurable: true,
  86. enumerable: false,
  87. writable,
  88. value,
  89. })
  90. }
  91. function looseToNumber(val) {
  92. const n = Number.parseFloat(val)
  93. return isNaN(n) ? val : n
  94. }
  95. function toNumber(val) {
  96. const n = isString(val) ? Number(val) : Number.NaN
  97. return isNaN(n) ? val : n
  98. }
  99. let _globalThis
  100. function getGlobalThis() {
  101. return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {})
  102. }
  103. const GLOBALS_ALLOWED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error'
  104. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED)
  105. function normalizeStyle(value) {
  106. if (isArray(value)) {
  107. const res = {}
  108. for (let i = 0; i < value.length; i++) {
  109. const item = value[i]
  110. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item)
  111. if (normalized) {
  112. for (const key in normalized)
  113. res[key] = normalized[key]
  114. }
  115. }
  116. return res
  117. }
  118. else if (isString(value) || isObject(value)) {
  119. return value
  120. }
  121. }
  122. const listDelimiterRE = /;(?![^(]*\))/g
  123. const propertyDelimiterRE = /:([^]+)/
  124. const styleCommentRE = /\/\*[^]*?\*\//g
  125. function parseStringStyle(cssText) {
  126. const ret = {}
  127. cssText.replace(styleCommentRE, '').split(listDelimiterRE).forEach((item) => {
  128. if (item) {
  129. const tmp = item.split(propertyDelimiterRE)
  130. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim())
  131. }
  132. })
  133. return ret
  134. }
  135. function stringifyStyle(styles) {
  136. let ret = ''
  137. if (!styles || isString(styles))
  138. return ret
  139. for (const key in styles) {
  140. const value = styles[key]
  141. if (isString(value) || typeof value === 'number') {
  142. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key)
  143. ret += `${normalizedKey}:${value};`
  144. }
  145. }
  146. return ret
  147. }
  148. function normalizeClass(value) {
  149. let res = ''
  150. if (isString(value)) {
  151. res = value
  152. }
  153. else if (isArray(value)) {
  154. for (let i = 0; i < value.length; i++) {
  155. const normalized = normalizeClass(value[i])
  156. if (normalized)
  157. res += `${normalized} `
  158. }
  159. }
  160. else if (isObject(value)) {
  161. for (const name in value) {
  162. if (value[name])
  163. res += `${name} `
  164. }
  165. }
  166. return res.trim()
  167. }
  168. function normalizeProps(props) {
  169. if (!props)
  170. return null
  171. const { class: klass, style } = props
  172. if (klass && !isString(klass))
  173. props.class = normalizeClass(klass)
  174. if (style)
  175. props.style = normalizeStyle(style)
  176. return props
  177. }
  178. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot'
  179. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view'
  180. const MATH_TAGS = 'annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics'
  181. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS)
  182. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS)
  183. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS)
  184. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`
  185. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs)
  186. const isBooleanAttr = /* @__PURE__ */ makeMap(
  187. `${specialBooleanAttrs},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`,
  188. )
  189. function includeBooleanAttr(value) {
  190. return !!value || value === ''
  191. }
  192. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  193. `accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`,
  194. )
  195. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  196. `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`,
  197. )
  198. function isRenderableAttrValue(value) {
  199. if (value == null)
  200. return false
  201. const type = typeof value
  202. return type === 'string' || type === 'number' || type === 'boolean'
  203. }
  204. function looseCompareArrays(a, b) {
  205. if (a.length !== b.length)
  206. return false
  207. let equal = true
  208. for (let i = 0; equal && i < a.length; i++)
  209. equal = looseEqual(a[i], b[i])
  210. return equal
  211. }
  212. function looseEqual(a, b) {
  213. if (a === b)
  214. return true
  215. let aValidType = isDate(a)
  216. let bValidType = isDate(b)
  217. if (aValidType || bValidType)
  218. return aValidType && bValidType ? a.getTime() === b.getTime() : false
  219. aValidType = isSymbol(a)
  220. bValidType = isSymbol(b)
  221. if (aValidType || bValidType)
  222. return a === b
  223. aValidType = isArray(a)
  224. bValidType = isArray(b)
  225. if (aValidType || bValidType)
  226. return aValidType && bValidType ? looseCompareArrays(a, b) : false
  227. aValidType = isObject(a)
  228. bValidType = isObject(b)
  229. if (aValidType || bValidType) {
  230. if (!aValidType || !bValidType)
  231. return false
  232. const aKeysCount = Object.keys(a).length
  233. const bKeysCount = Object.keys(b).length
  234. if (aKeysCount !== bKeysCount)
  235. return false
  236. for (const key in a) {
  237. const aHasKey = a.hasOwnProperty(key)
  238. const bHasKey = b.hasOwnProperty(key)
  239. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key]))
  240. return false
  241. }
  242. }
  243. return String(a) === String(b)
  244. }
  245. function looseIndexOf(arr, val) {
  246. return arr.findIndex(item => looseEqual(item, val))
  247. }
  248. function toDisplayString(val) {
  249. return isString(val) ? val : val == null ? '' : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val)
  250. }
  251. function replacer(_key, val) {
  252. if (val && val.__v_isRef) {
  253. return replacer(_key, val.value)
  254. }
  255. else if (isMap(val)) {
  256. return {
  257. [`Map(${val.size})`]: [...val.entries()].reduce(
  258. (entries, [key, val2], i) => {
  259. entries[`${stringifySymbol(key, i)} =>`] = val2
  260. return entries
  261. },
  262. {},
  263. ),
  264. }
  265. }
  266. else if (isSet(val)) {
  267. return {
  268. [`Set(${val.size})`]: [...val.values()].map(v => stringifySymbol(v)),
  269. }
  270. }
  271. else if (isSymbol(val)) {
  272. return stringifySymbol(val)
  273. }
  274. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  275. return String(val)
  276. }
  277. return val
  278. }
  279. function stringifySymbol(v, i = '') {
  280. let _a
  281. return (
  282. // Symbol.description in es2019+ so we need to cast here to pass
  283. // the lib: es2016 check
  284. isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  285. )
  286. }
  287. function warn$2(msg, ...args) {
  288. console.warn(`[Vue warn] ${msg}`, ...args)
  289. }
  290. let activeEffectScope
  291. class EffectScope {
  292. constructor(detached = false) {
  293. this.detached = detached
  294. /**
  295. * @internal
  296. */
  297. this._active = true
  298. /**
  299. * @internal
  300. */
  301. this.effects = []
  302. /**
  303. * @internal
  304. */
  305. this.cleanups = []
  306. this.parent = activeEffectScope
  307. if (!detached && activeEffectScope) {
  308. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  309. this,
  310. ) - 1
  311. }
  312. }
  313. get active() {
  314. return this._active
  315. }
  316. run(fn) {
  317. if (this._active) {
  318. const currentEffectScope = activeEffectScope
  319. try {
  320. activeEffectScope = this
  321. return fn()
  322. }
  323. finally {
  324. activeEffectScope = currentEffectScope
  325. }
  326. }
  327. else {
  328. warn$2(`cannot run an inactive effect scope.`)
  329. }
  330. }
  331. /**
  332. * This should only be called on non-detached scopes
  333. * @internal
  334. */
  335. on() {
  336. activeEffectScope = this
  337. }
  338. /**
  339. * This should only be called on non-detached scopes
  340. * @internal
  341. */
  342. off() {
  343. activeEffectScope = this.parent
  344. }
  345. stop(fromParent) {
  346. if (this._active) {
  347. let i, l
  348. for (i = 0, l = this.effects.length; i < l; i++)
  349. this.effects[i].stop()
  350. for (i = 0, l = this.cleanups.length; i < l; i++)
  351. this.cleanups[i]()
  352. if (this.scopes) {
  353. for (i = 0, l = this.scopes.length; i < l; i++)
  354. this.scopes[i].stop(true)
  355. }
  356. if (!this.detached && this.parent && !fromParent) {
  357. const last = this.parent.scopes.pop()
  358. if (last && last !== this) {
  359. this.parent.scopes[this.index] = last
  360. last.index = this.index
  361. }
  362. }
  363. this.parent = void 0
  364. this._active = false
  365. }
  366. }
  367. }
  368. function effectScope(detached) {
  369. return new EffectScope(detached)
  370. }
  371. function recordEffectScope(effect, scope = activeEffectScope) {
  372. if (scope && scope.active)
  373. scope.effects.push(effect)
  374. }
  375. function getCurrentScope() {
  376. return activeEffectScope
  377. }
  378. function onScopeDispose(fn) {
  379. if (activeEffectScope) {
  380. activeEffectScope.cleanups.push(fn)
  381. }
  382. else {
  383. warn$2(
  384. `onScopeDispose() is called when there is no active effect scope to be associated with.`,
  385. )
  386. }
  387. }
  388. let activeEffect
  389. class ReactiveEffect {
  390. constructor(fn, trigger, scheduler, scope) {
  391. this.fn = fn
  392. this.trigger = trigger
  393. this.scheduler = scheduler
  394. this.active = true
  395. this.deps = []
  396. /**
  397. * @internal
  398. */
  399. this._dirtyLevel = 4
  400. /**
  401. * @internal
  402. */
  403. this._trackId = 0
  404. /**
  405. * @internal
  406. */
  407. this._runnings = 0
  408. /**
  409. * @internal
  410. */
  411. this._shouldSchedule = false
  412. /**
  413. * @internal
  414. */
  415. this._depsLength = 0
  416. recordEffectScope(this, scope)
  417. }
  418. get dirty() {
  419. if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
  420. this._dirtyLevel = 1
  421. pauseTracking()
  422. for (let i = 0; i < this._depsLength; i++) {
  423. const dep = this.deps[i]
  424. if (dep.computed) {
  425. triggerComputed(dep.computed)
  426. if (this._dirtyLevel >= 4)
  427. break
  428. }
  429. }
  430. if (this._dirtyLevel === 1)
  431. this._dirtyLevel = 0
  432. resetTracking()
  433. }
  434. return this._dirtyLevel >= 4
  435. }
  436. set dirty(v) {
  437. this._dirtyLevel = v ? 4 : 0
  438. }
  439. run() {
  440. this._dirtyLevel = 0
  441. if (!this.active)
  442. return this.fn()
  443. const lastShouldTrack = shouldTrack
  444. const lastEffect = activeEffect
  445. try {
  446. shouldTrack = true
  447. activeEffect = this
  448. this._runnings++
  449. preCleanupEffect(this)
  450. return this.fn()
  451. }
  452. finally {
  453. postCleanupEffect(this)
  454. this._runnings--
  455. activeEffect = lastEffect
  456. shouldTrack = lastShouldTrack
  457. }
  458. }
  459. stop() {
  460. if (this.active) {
  461. preCleanupEffect(this)
  462. postCleanupEffect(this)
  463. this.onStop && this.onStop()
  464. this.active = false
  465. }
  466. }
  467. }
  468. function triggerComputed(computed) {
  469. return computed.value
  470. }
  471. function preCleanupEffect(effect2) {
  472. effect2._trackId++
  473. effect2._depsLength = 0
  474. }
  475. function postCleanupEffect(effect2) {
  476. if (effect2.deps.length > effect2._depsLength) {
  477. for (let i = effect2._depsLength; i < effect2.deps.length; i++)
  478. cleanupDepEffect(effect2.deps[i], effect2)
  479. effect2.deps.length = effect2._depsLength
  480. }
  481. }
  482. function cleanupDepEffect(dep, effect2) {
  483. const trackId = dep.get(effect2)
  484. if (trackId !== void 0 && effect2._trackId !== trackId) {
  485. dep.delete(effect2)
  486. if (dep.size === 0)
  487. dep.cleanup()
  488. }
  489. }
  490. function effect(fn, options) {
  491. if (fn.effect instanceof ReactiveEffect)
  492. fn = fn.effect.fn
  493. const _effect = new ReactiveEffect(fn, NOOP, () => {
  494. if (_effect.dirty)
  495. _effect.run()
  496. })
  497. if (options) {
  498. extend(_effect, options)
  499. if (options.scope)
  500. recordEffectScope(_effect, options.scope)
  501. }
  502. if (!options || !options.lazy)
  503. _effect.run()
  504. const runner = _effect.run.bind(_effect)
  505. runner.effect = _effect
  506. return runner
  507. }
  508. function stop(runner) {
  509. runner.effect.stop()
  510. }
  511. let shouldTrack = true
  512. let pauseScheduleStack = 0
  513. const trackStack = []
  514. function pauseTracking() {
  515. trackStack.push(shouldTrack)
  516. shouldTrack = false
  517. }
  518. function resetTracking() {
  519. const last = trackStack.pop()
  520. shouldTrack = last === void 0 ? true : last
  521. }
  522. function pauseScheduling() {
  523. pauseScheduleStack++
  524. }
  525. function resetScheduling() {
  526. pauseScheduleStack--
  527. while (!pauseScheduleStack && queueEffectSchedulers.length)
  528. queueEffectSchedulers.shift()()
  529. }
  530. function trackEffect(effect2, dep, debuggerEventExtraInfo) {
  531. let _a
  532. if (dep.get(effect2) !== effect2._trackId) {
  533. dep.set(effect2, effect2._trackId)
  534. const oldDep = effect2.deps[effect2._depsLength]
  535. if (oldDep !== dep) {
  536. if (oldDep)
  537. cleanupDepEffect(oldDep, effect2)
  538. effect2.deps[effect2._depsLength++] = dep
  539. }
  540. else {
  541. effect2._depsLength++
  542. }
  543. {
  544. (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo))
  545. }
  546. }
  547. }
  548. const queueEffectSchedulers = []
  549. function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
  550. let _a
  551. pauseScheduling()
  552. for (const effect2 of dep.keys()) {
  553. let tracking
  554. if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  555. effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0)
  556. effect2._dirtyLevel = dirtyLevel
  557. }
  558. if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  559. {
  560. (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo))
  561. }
  562. effect2.trigger()
  563. if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
  564. effect2._shouldSchedule = false
  565. if (effect2.scheduler)
  566. queueEffectSchedulers.push(effect2.scheduler)
  567. }
  568. }
  569. }
  570. resetScheduling()
  571. }
  572. function createDep(cleanup, computed) {
  573. const dep = /* @__PURE__ */ new Map()
  574. dep.cleanup = cleanup
  575. dep.computed = computed
  576. return dep
  577. }
  578. const targetMap = /* @__PURE__ */ new WeakMap()
  579. const ITERATE_KEY = Symbol('iterate')
  580. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate')
  581. function track(target, type, key) {
  582. if (shouldTrack && activeEffect) {
  583. let depsMap = targetMap.get(target)
  584. if (!depsMap)
  585. targetMap.set(target, depsMap = /* @__PURE__ */ new Map())
  586. let dep = depsMap.get(key)
  587. if (!dep)
  588. depsMap.set(key, dep = createDep(() => depsMap.delete(key)))
  589. trackEffect(
  590. activeEffect,
  591. dep,
  592. {
  593. target,
  594. type,
  595. key,
  596. },
  597. )
  598. }
  599. }
  600. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  601. const depsMap = targetMap.get(target)
  602. if (!depsMap)
  603. return
  604. let deps = []
  605. if (type === 'clear') {
  606. deps = [...depsMap.values()]
  607. }
  608. else if (key === 'length' && isArray(target)) {
  609. const newLength = Number(newValue)
  610. depsMap.forEach((dep, key2) => {
  611. if (key2 === 'length' || !isSymbol(key2) && key2 >= newLength)
  612. deps.push(dep)
  613. })
  614. }
  615. else {
  616. if (key !== void 0)
  617. deps.push(depsMap.get(key))
  618. switch (type) {
  619. case 'add':
  620. if (!isArray(target)) {
  621. deps.push(depsMap.get(ITERATE_KEY))
  622. if (isMap(target))
  623. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY))
  624. }
  625. else if (isIntegerKey(key)) {
  626. deps.push(depsMap.get('length'))
  627. }
  628. break
  629. case 'delete':
  630. if (!isArray(target)) {
  631. deps.push(depsMap.get(ITERATE_KEY))
  632. if (isMap(target))
  633. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY))
  634. }
  635. break
  636. case 'set':
  637. if (isMap(target))
  638. deps.push(depsMap.get(ITERATE_KEY))
  639. break
  640. }
  641. }
  642. pauseScheduling()
  643. for (const dep of deps) {
  644. if (dep) {
  645. triggerEffects(
  646. dep,
  647. 4,
  648. {
  649. target,
  650. type,
  651. key,
  652. newValue,
  653. oldValue,
  654. oldTarget,
  655. },
  656. )
  657. }
  658. }
  659. resetScheduling()
  660. }
  661. function getDepFromReactive(object, key) {
  662. const depsMap = targetMap.get(object)
  663. return depsMap && depsMap.get(key)
  664. }
  665. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`)
  666. const builtInSymbols = new Set(
  667. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter(key => key !== 'arguments' && key !== 'caller').map(key => Symbol[key]).filter(isSymbol),
  668. )
  669. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations()
  670. function createArrayInstrumentations() {
  671. const instrumentations = {};
  672. ['includes', 'indexOf', 'lastIndexOf'].forEach((key) => {
  673. instrumentations[key] = function (...args) {
  674. const arr = toRaw(this)
  675. for (let i = 0, l = this.length; i < l; i++)
  676. track(arr, 'get', `${i}`)
  677. const res = arr[key](...args)
  678. if (res === -1 || res === false)
  679. return arr[key](...args.map(toRaw))
  680. else
  681. return res
  682. }
  683. });
  684. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach((key) => {
  685. instrumentations[key] = function (...args) {
  686. pauseTracking()
  687. pauseScheduling()
  688. const res = toRaw(this)[key].apply(this, args)
  689. resetScheduling()
  690. resetTracking()
  691. return res
  692. }
  693. })
  694. return instrumentations
  695. }
  696. function hasOwnProperty(key) {
  697. if (!isSymbol(key))
  698. key = String(key)
  699. const obj = toRaw(this)
  700. track(obj, 'has', key)
  701. return obj.hasOwnProperty(key)
  702. }
  703. class BaseReactiveHandler {
  704. constructor(_isReadonly = false, _isShallow = false) {
  705. this._isReadonly = _isReadonly
  706. this._isShallow = _isShallow
  707. }
  708. get(target, key, receiver) {
  709. const isReadonly2 = this._isReadonly; const isShallow2 = this._isShallow
  710. if (key === '__v_isReactive') {
  711. return !isReadonly2
  712. }
  713. else if (key === '__v_isReadonly') {
  714. return isReadonly2
  715. }
  716. else if (key === '__v_isShallow') {
  717. return isShallow2
  718. }
  719. else if (key === '__v_raw') {
  720. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) // receiver is not the reactive proxy, but has the same prototype
  721. // this means the reciever is a user proxy of the reactive proxy
  722. || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver))
  723. return target
  724. return
  725. }
  726. const targetIsArray = isArray(target)
  727. if (!isReadonly2) {
  728. if (targetIsArray && hasOwn(arrayInstrumentations, key))
  729. return Reflect.get(arrayInstrumentations, key, receiver)
  730. if (key === 'hasOwnProperty')
  731. return hasOwnProperty
  732. }
  733. const res = Reflect.get(target, key, receiver)
  734. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key))
  735. return res
  736. if (!isReadonly2)
  737. track(target, 'get', key)
  738. if (isShallow2)
  739. return res
  740. if (isRef(res))
  741. return targetIsArray && isIntegerKey(key) ? res : res.value
  742. if (isObject(res))
  743. return isReadonly2 ? readonly(res) : reactive(res)
  744. return res
  745. }
  746. }
  747. class MutableReactiveHandler extends BaseReactiveHandler {
  748. constructor(isShallow2 = false) {
  749. super(false, isShallow2)
  750. }
  751. set(target, key, value, receiver) {
  752. let oldValue = target[key]
  753. if (!this._isShallow) {
  754. const isOldValueReadonly = isReadonly(oldValue)
  755. if (!isShallow(value) && !isReadonly(value)) {
  756. oldValue = toRaw(oldValue)
  757. value = toRaw(value)
  758. }
  759. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  760. if (isOldValueReadonly) {
  761. return false
  762. }
  763. else {
  764. oldValue.value = value
  765. return true
  766. }
  767. }
  768. }
  769. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key)
  770. const result = Reflect.set(target, key, value, receiver)
  771. if (target === toRaw(receiver)) {
  772. if (!hadKey)
  773. trigger(target, 'add', key, value)
  774. else if (hasChanged(value, oldValue))
  775. trigger(target, 'set', key, value, oldValue)
  776. }
  777. return result
  778. }
  779. deleteProperty(target, key) {
  780. const hadKey = hasOwn(target, key)
  781. const oldValue = target[key]
  782. const result = Reflect.deleteProperty(target, key)
  783. if (result && hadKey)
  784. trigger(target, 'delete', key, void 0, oldValue)
  785. return result
  786. }
  787. has(target, key) {
  788. const result = Reflect.has(target, key)
  789. if (!isSymbol(key) || !builtInSymbols.has(key))
  790. track(target, 'has', key)
  791. return result
  792. }
  793. ownKeys(target) {
  794. track(
  795. target,
  796. 'iterate',
  797. isArray(target) ? 'length' : ITERATE_KEY,
  798. )
  799. return Reflect.ownKeys(target)
  800. }
  801. }
  802. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  803. constructor(isShallow2 = false) {
  804. super(true, isShallow2)
  805. }
  806. set(target, key) {
  807. {
  808. warn$2(
  809. `Set operation on key "${String(key)}" failed: target is readonly.`,
  810. target,
  811. )
  812. }
  813. return true
  814. }
  815. deleteProperty(target, key) {
  816. {
  817. warn$2(
  818. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  819. target,
  820. )
  821. }
  822. return true
  823. }
  824. }
  825. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler()
  826. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler()
  827. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
  828. true,
  829. )
  830. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true)
  831. const toShallow = value => value
  832. const getProto = v => Reflect.getPrototypeOf(v)
  833. function get(target, key, isReadonly = false, isShallow = false) {
  834. target = target.__v_raw
  835. const rawTarget = toRaw(target)
  836. const rawKey = toRaw(key)
  837. if (!isReadonly) {
  838. if (hasChanged(key, rawKey))
  839. track(rawTarget, 'get', key)
  840. track(rawTarget, 'get', rawKey)
  841. }
  842. const { has: has2 } = getProto(rawTarget)
  843. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  844. if (has2.call(rawTarget, key))
  845. return wrap(target.get(key))
  846. else if (has2.call(rawTarget, rawKey))
  847. return wrap(target.get(rawKey))
  848. else if (target !== rawTarget)
  849. target.get(key)
  850. }
  851. function has(key, isReadonly = false) {
  852. const target = this.__v_raw
  853. const rawTarget = toRaw(target)
  854. const rawKey = toRaw(key)
  855. if (!isReadonly) {
  856. if (hasChanged(key, rawKey))
  857. track(rawTarget, 'has', key)
  858. track(rawTarget, 'has', rawKey)
  859. }
  860. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey)
  861. }
  862. function size(target, isReadonly = false) {
  863. target = target.__v_raw
  864. !isReadonly && track(toRaw(target), 'iterate', ITERATE_KEY)
  865. return Reflect.get(target, 'size', target)
  866. }
  867. function add(value) {
  868. value = toRaw(value)
  869. const target = toRaw(this)
  870. const proto = getProto(target)
  871. const hadKey = proto.has.call(target, value)
  872. if (!hadKey) {
  873. target.add(value)
  874. trigger(target, 'add', value, value)
  875. }
  876. return this
  877. }
  878. function set(key, value) {
  879. value = toRaw(value)
  880. const target = toRaw(this)
  881. const { has: has2, get: get2 } = getProto(target)
  882. let hadKey = has2.call(target, key)
  883. if (!hadKey) {
  884. key = toRaw(key)
  885. hadKey = has2.call(target, key)
  886. }
  887. else {
  888. checkIdentityKeys(target, has2, key)
  889. }
  890. const oldValue = get2.call(target, key)
  891. target.set(key, value)
  892. if (!hadKey)
  893. trigger(target, 'add', key, value)
  894. else if (hasChanged(value, oldValue))
  895. trigger(target, 'set', key, value, oldValue)
  896. return this
  897. }
  898. function deleteEntry(key) {
  899. const target = toRaw(this)
  900. const { has: has2, get: get2 } = getProto(target)
  901. let hadKey = has2.call(target, key)
  902. if (!hadKey) {
  903. key = toRaw(key)
  904. hadKey = has2.call(target, key)
  905. }
  906. else {
  907. checkIdentityKeys(target, has2, key)
  908. }
  909. const oldValue = get2 ? get2.call(target, key) : void 0
  910. const result = target.delete(key)
  911. if (hadKey)
  912. trigger(target, 'delete', key, void 0, oldValue)
  913. return result
  914. }
  915. function clear() {
  916. const target = toRaw(this)
  917. const hadItems = target.size !== 0
  918. const oldTarget = isMap(target) ? new Map(target) : new Set(target)
  919. const result = target.clear()
  920. if (hadItems)
  921. trigger(target, 'clear', void 0, void 0, oldTarget)
  922. return result
  923. }
  924. function createForEach(isReadonly, isShallow) {
  925. return function forEach(callback, thisArg) {
  926. const observed = this
  927. const target = observed.__v_raw
  928. const rawTarget = toRaw(target)
  929. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  930. !isReadonly && track(rawTarget, 'iterate', ITERATE_KEY)
  931. return target.forEach((value, key) => {
  932. return callback.call(thisArg, wrap(value), wrap(key), observed)
  933. })
  934. }
  935. }
  936. function createIterableMethod(method, isReadonly, isShallow) {
  937. return function (...args) {
  938. const target = this.__v_raw
  939. const rawTarget = toRaw(target)
  940. const targetIsMap = isMap(rawTarget)
  941. const isPair = method === 'entries' || method === Symbol.iterator && targetIsMap
  942. const isKeyOnly = method === 'keys' && targetIsMap
  943. const innerIterator = target[method](...args)
  944. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  945. !isReadonly && track(
  946. rawTarget,
  947. 'iterate',
  948. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY,
  949. )
  950. return {
  951. // iterator protocol
  952. next() {
  953. const { value, done } = innerIterator.next()
  954. return done
  955. ? { value, done }
  956. : {
  957. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  958. done,
  959. }
  960. },
  961. // iterable protocol
  962. [Symbol.iterator]() {
  963. return this
  964. },
  965. }
  966. }
  967. }
  968. function createReadonlyMethod(type) {
  969. return function (...args) {
  970. {
  971. const key = args[0] ? `on key "${args[0]}" ` : ``
  972. warn$2(
  973. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  974. toRaw(this),
  975. )
  976. }
  977. return type === 'delete' ? false : type === 'clear' ? void 0 : this
  978. }
  979. }
  980. function createInstrumentations() {
  981. const mutableInstrumentations2 = {
  982. get(key) {
  983. return get(this, key)
  984. },
  985. get size() {
  986. return size(this)
  987. },
  988. has,
  989. add,
  990. set,
  991. delete: deleteEntry,
  992. clear,
  993. forEach: createForEach(false, false),
  994. }
  995. const shallowInstrumentations2 = {
  996. get(key) {
  997. return get(this, key, false, true)
  998. },
  999. get size() {
  1000. return size(this)
  1001. },
  1002. has,
  1003. add,
  1004. set,
  1005. delete: deleteEntry,
  1006. clear,
  1007. forEach: createForEach(false, true),
  1008. }
  1009. const readonlyInstrumentations2 = {
  1010. get(key) {
  1011. return get(this, key, true)
  1012. },
  1013. get size() {
  1014. return size(this, true)
  1015. },
  1016. has(key) {
  1017. return has.call(this, key, true)
  1018. },
  1019. add: createReadonlyMethod('add'),
  1020. set: createReadonlyMethod('set'),
  1021. delete: createReadonlyMethod('delete'),
  1022. clear: createReadonlyMethod('clear'),
  1023. forEach: createForEach(true, false),
  1024. }
  1025. const shallowReadonlyInstrumentations2 = {
  1026. get(key) {
  1027. return get(this, key, true, true)
  1028. },
  1029. get size() {
  1030. return size(this, true)
  1031. },
  1032. has(key) {
  1033. return has.call(this, key, true)
  1034. },
  1035. add: createReadonlyMethod('add'),
  1036. set: createReadonlyMethod('set'),
  1037. delete: createReadonlyMethod('delete'),
  1038. clear: createReadonlyMethod('clear'),
  1039. forEach: createForEach(true, true),
  1040. }
  1041. const iteratorMethods = [
  1042. 'keys',
  1043. 'values',
  1044. 'entries',
  1045. Symbol.iterator,
  1046. ]
  1047. iteratorMethods.forEach((method) => {
  1048. mutableInstrumentations2[method] = createIterableMethod(method, false, false)
  1049. readonlyInstrumentations2[method] = createIterableMethod(method, true, false)
  1050. shallowInstrumentations2[method] = createIterableMethod(method, false, true)
  1051. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  1052. method,
  1053. true,
  1054. true,
  1055. )
  1056. })
  1057. return [
  1058. mutableInstrumentations2,
  1059. readonlyInstrumentations2,
  1060. shallowInstrumentations2,
  1061. shallowReadonlyInstrumentations2,
  1062. ]
  1063. }
  1064. const [
  1065. mutableInstrumentations,
  1066. readonlyInstrumentations,
  1067. shallowInstrumentations,
  1068. shallowReadonlyInstrumentations,
  1069. ] = /* @__PURE__ */ createInstrumentations()
  1070. function createInstrumentationGetter(isReadonly, shallow) {
  1071. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations
  1072. return (target, key, receiver) => {
  1073. if (key === '__v_isReactive')
  1074. return !isReadonly
  1075. else if (key === '__v_isReadonly')
  1076. return isReadonly
  1077. else if (key === '__v_raw')
  1078. return target
  1079. return Reflect.get(
  1080. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1081. key,
  1082. receiver,
  1083. )
  1084. }
  1085. }
  1086. const mutableCollectionHandlers = {
  1087. get: /* @__PURE__ */ createInstrumentationGetter(false, false),
  1088. }
  1089. const shallowCollectionHandlers = {
  1090. get: /* @__PURE__ */ createInstrumentationGetter(false, true),
  1091. }
  1092. const readonlyCollectionHandlers = {
  1093. get: /* @__PURE__ */ createInstrumentationGetter(true, false),
  1094. }
  1095. const shallowReadonlyCollectionHandlers = {
  1096. get: /* @__PURE__ */ createInstrumentationGetter(true, true),
  1097. }
  1098. function checkIdentityKeys(target, has2, key) {
  1099. const rawKey = toRaw(key)
  1100. if (rawKey !== key && has2.call(target, rawKey)) {
  1101. const type = toRawType(target)
  1102. warn$2(
  1103. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`,
  1104. )
  1105. }
  1106. }
  1107. const reactiveMap = /* @__PURE__ */ new WeakMap()
  1108. const shallowReactiveMap = /* @__PURE__ */ new WeakMap()
  1109. const readonlyMap = /* @__PURE__ */ new WeakMap()
  1110. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap()
  1111. function targetTypeMap(rawType) {
  1112. switch (rawType) {
  1113. case 'Object':
  1114. case 'Array':
  1115. return 1 /* COMMON */
  1116. case 'Map':
  1117. case 'Set':
  1118. case 'WeakMap':
  1119. case 'WeakSet':
  1120. return 2 /* COLLECTION */
  1121. default:
  1122. return 0 /* INVALID */
  1123. }
  1124. }
  1125. function getTargetType(value) {
  1126. return value.__v_skip || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value))
  1127. }
  1128. function reactive(target) {
  1129. if (isReadonly(target))
  1130. return target
  1131. return createReactiveObject(
  1132. target,
  1133. false,
  1134. mutableHandlers,
  1135. mutableCollectionHandlers,
  1136. reactiveMap,
  1137. )
  1138. }
  1139. function shallowReactive(target) {
  1140. return createReactiveObject(
  1141. target,
  1142. false,
  1143. shallowReactiveHandlers,
  1144. shallowCollectionHandlers,
  1145. shallowReactiveMap,
  1146. )
  1147. }
  1148. function readonly(target) {
  1149. return createReactiveObject(
  1150. target,
  1151. true,
  1152. readonlyHandlers,
  1153. readonlyCollectionHandlers,
  1154. readonlyMap,
  1155. )
  1156. }
  1157. function shallowReadonly(target) {
  1158. return createReactiveObject(
  1159. target,
  1160. true,
  1161. shallowReadonlyHandlers,
  1162. shallowReadonlyCollectionHandlers,
  1163. shallowReadonlyMap,
  1164. )
  1165. }
  1166. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1167. if (!isObject(target)) {
  1168. {
  1169. warn$2(`value cannot be made reactive: ${String(target)}`)
  1170. }
  1171. return target
  1172. }
  1173. if (target.__v_raw && !(isReadonly2 && target.__v_isReactive))
  1174. return target
  1175. const existingProxy = proxyMap.get(target)
  1176. if (existingProxy)
  1177. return existingProxy
  1178. const targetType = getTargetType(target)
  1179. if (targetType === 0 /* INVALID */)
  1180. return target
  1181. const proxy = new Proxy(
  1182. target,
  1183. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers,
  1184. )
  1185. proxyMap.set(target, proxy)
  1186. return proxy
  1187. }
  1188. function isReactive(value) {
  1189. if (isReadonly(value))
  1190. return isReactive(value.__v_raw)
  1191. return !!(value && value.__v_isReactive)
  1192. }
  1193. function isReadonly(value) {
  1194. return !!(value && value.__v_isReadonly)
  1195. }
  1196. function isShallow(value) {
  1197. return !!(value && value.__v_isShallow)
  1198. }
  1199. function isProxy(value) {
  1200. return value ? !!value.__v_raw : false
  1201. }
  1202. function toRaw(observed) {
  1203. const raw = observed && observed.__v_raw
  1204. return raw ? toRaw(raw) : observed
  1205. }
  1206. function markRaw(value) {
  1207. if (Object.isExtensible(value))
  1208. def(value, '__v_skip', true)
  1209. return value
  1210. }
  1211. const toReactive = value => isObject(value) ? reactive(value) : value
  1212. const toReadonly = value => isObject(value) ? readonly(value) : value
  1213. const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`
  1214. class ComputedRefImpl {
  1215. constructor(getter, _setter, isReadonly, isSSR) {
  1216. this.getter = getter
  1217. this._setter = _setter
  1218. this.dep = void 0
  1219. this.__v_isRef = true
  1220. this.__v_isReadonly = false
  1221. this.effect = new ReactiveEffect(
  1222. () => getter(this._value),
  1223. () => triggerRefValue(
  1224. this,
  1225. this.effect._dirtyLevel === 2 ? 2 : 3,
  1226. ),
  1227. )
  1228. this.effect.computed = this
  1229. this.effect.active = this._cacheable = !isSSR
  1230. this.__v_isReadonly = isReadonly
  1231. }
  1232. get value() {
  1233. const self = toRaw(this)
  1234. if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run()))
  1235. triggerRefValue(self, 4)
  1236. trackRefValue(self)
  1237. if (self.effect._dirtyLevel >= 2) {
  1238. if (this._warnRecursive) {
  1239. warn$2(COMPUTED_SIDE_EFFECT_WARN, `
  1240. getter: `, this.getter)
  1241. }
  1242. triggerRefValue(self, 2)
  1243. }
  1244. return self._value
  1245. }
  1246. set value(newValue) {
  1247. this._setter(newValue)
  1248. }
  1249. // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
  1250. get _dirty() {
  1251. return this.effect.dirty
  1252. }
  1253. set _dirty(v) {
  1254. this.effect.dirty = v
  1255. }
  1256. // #endregion
  1257. }
  1258. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  1259. let getter
  1260. let setter
  1261. const onlyGetter = isFunction(getterOrOptions)
  1262. if (onlyGetter) {
  1263. getter = getterOrOptions
  1264. setter = () => {
  1265. warn$2('Write operation failed: computed value is readonly')
  1266. }
  1267. }
  1268. else {
  1269. getter = getterOrOptions.get
  1270. setter = getterOrOptions.set
  1271. }
  1272. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR)
  1273. if (debugOptions && !isSSR) {
  1274. cRef.effect.onTrack = debugOptions.onTrack
  1275. cRef.effect.onTrigger = debugOptions.onTrigger
  1276. }
  1277. return cRef
  1278. }
  1279. function trackRefValue(ref2) {
  1280. let _a
  1281. if (shouldTrack && activeEffect) {
  1282. ref2 = toRaw(ref2)
  1283. trackEffect(
  1284. activeEffect,
  1285. (_a = ref2.dep) != null
  1286. ? _a
  1287. : ref2.dep = createDep(
  1288. () => ref2.dep = void 0,
  1289. ref2 instanceof ComputedRefImpl ? ref2 : void 0,
  1290. ),
  1291. {
  1292. target: ref2,
  1293. type: 'get',
  1294. key: 'value',
  1295. },
  1296. )
  1297. }
  1298. }
  1299. function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
  1300. ref2 = toRaw(ref2)
  1301. const dep = ref2.dep
  1302. if (dep) {
  1303. triggerEffects(
  1304. dep,
  1305. dirtyLevel,
  1306. {
  1307. target: ref2,
  1308. type: 'set',
  1309. key: 'value',
  1310. newValue: newVal,
  1311. },
  1312. )
  1313. }
  1314. }
  1315. function isRef(r) {
  1316. return !!(r && r.__v_isRef === true)
  1317. }
  1318. function ref(value) {
  1319. return createRef(value, false)
  1320. }
  1321. function shallowRef(value) {
  1322. return createRef(value, true)
  1323. }
  1324. function createRef(rawValue, shallow) {
  1325. if (isRef(rawValue))
  1326. return rawValue
  1327. return new RefImpl(rawValue, shallow)
  1328. }
  1329. class RefImpl {
  1330. constructor(value, __v_isShallow) {
  1331. this.__v_isShallow = __v_isShallow
  1332. this.dep = void 0
  1333. this.__v_isRef = true
  1334. this._rawValue = __v_isShallow ? value : toRaw(value)
  1335. this._value = __v_isShallow ? value : toReactive(value)
  1336. }
  1337. get value() {
  1338. trackRefValue(this)
  1339. return this._value
  1340. }
  1341. set value(newVal) {
  1342. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal)
  1343. newVal = useDirectValue ? newVal : toRaw(newVal)
  1344. if (hasChanged(newVal, this._rawValue)) {
  1345. this._rawValue = newVal
  1346. this._value = useDirectValue ? newVal : toReactive(newVal)
  1347. triggerRefValue(this, 4, newVal)
  1348. }
  1349. }
  1350. }
  1351. function triggerRef(ref2) {
  1352. triggerRefValue(ref2, 4, ref2.value)
  1353. }
  1354. function unref(ref2) {
  1355. return isRef(ref2) ? ref2.value : ref2
  1356. }
  1357. function toValue(source) {
  1358. return isFunction(source) ? source() : unref(source)
  1359. }
  1360. const shallowUnwrapHandlers = {
  1361. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1362. set: (target, key, value, receiver) => {
  1363. const oldValue = target[key]
  1364. if (isRef(oldValue) && !isRef(value)) {
  1365. oldValue.value = value
  1366. return true
  1367. }
  1368. else {
  1369. return Reflect.set(target, key, value, receiver)
  1370. }
  1371. },
  1372. }
  1373. function proxyRefs(objectWithRefs) {
  1374. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers)
  1375. }
  1376. class CustomRefImpl {
  1377. constructor(factory) {
  1378. this.dep = void 0
  1379. this.__v_isRef = true
  1380. const { get, set } = factory(
  1381. () => trackRefValue(this),
  1382. () => triggerRefValue(this),
  1383. )
  1384. this._get = get
  1385. this._set = set
  1386. }
  1387. get value() {
  1388. return this._get()
  1389. }
  1390. set value(newVal) {
  1391. this._set(newVal)
  1392. }
  1393. }
  1394. function customRef(factory) {
  1395. return new CustomRefImpl(factory)
  1396. }
  1397. function toRefs(object) {
  1398. if (!isProxy(object))
  1399. warn$2(`toRefs() expects a reactive object but received a plain one.`)
  1400. const ret = isArray(object) ? Array.from({ length: object.length }) : {}
  1401. for (const key in object)
  1402. ret[key] = propertyToRef(object, key)
  1403. return ret
  1404. }
  1405. class ObjectRefImpl {
  1406. constructor(_object, _key, _defaultValue) {
  1407. this._object = _object
  1408. this._key = _key
  1409. this._defaultValue = _defaultValue
  1410. this.__v_isRef = true
  1411. }
  1412. get value() {
  1413. const val = this._object[this._key]
  1414. return val === void 0 ? this._defaultValue : val
  1415. }
  1416. set value(newVal) {
  1417. this._object[this._key] = newVal
  1418. }
  1419. get dep() {
  1420. return getDepFromReactive(toRaw(this._object), this._key)
  1421. }
  1422. }
  1423. class GetterRefImpl {
  1424. constructor(_getter) {
  1425. this._getter = _getter
  1426. this.__v_isRef = true
  1427. this.__v_isReadonly = true
  1428. }
  1429. get value() {
  1430. return this._getter()
  1431. }
  1432. }
  1433. function toRef(source, key, defaultValue) {
  1434. if (isRef(source))
  1435. return source
  1436. else if (isFunction(source))
  1437. return new GetterRefImpl(source)
  1438. else if (isObject(source) && arguments.length > 1)
  1439. return propertyToRef(source, key, defaultValue)
  1440. else
  1441. return ref(source)
  1442. }
  1443. function propertyToRef(source, key, defaultValue) {
  1444. const val = source[key]
  1445. return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue)
  1446. }
  1447. const TrackOpTypes = {
  1448. GET: 'get',
  1449. HAS: 'has',
  1450. ITERATE: 'iterate',
  1451. }
  1452. const TriggerOpTypes = {
  1453. SET: 'set',
  1454. ADD: 'add',
  1455. DELETE: 'delete',
  1456. CLEAR: 'clear',
  1457. }
  1458. const stack = []
  1459. function pushWarningContext(vnode) {
  1460. stack.push(vnode)
  1461. }
  1462. function popWarningContext() {
  1463. stack.pop()
  1464. }
  1465. function warn$1(msg, ...args) {
  1466. pauseTracking()
  1467. const instance = stack.length ? stack[stack.length - 1].component : null
  1468. const appWarnHandler = instance && instance.appContext.config.warnHandler
  1469. const trace = getComponentTrace()
  1470. if (appWarnHandler) {
  1471. callWithErrorHandling(
  1472. appWarnHandler,
  1473. instance,
  1474. 11,
  1475. [
  1476. msg + args.map((a) => {
  1477. let _a, _b
  1478. return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a)
  1479. }).join(''),
  1480. instance && instance.proxy,
  1481. trace.map(
  1482. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`,
  1483. ).join('\n'),
  1484. trace,
  1485. ],
  1486. )
  1487. }
  1488. else {
  1489. const warnArgs = [`[Vue warn]: ${msg}`, ...args]
  1490. if (trace.length // avoid spamming console during tests
  1491. && true) {
  1492. warnArgs.push(`
  1493. `, ...formatTrace(trace))
  1494. }
  1495. console.warn(...warnArgs)
  1496. }
  1497. resetTracking()
  1498. }
  1499. function getComponentTrace() {
  1500. let currentVNode = stack[stack.length - 1]
  1501. if (!currentVNode)
  1502. return []
  1503. const normalizedStack = []
  1504. while (currentVNode) {
  1505. const last = normalizedStack[0]
  1506. if (last && last.vnode === currentVNode) {
  1507. last.recurseCount++
  1508. }
  1509. else {
  1510. normalizedStack.push({
  1511. vnode: currentVNode,
  1512. recurseCount: 0,
  1513. })
  1514. }
  1515. const parentInstance = currentVNode.component && currentVNode.component.parent
  1516. currentVNode = parentInstance && parentInstance.vnode
  1517. }
  1518. return normalizedStack
  1519. }
  1520. function formatTrace(trace) {
  1521. const logs = []
  1522. trace.forEach((entry, i) => {
  1523. logs.push(...i === 0
  1524. ? []
  1525. : [`
  1526. `], ...formatTraceEntry(entry))
  1527. })
  1528. return logs
  1529. }
  1530. function formatTraceEntry({ vnode, recurseCount }) {
  1531. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``
  1532. const isRoot = vnode.component ? vnode.component.parent == null : false
  1533. const open = ` at <${formatComponentName(
  1534. vnode.component,
  1535. vnode.type,
  1536. isRoot,
  1537. )}`
  1538. const close = `>${postfix}`
  1539. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close]
  1540. }
  1541. function formatProps(props) {
  1542. const res = []
  1543. const keys = Object.keys(props)
  1544. keys.slice(0, 3).forEach((key) => {
  1545. res.push(...formatProp(key, props[key]))
  1546. })
  1547. if (keys.length > 3)
  1548. res.push(` ...`)
  1549. return res
  1550. }
  1551. function formatProp(key, value, raw) {
  1552. if (isString(value)) {
  1553. value = JSON.stringify(value)
  1554. return raw ? value : [`${key}=${value}`]
  1555. }
  1556. else if (typeof value === 'number' || typeof value === 'boolean' || value == null) {
  1557. return raw ? value : [`${key}=${value}`]
  1558. }
  1559. else if (isRef(value)) {
  1560. value = formatProp(key, toRaw(value.value), true)
  1561. return raw ? value : [`${key}=Ref<`, value, `>`]
  1562. }
  1563. else if (isFunction(value)) {
  1564. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]
  1565. }
  1566. else {
  1567. value = toRaw(value)
  1568. return raw ? value : [`${key}=`, value]
  1569. }
  1570. }
  1571. function assertNumber(val, type) {
  1572. if (val === void 0) {
  1573. }
  1574. else if (typeof val !== 'number') {
  1575. warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`)
  1576. }
  1577. else if (isNaN(val)) {
  1578. warn$1(`${type} is NaN - the duration expression might be incorrect.`)
  1579. }
  1580. }
  1581. const ErrorCodes = {
  1582. SETUP_FUNCTION: 0,
  1583. 0: 'SETUP_FUNCTION',
  1584. RENDER_FUNCTION: 1,
  1585. 1: 'RENDER_FUNCTION',
  1586. WATCH_GETTER: 2,
  1587. 2: 'WATCH_GETTER',
  1588. WATCH_CALLBACK: 3,
  1589. 3: 'WATCH_CALLBACK',
  1590. WATCH_CLEANUP: 4,
  1591. 4: 'WATCH_CLEANUP',
  1592. NATIVE_EVENT_HANDLER: 5,
  1593. 5: 'NATIVE_EVENT_HANDLER',
  1594. COMPONENT_EVENT_HANDLER: 6,
  1595. 6: 'COMPONENT_EVENT_HANDLER',
  1596. VNODE_HOOK: 7,
  1597. 7: 'VNODE_HOOK',
  1598. DIRECTIVE_HOOK: 8,
  1599. 8: 'DIRECTIVE_HOOK',
  1600. TRANSITION_HOOK: 9,
  1601. 9: 'TRANSITION_HOOK',
  1602. APP_ERROR_HANDLER: 10,
  1603. 10: 'APP_ERROR_HANDLER',
  1604. APP_WARN_HANDLER: 11,
  1605. 11: 'APP_WARN_HANDLER',
  1606. FUNCTION_REF: 12,
  1607. 12: 'FUNCTION_REF',
  1608. ASYNC_COMPONENT_LOADER: 13,
  1609. 13: 'ASYNC_COMPONENT_LOADER',
  1610. SCHEDULER: 14,
  1611. 14: 'SCHEDULER',
  1612. }
  1613. const ErrorTypeStrings$1 = {
  1614. sp: 'serverPrefetch hook',
  1615. bc: 'beforeCreate hook',
  1616. c: 'created hook',
  1617. bm: 'beforeMount hook',
  1618. m: 'mounted hook',
  1619. bu: 'beforeUpdate hook',
  1620. u: 'updated',
  1621. bum: 'beforeUnmount hook',
  1622. um: 'unmounted hook',
  1623. a: 'activated hook',
  1624. da: 'deactivated hook',
  1625. ec: 'errorCaptured hook',
  1626. rtc: 'renderTracked hook',
  1627. rtg: 'renderTriggered hook',
  1628. 0: 'setup function',
  1629. 1: 'render function',
  1630. 2: 'watcher getter',
  1631. 3: 'watcher callback',
  1632. 4: 'watcher cleanup function',
  1633. 5: 'native event handler',
  1634. 6: 'component event handler',
  1635. 7: 'vnode hook',
  1636. 8: 'directive hook',
  1637. 9: 'transition hook',
  1638. 10: 'app errorHandler',
  1639. 11: 'app warnHandler',
  1640. 12: 'ref function',
  1641. 13: 'async component loader',
  1642. 14: 'scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .',
  1643. }
  1644. function callWithErrorHandling(fn, instance, type, args) {
  1645. try {
  1646. return args ? fn(...args) : fn()
  1647. }
  1648. catch (err) {
  1649. handleError(err, instance, type)
  1650. }
  1651. }
  1652. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1653. if (isFunction(fn)) {
  1654. const res = callWithErrorHandling(fn, instance, type, args)
  1655. if (res && isPromise(res)) {
  1656. res.catch((err) => {
  1657. handleError(err, instance, type)
  1658. })
  1659. }
  1660. return res
  1661. }
  1662. if (isArray(fn)) {
  1663. const values = []
  1664. for (let i = 0; i < fn.length; i++)
  1665. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args))
  1666. return values
  1667. }
  1668. else {
  1669. warn$1(
  1670. `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`,
  1671. )
  1672. }
  1673. }
  1674. function handleError(err, instance, type, throwInDev = true) {
  1675. const contextVNode = instance ? instance.vnode : null
  1676. if (instance) {
  1677. let cur = instance.parent
  1678. const exposedInstance = instance.proxy
  1679. const errorInfo = ErrorTypeStrings$1[type]
  1680. while (cur) {
  1681. const errorCapturedHooks = cur.ec
  1682. if (errorCapturedHooks) {
  1683. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1684. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false)
  1685. return
  1686. }
  1687. }
  1688. cur = cur.parent
  1689. }
  1690. const appErrorHandler = instance.appContext.config.errorHandler
  1691. if (appErrorHandler) {
  1692. pauseTracking()
  1693. callWithErrorHandling(
  1694. appErrorHandler,
  1695. null,
  1696. 10,
  1697. [err, exposedInstance, errorInfo],
  1698. )
  1699. resetTracking()
  1700. return
  1701. }
  1702. }
  1703. logError(err, type, contextVNode, throwInDev)
  1704. }
  1705. function logError(err, type, contextVNode, throwInDev = true) {
  1706. {
  1707. const info = ErrorTypeStrings$1[type]
  1708. if (contextVNode)
  1709. pushWarningContext(contextVNode)
  1710. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`)
  1711. if (contextVNode)
  1712. popWarningContext()
  1713. if (throwInDev)
  1714. throw err
  1715. else
  1716. console.error(err)
  1717. }
  1718. }
  1719. let isFlushing = false
  1720. let isFlushPending = false
  1721. const queue = []
  1722. let flushIndex = 0
  1723. const pendingPostFlushCbs = []
  1724. let activePostFlushCbs = null
  1725. let postFlushIndex = 0
  1726. const resolvedPromise = /* @__PURE__ */ Promise.resolve()
  1727. let currentFlushPromise = null
  1728. const RECURSION_LIMIT = 100
  1729. function nextTick(fn) {
  1730. const p = currentFlushPromise || resolvedPromise
  1731. return fn ? p.then(this ? fn.bind(this) : fn) : p
  1732. }
  1733. function findInsertionIndex(id) {
  1734. let start = flushIndex + 1
  1735. let end = queue.length
  1736. while (start < end) {
  1737. const middle = start + end >>> 1
  1738. const middleJob = queue[middle]
  1739. const middleJobId = getId(middleJob)
  1740. if (middleJobId < id || middleJobId === id && middleJob.pre)
  1741. start = middle + 1
  1742. else
  1743. end = middle
  1744. }
  1745. return start
  1746. }
  1747. function queueJob(job) {
  1748. if (!queue.length || !queue.includes(
  1749. job,
  1750. isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex,
  1751. )) {
  1752. if (job.id == null)
  1753. queue.push(job)
  1754. else
  1755. queue.splice(findInsertionIndex(job.id), 0, job)
  1756. queueFlush()
  1757. }
  1758. }
  1759. function queueFlush() {
  1760. if (!isFlushing && !isFlushPending) {
  1761. isFlushPending = true
  1762. currentFlushPromise = resolvedPromise.then(flushJobs)
  1763. }
  1764. }
  1765. function invalidateJob(job) {
  1766. const i = queue.indexOf(job)
  1767. if (i > flushIndex)
  1768. queue.splice(i, 1)
  1769. }
  1770. function queuePostFlushCb(cb) {
  1771. if (!isArray(cb)) {
  1772. if (!activePostFlushCbs || !activePostFlushCbs.includes(
  1773. cb,
  1774. cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex,
  1775. ))
  1776. pendingPostFlushCbs.push(cb)
  1777. }
  1778. else {
  1779. pendingPostFlushCbs.push(...cb)
  1780. }
  1781. queueFlush()
  1782. }
  1783. function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
  1784. {
  1785. seen = seen || /* @__PURE__ */ new Map()
  1786. }
  1787. for (; i < queue.length; i++) {
  1788. const cb = queue[i]
  1789. if (cb && cb.pre) {
  1790. if (instance && cb.id !== instance.uid)
  1791. continue
  1792. if (checkRecursiveUpdates(seen, cb))
  1793. continue
  1794. queue.splice(i, 1)
  1795. i--
  1796. cb()
  1797. }
  1798. }
  1799. }
  1800. function flushPostFlushCbs(seen) {
  1801. if (pendingPostFlushCbs.length) {
  1802. const deduped = [...new Set(pendingPostFlushCbs)].sort(
  1803. (a, b) => getId(a) - getId(b),
  1804. )
  1805. pendingPostFlushCbs.length = 0
  1806. if (activePostFlushCbs) {
  1807. activePostFlushCbs.push(...deduped)
  1808. return
  1809. }
  1810. activePostFlushCbs = deduped
  1811. {
  1812. seen = seen || /* @__PURE__ */ new Map()
  1813. }
  1814. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1815. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]))
  1816. continue
  1817. activePostFlushCbs[postFlushIndex]()
  1818. }
  1819. activePostFlushCbs = null
  1820. postFlushIndex = 0
  1821. }
  1822. }
  1823. const getId = job => job.id == null ? Number.POSITIVE_INFINITY : job.id
  1824. function comparator(a, b) {
  1825. const diff = getId(a) - getId(b)
  1826. if (diff === 0) {
  1827. if (a.pre && !b.pre)
  1828. return -1
  1829. if (b.pre && !a.pre)
  1830. return 1
  1831. }
  1832. return diff
  1833. }
  1834. function flushJobs(seen) {
  1835. isFlushPending = false
  1836. isFlushing = true
  1837. {
  1838. seen = seen || /* @__PURE__ */ new Map()
  1839. }
  1840. queue.sort(comparator)
  1841. const check = job => checkRecursiveUpdates(seen, job)
  1842. try {
  1843. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1844. const job = queue[flushIndex]
  1845. if (job && job.active !== false) {
  1846. if (check(job))
  1847. continue
  1848. callWithErrorHandling(job, null, 14)
  1849. }
  1850. }
  1851. }
  1852. finally {
  1853. flushIndex = 0
  1854. queue.length = 0
  1855. flushPostFlushCbs(seen)
  1856. isFlushing = false
  1857. currentFlushPromise = null
  1858. if (queue.length || pendingPostFlushCbs.length)
  1859. flushJobs(seen)
  1860. }
  1861. }
  1862. function checkRecursiveUpdates(seen, fn) {
  1863. if (!seen.has(fn)) {
  1864. seen.set(fn, 1)
  1865. }
  1866. else {
  1867. const count = seen.get(fn)
  1868. if (count > RECURSION_LIMIT) {
  1869. const instance = fn.ownerInstance
  1870. const componentName = instance && getComponentName(instance.type)
  1871. handleError(
  1872. `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
  1873. null,
  1874. 10,
  1875. )
  1876. return true
  1877. }
  1878. else {
  1879. seen.set(fn, count + 1)
  1880. }
  1881. }
  1882. }
  1883. let isHmrUpdating = false
  1884. const hmrDirtyComponents = /* @__PURE__ */ new Set()
  1885. {
  1886. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1887. createRecord: tryWrap(createRecord),
  1888. rerender: tryWrap(rerender),
  1889. reload: tryWrap(reload),
  1890. }
  1891. }
  1892. const map = /* @__PURE__ */ new Map()
  1893. function registerHMR(instance) {
  1894. const id = instance.type.__hmrId
  1895. let record = map.get(id)
  1896. if (!record) {
  1897. createRecord(id, instance.type)
  1898. record = map.get(id)
  1899. }
  1900. record.instances.add(instance)
  1901. }
  1902. function unregisterHMR(instance) {
  1903. map.get(instance.type.__hmrId).instances.delete(instance)
  1904. }
  1905. function createRecord(id, initialDef) {
  1906. if (map.has(id))
  1907. return false
  1908. map.set(id, {
  1909. initialDef: normalizeClassComponent(initialDef),
  1910. instances: /* @__PURE__ */ new Set(),
  1911. })
  1912. return true
  1913. }
  1914. function normalizeClassComponent(component) {
  1915. return isClassComponent(component) ? component.__vccOpts : component
  1916. }
  1917. function rerender(id, newRender) {
  1918. const record = map.get(id)
  1919. if (!record)
  1920. return
  1921. record.initialDef.render = newRender;
  1922. [...record.instances].forEach((instance) => {
  1923. if (newRender) {
  1924. instance.render = newRender
  1925. normalizeClassComponent(instance.type).render = newRender
  1926. }
  1927. instance.renderCache = []
  1928. isHmrUpdating = true
  1929. instance.effect.dirty = true
  1930. instance.update()
  1931. isHmrUpdating = false
  1932. })
  1933. }
  1934. function reload(id, newComp) {
  1935. const record = map.get(id)
  1936. if (!record)
  1937. return
  1938. newComp = normalizeClassComponent(newComp)
  1939. updateComponentDef(record.initialDef, newComp)
  1940. const instances = [...record.instances]
  1941. for (const instance of instances) {
  1942. const oldComp = normalizeClassComponent(instance.type)
  1943. if (!hmrDirtyComponents.has(oldComp)) {
  1944. if (oldComp !== record.initialDef)
  1945. updateComponentDef(oldComp, newComp)
  1946. hmrDirtyComponents.add(oldComp)
  1947. }
  1948. instance.appContext.propsCache.delete(instance.type)
  1949. instance.appContext.emitsCache.delete(instance.type)
  1950. instance.appContext.optionsCache.delete(instance.type)
  1951. if (instance.ceReload) {
  1952. hmrDirtyComponents.add(oldComp)
  1953. instance.ceReload(newComp.styles)
  1954. hmrDirtyComponents.delete(oldComp)
  1955. }
  1956. else if (instance.parent) {
  1957. instance.parent.effect.dirty = true
  1958. queueJob(instance.parent.update)
  1959. }
  1960. else if (instance.appContext.reload) {
  1961. instance.appContext.reload()
  1962. }
  1963. else if (typeof window !== 'undefined') {
  1964. window.location.reload()
  1965. }
  1966. else {
  1967. console.warn(
  1968. '[HMR] Root or manually mounted instance modified. Full reload required.',
  1969. )
  1970. }
  1971. }
  1972. queuePostFlushCb(() => {
  1973. for (const instance of instances) {
  1974. hmrDirtyComponents.delete(
  1975. normalizeClassComponent(instance.type),
  1976. )
  1977. }
  1978. })
  1979. }
  1980. function updateComponentDef(oldComp, newComp) {
  1981. extend(oldComp, newComp)
  1982. for (const key in oldComp) {
  1983. if (key !== '__file' && !(key in newComp))
  1984. delete oldComp[key]
  1985. }
  1986. }
  1987. function tryWrap(fn) {
  1988. return (id, arg) => {
  1989. try {
  1990. return fn(id, arg)
  1991. }
  1992. catch (e) {
  1993. console.error(e)
  1994. console.warn(
  1995. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`,
  1996. )
  1997. }
  1998. }
  1999. }
  2000. let devtools$1
  2001. let buffer = []
  2002. let devtoolsNotInstalled = false
  2003. function emit$1(event, ...args) {
  2004. if (devtools$1)
  2005. devtools$1.emit(event, ...args)
  2006. else if (!devtoolsNotInstalled)
  2007. buffer.push({ event, args })
  2008. }
  2009. function setDevtoolsHook$1(hook, target) {
  2010. let _a, _b
  2011. devtools$1 = hook
  2012. if (devtools$1) {
  2013. devtools$1.enabled = true
  2014. buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args))
  2015. buffer = []
  2016. }
  2017. else if (
  2018. // handle late devtools injection - only do this if we are in an actual
  2019. // browser environment to avoid the timer handle stalling test runner exit
  2020. // (#4815)
  2021. typeof window !== 'undefined' // some envs mock window but not fully
  2022. && window.HTMLElement // also exclude jsdom
  2023. && !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes('jsdom'))
  2024. ) {
  2025. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []
  2026. replay.push((newHook) => {
  2027. setDevtoolsHook$1(newHook, target)
  2028. })
  2029. setTimeout(() => {
  2030. if (!devtools$1) {
  2031. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null
  2032. devtoolsNotInstalled = true
  2033. buffer = []
  2034. }
  2035. }, 3e3)
  2036. }
  2037. else {
  2038. devtoolsNotInstalled = true
  2039. buffer = []
  2040. }
  2041. }
  2042. function devtoolsInitApp(app, version) {
  2043. emit$1('app:init' /* APP_INIT */, app, version, {
  2044. Fragment,
  2045. Text,
  2046. Comment,
  2047. Static,
  2048. })
  2049. }
  2050. function devtoolsUnmountApp(app) {
  2051. emit$1('app:unmount' /* APP_UNMOUNT */, app)
  2052. }
  2053. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
  2054. 'component:added', /* COMPONENT_ADDED */
  2055. )
  2056. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook('component:updated' /* COMPONENT_UPDATED */)
  2057. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  2058. 'component:removed', /* COMPONENT_REMOVED */
  2059. )
  2060. function devtoolsComponentRemoved(component) {
  2061. if (devtools$1 && typeof devtools$1.cleanupBuffer === 'function' // remove the component if it wasn't buffered
  2062. && !devtools$1.cleanupBuffer(component))
  2063. _devtoolsComponentRemoved(component)
  2064. }
  2065. /*! #__NO_SIDE_EFFECTS__ */
  2066. // @__NO_SIDE_EFFECTS__
  2067. function createDevtoolsComponentHook(hook) {
  2068. return (component) => {
  2069. emit$1(
  2070. hook,
  2071. component.appContext.app,
  2072. component.uid,
  2073. component.parent ? component.parent.uid : void 0,
  2074. component,
  2075. )
  2076. }
  2077. }
  2078. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2079. 'perf:start', /* PERFORMANCE_START */
  2080. )
  2081. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2082. 'perf:end', /* PERFORMANCE_END */
  2083. )
  2084. function createDevtoolsPerformanceHook(hook) {
  2085. return (component, type, time) => {
  2086. emit$1(hook, component.appContext.app, component.uid, component, type, time)
  2087. }
  2088. }
  2089. function devtoolsComponentEmit(component, event, params) {
  2090. emit$1(
  2091. 'component:emit' /* COMPONENT_EMIT */,
  2092. component.appContext.app,
  2093. component,
  2094. event,
  2095. params,
  2096. )
  2097. }
  2098. function emit(instance, event, ...rawArgs) {
  2099. if (instance.isUnmounted)
  2100. return
  2101. const props = instance.vnode.props || EMPTY_OBJ
  2102. {
  2103. const {
  2104. emitsOptions,
  2105. propsOptions: [propsOptions],
  2106. } = instance
  2107. if (emitsOptions) {
  2108. if (!(event in emitsOptions) && true) {
  2109. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2110. warn$1(
  2111. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`,
  2112. )
  2113. }
  2114. }
  2115. else {
  2116. const validator = emitsOptions[event]
  2117. if (isFunction(validator)) {
  2118. const isValid = validator(...rawArgs)
  2119. if (!isValid) {
  2120. warn$1(
  2121. `Invalid event arguments: event validation failed for event "${event}".`,
  2122. )
  2123. }
  2124. }
  2125. }
  2126. }
  2127. }
  2128. let args = rawArgs
  2129. const isModelListener = event.startsWith('update:')
  2130. const modelArg = isModelListener && event.slice(7)
  2131. if (modelArg && modelArg in props) {
  2132. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`
  2133. const { number, trim } = props[modifiersKey] || EMPTY_OBJ
  2134. if (trim)
  2135. args = rawArgs.map(a => isString(a) ? a.trim() : a)
  2136. if (number)
  2137. args = rawArgs.map(looseToNumber)
  2138. }
  2139. {
  2140. devtoolsComponentEmit(instance, event, args)
  2141. }
  2142. {
  2143. const lowerCaseEvent = event.toLowerCase()
  2144. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2145. warn$1(
  2146. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  2147. instance,
  2148. instance.type,
  2149. )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(
  2150. event,
  2151. )}" instead of "${event}".`,
  2152. )
  2153. }
  2154. }
  2155. let handlerName
  2156. let handler = props[handlerName = toHandlerKey(event)] // also try camelCase event handler (#2249)
  2157. || props[handlerName = toHandlerKey(camelize(event))]
  2158. if (!handler && isModelListener)
  2159. handler = props[handlerName = toHandlerKey(hyphenate(event))]
  2160. if (handler) {
  2161. callWithAsyncErrorHandling(
  2162. handler,
  2163. instance,
  2164. 6,
  2165. args,
  2166. )
  2167. }
  2168. const onceHandler = props[`${handlerName}Once`]
  2169. if (onceHandler) {
  2170. if (!instance.emitted)
  2171. instance.emitted = {}
  2172. else if (instance.emitted[handlerName])
  2173. return
  2174. instance.emitted[handlerName] = true
  2175. callWithAsyncErrorHandling(
  2176. onceHandler,
  2177. instance,
  2178. 6,
  2179. args,
  2180. )
  2181. }
  2182. }
  2183. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2184. const cache = appContext.emitsCache
  2185. const cached = cache.get(comp)
  2186. if (cached !== void 0)
  2187. return cached
  2188. const raw = comp.emits
  2189. const normalized = {}
  2190. let hasExtends = false
  2191. if (!isFunction(comp)) {
  2192. const extendEmits = (raw2) => {
  2193. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true)
  2194. if (normalizedFromExtend) {
  2195. hasExtends = true
  2196. extend(normalized, normalizedFromExtend)
  2197. }
  2198. }
  2199. if (!asMixin && appContext.mixins.length)
  2200. appContext.mixins.forEach(extendEmits)
  2201. if (comp.extends)
  2202. extendEmits(comp.extends)
  2203. if (comp.mixins)
  2204. comp.mixins.forEach(extendEmits)
  2205. }
  2206. if (!raw && !hasExtends) {
  2207. if (isObject(comp))
  2208. cache.set(comp, null)
  2209. return null
  2210. }
  2211. if (isArray(raw))
  2212. raw.forEach(key => normalized[key] = null)
  2213. else
  2214. extend(normalized, raw)
  2215. if (isObject(comp))
  2216. cache.set(comp, normalized)
  2217. return normalized
  2218. }
  2219. function isEmitListener(options, key) {
  2220. if (!options || !isOn(key))
  2221. return false
  2222. key = key.slice(2).replace(/Once$/, '')
  2223. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key)
  2224. }
  2225. let currentRenderingInstance = null
  2226. let currentScopeId = null
  2227. function setCurrentRenderingInstance(instance) {
  2228. const prev = currentRenderingInstance
  2229. currentRenderingInstance = instance
  2230. currentScopeId = instance && instance.type.__scopeId || null
  2231. return prev
  2232. }
  2233. function pushScopeId(id) {
  2234. currentScopeId = id
  2235. }
  2236. function popScopeId() {
  2237. currentScopeId = null
  2238. }
  2239. const withScopeId = _id => withCtx
  2240. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2241. if (!ctx)
  2242. return fn
  2243. if (fn._n)
  2244. return fn
  2245. const renderFnWithContext = (...args) => {
  2246. if (renderFnWithContext._d)
  2247. setBlockTracking(-1)
  2248. const prevInstance = setCurrentRenderingInstance(ctx)
  2249. let res
  2250. try {
  2251. res = fn(...args)
  2252. }
  2253. finally {
  2254. setCurrentRenderingInstance(prevInstance)
  2255. if (renderFnWithContext._d)
  2256. setBlockTracking(1)
  2257. }
  2258. {
  2259. devtoolsComponentUpdated(ctx)
  2260. }
  2261. return res
  2262. }
  2263. renderFnWithContext._n = true
  2264. renderFnWithContext._c = true
  2265. renderFnWithContext._d = true
  2266. return renderFnWithContext
  2267. }
  2268. let accessedAttrs = false
  2269. function markAttrsAccessed() {
  2270. accessedAttrs = true
  2271. }
  2272. function renderComponentRoot(instance) {
  2273. const {
  2274. type: Component,
  2275. vnode,
  2276. proxy,
  2277. withProxy,
  2278. propsOptions: [propsOptions],
  2279. slots,
  2280. attrs,
  2281. emit,
  2282. render,
  2283. renderCache,
  2284. props,
  2285. data,
  2286. setupState,
  2287. ctx,
  2288. inheritAttrs,
  2289. } = instance
  2290. const prev = setCurrentRenderingInstance(instance)
  2291. let result
  2292. let fallthroughAttrs
  2293. {
  2294. accessedAttrs = false
  2295. }
  2296. try {
  2297. if (vnode.shapeFlag & 4) {
  2298. const proxyToUse = withProxy || proxy
  2299. const thisProxy = setupState.__isScriptSetup
  2300. ? new Proxy(proxyToUse, {
  2301. get(target, key, receiver) {
  2302. warn$1(
  2303. `Property '${String(
  2304. key,
  2305. )}' was accessed via 'this'. Avoid using 'this' in templates.`,
  2306. )
  2307. return Reflect.get(target, key, receiver)
  2308. },
  2309. })
  2310. : proxyToUse
  2311. result = normalizeVNode(
  2312. render.call(
  2313. thisProxy,
  2314. proxyToUse,
  2315. renderCache,
  2316. true ? shallowReadonly(props) : props,
  2317. setupState,
  2318. data,
  2319. ctx,
  2320. ),
  2321. )
  2322. fallthroughAttrs = attrs
  2323. }
  2324. else {
  2325. const render2 = Component
  2326. if (attrs === props)
  2327. markAttrsAccessed()
  2328. result = normalizeVNode(
  2329. render2.length > 1
  2330. ? render2(
  2331. true ? shallowReadonly(props) : props,
  2332. true
  2333. ? {
  2334. get attrs() {
  2335. markAttrsAccessed()
  2336. return shallowReadonly(attrs)
  2337. },
  2338. slots,
  2339. emit,
  2340. }
  2341. : { attrs, slots, emit },
  2342. )
  2343. : render2(
  2344. true ? shallowReadonly(props) : props,
  2345. null,
  2346. ),
  2347. )
  2348. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs)
  2349. }
  2350. }
  2351. catch (err) {
  2352. blockStack.length = 0
  2353. handleError(err, instance, 1)
  2354. result = createVNode(Comment)
  2355. }
  2356. let root = result
  2357. let setRoot = void 0
  2358. if (result.patchFlag > 0 && result.patchFlag & 2048)
  2359. [root, setRoot] = getChildRoot(result)
  2360. if (fallthroughAttrs && inheritAttrs !== false) {
  2361. const keys = Object.keys(fallthroughAttrs)
  2362. const { shapeFlag } = root
  2363. if (keys.length) {
  2364. if (shapeFlag & (1 | 6)) {
  2365. if (propsOptions && keys.some(isModelListener)) {
  2366. fallthroughAttrs = filterModelListeners(
  2367. fallthroughAttrs,
  2368. propsOptions,
  2369. )
  2370. }
  2371. root = cloneVNode(root, fallthroughAttrs, false, true)
  2372. }
  2373. else if (!accessedAttrs && root.type !== Comment) {
  2374. const allAttrs = Object.keys(attrs)
  2375. const eventAttrs = []
  2376. const extraAttrs = []
  2377. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2378. const key = allAttrs[i]
  2379. if (isOn(key)) {
  2380. if (!isModelListener(key))
  2381. eventAttrs.push(key[2].toLowerCase() + key.slice(3))
  2382. }
  2383. else {
  2384. extraAttrs.push(key)
  2385. }
  2386. }
  2387. if (extraAttrs.length) {
  2388. warn$1(
  2389. `Extraneous non-props attributes (${extraAttrs.join(', ')}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`,
  2390. )
  2391. }
  2392. if (eventAttrs.length) {
  2393. warn$1(
  2394. `Extraneous non-emits event listeners (${eventAttrs.join(', ')}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`,
  2395. )
  2396. }
  2397. }
  2398. }
  2399. }
  2400. if (vnode.dirs) {
  2401. if (!isElementRoot(root)) {
  2402. warn$1(
  2403. `Runtime directive used on component with non-element root node. The directives will not function as intended.`,
  2404. )
  2405. }
  2406. root = cloneVNode(root, null, false, true)
  2407. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs
  2408. }
  2409. if (vnode.transition) {
  2410. if (!isElementRoot(root)) {
  2411. warn$1(
  2412. `Component inside <Transition> renders non-element root node that cannot be animated.`,
  2413. )
  2414. }
  2415. root.transition = vnode.transition
  2416. }
  2417. if (setRoot)
  2418. setRoot(root)
  2419. else
  2420. result = root
  2421. setCurrentRenderingInstance(prev)
  2422. return result
  2423. }
  2424. function getChildRoot(vnode) {
  2425. const rawChildren = vnode.children
  2426. const dynamicChildren = vnode.dynamicChildren
  2427. const childRoot = filterSingleRoot(rawChildren, false)
  2428. if (!childRoot)
  2429. return [vnode, void 0]
  2430. else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048)
  2431. return getChildRoot(childRoot)
  2432. const index = rawChildren.indexOf(childRoot)
  2433. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
  2434. const setRoot = (updatedRoot) => {
  2435. rawChildren[index] = updatedRoot
  2436. if (dynamicChildren) {
  2437. if (dynamicIndex > -1)
  2438. dynamicChildren[dynamicIndex] = updatedRoot
  2439. else if (updatedRoot.patchFlag > 0)
  2440. vnode.dynamicChildren = [...dynamicChildren, updatedRoot]
  2441. }
  2442. }
  2443. return [normalizeVNode(childRoot), setRoot]
  2444. }
  2445. function filterSingleRoot(children, recurse = true) {
  2446. let singleRoot
  2447. for (let i = 0; i < children.length; i++) {
  2448. const child = children[i]
  2449. if (isVNode(child)) {
  2450. if (child.type !== Comment || child.children === 'v-if') {
  2451. if (singleRoot) {
  2452. return
  2453. }
  2454. else {
  2455. singleRoot = child
  2456. if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048)
  2457. return filterSingleRoot(singleRoot.children)
  2458. }
  2459. }
  2460. }
  2461. else {
  2462. return
  2463. }
  2464. }
  2465. return singleRoot
  2466. }
  2467. function getFunctionalFallthrough(attrs) {
  2468. let res
  2469. for (const key in attrs) {
  2470. if (key === 'class' || key === 'style' || isOn(key))
  2471. (res || (res = {}))[key] = attrs[key]
  2472. }
  2473. return res
  2474. }
  2475. function filterModelListeners(attrs, props) {
  2476. const res = {}
  2477. for (const key in attrs) {
  2478. if (!isModelListener(key) || !(key.slice(9) in props))
  2479. res[key] = attrs[key]
  2480. }
  2481. return res
  2482. }
  2483. function isElementRoot(vnode) {
  2484. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment
  2485. }
  2486. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2487. const { props: prevProps, children: prevChildren, component } = prevVNode
  2488. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode
  2489. const emits = component.emitsOptions
  2490. if ((prevChildren || nextChildren) && isHmrUpdating)
  2491. return true
  2492. if (nextVNode.dirs || nextVNode.transition)
  2493. return true
  2494. if (optimized && patchFlag >= 0) {
  2495. if (patchFlag & 1024)
  2496. return true
  2497. if (patchFlag & 16) {
  2498. if (!prevProps)
  2499. return !!nextProps
  2500. return hasPropsChanged(prevProps, nextProps, emits)
  2501. }
  2502. else if (patchFlag & 8) {
  2503. const dynamicProps = nextVNode.dynamicProps
  2504. for (let i = 0; i < dynamicProps.length; i++) {
  2505. const key = dynamicProps[i]
  2506. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key))
  2507. return true
  2508. }
  2509. }
  2510. }
  2511. else {
  2512. if (prevChildren || nextChildren) {
  2513. if (!nextChildren || !nextChildren.$stable)
  2514. return true
  2515. }
  2516. if (prevProps === nextProps)
  2517. return false
  2518. if (!prevProps)
  2519. return !!nextProps
  2520. if (!nextProps)
  2521. return true
  2522. return hasPropsChanged(prevProps, nextProps, emits)
  2523. }
  2524. return false
  2525. }
  2526. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2527. const nextKeys = Object.keys(nextProps)
  2528. if (nextKeys.length !== Object.keys(prevProps).length)
  2529. return true
  2530. for (let i = 0; i < nextKeys.length; i++) {
  2531. const key = nextKeys[i]
  2532. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key))
  2533. return true
  2534. }
  2535. return false
  2536. }
  2537. function updateHOCHostEl({ vnode, parent }, el) {
  2538. while (parent) {
  2539. const root = parent.subTree
  2540. if (root.suspense && root.suspense.activeBranch === vnode)
  2541. root.el = vnode.el
  2542. if (root === vnode) {
  2543. (vnode = parent.vnode).el = el
  2544. parent = parent.parent
  2545. }
  2546. else {
  2547. break
  2548. }
  2549. }
  2550. }
  2551. const COMPONENTS = 'components'
  2552. const DIRECTIVES = 'directives'
  2553. function resolveComponent(name, maybeSelfReference) {
  2554. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name
  2555. }
  2556. const NULL_DYNAMIC_COMPONENT = Symbol.for('v-ndc')
  2557. function resolveDynamicComponent(component) {
  2558. if (isString(component))
  2559. return resolveAsset(COMPONENTS, component, false) || component
  2560. else
  2561. return component || NULL_DYNAMIC_COMPONENT
  2562. }
  2563. function resolveDirective(name) {
  2564. return resolveAsset(DIRECTIVES, name)
  2565. }
  2566. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  2567. const instance = currentRenderingInstance || currentInstance
  2568. if (instance) {
  2569. const Component = instance.type
  2570. if (type === COMPONENTS) {
  2571. const selfName = getComponentName(
  2572. Component,
  2573. false,
  2574. )
  2575. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name))))
  2576. return Component
  2577. }
  2578. const res = (
  2579. // local registration
  2580. // check instance[type] first which is resolved for options API
  2581. resolve(instance[type] || Component[type], name) // global registration
  2582. || resolve(instance.appContext[type], name)
  2583. )
  2584. if (!res && maybeSelfReference)
  2585. return Component
  2586. if (warnMissing && !res) {
  2587. const extra = type === COMPONENTS
  2588. ? `
  2589. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.`
  2590. : ``
  2591. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`)
  2592. }
  2593. return res
  2594. }
  2595. else {
  2596. warn$1(
  2597. `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`,
  2598. )
  2599. }
  2600. }
  2601. function resolve(registry, name) {
  2602. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))])
  2603. }
  2604. const isSuspense = type => type.__isSuspense
  2605. let suspenseId = 0
  2606. const SuspenseImpl = {
  2607. name: 'Suspense',
  2608. // In order to make Suspense tree-shakable, we need to avoid importing it
  2609. // directly in the renderer. The renderer checks for the __isSuspense flag
  2610. // on a vnode's type and calls the `process` method, passing in renderer
  2611. // internals.
  2612. __isSuspense: true,
  2613. process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
  2614. if (n1 == null) {
  2615. mountSuspense(
  2616. n2,
  2617. container,
  2618. anchor,
  2619. parentComponent,
  2620. parentSuspense,
  2621. namespace,
  2622. slotScopeIds,
  2623. optimized,
  2624. rendererInternals,
  2625. )
  2626. }
  2627. else {
  2628. if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
  2629. n2.suspense = n1.suspense
  2630. n2.suspense.vnode = n2
  2631. n2.el = n1.el
  2632. return
  2633. }
  2634. patchSuspense(
  2635. n1,
  2636. n2,
  2637. container,
  2638. anchor,
  2639. parentComponent,
  2640. namespace,
  2641. slotScopeIds,
  2642. optimized,
  2643. rendererInternals,
  2644. )
  2645. }
  2646. },
  2647. hydrate: hydrateSuspense,
  2648. create: createSuspenseBoundary,
  2649. normalize: normalizeSuspenseChildren,
  2650. }
  2651. const Suspense = SuspenseImpl
  2652. function triggerEvent(vnode, name) {
  2653. const eventListener = vnode.props && vnode.props[name]
  2654. if (isFunction(eventListener))
  2655. eventListener()
  2656. }
  2657. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
  2658. const {
  2659. p: patch,
  2660. o: { createElement },
  2661. } = rendererInternals
  2662. const hiddenContainer = createElement('div')
  2663. const suspense = vnode.suspense = createSuspenseBoundary(
  2664. vnode,
  2665. parentSuspense,
  2666. parentComponent,
  2667. container,
  2668. hiddenContainer,
  2669. anchor,
  2670. namespace,
  2671. slotScopeIds,
  2672. optimized,
  2673. rendererInternals,
  2674. )
  2675. patch(
  2676. null,
  2677. suspense.pendingBranch = vnode.ssContent,
  2678. hiddenContainer,
  2679. null,
  2680. parentComponent,
  2681. suspense,
  2682. namespace,
  2683. slotScopeIds,
  2684. )
  2685. if (suspense.deps > 0) {
  2686. triggerEvent(vnode, 'onPending')
  2687. triggerEvent(vnode, 'onFallback')
  2688. patch(
  2689. null,
  2690. vnode.ssFallback,
  2691. container,
  2692. anchor,
  2693. parentComponent,
  2694. null,
  2695. // fallback tree will not have suspense context
  2696. namespace,
  2697. slotScopeIds,
  2698. )
  2699. setActiveBranch(suspense, vnode.ssFallback)
  2700. }
  2701. else {
  2702. suspense.resolve(false, true)
  2703. }
  2704. }
  2705. function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2706. const suspense = n2.suspense = n1.suspense
  2707. suspense.vnode = n2
  2708. n2.el = n1.el
  2709. const newBranch = n2.ssContent
  2710. const newFallback = n2.ssFallback
  2711. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense
  2712. if (pendingBranch) {
  2713. suspense.pendingBranch = newBranch
  2714. if (isSameVNodeType(newBranch, pendingBranch)) {
  2715. patch(
  2716. pendingBranch,
  2717. newBranch,
  2718. suspense.hiddenContainer,
  2719. null,
  2720. parentComponent,
  2721. suspense,
  2722. namespace,
  2723. slotScopeIds,
  2724. optimized,
  2725. )
  2726. if (suspense.deps <= 0) {
  2727. suspense.resolve()
  2728. }
  2729. else if (isInFallback) {
  2730. if (!isHydrating) {
  2731. patch(
  2732. activeBranch,
  2733. newFallback,
  2734. container,
  2735. anchor,
  2736. parentComponent,
  2737. null,
  2738. // fallback tree will not have suspense context
  2739. namespace,
  2740. slotScopeIds,
  2741. optimized,
  2742. )
  2743. setActiveBranch(suspense, newFallback)
  2744. }
  2745. }
  2746. }
  2747. else {
  2748. suspense.pendingId = suspenseId++
  2749. if (isHydrating) {
  2750. suspense.isHydrating = false
  2751. suspense.activeBranch = pendingBranch
  2752. }
  2753. else {
  2754. unmount(pendingBranch, parentComponent, suspense)
  2755. }
  2756. suspense.deps = 0
  2757. suspense.effects.length = 0
  2758. suspense.hiddenContainer = createElement('div')
  2759. if (isInFallback) {
  2760. patch(
  2761. null,
  2762. newBranch,
  2763. suspense.hiddenContainer,
  2764. null,
  2765. parentComponent,
  2766. suspense,
  2767. namespace,
  2768. slotScopeIds,
  2769. optimized,
  2770. )
  2771. if (suspense.deps <= 0) {
  2772. suspense.resolve()
  2773. }
  2774. else {
  2775. patch(
  2776. activeBranch,
  2777. newFallback,
  2778. container,
  2779. anchor,
  2780. parentComponent,
  2781. null,
  2782. // fallback tree will not have suspense context
  2783. namespace,
  2784. slotScopeIds,
  2785. optimized,
  2786. )
  2787. setActiveBranch(suspense, newFallback)
  2788. }
  2789. }
  2790. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2791. patch(
  2792. activeBranch,
  2793. newBranch,
  2794. container,
  2795. anchor,
  2796. parentComponent,
  2797. suspense,
  2798. namespace,
  2799. slotScopeIds,
  2800. optimized,
  2801. )
  2802. suspense.resolve(true)
  2803. }
  2804. else {
  2805. patch(
  2806. null,
  2807. newBranch,
  2808. suspense.hiddenContainer,
  2809. null,
  2810. parentComponent,
  2811. suspense,
  2812. namespace,
  2813. slotScopeIds,
  2814. optimized,
  2815. )
  2816. if (suspense.deps <= 0)
  2817. suspense.resolve()
  2818. }
  2819. }
  2820. }
  2821. else {
  2822. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2823. patch(
  2824. activeBranch,
  2825. newBranch,
  2826. container,
  2827. anchor,
  2828. parentComponent,
  2829. suspense,
  2830. namespace,
  2831. slotScopeIds,
  2832. optimized,
  2833. )
  2834. setActiveBranch(suspense, newBranch)
  2835. }
  2836. else {
  2837. triggerEvent(n2, 'onPending')
  2838. suspense.pendingBranch = newBranch
  2839. if (newBranch.shapeFlag & 512)
  2840. suspense.pendingId = newBranch.component.suspenseId
  2841. else
  2842. suspense.pendingId = suspenseId++
  2843. patch(
  2844. null,
  2845. newBranch,
  2846. suspense.hiddenContainer,
  2847. null,
  2848. parentComponent,
  2849. suspense,
  2850. namespace,
  2851. slotScopeIds,
  2852. optimized,
  2853. )
  2854. if (suspense.deps <= 0) {
  2855. suspense.resolve()
  2856. }
  2857. else {
  2858. const { timeout, pendingId } = suspense
  2859. if (timeout > 0) {
  2860. setTimeout(() => {
  2861. if (suspense.pendingId === pendingId)
  2862. suspense.fallback(newFallback)
  2863. }, timeout)
  2864. }
  2865. else if (timeout === 0) {
  2866. suspense.fallback(newFallback)
  2867. }
  2868. }
  2869. }
  2870. }
  2871. }
  2872. let hasWarned = false
  2873. function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2874. if (!hasWarned) {
  2875. hasWarned = true
  2876. console[console.info ? 'info' : 'log'](
  2877. `<Suspense> is an experimental feature and its API will likely change.`,
  2878. )
  2879. }
  2880. const {
  2881. p: patch,
  2882. m: move,
  2883. um: unmount,
  2884. n: next,
  2885. o: { parentNode, remove },
  2886. } = rendererInternals
  2887. let parentSuspenseId
  2888. const isSuspensible = isVNodeSuspensible(vnode)
  2889. if (isSuspensible) {
  2890. if (parentSuspense && parentSuspense.pendingBranch) {
  2891. parentSuspenseId = parentSuspense.pendingId
  2892. parentSuspense.deps++
  2893. }
  2894. }
  2895. const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0
  2896. {
  2897. assertNumber(timeout, `Suspense timeout`)
  2898. }
  2899. const initialAnchor = anchor
  2900. const suspense = {
  2901. vnode,
  2902. parent: parentSuspense,
  2903. parentComponent,
  2904. namespace,
  2905. container,
  2906. hiddenContainer,
  2907. deps: 0,
  2908. pendingId: suspenseId++,
  2909. timeout: typeof timeout === 'number' ? timeout : -1,
  2910. activeBranch: null,
  2911. pendingBranch: null,
  2912. isInFallback: !isHydrating,
  2913. isHydrating,
  2914. isUnmounted: false,
  2915. effects: [],
  2916. resolve(resume = false, sync = false) {
  2917. {
  2918. if (!resume && !suspense.pendingBranch) {
  2919. throw new Error(
  2920. `suspense.resolve() is called without a pending branch.`,
  2921. )
  2922. }
  2923. if (suspense.isUnmounted) {
  2924. throw new Error(
  2925. `suspense.resolve() is called on an already unmounted suspense boundary.`,
  2926. )
  2927. }
  2928. }
  2929. const {
  2930. vnode: vnode2,
  2931. activeBranch,
  2932. pendingBranch,
  2933. pendingId,
  2934. effects,
  2935. parentComponent: parentComponent2,
  2936. container: container2,
  2937. } = suspense
  2938. let delayEnter = false
  2939. if (suspense.isHydrating) {
  2940. suspense.isHydrating = false
  2941. }
  2942. else if (!resume) {
  2943. delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === 'out-in'
  2944. if (delayEnter) {
  2945. activeBranch.transition.afterLeave = () => {
  2946. if (pendingId === suspense.pendingId) {
  2947. move(
  2948. pendingBranch,
  2949. container2,
  2950. anchor === initialAnchor ? next(activeBranch) : anchor,
  2951. 0,
  2952. )
  2953. queuePostFlushCb(effects)
  2954. }
  2955. }
  2956. }
  2957. if (activeBranch) {
  2958. if (parentNode(activeBranch.el) !== suspense.hiddenContainer)
  2959. anchor = next(activeBranch)
  2960. unmount(activeBranch, parentComponent2, suspense, true)
  2961. }
  2962. if (!delayEnter)
  2963. move(pendingBranch, container2, anchor, 0)
  2964. }
  2965. setActiveBranch(suspense, pendingBranch)
  2966. suspense.pendingBranch = null
  2967. suspense.isInFallback = false
  2968. let parent = suspense.parent
  2969. let hasUnresolvedAncestor = false
  2970. while (parent) {
  2971. if (parent.pendingBranch) {
  2972. parent.effects.push(...effects)
  2973. hasUnresolvedAncestor = true
  2974. break
  2975. }
  2976. parent = parent.parent
  2977. }
  2978. if (!hasUnresolvedAncestor && !delayEnter)
  2979. queuePostFlushCb(effects)
  2980. suspense.effects = []
  2981. if (isSuspensible) {
  2982. if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
  2983. parentSuspense.deps--
  2984. if (parentSuspense.deps === 0 && !sync)
  2985. parentSuspense.resolve()
  2986. }
  2987. }
  2988. triggerEvent(vnode2, 'onResolve')
  2989. },
  2990. fallback(fallbackVNode) {
  2991. if (!suspense.pendingBranch)
  2992. return
  2993. const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense
  2994. triggerEvent(vnode2, 'onFallback')
  2995. const anchor2 = next(activeBranch)
  2996. const mountFallback = () => {
  2997. if (!suspense.isInFallback)
  2998. return
  2999. patch(
  3000. null,
  3001. fallbackVNode,
  3002. container2,
  3003. anchor2,
  3004. parentComponent2,
  3005. null,
  3006. // fallback tree will not have suspense context
  3007. namespace2,
  3008. slotScopeIds,
  3009. optimized,
  3010. )
  3011. setActiveBranch(suspense, fallbackVNode)
  3012. }
  3013. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in'
  3014. if (delayEnter)
  3015. activeBranch.transition.afterLeave = mountFallback
  3016. suspense.isInFallback = true
  3017. unmount(
  3018. activeBranch,
  3019. parentComponent2,
  3020. null,
  3021. // no suspense so unmount hooks fire now
  3022. true,
  3023. // shouldRemove
  3024. )
  3025. if (!delayEnter)
  3026. mountFallback()
  3027. },
  3028. move(container2, anchor2, type) {
  3029. suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type)
  3030. suspense.container = container2
  3031. },
  3032. next() {
  3033. return suspense.activeBranch && next(suspense.activeBranch)
  3034. },
  3035. registerDep(instance, setupRenderEffect) {
  3036. const isInPendingSuspense = !!suspense.pendingBranch
  3037. if (isInPendingSuspense)
  3038. suspense.deps++
  3039. const hydratedEl = instance.vnode.el
  3040. instance.asyncDep.catch((err) => {
  3041. handleError(err, instance, 0)
  3042. }).then((asyncSetupResult) => {
  3043. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId)
  3044. return
  3045. instance.asyncResolved = true
  3046. const { vnode: vnode2 } = instance
  3047. {
  3048. pushWarningContext(vnode2)
  3049. }
  3050. handleSetupResult(instance, asyncSetupResult, false)
  3051. if (hydratedEl)
  3052. vnode2.el = hydratedEl
  3053. const placeholder = !hydratedEl && instance.subTree.el
  3054. setupRenderEffect(
  3055. instance,
  3056. vnode2,
  3057. // component may have been moved before resolve.
  3058. // if this is not a hydration, instance.subTree will be the comment
  3059. // placeholder.
  3060. parentNode(hydratedEl || instance.subTree.el),
  3061. // anchor will not be used if this is hydration, so only need to
  3062. // consider the comment placeholder case.
  3063. hydratedEl ? null : next(instance.subTree),
  3064. suspense,
  3065. namespace,
  3066. optimized,
  3067. )
  3068. if (placeholder)
  3069. remove(placeholder)
  3070. updateHOCHostEl(instance, vnode2.el)
  3071. {
  3072. popWarningContext()
  3073. }
  3074. if (isInPendingSuspense && --suspense.deps === 0)
  3075. suspense.resolve()
  3076. })
  3077. },
  3078. unmount(parentSuspense2, doRemove) {
  3079. suspense.isUnmounted = true
  3080. if (suspense.activeBranch) {
  3081. unmount(
  3082. suspense.activeBranch,
  3083. parentComponent,
  3084. parentSuspense2,
  3085. doRemove,
  3086. )
  3087. }
  3088. if (suspense.pendingBranch) {
  3089. unmount(
  3090. suspense.pendingBranch,
  3091. parentComponent,
  3092. parentSuspense2,
  3093. doRemove,
  3094. )
  3095. }
  3096. },
  3097. }
  3098. return suspense
  3099. }
  3100. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  3101. const suspense = vnode.suspense = createSuspenseBoundary(
  3102. vnode,
  3103. parentSuspense,
  3104. parentComponent,
  3105. node.parentNode,
  3106. document.createElement('div'),
  3107. null,
  3108. namespace,
  3109. slotScopeIds,
  3110. optimized,
  3111. rendererInternals,
  3112. true,
  3113. )
  3114. const result = hydrateNode(
  3115. node,
  3116. suspense.pendingBranch = vnode.ssContent,
  3117. parentComponent,
  3118. suspense,
  3119. slotScopeIds,
  3120. optimized,
  3121. )
  3122. if (suspense.deps === 0)
  3123. suspense.resolve(false, true)
  3124. return result
  3125. }
  3126. function normalizeSuspenseChildren(vnode) {
  3127. const { shapeFlag, children } = vnode
  3128. const isSlotChildren = shapeFlag & 32
  3129. vnode.ssContent = normalizeSuspenseSlot(
  3130. isSlotChildren ? children.default : children,
  3131. )
  3132. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment)
  3133. }
  3134. function normalizeSuspenseSlot(s) {
  3135. let block
  3136. if (isFunction(s)) {
  3137. const trackBlock = isBlockTreeEnabled && s._c
  3138. if (trackBlock) {
  3139. s._d = false
  3140. openBlock()
  3141. }
  3142. s = s()
  3143. if (trackBlock) {
  3144. s._d = true
  3145. block = currentBlock
  3146. closeBlock()
  3147. }
  3148. }
  3149. if (isArray(s)) {
  3150. const singleChild = filterSingleRoot(s)
  3151. if (!singleChild && s.filter(child => child !== NULL_DYNAMIC_COMPONENT).length > 0)
  3152. warn$1(`<Suspense> slots expect a single root node.`)
  3153. s = singleChild
  3154. }
  3155. s = normalizeVNode(s)
  3156. if (block && !s.dynamicChildren)
  3157. s.dynamicChildren = block.filter(c => c !== s)
  3158. return s
  3159. }
  3160. function queueEffectWithSuspense(fn, suspense) {
  3161. if (suspense && suspense.pendingBranch) {
  3162. if (isArray(fn))
  3163. suspense.effects.push(...fn)
  3164. else
  3165. suspense.effects.push(fn)
  3166. }
  3167. else {
  3168. queuePostFlushCb(fn)
  3169. }
  3170. }
  3171. function setActiveBranch(suspense, branch) {
  3172. suspense.activeBranch = branch
  3173. const { vnode, parentComponent } = suspense
  3174. let el = branch.el
  3175. while (!el && branch.component) {
  3176. branch = branch.component.subTree
  3177. el = branch.el
  3178. }
  3179. vnode.el = el
  3180. if (parentComponent && parentComponent.subTree === vnode) {
  3181. parentComponent.vnode.el = el
  3182. updateHOCHostEl(parentComponent, el)
  3183. }
  3184. }
  3185. function isVNodeSuspensible(vnode) {
  3186. const suspensible = vnode.props && vnode.props.suspensible
  3187. return suspensible != null && suspensible !== false
  3188. }
  3189. const ssrContextKey = Symbol.for('v-scx')
  3190. function useSSRContext() {
  3191. {
  3192. const ctx = inject(ssrContextKey)
  3193. if (!ctx) {
  3194. warn$1(
  3195. `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`,
  3196. )
  3197. }
  3198. return ctx
  3199. }
  3200. }
  3201. function watchEffect(effect, options) {
  3202. return doWatch(effect, null, options)
  3203. }
  3204. function watchPostEffect(effect, options) {
  3205. return doWatch(
  3206. effect,
  3207. null,
  3208. extend({}, options, { flush: 'post' }),
  3209. )
  3210. }
  3211. function watchSyncEffect(effect, options) {
  3212. return doWatch(
  3213. effect,
  3214. null,
  3215. extend({}, options, { flush: 'sync' }),
  3216. )
  3217. }
  3218. const INITIAL_WATCHER_VALUE = {}
  3219. function watch(source, cb, options) {
  3220. if (!isFunction(cb)) {
  3221. warn$1(
  3222. `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`,
  3223. )
  3224. }
  3225. return doWatch(source, cb, options)
  3226. }
  3227. function doWatch(source, cb, {
  3228. immediate,
  3229. deep,
  3230. flush,
  3231. once,
  3232. onTrack,
  3233. onTrigger,
  3234. } = EMPTY_OBJ) {
  3235. if (cb && once) {
  3236. const _cb = cb
  3237. cb = (...args) => {
  3238. _cb(...args)
  3239. unwatch()
  3240. }
  3241. }
  3242. if (deep !== void 0 && typeof deep === 'number') {
  3243. warn$1(
  3244. `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`,
  3245. )
  3246. }
  3247. if (!cb) {
  3248. if (immediate !== void 0) {
  3249. warn$1(
  3250. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`,
  3251. )
  3252. }
  3253. if (deep !== void 0) {
  3254. warn$1(
  3255. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`,
  3256. )
  3257. }
  3258. if (once !== void 0) {
  3259. warn$1(
  3260. `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`,
  3261. )
  3262. }
  3263. }
  3264. const warnInvalidSource = (s) => {
  3265. warn$1(
  3266. `Invalid watch source: `,
  3267. s,
  3268. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`,
  3269. )
  3270. }
  3271. const instance = currentInstance
  3272. const reactiveGetter = source2 => deep === true ? source2 : (
  3273. // for deep: false, only traverse root-level properties
  3274. traverse(source2, deep === false ? 1 : void 0)
  3275. )
  3276. let getter
  3277. let forceTrigger = false
  3278. let isMultiSource = false
  3279. if (isRef(source)) {
  3280. getter = () => source.value
  3281. forceTrigger = isShallow(source)
  3282. }
  3283. else if (isReactive(source)) {
  3284. getter = () => reactiveGetter(source)
  3285. forceTrigger = true
  3286. }
  3287. else if (isArray(source)) {
  3288. isMultiSource = true
  3289. forceTrigger = source.some(s => isReactive(s) || isShallow(s))
  3290. getter = () => source.map((s) => {
  3291. if (isRef(s))
  3292. return s.value
  3293. else if (isReactive(s))
  3294. return reactiveGetter(s)
  3295. else if (isFunction(s))
  3296. return callWithErrorHandling(s, instance, 2)
  3297. else
  3298. warnInvalidSource(s)
  3299. })
  3300. }
  3301. else if (isFunction(source)) {
  3302. if (cb) {
  3303. getter = () => callWithErrorHandling(source, instance, 2)
  3304. }
  3305. else {
  3306. getter = () => {
  3307. if (cleanup)
  3308. cleanup()
  3309. return callWithAsyncErrorHandling(
  3310. source,
  3311. instance,
  3312. 3,
  3313. [onCleanup],
  3314. )
  3315. }
  3316. }
  3317. }
  3318. else {
  3319. getter = NOOP
  3320. warnInvalidSource(source)
  3321. }
  3322. if (cb && deep) {
  3323. const baseGetter = getter
  3324. getter = () => traverse(baseGetter())
  3325. }
  3326. let cleanup
  3327. let onCleanup = (fn) => {
  3328. cleanup = effect.onStop = () => {
  3329. callWithErrorHandling(fn, instance, 4)
  3330. cleanup = effect.onStop = void 0
  3331. }
  3332. }
  3333. let oldValue = isMultiSource ? Array.from({ length: source.length }).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE
  3334. const job = () => {
  3335. if (!effect.active || !effect.dirty)
  3336. return
  3337. if (cb) {
  3338. const newValue = effect.run()
  3339. if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
  3340. if (cleanup)
  3341. cleanup()
  3342. callWithAsyncErrorHandling(cb, instance, 3, [
  3343. newValue,
  3344. // pass undefined as the old value when it's changed for the first time
  3345. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  3346. onCleanup,
  3347. ])
  3348. oldValue = newValue
  3349. }
  3350. }
  3351. else {
  3352. effect.run()
  3353. }
  3354. }
  3355. job.allowRecurse = !!cb
  3356. let scheduler
  3357. if (flush === 'sync') {
  3358. scheduler = job
  3359. }
  3360. else if (flush === 'post') {
  3361. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense)
  3362. }
  3363. else {
  3364. job.pre = true
  3365. if (instance)
  3366. job.id = instance.uid
  3367. scheduler = () => queueJob(job)
  3368. }
  3369. const effect = new ReactiveEffect(getter, NOOP, scheduler)
  3370. const scope = getCurrentScope()
  3371. const unwatch = () => {
  3372. effect.stop()
  3373. if (scope)
  3374. remove(scope.effects, effect)
  3375. }
  3376. {
  3377. effect.onTrack = onTrack
  3378. effect.onTrigger = onTrigger
  3379. }
  3380. if (cb) {
  3381. if (immediate)
  3382. job()
  3383. else
  3384. oldValue = effect.run()
  3385. }
  3386. else if (flush === 'post') {
  3387. queuePostRenderEffect(
  3388. effect.run.bind(effect),
  3389. instance && instance.suspense,
  3390. )
  3391. }
  3392. else {
  3393. effect.run()
  3394. }
  3395. return unwatch
  3396. }
  3397. function instanceWatch(source, value, options) {
  3398. const publicThis = this.proxy
  3399. const getter = isString(source) ? source.includes('.') ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis)
  3400. let cb
  3401. if (isFunction(value)) {
  3402. cb = value
  3403. }
  3404. else {
  3405. cb = value.handler
  3406. options = value
  3407. }
  3408. const reset = setCurrentInstance(this)
  3409. const res = doWatch(getter, cb.bind(publicThis), options)
  3410. reset()
  3411. return res
  3412. }
  3413. function createPathGetter(ctx, path) {
  3414. const segments = path.split('.')
  3415. return () => {
  3416. let cur = ctx
  3417. for (let i = 0; i < segments.length && cur; i++)
  3418. cur = cur[segments[i]]
  3419. return cur
  3420. }
  3421. }
  3422. function traverse(value, depth = Number.POSITIVE_INFINITY, seen) {
  3423. if (depth <= 0 || !isObject(value) || value.__v_skip)
  3424. return value
  3425. seen = seen || /* @__PURE__ */ new Set()
  3426. if (seen.has(value))
  3427. return value
  3428. seen.add(value)
  3429. depth--
  3430. if (isRef(value)) {
  3431. traverse(value.value, depth, seen)
  3432. }
  3433. else if (isArray(value)) {
  3434. for (let i = 0; i < value.length; i++)
  3435. traverse(value[i], depth, seen)
  3436. }
  3437. else if (isSet(value) || isMap(value)) {
  3438. value.forEach((v) => {
  3439. traverse(v, depth, seen)
  3440. })
  3441. }
  3442. else if (isPlainObject(value)) {
  3443. for (const key in value)
  3444. traverse(value[key], depth, seen)
  3445. }
  3446. return value
  3447. }
  3448. function validateDirectiveName(name) {
  3449. if (isBuiltInDirective(name))
  3450. warn$1(`Do not use built-in directive ids as custom directive id: ${name}`)
  3451. }
  3452. function withDirectives(vnode, directives) {
  3453. if (currentRenderingInstance === null) {
  3454. warn$1(`withDirectives can only be used inside render functions.`)
  3455. return vnode
  3456. }
  3457. const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy
  3458. const bindings = vnode.dirs || (vnode.dirs = [])
  3459. for (let i = 0; i < directives.length; i++) {
  3460. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i]
  3461. if (dir) {
  3462. if (isFunction(dir)) {
  3463. dir = {
  3464. mounted: dir,
  3465. updated: dir,
  3466. }
  3467. }
  3468. if (dir.deep)
  3469. traverse(value)
  3470. bindings.push({
  3471. dir,
  3472. instance,
  3473. value,
  3474. oldValue: void 0,
  3475. arg,
  3476. modifiers,
  3477. })
  3478. }
  3479. }
  3480. return vnode
  3481. }
  3482. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  3483. const bindings = vnode.dirs
  3484. const oldBindings = prevVNode && prevVNode.dirs
  3485. for (let i = 0; i < bindings.length; i++) {
  3486. const binding = bindings[i]
  3487. if (oldBindings)
  3488. binding.oldValue = oldBindings[i].value
  3489. const hook = binding.dir[name]
  3490. if (hook) {
  3491. pauseTracking()
  3492. callWithAsyncErrorHandling(hook, instance, 8, [
  3493. vnode.el,
  3494. binding,
  3495. vnode,
  3496. prevVNode,
  3497. ])
  3498. resetTracking()
  3499. }
  3500. }
  3501. }
  3502. const leaveCbKey = Symbol('_leaveCb')
  3503. const enterCbKey$1 = Symbol('_enterCb')
  3504. function useTransitionState() {
  3505. const state = {
  3506. isMounted: false,
  3507. isLeaving: false,
  3508. isUnmounting: false,
  3509. leavingVNodes: /* @__PURE__ */ new Map(),
  3510. }
  3511. onMounted(() => {
  3512. state.isMounted = true
  3513. })
  3514. onBeforeUnmount(() => {
  3515. state.isUnmounting = true
  3516. })
  3517. return state
  3518. }
  3519. const TransitionHookValidator = [Function, Array]
  3520. const BaseTransitionPropsValidators = {
  3521. mode: String,
  3522. appear: Boolean,
  3523. persisted: Boolean,
  3524. // enter
  3525. onBeforeEnter: TransitionHookValidator,
  3526. onEnter: TransitionHookValidator,
  3527. onAfterEnter: TransitionHookValidator,
  3528. onEnterCancelled: TransitionHookValidator,
  3529. // leave
  3530. onBeforeLeave: TransitionHookValidator,
  3531. onLeave: TransitionHookValidator,
  3532. onAfterLeave: TransitionHookValidator,
  3533. onLeaveCancelled: TransitionHookValidator,
  3534. // appear
  3535. onBeforeAppear: TransitionHookValidator,
  3536. onAppear: TransitionHookValidator,
  3537. onAfterAppear: TransitionHookValidator,
  3538. onAppearCancelled: TransitionHookValidator,
  3539. }
  3540. const BaseTransitionImpl = {
  3541. name: `BaseTransition`,
  3542. props: BaseTransitionPropsValidators,
  3543. setup(props, { slots }) {
  3544. const instance = getCurrentInstance()
  3545. const state = useTransitionState()
  3546. return () => {
  3547. const children = slots.default && getTransitionRawChildren(slots.default(), true)
  3548. if (!children || !children.length)
  3549. return
  3550. let child = children[0]
  3551. if (children.length > 1) {
  3552. let hasFound = false
  3553. for (const c of children) {
  3554. if (c.type !== Comment) {
  3555. if (hasFound) {
  3556. warn$1(
  3557. '<transition> can only be used on a single element or component. Use <transition-group> for lists.',
  3558. )
  3559. break
  3560. }
  3561. child = c
  3562. hasFound = true
  3563. }
  3564. }
  3565. }
  3566. const rawProps = toRaw(props)
  3567. const { mode } = rawProps
  3568. if (mode && mode !== 'in-out' && mode !== 'out-in' && mode !== 'default')
  3569. warn$1(`invalid <transition> mode: ${mode}`)
  3570. if (state.isLeaving)
  3571. return emptyPlaceholder(child)
  3572. const innerChild = getKeepAliveChild(child)
  3573. if (!innerChild)
  3574. return emptyPlaceholder(child)
  3575. const enterHooks = resolveTransitionHooks(
  3576. innerChild,
  3577. rawProps,
  3578. state,
  3579. instance,
  3580. )
  3581. setTransitionHooks(innerChild, enterHooks)
  3582. const oldChild = instance.subTree
  3583. const oldInnerChild = oldChild && getKeepAliveChild(oldChild)
  3584. if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
  3585. const leavingHooks = resolveTransitionHooks(
  3586. oldInnerChild,
  3587. rawProps,
  3588. state,
  3589. instance,
  3590. )
  3591. setTransitionHooks(oldInnerChild, leavingHooks)
  3592. if (mode === 'out-in' && innerChild.type !== Comment) {
  3593. state.isLeaving = true
  3594. leavingHooks.afterLeave = () => {
  3595. state.isLeaving = false
  3596. if (instance.update.active !== false) {
  3597. instance.effect.dirty = true
  3598. instance.update()
  3599. }
  3600. }
  3601. return emptyPlaceholder(child)
  3602. }
  3603. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3604. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3605. const leavingVNodesCache = getLeavingNodesForType(
  3606. state,
  3607. oldInnerChild,
  3608. )
  3609. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild
  3610. el[leaveCbKey] = () => {
  3611. earlyRemove()
  3612. el[leaveCbKey] = void 0
  3613. delete enterHooks.delayedLeave
  3614. }
  3615. enterHooks.delayedLeave = delayedLeave
  3616. }
  3617. }
  3618. }
  3619. return child
  3620. }
  3621. },
  3622. }
  3623. const BaseTransition = BaseTransitionImpl
  3624. function getLeavingNodesForType(state, vnode) {
  3625. const { leavingVNodes } = state
  3626. let leavingVNodesCache = leavingVNodes.get(vnode.type)
  3627. if (!leavingVNodesCache) {
  3628. leavingVNodesCache = /* @__PURE__ */ Object.create(null)
  3629. leavingVNodes.set(vnode.type, leavingVNodesCache)
  3630. }
  3631. return leavingVNodesCache
  3632. }
  3633. function resolveTransitionHooks(vnode, props, state, instance) {
  3634. const {
  3635. appear,
  3636. mode,
  3637. persisted = false,
  3638. onBeforeEnter,
  3639. onEnter,
  3640. onAfterEnter,
  3641. onEnterCancelled,
  3642. onBeforeLeave,
  3643. onLeave,
  3644. onAfterLeave,
  3645. onLeaveCancelled,
  3646. onBeforeAppear,
  3647. onAppear,
  3648. onAfterAppear,
  3649. onAppearCancelled,
  3650. } = props
  3651. const key = String(vnode.key)
  3652. const leavingVNodesCache = getLeavingNodesForType(state, vnode)
  3653. const callHook = (hook, args) => {
  3654. hook && callWithAsyncErrorHandling(
  3655. hook,
  3656. instance,
  3657. 9,
  3658. args,
  3659. )
  3660. }
  3661. const callAsyncHook = (hook, args) => {
  3662. const done = args[1]
  3663. callHook(hook, args)
  3664. if (isArray(hook)) {
  3665. if (hook.every(hook2 => hook2.length <= 1))
  3666. done()
  3667. }
  3668. else if (hook.length <= 1) {
  3669. done()
  3670. }
  3671. }
  3672. const hooks = {
  3673. mode,
  3674. persisted,
  3675. beforeEnter(el) {
  3676. let hook = onBeforeEnter
  3677. if (!state.isMounted) {
  3678. if (appear)
  3679. hook = onBeforeAppear || onBeforeEnter
  3680. else
  3681. return
  3682. }
  3683. if (el[leaveCbKey]) {
  3684. el[leaveCbKey](
  3685. true,
  3686. /* cancelled */
  3687. )
  3688. }
  3689. const leavingVNode = leavingVNodesCache[key]
  3690. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey])
  3691. leavingVNode.el[leaveCbKey]()
  3692. callHook(hook, [el])
  3693. },
  3694. enter(el) {
  3695. let hook = onEnter
  3696. let afterHook = onAfterEnter
  3697. let cancelHook = onEnterCancelled
  3698. if (!state.isMounted) {
  3699. if (appear) {
  3700. hook = onAppear || onEnter
  3701. afterHook = onAfterAppear || onAfterEnter
  3702. cancelHook = onAppearCancelled || onEnterCancelled
  3703. }
  3704. else {
  3705. return
  3706. }
  3707. }
  3708. let called = false
  3709. const done = el[enterCbKey$1] = (cancelled) => {
  3710. if (called)
  3711. return
  3712. called = true
  3713. if (cancelled)
  3714. callHook(cancelHook, [el])
  3715. else
  3716. callHook(afterHook, [el])
  3717. if (hooks.delayedLeave)
  3718. hooks.delayedLeave()
  3719. el[enterCbKey$1] = void 0
  3720. }
  3721. if (hook)
  3722. callAsyncHook(hook, [el, done])
  3723. else
  3724. done()
  3725. },
  3726. leave(el, remove) {
  3727. const key2 = String(vnode.key)
  3728. if (el[enterCbKey$1]) {
  3729. el[enterCbKey$1](
  3730. true,
  3731. /* cancelled */
  3732. )
  3733. }
  3734. if (state.isUnmounting)
  3735. return remove()
  3736. callHook(onBeforeLeave, [el])
  3737. let called = false
  3738. const done = el[leaveCbKey] = (cancelled) => {
  3739. if (called)
  3740. return
  3741. called = true
  3742. remove()
  3743. if (cancelled)
  3744. callHook(onLeaveCancelled, [el])
  3745. else
  3746. callHook(onAfterLeave, [el])
  3747. el[leaveCbKey] = void 0
  3748. if (leavingVNodesCache[key2] === vnode)
  3749. delete leavingVNodesCache[key2]
  3750. }
  3751. leavingVNodesCache[key2] = vnode
  3752. if (onLeave)
  3753. callAsyncHook(onLeave, [el, done])
  3754. else
  3755. done()
  3756. },
  3757. clone(vnode2) {
  3758. return resolveTransitionHooks(vnode2, props, state, instance)
  3759. },
  3760. }
  3761. return hooks
  3762. }
  3763. function emptyPlaceholder(vnode) {
  3764. if (isKeepAlive(vnode)) {
  3765. vnode = cloneVNode(vnode)
  3766. vnode.children = null
  3767. return vnode
  3768. }
  3769. }
  3770. function getKeepAliveChild(vnode) {
  3771. if (!isKeepAlive(vnode))
  3772. return vnode
  3773. if (vnode.component)
  3774. return vnode.component.subTree
  3775. const { shapeFlag, children } = vnode
  3776. if (children) {
  3777. if (shapeFlag & 16)
  3778. return children[0]
  3779. if (shapeFlag & 32 && isFunction(children.default))
  3780. return children.default()
  3781. }
  3782. }
  3783. function setTransitionHooks(vnode, hooks) {
  3784. if (vnode.shapeFlag & 6 && vnode.component) {
  3785. setTransitionHooks(vnode.component.subTree, hooks)
  3786. }
  3787. else if (vnode.shapeFlag & 128) {
  3788. vnode.ssContent.transition = hooks.clone(vnode.ssContent)
  3789. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback)
  3790. }
  3791. else {
  3792. vnode.transition = hooks
  3793. }
  3794. }
  3795. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3796. let ret = []
  3797. let keyedFragmentCount = 0
  3798. for (let i = 0; i < children.length; i++) {
  3799. const child = children[i]
  3800. const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i)
  3801. if (child.type === Fragment) {
  3802. if (child.patchFlag & 128)
  3803. keyedFragmentCount++
  3804. ret = ret.concat(
  3805. getTransitionRawChildren(child.children, keepComment, key),
  3806. )
  3807. }
  3808. else if (keepComment || child.type !== Comment) {
  3809. ret.push(key != null ? cloneVNode(child, { key }) : child)
  3810. }
  3811. }
  3812. if (keyedFragmentCount > 1) {
  3813. for (let i = 0; i < ret.length; i++)
  3814. ret[i].patchFlag = -2
  3815. }
  3816. return ret
  3817. }
  3818. /*! #__NO_SIDE_EFFECTS__ */
  3819. // @__NO_SIDE_EFFECTS__
  3820. function defineComponent(options, extraOptions) {
  3821. return isFunction(options) ? (
  3822. // #8326: extend call and options.name access are considered side-effects
  3823. // by Rollup, so we have to wrap it in a pure-annotated IIFE.
  3824. /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
  3825. ) : options
  3826. }
  3827. const isAsyncWrapper = i => !!i.type.__asyncLoader
  3828. /*! #__NO_SIDE_EFFECTS__ */
  3829. // @__NO_SIDE_EFFECTS__
  3830. function defineAsyncComponent(source) {
  3831. if (isFunction(source))
  3832. source = { loader: source }
  3833. const {
  3834. loader,
  3835. loadingComponent,
  3836. errorComponent,
  3837. delay = 200,
  3838. timeout,
  3839. // undefined = never times out
  3840. suspensible = true,
  3841. onError: userOnError,
  3842. } = source
  3843. let pendingRequest = null
  3844. let resolvedComp
  3845. let retries = 0
  3846. const retry = () => {
  3847. retries++
  3848. pendingRequest = null
  3849. return load()
  3850. }
  3851. const load = () => {
  3852. let thisRequest
  3853. return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
  3854. err = err instanceof Error ? err : new Error(String(err))
  3855. if (userOnError) {
  3856. return new Promise((resolve, reject) => {
  3857. const userRetry = () => resolve(retry())
  3858. const userFail = () => reject(err)
  3859. userOnError(err, userRetry, userFail, retries + 1)
  3860. })
  3861. }
  3862. else {
  3863. throw err
  3864. }
  3865. }).then((comp) => {
  3866. if (thisRequest !== pendingRequest && pendingRequest)
  3867. return pendingRequest
  3868. if (!comp) {
  3869. warn$1(
  3870. `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`,
  3871. )
  3872. }
  3873. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === 'Module'))
  3874. comp = comp.default
  3875. if (comp && !isObject(comp) && !isFunction(comp))
  3876. throw new Error(`Invalid async component load result: ${comp}`)
  3877. resolvedComp = comp
  3878. return comp
  3879. }))
  3880. }
  3881. return defineComponent({
  3882. name: 'AsyncComponentWrapper',
  3883. __asyncLoader: load,
  3884. get __asyncResolved() {
  3885. return resolvedComp
  3886. },
  3887. setup() {
  3888. const instance = currentInstance
  3889. if (resolvedComp)
  3890. return () => createInnerComp(resolvedComp, instance)
  3891. const onError = (err) => {
  3892. pendingRequest = null
  3893. handleError(
  3894. err,
  3895. instance,
  3896. 13,
  3897. !errorComponent,
  3898. )
  3899. }
  3900. if (suspensible && instance.suspense || false) {
  3901. return load().then((comp) => {
  3902. return () => createInnerComp(comp, instance)
  3903. }).catch((err) => {
  3904. onError(err)
  3905. return () => errorComponent
  3906. ? createVNode(errorComponent, {
  3907. error: err,
  3908. })
  3909. : null
  3910. })
  3911. }
  3912. const loaded = ref(false)
  3913. const error = ref()
  3914. const delayed = ref(!!delay)
  3915. if (delay) {
  3916. setTimeout(() => {
  3917. delayed.value = false
  3918. }, delay)
  3919. }
  3920. if (timeout != null) {
  3921. setTimeout(() => {
  3922. if (!loaded.value && !error.value) {
  3923. const err = new Error(
  3924. `Async component timed out after ${timeout}ms.`,
  3925. )
  3926. onError(err)
  3927. error.value = err
  3928. }
  3929. }, timeout)
  3930. }
  3931. load().then(() => {
  3932. loaded.value = true
  3933. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3934. instance.parent.effect.dirty = true
  3935. queueJob(instance.parent.update)
  3936. }
  3937. }).catch((err) => {
  3938. onError(err)
  3939. error.value = err
  3940. })
  3941. return () => {
  3942. if (loaded.value && resolvedComp) {
  3943. return createInnerComp(resolvedComp, instance)
  3944. }
  3945. else if (error.value && errorComponent) {
  3946. return createVNode(errorComponent, {
  3947. error: error.value,
  3948. })
  3949. }
  3950. else if (loadingComponent && !delayed.value) {
  3951. return createVNode(loadingComponent)
  3952. }
  3953. }
  3954. },
  3955. })
  3956. }
  3957. function createInnerComp(comp, parent) {
  3958. const { ref: ref2, props, children, ce } = parent.vnode
  3959. const vnode = createVNode(comp, props, children)
  3960. vnode.ref = ref2
  3961. vnode.ce = ce
  3962. delete parent.vnode.ce
  3963. return vnode
  3964. }
  3965. const isKeepAlive = vnode => vnode.type.__isKeepAlive
  3966. const KeepAliveImpl = {
  3967. name: `KeepAlive`,
  3968. // Marker for special handling inside the renderer. We are not using a ===
  3969. // check directly on KeepAlive in the renderer, because importing it directly
  3970. // would prevent it from being tree-shaken.
  3971. __isKeepAlive: true,
  3972. props: {
  3973. include: [String, RegExp, Array],
  3974. exclude: [String, RegExp, Array],
  3975. max: [String, Number],
  3976. },
  3977. setup(props, { slots }) {
  3978. const instance = getCurrentInstance()
  3979. const sharedContext = instance.ctx
  3980. const cache = /* @__PURE__ */ new Map()
  3981. const keys = /* @__PURE__ */ new Set()
  3982. let current = null
  3983. {
  3984. instance.__v_cache = cache
  3985. }
  3986. const parentSuspense = instance.suspense
  3987. const {
  3988. renderer: {
  3989. p: patch,
  3990. m: move,
  3991. um: _unmount,
  3992. o: { createElement },
  3993. },
  3994. } = sharedContext
  3995. const storageContainer = createElement('div')
  3996. sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
  3997. const instance2 = vnode.component
  3998. move(vnode, container, anchor, 0, parentSuspense)
  3999. patch(
  4000. instance2.vnode,
  4001. vnode,
  4002. container,
  4003. anchor,
  4004. instance2,
  4005. parentSuspense,
  4006. namespace,
  4007. vnode.slotScopeIds,
  4008. optimized,
  4009. )
  4010. queuePostRenderEffect(() => {
  4011. instance2.isDeactivated = false
  4012. if (instance2.a)
  4013. invokeArrayFns(instance2.a)
  4014. const vnodeHook = vnode.props && vnode.props.onVnodeMounted
  4015. if (vnodeHook)
  4016. invokeVNodeHook(vnodeHook, instance2.parent, vnode)
  4017. }, parentSuspense)
  4018. {
  4019. devtoolsComponentAdded(instance2)
  4020. }
  4021. }
  4022. sharedContext.deactivate = (vnode) => {
  4023. const instance2 = vnode.component
  4024. move(vnode, storageContainer, null, 1, parentSuspense)
  4025. queuePostRenderEffect(() => {
  4026. if (instance2.da)
  4027. invokeArrayFns(instance2.da)
  4028. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted
  4029. if (vnodeHook)
  4030. invokeVNodeHook(vnodeHook, instance2.parent, vnode)
  4031. instance2.isDeactivated = true
  4032. }, parentSuspense)
  4033. {
  4034. devtoolsComponentAdded(instance2)
  4035. }
  4036. }
  4037. function unmount(vnode) {
  4038. resetShapeFlag(vnode)
  4039. _unmount(vnode, instance, parentSuspense, true)
  4040. }
  4041. function pruneCache(filter) {
  4042. cache.forEach((vnode, key) => {
  4043. const name = getComponentName(vnode.type)
  4044. if (name && (!filter || !filter(name)))
  4045. pruneCacheEntry(key)
  4046. })
  4047. }
  4048. function pruneCacheEntry(key) {
  4049. const cached = cache.get(key)
  4050. if (!current || !isSameVNodeType(cached, current))
  4051. unmount(cached)
  4052. else if (current)
  4053. resetShapeFlag(current)
  4054. cache.delete(key)
  4055. keys.delete(key)
  4056. }
  4057. watch(
  4058. () => [props.include, props.exclude],
  4059. ([include, exclude]) => {
  4060. include && pruneCache(name => matches(include, name))
  4061. exclude && pruneCache(name => !matches(exclude, name))
  4062. },
  4063. // prune post-render after `current` has been updated
  4064. { flush: 'post', deep: true },
  4065. )
  4066. let pendingCacheKey = null
  4067. const cacheSubtree = () => {
  4068. if (pendingCacheKey != null)
  4069. cache.set(pendingCacheKey, getInnerChild(instance.subTree))
  4070. }
  4071. onMounted(cacheSubtree)
  4072. onUpdated(cacheSubtree)
  4073. onBeforeUnmount(() => {
  4074. cache.forEach((cached) => {
  4075. const { subTree, suspense } = instance
  4076. const vnode = getInnerChild(subTree)
  4077. if (cached.type === vnode.type && cached.key === vnode.key) {
  4078. resetShapeFlag(vnode)
  4079. const da = vnode.component.da
  4080. da && queuePostRenderEffect(da, suspense)
  4081. return
  4082. }
  4083. unmount(cached)
  4084. })
  4085. })
  4086. return () => {
  4087. pendingCacheKey = null
  4088. if (!slots.default)
  4089. return null
  4090. const children = slots.default()
  4091. const rawVNode = children[0]
  4092. if (children.length > 1) {
  4093. {
  4094. warn$1(`KeepAlive should contain exactly one component child.`)
  4095. }
  4096. current = null
  4097. return children
  4098. }
  4099. else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
  4100. current = null
  4101. return rawVNode
  4102. }
  4103. let vnode = getInnerChild(rawVNode)
  4104. const comp = vnode.type
  4105. const name = getComponentName(
  4106. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp,
  4107. )
  4108. const { include, exclude, max } = props
  4109. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  4110. current = vnode
  4111. return rawVNode
  4112. }
  4113. const key = vnode.key == null ? comp : vnode.key
  4114. const cachedVNode = cache.get(key)
  4115. if (vnode.el) {
  4116. vnode = cloneVNode(vnode)
  4117. if (rawVNode.shapeFlag & 128)
  4118. rawVNode.ssContent = vnode
  4119. }
  4120. pendingCacheKey = key
  4121. if (cachedVNode) {
  4122. vnode.el = cachedVNode.el
  4123. vnode.component = cachedVNode.component
  4124. if (vnode.transition)
  4125. setTransitionHooks(vnode, vnode.transition)
  4126. vnode.shapeFlag |= 512
  4127. keys.delete(key)
  4128. keys.add(key)
  4129. }
  4130. else {
  4131. keys.add(key)
  4132. if (max && keys.size > Number.parseInt(max, 10))
  4133. pruneCacheEntry(keys.values().next().value)
  4134. }
  4135. vnode.shapeFlag |= 256
  4136. current = vnode
  4137. return isSuspense(rawVNode.type) ? rawVNode : vnode
  4138. }
  4139. },
  4140. }
  4141. const KeepAlive = KeepAliveImpl
  4142. function matches(pattern, name) {
  4143. if (isArray(pattern))
  4144. return pattern.some(p => matches(p, name))
  4145. else if (isString(pattern))
  4146. return pattern.split(',').includes(name)
  4147. else if (isRegExp(pattern))
  4148. return pattern.test(name)
  4149. return false
  4150. }
  4151. function onActivated(hook, target) {
  4152. registerKeepAliveHook(hook, 'a', target)
  4153. }
  4154. function onDeactivated(hook, target) {
  4155. registerKeepAliveHook(hook, 'da', target)
  4156. }
  4157. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4158. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  4159. let current = target
  4160. while (current) {
  4161. if (current.isDeactivated)
  4162. return
  4163. current = current.parent
  4164. }
  4165. return hook()
  4166. })
  4167. injectHook(type, wrappedHook, target)
  4168. if (target) {
  4169. let current = target.parent
  4170. while (current && current.parent) {
  4171. if (isKeepAlive(current.parent.vnode))
  4172. injectToKeepAliveRoot(wrappedHook, type, target, current)
  4173. current = current.parent
  4174. }
  4175. }
  4176. }
  4177. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4178. const injected = injectHook(
  4179. type,
  4180. hook,
  4181. keepAliveRoot,
  4182. true,
  4183. /* prepend */
  4184. )
  4185. onUnmounted(() => {
  4186. remove(keepAliveRoot[type], injected)
  4187. }, target)
  4188. }
  4189. function resetShapeFlag(vnode) {
  4190. vnode.shapeFlag &= ~256
  4191. vnode.shapeFlag &= ~512
  4192. }
  4193. function getInnerChild(vnode) {
  4194. return vnode.shapeFlag & 128 ? vnode.ssContent : vnode
  4195. }
  4196. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4197. if (target) {
  4198. const hooks = target[type] || (target[type] = [])
  4199. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  4200. if (target.isUnmounted)
  4201. return
  4202. pauseTracking()
  4203. const reset = setCurrentInstance(target)
  4204. const res = callWithAsyncErrorHandling(hook, target, type, args)
  4205. reset()
  4206. resetTracking()
  4207. return res
  4208. })
  4209. if (prepend)
  4210. hooks.unshift(wrappedHook)
  4211. else
  4212. hooks.push(wrappedHook)
  4213. return wrappedHook
  4214. }
  4215. else {
  4216. const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ''))
  4217. warn$1(
  4218. `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`),
  4219. )
  4220. }
  4221. }
  4222. function createHook(lifecycle) {
  4223. return (hook, target = currentInstance) => (
  4224. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4225. (!isInSSRComponentSetup || lifecycle === 'sp') && injectHook(lifecycle, (...args) => hook(...args), target)
  4226. )
  4227. }
  4228. const onBeforeMount = createHook('bm')
  4229. const onMounted = createHook('m')
  4230. const onBeforeUpdate = createHook('bu')
  4231. const onUpdated = createHook('u')
  4232. const onBeforeUnmount = createHook('bum')
  4233. const onUnmounted = createHook('um')
  4234. const onServerPrefetch = createHook('sp')
  4235. const onRenderTriggered = createHook(
  4236. 'rtg',
  4237. )
  4238. const onRenderTracked = createHook(
  4239. 'rtc',
  4240. )
  4241. function onErrorCaptured(hook, target = currentInstance) {
  4242. injectHook('ec', hook, target)
  4243. }
  4244. function renderList(source, renderItem, cache, index) {
  4245. let ret
  4246. const cached = cache && cache[index]
  4247. if (isArray(source) || isString(source)) {
  4248. ret = Array.from({ length: source.length })
  4249. for (let i = 0, l = source.length; i < l; i++)
  4250. ret[i] = renderItem(source[i], i, void 0, cached && cached[i])
  4251. }
  4252. else if (typeof source === 'number') {
  4253. if (!Number.isInteger(source))
  4254. warn$1(`The v-for range expect an integer value but got ${source}.`)
  4255. ret = new Array(source)
  4256. for (let i = 0; i < source; i++)
  4257. ret[i] = renderItem(i + 1, i, void 0, cached && cached[i])
  4258. }
  4259. else if (isObject(source)) {
  4260. if (source[Symbol.iterator]) {
  4261. ret = Array.from(
  4262. source,
  4263. (item, i) => renderItem(item, i, void 0, cached && cached[i]),
  4264. )
  4265. }
  4266. else {
  4267. const keys = Object.keys(source)
  4268. ret = Array.from({ length: keys.length })
  4269. for (let i = 0, l = keys.length; i < l; i++) {
  4270. const key = keys[i]
  4271. ret[i] = renderItem(source[key], key, i, cached && cached[i])
  4272. }
  4273. }
  4274. }
  4275. else {
  4276. ret = []
  4277. }
  4278. if (cache)
  4279. cache[index] = ret
  4280. return ret
  4281. }
  4282. function createSlots(slots, dynamicSlots) {
  4283. for (let i = 0; i < dynamicSlots.length; i++) {
  4284. const slot = dynamicSlots[i]
  4285. if (isArray(slot)) {
  4286. for (let j = 0; j < slot.length; j++)
  4287. slots[slot[j].name] = slot[j].fn
  4288. }
  4289. else if (slot) {
  4290. slots[slot.name] = slot.key
  4291. ? (...args) => {
  4292. const res = slot.fn(...args)
  4293. if (res)
  4294. res.key = slot.key
  4295. return res
  4296. }
  4297. : slot.fn
  4298. }
  4299. }
  4300. return slots
  4301. }
  4302. function renderSlot(slots, name, props = {}, fallback, noSlotted) {
  4303. if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
  4304. if (name !== 'default')
  4305. props.name = name
  4306. return createVNode('slot', props, fallback && fallback())
  4307. }
  4308. let slot = slots[name]
  4309. if (slot && slot.length > 1) {
  4310. warn$1(
  4311. `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`,
  4312. )
  4313. slot = () => []
  4314. }
  4315. if (slot && slot._c)
  4316. slot._d = false
  4317. openBlock()
  4318. const validSlotContent = slot && ensureValidVNode(slot(props))
  4319. const rendered = createBlock(
  4320. Fragment,
  4321. {
  4322. key: props.key // slot content array of a dynamic conditional slot may have a branch
  4323. // key attached in the `createSlots` helper, respect that
  4324. || validSlotContent && validSlotContent.key || `_${name}`,
  4325. },
  4326. validSlotContent || (fallback ? fallback() : []),
  4327. validSlotContent && slots._ === 1 ? 64 : -2,
  4328. )
  4329. if (!noSlotted && rendered.scopeId)
  4330. rendered.slotScopeIds = [`${rendered.scopeId}-s`]
  4331. if (slot && slot._c)
  4332. slot._d = true
  4333. return rendered
  4334. }
  4335. function ensureValidVNode(vnodes) {
  4336. return vnodes.some((child) => {
  4337. if (!isVNode(child))
  4338. return true
  4339. if (child.type === Comment)
  4340. return false
  4341. if (child.type === Fragment && !ensureValidVNode(child.children))
  4342. return false
  4343. return true
  4344. })
  4345. ? vnodes
  4346. : null
  4347. }
  4348. function toHandlers(obj, preserveCaseIfNecessary) {
  4349. const ret = {}
  4350. if (!isObject(obj)) {
  4351. warn$1(`v-on with no argument expects an object value.`)
  4352. return ret
  4353. }
  4354. for (const key in obj)
  4355. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key]
  4356. return ret
  4357. }
  4358. function getPublicInstance(i) {
  4359. if (!i)
  4360. return null
  4361. if (isStatefulComponent(i))
  4362. return getExposeProxy(i) || i.proxy
  4363. return getPublicInstance(i.parent)
  4364. }
  4365. const publicPropertiesMap = (
  4366. // Move PURE marker to new line to workaround compiler discarding it
  4367. // due to type annotation
  4368. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  4369. $: i => i,
  4370. $el: i => i.vnode.el,
  4371. $data: i => i.data,
  4372. $props: i => shallowReadonly(i.props),
  4373. $attrs: i => shallowReadonly(i.attrs),
  4374. $slots: i => shallowReadonly(i.slots),
  4375. $refs: i => shallowReadonly(i.refs),
  4376. $parent: i => getPublicInstance(i.parent),
  4377. $root: i => getPublicInstance(i.root),
  4378. $emit: i => i.emit,
  4379. $options: i => resolveMergedOptions(i),
  4380. $forceUpdate: i => i.f || (i.f = () => {
  4381. i.effect.dirty = true
  4382. queueJob(i.update)
  4383. }),
  4384. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  4385. $watch: i => instanceWatch.bind(i),
  4386. })
  4387. )
  4388. const isReservedPrefix = key => key === '_' || key === '$'
  4389. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key)
  4390. const PublicInstanceProxyHandlers = {
  4391. get({ _: instance }, key) {
  4392. if (key === '__v_skip')
  4393. return true
  4394. const { ctx, setupState, data, props, accessCache, type, appContext } = instance
  4395. if (key === '__isVue')
  4396. return true
  4397. let normalizedProps
  4398. if (key[0] !== '$') {
  4399. const n = accessCache[key]
  4400. if (n !== void 0) {
  4401. switch (n) {
  4402. case 1 /* SETUP */:
  4403. return setupState[key]
  4404. case 2 /* DATA */:
  4405. return data[key]
  4406. case 4 /* CONTEXT */:
  4407. return ctx[key]
  4408. case 3 /* PROPS */:
  4409. return props[key]
  4410. }
  4411. }
  4412. else if (hasSetupBinding(setupState, key)) {
  4413. accessCache[key] = 1 /* SETUP */
  4414. return setupState[key]
  4415. }
  4416. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4417. accessCache[key] = 2 /* DATA */
  4418. return data[key]
  4419. }
  4420. else if (
  4421. // only cache other properties when instance has declared (thus stable)
  4422. // props
  4423. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
  4424. ) {
  4425. accessCache[key] = 3 /* PROPS */
  4426. return props[key]
  4427. }
  4428. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4429. accessCache[key] = 4 /* CONTEXT */
  4430. return ctx[key]
  4431. }
  4432. else if (shouldCacheAccess) {
  4433. accessCache[key] = 0 /* OTHER */
  4434. }
  4435. }
  4436. const publicGetter = publicPropertiesMap[key]
  4437. let cssModule, globalProperties
  4438. if (publicGetter) {
  4439. if (key === '$attrs') {
  4440. track(instance.attrs, 'get', '')
  4441. markAttrsAccessed()
  4442. }
  4443. else if (key === '$slots') {
  4444. track(instance, 'get', key)
  4445. }
  4446. return publicGetter(instance)
  4447. }
  4448. else if (
  4449. // css module (injected by vue-loader)
  4450. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  4451. ) {
  4452. return cssModule
  4453. }
  4454. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4455. accessCache[key] = 4 /* CONTEXT */
  4456. return ctx[key]
  4457. }
  4458. else if (
  4459. // global properties
  4460. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  4461. ) {
  4462. {
  4463. return globalProperties[key]
  4464. }
  4465. }
  4466. else if (currentRenderingInstance && (!isString(key) // #1091 avoid internal isRef/isVNode checks on component instance leading
  4467. // to infinite warning loop
  4468. || key.indexOf('__v') !== 0)) {
  4469. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4470. warn$1(
  4471. `Property ${JSON.stringify(
  4472. key,
  4473. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`,
  4474. )
  4475. }
  4476. else if (instance === currentRenderingInstance) {
  4477. warn$1(
  4478. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`,
  4479. )
  4480. }
  4481. }
  4482. },
  4483. set({ _: instance }, key, value) {
  4484. const { data, setupState, ctx } = instance
  4485. if (hasSetupBinding(setupState, key)) {
  4486. setupState[key] = value
  4487. return true
  4488. }
  4489. else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  4490. warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`)
  4491. return false
  4492. }
  4493. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4494. data[key] = value
  4495. return true
  4496. }
  4497. else if (hasOwn(instance.props, key)) {
  4498. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`)
  4499. return false
  4500. }
  4501. if (key[0] === '$' && key.slice(1) in instance) {
  4502. warn$1(
  4503. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`,
  4504. )
  4505. return false
  4506. }
  4507. else {
  4508. if (key in instance.appContext.config.globalProperties) {
  4509. Object.defineProperty(ctx, key, {
  4510. enumerable: true,
  4511. configurable: true,
  4512. value,
  4513. })
  4514. }
  4515. else {
  4516. ctx[key] = value
  4517. }
  4518. }
  4519. return true
  4520. },
  4521. has({
  4522. _: { data, setupState, accessCache, ctx, appContext, propsOptions },
  4523. }, key) {
  4524. let normalizedProps
  4525. return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key)
  4526. },
  4527. defineProperty(target, key, descriptor) {
  4528. if (descriptor.get != null)
  4529. target._.accessCache[key] = 0
  4530. else if (hasOwn(descriptor, 'value'))
  4531. this.set(target, key, descriptor.value, null)
  4532. return Reflect.defineProperty(target, key, descriptor)
  4533. },
  4534. }
  4535. {
  4536. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4537. warn$1(
  4538. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`,
  4539. )
  4540. return Reflect.ownKeys(target)
  4541. }
  4542. }
  4543. const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
  4544. {},
  4545. PublicInstanceProxyHandlers,
  4546. {
  4547. get(target, key) {
  4548. if (key === Symbol.unscopables)
  4549. return
  4550. return PublicInstanceProxyHandlers.get(target, key, target)
  4551. },
  4552. has(_, key) {
  4553. const has = key[0] !== '_' && !isGloballyAllowed(key)
  4554. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4555. warn$1(
  4556. `Property ${JSON.stringify(
  4557. key,
  4558. )} should not start with _ which is a reserved prefix for Vue internals.`,
  4559. )
  4560. }
  4561. return has
  4562. },
  4563. },
  4564. )
  4565. function createDevRenderContext(instance) {
  4566. const target = {}
  4567. Object.defineProperty(target, `_`, {
  4568. configurable: true,
  4569. enumerable: false,
  4570. get: () => instance,
  4571. })
  4572. Object.keys(publicPropertiesMap).forEach((key) => {
  4573. Object.defineProperty(target, key, {
  4574. configurable: true,
  4575. enumerable: false,
  4576. get: () => publicPropertiesMap[key](instance),
  4577. // intercepted by the proxy so no need for implementation,
  4578. // but needed to prevent set errors
  4579. set: NOOP,
  4580. })
  4581. })
  4582. return target
  4583. }
  4584. function exposePropsOnRenderContext(instance) {
  4585. const {
  4586. ctx,
  4587. propsOptions: [propsOptions],
  4588. } = instance
  4589. if (propsOptions) {
  4590. Object.keys(propsOptions).forEach((key) => {
  4591. Object.defineProperty(ctx, key, {
  4592. enumerable: true,
  4593. configurable: true,
  4594. get: () => instance.props[key],
  4595. set: NOOP,
  4596. })
  4597. })
  4598. }
  4599. }
  4600. function exposeSetupStateOnRenderContext(instance) {
  4601. const { ctx, setupState } = instance
  4602. Object.keys(toRaw(setupState)).forEach((key) => {
  4603. if (!setupState.__isScriptSetup) {
  4604. if (isReservedPrefix(key[0])) {
  4605. warn$1(
  4606. `setup() return property ${JSON.stringify(
  4607. key,
  4608. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`,
  4609. )
  4610. return
  4611. }
  4612. Object.defineProperty(ctx, key, {
  4613. enumerable: true,
  4614. configurable: true,
  4615. get: () => setupState[key],
  4616. set: NOOP,
  4617. })
  4618. }
  4619. })
  4620. }
  4621. function warnRuntimeUsage(method) {
  4622. return warn$1(
  4623. `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`,
  4624. )
  4625. }
  4626. function defineProps() {
  4627. {
  4628. warnRuntimeUsage(`defineProps`)
  4629. }
  4630. return null
  4631. }
  4632. function defineEmits() {
  4633. {
  4634. warnRuntimeUsage(`defineEmits`)
  4635. }
  4636. return null
  4637. }
  4638. function defineExpose(exposed) {
  4639. {
  4640. warnRuntimeUsage(`defineExpose`)
  4641. }
  4642. }
  4643. function defineOptions(options) {
  4644. {
  4645. warnRuntimeUsage(`defineOptions`)
  4646. }
  4647. }
  4648. function defineSlots() {
  4649. {
  4650. warnRuntimeUsage(`defineSlots`)
  4651. }
  4652. return null
  4653. }
  4654. function defineModel() {
  4655. {
  4656. warnRuntimeUsage('defineModel')
  4657. }
  4658. }
  4659. function withDefaults(props, defaults) {
  4660. {
  4661. warnRuntimeUsage(`withDefaults`)
  4662. }
  4663. return null
  4664. }
  4665. function useSlots() {
  4666. return getContext().slots
  4667. }
  4668. function useAttrs() {
  4669. return getContext().attrs
  4670. }
  4671. function getContext() {
  4672. const i = getCurrentInstance()
  4673. if (!i)
  4674. warn$1(`useContext() called without active instance.`)
  4675. return i.setupContext || (i.setupContext = createSetupContext(i))
  4676. }
  4677. function normalizePropsOrEmits(props) {
  4678. return isArray(props)
  4679. ? props.reduce(
  4680. (normalized, p) => (normalized[p] = null, normalized),
  4681. {},
  4682. )
  4683. : props
  4684. }
  4685. function mergeDefaults(raw, defaults) {
  4686. const props = normalizePropsOrEmits(raw)
  4687. for (const key in defaults) {
  4688. if (key.startsWith('__skip'))
  4689. continue
  4690. let opt = props[key]
  4691. if (opt) {
  4692. if (isArray(opt) || isFunction(opt))
  4693. opt = props[key] = { type: opt, default: defaults[key] }
  4694. else
  4695. opt.default = defaults[key]
  4696. }
  4697. else if (opt === null) {
  4698. opt = props[key] = { default: defaults[key] }
  4699. }
  4700. else {
  4701. warn$1(`props default key "${key}" has no corresponding declaration.`)
  4702. }
  4703. if (opt && defaults[`__skip_${key}`])
  4704. opt.skipFactory = true
  4705. }
  4706. return props
  4707. }
  4708. function mergeModels(a, b) {
  4709. if (!a || !b)
  4710. return a || b
  4711. if (isArray(a) && isArray(b))
  4712. return a.concat(b)
  4713. return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b))
  4714. }
  4715. function createPropsRestProxy(props, excludedKeys) {
  4716. const ret = {}
  4717. for (const key in props) {
  4718. if (!excludedKeys.includes(key)) {
  4719. Object.defineProperty(ret, key, {
  4720. enumerable: true,
  4721. get: () => props[key],
  4722. })
  4723. }
  4724. }
  4725. return ret
  4726. }
  4727. function withAsyncContext(getAwaitable) {
  4728. const ctx = getCurrentInstance()
  4729. if (!ctx) {
  4730. warn$1(
  4731. `withAsyncContext called without active current instance. This is likely a bug.`,
  4732. )
  4733. }
  4734. let awaitable = getAwaitable()
  4735. unsetCurrentInstance()
  4736. if (isPromise(awaitable)) {
  4737. awaitable = awaitable.catch((e) => {
  4738. setCurrentInstance(ctx)
  4739. throw e
  4740. })
  4741. }
  4742. return [awaitable, () => setCurrentInstance(ctx)]
  4743. }
  4744. function createDuplicateChecker() {
  4745. const cache = /* @__PURE__ */ Object.create(null)
  4746. return (type, key) => {
  4747. if (cache[key])
  4748. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`)
  4749. else
  4750. cache[key] = type
  4751. }
  4752. }
  4753. let shouldCacheAccess = true
  4754. function applyOptions(instance) {
  4755. const options = resolveMergedOptions(instance)
  4756. const publicThis = instance.proxy
  4757. const ctx = instance.ctx
  4758. shouldCacheAccess = false
  4759. if (options.beforeCreate)
  4760. callHook$1(options.beforeCreate, instance, 'bc')
  4761. const {
  4762. // state
  4763. data: dataOptions,
  4764. computed: computedOptions,
  4765. methods,
  4766. watch: watchOptions,
  4767. provide: provideOptions,
  4768. inject: injectOptions,
  4769. // lifecycle
  4770. created,
  4771. beforeMount,
  4772. mounted,
  4773. beforeUpdate,
  4774. updated,
  4775. activated,
  4776. deactivated,
  4777. beforeDestroy,
  4778. beforeUnmount,
  4779. destroyed,
  4780. unmounted,
  4781. render,
  4782. renderTracked,
  4783. renderTriggered,
  4784. errorCaptured,
  4785. serverPrefetch,
  4786. // public API
  4787. expose,
  4788. inheritAttrs,
  4789. // assets
  4790. components,
  4791. directives,
  4792. filters,
  4793. } = options
  4794. const checkDuplicateProperties = createDuplicateChecker()
  4795. {
  4796. const [propsOptions] = instance.propsOptions
  4797. if (propsOptions) {
  4798. for (const key in propsOptions)
  4799. checkDuplicateProperties('Props' /* PROPS */, key)
  4800. }
  4801. }
  4802. if (injectOptions)
  4803. resolveInjections(injectOptions, ctx, checkDuplicateProperties)
  4804. if (methods) {
  4805. for (const key in methods) {
  4806. const methodHandler = methods[key]
  4807. if (isFunction(methodHandler)) {
  4808. {
  4809. Object.defineProperty(ctx, key, {
  4810. value: methodHandler.bind(publicThis),
  4811. configurable: true,
  4812. enumerable: true,
  4813. writable: true,
  4814. })
  4815. }
  4816. {
  4817. checkDuplicateProperties('Methods' /* METHODS */, key)
  4818. }
  4819. }
  4820. else {
  4821. warn$1(
  4822. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`,
  4823. )
  4824. }
  4825. }
  4826. }
  4827. if (dataOptions) {
  4828. if (!isFunction(dataOptions)) {
  4829. warn$1(
  4830. `The data option must be a function. Plain object usage is no longer supported.`,
  4831. )
  4832. }
  4833. const data = dataOptions.call(publicThis, publicThis)
  4834. if (isPromise(data)) {
  4835. warn$1(
  4836. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`,
  4837. )
  4838. }
  4839. if (!isObject(data)) {
  4840. warn$1(`data() should return an object.`)
  4841. }
  4842. else {
  4843. instance.data = reactive(data)
  4844. {
  4845. for (const key in data) {
  4846. checkDuplicateProperties('Data' /* DATA */, key)
  4847. if (!isReservedPrefix(key[0])) {
  4848. Object.defineProperty(ctx, key, {
  4849. configurable: true,
  4850. enumerable: true,
  4851. get: () => data[key],
  4852. set: NOOP,
  4853. })
  4854. }
  4855. }
  4856. }
  4857. }
  4858. }
  4859. shouldCacheAccess = true
  4860. if (computedOptions) {
  4861. for (const key in computedOptions) {
  4862. const opt = computedOptions[key]
  4863. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP
  4864. if (get === NOOP)
  4865. warn$1(`Computed property "${key}" has no getter.`)
  4866. const set = !isFunction(opt) && isFunction(opt.set)
  4867. ? opt.set.bind(publicThis)
  4868. : () => {
  4869. warn$1(
  4870. `Write operation failed: computed property "${key}" is readonly.`,
  4871. )
  4872. }
  4873. const c = computed({
  4874. get,
  4875. set,
  4876. })
  4877. Object.defineProperty(ctx, key, {
  4878. enumerable: true,
  4879. configurable: true,
  4880. get: () => c.value,
  4881. set: v => c.value = v,
  4882. })
  4883. {
  4884. checkDuplicateProperties('Computed' /* COMPUTED */, key)
  4885. }
  4886. }
  4887. }
  4888. if (watchOptions) {
  4889. for (const key in watchOptions)
  4890. createWatcher(watchOptions[key], ctx, publicThis, key)
  4891. }
  4892. if (provideOptions) {
  4893. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions
  4894. Reflect.ownKeys(provides).forEach((key) => {
  4895. provide(key, provides[key])
  4896. })
  4897. }
  4898. if (created)
  4899. callHook$1(created, instance, 'c')
  4900. function registerLifecycleHook(register, hook) {
  4901. if (isArray(hook))
  4902. hook.forEach(_hook => register(_hook.bind(publicThis)))
  4903. else if (hook)
  4904. register(hook.bind(publicThis))
  4905. }
  4906. registerLifecycleHook(onBeforeMount, beforeMount)
  4907. registerLifecycleHook(onMounted, mounted)
  4908. registerLifecycleHook(onBeforeUpdate, beforeUpdate)
  4909. registerLifecycleHook(onUpdated, updated)
  4910. registerLifecycleHook(onActivated, activated)
  4911. registerLifecycleHook(onDeactivated, deactivated)
  4912. registerLifecycleHook(onErrorCaptured, errorCaptured)
  4913. registerLifecycleHook(onRenderTracked, renderTracked)
  4914. registerLifecycleHook(onRenderTriggered, renderTriggered)
  4915. registerLifecycleHook(onBeforeUnmount, beforeUnmount)
  4916. registerLifecycleHook(onUnmounted, unmounted)
  4917. registerLifecycleHook(onServerPrefetch, serverPrefetch)
  4918. if (isArray(expose)) {
  4919. if (expose.length) {
  4920. const exposed = instance.exposed || (instance.exposed = {})
  4921. expose.forEach((key) => {
  4922. Object.defineProperty(exposed, key, {
  4923. get: () => publicThis[key],
  4924. set: val => publicThis[key] = val,
  4925. })
  4926. })
  4927. }
  4928. else if (!instance.exposed) {
  4929. instance.exposed = {}
  4930. }
  4931. }
  4932. if (render && instance.render === NOOP)
  4933. instance.render = render
  4934. if (inheritAttrs != null)
  4935. instance.inheritAttrs = inheritAttrs
  4936. if (components)
  4937. instance.components = components
  4938. if (directives)
  4939. instance.directives = directives
  4940. }
  4941. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  4942. if (isArray(injectOptions))
  4943. injectOptions = normalizeInject(injectOptions)
  4944. for (const key in injectOptions) {
  4945. const opt = injectOptions[key]
  4946. let injected
  4947. if (isObject(opt)) {
  4948. if ('default' in opt) {
  4949. injected = inject(
  4950. opt.from || key,
  4951. opt.default,
  4952. true,
  4953. )
  4954. }
  4955. else {
  4956. injected = inject(opt.from || key)
  4957. }
  4958. }
  4959. else {
  4960. injected = inject(opt)
  4961. }
  4962. if (isRef(injected)) {
  4963. Object.defineProperty(ctx, key, {
  4964. enumerable: true,
  4965. configurable: true,
  4966. get: () => injected.value,
  4967. set: v => injected.value = v,
  4968. })
  4969. }
  4970. else {
  4971. ctx[key] = injected
  4972. }
  4973. {
  4974. checkDuplicateProperties('Inject' /* INJECT */, key)
  4975. }
  4976. }
  4977. }
  4978. function callHook$1(hook, instance, type) {
  4979. callWithAsyncErrorHandling(
  4980. isArray(hook) ? hook.map(h => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  4981. instance,
  4982. type,
  4983. )
  4984. }
  4985. function createWatcher(raw, ctx, publicThis, key) {
  4986. const getter = key.includes('.') ? createPathGetter(publicThis, key) : () => publicThis[key]
  4987. if (isString(raw)) {
  4988. const handler = ctx[raw]
  4989. if (isFunction(handler))
  4990. watch(getter, handler)
  4991. else
  4992. warn$1(`Invalid watch handler specified by key "${raw}"`, handler)
  4993. }
  4994. else if (isFunction(raw)) {
  4995. watch(getter, raw.bind(publicThis))
  4996. }
  4997. else if (isObject(raw)) {
  4998. if (isArray(raw)) {
  4999. raw.forEach(r => createWatcher(r, ctx, publicThis, key))
  5000. }
  5001. else {
  5002. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler]
  5003. if (isFunction(handler))
  5004. watch(getter, handler, raw)
  5005. else
  5006. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler)
  5007. }
  5008. }
  5009. else {
  5010. warn$1(`Invalid watch option: "${key}"`, raw)
  5011. }
  5012. }
  5013. function resolveMergedOptions(instance) {
  5014. const base = instance.type
  5015. const { mixins, extends: extendsOptions } = base
  5016. const {
  5017. mixins: globalMixins,
  5018. optionsCache: cache,
  5019. config: { optionMergeStrategies },
  5020. } = instance.appContext
  5021. const cached = cache.get(base)
  5022. let resolved
  5023. if (cached) {
  5024. resolved = cached
  5025. }
  5026. else if (!globalMixins.length && !mixins && !extendsOptions) {
  5027. {
  5028. resolved = base
  5029. }
  5030. }
  5031. else {
  5032. resolved = {}
  5033. if (globalMixins.length) {
  5034. globalMixins.forEach(
  5035. m => mergeOptions(resolved, m, optionMergeStrategies, true),
  5036. )
  5037. }
  5038. mergeOptions(resolved, base, optionMergeStrategies)
  5039. }
  5040. if (isObject(base))
  5041. cache.set(base, resolved)
  5042. return resolved
  5043. }
  5044. function mergeOptions(to, from, strats, asMixin = false) {
  5045. const { mixins, extends: extendsOptions } = from
  5046. if (extendsOptions)
  5047. mergeOptions(to, extendsOptions, strats, true)
  5048. if (mixins) {
  5049. mixins.forEach(
  5050. m => mergeOptions(to, m, strats, true),
  5051. )
  5052. }
  5053. for (const key in from) {
  5054. if (asMixin && key === 'expose') {
  5055. warn$1(
  5056. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`,
  5057. )
  5058. }
  5059. else {
  5060. const strat = internalOptionMergeStrats[key] || strats && strats[key]
  5061. to[key] = strat ? strat(to[key], from[key]) : from[key]
  5062. }
  5063. }
  5064. return to
  5065. }
  5066. const internalOptionMergeStrats = {
  5067. data: mergeDataFn,
  5068. props: mergeEmitsOrPropsOptions,
  5069. emits: mergeEmitsOrPropsOptions,
  5070. // objects
  5071. methods: mergeObjectOptions,
  5072. computed: mergeObjectOptions,
  5073. // lifecycle
  5074. beforeCreate: mergeAsArray,
  5075. created: mergeAsArray,
  5076. beforeMount: mergeAsArray,
  5077. mounted: mergeAsArray,
  5078. beforeUpdate: mergeAsArray,
  5079. updated: mergeAsArray,
  5080. beforeDestroy: mergeAsArray,
  5081. beforeUnmount: mergeAsArray,
  5082. destroyed: mergeAsArray,
  5083. unmounted: mergeAsArray,
  5084. activated: mergeAsArray,
  5085. deactivated: mergeAsArray,
  5086. errorCaptured: mergeAsArray,
  5087. serverPrefetch: mergeAsArray,
  5088. // assets
  5089. components: mergeObjectOptions,
  5090. directives: mergeObjectOptions,
  5091. // watch
  5092. watch: mergeWatchOptions,
  5093. // provide / inject
  5094. provide: mergeDataFn,
  5095. inject: mergeInject,
  5096. }
  5097. function mergeDataFn(to, from) {
  5098. if (!from)
  5099. return to
  5100. if (!to)
  5101. return from
  5102. return function mergedDataFn() {
  5103. return (extend)(
  5104. isFunction(to) ? to.call(this, this) : to,
  5105. isFunction(from) ? from.call(this, this) : from,
  5106. )
  5107. }
  5108. }
  5109. function mergeInject(to, from) {
  5110. return mergeObjectOptions(normalizeInject(to), normalizeInject(from))
  5111. }
  5112. function normalizeInject(raw) {
  5113. if (isArray(raw)) {
  5114. const res = {}
  5115. for (let i = 0; i < raw.length; i++)
  5116. res[raw[i]] = raw[i]
  5117. return res
  5118. }
  5119. return raw
  5120. }
  5121. function mergeAsArray(to, from) {
  5122. return to ? [...new Set([].concat(to, from))] : from
  5123. }
  5124. function mergeObjectOptions(to, from) {
  5125. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from
  5126. }
  5127. function mergeEmitsOrPropsOptions(to, from) {
  5128. if (to) {
  5129. if (isArray(to) && isArray(from))
  5130. return [...new Set([...to, ...from])]
  5131. return extend(
  5132. /* @__PURE__ */ Object.create(null),
  5133. normalizePropsOrEmits(to),
  5134. normalizePropsOrEmits(from != null ? from : {}),
  5135. )
  5136. }
  5137. else {
  5138. return from
  5139. }
  5140. }
  5141. function mergeWatchOptions(to, from) {
  5142. if (!to)
  5143. return from
  5144. if (!from)
  5145. return to
  5146. const merged = extend(/* @__PURE__ */ Object.create(null), to)
  5147. for (const key in from)
  5148. merged[key] = mergeAsArray(to[key], from[key])
  5149. return merged
  5150. }
  5151. function createAppContext() {
  5152. return {
  5153. app: null,
  5154. config: {
  5155. isNativeTag: NO,
  5156. performance: false,
  5157. globalProperties: {},
  5158. optionMergeStrategies: {},
  5159. errorHandler: void 0,
  5160. warnHandler: void 0,
  5161. compilerOptions: {},
  5162. },
  5163. mixins: [],
  5164. components: {},
  5165. directives: {},
  5166. provides: /* @__PURE__ */ Object.create(null),
  5167. optionsCache: /* @__PURE__ */ new WeakMap(),
  5168. propsCache: /* @__PURE__ */ new WeakMap(),
  5169. emitsCache: /* @__PURE__ */ new WeakMap(),
  5170. }
  5171. }
  5172. let uid$1 = 0
  5173. function createAppAPI(render, hydrate) {
  5174. return function createApp(rootComponent, rootProps = null) {
  5175. if (!isFunction(rootComponent))
  5176. rootComponent = extend({}, rootComponent)
  5177. if (rootProps != null && !isObject(rootProps)) {
  5178. warn$1(`root props passed to app.mount() must be an object.`)
  5179. rootProps = null
  5180. }
  5181. const context = createAppContext()
  5182. const installedPlugins = /* @__PURE__ */ new WeakSet()
  5183. let isMounted = false
  5184. const app = context.app = {
  5185. _uid: uid$1++,
  5186. _component: rootComponent,
  5187. _props: rootProps,
  5188. _container: null,
  5189. _context: context,
  5190. _instance: null,
  5191. version,
  5192. get config() {
  5193. return context.config
  5194. },
  5195. set config(v) {
  5196. {
  5197. warn$1(
  5198. `app.config cannot be replaced. Modify individual options instead.`,
  5199. )
  5200. }
  5201. },
  5202. use(plugin, ...options) {
  5203. if (installedPlugins.has(plugin)) {
  5204. warn$1(`Plugin has already been applied to target app.`)
  5205. }
  5206. else if (plugin && isFunction(plugin.install)) {
  5207. installedPlugins.add(plugin)
  5208. plugin.install(app, ...options)
  5209. }
  5210. else if (isFunction(plugin)) {
  5211. installedPlugins.add(plugin)
  5212. plugin(app, ...options)
  5213. }
  5214. else {
  5215. warn$1(
  5216. `A plugin must either be a function or an object with an "install" function.`,
  5217. )
  5218. }
  5219. return app
  5220. },
  5221. mixin(mixin) {
  5222. {
  5223. if (!context.mixins.includes(mixin)) {
  5224. context.mixins.push(mixin)
  5225. }
  5226. else {
  5227. warn$1(
  5228. `Mixin has already been applied to target app${mixin.name ? `: ${mixin.name}` : ''}`,
  5229. )
  5230. }
  5231. }
  5232. return app
  5233. },
  5234. component(name, component) {
  5235. {
  5236. validateComponentName(name, context.config)
  5237. }
  5238. if (!component)
  5239. return context.components[name]
  5240. if (context.components[name])
  5241. warn$1(`Component "${name}" has already been registered in target app.`)
  5242. context.components[name] = component
  5243. return app
  5244. },
  5245. directive(name, directive) {
  5246. {
  5247. validateDirectiveName(name)
  5248. }
  5249. if (!directive)
  5250. return context.directives[name]
  5251. if (context.directives[name])
  5252. warn$1(`Directive "${name}" has already been registered in target app.`)
  5253. context.directives[name] = directive
  5254. return app
  5255. },
  5256. mount(rootContainer, isHydrate, namespace) {
  5257. if (!isMounted) {
  5258. if (rootContainer.__vue_app__) {
  5259. warn$1(
  5260. `There is already an app instance mounted on the host container.
  5261. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`,
  5262. )
  5263. }
  5264. const vnode = createVNode(rootComponent, rootProps)
  5265. vnode.appContext = context
  5266. if (namespace === true)
  5267. namespace = 'svg'
  5268. else if (namespace === false)
  5269. namespace = void 0
  5270. {
  5271. context.reload = () => {
  5272. render(
  5273. cloneVNode(vnode),
  5274. rootContainer,
  5275. namespace,
  5276. )
  5277. }
  5278. }
  5279. if (isHydrate && hydrate)
  5280. hydrate(vnode, rootContainer)
  5281. else
  5282. render(vnode, rootContainer, namespace)
  5283. isMounted = true
  5284. app._container = rootContainer
  5285. rootContainer.__vue_app__ = app
  5286. {
  5287. app._instance = vnode.component
  5288. devtoolsInitApp(app, version)
  5289. }
  5290. return getExposeProxy(vnode.component) || vnode.component.proxy
  5291. }
  5292. else {
  5293. warn$1(
  5294. `App has already been mounted.
  5295. If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``,
  5296. )
  5297. }
  5298. },
  5299. unmount() {
  5300. if (isMounted) {
  5301. render(null, app._container)
  5302. {
  5303. app._instance = null
  5304. devtoolsUnmountApp(app)
  5305. }
  5306. delete app._container.__vue_app__
  5307. }
  5308. else {
  5309. warn$1(`Cannot unmount an app that is not mounted.`)
  5310. }
  5311. },
  5312. provide(key, value) {
  5313. if (key in context.provides) {
  5314. warn$1(
  5315. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`,
  5316. )
  5317. }
  5318. context.provides[key] = value
  5319. return app
  5320. },
  5321. runWithContext(fn) {
  5322. const lastApp = currentApp
  5323. currentApp = app
  5324. try {
  5325. return fn()
  5326. }
  5327. finally {
  5328. currentApp = lastApp
  5329. }
  5330. },
  5331. }
  5332. return app
  5333. }
  5334. }
  5335. let currentApp = null
  5336. function provide(key, value) {
  5337. if (!currentInstance) {
  5338. {
  5339. warn$1(`provide() can only be used inside setup().`)
  5340. }
  5341. }
  5342. else {
  5343. let provides = currentInstance.provides
  5344. const parentProvides = currentInstance.parent && currentInstance.parent.provides
  5345. if (parentProvides === provides)
  5346. provides = currentInstance.provides = Object.create(parentProvides)
  5347. provides[key] = value
  5348. }
  5349. }
  5350. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  5351. const instance = currentInstance || currentRenderingInstance
  5352. if (instance || currentApp) {
  5353. const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides
  5354. if (provides && key in provides)
  5355. return provides[key]
  5356. else if (arguments.length > 1)
  5357. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue
  5358. else
  5359. warn$1(`injection "${String(key)}" not found.`)
  5360. }
  5361. else {
  5362. warn$1(`inject() can only be used inside setup() or functional components.`)
  5363. }
  5364. }
  5365. function hasInjectionContext() {
  5366. return !!(currentInstance || currentRenderingInstance || currentApp)
  5367. }
  5368. const internalObjectProto = {}
  5369. const createInternalObject = () => Object.create(internalObjectProto)
  5370. const isInternalObject = obj => Object.getPrototypeOf(obj) === internalObjectProto
  5371. function initProps(instance, rawProps, isStateful, isSSR = false) {
  5372. const props = {}
  5373. const attrs = createInternalObject()
  5374. instance.propsDefaults = /* @__PURE__ */ Object.create(null)
  5375. setFullProps(instance, rawProps, props, attrs)
  5376. for (const key in instance.propsOptions[0]) {
  5377. if (!(key in props))
  5378. props[key] = void 0
  5379. }
  5380. {
  5381. validateProps(rawProps || {}, props, instance)
  5382. }
  5383. if (isStateful) {
  5384. instance.props = isSSR ? props : shallowReactive(props)
  5385. }
  5386. else {
  5387. if (!instance.type.props)
  5388. instance.props = attrs
  5389. else
  5390. instance.props = props
  5391. }
  5392. instance.attrs = attrs
  5393. }
  5394. function isInHmrContext(instance) {
  5395. while (instance) {
  5396. if (instance.type.__hmrId)
  5397. return true
  5398. instance = instance.parent
  5399. }
  5400. }
  5401. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5402. const {
  5403. props,
  5404. attrs,
  5405. vnode: { patchFlag },
  5406. } = instance
  5407. const rawCurrentProps = toRaw(props)
  5408. const [options] = instance.propsOptions
  5409. let hasAttrsChanged = false
  5410. if (
  5411. // always force full diff in dev
  5412. // - #1942 if hmr is enabled with sfc component
  5413. // - vite#872 non-sfc component used by sfc component
  5414. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  5415. ) {
  5416. if (patchFlag & 8) {
  5417. const propsToUpdate = instance.vnode.dynamicProps
  5418. for (let i = 0; i < propsToUpdate.length; i++) {
  5419. const key = propsToUpdate[i]
  5420. if (isEmitListener(instance.emitsOptions, key))
  5421. continue
  5422. const value = rawProps[key]
  5423. if (options) {
  5424. if (hasOwn(attrs, key)) {
  5425. if (value !== attrs[key]) {
  5426. attrs[key] = value
  5427. hasAttrsChanged = true
  5428. }
  5429. }
  5430. else {
  5431. const camelizedKey = camelize(key)
  5432. props[camelizedKey] = resolvePropValue(
  5433. options,
  5434. rawCurrentProps,
  5435. camelizedKey,
  5436. value,
  5437. instance,
  5438. false,
  5439. )
  5440. }
  5441. }
  5442. else {
  5443. if (value !== attrs[key]) {
  5444. attrs[key] = value
  5445. hasAttrsChanged = true
  5446. }
  5447. }
  5448. }
  5449. }
  5450. }
  5451. else {
  5452. if (setFullProps(instance, rawProps, props, attrs))
  5453. hasAttrsChanged = true
  5454. let kebabKey
  5455. for (const key in rawCurrentProps) {
  5456. if (!rawProps // for camelCase
  5457. || !hasOwn(rawProps, key) // it's possible the original props was passed in as kebab-case
  5458. // and converted to camelCase (#955)
  5459. && ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  5460. if (options) {
  5461. if (rawPrevProps // for camelCase
  5462. && (rawPrevProps[key] !== void 0 // for kebab-case
  5463. || rawPrevProps[kebabKey] !== void 0)) {
  5464. props[key] = resolvePropValue(
  5465. options,
  5466. rawCurrentProps,
  5467. key,
  5468. void 0,
  5469. instance,
  5470. true,
  5471. )
  5472. }
  5473. }
  5474. else {
  5475. delete props[key]
  5476. }
  5477. }
  5478. }
  5479. if (attrs !== rawCurrentProps) {
  5480. for (const key in attrs) {
  5481. if (!rawProps || !hasOwn(rawProps, key) && true) {
  5482. delete attrs[key]
  5483. hasAttrsChanged = true
  5484. }
  5485. }
  5486. }
  5487. }
  5488. if (hasAttrsChanged)
  5489. trigger(instance.attrs, 'set', '')
  5490. {
  5491. validateProps(rawProps || {}, props, instance)
  5492. }
  5493. }
  5494. function setFullProps(instance, rawProps, props, attrs) {
  5495. const [options, needCastKeys] = instance.propsOptions
  5496. let hasAttrsChanged = false
  5497. let rawCastValues
  5498. if (rawProps) {
  5499. for (const key in rawProps) {
  5500. if (isReservedProp(key))
  5501. continue
  5502. const value = rawProps[key]
  5503. let camelKey
  5504. if (options && hasOwn(options, camelKey = camelize(key))) {
  5505. if (!needCastKeys || !needCastKeys.includes(camelKey))
  5506. props[camelKey] = value
  5507. else
  5508. (rawCastValues || (rawCastValues = {}))[camelKey] = value
  5509. }
  5510. else if (!isEmitListener(instance.emitsOptions, key)) {
  5511. if (!(key in attrs) || value !== attrs[key]) {
  5512. attrs[key] = value
  5513. hasAttrsChanged = true
  5514. }
  5515. }
  5516. }
  5517. }
  5518. if (needCastKeys) {
  5519. const rawCurrentProps = toRaw(props)
  5520. const castValues = rawCastValues || EMPTY_OBJ
  5521. for (let i = 0; i < needCastKeys.length; i++) {
  5522. const key = needCastKeys[i]
  5523. props[key] = resolvePropValue(
  5524. options,
  5525. rawCurrentProps,
  5526. key,
  5527. castValues[key],
  5528. instance,
  5529. !hasOwn(castValues, key),
  5530. )
  5531. }
  5532. }
  5533. return hasAttrsChanged
  5534. }
  5535. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5536. const opt = options[key]
  5537. if (opt != null) {
  5538. const hasDefault = hasOwn(opt, 'default')
  5539. if (hasDefault && value === void 0) {
  5540. const defaultValue = opt.default
  5541. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  5542. const { propsDefaults } = instance
  5543. if (key in propsDefaults) {
  5544. value = propsDefaults[key]
  5545. }
  5546. else {
  5547. const reset = setCurrentInstance(instance)
  5548. value = propsDefaults[key] = defaultValue.call(
  5549. null,
  5550. props,
  5551. )
  5552. reset()
  5553. }
  5554. }
  5555. else {
  5556. value = defaultValue
  5557. }
  5558. }
  5559. if (opt[0 /* shouldCast */]) {
  5560. if (isAbsent && !hasDefault)
  5561. value = false
  5562. else if (opt[1 /* shouldCastTrue */] && (value === '' || value === hyphenate(key)))
  5563. value = true
  5564. }
  5565. }
  5566. return value
  5567. }
  5568. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5569. const cache = appContext.propsCache
  5570. const cached = cache.get(comp)
  5571. if (cached)
  5572. return cached
  5573. const raw = comp.props
  5574. const normalized = {}
  5575. const needCastKeys = []
  5576. let hasExtends = false
  5577. if (!isFunction(comp)) {
  5578. const extendProps = (raw2) => {
  5579. hasExtends = true
  5580. const [props, keys] = normalizePropsOptions(raw2, appContext, true)
  5581. extend(normalized, props)
  5582. if (keys)
  5583. needCastKeys.push(...keys)
  5584. }
  5585. if (!asMixin && appContext.mixins.length)
  5586. appContext.mixins.forEach(extendProps)
  5587. if (comp.extends)
  5588. extendProps(comp.extends)
  5589. if (comp.mixins)
  5590. comp.mixins.forEach(extendProps)
  5591. }
  5592. if (!raw && !hasExtends) {
  5593. if (isObject(comp))
  5594. cache.set(comp, EMPTY_ARR)
  5595. return EMPTY_ARR
  5596. }
  5597. if (isArray(raw)) {
  5598. for (let i = 0; i < raw.length; i++) {
  5599. if (!isString(raw[i]))
  5600. warn$1(`props must be strings when using array syntax.`, raw[i])
  5601. const normalizedKey = camelize(raw[i])
  5602. if (validatePropName(normalizedKey))
  5603. normalized[normalizedKey] = EMPTY_OBJ
  5604. }
  5605. }
  5606. else if (raw) {
  5607. if (!isObject(raw))
  5608. warn$1(`invalid props options`, raw)
  5609. for (const key in raw) {
  5610. const normalizedKey = camelize(key)
  5611. if (validatePropName(normalizedKey)) {
  5612. const opt = raw[key]
  5613. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt)
  5614. if (prop) {
  5615. const booleanIndex = getTypeIndex(Boolean, prop.type)
  5616. const stringIndex = getTypeIndex(String, prop.type)
  5617. prop[0 /* shouldCast */] = booleanIndex > -1
  5618. prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex
  5619. if (booleanIndex > -1 || hasOwn(prop, 'default'))
  5620. needCastKeys.push(normalizedKey)
  5621. }
  5622. }
  5623. }
  5624. }
  5625. const res = [normalized, needCastKeys]
  5626. if (isObject(comp))
  5627. cache.set(comp, res)
  5628. return res
  5629. }
  5630. function validatePropName(key) {
  5631. if (key[0] !== '$' && !isReservedProp(key))
  5632. return true
  5633. else
  5634. warn$1(`Invalid prop name: "${key}" is a reserved property.`)
  5635. return false
  5636. }
  5637. function getType(ctor) {
  5638. if (ctor === null)
  5639. return 'null'
  5640. if (typeof ctor === 'function') {
  5641. return ctor.name || ''
  5642. }
  5643. else if (typeof ctor === 'object') {
  5644. const name = ctor.constructor && ctor.constructor.name
  5645. return name || ''
  5646. }
  5647. return ''
  5648. }
  5649. function isSameType(a, b) {
  5650. return getType(a) === getType(b)
  5651. }
  5652. function getTypeIndex(type, expectedTypes) {
  5653. if (isArray(expectedTypes))
  5654. return expectedTypes.findIndex(t => isSameType(t, type))
  5655. else if (isFunction(expectedTypes))
  5656. return isSameType(expectedTypes, type) ? 0 : -1
  5657. return -1
  5658. }
  5659. function validateProps(rawProps, props, instance) {
  5660. const resolvedValues = toRaw(props)
  5661. const options = instance.propsOptions[0]
  5662. for (const key in options) {
  5663. const opt = options[key]
  5664. if (opt == null)
  5665. continue
  5666. validateProp(
  5667. key,
  5668. resolvedValues[key],
  5669. opt,
  5670. shallowReadonly(resolvedValues),
  5671. !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)),
  5672. )
  5673. }
  5674. }
  5675. function validateProp(name, value, prop, props, isAbsent) {
  5676. const { type, required, validator, skipCheck } = prop
  5677. if (required && isAbsent) {
  5678. warn$1(`Missing required prop: "${name}"`)
  5679. return
  5680. }
  5681. if (value == null && !required)
  5682. return
  5683. if (type != null && type !== true && !skipCheck) {
  5684. let isValid = false
  5685. const types = isArray(type) ? type : [type]
  5686. const expectedTypes = []
  5687. for (let i = 0; i < types.length && !isValid; i++) {
  5688. const { valid, expectedType } = assertType(value, types[i])
  5689. expectedTypes.push(expectedType || '')
  5690. isValid = valid
  5691. }
  5692. if (!isValid) {
  5693. warn$1(getInvalidTypeMessage(name, value, expectedTypes))
  5694. return
  5695. }
  5696. }
  5697. if (validator && !validator(value, props))
  5698. warn$1(`Invalid prop: custom validator check failed for prop "${name}".`)
  5699. }
  5700. const isSimpleType = /* @__PURE__ */ makeMap(
  5701. 'String,Number,Boolean,Function,Symbol,BigInt',
  5702. )
  5703. function assertType(value, type) {
  5704. let valid
  5705. const expectedType = getType(type)
  5706. if (isSimpleType(expectedType)) {
  5707. const t = typeof value
  5708. valid = t === expectedType.toLowerCase()
  5709. if (!valid && t === 'object')
  5710. valid = value instanceof type
  5711. }
  5712. else if (expectedType === 'Object') {
  5713. valid = isObject(value)
  5714. }
  5715. else if (expectedType === 'Array') {
  5716. valid = isArray(value)
  5717. }
  5718. else if (expectedType === 'null') {
  5719. valid = value === null
  5720. }
  5721. else {
  5722. valid = value instanceof type
  5723. }
  5724. return {
  5725. valid,
  5726. expectedType,
  5727. }
  5728. }
  5729. function getInvalidTypeMessage(name, value, expectedTypes) {
  5730. if (expectedTypes.length === 0)
  5731. return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`
  5732. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(' | ')}`
  5733. const expectedType = expectedTypes[0]
  5734. const receivedType = toRawType(value)
  5735. const expectedValue = styleValue(value, expectedType)
  5736. const receivedValue = styleValue(value, receivedType)
  5737. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType))
  5738. message += ` with value ${expectedValue}`
  5739. message += `, got ${receivedType} `
  5740. if (isExplicable(receivedType))
  5741. message += `with value ${receivedValue}.`
  5742. return message
  5743. }
  5744. function styleValue(value, type) {
  5745. if (type === 'String')
  5746. return `"${value}"`
  5747. else if (type === 'Number')
  5748. return `${Number(value)}`
  5749. else
  5750. return `${value}`
  5751. }
  5752. function isExplicable(type) {
  5753. const explicitTypes = ['string', 'number', 'boolean']
  5754. return explicitTypes.some(elem => type.toLowerCase() === elem)
  5755. }
  5756. function isBoolean(...args) {
  5757. return args.some(elem => elem.toLowerCase() === 'boolean')
  5758. }
  5759. const isInternalKey = key => key[0] === '_' || key === '$stable'
  5760. const normalizeSlotValue = value => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)]
  5761. function normalizeSlot(key, rawSlot, ctx) {
  5762. if (rawSlot._n)
  5763. return rawSlot
  5764. const normalized = withCtx((...args) => {
  5765. if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
  5766. warn$1(
  5767. `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`,
  5768. )
  5769. }
  5770. return normalizeSlotValue(rawSlot(...args))
  5771. }, ctx)
  5772. normalized._c = false
  5773. return normalized
  5774. }
  5775. function normalizeObjectSlots(rawSlots, slots, instance) {
  5776. const ctx = rawSlots._ctx
  5777. for (const key in rawSlots) {
  5778. if (isInternalKey(key))
  5779. continue
  5780. const value = rawSlots[key]
  5781. if (isFunction(value)) {
  5782. slots[key] = normalizeSlot(key, value, ctx)
  5783. }
  5784. else if (value != null) {
  5785. {
  5786. warn$1(
  5787. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`,
  5788. )
  5789. }
  5790. const normalized = normalizeSlotValue(value)
  5791. slots[key] = () => normalized
  5792. }
  5793. }
  5794. }
  5795. function normalizeVNodeSlots(instance, children) {
  5796. if (!isKeepAlive(instance.vnode) && true) {
  5797. warn$1(
  5798. `Non-function value encountered for default slot. Prefer function slots for better performance.`,
  5799. )
  5800. }
  5801. const normalized = normalizeSlotValue(children)
  5802. instance.slots.default = () => normalized
  5803. }
  5804. function initSlots(instance, children) {
  5805. const slots = instance.slots = createInternalObject()
  5806. if (instance.vnode.shapeFlag & 32) {
  5807. const type = children._
  5808. if (type) {
  5809. extend(slots, children)
  5810. def(slots, '_', type, true)
  5811. }
  5812. else {
  5813. normalizeObjectSlots(children, slots)
  5814. }
  5815. }
  5816. else if (children) {
  5817. normalizeVNodeSlots(instance, children)
  5818. }
  5819. }
  5820. function updateSlots(instance, children, optimized) {
  5821. const { vnode, slots } = instance
  5822. let needDeletionCheck = true
  5823. let deletionComparisonTarget = EMPTY_OBJ
  5824. if (vnode.shapeFlag & 32) {
  5825. const type = children._
  5826. if (type) {
  5827. if (isHmrUpdating) {
  5828. extend(slots, children)
  5829. trigger(instance, 'set', '$slots')
  5830. }
  5831. else if (optimized && type === 1) {
  5832. needDeletionCheck = false
  5833. }
  5834. else {
  5835. extend(slots, children)
  5836. if (!optimized && type === 1)
  5837. delete slots._
  5838. }
  5839. }
  5840. else {
  5841. needDeletionCheck = !children.$stable
  5842. normalizeObjectSlots(children, slots)
  5843. }
  5844. deletionComparisonTarget = children
  5845. }
  5846. else if (children) {
  5847. normalizeVNodeSlots(instance, children)
  5848. deletionComparisonTarget = { default: 1 }
  5849. }
  5850. if (needDeletionCheck) {
  5851. for (const key in slots) {
  5852. if (!isInternalKey(key) && deletionComparisonTarget[key] == null)
  5853. delete slots[key]
  5854. }
  5855. }
  5856. }
  5857. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5858. if (isArray(rawRef)) {
  5859. rawRef.forEach(
  5860. (r, i) => setRef(
  5861. r,
  5862. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  5863. parentSuspense,
  5864. vnode,
  5865. isUnmount,
  5866. ),
  5867. )
  5868. return
  5869. }
  5870. if (isAsyncWrapper(vnode) && !isUnmount)
  5871. return
  5872. const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el
  5873. const value = isUnmount ? null : refValue
  5874. const { i: owner, r: ref } = rawRef
  5875. if (!owner) {
  5876. warn$1(
  5877. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`,
  5878. )
  5879. return
  5880. }
  5881. const oldRef = oldRawRef && oldRawRef.r
  5882. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs
  5883. const setupState = owner.setupState
  5884. if (oldRef != null && oldRef !== ref) {
  5885. if (isString(oldRef)) {
  5886. refs[oldRef] = null
  5887. if (hasOwn(setupState, oldRef))
  5888. setupState[oldRef] = null
  5889. }
  5890. else if (isRef(oldRef)) {
  5891. oldRef.value = null
  5892. }
  5893. }
  5894. if (isFunction(ref)) {
  5895. callWithErrorHandling(ref, owner, 12, [value, refs])
  5896. }
  5897. else {
  5898. const _isString = isString(ref)
  5899. const _isRef = isRef(ref)
  5900. if (_isString || _isRef) {
  5901. const doSet = () => {
  5902. if (rawRef.f) {
  5903. const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value
  5904. if (isUnmount) {
  5905. isArray(existing) && remove(existing, refValue)
  5906. }
  5907. else {
  5908. if (!isArray(existing)) {
  5909. if (_isString) {
  5910. refs[ref] = [refValue]
  5911. if (hasOwn(setupState, ref))
  5912. setupState[ref] = refs[ref]
  5913. }
  5914. else {
  5915. ref.value = [refValue]
  5916. if (rawRef.k)
  5917. refs[rawRef.k] = ref.value
  5918. }
  5919. }
  5920. else if (!existing.includes(refValue)) {
  5921. existing.push(refValue)
  5922. }
  5923. }
  5924. }
  5925. else if (_isString) {
  5926. refs[ref] = value
  5927. if (hasOwn(setupState, ref))
  5928. setupState[ref] = value
  5929. }
  5930. else if (_isRef) {
  5931. ref.value = value
  5932. if (rawRef.k)
  5933. refs[rawRef.k] = value
  5934. }
  5935. else {
  5936. warn$1('Invalid template ref type:', ref, `(${typeof ref})`)
  5937. }
  5938. }
  5939. if (value) {
  5940. doSet.id = -1
  5941. queuePostRenderEffect(doSet, parentSuspense)
  5942. }
  5943. else {
  5944. doSet()
  5945. }
  5946. }
  5947. else {
  5948. warn$1('Invalid template ref type:', ref, `(${typeof ref})`)
  5949. }
  5950. }
  5951. }
  5952. let hasMismatch = false
  5953. const isSVGContainer = container => container.namespaceURI.includes('svg') && container.tagName !== 'foreignObject'
  5954. const isMathMLContainer = container => container.namespaceURI.includes('MathML')
  5955. function getContainerType(container) {
  5956. if (isSVGContainer(container))
  5957. return 'svg'
  5958. if (isMathMLContainer(container))
  5959. return 'mathml'
  5960. return void 0
  5961. }
  5962. const isComment = node => node.nodeType === 8 /* COMMENT */
  5963. function createHydrationFunctions(rendererInternals) {
  5964. const {
  5965. mt: mountComponent,
  5966. p: patch,
  5967. o: {
  5968. patchProp,
  5969. createText,
  5970. nextSibling,
  5971. parentNode,
  5972. remove,
  5973. insert,
  5974. createComment,
  5975. },
  5976. } = rendererInternals
  5977. const hydrate = (vnode, container) => {
  5978. if (!container.hasChildNodes()) {
  5979. warn$1(
  5980. `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`,
  5981. )
  5982. patch(null, vnode, container)
  5983. flushPostFlushCbs()
  5984. container._vnode = vnode
  5985. return
  5986. }
  5987. hasMismatch = false
  5988. hydrateNode(container.firstChild, vnode, null, null, null)
  5989. flushPostFlushCbs()
  5990. container._vnode = vnode
  5991. if (hasMismatch && true)
  5992. console.error(`Hydration completed but contains mismatches.`)
  5993. }
  5994. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5995. optimized = optimized || !!vnode.dynamicChildren
  5996. const isFragmentStart = isComment(node) && node.data === '['
  5997. const onMismatch = () => handleMismatch(
  5998. node,
  5999. vnode,
  6000. parentComponent,
  6001. parentSuspense,
  6002. slotScopeIds,
  6003. isFragmentStart,
  6004. )
  6005. const { type, ref, shapeFlag, patchFlag } = vnode
  6006. let domType = node.nodeType
  6007. vnode.el = node
  6008. {
  6009. if (!('__vnode' in node)) {
  6010. Object.defineProperty(node, '__vnode', {
  6011. value: vnode,
  6012. enumerable: false,
  6013. })
  6014. }
  6015. if (!('__vueParentComponent' in node)) {
  6016. Object.defineProperty(node, '__vueParentComponent', {
  6017. value: parentComponent,
  6018. enumerable: false,
  6019. })
  6020. }
  6021. }
  6022. if (patchFlag === -2) {
  6023. optimized = false
  6024. vnode.dynamicChildren = null
  6025. }
  6026. let nextNode = null
  6027. switch (type) {
  6028. case Text:
  6029. if (domType !== 3 /* TEXT */) {
  6030. if (vnode.children === '') {
  6031. insert(vnode.el = createText(''), parentNode(node), node)
  6032. nextNode = node
  6033. }
  6034. else {
  6035. nextNode = onMismatch()
  6036. }
  6037. }
  6038. else {
  6039. if (node.data !== vnode.children) {
  6040. hasMismatch = true
  6041. warn$1(
  6042. `Hydration text mismatch in`,
  6043. node.parentNode,
  6044. `
  6045. - rendered on server: ${JSON.stringify(
  6046. node.data,
  6047. )}
  6048. - expected on client: ${JSON.stringify(vnode.children)}`,
  6049. )
  6050. node.data = vnode.children
  6051. }
  6052. nextNode = nextSibling(node)
  6053. }
  6054. break
  6055. case Comment:
  6056. if (isTemplateNode(node)) {
  6057. nextNode = nextSibling(node)
  6058. replaceNode(
  6059. vnode.el = node.content.firstChild,
  6060. node,
  6061. parentComponent,
  6062. )
  6063. }
  6064. else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  6065. nextNode = onMismatch()
  6066. }
  6067. else {
  6068. nextNode = nextSibling(node)
  6069. }
  6070. break
  6071. case Static:
  6072. if (isFragmentStart) {
  6073. node = nextSibling(node)
  6074. domType = node.nodeType
  6075. }
  6076. if (domType === 1 /* ELEMENT */ || domType === 3 /* TEXT */) {
  6077. nextNode = node
  6078. const needToAdoptContent = !vnode.children.length
  6079. for (let i = 0; i < vnode.staticCount; i++) {
  6080. if (needToAdoptContent)
  6081. vnode.children += nextNode.nodeType === 1 /* ELEMENT */ ? nextNode.outerHTML : nextNode.data
  6082. if (i === vnode.staticCount - 1)
  6083. vnode.anchor = nextNode
  6084. nextNode = nextSibling(nextNode)
  6085. }
  6086. return isFragmentStart ? nextSibling(nextNode) : nextNode
  6087. }
  6088. else {
  6089. onMismatch()
  6090. }
  6091. break
  6092. case Fragment:
  6093. if (!isFragmentStart) {
  6094. nextNode = onMismatch()
  6095. }
  6096. else {
  6097. nextNode = hydrateFragment(
  6098. node,
  6099. vnode,
  6100. parentComponent,
  6101. parentSuspense,
  6102. slotScopeIds,
  6103. optimized,
  6104. )
  6105. }
  6106. break
  6107. default:
  6108. if (shapeFlag & 1) {
  6109. if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
  6110. nextNode = onMismatch()
  6111. }
  6112. else {
  6113. nextNode = hydrateElement(
  6114. node,
  6115. vnode,
  6116. parentComponent,
  6117. parentSuspense,
  6118. slotScopeIds,
  6119. optimized,
  6120. )
  6121. }
  6122. }
  6123. else if (shapeFlag & 6) {
  6124. vnode.slotScopeIds = slotScopeIds
  6125. const container = parentNode(node)
  6126. if (isFragmentStart)
  6127. nextNode = locateClosingAnchor(node)
  6128. else if (isComment(node) && node.data === 'teleport start')
  6129. nextNode = locateClosingAnchor(node, node.data, 'teleport end')
  6130. else
  6131. nextNode = nextSibling(node)
  6132. mountComponent(
  6133. vnode,
  6134. container,
  6135. null,
  6136. parentComponent,
  6137. parentSuspense,
  6138. getContainerType(container),
  6139. optimized,
  6140. )
  6141. if (isAsyncWrapper(vnode)) {
  6142. let subTree
  6143. if (isFragmentStart) {
  6144. subTree = createVNode(Fragment)
  6145. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild
  6146. }
  6147. else {
  6148. subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div')
  6149. }
  6150. subTree.el = node
  6151. vnode.component.subTree = subTree
  6152. }
  6153. }
  6154. else if (shapeFlag & 64) {
  6155. if (domType !== 8 /* COMMENT */) {
  6156. nextNode = onMismatch()
  6157. }
  6158. else {
  6159. nextNode = vnode.type.hydrate(
  6160. node,
  6161. vnode,
  6162. parentComponent,
  6163. parentSuspense,
  6164. slotScopeIds,
  6165. optimized,
  6166. rendererInternals,
  6167. hydrateChildren,
  6168. )
  6169. }
  6170. }
  6171. else if (shapeFlag & 128) {
  6172. nextNode = vnode.type.hydrate(
  6173. node,
  6174. vnode,
  6175. parentComponent,
  6176. parentSuspense,
  6177. getContainerType(parentNode(node)),
  6178. slotScopeIds,
  6179. optimized,
  6180. rendererInternals,
  6181. hydrateNode,
  6182. )
  6183. }
  6184. else {
  6185. warn$1('Invalid HostVNode type:', type, `(${typeof type})`)
  6186. }
  6187. }
  6188. if (ref != null)
  6189. setRef(ref, null, parentSuspense, vnode)
  6190. return nextNode
  6191. }
  6192. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6193. optimized = optimized || !!vnode.dynamicChildren
  6194. const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode
  6195. const forcePatch = type === 'input' || type === 'option'
  6196. {
  6197. if (dirs)
  6198. invokeDirectiveHook(vnode, null, parentComponent, 'created')
  6199. let needCallTransitionHooks = false
  6200. if (isTemplateNode(el)) {
  6201. needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear
  6202. const content = el.content.firstChild
  6203. if (needCallTransitionHooks)
  6204. transition.beforeEnter(content)
  6205. replaceNode(content, el, parentComponent)
  6206. vnode.el = el = content
  6207. }
  6208. if (shapeFlag & 16 // skip if element has innerHTML / textContent
  6209. && !(props && (props.innerHTML || props.textContent))) {
  6210. let next = hydrateChildren(
  6211. el.firstChild,
  6212. vnode,
  6213. el,
  6214. parentComponent,
  6215. parentSuspense,
  6216. slotScopeIds,
  6217. optimized,
  6218. )
  6219. let hasWarned = false
  6220. while (next) {
  6221. hasMismatch = true
  6222. if (!hasWarned) {
  6223. warn$1(
  6224. `Hydration children mismatch on`,
  6225. el,
  6226. `
  6227. Server rendered element contains more child nodes than client vdom.`,
  6228. )
  6229. hasWarned = true
  6230. }
  6231. const cur = next
  6232. next = next.nextSibling
  6233. remove(cur)
  6234. }
  6235. }
  6236. else if (shapeFlag & 8) {
  6237. if (el.textContent !== vnode.children) {
  6238. hasMismatch = true
  6239. warn$1(
  6240. `Hydration text content mismatch on`,
  6241. el,
  6242. `
  6243. - rendered on server: ${el.textContent}
  6244. - expected on client: ${vnode.children}`,
  6245. )
  6246. el.textContent = vnode.children
  6247. }
  6248. }
  6249. if (props) {
  6250. {
  6251. for (const key in props) {
  6252. if (propHasMismatch(el, key, props[key], vnode, parentComponent))
  6253. hasMismatch = true
  6254. if (forcePatch && (key.endsWith('value') || key === 'indeterminate') || isOn(key) && !isReservedProp(key) // force hydrate v-bind with .prop modifiers
  6255. || key[0] === '.') {
  6256. patchProp(
  6257. el,
  6258. key,
  6259. null,
  6260. props[key],
  6261. void 0,
  6262. void 0,
  6263. parentComponent,
  6264. )
  6265. }
  6266. }
  6267. }
  6268. }
  6269. let vnodeHooks
  6270. if (vnodeHooks = props && props.onVnodeBeforeMount)
  6271. invokeVNodeHook(vnodeHooks, parentComponent, vnode)
  6272. if (dirs)
  6273. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
  6274. if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
  6275. queueEffectWithSuspense(() => {
  6276. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode)
  6277. needCallTransitionHooks && transition.enter(el)
  6278. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted')
  6279. }, parentSuspense)
  6280. }
  6281. }
  6282. return el.nextSibling
  6283. }
  6284. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6285. optimized = optimized || !!parentVNode.dynamicChildren
  6286. const children = parentVNode.children
  6287. const l = children.length
  6288. let hasWarned = false
  6289. for (let i = 0; i < l; i++) {
  6290. const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i])
  6291. if (node) {
  6292. node = hydrateNode(
  6293. node,
  6294. vnode,
  6295. parentComponent,
  6296. parentSuspense,
  6297. slotScopeIds,
  6298. optimized,
  6299. )
  6300. }
  6301. else if (vnode.type === Text && !vnode.children) {
  6302. continue
  6303. }
  6304. else {
  6305. hasMismatch = true
  6306. if (!hasWarned) {
  6307. warn$1(
  6308. `Hydration children mismatch on`,
  6309. container,
  6310. `
  6311. Server rendered element contains fewer child nodes than client vdom.`,
  6312. )
  6313. hasWarned = true
  6314. }
  6315. patch(
  6316. null,
  6317. vnode,
  6318. container,
  6319. null,
  6320. parentComponent,
  6321. parentSuspense,
  6322. getContainerType(container),
  6323. slotScopeIds,
  6324. )
  6325. }
  6326. }
  6327. return node
  6328. }
  6329. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6330. const { slotScopeIds: fragmentSlotScopeIds } = vnode
  6331. if (fragmentSlotScopeIds)
  6332. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds
  6333. const container = parentNode(node)
  6334. const next = hydrateChildren(
  6335. nextSibling(node),
  6336. vnode,
  6337. container,
  6338. parentComponent,
  6339. parentSuspense,
  6340. slotScopeIds,
  6341. optimized,
  6342. )
  6343. if (next && isComment(next) && next.data === ']') {
  6344. return nextSibling(vnode.anchor = next)
  6345. }
  6346. else {
  6347. hasMismatch = true
  6348. insert(vnode.anchor = createComment(`]`), container, next)
  6349. return next
  6350. }
  6351. }
  6352. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6353. hasMismatch = true
  6354. warn$1(
  6355. `Hydration node mismatch:
  6356. - rendered on server:`,
  6357. node,
  6358. node.nodeType === 3 /* TEXT */ ? `(text)` : isComment(node) && node.data === '[' ? `(start of fragment)` : ``,
  6359. `
  6360. - expected on client:`,
  6361. vnode.type,
  6362. )
  6363. vnode.el = null
  6364. if (isFragment) {
  6365. const end = locateClosingAnchor(node)
  6366. while (true) {
  6367. const next2 = nextSibling(node)
  6368. if (next2 && next2 !== end)
  6369. remove(next2)
  6370. else
  6371. break
  6372. }
  6373. }
  6374. const next = nextSibling(node)
  6375. const container = parentNode(node)
  6376. remove(node)
  6377. patch(
  6378. null,
  6379. vnode,
  6380. container,
  6381. next,
  6382. parentComponent,
  6383. parentSuspense,
  6384. getContainerType(container),
  6385. slotScopeIds,
  6386. )
  6387. return next
  6388. }
  6389. const locateClosingAnchor = (node, open = '[', close = ']') => {
  6390. let match = 0
  6391. while (node) {
  6392. node = nextSibling(node)
  6393. if (node && isComment(node)) {
  6394. if (node.data === open)
  6395. match++
  6396. if (node.data === close) {
  6397. if (match === 0)
  6398. return nextSibling(node)
  6399. else
  6400. match--
  6401. }
  6402. }
  6403. }
  6404. return node
  6405. }
  6406. const replaceNode = (newNode, oldNode, parentComponent) => {
  6407. const parentNode2 = oldNode.parentNode
  6408. if (parentNode2)
  6409. parentNode2.replaceChild(newNode, oldNode)
  6410. let parent = parentComponent
  6411. while (parent) {
  6412. if (parent.vnode.el === oldNode)
  6413. parent.vnode.el = parent.subTree.el = newNode
  6414. parent = parent.parent
  6415. }
  6416. }
  6417. const isTemplateNode = (node) => {
  6418. return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === 'template'
  6419. }
  6420. return [hydrate, hydrateNode]
  6421. }
  6422. function propHasMismatch(el, key, clientValue, vnode, instance) {
  6423. let _a
  6424. let mismatchType
  6425. let mismatchKey
  6426. let actual
  6427. let expected
  6428. if (key === 'class') {
  6429. actual = el.getAttribute('class')
  6430. expected = normalizeClass(clientValue)
  6431. if (!isSetEqual(toClassSet(actual || ''), toClassSet(expected)))
  6432. mismatchType = mismatchKey = `class`
  6433. }
  6434. else if (key === 'style') {
  6435. actual = el.getAttribute('style') || ''
  6436. expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
  6437. const actualMap = toStyleMap(actual)
  6438. const expectedMap = toStyleMap(expected)
  6439. if (vnode.dirs) {
  6440. for (const { dir, value } of vnode.dirs) {
  6441. if (dir.name === 'show' && !value)
  6442. expectedMap.set('display', 'none')
  6443. }
  6444. }
  6445. const root = instance == null ? void 0 : instance.subTree
  6446. if (vnode === root || (root == null ? void 0 : root.type) === Fragment && root.children.includes(vnode)) {
  6447. const cssVars = (_a = instance == null ? void 0 : instance.getCssVars) == null ? void 0 : _a.call(instance)
  6448. for (const key2 in cssVars)
  6449. expectedMap.set(`--${key2}`, String(cssVars[key2]))
  6450. }
  6451. if (!isMapEqual(actualMap, expectedMap))
  6452. mismatchType = mismatchKey = 'style'
  6453. }
  6454. else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
  6455. if (isBooleanAttr(key)) {
  6456. actual = el.hasAttribute(key)
  6457. expected = includeBooleanAttr(clientValue)
  6458. }
  6459. else if (clientValue == null) {
  6460. actual = el.hasAttribute(key)
  6461. expected = false
  6462. }
  6463. else {
  6464. if (el.hasAttribute(key))
  6465. actual = el.getAttribute(key)
  6466. else if (key === 'value' && el.tagName === 'TEXTAREA')
  6467. actual = el.value
  6468. else
  6469. actual = false
  6470. expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false
  6471. }
  6472. if (actual !== expected) {
  6473. mismatchType = `attribute`
  6474. mismatchKey = key
  6475. }
  6476. }
  6477. if (mismatchType) {
  6478. const format = v => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`
  6479. const preSegment = `Hydration ${mismatchType} mismatch on`
  6480. const postSegment = `
  6481. - rendered on server: ${format(actual)}
  6482. - expected on client: ${format(expected)}
  6483. Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
  6484. You should fix the source of the mismatch.`
  6485. {
  6486. warn$1(preSegment, el, postSegment)
  6487. }
  6488. return true
  6489. }
  6490. return false
  6491. }
  6492. function toClassSet(str) {
  6493. return new Set(str.trim().split(/\s+/))
  6494. }
  6495. function isSetEqual(a, b) {
  6496. if (a.size !== b.size)
  6497. return false
  6498. for (const s of a) {
  6499. if (!b.has(s))
  6500. return false
  6501. }
  6502. return true
  6503. }
  6504. function toStyleMap(str) {
  6505. const styleMap = /* @__PURE__ */ new Map()
  6506. for (const item of str.split(';')) {
  6507. let [key, value] = item.split(':')
  6508. key = key == null ? void 0 : key.trim()
  6509. value = value == null ? void 0 : value.trim()
  6510. if (key && value)
  6511. styleMap.set(key, value)
  6512. }
  6513. return styleMap
  6514. }
  6515. function isMapEqual(a, b) {
  6516. if (a.size !== b.size)
  6517. return false
  6518. for (const [key, value] of a) {
  6519. if (value !== b.get(key))
  6520. return false
  6521. }
  6522. return true
  6523. }
  6524. let supported
  6525. let perf
  6526. function startMeasure(instance, type) {
  6527. if (instance.appContext.config.performance && isSupported())
  6528. perf.mark(`vue-${type}-${instance.uid}`)
  6529. {
  6530. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now())
  6531. }
  6532. }
  6533. function endMeasure(instance, type) {
  6534. if (instance.appContext.config.performance && isSupported()) {
  6535. const startTag = `vue-${type}-${instance.uid}`
  6536. const endTag = `${startTag}:end`
  6537. perf.mark(endTag)
  6538. perf.measure(
  6539. `<${formatComponentName(instance, instance.type)}> ${type}`,
  6540. startTag,
  6541. endTag,
  6542. )
  6543. perf.clearMarks(startTag)
  6544. perf.clearMarks(endTag)
  6545. }
  6546. {
  6547. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now())
  6548. }
  6549. }
  6550. function isSupported() {
  6551. if (supported !== void 0)
  6552. return supported
  6553. if (typeof window !== 'undefined' && window.performance) {
  6554. supported = true
  6555. perf = window.performance
  6556. }
  6557. else {
  6558. supported = false
  6559. }
  6560. return supported
  6561. }
  6562. const queuePostRenderEffect = queueEffectWithSuspense
  6563. function createRenderer(options) {
  6564. return baseCreateRenderer(options)
  6565. }
  6566. function createHydrationRenderer(options) {
  6567. return baseCreateRenderer(options, createHydrationFunctions)
  6568. }
  6569. function baseCreateRenderer(options, createHydrationFns) {
  6570. const target = getGlobalThis()
  6571. target.__VUE__ = true
  6572. {
  6573. setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target)
  6574. }
  6575. const {
  6576. insert: hostInsert,
  6577. remove: hostRemove,
  6578. patchProp: hostPatchProp,
  6579. createElement: hostCreateElement,
  6580. createText: hostCreateText,
  6581. createComment: hostCreateComment,
  6582. setText: hostSetText,
  6583. setElementText: hostSetElementText,
  6584. parentNode: hostParentNode,
  6585. nextSibling: hostNextSibling,
  6586. setScopeId: hostSetScopeId = NOOP,
  6587. insertStaticContent: hostInsertStaticContent,
  6588. } = options
  6589. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6590. if (n1 === n2)
  6591. return
  6592. if (n1 && !isSameVNodeType(n1, n2)) {
  6593. anchor = getNextHostNode(n1)
  6594. unmount(n1, parentComponent, parentSuspense, true)
  6595. n1 = null
  6596. }
  6597. if (n2.patchFlag === -2) {
  6598. optimized = false
  6599. n2.dynamicChildren = null
  6600. }
  6601. const { type, ref, shapeFlag } = n2
  6602. switch (type) {
  6603. case Text:
  6604. processText(n1, n2, container, anchor)
  6605. break
  6606. case Comment:
  6607. processCommentNode(n1, n2, container, anchor)
  6608. break
  6609. case Static:
  6610. if (n1 == null)
  6611. mountStaticNode(n2, container, anchor, namespace)
  6612. else
  6613. patchStaticNode(n1, n2, container, namespace)
  6614. break
  6615. case Fragment:
  6616. processFragment(
  6617. n1,
  6618. n2,
  6619. container,
  6620. anchor,
  6621. parentComponent,
  6622. parentSuspense,
  6623. namespace,
  6624. slotScopeIds,
  6625. optimized,
  6626. )
  6627. break
  6628. default:
  6629. if (shapeFlag & 1) {
  6630. processElement(
  6631. n1,
  6632. n2,
  6633. container,
  6634. anchor,
  6635. parentComponent,
  6636. parentSuspense,
  6637. namespace,
  6638. slotScopeIds,
  6639. optimized,
  6640. )
  6641. }
  6642. else if (shapeFlag & 6) {
  6643. processComponent(
  6644. n1,
  6645. n2,
  6646. container,
  6647. anchor,
  6648. parentComponent,
  6649. parentSuspense,
  6650. namespace,
  6651. slotScopeIds,
  6652. optimized,
  6653. )
  6654. }
  6655. else if (shapeFlag & 64) {
  6656. type.process(
  6657. n1,
  6658. n2,
  6659. container,
  6660. anchor,
  6661. parentComponent,
  6662. parentSuspense,
  6663. namespace,
  6664. slotScopeIds,
  6665. optimized,
  6666. internals,
  6667. )
  6668. }
  6669. else if (shapeFlag & 128) {
  6670. type.process(
  6671. n1,
  6672. n2,
  6673. container,
  6674. anchor,
  6675. parentComponent,
  6676. parentSuspense,
  6677. namespace,
  6678. slotScopeIds,
  6679. optimized,
  6680. internals,
  6681. )
  6682. }
  6683. else {
  6684. warn$1('Invalid VNode type:', type, `(${typeof type})`)
  6685. }
  6686. }
  6687. if (ref != null && parentComponent)
  6688. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2)
  6689. }
  6690. const processText = (n1, n2, container, anchor) => {
  6691. if (n1 == null) {
  6692. hostInsert(
  6693. n2.el = hostCreateText(n2.children),
  6694. container,
  6695. anchor,
  6696. )
  6697. }
  6698. else {
  6699. const el = n2.el = n1.el
  6700. if (n2.children !== n1.children)
  6701. hostSetText(el, n2.children)
  6702. }
  6703. }
  6704. const processCommentNode = (n1, n2, container, anchor) => {
  6705. if (n1 == null) {
  6706. hostInsert(
  6707. n2.el = hostCreateComment(n2.children || ''),
  6708. container,
  6709. anchor,
  6710. )
  6711. }
  6712. else {
  6713. n2.el = n1.el
  6714. }
  6715. }
  6716. const mountStaticNode = (n2, container, anchor, namespace) => {
  6717. [n2.el, n2.anchor] = hostInsertStaticContent(
  6718. n2.children,
  6719. container,
  6720. anchor,
  6721. namespace,
  6722. n2.el,
  6723. n2.anchor,
  6724. )
  6725. }
  6726. const patchStaticNode = (n1, n2, container, namespace) => {
  6727. if (n2.children !== n1.children) {
  6728. const anchor = hostNextSibling(n1.anchor)
  6729. removeStaticNode(n1);
  6730. [n2.el, n2.anchor] = hostInsertStaticContent(
  6731. n2.children,
  6732. container,
  6733. anchor,
  6734. namespace,
  6735. )
  6736. }
  6737. else {
  6738. n2.el = n1.el
  6739. n2.anchor = n1.anchor
  6740. }
  6741. }
  6742. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6743. let next
  6744. while (el && el !== anchor) {
  6745. next = hostNextSibling(el)
  6746. hostInsert(el, container, nextSibling)
  6747. el = next
  6748. }
  6749. hostInsert(anchor, container, nextSibling)
  6750. }
  6751. const removeStaticNode = ({ el, anchor }) => {
  6752. let next
  6753. while (el && el !== anchor) {
  6754. next = hostNextSibling(el)
  6755. hostRemove(el)
  6756. el = next
  6757. }
  6758. hostRemove(anchor)
  6759. }
  6760. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  6761. if (n2.type === 'svg')
  6762. namespace = 'svg'
  6763. else if (n2.type === 'math')
  6764. namespace = 'mathml'
  6765. if (n1 == null) {
  6766. mountElement(
  6767. n2,
  6768. container,
  6769. anchor,
  6770. parentComponent,
  6771. parentSuspense,
  6772. namespace,
  6773. slotScopeIds,
  6774. optimized,
  6775. )
  6776. }
  6777. else {
  6778. patchElement(
  6779. n1,
  6780. n2,
  6781. parentComponent,
  6782. parentSuspense,
  6783. namespace,
  6784. slotScopeIds,
  6785. optimized,
  6786. )
  6787. }
  6788. }
  6789. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  6790. let el
  6791. let vnodeHook
  6792. const { props, shapeFlag, transition, dirs } = vnode
  6793. el = vnode.el = hostCreateElement(
  6794. vnode.type,
  6795. namespace,
  6796. props && props.is,
  6797. props,
  6798. )
  6799. if (shapeFlag & 8) {
  6800. hostSetElementText(el, vnode.children)
  6801. }
  6802. else if (shapeFlag & 16) {
  6803. mountChildren(
  6804. vnode.children,
  6805. el,
  6806. null,
  6807. parentComponent,
  6808. parentSuspense,
  6809. resolveChildrenNamespace(vnode, namespace),
  6810. slotScopeIds,
  6811. optimized,
  6812. )
  6813. }
  6814. if (dirs)
  6815. invokeDirectiveHook(vnode, null, parentComponent, 'created')
  6816. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent)
  6817. if (props) {
  6818. for (const key in props) {
  6819. if (key !== 'value' && !isReservedProp(key)) {
  6820. hostPatchProp(
  6821. el,
  6822. key,
  6823. null,
  6824. props[key],
  6825. namespace,
  6826. vnode.children,
  6827. parentComponent,
  6828. parentSuspense,
  6829. unmountChildren,
  6830. )
  6831. }
  6832. }
  6833. if ('value' in props)
  6834. hostPatchProp(el, 'value', null, props.value, namespace)
  6835. if (vnodeHook = props.onVnodeBeforeMount)
  6836. invokeVNodeHook(vnodeHook, parentComponent, vnode)
  6837. }
  6838. {
  6839. Object.defineProperty(el, '__vnode', {
  6840. value: vnode,
  6841. enumerable: false,
  6842. })
  6843. Object.defineProperty(el, '__vueParentComponent', {
  6844. value: parentComponent,
  6845. enumerable: false,
  6846. })
  6847. }
  6848. if (dirs)
  6849. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
  6850. const needCallTransitionHooks = needTransition(parentSuspense, transition)
  6851. if (needCallTransitionHooks)
  6852. transition.beforeEnter(el)
  6853. hostInsert(el, container, anchor)
  6854. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  6855. queuePostRenderEffect(() => {
  6856. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
  6857. needCallTransitionHooks && transition.enter(el)
  6858. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted')
  6859. }, parentSuspense)
  6860. }
  6861. }
  6862. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6863. if (scopeId)
  6864. hostSetScopeId(el, scopeId)
  6865. if (slotScopeIds) {
  6866. for (let i = 0; i < slotScopeIds.length; i++)
  6867. hostSetScopeId(el, slotScopeIds[i])
  6868. }
  6869. if (parentComponent) {
  6870. let subTree = parentComponent.subTree
  6871. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048)
  6872. subTree = filterSingleRoot(subTree.children) || subTree
  6873. if (vnode === subTree) {
  6874. const parentVNode = parentComponent.vnode
  6875. setScopeId(
  6876. el,
  6877. parentVNode,
  6878. parentVNode.scopeId,
  6879. parentVNode.slotScopeIds,
  6880. parentComponent.parent,
  6881. )
  6882. }
  6883. }
  6884. }
  6885. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
  6886. for (let i = start; i < children.length; i++) {
  6887. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i])
  6888. patch(
  6889. null,
  6890. child,
  6891. container,
  6892. anchor,
  6893. parentComponent,
  6894. parentSuspense,
  6895. namespace,
  6896. slotScopeIds,
  6897. optimized,
  6898. )
  6899. }
  6900. }
  6901. const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  6902. const el = n2.el = n1.el
  6903. let { patchFlag, dynamicChildren, dirs } = n2
  6904. patchFlag |= n1.patchFlag & 16
  6905. const oldProps = n1.props || EMPTY_OBJ
  6906. const newProps = n2.props || EMPTY_OBJ
  6907. let vnodeHook
  6908. parentComponent && toggleRecurse(parentComponent, false)
  6909. if (vnodeHook = newProps.onVnodeBeforeUpdate)
  6910. invokeVNodeHook(vnodeHook, parentComponent, n2, n1)
  6911. if (dirs)
  6912. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate')
  6913. parentComponent && toggleRecurse(parentComponent, true)
  6914. if (isHmrUpdating) {
  6915. patchFlag = 0
  6916. optimized = false
  6917. dynamicChildren = null
  6918. }
  6919. if (dynamicChildren) {
  6920. patchBlockChildren(
  6921. n1.dynamicChildren,
  6922. dynamicChildren,
  6923. el,
  6924. parentComponent,
  6925. parentSuspense,
  6926. resolveChildrenNamespace(n2, namespace),
  6927. slotScopeIds,
  6928. )
  6929. {
  6930. traverseStaticChildren(n1, n2)
  6931. }
  6932. }
  6933. else if (!optimized) {
  6934. patchChildren(
  6935. n1,
  6936. n2,
  6937. el,
  6938. null,
  6939. parentComponent,
  6940. parentSuspense,
  6941. resolveChildrenNamespace(n2, namespace),
  6942. slotScopeIds,
  6943. false,
  6944. )
  6945. }
  6946. if (patchFlag > 0) {
  6947. if (patchFlag & 16) {
  6948. patchProps(
  6949. el,
  6950. n2,
  6951. oldProps,
  6952. newProps,
  6953. parentComponent,
  6954. parentSuspense,
  6955. namespace,
  6956. )
  6957. }
  6958. else {
  6959. if (patchFlag & 2) {
  6960. if (oldProps.class !== newProps.class)
  6961. hostPatchProp(el, 'class', null, newProps.class, namespace)
  6962. }
  6963. if (patchFlag & 4)
  6964. hostPatchProp(el, 'style', oldProps.style, newProps.style, namespace)
  6965. if (patchFlag & 8) {
  6966. const propsToUpdate = n2.dynamicProps
  6967. for (let i = 0; i < propsToUpdate.length; i++) {
  6968. const key = propsToUpdate[i]
  6969. const prev = oldProps[key]
  6970. const next = newProps[key]
  6971. if (next !== prev || key === 'value') {
  6972. hostPatchProp(
  6973. el,
  6974. key,
  6975. prev,
  6976. next,
  6977. namespace,
  6978. n1.children,
  6979. parentComponent,
  6980. parentSuspense,
  6981. unmountChildren,
  6982. )
  6983. }
  6984. }
  6985. }
  6986. }
  6987. if (patchFlag & 1) {
  6988. if (n1.children !== n2.children)
  6989. hostSetElementText(el, n2.children)
  6990. }
  6991. }
  6992. else if (!optimized && dynamicChildren == null) {
  6993. patchProps(
  6994. el,
  6995. n2,
  6996. oldProps,
  6997. newProps,
  6998. parentComponent,
  6999. parentSuspense,
  7000. namespace,
  7001. )
  7002. }
  7003. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  7004. queuePostRenderEffect(() => {
  7005. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1)
  7006. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated')
  7007. }, parentSuspense)
  7008. }
  7009. }
  7010. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
  7011. for (let i = 0; i < newChildren.length; i++) {
  7012. const oldVNode = oldChildren[i]
  7013. const newVNode = newChildren[i]
  7014. const container = (
  7015. // oldVNode may be an errored async setup() component inside Suspense
  7016. // which will not have a mounted element
  7017. oldVNode.el // - In the case of a Fragment, we need to provide the actual parent
  7018. // of the Fragment itself so it can move its children.
  7019. && (oldVNode.type === Fragment // - In the case of different nodes, there is going to be a replacement
  7020. // which also requires the correct parent container
  7021. || !isSameVNodeType(oldVNode, newVNode) // - In the case of a component, it could contain anything.
  7022. || oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
  7023. // In other cases, the parent container is not actually used so we
  7024. // just pass the block element here to avoid a DOM parentNode call.
  7025. fallbackContainer
  7026. )
  7027. )
  7028. patch(
  7029. oldVNode,
  7030. newVNode,
  7031. container,
  7032. null,
  7033. parentComponent,
  7034. parentSuspense,
  7035. namespace,
  7036. slotScopeIds,
  7037. true,
  7038. )
  7039. }
  7040. }
  7041. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
  7042. if (oldProps !== newProps) {
  7043. if (oldProps !== EMPTY_OBJ) {
  7044. for (const key in oldProps) {
  7045. if (!isReservedProp(key) && !(key in newProps)) {
  7046. hostPatchProp(
  7047. el,
  7048. key,
  7049. oldProps[key],
  7050. null,
  7051. namespace,
  7052. vnode.children,
  7053. parentComponent,
  7054. parentSuspense,
  7055. unmountChildren,
  7056. )
  7057. }
  7058. }
  7059. }
  7060. for (const key in newProps) {
  7061. if (isReservedProp(key))
  7062. continue
  7063. const next = newProps[key]
  7064. const prev = oldProps[key]
  7065. if (next !== prev && key !== 'value') {
  7066. hostPatchProp(
  7067. el,
  7068. key,
  7069. prev,
  7070. next,
  7071. namespace,
  7072. vnode.children,
  7073. parentComponent,
  7074. parentSuspense,
  7075. unmountChildren,
  7076. )
  7077. }
  7078. }
  7079. if ('value' in newProps)
  7080. hostPatchProp(el, 'value', oldProps.value, newProps.value, namespace)
  7081. }
  7082. }
  7083. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7084. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText('')
  7085. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText('')
  7086. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
  7087. if (
  7088. // #5523 dev root fragment may inherit directives
  7089. isHmrUpdating || patchFlag & 2048
  7090. ) {
  7091. patchFlag = 0
  7092. optimized = false
  7093. dynamicChildren = null
  7094. }
  7095. if (fragmentSlotScopeIds)
  7096. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds
  7097. if (n1 == null) {
  7098. hostInsert(fragmentStartAnchor, container, anchor)
  7099. hostInsert(fragmentEndAnchor, container, anchor)
  7100. mountChildren(
  7101. // #10007
  7102. // such fragment like `<></>` will be compiled into
  7103. // a fragment which doesn't have a children.
  7104. // In this case fallback to an empty array
  7105. n2.children || [],
  7106. container,
  7107. fragmentEndAnchor,
  7108. parentComponent,
  7109. parentSuspense,
  7110. namespace,
  7111. slotScopeIds,
  7112. optimized,
  7113. )
  7114. }
  7115. else {
  7116. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren // #2715 the previous fragment could've been a BAILed one as a result
  7117. // of renderSlot() with no valid children
  7118. && n1.dynamicChildren) {
  7119. patchBlockChildren(
  7120. n1.dynamicChildren,
  7121. dynamicChildren,
  7122. container,
  7123. parentComponent,
  7124. parentSuspense,
  7125. namespace,
  7126. slotScopeIds,
  7127. )
  7128. {
  7129. traverseStaticChildren(n1, n2)
  7130. }
  7131. }
  7132. else {
  7133. patchChildren(
  7134. n1,
  7135. n2,
  7136. container,
  7137. fragmentEndAnchor,
  7138. parentComponent,
  7139. parentSuspense,
  7140. namespace,
  7141. slotScopeIds,
  7142. optimized,
  7143. )
  7144. }
  7145. }
  7146. }
  7147. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7148. n2.slotScopeIds = slotScopeIds
  7149. if (n1 == null) {
  7150. if (n2.shapeFlag & 512) {
  7151. parentComponent.ctx.activate(
  7152. n2,
  7153. container,
  7154. anchor,
  7155. namespace,
  7156. optimized,
  7157. )
  7158. }
  7159. else {
  7160. mountComponent(
  7161. n2,
  7162. container,
  7163. anchor,
  7164. parentComponent,
  7165. parentSuspense,
  7166. namespace,
  7167. optimized,
  7168. )
  7169. }
  7170. }
  7171. else {
  7172. updateComponent(n1, n2, optimized)
  7173. }
  7174. }
  7175. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
  7176. const instance = (initialVNode.component = createComponentInstance(
  7177. initialVNode,
  7178. parentComponent,
  7179. parentSuspense,
  7180. ))
  7181. if (instance.type.__hmrId)
  7182. registerHMR(instance)
  7183. {
  7184. pushWarningContext(initialVNode)
  7185. startMeasure(instance, `mount`)
  7186. }
  7187. if (isKeepAlive(initialVNode))
  7188. instance.ctx.renderer = internals
  7189. {
  7190. {
  7191. startMeasure(instance, `init`)
  7192. }
  7193. setupComponent(instance)
  7194. {
  7195. endMeasure(instance, `init`)
  7196. }
  7197. }
  7198. if (instance.asyncDep) {
  7199. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect)
  7200. if (!initialVNode.el) {
  7201. const placeholder = instance.subTree = createVNode(Comment)
  7202. processCommentNode(null, placeholder, container, anchor)
  7203. }
  7204. }
  7205. else {
  7206. setupRenderEffect(
  7207. instance,
  7208. initialVNode,
  7209. container,
  7210. anchor,
  7211. parentSuspense,
  7212. namespace,
  7213. optimized,
  7214. )
  7215. }
  7216. {
  7217. popWarningContext()
  7218. endMeasure(instance, `mount`)
  7219. }
  7220. }
  7221. const updateComponent = (n1, n2, optimized) => {
  7222. const instance = n2.component = n1.component
  7223. if (shouldUpdateComponent(n1, n2, optimized)) {
  7224. if (instance.asyncDep && !instance.asyncResolved) {
  7225. {
  7226. pushWarningContext(n2)
  7227. }
  7228. updateComponentPreRender(instance, n2, optimized)
  7229. {
  7230. popWarningContext()
  7231. }
  7232. }
  7233. else {
  7234. instance.next = n2
  7235. invalidateJob(instance.update)
  7236. instance.effect.dirty = true
  7237. instance.update()
  7238. }
  7239. }
  7240. else {
  7241. n2.el = n1.el
  7242. instance.vnode = n2
  7243. }
  7244. }
  7245. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
  7246. const componentUpdateFn = () => {
  7247. if (!instance.isMounted) {
  7248. let vnodeHook
  7249. const { el, props } = initialVNode
  7250. const { bm, m, parent } = instance
  7251. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode)
  7252. toggleRecurse(instance, false)
  7253. if (bm)
  7254. invokeArrayFns(bm)
  7255. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount))
  7256. invokeVNodeHook(vnodeHook, parent, initialVNode)
  7257. toggleRecurse(instance, true)
  7258. if (el && hydrateNode) {
  7259. const hydrateSubTree = () => {
  7260. {
  7261. startMeasure(instance, `render`)
  7262. }
  7263. instance.subTree = renderComponentRoot(instance)
  7264. {
  7265. endMeasure(instance, `render`)
  7266. }
  7267. {
  7268. startMeasure(instance, `hydrate`)
  7269. }
  7270. hydrateNode(
  7271. el,
  7272. instance.subTree,
  7273. instance,
  7274. parentSuspense,
  7275. null,
  7276. )
  7277. {
  7278. endMeasure(instance, `hydrate`)
  7279. }
  7280. }
  7281. if (isAsyncWrapperVNode) {
  7282. initialVNode.type.__asyncLoader().then(
  7283. // note: we are moving the render call into an async callback,
  7284. // which means it won't track dependencies - but it's ok because
  7285. // a server-rendered async wrapper is already in resolved state
  7286. // and it will never need to change.
  7287. () => !instance.isUnmounted && hydrateSubTree(),
  7288. )
  7289. }
  7290. else {
  7291. hydrateSubTree()
  7292. }
  7293. }
  7294. else {
  7295. {
  7296. startMeasure(instance, `render`)
  7297. }
  7298. const subTree = instance.subTree = renderComponentRoot(instance)
  7299. {
  7300. endMeasure(instance, `render`)
  7301. }
  7302. {
  7303. startMeasure(instance, `patch`)
  7304. }
  7305. patch(
  7306. null,
  7307. subTree,
  7308. container,
  7309. anchor,
  7310. instance,
  7311. parentSuspense,
  7312. namespace,
  7313. )
  7314. {
  7315. endMeasure(instance, `patch`)
  7316. }
  7317. initialVNode.el = subTree.el
  7318. }
  7319. if (m)
  7320. queuePostRenderEffect(m, parentSuspense)
  7321. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  7322. const scopedInitialVNode = initialVNode
  7323. queuePostRenderEffect(
  7324. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  7325. parentSuspense,
  7326. )
  7327. }
  7328. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256)
  7329. instance.a && queuePostRenderEffect(instance.a, parentSuspense)
  7330. instance.isMounted = true
  7331. {
  7332. devtoolsComponentAdded(instance)
  7333. }
  7334. initialVNode = container = anchor = null
  7335. }
  7336. else {
  7337. let { next, bu, u, parent, vnode } = instance
  7338. {
  7339. const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance)
  7340. if (nonHydratedAsyncRoot) {
  7341. if (next) {
  7342. next.el = vnode.el
  7343. updateComponentPreRender(instance, next, optimized)
  7344. }
  7345. nonHydratedAsyncRoot.asyncDep.then(() => {
  7346. if (!instance.isUnmounted)
  7347. componentUpdateFn()
  7348. })
  7349. return
  7350. }
  7351. }
  7352. const originNext = next
  7353. let vnodeHook
  7354. {
  7355. pushWarningContext(next || instance.vnode)
  7356. }
  7357. toggleRecurse(instance, false)
  7358. if (next) {
  7359. next.el = vnode.el
  7360. updateComponentPreRender(instance, next, optimized)
  7361. }
  7362. else {
  7363. next = vnode
  7364. }
  7365. if (bu)
  7366. invokeArrayFns(bu)
  7367. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate)
  7368. invokeVNodeHook(vnodeHook, parent, next, vnode)
  7369. toggleRecurse(instance, true)
  7370. {
  7371. startMeasure(instance, `render`)
  7372. }
  7373. const nextTree = renderComponentRoot(instance)
  7374. {
  7375. endMeasure(instance, `render`)
  7376. }
  7377. const prevTree = instance.subTree
  7378. instance.subTree = nextTree
  7379. {
  7380. startMeasure(instance, `patch`)
  7381. }
  7382. patch(
  7383. prevTree,
  7384. nextTree,
  7385. // parent may have changed if it's in a teleport
  7386. hostParentNode(prevTree.el),
  7387. // anchor may have changed if it's in a fragment
  7388. getNextHostNode(prevTree),
  7389. instance,
  7390. parentSuspense,
  7391. namespace,
  7392. )
  7393. {
  7394. endMeasure(instance, `patch`)
  7395. }
  7396. next.el = nextTree.el
  7397. if (originNext === null)
  7398. updateHOCHostEl(instance, nextTree.el)
  7399. if (u)
  7400. queuePostRenderEffect(u, parentSuspense)
  7401. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  7402. queuePostRenderEffect(
  7403. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  7404. parentSuspense,
  7405. )
  7406. }
  7407. {
  7408. devtoolsComponentUpdated(instance)
  7409. }
  7410. {
  7411. popWarningContext()
  7412. }
  7413. }
  7414. }
  7415. const effect = instance.effect = new ReactiveEffect(
  7416. componentUpdateFn,
  7417. NOOP,
  7418. () => queueJob(update),
  7419. instance.scope,
  7420. // track it in component's effect scope
  7421. )
  7422. const update = instance.update = () => {
  7423. if (effect.dirty)
  7424. effect.run()
  7425. }
  7426. update.id = instance.uid
  7427. toggleRecurse(instance, true)
  7428. {
  7429. effect.onTrack = instance.rtc ? e => invokeArrayFns(instance.rtc, e) : void 0
  7430. effect.onTrigger = instance.rtg ? e => invokeArrayFns(instance.rtg, e) : void 0
  7431. update.ownerInstance = instance
  7432. }
  7433. update()
  7434. }
  7435. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7436. nextVNode.component = instance
  7437. const prevProps = instance.vnode.props
  7438. instance.vnode = nextVNode
  7439. instance.next = null
  7440. updateProps(instance, nextVNode.props, prevProps, optimized)
  7441. updateSlots(instance, nextVNode.children, optimized)
  7442. pauseTracking()
  7443. flushPreFlushCbs(instance)
  7444. resetTracking()
  7445. }
  7446. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
  7447. const c1 = n1 && n1.children
  7448. const prevShapeFlag = n1 ? n1.shapeFlag : 0
  7449. const c2 = n2.children
  7450. const { patchFlag, shapeFlag } = n2
  7451. if (patchFlag > 0) {
  7452. if (patchFlag & 128) {
  7453. patchKeyedChildren(
  7454. c1,
  7455. c2,
  7456. container,
  7457. anchor,
  7458. parentComponent,
  7459. parentSuspense,
  7460. namespace,
  7461. slotScopeIds,
  7462. optimized,
  7463. )
  7464. return
  7465. }
  7466. else if (patchFlag & 256) {
  7467. patchUnkeyedChildren(
  7468. c1,
  7469. c2,
  7470. container,
  7471. anchor,
  7472. parentComponent,
  7473. parentSuspense,
  7474. namespace,
  7475. slotScopeIds,
  7476. optimized,
  7477. )
  7478. return
  7479. }
  7480. }
  7481. if (shapeFlag & 8) {
  7482. if (prevShapeFlag & 16)
  7483. unmountChildren(c1, parentComponent, parentSuspense)
  7484. if (c2 !== c1)
  7485. hostSetElementText(container, c2)
  7486. }
  7487. else {
  7488. if (prevShapeFlag & 16) {
  7489. if (shapeFlag & 16) {
  7490. patchKeyedChildren(
  7491. c1,
  7492. c2,
  7493. container,
  7494. anchor,
  7495. parentComponent,
  7496. parentSuspense,
  7497. namespace,
  7498. slotScopeIds,
  7499. optimized,
  7500. )
  7501. }
  7502. else {
  7503. unmountChildren(c1, parentComponent, parentSuspense, true)
  7504. }
  7505. }
  7506. else {
  7507. if (prevShapeFlag & 8)
  7508. hostSetElementText(container, '')
  7509. if (shapeFlag & 16) {
  7510. mountChildren(
  7511. c2,
  7512. container,
  7513. anchor,
  7514. parentComponent,
  7515. parentSuspense,
  7516. namespace,
  7517. slotScopeIds,
  7518. optimized,
  7519. )
  7520. }
  7521. }
  7522. }
  7523. }
  7524. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7525. c1 = c1 || EMPTY_ARR
  7526. c2 = c2 || EMPTY_ARR
  7527. const oldLength = c1.length
  7528. const newLength = c2.length
  7529. const commonLength = Math.min(oldLength, newLength)
  7530. let i
  7531. for (i = 0; i < commonLength; i++) {
  7532. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i])
  7533. patch(
  7534. c1[i],
  7535. nextChild,
  7536. container,
  7537. null,
  7538. parentComponent,
  7539. parentSuspense,
  7540. namespace,
  7541. slotScopeIds,
  7542. optimized,
  7543. )
  7544. }
  7545. if (oldLength > newLength) {
  7546. unmountChildren(
  7547. c1,
  7548. parentComponent,
  7549. parentSuspense,
  7550. true,
  7551. false,
  7552. commonLength,
  7553. )
  7554. }
  7555. else {
  7556. mountChildren(
  7557. c2,
  7558. container,
  7559. anchor,
  7560. parentComponent,
  7561. parentSuspense,
  7562. namespace,
  7563. slotScopeIds,
  7564. optimized,
  7565. commonLength,
  7566. )
  7567. }
  7568. }
  7569. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7570. let i = 0
  7571. const l2 = c2.length
  7572. let e1 = c1.length - 1
  7573. let e2 = l2 - 1
  7574. while (i <= e1 && i <= e2) {
  7575. const n1 = c1[i]
  7576. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i])
  7577. if (isSameVNodeType(n1, n2)) {
  7578. patch(
  7579. n1,
  7580. n2,
  7581. container,
  7582. null,
  7583. parentComponent,
  7584. parentSuspense,
  7585. namespace,
  7586. slotScopeIds,
  7587. optimized,
  7588. )
  7589. }
  7590. else {
  7591. break
  7592. }
  7593. i++
  7594. }
  7595. while (i <= e1 && i <= e2) {
  7596. const n1 = c1[e1]
  7597. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2])
  7598. if (isSameVNodeType(n1, n2)) {
  7599. patch(
  7600. n1,
  7601. n2,
  7602. container,
  7603. null,
  7604. parentComponent,
  7605. parentSuspense,
  7606. namespace,
  7607. slotScopeIds,
  7608. optimized,
  7609. )
  7610. }
  7611. else {
  7612. break
  7613. }
  7614. e1--
  7615. e2--
  7616. }
  7617. if (i > e1) {
  7618. if (i <= e2) {
  7619. const nextPos = e2 + 1
  7620. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor
  7621. while (i <= e2) {
  7622. patch(
  7623. null,
  7624. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
  7625. container,
  7626. anchor,
  7627. parentComponent,
  7628. parentSuspense,
  7629. namespace,
  7630. slotScopeIds,
  7631. optimized,
  7632. )
  7633. i++
  7634. }
  7635. }
  7636. }
  7637. else if (i > e2) {
  7638. while (i <= e1) {
  7639. unmount(c1[i], parentComponent, parentSuspense, true)
  7640. i++
  7641. }
  7642. }
  7643. else {
  7644. const s1 = i
  7645. const s2 = i
  7646. const keyToNewIndexMap = /* @__PURE__ */ new Map()
  7647. for (i = s2; i <= e2; i++) {
  7648. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i])
  7649. if (nextChild.key != null) {
  7650. if (keyToNewIndexMap.has(nextChild.key)) {
  7651. warn$1(
  7652. `Duplicate keys found during update:`,
  7653. JSON.stringify(nextChild.key),
  7654. `Make sure keys are unique.`,
  7655. )
  7656. }
  7657. keyToNewIndexMap.set(nextChild.key, i)
  7658. }
  7659. }
  7660. let j
  7661. let patched = 0
  7662. const toBePatched = e2 - s2 + 1
  7663. let moved = false
  7664. let maxNewIndexSoFar = 0
  7665. const newIndexToOldIndexMap = new Array(toBePatched)
  7666. for (i = 0; i < toBePatched; i++)
  7667. newIndexToOldIndexMap[i] = 0
  7668. for (i = s1; i <= e1; i++) {
  7669. const prevChild = c1[i]
  7670. if (patched >= toBePatched) {
  7671. unmount(prevChild, parentComponent, parentSuspense, true)
  7672. continue
  7673. }
  7674. let newIndex
  7675. if (prevChild.key != null) {
  7676. newIndex = keyToNewIndexMap.get(prevChild.key)
  7677. }
  7678. else {
  7679. for (j = s2; j <= e2; j++) {
  7680. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  7681. newIndex = j
  7682. break
  7683. }
  7684. }
  7685. }
  7686. if (newIndex === void 0) {
  7687. unmount(prevChild, parentComponent, parentSuspense, true)
  7688. }
  7689. else {
  7690. newIndexToOldIndexMap[newIndex - s2] = i + 1
  7691. if (newIndex >= maxNewIndexSoFar)
  7692. maxNewIndexSoFar = newIndex
  7693. else
  7694. moved = true
  7695. patch(
  7696. prevChild,
  7697. c2[newIndex],
  7698. container,
  7699. null,
  7700. parentComponent,
  7701. parentSuspense,
  7702. namespace,
  7703. slotScopeIds,
  7704. optimized,
  7705. )
  7706. patched++
  7707. }
  7708. }
  7709. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR
  7710. j = increasingNewIndexSequence.length - 1
  7711. for (i = toBePatched - 1; i >= 0; i--) {
  7712. const nextIndex = s2 + i
  7713. const nextChild = c2[nextIndex]
  7714. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor
  7715. if (newIndexToOldIndexMap[i] === 0) {
  7716. patch(
  7717. null,
  7718. nextChild,
  7719. container,
  7720. anchor,
  7721. parentComponent,
  7722. parentSuspense,
  7723. namespace,
  7724. slotScopeIds,
  7725. optimized,
  7726. )
  7727. }
  7728. else if (moved) {
  7729. if (j < 0 || i !== increasingNewIndexSequence[j])
  7730. move(nextChild, container, anchor, 2)
  7731. else
  7732. j--
  7733. }
  7734. }
  7735. }
  7736. }
  7737. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7738. const { el, type, transition, children, shapeFlag } = vnode
  7739. if (shapeFlag & 6) {
  7740. move(vnode.component.subTree, container, anchor, moveType)
  7741. return
  7742. }
  7743. if (shapeFlag & 128) {
  7744. vnode.suspense.move(container, anchor, moveType)
  7745. return
  7746. }
  7747. if (shapeFlag & 64) {
  7748. type.move(vnode, container, anchor, internals)
  7749. return
  7750. }
  7751. if (type === Fragment) {
  7752. hostInsert(el, container, anchor)
  7753. for (let i = 0; i < children.length; i++)
  7754. move(children[i], container, anchor, moveType)
  7755. hostInsert(vnode.anchor, container, anchor)
  7756. return
  7757. }
  7758. if (type === Static) {
  7759. moveStaticNode(vnode, container, anchor)
  7760. return
  7761. }
  7762. const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition
  7763. if (needTransition2) {
  7764. if (moveType === 0) {
  7765. transition.beforeEnter(el)
  7766. hostInsert(el, container, anchor)
  7767. queuePostRenderEffect(() => transition.enter(el), parentSuspense)
  7768. }
  7769. else {
  7770. const { leave, delayLeave, afterLeave } = transition
  7771. const remove2 = () => hostInsert(el, container, anchor)
  7772. const performLeave = () => {
  7773. leave(el, () => {
  7774. remove2()
  7775. afterLeave && afterLeave()
  7776. })
  7777. }
  7778. if (delayLeave)
  7779. delayLeave(el, remove2, performLeave)
  7780. else
  7781. performLeave()
  7782. }
  7783. }
  7784. else {
  7785. hostInsert(el, container, anchor)
  7786. }
  7787. }
  7788. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7789. const {
  7790. type,
  7791. props,
  7792. ref,
  7793. children,
  7794. dynamicChildren,
  7795. shapeFlag,
  7796. patchFlag,
  7797. dirs,
  7798. } = vnode
  7799. if (ref != null)
  7800. setRef(ref, null, parentSuspense, vnode, true)
  7801. if (shapeFlag & 256) {
  7802. parentComponent.ctx.deactivate(vnode)
  7803. return
  7804. }
  7805. const shouldInvokeDirs = shapeFlag & 1 && dirs
  7806. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode)
  7807. let vnodeHook
  7808. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount))
  7809. invokeVNodeHook(vnodeHook, parentComponent, vnode)
  7810. if (shapeFlag & 6) {
  7811. unmountComponent(vnode.component, parentSuspense, doRemove)
  7812. }
  7813. else {
  7814. if (shapeFlag & 128) {
  7815. vnode.suspense.unmount(parentSuspense, doRemove)
  7816. return
  7817. }
  7818. if (shouldInvokeDirs)
  7819. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount')
  7820. if (shapeFlag & 64) {
  7821. vnode.type.remove(
  7822. vnode,
  7823. parentComponent,
  7824. parentSuspense,
  7825. optimized,
  7826. internals,
  7827. doRemove,
  7828. )
  7829. }
  7830. else if (dynamicChildren // #1153: fast path should not be taken for non-stable (v-for) fragments
  7831. && (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  7832. unmountChildren(
  7833. dynamicChildren,
  7834. parentComponent,
  7835. parentSuspense,
  7836. false,
  7837. true,
  7838. )
  7839. }
  7840. else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  7841. unmountChildren(children, parentComponent, parentSuspense)
  7842. }
  7843. if (doRemove)
  7844. remove(vnode)
  7845. }
  7846. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  7847. queuePostRenderEffect(() => {
  7848. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
  7849. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, 'unmounted')
  7850. }, parentSuspense)
  7851. }
  7852. }
  7853. const remove = (vnode) => {
  7854. const { type, el, anchor, transition } = vnode
  7855. if (type === Fragment) {
  7856. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  7857. vnode.children.forEach((child) => {
  7858. if (child.type === Comment)
  7859. hostRemove(child.el)
  7860. else
  7861. remove(child)
  7862. })
  7863. }
  7864. else {
  7865. removeFragment(el, anchor)
  7866. }
  7867. return
  7868. }
  7869. if (type === Static) {
  7870. removeStaticNode(vnode)
  7871. return
  7872. }
  7873. const performRemove = () => {
  7874. hostRemove(el)
  7875. if (transition && !transition.persisted && transition.afterLeave)
  7876. transition.afterLeave()
  7877. }
  7878. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  7879. const { leave, delayLeave } = transition
  7880. const performLeave = () => leave(el, performRemove)
  7881. if (delayLeave)
  7882. delayLeave(vnode.el, performRemove, performLeave)
  7883. else
  7884. performLeave()
  7885. }
  7886. else {
  7887. performRemove()
  7888. }
  7889. }
  7890. const removeFragment = (cur, end) => {
  7891. let next
  7892. while (cur !== end) {
  7893. next = hostNextSibling(cur)
  7894. hostRemove(cur)
  7895. cur = next
  7896. }
  7897. hostRemove(end)
  7898. }
  7899. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7900. if (instance.type.__hmrId)
  7901. unregisterHMR(instance)
  7902. const { bum, scope, update, subTree, um } = instance
  7903. if (bum)
  7904. invokeArrayFns(bum)
  7905. scope.stop()
  7906. if (update) {
  7907. update.active = false
  7908. unmount(subTree, instance, parentSuspense, doRemove)
  7909. }
  7910. if (um)
  7911. queuePostRenderEffect(um, parentSuspense)
  7912. queuePostRenderEffect(() => {
  7913. instance.isUnmounted = true
  7914. }, parentSuspense)
  7915. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  7916. parentSuspense.deps--
  7917. if (parentSuspense.deps === 0)
  7918. parentSuspense.resolve()
  7919. }
  7920. {
  7921. devtoolsComponentRemoved(instance)
  7922. }
  7923. }
  7924. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7925. for (let i = start; i < children.length; i++)
  7926. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized)
  7927. }
  7928. const getNextHostNode = (vnode) => {
  7929. if (vnode.shapeFlag & 6)
  7930. return getNextHostNode(vnode.component.subTree)
  7931. if (vnode.shapeFlag & 128)
  7932. return vnode.suspense.next()
  7933. return hostNextSibling(vnode.anchor || vnode.el)
  7934. }
  7935. let isFlushing = false
  7936. const render = (vnode, container, namespace) => {
  7937. if (vnode == null) {
  7938. if (container._vnode)
  7939. unmount(container._vnode, null, null, true)
  7940. }
  7941. else {
  7942. patch(
  7943. container._vnode || null,
  7944. vnode,
  7945. container,
  7946. null,
  7947. null,
  7948. null,
  7949. namespace,
  7950. )
  7951. }
  7952. if (!isFlushing) {
  7953. isFlushing = true
  7954. flushPreFlushCbs()
  7955. flushPostFlushCbs()
  7956. isFlushing = false
  7957. }
  7958. container._vnode = vnode
  7959. }
  7960. const internals = {
  7961. p: patch,
  7962. um: unmount,
  7963. m: move,
  7964. r: remove,
  7965. mt: mountComponent,
  7966. mc: mountChildren,
  7967. pc: patchChildren,
  7968. pbc: patchBlockChildren,
  7969. n: getNextHostNode,
  7970. o: options,
  7971. }
  7972. let hydrate
  7973. let hydrateNode
  7974. if (createHydrationFns) {
  7975. [hydrate, hydrateNode] = createHydrationFns(
  7976. internals,
  7977. )
  7978. }
  7979. return {
  7980. render,
  7981. hydrate,
  7982. createApp: createAppAPI(render, hydrate),
  7983. }
  7984. }
  7985. function resolveChildrenNamespace({ type, props }, currentNamespace) {
  7986. return currentNamespace === 'svg' && type === 'foreignObject' || currentNamespace === 'mathml' && type === 'annotation-xml' && props && props.encoding && props.encoding.includes('html') ? void 0 : currentNamespace
  7987. }
  7988. function toggleRecurse({ effect, update }, allowed) {
  7989. effect.allowRecurse = update.allowRecurse = allowed
  7990. }
  7991. function needTransition(parentSuspense, transition) {
  7992. return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted
  7993. }
  7994. function traverseStaticChildren(n1, n2, shallow = false) {
  7995. const ch1 = n1.children
  7996. const ch2 = n2.children
  7997. if (isArray(ch1) && isArray(ch2)) {
  7998. for (let i = 0; i < ch1.length; i++) {
  7999. const c1 = ch1[i]
  8000. let c2 = ch2[i]
  8001. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  8002. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  8003. c2 = ch2[i] = cloneIfMounted(ch2[i])
  8004. c2.el = c1.el
  8005. }
  8006. if (!shallow)
  8007. traverseStaticChildren(c1, c2)
  8008. }
  8009. if (c2.type === Text)
  8010. c2.el = c1.el
  8011. if (c2.type === Comment && !c2.el)
  8012. c2.el = c1.el
  8013. }
  8014. }
  8015. }
  8016. function getSequence(arr) {
  8017. const p = arr.slice()
  8018. const result = [0]
  8019. let i, j, u, v, c
  8020. const len = arr.length
  8021. for (i = 0; i < len; i++) {
  8022. const arrI = arr[i]
  8023. if (arrI !== 0) {
  8024. j = result[result.length - 1]
  8025. if (arr[j] < arrI) {
  8026. p[i] = j
  8027. result.push(i)
  8028. continue
  8029. }
  8030. u = 0
  8031. v = result.length - 1
  8032. while (u < v) {
  8033. c = u + v >> 1
  8034. if (arr[result[c]] < arrI)
  8035. u = c + 1
  8036. else
  8037. v = c
  8038. }
  8039. if (arrI < arr[result[u]]) {
  8040. if (u > 0)
  8041. p[i] = result[u - 1]
  8042. result[u] = i
  8043. }
  8044. }
  8045. }
  8046. u = result.length
  8047. v = result[u - 1]
  8048. while (u-- > 0) {
  8049. result[u] = v
  8050. v = p[v]
  8051. }
  8052. return result
  8053. }
  8054. function locateNonHydratedAsyncRoot(instance) {
  8055. const subComponent = instance.subTree.component
  8056. if (subComponent) {
  8057. if (subComponent.asyncDep && !subComponent.asyncResolved)
  8058. return subComponent
  8059. else
  8060. return locateNonHydratedAsyncRoot(subComponent)
  8061. }
  8062. }
  8063. const isTeleport = type => type.__isTeleport
  8064. const isTeleportDisabled = props => props && (props.disabled || props.disabled === '')
  8065. const isTargetSVG = target => typeof SVGElement !== 'undefined' && target instanceof SVGElement
  8066. const isTargetMathML = target => typeof MathMLElement === 'function' && target instanceof MathMLElement
  8067. function resolveTarget(props, select) {
  8068. const targetSelector = props && props.to
  8069. if (isString(targetSelector)) {
  8070. if (!select) {
  8071. warn$1(
  8072. `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`,
  8073. )
  8074. return null
  8075. }
  8076. else {
  8077. const target = select(targetSelector)
  8078. if (!target) {
  8079. warn$1(
  8080. `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`,
  8081. )
  8082. }
  8083. return target
  8084. }
  8085. }
  8086. else {
  8087. if (!targetSelector && !isTeleportDisabled(props))
  8088. warn$1(`Invalid Teleport target: ${targetSelector}`)
  8089. return targetSelector
  8090. }
  8091. }
  8092. const TeleportImpl = {
  8093. name: 'Teleport',
  8094. __isTeleport: true,
  8095. process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
  8096. const {
  8097. mc: mountChildren,
  8098. pc: patchChildren,
  8099. pbc: patchBlockChildren,
  8100. o: { insert, querySelector, createText, createComment },
  8101. } = internals
  8102. const disabled = isTeleportDisabled(n2.props)
  8103. let { shapeFlag, children, dynamicChildren } = n2
  8104. if (isHmrUpdating) {
  8105. optimized = false
  8106. dynamicChildren = null
  8107. }
  8108. if (n1 == null) {
  8109. const placeholder = n2.el = createComment('teleport start')
  8110. const mainAnchor = n2.anchor = createComment('teleport end')
  8111. insert(placeholder, container, anchor)
  8112. insert(mainAnchor, container, anchor)
  8113. const target = n2.target = resolveTarget(n2.props, querySelector)
  8114. const targetAnchor = n2.targetAnchor = createText('')
  8115. if (target) {
  8116. insert(targetAnchor, target)
  8117. if (namespace === 'svg' || isTargetSVG(target))
  8118. namespace = 'svg'
  8119. else if (namespace === 'mathml' || isTargetMathML(target))
  8120. namespace = 'mathml'
  8121. }
  8122. else if (!disabled) {
  8123. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`)
  8124. }
  8125. const mount = (container2, anchor2) => {
  8126. if (shapeFlag & 16) {
  8127. mountChildren(
  8128. children,
  8129. container2,
  8130. anchor2,
  8131. parentComponent,
  8132. parentSuspense,
  8133. namespace,
  8134. slotScopeIds,
  8135. optimized,
  8136. )
  8137. }
  8138. }
  8139. if (disabled)
  8140. mount(container, mainAnchor)
  8141. else if (target)
  8142. mount(target, targetAnchor)
  8143. }
  8144. else {
  8145. n2.el = n1.el
  8146. const mainAnchor = n2.anchor = n1.anchor
  8147. const target = n2.target = n1.target
  8148. const targetAnchor = n2.targetAnchor = n1.targetAnchor
  8149. const wasDisabled = isTeleportDisabled(n1.props)
  8150. const currentContainer = wasDisabled ? container : target
  8151. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor
  8152. if (namespace === 'svg' || isTargetSVG(target))
  8153. namespace = 'svg'
  8154. else if (namespace === 'mathml' || isTargetMathML(target))
  8155. namespace = 'mathml'
  8156. if (dynamicChildren) {
  8157. patchBlockChildren(
  8158. n1.dynamicChildren,
  8159. dynamicChildren,
  8160. currentContainer,
  8161. parentComponent,
  8162. parentSuspense,
  8163. namespace,
  8164. slotScopeIds,
  8165. )
  8166. traverseStaticChildren(n1, n2, true)
  8167. }
  8168. else if (!optimized) {
  8169. patchChildren(
  8170. n1,
  8171. n2,
  8172. currentContainer,
  8173. currentAnchor,
  8174. parentComponent,
  8175. parentSuspense,
  8176. namespace,
  8177. slotScopeIds,
  8178. false,
  8179. )
  8180. }
  8181. if (disabled) {
  8182. if (!wasDisabled) {
  8183. moveTeleport(
  8184. n2,
  8185. container,
  8186. mainAnchor,
  8187. internals,
  8188. 1,
  8189. )
  8190. }
  8191. else {
  8192. if (n2.props && n1.props && n2.props.to !== n1.props.to)
  8193. n2.props.to = n1.props.to
  8194. }
  8195. }
  8196. else {
  8197. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  8198. const nextTarget = n2.target = resolveTarget(
  8199. n2.props,
  8200. querySelector,
  8201. )
  8202. if (nextTarget) {
  8203. moveTeleport(
  8204. n2,
  8205. nextTarget,
  8206. null,
  8207. internals,
  8208. 0,
  8209. )
  8210. }
  8211. else {
  8212. warn$1(
  8213. 'Invalid Teleport target on update:',
  8214. target,
  8215. `(${typeof target})`,
  8216. )
  8217. }
  8218. }
  8219. else if (wasDisabled) {
  8220. moveTeleport(
  8221. n2,
  8222. target,
  8223. targetAnchor,
  8224. internals,
  8225. 1,
  8226. )
  8227. }
  8228. }
  8229. }
  8230. updateCssVars(n2)
  8231. },
  8232. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  8233. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode
  8234. if (target)
  8235. hostRemove(targetAnchor)
  8236. doRemove && hostRemove(anchor)
  8237. if (shapeFlag & 16) {
  8238. const shouldRemove = doRemove || !isTeleportDisabled(props)
  8239. for (let i = 0; i < children.length; i++) {
  8240. const child = children[i]
  8241. unmount(
  8242. child,
  8243. parentComponent,
  8244. parentSuspense,
  8245. shouldRemove,
  8246. !!child.dynamicChildren,
  8247. )
  8248. }
  8249. }
  8250. },
  8251. move: moveTeleport,
  8252. hydrate: hydrateTeleport,
  8253. }
  8254. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
  8255. if (moveType === 0)
  8256. insert(vnode.targetAnchor, container, parentAnchor)
  8257. const { el, anchor, shapeFlag, children, props } = vnode
  8258. const isReorder = moveType === 2
  8259. if (isReorder)
  8260. insert(el, container, parentAnchor)
  8261. if (!isReorder || isTeleportDisabled(props)) {
  8262. if (shapeFlag & 16) {
  8263. for (let i = 0; i < children.length; i++) {
  8264. move(
  8265. children[i],
  8266. container,
  8267. parentAnchor,
  8268. 2,
  8269. )
  8270. }
  8271. }
  8272. }
  8273. if (isReorder)
  8274. insert(anchor, container, parentAnchor)
  8275. }
  8276. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
  8277. o: { nextSibling, parentNode, querySelector },
  8278. }, hydrateChildren) {
  8279. const target = vnode.target = resolveTarget(
  8280. vnode.props,
  8281. querySelector,
  8282. )
  8283. if (target) {
  8284. const targetNode = target._lpa || target.firstChild
  8285. if (vnode.shapeFlag & 16) {
  8286. if (isTeleportDisabled(vnode.props)) {
  8287. vnode.anchor = hydrateChildren(
  8288. nextSibling(node),
  8289. vnode,
  8290. parentNode(node),
  8291. parentComponent,
  8292. parentSuspense,
  8293. slotScopeIds,
  8294. optimized,
  8295. )
  8296. vnode.targetAnchor = targetNode
  8297. }
  8298. else {
  8299. vnode.anchor = nextSibling(node)
  8300. let targetAnchor = targetNode
  8301. while (targetAnchor) {
  8302. targetAnchor = nextSibling(targetAnchor)
  8303. if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === 'teleport anchor') {
  8304. vnode.targetAnchor = targetAnchor
  8305. target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor)
  8306. break
  8307. }
  8308. }
  8309. hydrateChildren(
  8310. targetNode,
  8311. vnode,
  8312. target,
  8313. parentComponent,
  8314. parentSuspense,
  8315. slotScopeIds,
  8316. optimized,
  8317. )
  8318. }
  8319. }
  8320. updateCssVars(vnode)
  8321. }
  8322. return vnode.anchor && nextSibling(vnode.anchor)
  8323. }
  8324. const Teleport = TeleportImpl
  8325. function updateCssVars(vnode) {
  8326. const ctx = vnode.ctx
  8327. if (ctx && ctx.ut) {
  8328. let node = vnode.children[0].el
  8329. while (node && node !== vnode.targetAnchor) {
  8330. if (node.nodeType === 1)
  8331. node.setAttribute('data-v-owner', ctx.uid)
  8332. node = node.nextSibling
  8333. }
  8334. ctx.ut()
  8335. }
  8336. }
  8337. const Fragment = Symbol.for('v-fgt')
  8338. const Text = Symbol.for('v-txt')
  8339. const Comment = Symbol.for('v-cmt')
  8340. const Static = Symbol.for('v-stc')
  8341. const blockStack = []
  8342. let currentBlock = null
  8343. function openBlock(disableTracking = false) {
  8344. blockStack.push(currentBlock = disableTracking ? null : [])
  8345. }
  8346. function closeBlock() {
  8347. blockStack.pop()
  8348. currentBlock = blockStack[blockStack.length - 1] || null
  8349. }
  8350. let isBlockTreeEnabled = 1
  8351. function setBlockTracking(value) {
  8352. isBlockTreeEnabled += value
  8353. }
  8354. function setupBlock(vnode) {
  8355. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null
  8356. closeBlock()
  8357. if (isBlockTreeEnabled > 0 && currentBlock)
  8358. currentBlock.push(vnode)
  8359. return vnode
  8360. }
  8361. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8362. return setupBlock(
  8363. createBaseVNode(
  8364. type,
  8365. props,
  8366. children,
  8367. patchFlag,
  8368. dynamicProps,
  8369. shapeFlag,
  8370. true,
  8371. ),
  8372. )
  8373. }
  8374. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8375. return setupBlock(
  8376. createVNode(
  8377. type,
  8378. props,
  8379. children,
  8380. patchFlag,
  8381. dynamicProps,
  8382. true,
  8383. ),
  8384. )
  8385. }
  8386. function isVNode(value) {
  8387. return value ? value.__v_isVNode === true : false
  8388. }
  8389. function isSameVNodeType(n1, n2) {
  8390. if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
  8391. n1.shapeFlag &= ~256
  8392. n2.shapeFlag &= ~512
  8393. return false
  8394. }
  8395. return n1.type === n2.type && n1.key === n2.key
  8396. }
  8397. let vnodeArgsTransformer
  8398. function transformVNodeArgs(transformer) {
  8399. vnodeArgsTransformer = transformer
  8400. }
  8401. function createVNodeWithArgsTransform(...args) {
  8402. return _createVNode(
  8403. ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args,
  8404. )
  8405. }
  8406. const normalizeKey = ({ key }) => key != null ? key : null
  8407. function normalizeRef({
  8408. ref,
  8409. ref_key,
  8410. ref_for,
  8411. }) {
  8412. if (typeof ref === 'number')
  8413. ref = `${ref}`
  8414. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null
  8415. }
  8416. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  8417. const vnode = {
  8418. __v_isVNode: true,
  8419. __v_skip: true,
  8420. type,
  8421. props,
  8422. key: props && normalizeKey(props),
  8423. ref: props && normalizeRef(props),
  8424. scopeId: currentScopeId,
  8425. slotScopeIds: null,
  8426. children,
  8427. component: null,
  8428. suspense: null,
  8429. ssContent: null,
  8430. ssFallback: null,
  8431. dirs: null,
  8432. transition: null,
  8433. el: null,
  8434. anchor: null,
  8435. target: null,
  8436. targetAnchor: null,
  8437. staticCount: 0,
  8438. shapeFlag,
  8439. patchFlag,
  8440. dynamicProps,
  8441. dynamicChildren: null,
  8442. appContext: null,
  8443. ctx: currentRenderingInstance,
  8444. }
  8445. if (needFullChildrenNormalization) {
  8446. normalizeChildren(vnode, children)
  8447. if (shapeFlag & 128)
  8448. type.normalize(vnode)
  8449. }
  8450. else if (children) {
  8451. vnode.shapeFlag |= isString(children) ? 8 : 16
  8452. }
  8453. if (vnode.key !== vnode.key)
  8454. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
  8455. if (isBlockTreeEnabled > 0 // avoid a block node from tracking itself
  8456. && !isBlockNode // has current parent block
  8457. && currentBlock // presence of a patch flag indicates this node needs patching on updates.
  8458. // component nodes also should always be patched, because even if the
  8459. // component doesn't need to update, it needs to persist the instance on to
  8460. // the next vnode so that it can be properly unmounted later.
  8461. && (vnode.patchFlag > 0 || shapeFlag & 6) // the EVENTS flag is only for hydration and if it is the only flag, the
  8462. // vnode should not be considered dynamic due to handler caching.
  8463. && vnode.patchFlag !== 32)
  8464. currentBlock.push(vnode)
  8465. return vnode
  8466. }
  8467. const createVNode = createVNodeWithArgsTransform
  8468. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8469. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8470. if (!type)
  8471. warn$1(`Invalid vnode type when creating vnode: ${type}.`)
  8472. type = Comment
  8473. }
  8474. if (isVNode(type)) {
  8475. const cloned = cloneVNode(
  8476. type,
  8477. props,
  8478. true,
  8479. /* mergeRef: true */
  8480. )
  8481. if (children)
  8482. normalizeChildren(cloned, children)
  8483. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8484. if (cloned.shapeFlag & 6)
  8485. currentBlock[currentBlock.indexOf(type)] = cloned
  8486. else
  8487. currentBlock.push(cloned)
  8488. }
  8489. cloned.patchFlag |= -2
  8490. return cloned
  8491. }
  8492. if (isClassComponent(type))
  8493. type = type.__vccOpts
  8494. if (props) {
  8495. props = guardReactiveProps(props)
  8496. let { class: klass, style } = props
  8497. if (klass && !isString(klass))
  8498. props.class = normalizeClass(klass)
  8499. if (isObject(style)) {
  8500. if (isProxy(style) && !isArray(style))
  8501. style = extend({}, style)
  8502. props.style = normalizeStyle(style)
  8503. }
  8504. }
  8505. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0
  8506. if (shapeFlag & 4 && isProxy(type)) {
  8507. type = toRaw(type)
  8508. warn$1(
  8509. `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
  8510. `
  8511. Component that was made reactive: `,
  8512. type,
  8513. )
  8514. }
  8515. return createBaseVNode(
  8516. type,
  8517. props,
  8518. children,
  8519. patchFlag,
  8520. dynamicProps,
  8521. shapeFlag,
  8522. isBlockNode,
  8523. true,
  8524. )
  8525. }
  8526. function guardReactiveProps(props) {
  8527. if (!props)
  8528. return null
  8529. return isProxy(props) || isInternalObject(props) ? extend({}, props) : props
  8530. }
  8531. function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
  8532. const { props, ref, patchFlag, children, transition } = vnode
  8533. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props
  8534. const cloned = {
  8535. __v_isVNode: true,
  8536. __v_skip: true,
  8537. type: vnode.type,
  8538. props: mergedProps,
  8539. key: mergedProps && normalizeKey(mergedProps),
  8540. ref: extraProps && extraProps.ref ? (
  8541. // #2078 in the case of <component :is="vnode" ref="extra"/>
  8542. // if the vnode itself already has a ref, cloneVNode will need to merge
  8543. // the refs so the single vnode can be set on multiple refs
  8544. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  8545. ) : ref,
  8546. scopeId: vnode.scopeId,
  8547. slotScopeIds: vnode.slotScopeIds,
  8548. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  8549. target: vnode.target,
  8550. targetAnchor: vnode.targetAnchor,
  8551. staticCount: vnode.staticCount,
  8552. shapeFlag: vnode.shapeFlag,
  8553. // if the vnode is cloned with extra props, we can no longer assume its
  8554. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8555. // note: preserve flag for fragments since they use the flag for children
  8556. // fast paths only.
  8557. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  8558. dynamicProps: vnode.dynamicProps,
  8559. dynamicChildren: vnode.dynamicChildren,
  8560. appContext: vnode.appContext,
  8561. dirs: vnode.dirs,
  8562. transition,
  8563. // These should technically only be non-null on mounted VNodes. However,
  8564. // they *should* be copied for kept-alive vnodes. So we just always copy
  8565. // them since them being non-null during a mount doesn't affect the logic as
  8566. // they will simply be overwritten.
  8567. component: vnode.component,
  8568. suspense: vnode.suspense,
  8569. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8570. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8571. el: vnode.el,
  8572. anchor: vnode.anchor,
  8573. ctx: vnode.ctx,
  8574. ce: vnode.ce,
  8575. }
  8576. if (transition && cloneTransition)
  8577. cloned.transition = transition.clone(cloned)
  8578. return cloned
  8579. }
  8580. function deepCloneVNode(vnode) {
  8581. const cloned = cloneVNode(vnode)
  8582. if (isArray(vnode.children))
  8583. cloned.children = vnode.children.map(deepCloneVNode)
  8584. return cloned
  8585. }
  8586. function createTextVNode(text = ' ', flag = 0) {
  8587. return createVNode(Text, null, text, flag)
  8588. }
  8589. function createStaticVNode(content, numberOfNodes) {
  8590. const vnode = createVNode(Static, null, content)
  8591. vnode.staticCount = numberOfNodes
  8592. return vnode
  8593. }
  8594. function createCommentVNode(text = '', asBlock = false) {
  8595. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text)
  8596. }
  8597. function normalizeVNode(child) {
  8598. if (child == null || typeof child === 'boolean') {
  8599. return createVNode(Comment)
  8600. }
  8601. else if (isArray(child)) {
  8602. return createVNode(
  8603. Fragment,
  8604. null,
  8605. // #3666, avoid reference pollution when reusing vnode
  8606. child.slice(),
  8607. )
  8608. }
  8609. else if (typeof child === 'object') {
  8610. return cloneIfMounted(child)
  8611. }
  8612. else {
  8613. return createVNode(Text, null, String(child))
  8614. }
  8615. }
  8616. function cloneIfMounted(child) {
  8617. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child)
  8618. }
  8619. function normalizeChildren(vnode, children) {
  8620. let type = 0
  8621. const { shapeFlag } = vnode
  8622. if (children == null) {
  8623. children = null
  8624. }
  8625. else if (isArray(children)) {
  8626. type = 16
  8627. }
  8628. else if (typeof children === 'object') {
  8629. if (shapeFlag & (1 | 64)) {
  8630. const slot = children.default
  8631. if (slot) {
  8632. slot._c && (slot._d = false)
  8633. normalizeChildren(vnode, slot())
  8634. slot._c && (slot._d = true)
  8635. }
  8636. return
  8637. }
  8638. else {
  8639. type = 32
  8640. const slotFlag = children._
  8641. if (!slotFlag && !isInternalObject(children)) {
  8642. children._ctx = currentRenderingInstance
  8643. }
  8644. else if (slotFlag === 3 && currentRenderingInstance) {
  8645. if (currentRenderingInstance.slots._ === 1) {
  8646. children._ = 1
  8647. }
  8648. else {
  8649. children._ = 2
  8650. vnode.patchFlag |= 1024
  8651. }
  8652. }
  8653. }
  8654. }
  8655. else if (isFunction(children)) {
  8656. children = { default: children, _ctx: currentRenderingInstance }
  8657. type = 32
  8658. }
  8659. else {
  8660. children = String(children)
  8661. if (shapeFlag & 64) {
  8662. type = 16
  8663. children = [createTextVNode(children)]
  8664. }
  8665. else {
  8666. type = 8
  8667. }
  8668. }
  8669. vnode.children = children
  8670. vnode.shapeFlag |= type
  8671. }
  8672. function mergeProps(...args) {
  8673. const ret = {}
  8674. for (let i = 0; i < args.length; i++) {
  8675. const toMerge = args[i]
  8676. for (const key in toMerge) {
  8677. if (key === 'class') {
  8678. if (ret.class !== toMerge.class)
  8679. ret.class = normalizeClass([ret.class, toMerge.class])
  8680. }
  8681. else if (key === 'style') {
  8682. ret.style = normalizeStyle([ret.style, toMerge.style])
  8683. }
  8684. else if (isOn(key)) {
  8685. const existing = ret[key]
  8686. const incoming = toMerge[key]
  8687. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming)))
  8688. ret[key] = existing ? [].concat(existing, incoming) : incoming
  8689. }
  8690. else if (key !== '') {
  8691. ret[key] = toMerge[key]
  8692. }
  8693. }
  8694. }
  8695. return ret
  8696. }
  8697. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8698. callWithAsyncErrorHandling(hook, instance, 7, [
  8699. vnode,
  8700. prevVNode,
  8701. ])
  8702. }
  8703. const emptyAppContext = createAppContext()
  8704. let uid = 0
  8705. function createComponentInstance(vnode, parent, suspense) {
  8706. const type = vnode.type
  8707. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext
  8708. const instance = {
  8709. uid: uid++,
  8710. vnode,
  8711. type,
  8712. parent,
  8713. appContext,
  8714. root: null,
  8715. // to be immediately set
  8716. next: null,
  8717. subTree: null,
  8718. // will be set synchronously right after creation
  8719. effect: null,
  8720. update: null,
  8721. // will be set synchronously right after creation
  8722. scope: new EffectScope(
  8723. true,
  8724. /* detached */
  8725. ),
  8726. render: null,
  8727. proxy: null,
  8728. exposed: null,
  8729. exposeProxy: null,
  8730. withProxy: null,
  8731. provides: parent ? parent.provides : Object.create(appContext.provides),
  8732. accessCache: null,
  8733. renderCache: [],
  8734. // local resolved assets
  8735. components: null,
  8736. directives: null,
  8737. // resolved props and emits options
  8738. propsOptions: normalizePropsOptions(type, appContext),
  8739. emitsOptions: normalizeEmitsOptions(type, appContext),
  8740. // emit
  8741. emit: null,
  8742. // to be set immediately
  8743. emitted: null,
  8744. // props default value
  8745. propsDefaults: EMPTY_OBJ,
  8746. // inheritAttrs
  8747. inheritAttrs: type.inheritAttrs,
  8748. // state
  8749. ctx: EMPTY_OBJ,
  8750. data: EMPTY_OBJ,
  8751. props: EMPTY_OBJ,
  8752. attrs: EMPTY_OBJ,
  8753. slots: EMPTY_OBJ,
  8754. refs: EMPTY_OBJ,
  8755. setupState: EMPTY_OBJ,
  8756. setupContext: null,
  8757. attrsProxy: null,
  8758. slotsProxy: null,
  8759. // suspense related
  8760. suspense,
  8761. suspenseId: suspense ? suspense.pendingId : 0,
  8762. asyncDep: null,
  8763. asyncResolved: false,
  8764. // lifecycle hooks
  8765. // not using enums here because it results in computed properties
  8766. isMounted: false,
  8767. isUnmounted: false,
  8768. isDeactivated: false,
  8769. bc: null,
  8770. c: null,
  8771. bm: null,
  8772. m: null,
  8773. bu: null,
  8774. u: null,
  8775. um: null,
  8776. bum: null,
  8777. da: null,
  8778. a: null,
  8779. rtg: null,
  8780. rtc: null,
  8781. ec: null,
  8782. sp: null,
  8783. }
  8784. {
  8785. instance.ctx = createDevRenderContext(instance)
  8786. }
  8787. instance.root = parent ? parent.root : instance
  8788. instance.emit = emit.bind(null, instance)
  8789. if (vnode.ce)
  8790. vnode.ce(instance)
  8791. return instance
  8792. }
  8793. let currentInstance = null
  8794. const getCurrentInstance = () => currentInstance || currentRenderingInstance
  8795. let internalSetCurrentInstance
  8796. let setInSSRSetupState
  8797. {
  8798. internalSetCurrentInstance = (i) => {
  8799. currentInstance = i
  8800. }
  8801. setInSSRSetupState = (v) => {
  8802. isInSSRComponentSetup = v
  8803. }
  8804. }
  8805. function setCurrentInstance(instance) {
  8806. const prev = currentInstance
  8807. internalSetCurrentInstance(instance)
  8808. instance.scope.on()
  8809. return () => {
  8810. instance.scope.off()
  8811. internalSetCurrentInstance(prev)
  8812. }
  8813. }
  8814. function unsetCurrentInstance() {
  8815. currentInstance && currentInstance.scope.off()
  8816. internalSetCurrentInstance(null)
  8817. }
  8818. const isBuiltInTag = /* @__PURE__ */ makeMap('slot,component')
  8819. function validateComponentName(name, { isNativeTag }) {
  8820. if (isBuiltInTag(name) || isNativeTag(name)) {
  8821. warn$1(
  8822. `Do not use built-in or reserved HTML elements as component id: ${name}`,
  8823. )
  8824. }
  8825. }
  8826. function isStatefulComponent(instance) {
  8827. return instance.vnode.shapeFlag & 4
  8828. }
  8829. let isInSSRComponentSetup = false
  8830. function setupComponent(instance, isSSR = false) {
  8831. isSSR && setInSSRSetupState(isSSR)
  8832. const { props, children } = instance.vnode
  8833. const isStateful = isStatefulComponent(instance)
  8834. initProps(instance, props, isStateful, isSSR)
  8835. initSlots(instance, children)
  8836. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0
  8837. isSSR && setInSSRSetupState(false)
  8838. return setupResult
  8839. }
  8840. function setupStatefulComponent(instance, isSSR) {
  8841. let _a
  8842. const Component = instance.type
  8843. {
  8844. if (Component.name)
  8845. validateComponentName(Component.name, instance.appContext.config)
  8846. if (Component.components) {
  8847. const names = Object.keys(Component.components)
  8848. for (let i = 0; i < names.length; i++)
  8849. validateComponentName(names[i], instance.appContext.config)
  8850. }
  8851. if (Component.directives) {
  8852. const names = Object.keys(Component.directives)
  8853. for (let i = 0; i < names.length; i++)
  8854. validateDirectiveName(names[i])
  8855. }
  8856. if (Component.compilerOptions && isRuntimeOnly()) {
  8857. warn$1(
  8858. `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`,
  8859. )
  8860. }
  8861. }
  8862. instance.accessCache = /* @__PURE__ */ Object.create(null)
  8863. instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers)
  8864. {
  8865. exposePropsOnRenderContext(instance)
  8866. }
  8867. const { setup } = Component
  8868. if (setup) {
  8869. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null
  8870. const reset = setCurrentInstance(instance)
  8871. pauseTracking()
  8872. const setupResult = callWithErrorHandling(
  8873. setup,
  8874. instance,
  8875. 0,
  8876. [
  8877. shallowReadonly(instance.props),
  8878. setupContext,
  8879. ],
  8880. )
  8881. resetTracking()
  8882. reset()
  8883. if (isPromise(setupResult)) {
  8884. setupResult.then(unsetCurrentInstance, unsetCurrentInstance)
  8885. if (isSSR) {
  8886. return setupResult.then((resolvedResult) => {
  8887. handleSetupResult(instance, resolvedResult, isSSR)
  8888. }).catch((e) => {
  8889. handleError(e, instance, 0)
  8890. })
  8891. }
  8892. else {
  8893. instance.asyncDep = setupResult
  8894. if (!instance.suspense) {
  8895. const name = (_a = Component.name) != null ? _a : 'Anonymous'
  8896. warn$1(
  8897. `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`,
  8898. )
  8899. }
  8900. }
  8901. }
  8902. else {
  8903. handleSetupResult(instance, setupResult, isSSR)
  8904. }
  8905. }
  8906. else {
  8907. finishComponentSetup(instance, isSSR)
  8908. }
  8909. }
  8910. function handleSetupResult(instance, setupResult, isSSR) {
  8911. if (isFunction(setupResult)) {
  8912. {
  8913. instance.render = setupResult
  8914. }
  8915. }
  8916. else if (isObject(setupResult)) {
  8917. if (isVNode(setupResult)) {
  8918. warn$1(
  8919. `setup() should not return VNodes directly - return a render function instead.`,
  8920. )
  8921. }
  8922. {
  8923. instance.devtoolsRawSetupState = setupResult
  8924. }
  8925. instance.setupState = proxyRefs(setupResult)
  8926. {
  8927. exposeSetupStateOnRenderContext(instance)
  8928. }
  8929. }
  8930. else if (setupResult !== void 0) {
  8931. warn$1(
  8932. `setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`,
  8933. )
  8934. }
  8935. finishComponentSetup(instance, isSSR)
  8936. }
  8937. let compile$1
  8938. let installWithProxy
  8939. function registerRuntimeCompiler(_compile) {
  8940. compile$1 = _compile
  8941. installWithProxy = (i) => {
  8942. if (i.render._rc)
  8943. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers)
  8944. }
  8945. }
  8946. const isRuntimeOnly = () => !compile$1
  8947. function finishComponentSetup(instance, isSSR, skipOptions) {
  8948. const Component = instance.type
  8949. if (!instance.render) {
  8950. if (!isSSR && compile$1 && !Component.render) {
  8951. const template = Component.template || resolveMergedOptions(instance).template
  8952. if (template) {
  8953. {
  8954. startMeasure(instance, `compile`)
  8955. }
  8956. const { isCustomElement, compilerOptions } = instance.appContext.config
  8957. const { delimiters, compilerOptions: componentCompilerOptions } = Component
  8958. const finalCompilerOptions = extend(
  8959. extend(
  8960. {
  8961. isCustomElement,
  8962. delimiters,
  8963. },
  8964. compilerOptions,
  8965. ),
  8966. componentCompilerOptions,
  8967. )
  8968. Component.render = compile$1(template, finalCompilerOptions)
  8969. {
  8970. endMeasure(instance, `compile`)
  8971. }
  8972. }
  8973. }
  8974. instance.render = Component.render || NOOP
  8975. if (installWithProxy)
  8976. installWithProxy(instance)
  8977. }
  8978. {
  8979. const reset = setCurrentInstance(instance)
  8980. pauseTracking()
  8981. try {
  8982. applyOptions(instance)
  8983. }
  8984. finally {
  8985. resetTracking()
  8986. reset()
  8987. }
  8988. }
  8989. if (!Component.render && instance.render === NOOP && !isSSR) {
  8990. if (!compile$1 && Component.template) {
  8991. warn$1(
  8992. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.`),
  8993. )
  8994. }
  8995. else {
  8996. warn$1(`Component is missing template or render function.`)
  8997. }
  8998. }
  8999. }
  9000. const attrsProxyHandlers = {
  9001. get(target, key) {
  9002. markAttrsAccessed()
  9003. track(target, 'get', '')
  9004. return target[key]
  9005. },
  9006. set() {
  9007. warn$1(`setupContext.attrs is readonly.`)
  9008. return false
  9009. },
  9010. deleteProperty() {
  9011. warn$1(`setupContext.attrs is readonly.`)
  9012. return false
  9013. },
  9014. }
  9015. function getSlotsProxy(instance) {
  9016. return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
  9017. get(target, key) {
  9018. track(instance, 'get', '$slots')
  9019. return target[key]
  9020. },
  9021. }))
  9022. }
  9023. function createSetupContext(instance) {
  9024. const expose = (exposed) => {
  9025. {
  9026. if (instance.exposed)
  9027. warn$1(`expose() should be called only once per setup().`)
  9028. if (exposed != null) {
  9029. let exposedType = typeof exposed
  9030. if (exposedType === 'object') {
  9031. if (isArray(exposed))
  9032. exposedType = 'array'
  9033. else if (isRef(exposed))
  9034. exposedType = 'ref'
  9035. }
  9036. if (exposedType !== 'object') {
  9037. warn$1(
  9038. `expose() should be passed a plain object, received ${exposedType}.`,
  9039. )
  9040. }
  9041. }
  9042. }
  9043. instance.exposed = exposed || {}
  9044. }
  9045. {
  9046. let attrsProxy
  9047. return Object.freeze({
  9048. get attrs() {
  9049. return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers))
  9050. },
  9051. get slots() {
  9052. return getSlotsProxy(instance)
  9053. },
  9054. get emit() {
  9055. return (event, ...args) => instance.emit(event, ...args)
  9056. },
  9057. expose,
  9058. })
  9059. }
  9060. }
  9061. function getExposeProxy(instance) {
  9062. if (instance.exposed) {
  9063. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  9064. get(target, key) {
  9065. if (key in target)
  9066. return target[key]
  9067. else if (key in publicPropertiesMap)
  9068. return publicPropertiesMap[key](instance)
  9069. },
  9070. has(target, key) {
  9071. return key in target || key in publicPropertiesMap
  9072. },
  9073. }))
  9074. }
  9075. }
  9076. const classifyRE = /(?:^|[-_])(\w)/g
  9077. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '')
  9078. function getComponentName(Component, includeInferred = true) {
  9079. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name
  9080. }
  9081. function formatComponentName(instance, Component, isRoot = false) {
  9082. let name = getComponentName(Component)
  9083. if (!name && Component.__file) {
  9084. const match = Component.__file.match(/([^/\\]+)\.\w+$/)
  9085. if (match)
  9086. name = match[1]
  9087. }
  9088. if (!name && instance && instance.parent) {
  9089. const inferFromRegistry = (registry) => {
  9090. for (const key in registry) {
  9091. if (registry[key] === Component)
  9092. return key
  9093. }
  9094. }
  9095. name = inferFromRegistry(
  9096. instance.components || instance.parent.type.components,
  9097. ) || inferFromRegistry(instance.appContext.components)
  9098. }
  9099. return name ? classify(name) : isRoot ? `App` : `Anonymous`
  9100. }
  9101. function isClassComponent(value) {
  9102. return isFunction(value) && '__vccOpts' in value
  9103. }
  9104. function computed(getterOrOptions, debugOptions) {
  9105. const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup)
  9106. {
  9107. const i = getCurrentInstance()
  9108. if (i && i.appContext.config.warnRecursiveComputed)
  9109. c._warnRecursive = true
  9110. }
  9111. return c
  9112. }
  9113. function useModel(props, name, options = EMPTY_OBJ) {
  9114. const i = getCurrentInstance()
  9115. if (!i) {
  9116. warn$1(`useModel() called without active instance.`)
  9117. return ref()
  9118. }
  9119. if (!i.propsOptions[0][name]) {
  9120. warn$1(`useModel() called with prop "${name}" which is not declared.`)
  9121. return ref()
  9122. }
  9123. const camelizedName = camelize(name)
  9124. const hyphenatedName = hyphenate(name)
  9125. const res = customRef((track, trigger) => {
  9126. let localValue
  9127. watchSyncEffect(() => {
  9128. const propValue = props[name]
  9129. if (hasChanged(localValue, propValue)) {
  9130. localValue = propValue
  9131. trigger()
  9132. }
  9133. })
  9134. return {
  9135. get() {
  9136. track()
  9137. return options.get ? options.get(localValue) : localValue
  9138. },
  9139. set(value) {
  9140. const rawProps = i.vnode.props
  9141. if (!(rawProps // check if parent has passed v-model
  9142. && (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
  9143. localValue = value
  9144. trigger()
  9145. }
  9146. i.emit(`update:${name}`, options.set ? options.set(value) : value)
  9147. },
  9148. }
  9149. })
  9150. const modifierKey = name === 'modelValue' ? 'modelModifiers' : `${name}Modifiers`
  9151. res[Symbol.iterator] = () => {
  9152. let i2 = 0
  9153. return {
  9154. next() {
  9155. if (i2 < 2)
  9156. return { value: i2++ ? props[modifierKey] || {} : res, done: false }
  9157. else
  9158. return { done: true }
  9159. },
  9160. }
  9161. }
  9162. return res
  9163. }
  9164. function h(type, propsOrChildren, children) {
  9165. const l = arguments.length
  9166. if (l === 2) {
  9167. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  9168. if (isVNode(propsOrChildren))
  9169. return createVNode(type, null, [propsOrChildren])
  9170. return createVNode(type, propsOrChildren)
  9171. }
  9172. else {
  9173. return createVNode(type, null, propsOrChildren)
  9174. }
  9175. }
  9176. else {
  9177. if (l > 3)
  9178. children = Array.prototype.slice.call(arguments, 2)
  9179. else if (l === 3 && isVNode(children))
  9180. children = [children]
  9181. return createVNode(type, propsOrChildren, children)
  9182. }
  9183. }
  9184. function initCustomFormatter() {
  9185. if (typeof window === 'undefined')
  9186. return
  9187. const vueStyle = { style: 'color:#3ba776' }
  9188. const numberStyle = { style: 'color:#1677ff' }
  9189. const stringStyle = { style: 'color:#f5222d' }
  9190. const keywordStyle = { style: 'color:#eb2f96' }
  9191. const formatter = {
  9192. header(obj) {
  9193. if (!isObject(obj))
  9194. return null
  9195. if (obj.__isVue) {
  9196. return ['div', vueStyle, `VueInstance`]
  9197. }
  9198. else if (isRef(obj)) {
  9199. return [
  9200. 'div',
  9201. {},
  9202. ['span', vueStyle, genRefFlag(obj)],
  9203. '<',
  9204. formatValue(obj.value),
  9205. `>`,
  9206. ]
  9207. }
  9208. else if (isReactive(obj)) {
  9209. return [
  9210. 'div',
  9211. {},
  9212. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  9213. '<',
  9214. formatValue(obj),
  9215. `>${isReadonly(obj) ? ` (readonly)` : ``}`,
  9216. ]
  9217. }
  9218. else if (isReadonly(obj)) {
  9219. return [
  9220. 'div',
  9221. {},
  9222. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  9223. '<',
  9224. formatValue(obj),
  9225. '>',
  9226. ]
  9227. }
  9228. return null
  9229. },
  9230. hasBody(obj) {
  9231. return obj && obj.__isVue
  9232. },
  9233. body(obj) {
  9234. if (obj && obj.__isVue) {
  9235. return [
  9236. 'div',
  9237. {},
  9238. ...formatInstance(obj.$),
  9239. ]
  9240. }
  9241. },
  9242. }
  9243. function formatInstance(instance) {
  9244. const blocks = []
  9245. if (instance.type.props && instance.props)
  9246. blocks.push(createInstanceBlock('props', toRaw(instance.props)))
  9247. if (instance.setupState !== EMPTY_OBJ)
  9248. blocks.push(createInstanceBlock('setup', instance.setupState))
  9249. if (instance.data !== EMPTY_OBJ)
  9250. blocks.push(createInstanceBlock('data', toRaw(instance.data)))
  9251. const computed = extractKeys(instance, 'computed')
  9252. if (computed)
  9253. blocks.push(createInstanceBlock('computed', computed))
  9254. const injected = extractKeys(instance, 'inject')
  9255. if (injected)
  9256. blocks.push(createInstanceBlock('injected', injected))
  9257. blocks.push([
  9258. 'div',
  9259. {},
  9260. [
  9261. 'span',
  9262. {
  9263. style: `${keywordStyle.style};opacity:0.66`,
  9264. },
  9265. '$ (internal): ',
  9266. ],
  9267. ['object', { object: instance }],
  9268. ])
  9269. return blocks
  9270. }
  9271. function createInstanceBlock(type, target) {
  9272. target = extend({}, target)
  9273. if (!Object.keys(target).length)
  9274. return ['span', {}]
  9275. return [
  9276. 'div',
  9277. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  9278. [
  9279. 'div',
  9280. {
  9281. style: 'color:#476582',
  9282. },
  9283. type,
  9284. ],
  9285. [
  9286. 'div',
  9287. {
  9288. style: 'padding-left:1.25em',
  9289. },
  9290. ...Object.keys(target).map((key) => {
  9291. return [
  9292. 'div',
  9293. {},
  9294. ['span', keywordStyle, `${key}: `],
  9295. formatValue(target[key], false),
  9296. ]
  9297. }),
  9298. ],
  9299. ]
  9300. }
  9301. function formatValue(v, asRaw = true) {
  9302. if (typeof v === 'number')
  9303. return ['span', numberStyle, v]
  9304. else if (typeof v === 'string')
  9305. return ['span', stringStyle, JSON.stringify(v)]
  9306. else if (typeof v === 'boolean')
  9307. return ['span', keywordStyle, v]
  9308. else if (isObject(v))
  9309. return ['object', { object: asRaw ? toRaw(v) : v }]
  9310. else
  9311. return ['span', stringStyle, String(v)]
  9312. }
  9313. function extractKeys(instance, type) {
  9314. const Comp = instance.type
  9315. if (isFunction(Comp))
  9316. return
  9317. const extracted = {}
  9318. for (const key in instance.ctx) {
  9319. if (isKeyOfType(Comp, key, type))
  9320. extracted[key] = instance.ctx[key]
  9321. }
  9322. return extracted
  9323. }
  9324. function isKeyOfType(Comp, key, type) {
  9325. const opts = Comp[type]
  9326. if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts)
  9327. return true
  9328. if (Comp.extends && isKeyOfType(Comp.extends, key, type))
  9329. return true
  9330. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type)))
  9331. return true
  9332. }
  9333. function genRefFlag(v) {
  9334. if (isShallow(v))
  9335. return `ShallowRef`
  9336. if (v.effect)
  9337. return `ComputedRef`
  9338. return `Ref`
  9339. }
  9340. if (window.devtoolsFormatters)
  9341. window.devtoolsFormatters.push(formatter)
  9342. else
  9343. window.devtoolsFormatters = [formatter]
  9344. }
  9345. function withMemo(memo, render, cache, index) {
  9346. const cached = cache[index]
  9347. if (cached && isMemoSame(cached, memo))
  9348. return cached
  9349. const ret = render()
  9350. ret.memo = memo.slice()
  9351. return cache[index] = ret
  9352. }
  9353. function isMemoSame(cached, memo) {
  9354. const prev = cached.memo
  9355. if (prev.length != memo.length)
  9356. return false
  9357. for (let i = 0; i < prev.length; i++) {
  9358. if (hasChanged(prev[i], memo[i]))
  9359. return false
  9360. }
  9361. if (isBlockTreeEnabled > 0 && currentBlock)
  9362. currentBlock.push(cached)
  9363. return true
  9364. }
  9365. const version = '3.4.27'
  9366. const warn = warn$1
  9367. const ErrorTypeStrings = ErrorTypeStrings$1
  9368. const devtools = devtools$1
  9369. const setDevtoolsHook = setDevtoolsHook$1
  9370. const ssrUtils = null
  9371. const resolveFilter = null
  9372. const compatUtils = null
  9373. const DeprecationTypes = null
  9374. const svgNS = 'http://www.w3.org/2000/svg'
  9375. const mathmlNS = 'http://www.w3.org/1998/Math/MathML'
  9376. const doc = typeof document !== 'undefined' ? document : null
  9377. const templateContainer = doc && /* @__PURE__ */ doc.createElement('template')
  9378. const nodeOps = {
  9379. insert: (child, parent, anchor) => {
  9380. parent.insertBefore(child, anchor || null)
  9381. },
  9382. remove: (child) => {
  9383. const parent = child.parentNode
  9384. if (parent)
  9385. parent.removeChild(child)
  9386. },
  9387. createElement: (tag, namespace, is, props) => {
  9388. const el = namespace === 'svg' ? doc.createElementNS(svgNS, tag) : namespace === 'mathml' ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0)
  9389. if (tag === 'select' && props && props.multiple != null)
  9390. el.setAttribute('multiple', props.multiple)
  9391. return el
  9392. },
  9393. createText: text => doc.createTextNode(text),
  9394. createComment: text => doc.createComment(text),
  9395. setText: (node, text) => {
  9396. node.nodeValue = text
  9397. },
  9398. setElementText: (el, text) => {
  9399. el.textContent = text
  9400. },
  9401. parentNode: node => node.parentNode,
  9402. nextSibling: node => node.nextSibling,
  9403. querySelector: selector => doc.querySelector(selector),
  9404. setScopeId(el, id) {
  9405. el.setAttribute(id, '')
  9406. },
  9407. // __UNSAFE__
  9408. // Reason: innerHTML.
  9409. // Static content here can only come from compiled templates.
  9410. // As long as the user only uses trusted templates, this is safe.
  9411. insertStaticContent(content, parent, anchor, namespace, start, end) {
  9412. const before = anchor ? anchor.previousSibling : parent.lastChild
  9413. if (start && (start === end || start.nextSibling)) {
  9414. while (true) {
  9415. parent.insertBefore(start.cloneNode(true), anchor)
  9416. if (start === end || !(start = start.nextSibling))
  9417. break
  9418. }
  9419. }
  9420. else {
  9421. templateContainer.innerHTML = namespace === 'svg' ? `<svg>${content}</svg>` : namespace === 'mathml' ? `<math>${content}</math>` : content
  9422. const template = templateContainer.content
  9423. if (namespace === 'svg' || namespace === 'mathml') {
  9424. const wrapper = template.firstChild
  9425. while (wrapper.firstChild)
  9426. template.appendChild(wrapper.firstChild)
  9427. template.removeChild(wrapper)
  9428. }
  9429. parent.insertBefore(template, anchor)
  9430. }
  9431. return [
  9432. // first
  9433. before ? before.nextSibling : parent.firstChild,
  9434. // last
  9435. anchor ? anchor.previousSibling : parent.lastChild,
  9436. ]
  9437. },
  9438. }
  9439. const TRANSITION = 'transition'
  9440. const ANIMATION = 'animation'
  9441. const vtcKey = Symbol('_vtc')
  9442. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots)
  9443. Transition.displayName = 'Transition'
  9444. const DOMTransitionPropsValidators = {
  9445. name: String,
  9446. type: String,
  9447. css: {
  9448. type: Boolean,
  9449. default: true,
  9450. },
  9451. duration: [String, Number, Object],
  9452. enterFromClass: String,
  9453. enterActiveClass: String,
  9454. enterToClass: String,
  9455. appearFromClass: String,
  9456. appearActiveClass: String,
  9457. appearToClass: String,
  9458. leaveFromClass: String,
  9459. leaveActiveClass: String,
  9460. leaveToClass: String,
  9461. }
  9462. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
  9463. {},
  9464. BaseTransitionPropsValidators,
  9465. DOMTransitionPropsValidators,
  9466. )
  9467. function callHook(hook, args = []) {
  9468. if (isArray(hook))
  9469. hook.forEach(h2 => h2(...args))
  9470. else if (hook)
  9471. hook(...args)
  9472. }
  9473. function hasExplicitCallback(hook) {
  9474. return hook ? isArray(hook) ? hook.some(h2 => h2.length > 1) : hook.length > 1 : false
  9475. }
  9476. function resolveTransitionProps(rawProps) {
  9477. const baseProps = {}
  9478. for (const key in rawProps) {
  9479. if (!(key in DOMTransitionPropsValidators))
  9480. baseProps[key] = rawProps[key]
  9481. }
  9482. if (rawProps.css === false)
  9483. return baseProps
  9484. const {
  9485. name = 'v',
  9486. type,
  9487. duration,
  9488. enterFromClass = `${name}-enter-from`,
  9489. enterActiveClass = `${name}-enter-active`,
  9490. enterToClass = `${name}-enter-to`,
  9491. appearFromClass = enterFromClass,
  9492. appearActiveClass = enterActiveClass,
  9493. appearToClass = enterToClass,
  9494. leaveFromClass = `${name}-leave-from`,
  9495. leaveActiveClass = `${name}-leave-active`,
  9496. leaveToClass = `${name}-leave-to`,
  9497. } = rawProps
  9498. const durations = normalizeDuration(duration)
  9499. const enterDuration = durations && durations[0]
  9500. const leaveDuration = durations && durations[1]
  9501. const {
  9502. onBeforeEnter,
  9503. onEnter,
  9504. onEnterCancelled,
  9505. onLeave,
  9506. onLeaveCancelled,
  9507. onBeforeAppear = onBeforeEnter,
  9508. onAppear = onEnter,
  9509. onAppearCancelled = onEnterCancelled,
  9510. } = baseProps
  9511. const finishEnter = (el, isAppear, done) => {
  9512. removeTransitionClass(el, isAppear ? appearToClass : enterToClass)
  9513. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass)
  9514. done && done()
  9515. }
  9516. const finishLeave = (el, done) => {
  9517. el._isLeaving = false
  9518. removeTransitionClass(el, leaveFromClass)
  9519. removeTransitionClass(el, leaveToClass)
  9520. removeTransitionClass(el, leaveActiveClass)
  9521. done && done()
  9522. }
  9523. const makeEnterHook = (isAppear) => {
  9524. return (el, done) => {
  9525. const hook = isAppear ? onAppear : onEnter
  9526. const resolve = () => finishEnter(el, isAppear, done)
  9527. callHook(hook, [el, resolve])
  9528. nextFrame(() => {
  9529. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass)
  9530. addTransitionClass(el, isAppear ? appearToClass : enterToClass)
  9531. if (!hasExplicitCallback(hook))
  9532. whenTransitionEnds(el, type, enterDuration, resolve)
  9533. })
  9534. }
  9535. }
  9536. return extend(baseProps, {
  9537. onBeforeEnter(el) {
  9538. callHook(onBeforeEnter, [el])
  9539. addTransitionClass(el, enterFromClass)
  9540. addTransitionClass(el, enterActiveClass)
  9541. },
  9542. onBeforeAppear(el) {
  9543. callHook(onBeforeAppear, [el])
  9544. addTransitionClass(el, appearFromClass)
  9545. addTransitionClass(el, appearActiveClass)
  9546. },
  9547. onEnter: makeEnterHook(false),
  9548. onAppear: makeEnterHook(true),
  9549. onLeave(el, done) {
  9550. el._isLeaving = true
  9551. const resolve = () => finishLeave(el, done)
  9552. addTransitionClass(el, leaveFromClass)
  9553. addTransitionClass(el, leaveActiveClass)
  9554. forceReflow()
  9555. nextFrame(() => {
  9556. if (!el._isLeaving)
  9557. return
  9558. removeTransitionClass(el, leaveFromClass)
  9559. addTransitionClass(el, leaveToClass)
  9560. if (!hasExplicitCallback(onLeave))
  9561. whenTransitionEnds(el, type, leaveDuration, resolve)
  9562. })
  9563. callHook(onLeave, [el, resolve])
  9564. },
  9565. onEnterCancelled(el) {
  9566. finishEnter(el, false)
  9567. callHook(onEnterCancelled, [el])
  9568. },
  9569. onAppearCancelled(el) {
  9570. finishEnter(el, true)
  9571. callHook(onAppearCancelled, [el])
  9572. },
  9573. onLeaveCancelled(el) {
  9574. finishLeave(el)
  9575. callHook(onLeaveCancelled, [el])
  9576. },
  9577. })
  9578. }
  9579. function normalizeDuration(duration) {
  9580. if (duration == null) {
  9581. return null
  9582. }
  9583. else if (isObject(duration)) {
  9584. return [NumberOf(duration.enter), NumberOf(duration.leave)]
  9585. }
  9586. else {
  9587. const n = NumberOf(duration)
  9588. return [n, n]
  9589. }
  9590. }
  9591. function NumberOf(val) {
  9592. const res = toNumber(val)
  9593. {
  9594. assertNumber(res, '<transition> explicit duration')
  9595. }
  9596. return res
  9597. }
  9598. function addTransitionClass(el, cls) {
  9599. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  9600. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls)
  9601. }
  9602. function removeTransitionClass(el, cls) {
  9603. cls.split(/\s+/).forEach(c => c && el.classList.remove(c))
  9604. const _vtc = el[vtcKey]
  9605. if (_vtc) {
  9606. _vtc.delete(cls)
  9607. if (!_vtc.size)
  9608. el[vtcKey] = void 0
  9609. }
  9610. }
  9611. function nextFrame(cb) {
  9612. requestAnimationFrame(() => {
  9613. requestAnimationFrame(cb)
  9614. })
  9615. }
  9616. let endId = 0
  9617. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9618. const id = el._endId = ++endId
  9619. const resolveIfNotStale = () => {
  9620. if (id === el._endId)
  9621. resolve()
  9622. }
  9623. if (explicitTimeout)
  9624. return setTimeout(resolveIfNotStale, explicitTimeout)
  9625. const { type, timeout, propCount } = getTransitionInfo(el, expectedType)
  9626. if (!type)
  9627. return resolve()
  9628. const endEvent = `${type}end`
  9629. let ended = 0
  9630. const end = () => {
  9631. el.removeEventListener(endEvent, onEnd)
  9632. resolveIfNotStale()
  9633. }
  9634. const onEnd = (e) => {
  9635. if (e.target === el && ++ended >= propCount)
  9636. end()
  9637. }
  9638. setTimeout(() => {
  9639. if (ended < propCount)
  9640. end()
  9641. }, timeout + 1)
  9642. el.addEventListener(endEvent, onEnd)
  9643. }
  9644. function getTransitionInfo(el, expectedType) {
  9645. const styles = window.getComputedStyle(el)
  9646. const getStyleProperties = key => (styles[key] || '').split(', ')
  9647. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`)
  9648. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`)
  9649. const transitionTimeout = getTimeout(transitionDelays, transitionDurations)
  9650. const animationDelays = getStyleProperties(`${ANIMATION}Delay`)
  9651. const animationDurations = getStyleProperties(`${ANIMATION}Duration`)
  9652. const animationTimeout = getTimeout(animationDelays, animationDurations)
  9653. let type = null
  9654. let timeout = 0
  9655. let propCount = 0
  9656. if (expectedType === TRANSITION) {
  9657. if (transitionTimeout > 0) {
  9658. type = TRANSITION
  9659. timeout = transitionTimeout
  9660. propCount = transitionDurations.length
  9661. }
  9662. }
  9663. else if (expectedType === ANIMATION) {
  9664. if (animationTimeout > 0) {
  9665. type = ANIMATION
  9666. timeout = animationTimeout
  9667. propCount = animationDurations.length
  9668. }
  9669. }
  9670. else {
  9671. timeout = Math.max(transitionTimeout, animationTimeout)
  9672. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null
  9673. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0
  9674. }
  9675. const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
  9676. getStyleProperties(`${TRANSITION}Property`).toString(),
  9677. )
  9678. return {
  9679. type,
  9680. timeout,
  9681. propCount,
  9682. hasTransform,
  9683. }
  9684. }
  9685. function getTimeout(delays, durations) {
  9686. while (delays.length < durations.length)
  9687. delays = delays.concat(delays)
  9688. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])))
  9689. }
  9690. function toMs(s) {
  9691. if (s === 'auto')
  9692. return 0
  9693. return Number(s.slice(0, -1).replace(',', '.')) * 1e3
  9694. }
  9695. function forceReflow() {
  9696. return document.body.offsetHeight
  9697. }
  9698. function patchClass(el, value, isSVG) {
  9699. const transitionClasses = el[vtcKey]
  9700. if (transitionClasses)
  9701. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ')
  9702. if (value == null)
  9703. el.removeAttribute('class')
  9704. else if (isSVG)
  9705. el.setAttribute('class', value)
  9706. else
  9707. el.className = value
  9708. }
  9709. const vShowOriginalDisplay = Symbol('_vod')
  9710. const vShowHidden = Symbol('_vsh')
  9711. const vShow = {
  9712. beforeMount(el, { value }, { transition }) {
  9713. el[vShowOriginalDisplay] = el.style.display === 'none' ? '' : el.style.display
  9714. if (transition && value)
  9715. transition.beforeEnter(el)
  9716. else
  9717. setDisplay(el, value)
  9718. },
  9719. mounted(el, { value }, { transition }) {
  9720. if (transition && value)
  9721. transition.enter(el)
  9722. },
  9723. updated(el, { value, oldValue }, { transition }) {
  9724. if (!value === !oldValue)
  9725. return
  9726. if (transition) {
  9727. if (value) {
  9728. transition.beforeEnter(el)
  9729. setDisplay(el, true)
  9730. transition.enter(el)
  9731. }
  9732. else {
  9733. transition.leave(el, () => {
  9734. setDisplay(el, false)
  9735. })
  9736. }
  9737. }
  9738. else {
  9739. setDisplay(el, value)
  9740. }
  9741. },
  9742. beforeUnmount(el, { value }) {
  9743. setDisplay(el, value)
  9744. },
  9745. }
  9746. {
  9747. vShow.name = 'show'
  9748. }
  9749. function setDisplay(el, value) {
  9750. el.style.display = value ? el[vShowOriginalDisplay] : 'none'
  9751. el[vShowHidden] = !value
  9752. }
  9753. const CSS_VAR_TEXT = Symbol('CSS_VAR_TEXT')
  9754. function useCssVars(getter) {
  9755. const instance = getCurrentInstance()
  9756. if (!instance) {
  9757. warn(`useCssVars is called without current active component instance.`)
  9758. return
  9759. }
  9760. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  9761. Array.from(
  9762. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`),
  9763. ).forEach(node => setVarsOnNode(node, vars))
  9764. }
  9765. {
  9766. instance.getCssVars = () => getter(instance.proxy)
  9767. }
  9768. const setVars = () => {
  9769. const vars = getter(instance.proxy)
  9770. setVarsOnVNode(instance.subTree, vars)
  9771. updateTeleports(vars)
  9772. }
  9773. onMounted(() => {
  9774. watchPostEffect(setVars)
  9775. const ob = new MutationObserver(setVars)
  9776. ob.observe(instance.subTree.el.parentNode, { childList: true })
  9777. onUnmounted(() => ob.disconnect())
  9778. })
  9779. }
  9780. function setVarsOnVNode(vnode, vars) {
  9781. if (vnode.shapeFlag & 128) {
  9782. const suspense = vnode.suspense
  9783. vnode = suspense.activeBranch
  9784. if (suspense.pendingBranch && !suspense.isHydrating) {
  9785. suspense.effects.push(() => {
  9786. setVarsOnVNode(suspense.activeBranch, vars)
  9787. })
  9788. }
  9789. }
  9790. while (vnode.component)
  9791. vnode = vnode.component.subTree
  9792. if (vnode.shapeFlag & 1 && vnode.el) {
  9793. setVarsOnNode(vnode.el, vars)
  9794. }
  9795. else if (vnode.type === Fragment) {
  9796. vnode.children.forEach(c => setVarsOnVNode(c, vars))
  9797. }
  9798. else if (vnode.type === Static) {
  9799. let { el, anchor } = vnode
  9800. while (el) {
  9801. setVarsOnNode(el, vars)
  9802. if (el === anchor)
  9803. break
  9804. el = el.nextSibling
  9805. }
  9806. }
  9807. }
  9808. function setVarsOnNode(el, vars) {
  9809. if (el.nodeType === 1) {
  9810. const style = el.style
  9811. let cssText = ''
  9812. for (const key in vars) {
  9813. style.setProperty(`--${key}`, vars[key])
  9814. cssText += `--${key}: ${vars[key]};`
  9815. }
  9816. style[CSS_VAR_TEXT] = cssText
  9817. }
  9818. }
  9819. const displayRE = /(^|;)\s*display\s*:/
  9820. function patchStyle(el, prev, next) {
  9821. const style = el.style
  9822. const isCssString = isString(next)
  9823. let hasControlledDisplay = false
  9824. if (next && !isCssString) {
  9825. if (prev) {
  9826. if (!isString(prev)) {
  9827. for (const key in prev) {
  9828. if (next[key] == null)
  9829. setStyle(style, key, '')
  9830. }
  9831. }
  9832. else {
  9833. for (const prevStyle of prev.split(';')) {
  9834. const key = prevStyle.slice(0, prevStyle.indexOf(':')).trim()
  9835. if (next[key] == null)
  9836. setStyle(style, key, '')
  9837. }
  9838. }
  9839. }
  9840. for (const key in next) {
  9841. if (key === 'display')
  9842. hasControlledDisplay = true
  9843. setStyle(style, key, next[key])
  9844. }
  9845. }
  9846. else {
  9847. if (isCssString) {
  9848. if (prev !== next) {
  9849. const cssVarText = style[CSS_VAR_TEXT]
  9850. if (cssVarText)
  9851. next += `;${cssVarText}`
  9852. style.cssText = next
  9853. hasControlledDisplay = displayRE.test(next)
  9854. }
  9855. }
  9856. else if (prev) {
  9857. el.removeAttribute('style')
  9858. }
  9859. }
  9860. if (vShowOriginalDisplay in el) {
  9861. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : ''
  9862. if (el[vShowHidden])
  9863. style.display = 'none'
  9864. }
  9865. }
  9866. const semicolonRE = /[^\\];\s*$/
  9867. const importantRE = /\s*!important$/
  9868. function setStyle(style, name, val) {
  9869. if (isArray(val)) {
  9870. val.forEach(v => setStyle(style, name, v))
  9871. }
  9872. else {
  9873. if (val == null)
  9874. val = ''
  9875. {
  9876. if (semicolonRE.test(val)) {
  9877. warn(
  9878. `Unexpected semicolon at the end of '${name}' style value: '${val}'`,
  9879. )
  9880. }
  9881. }
  9882. if (name.startsWith('--')) {
  9883. style.setProperty(name, val)
  9884. }
  9885. else {
  9886. const prefixed = autoPrefix(style, name)
  9887. if (importantRE.test(val)) {
  9888. style.setProperty(
  9889. hyphenate(prefixed),
  9890. val.replace(importantRE, ''),
  9891. 'important',
  9892. )
  9893. }
  9894. else {
  9895. style[prefixed] = val
  9896. }
  9897. }
  9898. }
  9899. }
  9900. const prefixes = ['Webkit', 'Moz', 'ms']
  9901. const prefixCache = {}
  9902. function autoPrefix(style, rawName) {
  9903. const cached = prefixCache[rawName]
  9904. if (cached)
  9905. return cached
  9906. let name = camelize(rawName)
  9907. if (name !== 'filter' && name in style)
  9908. return prefixCache[rawName] = name
  9909. name = capitalize(name)
  9910. for (let i = 0; i < prefixes.length; i++) {
  9911. const prefixed = prefixes[i] + name
  9912. if (prefixed in style)
  9913. return prefixCache[rawName] = prefixed
  9914. }
  9915. return rawName
  9916. }
  9917. const xlinkNS = 'http://www.w3.org/1999/xlink'
  9918. function patchAttr(el, key, value, isSVG, instance) {
  9919. if (isSVG && key.startsWith('xlink:')) {
  9920. if (value == null)
  9921. el.removeAttributeNS(xlinkNS, key.slice(6, key.length))
  9922. else
  9923. el.setAttributeNS(xlinkNS, key, value)
  9924. }
  9925. else {
  9926. const isBoolean = isSpecialBooleanAttr(key)
  9927. if (value == null || isBoolean && !includeBooleanAttr(value))
  9928. el.removeAttribute(key)
  9929. else
  9930. el.setAttribute(key, isBoolean ? '' : value)
  9931. }
  9932. }
  9933. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9934. if (key === 'innerHTML' || key === 'textContent') {
  9935. if (prevChildren)
  9936. unmountChildren(prevChildren, parentComponent, parentSuspense)
  9937. el[key] = value == null ? '' : value
  9938. return
  9939. }
  9940. const tag = el.tagName
  9941. if (key === 'value' && tag !== 'PROGRESS' // custom elements may use _value internally
  9942. && !tag.includes('-')) {
  9943. const oldValue = tag === 'OPTION' ? el.getAttribute('value') || '' : el.value
  9944. const newValue = value == null ? '' : value
  9945. if (oldValue !== newValue || !('_value' in el))
  9946. el.value = newValue
  9947. if (value == null)
  9948. el.removeAttribute(key)
  9949. el._value = value
  9950. return
  9951. }
  9952. let needRemove = false
  9953. if (value === '' || value == null) {
  9954. const type = typeof el[key]
  9955. if (type === 'boolean') {
  9956. value = includeBooleanAttr(value)
  9957. }
  9958. else if (value == null && type === 'string') {
  9959. value = ''
  9960. needRemove = true
  9961. }
  9962. else if (type === 'number') {
  9963. value = 0
  9964. needRemove = true
  9965. }
  9966. }
  9967. try {
  9968. el[key] = value
  9969. }
  9970. catch (e) {
  9971. if (!needRemove) {
  9972. warn(
  9973. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  9974. e,
  9975. )
  9976. }
  9977. }
  9978. needRemove && el.removeAttribute(key)
  9979. }
  9980. function addEventListener(el, event, handler, options) {
  9981. el.addEventListener(event, handler, options)
  9982. }
  9983. function removeEventListener(el, event, handler, options) {
  9984. el.removeEventListener(event, handler, options)
  9985. }
  9986. const veiKey = Symbol('_vei')
  9987. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9988. const invokers = el[veiKey] || (el[veiKey] = {})
  9989. const existingInvoker = invokers[rawName]
  9990. if (nextValue && existingInvoker) {
  9991. existingInvoker.value = sanitizeEventValue(nextValue, rawName)
  9992. }
  9993. else {
  9994. const [name, options] = parseName(rawName)
  9995. if (nextValue) {
  9996. const invoker = invokers[rawName] = createInvoker(
  9997. sanitizeEventValue(nextValue, rawName),
  9998. instance,
  9999. )
  10000. addEventListener(el, name, invoker, options)
  10001. }
  10002. else if (existingInvoker) {
  10003. removeEventListener(el, name, existingInvoker, options)
  10004. invokers[rawName] = void 0
  10005. }
  10006. }
  10007. }
  10008. const optionsModifierRE = /(?:Once|Passive|Capture)$/
  10009. function parseName(name) {
  10010. let options
  10011. if (optionsModifierRE.test(name)) {
  10012. options = {}
  10013. let m
  10014. while (m = name.match(optionsModifierRE)) {
  10015. name = name.slice(0, name.length - m[0].length)
  10016. options[m[0].toLowerCase()] = true
  10017. }
  10018. }
  10019. const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2))
  10020. return [event, options]
  10021. }
  10022. let cachedNow = 0
  10023. const p = /* @__PURE__ */ Promise.resolve()
  10024. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now())
  10025. function createInvoker(initialValue, instance) {
  10026. const invoker = (e) => {
  10027. if (!e._vts)
  10028. e._vts = Date.now()
  10029. else if (e._vts <= invoker.attached)
  10030. return
  10031. callWithAsyncErrorHandling(
  10032. patchStopImmediatePropagation(e, invoker.value),
  10033. instance,
  10034. 5,
  10035. [e],
  10036. )
  10037. }
  10038. invoker.value = initialValue
  10039. invoker.attached = getNow()
  10040. return invoker
  10041. }
  10042. function sanitizeEventValue(value, propName) {
  10043. if (isFunction(value) || isArray(value))
  10044. return value
  10045. warn(
  10046. `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
  10047. Expected function or array of functions, received type ${typeof value}.`,
  10048. )
  10049. return NOOP
  10050. }
  10051. function patchStopImmediatePropagation(e, value) {
  10052. if (isArray(value)) {
  10053. const originalStop = e.stopImmediatePropagation
  10054. e.stopImmediatePropagation = () => {
  10055. originalStop.call(e)
  10056. e._stopped = true
  10057. }
  10058. return value.map(
  10059. fn => e2 => !e2._stopped && fn && fn(e2),
  10060. )
  10061. }
  10062. else {
  10063. return value
  10064. }
  10065. }
  10066. function isNativeOn(key) {
  10067. return key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 // lowercase letter
  10068. && key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123
  10069. }
  10070. function patchProp(el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  10071. const isSVG = namespace === 'svg'
  10072. if (key === 'class') {
  10073. patchClass(el, nextValue, isSVG)
  10074. }
  10075. else if (key === 'style') {
  10076. patchStyle(el, prevValue, nextValue)
  10077. }
  10078. else if (isOn(key)) {
  10079. if (!isModelListener(key))
  10080. patchEvent(el, key, prevValue, nextValue, parentComponent)
  10081. }
  10082. else if (key[0] === '.' ? (key = key.slice(1), true) : key[0] === '^' ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  10083. patchDOMProp(
  10084. el,
  10085. key,
  10086. nextValue,
  10087. prevChildren,
  10088. parentComponent,
  10089. parentSuspense,
  10090. unmountChildren,
  10091. )
  10092. }
  10093. else {
  10094. if (key === 'true-value')
  10095. el._trueValue = nextValue
  10096. else if (key === 'false-value')
  10097. el._falseValue = nextValue
  10098. patchAttr(el, key, nextValue, isSVG)
  10099. }
  10100. }
  10101. function shouldSetAsProp(el, key, value, isSVG) {
  10102. if (isSVG) {
  10103. if (key === 'innerHTML' || key === 'textContent')
  10104. return true
  10105. if (key in el && isNativeOn(key) && isFunction(value))
  10106. return true
  10107. return false
  10108. }
  10109. if (key === 'spellcheck' || key === 'draggable' || key === 'translate')
  10110. return false
  10111. if (key === 'form')
  10112. return false
  10113. if (key === 'list' && el.tagName === 'INPUT')
  10114. return false
  10115. if (key === 'type' && el.tagName === 'TEXTAREA')
  10116. return false
  10117. if (key === 'width' || key === 'height') {
  10118. const tag = el.tagName
  10119. if (tag === 'IMG' || tag === 'VIDEO' || tag === 'CANVAS' || tag === 'SOURCE')
  10120. return false
  10121. }
  10122. if (isNativeOn(key) && isString(value))
  10123. return false
  10124. return key in el
  10125. }
  10126. /*! #__NO_SIDE_EFFECTS__ */
  10127. // @__NO_SIDE_EFFECTS__
  10128. function defineCustomElement(options, hydrate2) {
  10129. const Comp = defineComponent(options)
  10130. class VueCustomElement extends VueElement {
  10131. constructor(initialProps) {
  10132. super(Comp, initialProps, hydrate2)
  10133. }
  10134. }
  10135. VueCustomElement.def = Comp
  10136. return VueCustomElement
  10137. }
  10138. /*! #__NO_SIDE_EFFECTS__ */
  10139. function defineSSRCustomElement(options) {
  10140. return /* @__PURE__ */ defineCustomElement(options, hydrate)
  10141. }
  10142. const BaseClass = typeof HTMLElement !== 'undefined'
  10143. ? HTMLElement
  10144. : class {
  10145. }
  10146. class VueElement extends BaseClass {
  10147. constructor(_def, _props = {}, hydrate2) {
  10148. super()
  10149. this._def = _def
  10150. this._props = _props
  10151. /**
  10152. * @internal
  10153. */
  10154. this._instance = null
  10155. this._connected = false
  10156. this._resolved = false
  10157. this._numberProps = null
  10158. this._ob = null
  10159. if (this.shadowRoot && hydrate2) {
  10160. hydrate2(this._createVNode(), this.shadowRoot)
  10161. }
  10162. else {
  10163. if (this.shadowRoot) {
  10164. warn(
  10165. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`,
  10166. )
  10167. }
  10168. this.attachShadow({ mode: 'open' })
  10169. if (!this._def.__asyncLoader)
  10170. this._resolveProps(this._def)
  10171. }
  10172. }
  10173. connectedCallback() {
  10174. this._connected = true
  10175. if (!this._instance) {
  10176. if (this._resolved)
  10177. this._update()
  10178. else
  10179. this._resolveDef()
  10180. }
  10181. }
  10182. disconnectedCallback() {
  10183. this._connected = false
  10184. if (this._ob) {
  10185. this._ob.disconnect()
  10186. this._ob = null
  10187. }
  10188. nextTick(() => {
  10189. if (!this._connected) {
  10190. render(null, this.shadowRoot)
  10191. this._instance = null
  10192. }
  10193. })
  10194. }
  10195. /**
  10196. * resolve inner component definition (handle possible async component)
  10197. */
  10198. _resolveDef() {
  10199. this._resolved = true
  10200. for (let i = 0; i < this.attributes.length; i++)
  10201. this._setAttr(this.attributes[i].name)
  10202. this._ob = new MutationObserver((mutations) => {
  10203. for (const m of mutations)
  10204. this._setAttr(m.attributeName)
  10205. })
  10206. this._ob.observe(this, { attributes: true })
  10207. const resolve = (def, isAsync = false) => {
  10208. const { props, styles } = def
  10209. let numberProps
  10210. if (props && !isArray(props)) {
  10211. for (const key in props) {
  10212. const opt = props[key]
  10213. if (opt === Number || opt && opt.type === Number) {
  10214. if (key in this._props)
  10215. this._props[key] = toNumber(this._props[key]);
  10216. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true
  10217. }
  10218. }
  10219. }
  10220. this._numberProps = numberProps
  10221. if (isAsync)
  10222. this._resolveProps(def)
  10223. this._applyStyles(styles)
  10224. this._update()
  10225. }
  10226. const asyncDef = this._def.__asyncLoader
  10227. if (asyncDef)
  10228. asyncDef().then(def => resolve(def, true))
  10229. else
  10230. resolve(this._def)
  10231. }
  10232. _resolveProps(def) {
  10233. const { props } = def
  10234. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {})
  10235. for (const key of Object.keys(this)) {
  10236. if (key[0] !== '_' && declaredPropKeys.includes(key))
  10237. this._setProp(key, this[key], true, false)
  10238. }
  10239. for (const key of declaredPropKeys.map(camelize)) {
  10240. Object.defineProperty(this, key, {
  10241. get() {
  10242. return this._getProp(key)
  10243. },
  10244. set(val) {
  10245. this._setProp(key, val)
  10246. },
  10247. })
  10248. }
  10249. }
  10250. _setAttr(key) {
  10251. let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0
  10252. const camelKey = camelize(key)
  10253. if (this._numberProps && this._numberProps[camelKey])
  10254. value = toNumber(value)
  10255. this._setProp(camelKey, value, false)
  10256. }
  10257. /**
  10258. * @internal
  10259. */
  10260. _getProp(key) {
  10261. return this._props[key]
  10262. }
  10263. /**
  10264. * @internal
  10265. */
  10266. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  10267. if (val !== this._props[key]) {
  10268. this._props[key] = val
  10269. if (shouldUpdate && this._instance)
  10270. this._update()
  10271. if (shouldReflect) {
  10272. if (val === true)
  10273. this.setAttribute(hyphenate(key), '')
  10274. else if (typeof val === 'string' || typeof val === 'number')
  10275. this.setAttribute(hyphenate(key), `${val}`)
  10276. else if (!val)
  10277. this.removeAttribute(hyphenate(key))
  10278. }
  10279. }
  10280. }
  10281. _update() {
  10282. render(this._createVNode(), this.shadowRoot)
  10283. }
  10284. _createVNode() {
  10285. const vnode = createVNode(this._def, extend({}, this._props))
  10286. if (!this._instance) {
  10287. vnode.ce = (instance) => {
  10288. this._instance = instance
  10289. instance.isCE = true
  10290. {
  10291. instance.ceReload = (newStyles) => {
  10292. if (this._styles) {
  10293. this._styles.forEach(s => this.shadowRoot.removeChild(s))
  10294. this._styles.length = 0
  10295. }
  10296. this._applyStyles(newStyles)
  10297. this._instance = null
  10298. this._update()
  10299. }
  10300. }
  10301. const dispatch = (event, args) => {
  10302. this.dispatchEvent(
  10303. new CustomEvent(event, {
  10304. detail: args,
  10305. }),
  10306. )
  10307. }
  10308. instance.emit = (event, ...args) => {
  10309. dispatch(event, args)
  10310. if (hyphenate(event) !== event)
  10311. dispatch(hyphenate(event), args)
  10312. }
  10313. let parent = this
  10314. while (parent = parent && (parent.parentNode || parent.host)) {
  10315. if (parent instanceof VueElement) {
  10316. instance.parent = parent._instance
  10317. instance.provides = parent._instance.provides
  10318. break
  10319. }
  10320. }
  10321. }
  10322. }
  10323. return vnode
  10324. }
  10325. _applyStyles(styles) {
  10326. if (styles) {
  10327. styles.forEach((css) => {
  10328. const s = document.createElement('style')
  10329. s.textContent = css
  10330. this.shadowRoot.appendChild(s)
  10331. {
  10332. (this._styles || (this._styles = [])).push(s)
  10333. }
  10334. })
  10335. }
  10336. }
  10337. }
  10338. function useCssModule(name = '$style') {
  10339. {
  10340. const instance = getCurrentInstance()
  10341. if (!instance) {
  10342. warn(`useCssModule must be called inside setup()`)
  10343. return EMPTY_OBJ
  10344. }
  10345. const modules = instance.type.__cssModules
  10346. if (!modules) {
  10347. warn(`Current instance does not have CSS modules injected.`)
  10348. return EMPTY_OBJ
  10349. }
  10350. const mod = modules[name]
  10351. if (!mod) {
  10352. warn(`Current instance does not have CSS module named "${name}".`)
  10353. return EMPTY_OBJ
  10354. }
  10355. return mod
  10356. }
  10357. }
  10358. const positionMap = /* @__PURE__ */ new WeakMap()
  10359. const newPositionMap = /* @__PURE__ */ new WeakMap()
  10360. const moveCbKey = Symbol('_moveCb')
  10361. const enterCbKey = Symbol('_enterCb')
  10362. const TransitionGroupImpl = {
  10363. name: 'TransitionGroup',
  10364. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  10365. tag: String,
  10366. moveClass: String,
  10367. }),
  10368. setup(props, { slots }) {
  10369. const instance = getCurrentInstance()
  10370. const state = useTransitionState()
  10371. let prevChildren
  10372. let children
  10373. onUpdated(() => {
  10374. if (!prevChildren.length)
  10375. return
  10376. const moveClass = props.moveClass || `${props.name || 'v'}-move`
  10377. if (!hasCSSTransform(
  10378. prevChildren[0].el,
  10379. instance.vnode.el,
  10380. moveClass,
  10381. ))
  10382. return
  10383. prevChildren.forEach(callPendingCbs)
  10384. prevChildren.forEach(recordPosition)
  10385. const movedChildren = prevChildren.filter(applyTranslation)
  10386. forceReflow()
  10387. movedChildren.forEach((c) => {
  10388. const el = c.el
  10389. const style = el.style
  10390. addTransitionClass(el, moveClass)
  10391. style.transform = style.webkitTransform = style.transitionDuration = ''
  10392. const cb = el[moveCbKey] = (e) => {
  10393. if (e && e.target !== el)
  10394. return
  10395. if (!e || e.propertyName.endsWith('transform')) {
  10396. el.removeEventListener('transitionend', cb)
  10397. el[moveCbKey] = null
  10398. removeTransitionClass(el, moveClass)
  10399. }
  10400. }
  10401. el.addEventListener('transitionend', cb)
  10402. })
  10403. })
  10404. return () => {
  10405. const rawProps = toRaw(props)
  10406. const cssTransitionProps = resolveTransitionProps(rawProps)
  10407. const tag = rawProps.tag || Fragment
  10408. prevChildren = []
  10409. if (children) {
  10410. for (let i = 0; i < children.length; i++) {
  10411. const child = children[i]
  10412. if (child.el && child.el instanceof Element) {
  10413. prevChildren.push(child)
  10414. setTransitionHooks(
  10415. child,
  10416. resolveTransitionHooks(
  10417. child,
  10418. cssTransitionProps,
  10419. state,
  10420. instance,
  10421. ),
  10422. )
  10423. positionMap.set(
  10424. child,
  10425. child.el.getBoundingClientRect(),
  10426. )
  10427. }
  10428. }
  10429. }
  10430. children = slots.default ? getTransitionRawChildren(slots.default()) : []
  10431. for (let i = 0; i < children.length; i++) {
  10432. const child = children[i]
  10433. if (child.key != null) {
  10434. setTransitionHooks(
  10435. child,
  10436. resolveTransitionHooks(child, cssTransitionProps, state, instance),
  10437. )
  10438. }
  10439. else {
  10440. warn(`<TransitionGroup> children must be keyed.`)
  10441. }
  10442. }
  10443. return createVNode(tag, null, children)
  10444. }
  10445. },
  10446. }
  10447. const removeMode = props => delete props.mode
  10448. /* @__PURE__ */ removeMode(TransitionGroupImpl.props)
  10449. const TransitionGroup = TransitionGroupImpl
  10450. function callPendingCbs(c) {
  10451. const el = c.el
  10452. if (el[moveCbKey])
  10453. el[moveCbKey]()
  10454. if (el[enterCbKey])
  10455. el[enterCbKey]()
  10456. }
  10457. function recordPosition(c) {
  10458. newPositionMap.set(c, c.el.getBoundingClientRect())
  10459. }
  10460. function applyTranslation(c) {
  10461. const oldPos = positionMap.get(c)
  10462. const newPos = newPositionMap.get(c)
  10463. const dx = oldPos.left - newPos.left
  10464. const dy = oldPos.top - newPos.top
  10465. if (dx || dy) {
  10466. const s = c.el.style
  10467. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`
  10468. s.transitionDuration = '0s'
  10469. return c
  10470. }
  10471. }
  10472. function hasCSSTransform(el, root, moveClass) {
  10473. const clone = el.cloneNode()
  10474. const _vtc = el[vtcKey]
  10475. if (_vtc) {
  10476. _vtc.forEach((cls) => {
  10477. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c))
  10478. })
  10479. }
  10480. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c))
  10481. clone.style.display = 'none'
  10482. const container = root.nodeType === 1 ? root : root.parentNode
  10483. container.appendChild(clone)
  10484. const { hasTransform } = getTransitionInfo(clone)
  10485. container.removeChild(clone)
  10486. return hasTransform
  10487. }
  10488. function getModelAssigner(vnode) {
  10489. const fn = vnode.props['onUpdate:modelValue'] || false
  10490. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn
  10491. }
  10492. function onCompositionStart(e) {
  10493. e.target.composing = true
  10494. }
  10495. function onCompositionEnd(e) {
  10496. const target = e.target
  10497. if (target.composing) {
  10498. target.composing = false
  10499. target.dispatchEvent(new Event('input'))
  10500. }
  10501. }
  10502. const assignKey = Symbol('_assign')
  10503. const vModelText = {
  10504. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10505. el[assignKey] = getModelAssigner(vnode)
  10506. const castToNumber = number || vnode.props && vnode.props.type === 'number'
  10507. addEventListener(el, lazy ? 'change' : 'input', (e) => {
  10508. if (e.target.composing)
  10509. return
  10510. let domValue = el.value
  10511. if (trim)
  10512. domValue = domValue.trim()
  10513. if (castToNumber)
  10514. domValue = looseToNumber(domValue)
  10515. el[assignKey](domValue)
  10516. })
  10517. if (trim) {
  10518. addEventListener(el, 'change', () => {
  10519. el.value = el.value.trim()
  10520. })
  10521. }
  10522. if (!lazy) {
  10523. addEventListener(el, 'compositionstart', onCompositionStart)
  10524. addEventListener(el, 'compositionend', onCompositionEnd)
  10525. addEventListener(el, 'change', onCompositionEnd)
  10526. }
  10527. },
  10528. // set value on mounted so it's after min/max for type="range"
  10529. mounted(el, { value }) {
  10530. el.value = value == null ? '' : value
  10531. },
  10532. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10533. el[assignKey] = getModelAssigner(vnode)
  10534. if (el.composing)
  10535. return
  10536. const elValue = (number || el.type === 'number') && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value
  10537. const newValue = value == null ? '' : value
  10538. if (elValue === newValue)
  10539. return
  10540. if (document.activeElement === el && el.type !== 'range') {
  10541. if (lazy)
  10542. return
  10543. if (trim && el.value.trim() === newValue)
  10544. return
  10545. }
  10546. el.value = newValue
  10547. },
  10548. }
  10549. const vModelCheckbox = {
  10550. // #4096 array checkboxes need to be deep traversed
  10551. deep: true,
  10552. created(el, _, vnode) {
  10553. el[assignKey] = getModelAssigner(vnode)
  10554. addEventListener(el, 'change', () => {
  10555. const modelValue = el._modelValue
  10556. const elementValue = getValue(el)
  10557. const checked = el.checked
  10558. const assign = el[assignKey]
  10559. if (isArray(modelValue)) {
  10560. const index = looseIndexOf(modelValue, elementValue)
  10561. const found = index !== -1
  10562. if (checked && !found) {
  10563. assign(modelValue.concat(elementValue))
  10564. }
  10565. else if (!checked && found) {
  10566. const filtered = [...modelValue]
  10567. filtered.splice(index, 1)
  10568. assign(filtered)
  10569. }
  10570. }
  10571. else if (isSet(modelValue)) {
  10572. const cloned = new Set(modelValue)
  10573. if (checked)
  10574. cloned.add(elementValue)
  10575. else
  10576. cloned.delete(elementValue)
  10577. assign(cloned)
  10578. }
  10579. else {
  10580. assign(getCheckboxValue(el, checked))
  10581. }
  10582. })
  10583. },
  10584. // set initial checked on mount to wait for true-value/false-value
  10585. mounted: setChecked,
  10586. beforeUpdate(el, binding, vnode) {
  10587. el[assignKey] = getModelAssigner(vnode)
  10588. setChecked(el, binding, vnode)
  10589. },
  10590. }
  10591. function setChecked(el, { value, oldValue }, vnode) {
  10592. el._modelValue = value
  10593. if (isArray(value))
  10594. el.checked = looseIndexOf(value, vnode.props.value) > -1
  10595. else if (isSet(value))
  10596. el.checked = value.has(vnode.props.value)
  10597. else if (value !== oldValue)
  10598. el.checked = looseEqual(value, getCheckboxValue(el, true))
  10599. }
  10600. const vModelRadio = {
  10601. created(el, { value }, vnode) {
  10602. el.checked = looseEqual(value, vnode.props.value)
  10603. el[assignKey] = getModelAssigner(vnode)
  10604. addEventListener(el, 'change', () => {
  10605. el[assignKey](getValue(el))
  10606. })
  10607. },
  10608. beforeUpdate(el, { value, oldValue }, vnode) {
  10609. el[assignKey] = getModelAssigner(vnode)
  10610. if (value !== oldValue)
  10611. el.checked = looseEqual(value, vnode.props.value)
  10612. },
  10613. }
  10614. const vModelSelect = {
  10615. // <select multiple> value need to be deep traversed
  10616. deep: true,
  10617. created(el, { value, modifiers: { number } }, vnode) {
  10618. const isSetModel = isSet(value)
  10619. addEventListener(el, 'change', () => {
  10620. const selectedVal = Array.prototype.filter.call(el.options, o => o.selected).map(
  10621. o => number ? looseToNumber(getValue(o)) : getValue(o),
  10622. )
  10623. el[assignKey](
  10624. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0],
  10625. )
  10626. el._assigning = true
  10627. nextTick(() => {
  10628. el._assigning = false
  10629. })
  10630. })
  10631. el[assignKey] = getModelAssigner(vnode)
  10632. },
  10633. // set value in mounted & updated because <select> relies on its children
  10634. // <option>s.
  10635. mounted(el, { value, modifiers: { number } }) {
  10636. setSelected(el, value)
  10637. },
  10638. beforeUpdate(el, _binding, vnode) {
  10639. el[assignKey] = getModelAssigner(vnode)
  10640. },
  10641. updated(el, { value, modifiers: { number } }) {
  10642. if (!el._assigning)
  10643. setSelected(el, value)
  10644. },
  10645. }
  10646. function setSelected(el, value, number) {
  10647. const isMultiple = el.multiple
  10648. const isArrayValue = isArray(value)
  10649. if (isMultiple && !isArrayValue && !isSet(value)) {
  10650. warn(
  10651. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`,
  10652. )
  10653. return
  10654. }
  10655. for (let i = 0, l = el.options.length; i < l; i++) {
  10656. const option = el.options[i]
  10657. const optionValue = getValue(option)
  10658. if (isMultiple) {
  10659. if (isArrayValue) {
  10660. const optionType = typeof optionValue
  10661. if (optionType === 'string' || optionType === 'number')
  10662. option.selected = value.some(v => String(v) === String(optionValue))
  10663. else
  10664. option.selected = looseIndexOf(value, optionValue) > -1
  10665. }
  10666. else {
  10667. option.selected = value.has(optionValue)
  10668. }
  10669. }
  10670. else if (looseEqual(getValue(option), value)) {
  10671. if (el.selectedIndex !== i)
  10672. el.selectedIndex = i
  10673. return
  10674. }
  10675. }
  10676. if (!isMultiple && el.selectedIndex !== -1)
  10677. el.selectedIndex = -1
  10678. }
  10679. function getValue(el) {
  10680. return '_value' in el ? el._value : el.value
  10681. }
  10682. function getCheckboxValue(el, checked) {
  10683. const key = checked ? '_trueValue' : '_falseValue'
  10684. return key in el ? el[key] : checked
  10685. }
  10686. const vModelDynamic = {
  10687. created(el, binding, vnode) {
  10688. callModelHook(el, binding, vnode, null, 'created')
  10689. },
  10690. mounted(el, binding, vnode) {
  10691. callModelHook(el, binding, vnode, null, 'mounted')
  10692. },
  10693. beforeUpdate(el, binding, vnode, prevVNode) {
  10694. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate')
  10695. },
  10696. updated(el, binding, vnode, prevVNode) {
  10697. callModelHook(el, binding, vnode, prevVNode, 'updated')
  10698. },
  10699. }
  10700. function resolveDynamicModel(tagName, type) {
  10701. switch (tagName) {
  10702. case 'SELECT':
  10703. return vModelSelect
  10704. case 'TEXTAREA':
  10705. return vModelText
  10706. default:
  10707. switch (type) {
  10708. case 'checkbox':
  10709. return vModelCheckbox
  10710. case 'radio':
  10711. return vModelRadio
  10712. default:
  10713. return vModelText
  10714. }
  10715. }
  10716. }
  10717. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10718. const modelToUse = resolveDynamicModel(
  10719. el.tagName,
  10720. vnode.props && vnode.props.type,
  10721. )
  10722. const fn = modelToUse[hook]
  10723. fn && fn(el, binding, vnode, prevVNode)
  10724. }
  10725. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta']
  10726. const modifierGuards = {
  10727. stop: e => e.stopPropagation(),
  10728. prevent: e => e.preventDefault(),
  10729. self: e => e.target !== e.currentTarget,
  10730. ctrl: e => !e.ctrlKey,
  10731. shift: e => !e.shiftKey,
  10732. alt: e => !e.altKey,
  10733. meta: e => !e.metaKey,
  10734. left: e => 'button' in e && e.button !== 0,
  10735. middle: e => 'button' in e && e.button !== 1,
  10736. right: e => 'button' in e && e.button !== 2,
  10737. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m)),
  10738. }
  10739. function withModifiers(fn, modifiers) {
  10740. const cache = fn._withMods || (fn._withMods = {})
  10741. const cacheKey = modifiers.join('.')
  10742. return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
  10743. for (let i = 0; i < modifiers.length; i++) {
  10744. const guard = modifierGuards[modifiers[i]]
  10745. if (guard && guard(event, modifiers))
  10746. return
  10747. }
  10748. return fn(event, ...args)
  10749. })
  10750. }
  10751. const keyNames = {
  10752. esc: 'escape',
  10753. space: ' ',
  10754. up: 'arrow-up',
  10755. left: 'arrow-left',
  10756. right: 'arrow-right',
  10757. down: 'arrow-down',
  10758. delete: 'backspace',
  10759. }
  10760. function withKeys(fn, modifiers) {
  10761. const cache = fn._withKeys || (fn._withKeys = {})
  10762. const cacheKey = modifiers.join('.')
  10763. return cache[cacheKey] || (cache[cacheKey] = (event) => {
  10764. if (!('key' in event))
  10765. return
  10766. const eventKey = hyphenate(event.key)
  10767. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey))
  10768. return fn(event)
  10769. })
  10770. }
  10771. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps)
  10772. let renderer
  10773. let enabledHydration = false
  10774. function ensureRenderer() {
  10775. return renderer || (renderer = createRenderer(rendererOptions))
  10776. }
  10777. function ensureHydrationRenderer() {
  10778. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions)
  10779. enabledHydration = true
  10780. return renderer
  10781. }
  10782. function render(...args) {
  10783. ensureRenderer().render(...args)
  10784. }
  10785. function hydrate(...args) {
  10786. ensureHydrationRenderer().hydrate(...args)
  10787. }
  10788. function createApp(...args) {
  10789. const app = ensureRenderer().createApp(...args)
  10790. {
  10791. injectNativeTagCheck(app)
  10792. injectCompilerOptionsCheck(app)
  10793. }
  10794. const { mount } = app
  10795. app.mount = (containerOrSelector) => {
  10796. const container = normalizeContainer(containerOrSelector)
  10797. if (!container)
  10798. return
  10799. const component = app._component
  10800. if (!isFunction(component) && !component.render && !component.template)
  10801. component.template = container.innerHTML
  10802. container.innerHTML = ''
  10803. const proxy = mount(container, false, resolveRootNamespace(container))
  10804. if (container instanceof Element) {
  10805. container.removeAttribute('v-cloak')
  10806. container.setAttribute('data-v-app', '')
  10807. }
  10808. return proxy
  10809. }
  10810. return app
  10811. }
  10812. function createSSRApp(...args) {
  10813. const app = ensureHydrationRenderer().createApp(...args)
  10814. {
  10815. injectNativeTagCheck(app)
  10816. injectCompilerOptionsCheck(app)
  10817. }
  10818. const { mount } = app
  10819. app.mount = (containerOrSelector) => {
  10820. const container = normalizeContainer(containerOrSelector)
  10821. if (container)
  10822. return mount(container, true, resolveRootNamespace(container))
  10823. }
  10824. return app
  10825. }
  10826. function resolveRootNamespace(container) {
  10827. if (container instanceof SVGElement)
  10828. return 'svg'
  10829. if (typeof MathMLElement === 'function' && container instanceof MathMLElement)
  10830. return 'mathml'
  10831. }
  10832. function injectNativeTagCheck(app) {
  10833. Object.defineProperty(app.config, 'isNativeTag', {
  10834. value: tag => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  10835. writable: false,
  10836. })
  10837. }
  10838. function injectCompilerOptionsCheck(app) {
  10839. if (isRuntimeOnly()) {
  10840. const isCustomElement = app.config.isCustomElement
  10841. Object.defineProperty(app.config, 'isCustomElement', {
  10842. get() {
  10843. return isCustomElement
  10844. },
  10845. set() {
  10846. warn(
  10847. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`,
  10848. )
  10849. },
  10850. })
  10851. const compilerOptions = app.config.compilerOptions
  10852. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  10853. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  10854. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  10855. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`
  10856. Object.defineProperty(app.config, 'compilerOptions', {
  10857. get() {
  10858. warn(msg)
  10859. return compilerOptions
  10860. },
  10861. set() {
  10862. warn(msg)
  10863. },
  10864. })
  10865. }
  10866. }
  10867. function normalizeContainer(container) {
  10868. if (isString(container)) {
  10869. const res = document.querySelector(container)
  10870. if (!res) {
  10871. warn(
  10872. `Failed to mount app: mount target selector "${container}" returned null.`,
  10873. )
  10874. }
  10875. return res
  10876. }
  10877. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === 'closed') {
  10878. warn(
  10879. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`,
  10880. )
  10881. }
  10882. return container
  10883. }
  10884. const initDirectivesForSSR = NOOP
  10885. function initDev() {
  10886. {
  10887. {
  10888. console.info(
  10889. `You are running a development build of Vue.
  10890. Make sure to use the production build (*.prod.js) when deploying for production.`,
  10891. )
  10892. }
  10893. initCustomFormatter()
  10894. }
  10895. }
  10896. {
  10897. initDev()
  10898. }
  10899. function compile() {
  10900. {
  10901. warn(
  10902. `Runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.`),
  10903. )
  10904. }
  10905. }
  10906. export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId }