!function(A,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/quick-favorite"]=t():A["video/quick-favorite"]=t()}(self,(function(){return function(){var A,t,e={693:function(A,t,e){var i=e(645)((function(A){return A[1]}));i.push([A.id,'@charset "UTF-8";\n@font-face {\n font-family: "quick-favorite";\n src: url("data:application/x-font-ttf;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzJAIEqwAAABjAAAAFZjbWFw6ynBrQAAAewAAAFwZ2x5ZnI4GW4AAANkAAABDGhlYWQYiH0gAAAA4AAAADZoaGVhB4sD6wAAALwAAAAkaG10eAPoAAAAAAHkAAAACGxvY2EAhgAAAAADXAAAAAZtYXhwAQ8AZAAAARgAAAAgbmFtZa2yT/oAAARwAAACXnBvc3QnqNOhAAAG0AAAAD0AAQAAA+gAAAAAA+gAAAAAA6IAAQAAAAAAAAAAAAAAAAAAAAIAAQAAAAEAAOxSVapfDzz1AAsD6AAAAADa5Bw+AAAAANrkHD4AAAAAA6IDvwAAAAgAAgAAAAAAAAABAAAAAgBYAAMAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAEB9AGQAAUAAAJ6ArwAAACMAnoCvAAAAeAAMQECAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAQOoB6gED6AAAAFoD6AAAAAAAAQAAAAAAAAAAAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAVQAAQAAAAAATgADAAEAAAAsAAMACgAAAVQABAAiAAAABAAEAAEAAOoB//8AAOoB//8AAAABAAQAAAABAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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vamVjdC5odHRwOi8vZm9udGVsbG8uY29tAHEAdQBpAGMAawAtAGYAYQB2AG8AcgBpAHQAZQBSAGUAZwB1AGwAYQByAHEAdQBpAGMAawAtAGYAYQB2AG8AcgBpAHQAZQBxAHUAaQBjAGsALQBmAGEAdgBvAHIAaQB0AGUAVgBlAHIAcwBpAG8AbgAgADEALgAwAHEAdQBpAGMAawAtAGYAYQB2AG8AcgBpAHQAZQBHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBAgEDABNxdWljay1mYXZvcml0ZV9fXyAxAAAAAAA=");\n}\n.video-toolbar .ops .quick-favorite {\n margin-right: 28px !important;\n position: relative;\n font-size: 0;\n font-size: 14px;\n width: auto !important;\n}\n.video-toolbar .ops .quick-favorite .text {\n display: inline;\n}\n@media screen and (max-width: 1320px), (max-height: 750px) {\n.video-toolbar .ops .quick-favorite {\n margin-right: max(calc(min(11vw, 11vh) - 117.2px), 6px) !important;\n}\n.video-toolbar .ops .quick-favorite .text {\n display: none;\n}\n}\n.video-toolbar .ops .quick-favorite-icon {\n font-family: "quick-favorite" !important;\n display: inline-block;\n font-style: normal;\n text-align: center;\n text-transform: none;\n line-height: 1;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n}\n.video-toolbar .ops .quick-favorite-icon:after {\n content: "";\n}\n.video-toolbar .ops .quick-favorite .tip,\n.video-toolbar .ops .quick-favorite .select-list,\n.video-toolbar .ops .quick-favorite .lists-tip {\n line-height: normal;\n position: absolute;\n top: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n z-index: 1000;\n background: rgba(0,0,0,0.86667);\n padding: 4px 8px;\n border-radius: 4px;\n color: #eee;\n transition: all 0.2s ease-out;\n opacity: 0;\n pointer-events: none;\n}\n.video-toolbar .ops .quick-favorite .tip.show,\n.video-toolbar .ops .quick-favorite .select-list.show,\n.video-toolbar .ops .quick-favorite .lists-tip.show {\n opacity: 1;\n pointer-events: initial;\n}\n.video-toolbar .ops .quick-favorite .tip {\n padding: 8px;\n}\n.video-toolbar .ops .quick-favorite .lists-tip {\n top: calc(100% + 8px + 42px);\n color: #ccc;\n font-size: 12px;\n z-index: 100;\n}\n.video-toolbar .ops .quick-favorite .select-list {\n display: flex;\n align-items: center;\n}\n.video-toolbar .ops .quick-favorite .select-list > * {\n white-space: nowrap;\n}\n.video-toolbar .ops .quick-favorite .select-list .lists-loading {\n padding: 4px 32px;\n}\n.video-toolbar .ops .quick-favorite .select-list .lists {\n margin-left: 8px;\n}',""]),A.exports=i},645:function(A){"use strict"; // eslint-disable-next-line func-names A.exports=function(A){var t=[];return t.toString=function(){return this.map((function(t){var e=A(t);return t[2]?"@media ".concat(t[2]," {").concat(e,"}"):e})).join("")}, // eslint-disable-next-line func-names t.i=function(A,e,i){"string"==typeof A&&( // eslint-disable-next-line no-param-reassign A=[[null,A,""]]);var n={};if(i)for(var o=0;o({aid:unsafeWindow.aid,favoriteTitle:"",isFavorite:!1,tipText:"",tipShowing:!1,tipHandle:0,lists:[],selectedFavorite:"<未选择>",listShowing:!1}),watch:{selectedFavorite(A){if(0===this.lists.length)return;const{lists:t}=this,e=t.find((t=>t.title===A));e?(l.favoriteFolderID=e.id,this.syncFavoriteState()):console.error("list not found in selectedFavorite(value)")},async listShowing(A){if(A&&(document.addEventListener("click",(A=>{const t=this.$el,e=A.target;e===t||t.contains(e)||(this.listShowing=!1)})),0===this.lists.length))try{const A=await(0,o.getJsonWithCredentials)(`https://api.bilibili.com/medialist/gateway/base/created?pn=1&ps=100&up_mid=${(0,r.getUID)()}&is_space=0`);if(0!==A.code)throw new Error(`获取收藏夹列表失败: ${A.message}`);this.lists=lodash.get(A,"data.list",[])}catch(A){(0,a.logError)(A)}}},created(){this.syncFavoriteState()},methods:{async syncFavoriteState(){if(0!==l.favoriteFolderID)try{const A=await(0,o.getJsonWithCredentials)(`https://api.bilibili.com/x/v3/fav/folder/created/list-all?type=2&rid=${this.aid}&up_mid=${(0,r.getUID)()}`);if(0!==A.code)throw new Error(`获取收藏状态失败: ${A.message}`);const t=lodash.get(A,"data.list",[]).find((A=>A.id===l.favoriteFolderID));if(void 0===t)return void(l.favoriteFolderID=0);this.isFavorite=Boolean(t.fav_state),this.favoriteTitle=t.title,this.selectedFavorite=t.title}catch(A){(0,a.logError)(A)}},showTip(A){this.tipText=A,this.tipShowing=!0,this.tipHandle&&clearTimeout(this.tipHandle),this.tipHandle=setTimeout((()=>{this.tipShowing=!1}),2e3)},async toggle(){if(0===l.favoriteFolderID)return void(this.listShowing=!0);const A={rid:this.aid,type:2,add_media_ids:"",del_media_ids:"",csrf:(0,r.getCsrf)()};A[this.isFavorite?"del_media_ids":"add_media_ids"]=l.favoriteFolderID.toString();try{await(0,o.postTextWithCredentials)("https://api.bilibili.com/x/v3/fav/resource/deal",Object.entries(A).map((([A,t])=>`${A}=${t}`)).join("&")),this.isFavorite=!this.isFavorite,this.showTip(this.isFavorite?`已添加至收藏夹: ${this.favoriteTitle}`:`已移出收藏夹: ${this.favoriteTitle}`)}catch(A){s.Toast.error(`快速收藏失败: ${A.message}`,"快速收藏"),console.error(A)}}}}),u=e(379),f=e.n(u),p=e(693),v=e.n(p),g={insert:"head",singleton:!1};f()(v(),g),v().locals;var h=function(A,t,e,i,n,o,r,a){var s,c="function"==typeof A?A.options:A;if(t&&(c.render=t,c.staticRenderFns=e,c._compiled=!0),i&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),r?(s=function(A){(A=A||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(A=__VUE_SSR_CONTEXT__),n&&n.call(this,A),A&&A._registeredComponents&&A._registeredComponents.add(r)},c._ssrRegister=s):n&&(s=a?function(){n.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:n),s)if(c.functional){c._injectStyles=s;var l=c.render;c.render=function(A,t){return s.call(t),l(A,t)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,s):[s]}return{exports:A,options:c}}(d,i,[],!1,null,null,null);h.options.__file="registry/lib/components/video/quick-favorite/QuickFavorite.vue";var m=h.exports},156:function(A){"use strict";A.exports=coreApis.observer},109:function(A){"use strict";A.exports=coreApis.utils}},i={};function n(A){var t=i[A];if(void 0!==t)return t.exports;var o=i[A]={id:A,exports:{}};return e[A](o,o.exports,n),o.exports}n.n=function(A){var t=A&&A.__esModule?function(){return A.default}:function(){return A};return n.d(t,{a:t}),t},t=Object.getPrototypeOf?function(A){return Object.getPrototypeOf(A)}:function(A){return A.__proto__},n.t=function(e,i){if(1&i&&(e=this(e)),8&i)return e;if("object"==typeof e&&e){if(4&i&&e.__esModule)return e;if(16&i&&"function"==typeof e.then)return e}var o=Object.create(null);n.r(o);var r={};A=A||[null,t({}),t([]),t(t)];for(var a=2&i&&e;"object"==typeof a&&!~A.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((function(A){r[A]=function(){return e[A]}}));return r.default=function(){return e},n.d(o,r),o},n.d=function(A,t){for(var e in t)n.o(t,e)&&!n.o(A,e)&&Object.defineProperty(A,e,{enumerable:!0,get:t[e]})},n.o=function(A,t){return Object.prototype.hasOwnProperty.call(A,t)},n.r=function(A){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})};var o={};return function(){"use strict";n.d(o,{component:function(){return t}});var A=coreApis.utils.urls;const t={name:"quickFavorite",displayName:"启用快速收藏",description:{"zh-CN":"启用快速收藏, 在视频页面可以一键收藏到设定的某个收藏夹."},entry:async()=>{const{playerReady:A,mountVueComponent:t,getUID:e}=await Promise.resolve().then(n.t.bind(n,109,23));if(!e())return;await A();const i=dq(".video-toolbar .ops .collect");if(!i)return;const o=await Promise.resolve().then(n.bind(n,301));let r;const{videoChange:a}=await Promise.resolve().then(n.t.bind(n,156,23));a((()=>{r||(r=t(o),i.insertAdjacentElement("afterend",r.$el)),r.aid=unsafeWindow.aid,r.syncFavoriteState()}))},unload:()=>{dqa(".ops .quick-favorite").forEach((A=>A.style.display="none"))},reload:()=>{dqa(".ops .quick-favorite").forEach((A=>A.style.display="inline-block"))},urlInclude:A.videoUrls,urlExclude:A.favoriteListUrls,tags:[componentsTags.video],options:{favoriteFolderID:{defaultValue:0,displayName:"快速收藏夹ID",hidden:!0}},plugin:{displayName:"快速收藏 - 快捷键支持",setup:({addData:A})=>{A("keymap.actions",(A=>{A.quickFavorite={displayName:"快速收藏",run:A=>{const{clickElement:t}=A;return t(".quick-favorite",A)}}})),A("keymap.presets",(A=>{A.quickFavorite="shift s"}))}}}}(),o=o.component}()}));