【仅供测试】

https://microsoftedge.microsoft.com/addons/detail/%E7%AF%A1%E6%94%B9%E7%8C%B4/iikmkjmpaadaobahmlepeloendndfphd
测试网站:
https://www.alipan.com/s/tJ5uzFvp2aF




// ==UserScript==
// @name         阿里云盘助手
// @namespace    http://tampermonkey.net/
// @version      2.1.6
// @description  支持生成文件下载链接、修改文件后缀,支持第三方播放器Artplayer(突破视频2分钟限制,长按倍速,选集,历史播放)
// @license      MIT
// @icon         https://img.alicdn.com/imgextra/i1/O1CN01JDQCi21Dc8EfbRwvF_!!6000000000236-73-tps-64-64.ico
// @match        https://www.aliyundrive.com/*
// @match        https://www.alipan.com/*
// @require      https://cdn.bootcdn.net/ajax/libs/vue/3.2.47/vue.global.min.js
// @require      data:application/javascript,window.Vue%3DVue%3B
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/axios/1.3.4/axios.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/hls.js/1.3.3/hls.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/artplayer/4.6.2/artplayer.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.32/index.full.min.js
// @resource     element-plus/dist/index.css  https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.32/index.min.css
// @grant        GM_getResourceText
// @grant        unsafeWindow
// ==/UserScript==
 
(t=>{const e=document.createElement("style");e.dataset.source="vite-plugin-monkey",e.innerText=t,document.head.appendChild(e)})(".icon-wrapper--3dbbo[data-v-e5d83ee0]{height:28px;width:28px;display:-ms-flexbox;display:flex;border-radius:5px;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;color:var(--context_secondary);position:absolute;top:18px;right:16px;-webkit-transition:all .3s ease;-o-transition:all .3s ease;transition:all .3s ease;cursor:pointer;z-index:10}.notice2[data-v-e5d83ee0]{margin:2px 0 0;color:red;font-size:8pt}.close-icon--33bP0[data-v-e5d83ee0]{font-size:18px}.icon--d-ejA[data-v-e5d83ee0]{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;text-align:center}.content-wrapper--1_WJv[data-v-e5d83ee0]{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center}.notice[data-v-afdd0eed]{color:#6592f9;font-size:10pt}.notice1[data-v-afdd0eed]{margin:2px 0 0;color:#e6a23c;font-size:8pt}.notice2[data-v-afdd0eed]{margin:2px 0 0;color:red;font-size:8pt}.footer[data-v-afdd0eed]{height:68px;background:var(--background_secondary_blur);-webkit-backdrop-filter:blur(30px);backdrop-filter:blur(30px);margin:-20px;padding:0 20px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;border-radius:0 0 10px 10px}.notice1[data-v-d892bc01]{margin:2px 0 0;color:#e6a23c;font-size:8pt}.breadcrumb-item--tV9dn[data-v-d892bc01]{font-size:12px}.td--SGrZj[data-v-d892bc01]{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-negative:0;flex-shrink:0;height:52px;position:relative}.td---v-kp[data-v-d892bc01]{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-negative:0;flex-shrink:0;padding:0 24px}.cover--Mn1Bt[data-v-d892bc01]{margin-right:20px}.folder-cover--ExDmp[data-v-d892bc01]{position:relative;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0}.folder-cover--ExDmp[data-size=XXS][data-v-d892bc01],.folder-cover--ExDmp[data-size=XXS] .fileicon--Ob-Oj[data-v-d892bc01]{width:28px;height:28px}.fileicon---webs[data-v-d892bc01]{max-width:100%;max-height:100%}.breadcrumb-wrap--Uq5Lb[data-v-d892bc01]{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:16px;line-height:1.4;width:100%;overflow:hidden;position:relative}.breadcrumb-wrap--Uq5Lb[data-align=left][data-v-d892bc01]{-ms-flex-pack:start;justify-content:flex-start}.breadcrumb-wrap--Uq5Lb .breadcrumb--gnRPG[data-v-d892bc01]{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-width:24px}.breadcrumb-item--j8J5H[data-v-d892bc01]{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;white-space:nowrap;color:var(--context_tertiary);cursor:pointer}.breadcrumb-item--j8J5H:first-child .breadcrumb-item-link--9zcQY[data-v-d892bc01]{font-weight:500}.breadcrumb-item--j8J5H .breadcrumb-item-link--9zcQY[data-v-d892bc01]{font-weight:400;line-height:1.4;-webkit-transition:all .3s ease;-o-transition:all .3s ease;transition:all .3s ease}.breadcrumb-item--j8J5H .breadcrumb-item-separator--MnbFV[data-v-d892bc01]{line-height:1.4;margin:0 8px}.card[data-v-d200ca3c]{margin-bottom:10px}.player[data-v-ee523f38]{display:flex;height:100%;align-items:center;justify-content:center;flex-direction:column}.notice[data-v-46fc6531]{color:#6592f9;font-size:8pt}.notice2[data-v-46fc6531]{color:red;font-size:8pt}.notice[data-v-4f08e60f]{color:#6592f9;font-size:10pt}.notice1[data-v-4f08e60f]{margin:2px 0 0;color:#e6a23c;font-size:8pt}.notice2[data-v-4f08e60f]{margin:2px 0 0;color:red;font-size:8pt}.footer[data-v-4f08e60f]{height:68px;background:var(--background_secondary_blur);-webkit-backdrop-filter:blur(30px);backdrop-filter:blur(30px);margin:-20px;padding:0 20px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;border-radius:0 0 10px 10px}");
 
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
(function(elementPlus, $2, axios2, vue, Hls2, Artplayer2) {
  "use strict";
  var monkeyWindow = window;
  var unsafeWindow = /* @__PURE__ */ (() => {
    return monkeyWindow.unsafeWindow;
  })();
  var message = null;
  let showMessge = function(option) {
    try {
      message.close();
    } catch {
    }
    message = elementPlus.ElMessage(option);
  };
  let showError$1 = function(msg, timeout, option) {
    showMessge({
      message: msg,
      type: "error",
      duration: timeout || 3e3,
      ...option
    });
  };
  let showSuccess = function(msg, timeout, option) {
    showMessge({
      message: msg,
      type: "success",
      duration: timeout || 3e3,
      ...option
    });
  };
  let showDiv = function(title2, app) {
    function format(s2, c) {
      return s2.replace(/{(\w+)}/g, function(m, p) {
        return c[p];
      });
    }
    let html2 = '<div class="ant-modal-root ant-modal-Link"><div class="ant-modal-mask"></div><div tabindex="-1" class="ant-modal-wrap" role="dialog"><div role="document" class="ant-modal modal-wrapper--5SA7y" style="width: 666px;"><div class="ant-modal-content"><div class="ant-modal-header"><div class="ant-modal-title" id="rcDialogTitle1">{title}</div></div><div class="ant-modal-body"><div class="icon-wrapper--TbIdu"><span data-role="icon" data-render-as="svg" data-icon-type="PDSClose" class="close-icon--KF5OX icon--D3kMk  "><svg viewBox="0 0 1024 1024"><use xlink:href="#PDSClose"></use></svg></span></div>';
    html2 = format(html2, {
      title: title2
    });
    html2 += "</div></div></div></div></div></div>";
    $2("body").append(html2);
    app.mount(
      (() => {
        const app2 = document.createElement("div");
        $2(".ant-modal-body").append(app2);
        return app2;
      })()
    );
    $2(".ant-modal-Link .icon-wrapper--TbIdu").one("click", function() {
      $2(".ant-modal-Link").remove();
      app.unmount();
    });
    $2(".ant-modal-Link .ant-modal-wrap").on("click", function(event) {
      if ($2(event.target).closest(".ant-modal-content").length === 0) {
        $2(".ant-modal-Link").remove();
        app.unmount();
      }
    });
  };
  let showShareDiv = function(title2, app) {
    function format(s2, c) {
      return s2.replace(/{(\w+)}/g, function(m, p) {
        return c[p];
      });
    }
    let html2 = `
    <div class="ant-modal-root ant-modal-Link">
  <div class="ant-modal-mask">
  </div>
  <div tabindex="-1" class="ant-modal-wrap" role="dialog">
    <div role="document" class="ant-modal modal-wrapper--5SA7y" style="width: 666px;">
      <div class="ant-modal-content" >
        <div class="ant-modal-header">
          <div class="ant-modal-title" id="rcDialogTitle1" >{title}</div>
        </div>
        <div class="ant-modal-body">
          <div class="icon-wrapper--TbIdu" style="height:28px;width:28px;display:-ms-flexbox;display:flex;border-radius:5px;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;color:var(--context_secondary);position:absolute;top:18px;right:16px;-webkit-transition:all .3s ease;-o-transition:all .3s ease;transition:all .3s ease;cursor:pointer;z-index:10;" data-spm-anchor-id="aliyundrive.file_file_sharing.0.i2.39733575IlF5dn">
           <img src="https://img.alicdn.com/imgextra/i1/O1CN01Q2sMej1EoKIosKJLA_!!6000000000398-2-tps-56-56.png" width="28" height="28" style="margin: 0px 14px 7px 0px; align-self: flex-end; cursor: pointer;" data-spm-anchor-id="aliyundrive.file_file_sharing.0.i3.39733575eJqbVb" />
          </div>
    `;
    html2 = format(html2, {
      title: title2
    });
    html2 += "</div></div></div></div></div></div>";
    $2("body").append(html2);
    app.mount(
      (() => {
        const app2 = document.createElement("div");
        $2(".ant-modal-body").append(app2);
        return app2;
      })()
    );
    $2(".ant-modal-Link .icon-wrapper--TbIdu").one("click", function() {
      $2(".ant-modal-Link").remove();
      app.unmount();
    });
    $2(".ant-modal-Link .ant-modal-wrap").on("click", function(event) {
      if ($2(event.target).closest(".ant-modal-content").length === 0) {
        $2(".ant-modal-Link").remove();
        app.unmount();
      }
    });
  };
  class Store {
    constructor() {
      this.prefix = "LGZS_";
    }
    getAliyun(key2 = "") {
      let item = localStorage.getItem(key2);
      if (!item) {
        return "";
      }
      try {
        return JSON.parse(item);
      } catch (e) {
        return item;
      }
    }
    getItem(key2 = "") {
      return this.getAliyun(this.prefix + key2);
    }
    setItem(key2 = "", value) {
      localStorage.setItem(this.prefix + key2, value instanceof Object ? JSON.stringify(value) : value);
    }
    removeItem(key2) {
      if (key2 == null || key2 == "") {
        return;
      }
      localStorage.removeItem(this.prefix + key2);
    }
  }
  const store = new Store();
  const getDownloadUrl = (data) => axios2.post("/v2/file/get_download_url", data, {
    headers: {
      "x-canary": "client=web,app=adrive,version=v4.2.0"
    }
  });
  const search = (data) => axios2.post("/adrive/v3/file/search", data, {
    headers: {
      "x-canary": "client=web,app=adrive,version=v4.2.0"
    }
  });
  const videoUpdate = (data) => axios2.post("/adrive/v2/video/update", data);
  const deviceLogout = () => axios2.post("/users/v1/users/device_logout", {});
  const homeWidgets = () => axios2.post("/apps/v1/users/home/widgets", { "context": { "recentUsed": { "limit": 20 }, "recentSaved": { "limit": 1 } } });
  const shareVideoInfo = (fileId, share_id, shareToken) => axios2({
    method: "post",
    url: "/v2/file/get_share_link_video_preview_play_info",
    data: {
      category: "live_transcoding",
      file_id: fileId,
      get_preview_url: true,
      share_id,
      template_id: "",
      get_subtitle_info: true
    },
    headers: {
      "content-type": "application/json;charset=UTF-8",
      "x-share-token": shareToken
    }
  });
  const videoPreviewPlayInfo = (data) => axios2.post("/v2/file/get_video_preview_play_info", data);
  const shareLinkDownloadUrl = (data, shareToken) => axios2({
    method: "post",
    url: "/v2/file/get_share_link_download_url",
    data: {
      ...data
    },
    headers: {
      "content-type": "application/json;charset=UTF-8",
      "x-share-token": shareToken,
      "_token": false
    }
  });
  const createSessionUrl = (data, signature2, deviceId) => axios2({
    method: "post",
    url: "/users/v1/users/device/create_session",
    data: {
      ...data
    },
    headers: {
      "content-type": "application/json;charset=UTF-8",
      "x-canary": "client=web,app=adrive,version=v3.17.0",
      "_token": false,
      "x-signature": signature2,
      "x-device-id": deviceId
    }
  });
  const signInList = () => axios2({
    method: "post",
    url: "https://member.aliyundrive.com/v1/activity/sign_in_list",
    data: {
      "_rx-s": "mobile"
    },
    headers: {
      "content-type": "application/json;charset=UTF-8",
      "_token": false
    }
  });
  const signInReward = (signInDay) => axios2({
    method: "post",
    url: "https://member.aliyundrive.com/v1/activity/sign_in_reward",
    data: {
      "signInDay": signInDay
    },
    headers: {
      "content-type": "application/json;charset=UTF-8",
      "_token": false
    }
  });
  function copy(obj) {
    if (typeof obj !== "object" || obj == null) {
      return;
    }
    var newobj = obj.constructor === Array ? [] : {};
    for (var i2 in obj) {
      newobj[i2] = typeof obj[i2] === "object" ? copy(obj[i2]) : obj[i2];
    }
    return newobj;
  }
  class User {
    constructor() {
      this.is_login = false;
      this.vip_status = 0;
      this.mid = "";
      this.uname = "";
      this.has_init = false;
      this.page = {
        id: "",
        order: "",
        order_by: "",
        // 当前路径文件夹名称
        folderName: "",
        items: []
      };
      this.video = {
        id: "",
        // 时长
        duration: "",
        // 播放的时长
        play_cursor: "",
        // 视频名称
        name: "",
        thumbnail: "",
        // 0 首页自己的视频 1分享的视频
        type: -1,
        //当前视频所在的文件夹名称
        folderName: "",
        //跳转地址
        href: "",
        drive_id: ""
      };
    }
    getVideoPage() {
      return this.video;
    }
    /**
     * 获取自动签到设置
     * 
     */
    getSignInSet() {
      let config = store.getItem("signIn_config");
      return config == "" ? {} : config;
    }
    setSignInSet(signInInfo) {
      return store.setItem("signIn_config", signInInfo);
    }
    //保存当前播放器设置
    saveVideoPlayerSet(art) {
      let playerSet = {
        // 全屏
        fullscreen: art.fullscreen,
        //网页全屏
        fullscreenWeb: art.fullscreenWeb,
        // 播放速度
        playbackRate: art.playbackRate,
        // 清晰度
        qualityHtml: art.qualityHtml,
        //字幕大小
        subtitleSize: art.subtitleSize || 20,
        //字幕间距
        subtitleMargin: art.subtitleMargin || 0,
        //字幕偏移
        subtitleOffset: art.subtitleOffset || 0,
        //字幕颜色
        subtitleColor: art.subtitleColor || "#FFF"
      };
      store.setItem("playerSet", playerSet);
    }
    // 获取播放器设置页面
    getVideoPlayerSet() {
      let playerSet = store.getItem("playerSet");
      if (playerSet == "") {
        playerSet = {};
      }
      return playerSet;
    }
    // 查看用户是否已经同意 或者 配置了 获取session 所需要的浏览器名称
    isConfigSession() {
      let deviceName = store.getItem("deviceName");
      let modelName = store.getItem("modelName");
      return !(deviceName == "" || modelName == "");
    }
    // 保存视频信息
    saveVideoInfo(id, name2, progress, folderName, href, share2, play_cursor) {
      let videoInfo = {
        "category": "video",
        "name": name2,
        "progress": progress,
        "id": id,
        "folderName": folderName,
        "href": href,
        "share": share2,
        "play_cursor": play_cursor
      };
      let list = store.getItem("historyVideo");
      if (list == "") {
        list = [];
      }
      let newList = [videoInfo];
      list.forEach(function(item, index) {
        if (item.id !== id && newList.length <= 5) {
          newList.push(item);
        }
      });
      store.setItem("historyVideo", newList);
    }
    clearSession() {
      store.removeItem("LG_session");
      store.removeItem("LG_session_Ref");
      store.removeItem("x-device-id");
      store.removeItem("x-signature");
      store.removeItem("deviceName");
      store.removeItem("modelName");
      store.removeItem("signIn_config");
    }
    removeSession() {
      store.removeItem("LG_session");
    }
    clearAll() {
      user.clearSession();
      user.clearVideoHistory();
    }
    clearVideoHistory() {
      store.removeItem("historyVideo");
    }
    //获取视频历史列表
    getVideoLookList() {
      let historyVideo = store.getItem("historyVideo");
      if (historyVideo == "") {
        historyVideo = [];
      }
      return historyVideo;
    }
    getDeviceId() {
      return store.getItem("x-device-id");
    }
    getSignature() {
      return store.getItem("x-signature");
    }
    getPage() {
      var page = this.page;
      if (!page.items) {
        page.items = [];
      }
      return page;
    }
    getAria2Set() {
      let aria2Set = store.getItem("Aria2Set");
      if (aria2Set == "") {
        aria2Set = {
          link: "http://localhost:6800/jsonrpc",
          path: "D:/aliyundriveDownloads",
          token: "",
          dirCreate: false
        };
      }
      return aria2Set;
    }
    getVideoSet() {
      let videoSet = store.getItem("VideoSet");
      if (videoSet == "") {
        videoSet = {
          quality: null
        };
      }
      return videoSet;
    }
    setVideoSet(videoSet) {
      store.setItem("VideoSet", videoSet);
    }
    setAria2Set(aria2Set) {
      store.setItem("Aria2Set", aria2Set);
    }
    refSession() {
      let now = new Date().getTime();
      let time = store.getItem("LG_session") || 0;
      let token = user.getToken();
      if (token == null) {
        showError$1("获取当前凭证失败,请刷新或重新登录");
        return;
      } else if (!user.isExpires(token)) {
        showError$1("Token已失效,请刷新或重新登录");
        return;
      }
      let d = user.getDeviceId();
      let s2 = user.getSignature();
      if (now - time > 18e4 && token.user_id || d == "" || s2 == "") {
        store.setItem("LG_session", now);
        store.setItem("LG_session_Ref", "true");
      } else {
        console.log("未到刷新时间或者时机");
        return;
      }
      user.session(token, function(a, b) {
        store.setItem("LG_session", new Date().getTime());
        store.removeItem("LG_session_Ref");
      });
    }
    session(token, callback) {
      if (token == null) {
        showError$1("刷新Session失败,token为空,请刷新或重新登录");
        return {};
      }
      return new Promise((resolve, reject) => {
        let deviceId = store.getAliyun("__ETAG__CNA__ID__");
        if (deviceId == "") {
          deviceId = token.user_id.split("").reverse().join("").substring(0, 20);
        }
        let userId = token.user_id;
        unsafeWindow.luoGenSession(function(key2, pubStr, signature2, nd) {
          deviceId = nd;
          console.log("你好,罗根!");
          let deviceName = store.getItem("deviceName");
          let modelName = store.getItem("modelName");
          createSessionUrl({
            "deviceName": deviceName,
            "modelName": modelName,
            "refreshToken": "71a164a40eb84a40b35c1a39d2023499",
            "pubKey": pubStr
          }, signature2, deviceId).then((res) => {
            if (!res.data.result) {
              user.clearSession();
              showError$1("设备超限,请下线其他设备,在刷新页面");
              elementPlus.ElMessageBox.alert("请点击左下角退出登陆那个菜单,点击登陆设备管理,下线其他设备。然后刷新页面", "设备超限", {
                confirmButtonText: "好的",
                callback: (action) => {
                }
              });
              return;
            }
            store.setItem("x-device-id", deviceId);
            store.setItem("x-signature", signature2);
            resolve({
              deviceId,
              signature: signature2
            });
            callback && callback(pubStr, signature2);
          }).catch((e) => {
            console.error("出现异常了...", e);
            user.clearSession();
            elementPlus.ElMessageBox.alert(e + "", "刷新session失败", {
              confirmButtonText: "刷新试一试",
              callback: (action) => {
                location.href = location.href;
              }
            });
            reject(e);
          });
        }, window.atob("NWRkZTRlMWJkZjllNDk2NmIzODdiYTU4ZjRiM2ZkYzM="), deviceId, userId);
      });
    }
    /**
     * 是否在首页
     */
    home() {
      return location.href.indexOf("/drive/file") > 0;
    }
    /**
     * 是否在资源库
     */
    resource() {
      return location.href.indexOf("/drive/file/resource") > 0;
    }
    // 没过期返回true 过期 false
    isExpires(item) {
      if (item == null || !item.expire_time) {
        return false;
      }
      let time = Date.parse(item.expire_time) - Date.now();
      return time > 0;
    }
    getShareToken() {
      return store.getAliyun("shareToken");
    }
    getToken() {
      let token = localStorage.getItem(`token`);
      if (token != null) {
        return JSON.parse(token);
      }
      return token;
    }
    // 获取当前页面上所有的文件
    getAllFileList() {
      let fileList2 = this.getPage().items;
      if (fileList2.length === 0) {
        console.error("获取文件列表失败");
        return [];
      }
      return copy(fileList2);
    }
    // 获取已选择的文件
    selectedFileList() {
      let jq = $2;
      let selectedFileList = [], fileList2 = this.getAllFileList();
      if (fileList2.length === 0) {
        console.error("获取文件列表失败");
        return [];
      }
      let node = "";
      if (jq(".tbody--Na444  .tr--Ogi-3.tr--97U9T").length) {
        node = jq(".tbody--Na444  .tr--Ogi-3.tr--97U9T");
      } else if (jq(".outer-wrapper--JCodp").length) {
        node = jq(".outer-wrapper--JCodp");
      }
      node.each(function(index) {
        var $this = jq(node[index]);
        if ($this.attr("data-is-selected") === "true") {
          let data_index = $this.closest("[data-index]").attr("data-index");
          data_index && selectedFileList.push(fileList2[data_index]);
        }
      });
      return copy(selectedFileList);
    }
  }
  const user = new User();
  /*! Element Plus Icons Vue v2.0.10 */
  var export_helper_default = (sfc, props) => {
    let target = sfc.__vccOpts || sfc;
    for (let [key2, val] of props)
      target[key2] = val;
    return target;
  };
  var refresh_vue_vue_type_script_lang_default = {
    name: "Refresh"
  };
  var _hoisted_1217 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2217 = /* @__PURE__ */ vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M771.776 794.88A384 384 0 0 1 128 512h64a320 320 0 0 0 555.712 216.448H654.72a32 32 0 1 1 0-64h149.056a32 32 0 0 1 32 32v148.928a32 32 0 1 1-64 0v-50.56zM276.288 295.616h92.992a32 32 0 0 1 0 64H220.16a32 32 0 0 1-32-32V178.56a32 32 0 0 1 64 0v50.56A384 384 0 0 1 896.128 512h-64a320 320 0 0 0-555.776-216.384z"
  }, null, -1), _hoisted_3216 = [
    _hoisted_2217
  ];
  function _sfc_render217(_ctx, _cache, $props, $setup, $data, $options) {
    return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1217, _hoisted_3216);
  }
  var refresh_default = /* @__PURE__ */ export_helper_default(refresh_vue_vue_type_script_lang_default, [["render", _sfc_render217], ["__file", "refresh.vue"]]);
  const cssLoader = (e) => {
    const t2 = GM_getResourceText(e), o = document.createElement("style");
    return o.innerText = t2, document.head.append(o), t2;
  };
  cssLoader("element-plus/dist/index.css");
  const Aria2Set_vue_vue_type_style_index_0_scoped_e5d83ee0_lang = "";
  const _export_sfc = (sfc, props) => {
    const target = sfc.__vccOpts || sfc;
    for (const [key2, val] of props) {
      target[key2] = val;
    }
    return target;
  };
  const _withScopeId$4 = (n) => (vue.pushScopeId("data-v-e5d83ee0"), n = n(), vue.popScopeId(), n);
  const _hoisted_1$6 = {
    key: 0,
    class: "ant-modal-root",
    id: "aria2-set-box"
  };
  const _hoisted_2$5 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "ant-modal-mask" }, null, -1));
  const _hoisted_3$5 = {
    tabindex: "-1",
    class: "ant-modal-wrap",
    role: "dialog",
    id: "aria2_set_LuoGen"
  };
  const _hoisted_4$5 = {
    role: "document",
    class: "ant-modal modal-wrapper--2yJKO",
    style: { "width": "340px", "transform-origin": "-14px 195px" }
  };
  const _hoisted_5$5 = { class: "ant-modal-content" };
  const _hoisted_6$5 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "ant-modal-header" }, [
    /* @__PURE__ */ vue.createElementVNode("div", { class: "ant-modal-title" }, " Aria2设置 ")
  ], -1));
  const _hoisted_7$4 = { class: "ant-modal-body" };
  const _hoisted_8$4 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("span", {
    "data-role": "icon",
    "data-render-as": "svg",
    "data-icon-type": "PDSClose",
    class: "close-icon--33bP0 icon--d-ejA"
  }, [
    /* @__PURE__ */ vue.createElementVNode("svg", {
      t: "1685717543646",
      class: "icon",
      viewBox: "0 0 1024 1024",
      version: "1.1",
      xmlns: "http://www.w3.org/2000/svg",
      "p-id": "2490",
      id: "mx_n_1685717543647",
      width: "16",
      height: "16"
    }, [
      /* @__PURE__ */ vue.createElementVNode("path", {
        d: "M849 896c-12 0-24.1-4.6-33.2-13.8l-674-674c-18.4-18.4-18.4-48.1 0-66.5s48.1-18.4 66.5 0l674 674c18.4 18.4 18.4 48.1 0 66.5A47.03 47.03 0 0 1 849 896z",
        "p-id": "2491",
        fill: "#cdcdcd"
      }),
      /* @__PURE__ */ vue.createElementVNode("path", {
        d: "M175 896c-12 0-24.1-4.6-33.2-13.8-18.4-18.4-18.4-48.1 0-66.5l674-674c18.4-18.4 48.1-18.4 66.5 0s18.4 48.1 0 66.5l-674 674C199 891.4 187 896 175 896z",
        "p-id": "2492",
        fill: "#cdcdcd"
      })
    ])
  ], -1));
  const _hoisted_9$4 = [
    _hoisted_8$4
  ];
  const _hoisted_10$4 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", null, " 推送链接: ", -1));
  const _hoisted_11$3 = { class: "content-wrapper--1_WJv" };
  const _hoisted_12$3 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", null, " 推送路径: ", -1));
  const _hoisted_13$3 = { class: "content-wrapper--1_WJv" };
  const _hoisted_14$3 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", null, " RPC密钥: ", -1));
  const _hoisted_15$2 = { class: "content-wrapper--1_WJv" };
  const _hoisted_16$2 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("div", null, " 其他: ", -1));
  const _hoisted_17$1 = {
    key: 0,
    class: "notice2"
  };
  const _hoisted_18$1 = {
    key: 1,
    class: "notice2"
  };
  const _hoisted_19$1 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_20$1 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_21$1 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_22$1 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_23$1 = {
    key: 2,
    class: "notice2"
  };
  const _hoisted_24$1 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_25 = { class: "ant-modal-footer" };
  const _hoisted_26 = { class: "footer--3Q0je" };
  const _sfc_main$7 = {
    __name: "Aria2Set",
    setup(__props, { expose }) {
      const data = vue.reactive({
        isShowAria2Set: false,
        pushBtonText: "Aria2 推送",
        aria2Model: user.getAria2Set()
      });
      const errorMsg = vue.ref(false);
      function saveAria2() {
        $2.ajax({
          type: "POST",
          url: data.aria2Model.link,
          data: JSON.stringify({
            "jsonrpc": "2.0",
            "method": "aria2.getVersion",
            "id": "1",
            "params": [
              "token:" + data.aria2Model.token
            ]
          }),
          crossDomain: true,
          processData: false,
          contentType: "application/json",
          success: function(result) {
            user.setAria2Set(data.aria2Model);
            data.isShowAria2Set = false;
            errorMsg.value = false;
            showSuccess("Aria2配置保存成功", null, {
              appendTo: ".ant-modal-header"
            });
          },
          error: function(error) {
            errorMsg.value = true;
            showError$1("保存失败,连接不上Aria2配置", null, {
              appendTo: "#aria2_set_LuoGen"
            });
          }
        });
      }
      function aria2Push(fileList2, call) {
        if (data.pushBtonText == "正在推送") {
          return;
        }
        let folderName = "";
        if (data.aria2Model.dirCreate) {
          let dir = $2(".breadcrumb--2FqFQ[data-calc=true] > .breadcrumb-item--tV9dn > .breadcrumb-item-link--M-p4b");
          folderName = "/阿里云盘";
          for (let i2 = 0; i2 < dir.length; i2++) {
            folderName += "/" + dir[i2].innerText;
          }
        }
        let sendDownLoad = [];
        fileList2.forEach(function(item, index) {
          sendDownLoad.push({
            id: "",
            jsonrpc: "2.0",
            method: "aria2.addUri",
            params: [
              "token:" + data.aria2Model.token,
              [item.url],
              {
                out: item.name,
                dir: data.aria2Model.path + folderName,
                referer: "https://www.aliyundrive.com/",
                "user-agent": navigator.userAgent
              }
            ]
          });
        });
        let text = data.pushBtonText;
        data.pushBtonText = "正在推送";
        $2.ajax({
          type: "POST",
          url: data.aria2Model.link,
          data: JSON.stringify(sendDownLoad),
          crossDomain: true,
          processData: false,
          contentType: "application/json",
          success: function(result) {
            showSuccess("Aria2推送成功", null, {
              appendTo: ".ant-modal-header"
            });
            data.pushBtonText = text;
            call(true);
          },
          error: function(error) {
            showError$1("Aria2 推送失败,请检查配置", null, {
              appendTo: ".ant-modal-header"
            });
            data.pushBtonText = text;
            call(false);
          }
        });
      }
      function show() {
        data.isShowAria2Set = true;
      }
      function hide() {
        data.isShowAria2Set = false;
      }
      expose({
        aria2Push,
        show,
        hide
      });
      return (_ctx, _cache) => {
        return data.isShowAria2Set ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
          _hoisted_2$5,
          vue.createElementVNode("div", _hoisted_3$5, [
            vue.createElementVNode("div", _hoisted_4$5, [
              vue.createElementVNode("div", _hoisted_5$5, [
                _hoisted_6$5,
                vue.createElementVNode("div", _hoisted_7$4, [
                  vue.createElementVNode("div", {
                    class: "icon-wrapper--3dbbo",
                    id: "aria2-set-icon",
                    onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => data.isShowAria2Set = false, ["stop"]))
                  }, _hoisted_9$4),
                  _hoisted_10$4,
                  vue.createElementVNode("div", _hoisted_11$3, [
                    vue.createVNode(vue.unref(elementPlus.ElInput), {
                      id: "aria2-link",
                      modelValue: data.aria2Model.link,
                      "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => data.aria2Model.link = $event),
                      type: "text"
                    }, null, 8, ["modelValue"])
                  ]),
                  _hoisted_12$3,
                  vue.createElementVNode("div", _hoisted_13$3, [
                    vue.createVNode(vue.unref(elementPlus.ElInput), {
                      id: "aria2-path",
                      modelValue: data.aria2Model.path,
                      "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => data.aria2Model.path = $event),
                      type: "text"
                    }, null, 8, ["modelValue"])
                  ]),
                  _hoisted_14$3,
                  vue.createElementVNode("div", _hoisted_15$2, [
                    vue.createVNode(vue.unref(elementPlus.ElInput), {
                      id: "aria2-token",
                      modelValue: data.aria2Model.token,
                      "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => data.aria2Model.token = $event),
                      type: "text"
                    }, null, 8, ["modelValue"])
                  ]),
                  _hoisted_16$2,
                  vue.createTextVNode(" 不创建对应目录: "),
                  vue.createVNode(vue.unref(elementPlus.ElSwitch), {
                    modelValue: data.aria2Model.dirCreate,
                    "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => data.aria2Model.dirCreate = $event)
                  }, null, 8, ["modelValue"]),
                  errorMsg.value ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_17$1, " 如果当前推送链接是http开头,则需要修改浏览器安全限制更改为允许。 ")) : vue.createCommentVNode("", true),
                  errorMsg.value ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_18$1, [
                    vue.createTextVNode("连接不上的原因:"),
                    _hoisted_19$1,
                    vue.createTextVNode(" 1.端口或链接填写错误"),
                    _hoisted_20$1,
                    vue.createTextVNode(" 2.密钥错误 "),
                    _hoisted_21$1,
                    vue.createTextVNode(" 3.未开启跨域请求"),
                    _hoisted_22$1
                  ])) : vue.createCommentVNode("", true),
                  errorMsg.value ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_23$1, [
                    vue.createTextVNode(" ./aria2c.exe --enable-rpc --rpc-listen-all --rpc-secret 123 --rpc-allow-origin-all=true"),
                    _hoisted_24$1,
                    vue.createTextVNode(" 可以在Aria2的程序目录下,使用上面命令,RPC密钥为:123 ")
                  ])) : vue.createCommentVNode("", true)
                ]),
                vue.createElementVNode("div", _hoisted_25, [
                  vue.createElementVNode("div", _hoisted_26, [
                    vue.createVNode(vue.unref(elementPlus.ElButton), {
                      id: "aria2-set-save",
                      type: "primary",
                      onClick: vue.withModifiers(saveAria2, ["stop"])
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(" 检测 & 确定 ")
                      ]),
                      _: 1
                    }, 8, ["onClick"])
                  ])
                ])
              ])
            ])
          ])
        ])) : vue.createCommentVNode("", true);
      };
    }
  };
  const Aria2Set = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-e5d83ee0"]]);
  const DwoloadPage_vue_vue_type_style_index_0_scoped_afdd0eed_lang = "";
  const _withScopeId$3 = (n) => (vue.pushScopeId("data-v-afdd0eed"), n = n(), vue.popScopeId(), n);
  const _hoisted_1$5 = { key: 0 };
  const _hoisted_2$4 = { key: 1 };
  const _hoisted_3$4 = { key: 0 };
  const _hoisted_4$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("p", { class: "notice2" }, "注意: 如果大批量获取下载地址,会被官网限速!", -1));
  const _hoisted_5$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("p", { class: "notice1" }, "1. 因阿里云盘接口限制,短期大量请求会出现接口请求频繁,可以先选择需要下载的文件,在点击显示链接按钮。 ", -1));
  const _hoisted_6$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("p", { class: "notice1" }, "2. 接口请求频繁,也可尝试点击下载,不过文件名需要重新命名 ", -1));
  const _hoisted_7$3 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("p", { class: "notice1" }, "3. 在点击刷新按钮时,不要连续点击,可等几秒在点一次尝试获取 ", -1));
  const _hoisted_8$3 = [
    _hoisted_4$4,
    _hoisted_5$4,
    _hoisted_6$4,
    _hoisted_7$3
  ];
  const _hoisted_9$3 = { class: "notice" };
  const _hoisted_10$3 = {
    class: "item-list",
    style: { "padding": "20px", "height": "410px", "overflow-y": "auto" }
  };
  const _hoisted_11$2 = { key: 0 };
  const _hoisted_12$2 = { key: 1 };
  const _hoisted_13$2 = { style: { "margin": "10px 0px", "overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis" } };
  const _hoisted_14$2 = { class: "footer" };
  const _sfc_main$6 = {
    __name: "DwoloadPage",
    setup(__props) {
      let list = user.selectedFileList();
      if (list.length == 0) {
        list = user.getAllFileList();
      }
      list = list.filter(function(item) {
        return item.type === "folder" || item.type === "file";
      });
      console.log(list);
      const fileList2 = vue.reactive(list);
      const aria2SetRef = vue.ref();
      const data = vue.reactive({
        pushBtonText: "Aria2 推送"
      });
      const home2 = vue.ref(user.home());
      const resource = vue.ref(user.resource());
      const laterLoad = vue.ref(getCount() != 0 && list == 0);
      function getCount() {
        let text = $2(".left-wrapper--zzDY4").text();
        if (!text) {
          return 0;
        }
        var reg = /\d+/g;
        var num = text.match(reg);
        if (num.length == 0) {
          return 0;
        }
        return num[0];
      }
      function group(array, subGroupLength) {
        var index = 0;
        var newArray = [];
        while (index < array.length) {
          newArray.push(array.slice(index, index += subGroupLength));
        }
        return newArray;
      }
      function updateHref(id) {
        var $a = $2(`a[data-id="${id}"]`);
        var title2 = $a.attr("title");
        $a.attr("href", title2);
      }
      var shareToken;
      const shareTokenV = vue.reactive(user.getShareToken());
      vue.onMounted(async () => {
        if (!user.home()) {
          shareToken = user.getShareToken();
          if (!user.isExpires(shareToken)) {
            showError$1("当前页面已过期,请刷新重试");
            return;
          }
        }
        var groupedCountries = group(fileList2, 1);
        for (const index in groupedCountries) {
          await loadingUrl(groupedCountries[index]);
        }
        function loadingUrl(array) {
          return new Promise((resolve, reject) => {
            let length = array.length;
            let initLength = 0;
            array.forEach((item) => {
              if (item.type == "file") {
                getFileUrl(item, function() {
                  initLength += 1;
                  if (initLength == length) {
                    resolve();
                  }
                });
              } else {
                initLength += 1;
                if (initLength == length) {
                  resolve();
                }
              }
            });
          });
        }
      });
      function showSet() {
        aria2SetRef.value.show();
      }
      function IDMPush() {
        var content = "", referer = "https://www.aliyundrive.com/", userAgent = navigator.userAgent;
        fileList2.forEach(function(item, index) {
          if (item.url != "" && item.url != null) {
            content += ["<", item.url, "referer: " + referer, "User-Agent: " + userAgent, ">"].join("\r\n") + "\r\n";
          }
        });
        var a = document.createElement("a");
        var blob = new Blob([content]);
        var url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = "IDM导出文件_阿里云盘.ef2";
        a.click();
        window.URL.revokeObjectURL(url);
      }
      function aria2Push() {
        if (data.pushBtonText == "正在推送") {
          return;
        }
        var text = data.pushBtonText;
        data.pushBtonText = "正在推送";
        aria2SetRef.value.aria2Push(fileList2, (res) => {
          if (res == false) {
            data.pushBtonText = "推送失败";
          } else {
            data.pushBtonText = text;
          }
        });
      }
      function getFileUrl(item, call) {
        item.loading = true;
        item.text = "正在获取下载地址中";
        let showDnload;
        if (item.share_id) {
          showDnload = shareLinkDownloadUrl({
            file_id: item.file_id,
            share_id: item.share_id
          }, shareToken.share_token).then((response) => {
            item.error = false;
            item.text = response.data.download_url;
            item.url = response.data.download_url;
          });
        } else {
          showDnload = getDownloadUrl({
            expire_sec: 14400,
            drive_id: item.drive_id,
            file_id: item.file_id
          }).then((response) => {
            item.error = false;
            item.text = response.data.url;
            item.url = response.data.url;
          });
        }
        showDnload.catch((e) => {
          if (e && e + "" == "AxiosError: Request failed with status code 429") {
            item.error = true;
            item.text = "接口请求频繁,请稍后点击文件旁边的刷新按钮,重新获取 (也可点击我尝试跳转下载)";
          } else {
            item.text = "刷新失败,错误异常:" + e;
          }
        }).finally(() => {
          item.loading = false;
          call && call();
        });
      }
      vue.onUnmounted(() => {
        console.log("文件下载窗口关闭");
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
          vue.createVNode(Aria2Set, {
            ref_key: "aria2SetRef",
            ref: aria2SetRef
          }, null, 512),
          laterLoad.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
            vue.createVNode(vue.unref(elementPlus.ElResult), {
              icon: "error",
              title: "获取文件失败",
              "sub-title": "请回到文件列表中,随便点击排序,看到已加载多少文件时,在回到这里吧"
            })
          ])) : vue.createCommentVNode("", true),
          !laterLoad.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$4, [
            fileList2.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$4, _hoisted_8$3)) : vue.createCommentVNode("", true),
            vue.createElementVNode("p", _hoisted_9$3, " 共加载了" + vue.toDisplayString(fileList2.length) + "个文件", 1),
            vue.createElementVNode("div", _hoisted_10$3, [
              (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(fileList2, (item, index) => {
                return vue.openBlock(), vue.createElementBlock("div", { key: index }, [
                  item.type == "folder" ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_11$2, vue.toDisplayString(index + 1) + ". " + vue.toDisplayString(item.name), 1)) : vue.createCommentVNode("", true),
                  item.type == "file" ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_12$2, [
                    vue.createTextVNode(vue.toDisplayString(index + 1) + ". " + vue.toDisplayString(item.name) + " ", 1),
                    vue.createVNode(vue.unref(elementPlus.ElButton), {
                      type: "primary",
                      icon: vue.unref(refresh_default),
                      loading: item.loading,
                      circle: "",
                      size: "small",
                      onClick: vue.withModifiers(($event) => getFileUrl(item), ["stop"])
                    }, null, 8, ["icon", "loading", "onClick"])
                  ])) : vue.createCommentVNode("", true),
                  vue.createElementVNode("p", _hoisted_13$2, [
                    item.type == "folder" ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElLink), {
                      key: 0,
                      type: "primary",
                      href: resource.value ? "/drive/file/resource/" + item.file_id : home2.value ? "/drive/file/backup/" + item.file_id : "/s/" + shareTokenV.share_id + "/folder/" + item.file_id
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode("点击进入文件夹")
                      ]),
                      _: 2
                    }, 1032, ["href"])) : vue.createCommentVNode("", true),
                    item.type == "file" && !item.error ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElLink), {
                      key: 1,
                      onMousedown: ($event) => updateHref(item.file_id),
                      onMouseup: ($event) => updateHref(item.file_id),
                      "data-id": item.file_id,
                      type: "primary",
                      title: item.url,
                      href: item.url
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(vue.toDisplayString(item.text), 1)
                      ]),
                      _: 2
                    }, 1032, ["onMousedown", "onMouseup", "data-id", "title", "href"])) : vue.createCommentVNode("", true),
                    item.type == "file" && item.error ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElLink), {
                      key: 2,
                      type: "danger",
                      href: item.url
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(vue.toDisplayString(item.text), 1)
                      ]),
                      _: 2
                    }, 1032, ["href"])) : vue.createCommentVNode("", true)
                  ])
                ]);
              }), 128))
            ]),
            vue.createElementVNode("div", null, [
              vue.createElementVNode("div", _hoisted_14$2, [
                vue.createElementVNode("div", null, [
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    type: "primary",
                    onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => vue.unref(monkeyWindow).open("https://github.com/wyndem/ali-video", "_blank"), ["stop"]))
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode("❤️ 开源地址")
                    ]),
                    _: 1
                  }),
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    type: "primary",
                    onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => vue.unref(monkeyWindow).open("https://greasyfork.org/zh-CN/scripts/458626", "_blank"), ["stop"]))
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode("👍 点个赞")
                    ]),
                    _: 1
                  }),
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    type: "primary",
                    onClick: vue.withModifiers(IDMPush, ["stop"])
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode("IDM 导出文件")
                    ]),
                    _: 1
                  }, 8, ["onClick"]),
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    type: "primary",
                    onClick: vue.withModifiers(aria2Push, ["stop"])
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(vue.toDisplayString(data.pushBtonText), 1)
                    ]),
                    _: 1
                  }, 8, ["onClick"]),
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    type: "primary",
                    style: { "margin-left": "10px", "width": "auto", "border": "0 solid transparent" },
                    class: "aria2-set",
                    onClick: vue.withModifiers(showSet, ["stop"]),
                    circle: ""
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode("⚙️")
                    ]),
                    _: 1
                  }, 8, ["onClick"])
                ])
              ])
            ])
          ])) : vue.createCommentVNode("", true)
        ], 64);
      };
    }
  };
  const DwoloadPage = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-afdd0eed"]]);
  function title(html2) {
    let name2 = html2.split(" ")[1];
    let css = "display:flex;flex-direction:row;align-items:center;";
    let htmlDiv = `<div style='${css}padding-left:10px;padding-right:10px'>
        <p>${name2}</p>
    </div>`;
    return htmlDiv;
  }
  function getVideoSrc(call) {
    let videoPage = user.getVideoPage();
    let showDnload;
    if (!user.home()) {
      let token = user.getShareToken();
      if (token == "") {
        showError$1("当前登录凭证失效,请刷新或重新登录");
        return "";
      }
      showDnload = shareLinkDownloadUrl({
        file_id: videoPage.id,
        share_id: token.share_id
      }, token.share_token).then((response) => {
        call && call(response.data.download_url);
      });
    } else {
      let token = user.getToken();
      if (token == "") {
        showError$1("当前登录凭证获取为空,请刷新或重新登录");
        return "";
      }
      showDnload = getDownloadUrl({
        expire_sec: 14400,
        drive_id: token.default_drive_id,
        file_id: videoPage.id
      }).then((response) => {
        call && call(response.data.url);
      });
    }
    showDnload.catch((e) => {
      if (e && e + "" == "AxiosError: Request failed with status code 429") {
        showError$1("接口请求频繁");
      } else {
        showError$1("刷新失败,错误异常:" + e);
      }
    }).finally(() => {
      call && call();
    });
  }
  function getOptionUrl(option) {
    console.log(option);
    return new Promise((resolve, reject) => {
      if (option.html != " 原画") {
        resolve(option.url);
      } else {
        getVideoSrc((url) => {
          if (url != "") {
            resolve(url);
          } else {
            reject("获取地址视频错误");
          }
        });
      }
    });
  }
  function artplayPluginQuality(option) {
    return async (art) => {
      let def = option[option.length - 1];
      let loc = user.getVideoPlayerSet().qualityHtml;
      var storageQuality;
      if (loc) {
        let quality2 = option.find((item) => item.html === loc);
        if (quality2) {
          quality2["default"] = true;
          storageQuality = quality2.html;
        }
      }
      if (!storageQuality) {
        storageQuality = def.html;
        def["default"] = true;
      }
      let index = option.findIndex(function(item, index2) {
        return item.html === storageQuality;
      });
      var quality = {
        name: "quality",
        position: "right",
        html: title(storageQuality) || "Quality",
        selector: option,
        index: 2,
        onSelect: async function(item) {
          let url = await getOptionUrl(item);
          console.log(item.html);
          console.log(url);
          art.qualityHtml = item.html;
          art.switchQuality(url, item.html);
          return title(item.html);
        }
      };
      art.quality_ = quality;
      art.controls.add(quality);
      const quality1 = option[index];
      if (quality1) {
        art.url = await getOptionUrl(quality1);
        art.qualityHtml = quality1.html;
      } else {
        art.url = await getOptionUrl(option[0]);
        art.qualityHtml = option[0].html;
      }
    };
  }
  var cur = `<span  data-role="icon"data-render-as="svg"data-icon-type="PDSPlayCircle"class="icon--2AFV7 icon--d-ejA ">
<svg viewBox="0 0 1024 1024"><use xlink:href="#PDSPlayCircle"></use></svg>
</span>`;
  function html(item, def) {
    let htmlDiv = `<div style='display:flex;flex-direction:row;align-items:center;'  title="${item.name}">
    <p class="title--2vewu " >
        ${def ? cur : ""}
    </p>
        <span class="filename--3hcxw filename_luogen" style="font-size:14px">${item.name}</span>
    </div>
    `;
    return htmlDiv;
  }
  function selector(call) {
    let items = user.getPage().items;
    if (items.length == 0 || $2("#videoHistory").length > 0) {
      return (art) => {
      };
    }
    let fileList2 = items;
    let id = user.getVideoPage().id;
    var videoList = fileList2.filter(function(item, index) {
      return item.category === "video";
    }), fileIndex = videoList.findIndex(function(item, index) {
      return item.file_id === id;
    });
    if (!(fileIndex > -1 && videoList.length > 1))
      return () => {
      };
    console.log("视频数量为::" + videoList.length);
    return (art) => {
      let option = [];
      videoList.forEach((it, index) => {
        option.push({
          default: index == fileIndex,
          index,
          file: it,
          html: html(it, index == fileIndex)
        });
      });
      let svg = '<svg t="1677915128666" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2048" width="24" height="24"><path d="M665.47 417.65l-345.03-244.3c-69.8-49.42-166.29 0.49-166.29 86.01v502.27c0 85.52 96.49 135.43 166.29 86.01l345.03-244.31c64.02-45.34 64.02-140.34 0-185.68zM811.82 868.52c-30.38 0-55-24.62-55-55V207.46c0-30.38 24.62-55 55-55s55 24.62 55 55v606.07c0 30.37-24.62 54.99-55 54.99z" p-id="2049" fill="#ffffff"></path></svg>';
      if (fileIndex + 1 < videoList.length) {
        art.controls.add({
          name: "next_selector",
          position: "left",
          html: `<i class="art-icon"  title="${videoList[fileIndex + 1].name}">` + svg + "</i>",
          tooltip: videoList[fileIndex + 1].name,
          style: {
            marginRight: "10px"
          },
          click: function() {
            let item = videoList[fileIndex + 1];
            call && call(item);
          }
        });
      }
      art.videoList = option;
      art.controls.add({
        name: "selector",
        position: "right",
        index: 1,
        html: "选集",
        click: function() {
          if (art.fullscreen) {
            art.fullscreen = false;
          } else if (art.fullscreenWeb) {
            art.fullscreen = false;
          }
          call && call();
        }
      });
    };
  }
  function subtitle(click) {
    return (art) => {
      art.controls.add({
        name: "subtitle",
        position: "right",
        html: "字幕",
        index: 2,
        style: {
          marginLeft: "10px"
        },
        click: function() {
          if (art.fullscreen) {
            art.fullscreen = false;
          } else if (art.fullscreenWeb) {
            art.fullscreen = false;
          }
          click && click();
        }
      });
    };
  }
  var doubleSpeed = function(art) {
    art.notice.show = "倍速播放 x3";
    art.playbackRate = 3;
  };
  function hotkey() {
    return (art) => {
      var rightCount = 0;
      var playbackRate = null;
      var rightInterval = null;
      var logKey = false;
      document.onkeyup = function(event) {
        if (event.code === "ArrowRight") {
          if (rightCount === 1) {
            art.currentTime = art.currentTime + 5;
          }
          logKey = false;
          if (rightInterval) {
            window.clearInterval(rightInterval);
          }
          rightInterval = null;
          rightCount = 0;
          if (playbackRate) {
            art.playbackRate = playbackRate;
            playbackRate = null;
          }
        }
      };
      document.onkeydown = function(event) {
        if (event.code === "ArrowRight") {
          rightCount += 1;
          if (!playbackRate) {
            playbackRate = art.playbackRate;
          }
          if (!rightInterval) {
            rightInterval = setInterval(function() {
              if (rightCount > 100) {
                rightCount = 2;
              }
              if (rightCount > 1 && !logKey) {
                doubleSpeed(art);
                logKey = true;
              }
            }, 100);
          }
        } else if (event.code === "ArrowLeft") {
          art.currentTime = art.currentTime - 5;
        } else if (event.code === "ArrowUp") {
          art.volume = art.volume + 0.01;
        } else if (event.code === "ArrowDown") {
          art.volume = art.volume - 0.01;
        } else if (event.code === "Space") {
          art.toggle();
        } else if (event.code === "Enter") {
          art.fullscreen = !art.fullscreen;
        }
      };
    };
  }
  function saveCloud(art) {
    let token = user.getToken();
    if (token == null) {
      return;
    }
    let v = user.getVideoPage();
    videoUpdate({
      drive_id: token.default_drive_id,
      duration: art.duration,
      file_id: v.id,
      play_cursor: art.currentTime
    }).then((res) => {
    });
  }
  function saveExit() {
    return (art) => {
      art.on("ready", () => {
        let v = user.getVideoPage();
        if (v.play_cursor) {
          art.seek = v.play_cursor;
        } else {
          let list = user.getVideoLookList();
          let index = list.findIndex((item) => {
            return item.id == v.id;
          });
          if (index != -1) {
            art.seek = list[index].play_cursor;
          }
        }
        let plset = user.getVideoPlayerSet();
        if (plset.fullscreen) {
          art.fullscreen = true;
        }
        if (plset.fullscreenWeb) {
          art.fullscreenWeb = true;
        }
        if (plset.playbackRate) {
          art.playbackRate = plset.playbackRate;
        }
        if (plset.subtitleSize && plset.subtitleSize != 0) {
          $2(".art-subtitle").css("font-size", plset.subtitleSize + "px");
          art.subtitleSize = plset.subtitleSize;
        }
        if (plset.subtitleMargin && plset.subtitleSize != 0) {
          $2(".art-subtitle").css("margin-bottom", plset.subtitleMargin + "px");
          art.subtitleMargin = plset.subtitleMargin;
        }
        if (plset.subtitleOffset) {
          art.subtitleOffset = plset.subtitleOffset;
          art.subtitleOffset = plset.subtitleOffset;
        }
        if (plset.subtitleColor && plset.subtitleColor.indexOf("#") != -1) {
          $2(".art-subtitle").css("color", plset.subtitleColor);
          art.subtitleColor = plset.subtitleColor;
        }
      });
      art.on("destroy", () => {
        let v = user.getVideoPage();
        if (v.type == 0) {
          saveCloud(art);
        }
        user.saveVideoPlayerSet(art);
        let currentTime = art.currentTime;
        let progress = parseInt(currentTime / art.duration * 100);
        try {
          art.hls.destroy();
          art.video.dispose();
        } catch (error) {
        }
        let items = user.getPage().items;
        let index = items.findIndex((it) => {
          return it.file_id == v.id;
        });
        if (index != -1) {
          if (!items[index].user_meta) {
            items[index].user_meta = "{}";
          }
          let meta = JSON.parse(items[index].user_meta);
          meta.play_cursor = currentTime;
          items[index].user_meta = JSON.stringify(meta);
        }
        let folderName;
        let href = v.href;
        if (v.type == 1) {
          folderName = "来自分享";
        } else {
          folderName = v.folderName;
        }
        user.saveVideoInfo(v.id, v.name, progress, folderName, href, v.type == 1, currentTime);
      });
    };
  }
  const SubTitle_vue_vue_type_style_index_0_scoped_d892bc01_lang = "";
  const _withScopeId$2 = (n) => (vue.pushScopeId("data-v-d892bc01"), n = n(), vue.popScopeId(), n);
  const _hoisted_1$4 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("div", { style: { "margin-top": "-20px" } }, [
    /* @__PURE__ */ vue.createElementVNode("p", { class: "notice1" }, "页面链接就是先去找到字幕位置,然后再把当前页面的链接拷贝复制到下面输入框中,再点击跳转即可")
  ], -1));
  const _hoisted_2$3 = { style: { "margin-bottom": "20px" } };
  const _hoisted_3$3 = { class: "bread-container--xuGOj" };
  const _hoisted_4$3 = {
    class: "breadcrumb-wrap--Uq5Lb",
    "data-align": "left"
  };
  const _hoisted_5$3 = {
    class: "breadcrumb--gnRPG",
    "data-calc": "true"
  };
  const _hoisted_6$3 = ["data-label", "onClick", "data-key"];
  const _hoisted_7$2 = {
    class: "breadcrumb-item-link--9zcQY",
    "data-spm-anchor-id": "0.0.0.i5.54a06c75zaT9h6"
  };
  const _hoisted_8$2 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "breadcrumb-item-separator--MnbFV" }, "›", -1));
  const _hoisted_9$2 = { key: 0 };
  const _hoisted_10$2 = { id: "_fileList" };
  const _hoisted_11$1 = {
    class: "td--SGrZj td---v-kp",
    "data-col-key": "name",
    style: { "flex": "1 1 0%", "min-width": "160px" }
  };
  const _hoisted_12$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("div", {
    class: "cover--Mn1Bt folder-cover--ExDmp",
    "data-size": "XXS"
  }, [
    /* @__PURE__ */ vue.createElementVNode("img", {
      alt: "folder",
      class: "fileicon--Ob-Oj fileicon---webs",
      draggable: "false",
      src: "https://img.alicdn.com/imgextra/i3/O1CN01qSxjg71RMTCxOfTdi_!!6000000002097-2-tps-80-80.png"
    })
  ], -1));
  const _hoisted_13$1 = ["title"];
  const _hoisted_14$1 = {
    class: "td--SGrZj td---v-kp",
    "data-col-key": "name",
    style: { "flex": "1 1 0%", "min-width": "160px" }
  };
  const _hoisted_15$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("div", {
    class: "cover--Mn1Bt folder-cover--ExDmp",
    "data-size": "XXS"
  }, [
    /* @__PURE__ */ vue.createElementVNode("img", {
      alt: "others",
      class: "fileicon--Ob-Oj fileicon---webs",
      draggable: "false",
      src: "https://img.alicdn.com/imgextra/i2/O1CN01ROG7du1aV18hZukHC_!!6000000003334-2-tps-140-140.png"
    })
  ], -1));
  const _hoisted_16$1 = ["title"];
  const _sfc_main$5 = {
    __name: "SubTitle",
    emits: ["selectSubTitle"],
    setup(__props, { expose, emit }) {
      const data = vue.ref([]);
      const path = vue.ref([]);
      const url = vue.ref();
      vue.onMounted(() => {
        getFileList("root", "全部文件");
      });
      function selectFile(fileInfo) {
        elementPlus.ElMessageBox.confirm(
          `确认加载《${fileInfo.name}》字幕文件吗?`,
          "字幕选择",
          {
            confirmButtonText: "确认",
            cancelButtonText: "取消"
          }
        ).then(() => {
          emit("selectSubTitle", fileInfo);
        });
      }
      function getFileList(parent_file_id, name2) {
        let loadingInstance = elementPlus.ElLoading.service({
          target: "#_fileList",
          text: "加载中"
        });
        try {
          if (path.value.length != 0) {
            let last = path.value[path.value.length - 1];
            if (last.id == parent_file_id) {
              return;
            }
            let index = path.value.findIndex((item, index2) => {
              return item.id === parent_file_id;
            });
            if (index != -1) {
              path.value = path.value.splice(0, index);
            }
          }
          path.value.push({
            id: parent_file_id,
            name: name2
          });
          let token = user.getToken();
          if (token == "" || token == null) {
            showError$1("登录凭证失效,请重新登录重试");
            return;
          }
          if (token.default_drive_id == null || token.default_drive_id == "") {
            showError$1("设备id为空,请刷新重试");
            console.log(token.default_drive_id);
            return;
          }
          search({
            "drive_id": token.default_drive_id,
            "query": `parent_file_id = "${parent_file_id}" and (type = "folder" or file_extension in ["srt", "ass", "vtt"])`,
            "order_by": "type ASC,updated_at DESC",
            "limit": 20,
            "image_thumbnail_process": "image/resize,w_256/format,jpeg",
            "image_url_process": "image/resize,w_1920/format,jpeg/interlace,1",
            "video_thumbnail_process": "video/snapshot,t_1000,f_jpg,ar_auto,w_256"
          }).then((res) => {
            data.value.length = 0;
            data.value = res.data.items;
            if (parent_file_id == "root") {
              url.value = "https://www.aliyundrive.com/drive/file/backup";
            } else {
              url.value = "https://www.aliyundrive.com/drive/file/backup/" + parent_file_id;
            }
          }).catch((e) => {
            console.log(e);
            if (e && e + "" == "AxiosError: Request failed with status code 429") {
              showError$1("您操作的太快了! 请稍候点击下方按钮,刷新尝试");
            } else {
              showError$1(e + "");
            }
            path.value.pop();
          });
        } finally {
          loadingInstance.close();
        }
      }
      function toUrlFile() {
        var link = url.value;
        if (link == "https://www.aliyundrive.com/drive") {
          showError$1("如需跳首页,请点下方全部文件");
          return;
        }
        var regex = /backup\/(.+?)(?:\/|\?|$)/;
        var match = link.match(regex);
        if (match) {
          var value = match[1];
          getFileList(value, "搜索结果");
        } else {
          showError$1("错误的链接");
        }
      }
      function toCurrentPage() {
        url.value = location.href;
        toUrlFile();
      }
      expose({
        getFileList
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock("div", null, [
          _hoisted_1$4,
          vue.createElementVNode("div", _hoisted_2$3, [
            vue.createVNode(vue.unref(elementPlus.ElInput), {
              modelValue: url.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => url.value = $event),
              placeholder: "Please input"
            }, {
              prepend: vue.withCtx(() => [
                vue.createTextVNode("链接")
              ]),
              append: vue.withCtx(() => [
                vue.createVNode(vue.unref(elementPlus.ElButton), {
                  type: "primary",
                  onClick: toUrlFile
                }, {
                  default: vue.withCtx(() => [
                    vue.createTextVNode("跳转")
                  ]),
                  _: 1
                })
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          vue.createVNode(vue.unref(elementPlus.ElButton), {
            type: "primary",
            link: "",
            onClick: toCurrentPage
          }, {
            default: vue.withCtx(() => [
              vue.createTextVNode("跳转到当前页面")
            ]),
            _: 1
          }),
          vue.createElementVNode("div", _hoisted_3$3, [
            vue.createElementVNode("div", _hoisted_4$3, [
              vue.createElementVNode("div", _hoisted_5$3, [
                (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(path.value, (item, index) => {
                  return vue.openBlock(), vue.createElementBlock("div", {
                    key: index,
                    class: "breadcrumb-item--j8J5H",
                    "data-label": item.name,
                    onClick: vue.withModifiers(($event) => getFileList(item.id, item.name), ["stop"]),
                    "data-key": item.id,
                    "data-hide": "false",
                    "data-more": "false"
                  }, [
                    vue.createElementVNode("div", _hoisted_7$2, vue.toDisplayString(item.name), 1),
                    _hoisted_8$2
                  ], 8, _hoisted_6$3);
                }), 128))
              ])
            ])
          ]),
          data.value.length == 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_9$2, [
            vue.createVNode(vue.unref(elementPlus.ElEmpty), { description: "文件夹为空" })
          ])) : vue.createCommentVNode("", true),
          vue.createElementVNode("div", _hoisted_10$2, [
            (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.value, (item, index) => {
              return vue.openBlock(), vue.createElementBlock("div", {
                key: index,
                style: { "margin-top": "4px" }
              }, [
                item.type == "folder" ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCard), {
                  key: 0,
                  "body-style": { "padding": "5px", "margin": "0px" },
                  shadow: "hover",
                  onClick: vue.withModifiers(($event) => getFileList(item.file_id, item.name), ["stop"])
                }, {
                  default: vue.withCtx(() => [
                    vue.createElementVNode("div", _hoisted_11$1, [
                      _hoisted_12$1,
                      vue.createElementVNode("p", {
                        class: "text-primary--JzAb9",
                        title: item.name
                      }, vue.toDisplayString(item.name), 9, _hoisted_13$1)
                    ])
                  ]),
                  _: 2
                }, 1032, ["onClick"])) : vue.createCommentVNode("", true),
                item.type == "file" ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCard), {
                  key: 1,
                  "body-style": { "padding": "5px", "margin": "0px" },
                  shadow: "hover",
                  onClick: vue.withModifiers(($event) => selectFile(item), ["stop"])
                }, {
                  default: vue.withCtx(() => [
                    vue.createElementVNode("div", _hoisted_14$1, [
                      _hoisted_15$1,
                      vue.createElementVNode("p", {
                        class: "text-primary--JzAb9",
                        title: item.name
                      }, vue.toDisplayString(item.name), 9, _hoisted_16$1)
                    ])
                  ]),
                  _: 2
                }, 1032, ["onClick"])) : vue.createCommentVNode("", true)
              ]);
            }), 128))
          ])
        ]);
      };
    }
  };
  const SubTitle = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-d892bc01"]]);
  const indicator = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMiAyMiI+CiAgICA8cGF0aCBkPSJNMTYuMTE4IDMuNjY3aC4zODJhMy42NjcgMy42NjcgMCAwMTMuNjY3IDMuNjY3djcuMzMzYTMuNjY3IDMuNjY3IDAgMDEtMy42NjcgMy42NjdoLTExYTMuNjY3IDMuNjY3IDAgMDEtMy42NjctMy42NjdWNy4zMzNBMy42NjcgMy42NjcgMCAwMTUuNSAzLjY2NmguMzgyTDQuOTUgMi4wNTNhMS4xIDEuMSAwIDAxMS45MDYtMS4xbDEuNTY3IDIuNzE0aDUuMTU2TDE1LjE0Ni45NTNhMS4xMDEgMS4xMDEgMCAwMTEuOTA2IDEuMWwtLjkzNCAxLjYxNHoiIGZpbGw9IiMzMzMiPjwvcGF0aD4KICAgIDxwYXRoIGQ9Ik01LjU2MSA1LjE5NGgxMC44NzhhMi4yIDIuMiAwIDAxMi4yIDIuMnY3LjIxMWEyLjIgMi4yIDAgMDEtMi4yIDIuMkg1LjU2MWEyLjIgMi4yIDAgMDEtMi4yLTIuMlY3LjM5NGEyLjIgMi4yIDAgMDEyLjItMi4yeiIgZmlsbD0iI2ZmZiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTYuOTY3IDguNTU2YTEuMSAxLjEgMCAwMTEuMSAxLjF2Mi42ODlhMS4xIDEuMSAwIDExLTIuMiAwVjkuNjU2YTEuMSAxLjEgMCAwMTEuMS0xLjF6TTE1LjAzMyA4LjU1NmExLjEgMS4xIDAgMDExLjEgMS4xdjIuNjg5YTEuMSAxLjEgMCAxMS0yLjIgMFY5LjY1NmExLjEgMS4xIDAgMDExLjEtMS4xeiIgZmlsbD0iIzMzMyI+PC9wYXRoPgo8L3N2Zz4=";
  const state = "data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgODAgODAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzPjxwYXRoIGlkPSJwaWQtNjQtc3Znby1hIiBkPSJNMCAwaDgwdjgwSDB6Ij48L3BhdGg+PHBhdGggZD0iTTUyLjU0NiA4LjAxNGEzLjk5OCAzLjk5OCAwIDAxNC4yMjIgMy4wNzdjLjEwNC40NDYuMDkzLjgwOC4wMzkgMS4xMzhhMi43NCAyLjc0IDAgMDEtLjMxMi44ODFjLS4wNzMuMTMyLS4xNi4yNTQtLjI0Ni4zNzZsLS4yNTcuMzY2LS41MjEuNzNjLS43Ljk2OS0xLjQxNSAxLjkyNi0yLjE1NCAyLjg2NmwtLjAxNS4wMmEyNDAuOTQ1IDI0MC45NDUgMCAwMTUuOTg2LjM0MWwxLjY0My4xMjMuODIyLjA2Ni40MS4wMzQuMjA2LjAxOC4xMDMuMDA4LjExNS4wMTJjMS4yNjYuMTE2IDIuNTE2LjQ1IDMuNjc3Ljk3NWExMS42NjMgMTEuNjYzIDAgMDEzLjE2NiAyLjExNGMuOTMxLjg3IDEuNzE5IDEuODk1IDIuMzIxIDMuMDIyYTExLjU5NSAxMS41OTUgMCAwMTEuMjI0IDMuNjEzYy4wMy4xNTcuMDQ2LjMxNi4wNjguNDc0bC4wMTUuMTE5LjAxMy4xMTIuMDIyLjIwNi4wODUuODIyLjE1OSAxLjY0NmMuMSAxLjA5OC4xOSAyLjE5OC4yNyAzLjI5OC4zMTUgNC40LjQ2MyA4LjgyOS4zNiAxMy4yNTVhMTY2LjQ4OSAxNjYuNDg5IDAgMDEtLjg0MyAxMy4yMTNjLS4wMTIuMTI3LS4wMzQuMjk3LS4wNTMuNDU0YTcuNTg5IDcuNTg5IDAgMDEtLjA3Mi40NzVsLS4wNC4yMzctLjA1LjIzNmExMS43NjIgMTEuNzYyIDAgMDEtLjc0IDIuMjg3IDExLjc1NSAxMS43NTUgMCAwMS01LjExOCA1LjU3IDExLjcwNSAxMS43MDUgMCAwMS0zLjYyMyAxLjI2M2MtLjE1OC4wMjQtLjMxNi4wNTItLjQ3NS4wNzJsLS40NzcuMDUzLS44MjEuMDcxLTEuNjQ0LjEzNGMtMS4wOTYuMDg2LTIuMTkyLjE2LTMuMjg4LjIzYTI2MC4wOCAyNjAuMDggMCAwMS02LjU3OC4zMjVjLTguNzcyLjMyNC0xNy41NDYuMjItMjYuMzEzLS4zMDJhMjQyLjQ1OCAyNDIuNDU4IDAgMDEtMy4yODctLjIybC0xLjY0My0uMTI5LS44MjItLjA2OS0uNDEtLjAzNS0uMjA2LS4wMThjLS4wNjgtLjAwNi0uMTMzLS4wMS0uMjE4LS4wMmExMS41NjYgMTEuNTY2IDAgMDEtMy43LS45OTIgMTEuNzMyIDExLjczMiAwIDAxLTUuNDk3LTUuMTc4IDExLjczIDExLjczIDAgMDEtMS4yMTUtMy42MjdjLS4wMjQtLjE1OC0uMDUxLS4zMTYtLjA2Ny0uNDc1bC0uMDI2LS4yMzgtLjAxMy0uMTE5LS4wMS0uMTAzLS4wNy0uODIzLS4xMzItMS42NDhhMTkwLjYzNyAxOTAuNjM3IDAgMDEtLjIyLTMuMjk4Yy0uMjU2LTQuMzk5LS4zNTgtOC44MTctLjI1OC0xMy4yMzMuMDk5LTQuNDEyLjM3Mi04LjgxMS43ODgtMTMuMTk3YTExLjY1IDExLjY1IDAgMDEzLjAzOS02LjgzNSAxMS41ODUgMTEuNTg1IDAgMDE2LjU3Mi0zLjU2M2MuMTU3LS4wMjMuMzEyLS4wNTEuNDctLjA3bC40Ny0uMDUuODItLjA3IDEuNjQzLS4xM2EyMjguNDkzIDIyOC40OTMgMCAwMTYuNjQ3LS40MDVsLS4wNDEtLjA1YTg4LjE0NSA4OC4xNDUgMCAwMS0yLjE1NC0yLjg2N2wtLjUyLS43My0uMjU4LS4zNjZjLS4wODYtLjEyMi0uMTczLS4yNDQtLjI0Ni0uMzc2YTIuNzQgMi43NCAwIDAxLS4zMTItLjg4MSAyLjgwOCAyLjgwOCAwIDAxLjA0LTEuMTM4IDMuOTk4IDMuOTk4IDAgMDE0LjIyLTMuMDc3IDIuOCAyLjggMCAwMTEuMDkzLjMxM2MuMjk0LjE1NS41MzguMzQ3Ljc0Mi41NjguMTAyLjExLjE5LjIzLjI4LjM1bC4yNy4zNTkuNTMyLjcyYTg4LjA1OSA4OC4wNTkgMCAwMTIuMDYgMi45MzYgNzMuMDM2IDczLjAzNiAwIDAxMS45MjkgMy4wM2MuMTg3LjMxMy4zNzMuNjI4LjU1Ni45NDUgMi43MjQtLjA0NyA1LjQ0Ny0uMDU2IDguMTctLjAzOC43NDguMDA2IDEuNDk2LjAxNSAyLjI0NC4wMjYuMTgtLjMxMy4zNjQtLjYyNC41NDktLjkzNGE3My4yODEgNzMuMjgxIDAgMDExLjkzLTMuMDMgODguNzM3IDg4LjczNyAwIDAxMi4wNTktMi45MzVsLjUzMy0uNzIuMjY4LS4zNTljLjA5LS4xMi4xNzktLjI0LjI4MS0uMzVhMi44IDIuOCAwIDAxMS44MzQtLjg4MXpNMzAuMTMgMzQuNjMxYTQgNCAwIDAwLS40MTggMS40MiA5MS4xNTcgOTEuMTU3IDAgMDAtLjQ0NiA5LjEyOGMwIDIuODI4LjEyMSA1LjY1Ni4zNjQgOC40ODNsLjExIDEuMjEyYTQgNCAwIDAwNS44NTggMy4xNDNjMi44Mi0xLjQ5OCA1LjU1LTMuMDMzIDguMTkzLTQuNjA2YTE3Ny40MSAxNzcuNDEgMCAwMDUuODk2LTMuNjY2bDEuNDM0LS45NDJhNCA0IDAgMDAuMDQ3LTYuNjMyIDEzNy43MDMgMTM3LjcwMyAwIDAwLTcuMzc3LTQuNzA4IDE0Ni44OCAxNDYuODggMCAwMC02Ljg3OS0zLjg0OWwtMS40LS43MjVhNCA0IDAgMDAtNS4zODIgMS43NDJ6IiBpZD0icGlkLTY0LXN2Z28tZCI+PC9wYXRoPjxmaWx0ZXIgeD0iLTE1LjQlIiB5PSItMTYuMyUiIHdpZHRoPSIxMzAuOSUiIGhlaWdodD0iMTMyLjUlIiBmaWx0ZXJVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giIGlkPSJwaWQtNjQtc3Znby1jIj48ZmVPZmZzZXQgZHk9IjIiIGluPSJTb3VyY2VBbHBoYSIgcmVzdWx0PSJzaGFkb3dPZmZzZXRPdXRlcjEiPjwvZmVPZmZzZXQ+PGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMSIgaW49InNoYWRvd09mZnNldE91dGVyMSIgcmVzdWx0PSJzaGFkb3dCbHVyT3V0ZXIxIj48L2ZlR2F1c3NpYW5CbHVyPjxmZUNvbG9yTWF0cml4IHZhbHVlcz0iMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMC4zIDAiIGluPSJzaGFkb3dCbHVyT3V0ZXIxIiByZXN1bHQ9InNoYWRvd01hdHJpeE91dGVyMSI+PC9mZUNvbG9yTWF0cml4PjxmZU9mZnNldCBpbj0iU291cmNlQWxwaGEiIHJlc3VsdD0ic2hhZG93T2Zmc2V0T3V0ZXIyIj48L2ZlT2Zmc2V0PjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjMuNSIgaW49InNoYWRvd09mZnNldE91dGVyMiIgcmVzdWx0PSJzaGFkb3dCbHVyT3V0ZXIyIj48L2ZlR2F1c3NpYW5CbHVyPjxmZUNvbG9yTWF0cml4IHZhbHVlcz0iMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMC4yIDAiIGluPSJzaGFkb3dCbHVyT3V0ZXIyIiByZXN1bHQ9InNoYWRvd01hdHJpeE91dGVyMiI+PC9mZUNvbG9yTWF0cml4PjxmZU1lcmdlPjxmZU1lcmdlTm9kZSBpbj0ic2hhZG93TWF0cml4T3V0ZXIxIj48L2ZlTWVyZ2VOb2RlPjxmZU1lcmdlTm9kZSBpbj0ic2hhZG93TWF0cml4T3V0ZXIyIj48L2ZlTWVyZ2VOb2RlPjwvZmVNZXJnZT48L2ZpbHRlcj48L2RlZnM+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBvcGFjaXR5PSIuOCI+PG1hc2sgaWQ9InBpZC02NC1zdmdvLWIiIGZpbGw9IiNmZmYiPjx1c2UgeGxpbms6aHJlZj0iI3BpZC02NC1zdmdvLWEiPjwvdXNlPjwvbWFzaz48ZyBtYXNrPSJ1cmwoI3BpZC02NC1zdmdvLWIpIj48dXNlIGZpbGw9IiMwMDAiIGZpbHRlcj0idXJsKCNwaWQtNjQtc3Znby1jKSIgeGxpbms6aHJlZj0iI3BpZC02NC1zdmdvLWQiPjwvdXNlPjx1c2UgZmlsbD0iI0ZGRiIgeGxpbms6aHJlZj0iI3BpZC02NC1zdmdvLWQiPjwvdXNlPjwvZz48L2c+PC9zdmc+";
  const Selector_vue_vue_type_style_index_0_scoped_d200ca3c_lang = "";
  const _hoisted_1$3 = ["data-def"];
  const _sfc_main$4 = {
    __name: "Selector",
    emits: ["next"],
    setup(__props, { expose, emit }) {
      const videoList = vue.ref([]);
      const card = vue.ref();
      vue.onMounted(() => {
      });
      function nextVideo(index) {
        videoList.value.forEach((it, ix) => {
          if (ix == index) {
            it.default = true;
          } else {
            it.default = false;
          }
        });
        emit("next", videoList.value[index]);
      }
      function loadingList(vList) {
        console.log(vList);
        videoList.value = vList;
        scrollToData();
      }
      function scrollToData() {
        let target = $2('div[data-def="true"]');
        if (target.length == 0) {
          setTimeout(scrollToData, 200);
          return;
        }
        card.value.setScrollTop(target[0].offsetTop);
      }
      expose({
        loadingList
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElScrollbar), {
          class: "GoodList",
          ref_key: "card",
          ref: card
        }, {
          default: vue.withCtx(() => [
            (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(videoList.value, (item, index) => {
              return vue.openBlock(), vue.createElementBlock("div", {
                "data-def": item.default,
                class: "card",
                key: index
              }, [
                vue.createVNode(vue.unref(elementPlus.ElTooltip), {
                  content: item.file.name,
                  placement: "left-start",
                  effect: "light",
                  "hide-after": "10",
                  "show-after": "100"
                }, {
                  default: vue.withCtx(() => [
                    vue.createVNode(vue.unref(elementPlus.ElCard), {
                      shadow: item.default ? "always" : "hover",
                      onClick: vue.withModifiers(($event) => nextVideo(index), ["stop"])
                    }, {
                      default: vue.withCtx(() => [
                        vue.createElementVNode("p", {
                          style: vue.normalizeStyle(item.default ? "color:#23ade5" : "")
                        }, vue.toDisplayString(item.file.name), 5)
                      ]),
                      _: 2
                    }, 1032, ["shadow", "onClick"])
                  ]),
                  _: 2
                }, 1032, ["content"])
              ], 8, _hoisted_1$3);
            }), 128))
          ]),
          _: 1
        }, 512);
      };
    }
  };
  const Selector = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-d200ca3c"]]);
  const VideoPage_vue_vue_type_style_index_0_scoped_ee523f38_lang = "";
  const _sfc_main$3 = {
    __name: "VideoPage",
    setup(__props) {
      const artRef = vue.ref();
      const subtitleRef = vue.ref();
      const selectorRef = vue.ref();
      const color = vue.ref("#fff");
      const table = vue.ref(false);
      const showSelector = vue.ref(false);
      const retry = vue.reactive({
        error: false,
        text: "",
        title: "",
        loading: false
      });
      const transcoding = {
        UHD: "4K 超清",
        QHD: "2K 超清",
        FHD: "1080 全高清",
        HD: "720 高清",
        SD: "540 标清",
        LD: "360 流畅"
      };
      var options = {};
      var retries = 3;
      let instance;
      vue.onMounted(() => {
        getVideoInfo(artp);
      });
      function getOption(video) {
        let vInfo = user.getVideoPage();
        let yh = vInfo.name && getExt(vInfo.name) == "mp4" && false;
        let play_info = video.video_preview_play_info;
        let task_list = play_info.live_transcoding_task_list;
        var option = [];
        if (yh) {
          option.push({
            html: " 原画",
            url: ""
          });
        }
        task_list.forEach(function(item, index) {
          let name2 = transcoding[item.template_id];
          if (!name2) {
            return;
          }
          if (item.url != "") {
            option.push({
              html: name2,
              url: item.url || item.preview_url
            });
          }
        });
        return option;
      }
      function nextVideo(item) {
        showSelector.value = false;
        if (item.file) {
          item = item.file;
        }
        instance.destroy(false);
        let vInfo = user.getVideoPage();
        vInfo.id = item.file_id;
        if (!item.user_meta) {
          item.user_meta = "{}";
        }
        let meta = JSON.parse(item.user_meta);
        vInfo.duration = meta.duration;
        vInfo.play_cursor = meta.play_cursor;
        vInfo.name = item.name;
        vInfo.thumbnail = item.thumbnail;
        getVideoInfo(artp);
      }
      function artp(video) {
        var option = getOption(video);
        var plset = user.getVideoPlayerSet();
        color.value = plset.subtitleColor || "#FFF";
        instance = new Artplayer2({
          container: artRef.value,
          settings: [
            {
              html: "画中画",
              icon: '<i class="art-icon art-icon-pip"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" height="32" width="32"><path d="M25 17h-8v6h8v-6Zm4 8V10.98C29 9.88 28.1 9 27 9H9c-1.1 0-2 .88-2 1.98V25c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2Zm-2 .02H9V10.97h18v14.05Z"></path></svg></i>',
              switch: false,
              tooltip: "Close",
              onSwitch: function(item, $dom, event) {
                console.info(item, $dom, event);
                const nextState = !item.switch;
                instance.pip = nextState;
                item.tooltip = nextState ? "Open" : "Close";
                return nextState;
              }
            },
            {
              html: "字幕设置",
              selector: [
                {
                  html: "字体大小",
                  range: [plset.subtitleSize || 20, 10, 45, 5],
                  tooltip: (plset.subtitleSize || 20) + "px",
                  onChange: function(item, $dom, event) {
                    $2(".art-subtitle").css("font-size", item.range + "px");
                    instance.subtitleSize = item.range;
                    return item.range + "px";
                  }
                },
                {
                  html: "上下移动",
                  range: [plset.subtitleMargin || 0, 0, 150, 10],
                  tooltip: (plset.subtitleMargin || 0) + "px",
                  onChange: function(item, $dom, event) {
                    $2(".art-subtitle").css("margin-bottom", item.range + "px");
                    instance.subtitleMargin = item.range;
                    return item.range + "px";
                  }
                },
                {
                  html: "偏移",
                  tooltip: (plset.subtitleOffset || 0) + "s",
                  range: [plset.subtitleOffset || 0, -5, 5, 0.1],
                  onChange(item) {
                    instance.subtitleOffset = item.range;
                    return item.range + "s";
                  }
                },
                {
                  html: `<div style="display:flex;justify-content:center; align-items:center ">颜色<div style='background-color:${color.value};width:15px;height:15px;' /></div>`,
                  switch: false,
                  onSwitch: function(item, $dom, event) {
                    var subtitle2 = $2(".art-subtitle");
                    elementPlus.ElMessageBox({
                      title: "颜色面板",
                      message: () => vue.h("p", null, [
                        vue.h("span", null, "请选择颜色"),
                        vue.h(elementPlus.ElColorPicker, {
                          model: color,
                          modelValue: color.value,
                          "onUpdate:modelValue": (val) => {
                            color.value = val;
                          }
                        })
                      ]),
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      closeOnClickModal: false
                    }).then(() => {
                      subtitle2.css("color", color.value);
                      item.html = `<div style="display:flex;justify-content:center; align-items:center ">颜色<div style='background-color:${color.value};width:15px;height:15px;' /></div>`;
                      item.switch = true;
                      instance.subtitleColor = color.value;
                    }).catch(() => {
                    });
                    return false;
                  }
                }
              ]
            }
          ],
          plugins: [
            // 清晰度
            artplayPluginQuality(option),
            // 上下集
            selector(function(item) {
              if (item == null) {
                instance.pause();
                showSelector.value = true;
                return;
              }
              nextVideo(item);
            }),
            //快捷键
            hotkey(),
            // 字幕插件
            subtitle(openSubTitle),
            // 偏好设置
            saveExit()
          ],
          ...options
        });
        instance.on("error", function(e) {
          console.log(e);
        });
        instance.on("ready", () => {
          let subtitle2 = video && video.video_preview_play_info && video.video_preview_play_info.live_transcoding_subtitle_task_list;
          if (subtitle2 != null && subtitle2.length > 0) {
            let subtitleType = getExt(subtitle2[0].url);
            instance.subtitle.switch(subtitle2[0].url, {
              type: subtitleType.length > 3 ? "srt" : subtitleType
            });
          }
          instance.play();
        });
        instance.on("destroy", () => {
          console.info("destroy");
        });
      }
      function getExt(url) {
        if (url.includes("?")) {
          return getExt(url.split("?")[0]);
        }
        if (url.includes("#")) {
          return getExt(url.split("#")[0]);
        }
        return url.trim().toLowerCase().split(".").pop();
      }
      function selectSubTitle(fileInfo) {
        console.log(fileInfo.url);
        table.value = false;
        instance.subtitle.switch(fileInfo.url, {
          type: getExt(fileInfo.name)
        });
        instance.play();
      }
      function openSubTitle() {
        instance.pause();
        table.value = true;
      }
      function retryClick() {
        retries = 3;
        retry.loading = true;
        getVideoInfo(artp);
      }
      var hlsErrorHandler = function(event, data, art) {
        if (art.hls.error == -1) {
          console.log("在处理了");
          return;
        }
        var errorType = data.type;
        var errorDetails = data.details;
        var errorFatal = data.fatal;
        console.log(errorType);
        console.log(errorDetails);
        console.log(errorFatal);
        if (art.hls.error) {
          art.hls.error += 1;
        } else {
          art.hls.error = 1;
        }
        if (data.details == "fragLoadError" && (errorFatal || art.hls.error >= 4)) {
          art.hls.error = -1;
          retry403(art);
        } else if (errorType == "networkError" && errorFatal) {
          elementPlus.ElNotification({
            title: "网络错误",
            message: "请检查网络配置后,刷新页面",
            type: "error"
          });
        }
      };
      function m3u8Hls(video, url, art) {
        if (art.qualityHtml == " 原画") {
          video.src = url;
          return;
        }
        art.hls = new Hls2();
        art.hls.loadSource(url);
        art.hls.attachMedia(video);
        video.addEventListener("loadstart", function(e) {
          console.log("提示视频的元数据已加载" + video.src);
          if (art.hlsCurrentTime403) {
            video.currentTime = art.hlsCurrentTime403;
          }
        });
        art.hls.on(Hls2.Events.ERROR, function(e, d) {
          hlsErrorHandler(e, d, art);
        });
      }
      function retry403(art) {
        getVideoInfo(function(data) {
          let option = getOption(data);
          let index = option.findIndex(function(item2, index2) {
            return item2.html === art.qualityHtml;
          });
          if (index == -1) {
            index = option.length - 1;
          }
          let item = option[index];
          item["default"] = true;
          art.quality_.selector = option;
          art.hlsCurrentTime403 = art.currentTime;
          art.hls.destroy();
          art.hls.error = 0;
          art.hls = new Hls2();
          art.hls.loadSource(item.url);
          art.hls.attachMedia(art.video);
          art.hls.on(Hls2.Events.ERROR, function(e, d) {
            hlsErrorHandler(e, d, art);
          });
        });
      }
      function showSelectorOpen() {
        selectorRef.value.loadingList(instance.videoList);
      }
      function closeSelector() {
        instance.play();
      }
      function getVideoInfo(call) {
        let token = user.getToken();
        if (token == null) {
          elementPlus.ElMessageBox.alert("当前登录凭证获取为空,请刷新或重新登录", {
            confirmButtonText: "获取凭证失败",
            callback: (action) => {
              location.href = location.href;
            }
          });
          return;
        }
        let videoInfo = user.getVideoPage();
        let req;
        if (videoInfo.type == 0) {
          req = videoPreviewPlayInfo({
            category: "live_transcoding",
            drive_id: videoInfo.drive_id,
            file_id: videoInfo.id,
            template_id: "FHD|HD|SD|LD",
            url_expire_sec: 14400,
            get_subtitle_info: true
          });
        } else if (videoInfo.type == 1) {
          let shareToken = user.getShareToken();
          if (!user.isExpires(shareToken)) {
            elementPlus.ElMessageBox.alert("很抱歉,当前页面太久没活动了,请点击刷新后再来观看吧", "分享凭证失效", {
              confirmButtonText: "刷新",
              callback: (action) => {
                location.href = location.href;
              }
            });
          }
          req = shareVideoInfo(videoInfo.id, shareToken.share_id, shareToken.share_token);
        }
        req.then((res) => {
          retry.error = false;
          Artplayer2.ASPECT_RATIO = ["default", "1:1", "2:1", "4:3", "16:9", "21:9"];
          options = {
            id: videoInfo.id,
            poster: videoInfo.thumbnail,
            title: videoInfo.name,
            type: "m3u8",
            customType: {
              m3u8: m3u8Hls
            },
            flip: true,
            setting: true,
            playbackRate: true,
            aspectRatio: true,
            fullscreen: true,
            fullscreenWeb: true,
            miniProgressBar: true,
            autoplay: true,
            screenshot: true,
            hotkey: false,
            airplay: true,
            theme: "#23ade5",
            volume: 1,
            contextmenu: [],
            icons: {
              state: `<img width="150" heigth="150" src="${state}">`,
              indicator: `<img width="16" heigth="16" src="${indicator}">`
            }
          };
          if (videoInfo.type == 0) {
            $2(".text--KBVB3").text(videoInfo.name);
          } else if (videoInfo.type == 1) {
            $2(".header-file-name--CN_fq").text(videoInfo.name);
          }
          call && call(res.data);
        }).catch((e) => {
          if (instance) {
            instance.pause();
            instance.destroy(false);
          }
          if (e.skip) {
            return;
          }
          console.log(e);
          if (retries != 0) {
            retries = retries - 1;
            getVideoInfo(call);
          }
          if (e && e + "" == "AxiosError: Request failed with status code 429") {
            retry.text = "请稍候点击下方按钮,刷新尝试";
            retry.title = "您操作的太快了";
          } else {
            retry.title = "接口问题";
            retry.text = e + "";
          }
          retry.error = true;
        }).finally(() => {
          retry.loading = false;
        });
      }
      vue.onUnmounted(() => {
        if (instance) {
          instance.destroy(false);
        }
        console.log("视频页面销毁");
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
          vue.createVNode(vue.unref(elementPlus.ElDrawer), {
            modelValue: table.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => table.value = $event),
            title: "请选择字幕文件",
            direction: "rtl",
            size: "25%"
          }, {
            default: vue.withCtx(() => [
              vue.createVNode(SubTitle, {
                onSelectSubTitle: selectSubTitle,
                ref_key: "subtitleRef",
                ref: subtitleRef
              }, null, 512)
            ]),
            _: 1
          }, 8, ["modelValue"]),
          vue.createVNode(vue.unref(elementPlus.ElDrawer), {
            modelValue: showSelector.value,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => showSelector.value = $event),
            title: "选集",
            direction: "rtl",
            size: "20%",
            onOpen: showSelectorOpen,
            onClose: closeSelector
          }, {
            default: vue.withCtx(() => [
              vue.createVNode(Selector, {
                videoList: _ctx.videoList,
                ref_key: "selectorRef",
                ref: selectorRef,
                onNext: nextVideo
              }, null, 8, ["videoList"])
            ]),
            _: 1
          }, 8, ["modelValue"]),
          vue.withDirectives(vue.createElementVNode("div", {
            class: "player",
            ref_key: "artRef",
            ref: artRef
          }, null, 512), [
            [vue.vShow, !retry.error]
          ]),
          vue.withDirectives(vue.createVNode(vue.unref(elementPlus.ElResult), {
            title: retry.title,
            "sub-title": retry.text
          }, {
            extra: vue.withCtx(() => [
              vue.createVNode(vue.unref(elementPlus.ElButton), {
                type: "primary",
                loading: retry.loading,
                onClick: vue.withModifiers(retryClick, ["stop"])
              }, {
                default: vue.withCtx(() => [
                  vue.createTextVNode("刷新")
                ]),
                _: 1
              }, 8, ["loading", "onClick"])
            ]),
            _: 1
          }, 8, ["title", "sub-title"]), [
            [vue.vShow, retry.error]
          ])
        ], 64);
      };
    }
  };
  const VideoPage = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-ee523f38"]]);
  const _hoisted_1$2 = { style: { "padding-bottom": "10px" } };
  const _hoisted_2$2 = { style: { "height": "410px", "overflow-y": "auto" } };
  const _hoisted_3$2 = {
    key: 0,
    align: "center",
    width: "100%",
    color: "#1890ff",
    size: "1/"
  };
  const _hoisted_4$2 = { style: { "padding-bottom": "13px" } };
  const _hoisted_5$2 = ["onClick"];
  const _hoisted_6$2 = /* @__PURE__ */ vue.createElementVNode("a", null, "清空本地历史", -1);
  const _hoisted_7$1 = [
    _hoisted_6$2
  ];
  const _hoisted_8$1 = {
    "data-index": "0",
    class: "tr-wrapper--RxoAI",
    style: { "height": "52px", "width": "100%" }
  };
  const _hoisted_9$1 = /* @__PURE__ */ vue.createElementVNode("div", {
    class: "padding-element-horizontal--pMTS6",
    style: { "width": "32px" }
  }, null, -1);
  const _hoisted_10$1 = {
    class: "drop-wrapper--T27s",
    "data-drop-target": "false"
  };
  const _hoisted_11 = {
    "data-is-dragging": "false",
    class: "drag-wrapper---smTQ",
    draggable: "true"
  };
  const _hoisted_12 = {
    class: "tr--Ogi-3 tr--97U9T",
    "data-is-selected": "false",
    "data-clickable": "true",
    "data-has-checkbox": "true",
    style: { "cursor": "pointer" }
  };
  const _hoisted_13 = ["onClick"];
  const _hoisted_14 = /* @__PURE__ */ vue.createElementVNode("span", {
    "data-role": "icon",
    "data-render-as": "svg",
    "data-icon-type": "PDSMore",
    class: "ant-dropdown-trigger icon--d-ejA"
  }, [
    /* @__PURE__ */ vue.createElementVNode("svg", {
      t: "1676180557921",
      class: "icon",
      viewBox: "0 0 1024 1024",
      version: "1.1",
      xmlns: "http://www.w3.org/2000/svg",
      "p-id": "3478",
      width: "16",
      height: "16"
    }, [
      /* @__PURE__ */ vue.createElementVNode("path", {
        d: "M374.6 636.5c4.4 0 8.5-1.2 12.1-3.3l171.7-100c8-3.6 13.6-11.9 13.6-21.5 0-8.8-4.8-16.6-11.9-20.7l-167.8-97.8c-4.3-5-10.7-8.1-17.7-8.1-13.1 0-23.6 10.7-23.6 23.8v1.3l-0.3 0.2 0.4 199.8c-0.1 0.8-0.1 1.6-0.1 2.5 0 13.2 10.6 23.8 23.6 23.8z",
        fill: "#4D4D4D",
        "p-id": "3479"
      }),
      /* @__PURE__ */ vue.createElementVNode("path", {
        d: "M64.7 586.3a32.2 32.1 0 1 0 64.4 0 32.2 32.1 0 1 0-64.4 0Z",
        fill: "#4D4D4D",
        "p-id": "3480"
      }),
      /* @__PURE__ */ vue.createElementVNode("path", {
        d: "M960 398.3c0.1-1.6 0.2-3.2 0.2-4.8 0-35-28.5-63.3-63.6-63.3-11.7 0-22.7 3.2-32.2 8.7l-0.5-0.3-31.5 18.2v-64.7c-0.1-73.1-59.9-133-133.1-133H197.4c-73.1 0-133 59.8-133 133v165.8h0.2c0 17.7 14.4 32.1 32.2 32.1s32.2-14.4 32.2-32.1h0.2V287c0-35.2 28.8-64 64-64h510.2c35.2 0 64 28.8 64 64v448.9c0 35.2-28.8 64-64 64H193.3c-35.2 0-64-28.8-64-64v-21.4c0-17.7-14.4-32.1-32.2-32.1-17.8 0-32.2 14.4-32.2 32.1h-0.4v15.3c0 73.2 59.9 133 133 133h501.9c73.2 0 133-59.8 133-133v-64.1l33.1 19.1 0.1-0.1c9.2 5.1 19.8 8 31 8 35.1 0 63.6-28.4 63.6-63.3 0-1.6-0.1-3.2-0.2-4.8V398.3z m-63.6 205.1c-0.3 7.8-6.9 14.1-15 14.1-2.7 0-5.3-0.7-7.5-2l-41.5-23.7V430.1l40.9-23.2c2.3-1.5 5.1-2.3 8.1-2.3 8.3 0 15 6.6 15 14.6v184.2z",
        fill: "#4D4D4D",
        "p-id": "3481"
      })
    ])
  ], -1);
  const _hoisted_15 = [
    _hoisted_14
  ];
  const _hoisted_16 = ["onClick"];
  const _hoisted_17 = /* @__PURE__ */ vue.createElementVNode("div", {
    class: "cover--Mn1Bt file-cover--tJG-H",
    "data-size": "XXS",
    "data-thumbnail": "normal"
  }, [
    /* @__PURE__ */ vue.createElementVNode("div", { class: "is-loaded--otXtL thumbnail-wrapper--aGcWv" }, [
      /* @__PURE__ */ vue.createElementVNode("div", { class: "thumbnail--skb-6 fill-mode-cover--VWUJo size-xxs--oSITU" }, [
        /* @__PURE__ */ vue.createElementVNode("img", {
          alt: "video",
          class: "fileicon--38wQG fileicon---webs",
          draggable: "false",
          src: "https://img.alicdn.com/imgextra/i2/O1CN01H7FCkb1P6mPJxDEFa_!!6000000001792-2-tps-80-80.png"
        })
      ])
    ])
  ], -1);
  const _hoisted_18 = ["title"];
  const _hoisted_19 = ["onClick"];
  const _hoisted_20 = { class: "text-secondary--kiARj" };
  const _hoisted_21 = {
    class: "td--SGrZj td---v-kp",
    "data-col-key": "size",
    style: { "width": "160px", "flex": "0 0 auto" }
  };
  const _hoisted_22 = { class: "text-secondary--kiARj" };
  const _hoisted_23 = ["href"];
  const _hoisted_24 = /* @__PURE__ */ vue.createElementVNode("div", {
    class: "padding-element-horizontal--39l8Q",
    style: { "width": "32px" }
  }, null, -1);
  const _sfc_main$2 = {
    __name: "VideoHistoryPage",
    setup(__props) {
      let locList = vue.ref(user.getVideoLookList());
      let clodList = vue.ref([]);
      let listData = vue.ref([
        {
          key: "本地历史",
          list: locList
        },
        {
          key: "云端历史",
          list: clodList
        }
      ]);
      vue.onMounted(() => {
        videoHistoryList(listFuction);
      });
      function listFuction(data) {
        if (data.length != 0) {
          clodList.value = data;
        }
      }
      function clearHistory() {
        user.clearVideoHistory();
      }
      function playInfo(videoItem) {
        if (videoItem.share) {
          location.href = videoItem.href;
          return;
        }
        let vInfo = user.getVideoPage();
        vInfo.id = videoItem.id;
        vInfo.play_cursor = videoItem.play_cursor;
        vInfo.name = videoItem.name;
        vInfo.thumbnail = "";
        vInfo.folderName = videoItem.folderName;
        vInfo.type = 0;
        vInfo.href = videoItem.href;
        let html2 = `<div class="modal--nw7G9" id="videoHistory">
    <div class="web--sYiY- container--5Stu-">
      <div class="content--9N3Eh">
        <div class="header--u7XR-" data-layout-sider-open="true">
        <div class="header-right--jsds3">
          <div class="nav-actions--hGPM3">
          <span class="nav-action--McoQC nav-prev--f5MXf">
                    <span data-role="icon" data-render-as="svg" data-icon-type="PDSLeftNormal" class="nav-icon--0dKs7 icon--D3kMk "  style="color:#1890ff">
                  <svg viewBox="0 0 1024 1024">
                    <use xlink:href="#PDSRightNormal">
                    </use>
                  </svg>
                </span>
                <span class="nav-text--gdQi6">
                  <a href="${vInfo.href}">进入到当前目录</a>
                </span>
              </span>
            </div>
          <div class="separator--cn-Xf">
            </div>
          </div>
        <div class="header-center--CexZ2">
          <div class="filename--cpLKM">
              <span class="text--KBVB3">${vInfo.name}</span>
            </div>
          </div>
          <div style="padding:10px" id="header-close">
            <span data-role="icon" data-render-as="svg" data-icon-type="PDSClose"  class="icon--BObaC icon--D3kMk ">
              <svg viewBox="0 0 1024 1024" data-spm-anchor-id="0.0.0.i4.54a06c75hUkxKw">
                <use xlink:href="#PDSClose">
                </use>
              </svg>
            </span>
          </div>
        </div>
        <div class="previewer--g6qCF">
          <div class="video-previewer--6slx7">
 		<div class="video-previewer-container--43gy-"  tabindex="-1" data-fullscreen="false">
               <div class="video-stage---5FXB">
                <video class="video--26SLZ" preload="metadata" src="">
                </video>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>`;
        $2("#root").append(html2);
        var app = vue.createApp(VideoPage);
        app.mount(
          (() => {
            const app2 = $2(`<div id="videoPage" class='video-previewer--6slx7'></div>`)[0];
            $2(".previewer--g6qCF").replaceWith(app2);
            $2(".ant-modal-Link .icon-wrapper--TbIdu").click();
            return app2;
          })()
        );
        $2("#header-close").one("click", function() {
          app.unmount();
          $2("#videoHistory").remove();
        });
      }
      let videoHistoryList = function(callback) {
        homeWidgets().then((res) => {
          if (res.data && res.data.recentUsed) {
            let videoList = res.data.recentUsed.items.filter(function(item, index) {
              return item.category === "video";
            });
            videoList = videoList.map((item) => {
              let href = "https://www.aliyundrive.com/drive/";
              if (item.compilationId) {
                let i2 = item.compilationId.indexOf("_");
                let compilationId = item.compilationId.substring(i2 + 1, item.compilationId.length);
                href = "https://www.aliyundrive.com/drive/folder/" + compilationId;
              }
              return {
                "category": "video",
                "name": item.name,
                "progress": item.progressPercentage,
                "id": item.fileId,
                "folderName": item.fromSourceDescription,
                "href": href,
                "share": false,
                "play_cursor": item.playCursor
              };
            });
            callback && callback(videoList);
            return;
          }
          callback && callback([]);
        }).catch((err) => {
          callback && callback([]);
        });
      };
      vue.onUnmounted(() => {
        console.log("历史页面销毁");
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock("div", null, [
          vue.createElementVNode("p", _hoisted_1$2, " 最近观看了" + vue.toDisplayString(vue.unref(locList).length + vue.unref(clodList).length) + "个视频", 1),
          vue.createElementVNode("div", _hoisted_2$2, [
            (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(listData), (data, i1) => {
              return vue.openBlock(), vue.createElementBlock("div", { key: i1 }, [
                data.key == "云端历史" ? (vue.openBlock(), vue.createElementBlock("hr", _hoisted_3$2)) : vue.createCommentVNode("", true),
                vue.createElementVNode("h1", _hoisted_4$2, vue.toDisplayString(data.key), 1),
                data.key == "本地历史" ? (vue.openBlock(), vue.createElementBlock("p", {
                  key: 1,
                  class: "text-secondary--38-Of clearHistory",
                  style: { "padding-bottom": "13px" },
                  onClick: vue.withModifiers(clearHistory, ["stop"])
                }, _hoisted_7$1, 8, _hoisted_5$2)) : vue.createCommentVNode("", true),
                (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.list, (item, index) => {
                  return vue.openBlock(), vue.createElementBlock("div", {
                    style: { "height": "52px", "width": "100%" },
                    key: index
                  }, [
                    vue.createElementVNode("div", _hoisted_8$1, [
                      _hoisted_9$1,
                      vue.createElementVNode("div", _hoisted_10$1, [
                        vue.createElementVNode("div", _hoisted_11, [
                          vue.createElementVNode("div", _hoisted_12, [
                            vue.createElementVNode("div", {
                              onClick: ($event) => playInfo(item),
                              class: "checkbox--P-zHa checkbox-container--t0ALJ",
                              role: "checkbox",
                              "aria-checked": "false",
                              "data-checked": "false",
                              "data-partial": "false",
                              "data-disabled": "false",
                              "data-no-padding": "false"
                            }, _hoisted_15, 8, _hoisted_13),
                            vue.createElementVNode("div", {
                              class: "td--SGrZj td---v-kp history_video",
                              compilationid: "",
                              "data-col-key": "name",
                              style: { "flex": "1 1 0%", "min-width": "160px" },
                              onClick: ($event) => playInfo(item)
                            }, [
                              _hoisted_17,
                              vue.createElementVNode("p", {
                                class: "text-primary--JzAb9",
                                title: item.name
                              }, vue.toDisplayString(item.name), 9, _hoisted_18)
                            ], 8, _hoisted_16),
                            vue.createElementVNode("div", {
                              compilationid: "",
                              class: "history_video td--SGrZj td---v-kp",
                              "data-col-key": "updated_at",
                              style: { "width": "200px", "flex": "0 0 auto" },
                              onClick: ($event) => playInfo(item)
                            }, [
                              vue.createElementVNode("p", _hoisted_20, "已观看" + vue.toDisplayString(item.progress) + "%", 1)
                            ], 8, _hoisted_19),
                            vue.createElementVNode("div", _hoisted_21, [
                              vue.createElementVNode("p", _hoisted_22, [
                                vue.createElementVNode("a", {
                                  href: item.href
                                }, vue.toDisplayString(item.folderName), 9, _hoisted_23)
                              ])
                            ])
                          ])
                        ])
                      ]),
                      _hoisted_24
                    ])
                  ]);
                }), 128))
              ]);
            }), 128))
          ])
        ]);
      };
    }
  };
  let showDownloadHomePage = function() {
    let app = vue.createApp(DwoloadPage);
    showDiv("文件下载", app);
  };
  function initMenuButton(menuName) {
    if ($2(".button-download-aliyun").length !== 0) {
      return;
    }
    var css = "#root header:eq(0)";
    if ($2(css).length > 0) {
      var html2 = "";
      html2 += '<div style="margin:1px 8px;"></div><div class="button--WC7or primary--NVxfK small--e7LRt history-video"><span style="margin-right:2px" data-role="icon"data-render-as="svg"data-icon-type="PDSAddS"class="icon--D3kMk"><svg t="1676170067530"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2764"width="200"height="200"><path d="M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 229.248 512 512-229.248 512-512 512z m42.666667-486.869333V298.538667C554.666667 275.328 535.552 256 512 256c-23.722667 0-42.666667 19.029333-42.666667 42.538667v256.256a41.984 41.984 0 0 0 12.202667 29.866666l121.258667 121.258667a42.368 42.368 0 0 0 60.032-0.298667 42.666667 42.666667 0 0 0 0.298666-60.032L554.666667 537.130667z"fill="#ffffff"p-id="2765"></path></svg></span>最近在看</div>';
      html2 += '<div style="margin:1px 8px;"></div><div class="button--WC7or primary--NVxfK small--e7LRt button-download-aliyun">显示链接</div>';
      $2(".history-video").remove();
      $2(".button-download-aliyun").remove();
      $2(css).append(html2);
      $2(".button-download-aliyun").on("click", showDownloadHomePage);
      $2(".history-video").on("click", () => {
        let app = vue.createApp(_sfc_main$2);
        showDiv(`<div style="display:flex; justify-content:center;  align-items:center;">
                    <span data-role="icon" data-render-as="svg" data-icon-type="PDSRecent" class="icon--d-ejA ">
                        <svg viewBox="0 0 1024 1024"><use xlink:href="#PDSRecent"></use></svg>
                        </span>最近在看</div>`, app);
      });
    } else {
      setTimeout(function() {
        initMenuButton();
      }, 1e3);
    }
  }
  const home = (menuName) => {
    initMenuButton();
  };
  function handler$2(res) {
    let data = res.data;
    let response = res.response;
    let page = user.getPage();
    let items = [];
    if (page.id === data.parent_file_id && page.order === data.order_direction && page.order_by === data.order_by && page.drive_id === data.drive_id) {
      items = response.items;
    } else {
      page.id = data.parent_file_id;
      page.order = data.order_direction;
      page.drive_id = data.drive_id;
      page.order_by = data.order_by;
      page.items = response.items;
    }
    let folderName = $2(".breadcrumb-item-link--9zcQY:last").text();
    page.folderName = folderName;
    if (items.length > 0) {
      if (!page.items) {
        page.items = [];
      }
      items.forEach(function(newItem) {
        var existingItemIndex = page.items.findIndex(function(oldItem) {
          return oldItem.file_id === newItem.file_id;
        });
        if (existingItemIndex !== -1) {
          page.items[existingItemIndex] = newItem;
        } else {
          page.items.push(newItem);
        }
      });
    }
    console.log(`已加载${page.items.length}个文件`);
    showSuccess(`已加载${page.items.length}个文件`);
    if ($2(".button-download-aliyun").length <= 0 && user.home()) {
      home();
    }
  }
  const fileList = () => {
    http.onResponse(function(res, url) {
      let config = res.config;
      try {
        config.data = JSON.parse(config.data);
      } catch (error) {
        config.data = {};
      }
      let response = {
        response: res.response,
        data: config.data
      };
      if (url.indexOf("/file/list") > 0 || url.indexOf("/file/search") > 0 || url.indexOf("/adrive/v1/intelligent/movie") > 0 || url.indexOf("/adrive/v1/intelligent/tv") > 0) {
        handler$2(response);
      }
    });
  };
  var interval;
  function initVideoPlayer(videoFile) {
    let node = $2(".video-previewer--6slx7");
    if (node.length <= 0) {
      if (interval == null) {
        interval = setInterval(function() {
          initVideoPlayer(videoFile);
        }, 200);
      }
      return;
    } else {
      clearInterval(interval);
      interval = null;
    }
    let vInfo = user.getVideoPage();
    vInfo.id = videoFile.file_id;
    if (videoFile.user_meta) {
      try {
        let meta = JSON.parse(videoFile.user_meta);
        if (meta.duration) {
          vInfo.duration = meta.duration;
        }
        if (meta.play_cursor) {
          vInfo.play_cursor = meta.play_cursor;
        }
      } catch (error) {
        console.error(error);
      }
    }
    vInfo.name = videoFile.name;
    vInfo.drive_id = videoFile.drive_id;
    vInfo.thumbnail = videoFile.thumbnail;
    vInfo.folderName = user.getPage().folderName;
    vInfo.type = 0;
    vInfo.href = location.href;
    var app = vue.createApp(VideoPage);
    app.mount(
      (() => {
        const app2 = $2(`<div id="videoPage" class='video-previewer--6slx7'></div>`)[0];
        node.replaceWith(app2);
        return app2;
      })()
    );
    $2(".header-left--Kobd9").on("click", function() {
      app.unmount();
    });
  }
  function homeVideo(videoFile) {
    if (interval != null) {
      clearInterval(interval);
    }
    initVideoPlayer(videoFile);
  }
  function shareVideo$1(videoFile) {
    let node = $2(".video-previewer--Rg9fI");
    if (node.length <= 0) {
      if (interval == null) {
        interval = setInterval(function() {
          shareVideo$1(videoFile);
        }, 200);
      }
      return;
    } else {
      clearInterval(interval);
      interval = null;
    }
    let it = user.getPage().items;
    let index = it.findIndex((item) => {
      return item.file_id == videoFile.file_id;
    });
    console.log(index);
    if (index == -1) {
      elementPlus.ElMessageBox.alert("手速太快啦,请回到文件列表中,随便点击排序,看到已加载多少文件时,在进来吧", "操作页面过快", {
        confirmButtonText: "去排序",
        callback: (action) => {
          location.href = location.href;
        }
      });
      return;
    }
    let v = it[index];
    v.user_meta = "{}";
    let vInfo = user.getVideoPage();
    let list = user.getVideoLookList();
    index = list.findIndex((item) => {
      return item.id == videoFile.file_id;
    });
    if (index != -1) {
      vInfo.play_cursor = list[index].play_cursor;
    }
    vInfo.id = v.file_id;
    vInfo.name = v.name;
    vInfo.thumbnail = v.thumbnail;
    vInfo.type = 1;
    vInfo.folderName = "来自分享";
    vInfo.href = location.href;
    var app = vue.createApp(VideoPage);
    app.mount(
      (() => {
        const app2 = $2(`<div id="videoPage" class='video-previewer--Rg9fI'></div>`)[0];
        node.replaceWith(app2);
        return app2;
      })()
    );
    $2(".header-icon--bJn--").on("click", function() {
      app.unmount();
    });
  }
  function handler$1(res) {
    let response = res.response;
    if (response.category && response.category === "video") {
      homeVideo(response);
    }
  }
  const fileGet = () => {
    http.onResponse(function(res, url) {
      let config = res.config;
      try {
        config.data = JSON.parse(config.data);
      } catch (error) {
        config.data = {};
      }
      let response = {
        response: res.response,
        data: config.data
      };
      if (url.endsWith("/file/get")) {
        handler$1(response);
      }
    });
  };
  function handler(res) {
    let response = res.response;
    let shareToken = user.getShareToken();
    if (!user.isExpires(shareToken) || shareToken.share_id != response.share_id) {
      showError("当前页面已过期,请刷新重试");
      return;
    }
    shareVideo$1(response);
  }
  const shareVideo = () => {
    http.onResponse(function(res, url) {
      let config = res.config;
      try {
        config.data = JSON.parse(config.data);
      } catch (error) {
        config.data = {};
      }
      let response = {
        response: res.response,
        data: config.data
      };
      if (url.indexOf("get_video_preview_play_info_by_share") > 0) {
        handler(response);
      }
    });
  };
  const fileUpdate = () => {
    http.onRequest(function(req) {
      if (req.url.endsWith("v3/file/update")) {
        let reqbody = JSON.parse(req.data[0]);
        let name2 = reqbody.name;
        let i2 = name2.lastIndexOf(".");
        if (i2 === -1) {
          return;
        }
        let newName = name2.substring(0, i2);
        if (newName.lastIndexOf(".") !== -1) {
          reqbody.name = newName;
          req.data[0] = JSON.stringify(reqbody);
        }
      }
    });
  };
  const logout = () => {
    http.onRequest(function(req) {
      if (req.url.endsWith("/users/v1/users/device_logout")) {
        deviceLogout();
        console.log("sadasd");
      }
    });
  };
  const xhrHandler = () => {
    fileList();
    fileGet();
    shareVideo();
    fileUpdate();
    logout();
  };
  class XMLHttp {
    constructor() {
      __publicField(this, "request", function(param) {
      });
      __publicField(this, "response", function(param) {
      });
      __publicField(this, "onRequest", function(cal) {
        this.requestListen.push(cal);
      });
      __publicField(this, "onResponse", function(cal) {
        this.responseListen.push(cal);
      });
      this.responseListen = [];
      this.requestListen = [];
    }
  }
  function initXMLHttpRequest(http2) {
    let open = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(...args) {
      let send = this.send;
      let _this = this;
      let post_data = [];
      this.send = function(...data) {
        post_data = data;
        let dataBody = {
          url: args[1],
          method: args[0],
          headers: {},
          data
        };
        if (_this._header_) {
          dataBody.headers = _this._header_;
        }
        if (_this._header_ && _this._header_["fileId"]) {
          return send.apply(_this, data);
        }
        http2.request(dataBody);
        return send.apply(_this, data);
      };
      this.addEventListener("readystatechange", function() {
        if (this.readyState === 4) {
          let config = {
            url: args[1],
            status: this.status,
            method: args[0],
            data: post_data
          };
          let res = this.response;
          if (_this._header_ && _this._header_["fileId"]) {
            return;
          }
          if (typeof res == "string") {
            try {
              res = JSON.parse(this.response);
            } catch (e) {
              console.log("解析出问题了, ", e);
              return;
            }
          }
          http2.response({ config, response: res });
        }
      }, false);
      return open.apply(this, args);
    };
  }
  const http = new XMLHttp();
  function listen() {
    xhrHandler();
    http.request = function(req) {
      if (this.requestListen.length > 0) {
        this.requestListen.forEach((i2) => {
          i2(req);
        });
      }
    };
    http.response = function(res) {
      if (this.responseListen.length > 0) {
        let config = res.config;
        this.responseListen.forEach((i2) => {
          i2(res, config.url);
        });
      }
    };
    initXMLHttpRequest(http);
  }
  let shareId = function() {
    var url = location.href;
    var match = url.match(/(aliyundrive|alipan)\.com\/s\/([a-zA-Z\d]+)/);
    return match ? match[2] : null;
  };
  let showDownloadSharePage = function() {
    let shareToken = user.getShareToken();
    if (!user.isExpires(shareToken)) {
      showError$1("当前页面已过期,请刷新重试");
      return;
    } else if (shareId() != shareToken.share_id) {
      location.reload();
      return;
    }
    let app = vue.createApp(DwoloadPage);
    showShareDiv("文件下载", app);
  };
  function initShareButton() {
    if ($2(".button-download-aliyun").length !== 0) {
      $2(".button-download-aliyun").remove();
    }
    if ($2("#root [class^=banner] [class^=right]").length !== 0 && $2(".button--fep7l").length == 0) {
      var html2 = "";
      html2 += '<div style="margin:1px 7px;"></div><button class="button--WC7or primary--NVxfK  medium--Pt0UL button-download-aliyun">显示链接</button>';
      $2("#root [class^=banner] [class^=right]").prepend(html2);
      $2(".button-download-aliyun").on("click", showDownloadSharePage);
    } else {
      setTimeout(initShareButton, 1e3);
    }
  }
  const share = () => {
    initShareButton();
  };
  const SignInPage_vue_vue_type_style_index_0_scoped_46fc6531_lang = "";
  const _withScopeId$1 = (n) => (vue.pushScopeId("data-v-46fc6531"), n = n(), vue.popScopeId(), n);
  const _hoisted_1$1 = {
    key: 0,
    class: "notice"
  };
  const _hoisted_2$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_3$1 = {
    key: 1,
    class: "notice2"
  };
  const _hoisted_4$1 = {
    key: 2,
    class: "notice"
  };
  const _hoisted_5$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _hoisted_6$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  const _sfc_main$1 = {
    __name: "SignInPage",
    setup(__props) {
      const signInSwitch = vue.ref(false);
      const signInSet = vue.ref({
        goods_info: {
          name: "",
          description: "",
          notice: ""
        }
      });
      const isSigIn = vue.computed(() => {
        return isSignIn();
      });
      async function signIn() {
        const data = await signInList();
        if (data.status !== 200) {
          showError$1("签到失败,服务器响应:" + data.status);
          return;
        }
        let signin_count = data.data["result"]["signInCount"];
        console.log(signin_count);
        var reward = await signInReward(signin_count);
        if (data.status !== 200) {
          showError$1("领取奖励失败,服务器响应:" + reward.status);
          return;
        }
        const res = reward.data;
        let rewardName = res["result"]["name"];
        let rewardDescription = res["result"]["description"];
        let rewardNotice = res["result"]["notice"];
        signInSet.value["last_siginIn"] = getNowDate();
        signInSet.value["goods_info"] = {
          name: rewardName,
          description: rewardDescription,
          notice: rewardNotice
        };
        showSuccess(rewardNotice);
        user.setSignInSet(signInSet.value);
      }
      const changeEvent = () => {
        signInSet.value["status"] = signInSwitch.value;
        if (!isSignIn() && signInSwitch.value) {
          signIn();
        }
        user.setSignInSet(signInSet.value);
      };
      function getNowDate() {
        var currentDate = new Date();
        var year = currentDate.getFullYear();
        var month = currentDate.getMonth() + 1;
        var day = currentDate.getDate();
        return year + "" + month + day;
      }
      function isSignIn() {
        const now = getNowDate();
        return signInSet.value["last_siginIn"] == now;
      }
      vue.onMounted(async () => {
        let _signInSet = user.getSignInSet();
        if (Object.keys(_signInSet).length > 0) {
          signInSet.value = _signInSet;
        }
        signInSwitch.value = _signInSet["status"] == true;
        if (!isSignIn() && signInSwitch.value) {
          signIn();
        }
      });
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
          vue.createElementVNode("p", null, [
            vue.unref(isSigIn) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1$1, "今日:已签到")) : vue.createCommentVNode("", true),
            vue.createTextVNode(),
            _hoisted_2$1,
            !vue.unref(isSigIn) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_3$1, "今日:末签到")) : vue.createCommentVNode("", true),
            vue.unref(isSigIn) ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_4$1, [
              vue.createTextVNode(vue.toDisplayString(signInSet.value.goods_info.name), 1),
              _hoisted_5$1,
              vue.createTextVNode(" " + vue.toDisplayString(signInSet.value.goods_info.description), 1),
              _hoisted_6$1
            ])) : vue.createCommentVNode("", true)
          ]),
          vue.createVNode(vue.unref(elementPlus.ElForm), { style: { "max-width": "100%" } }, {
            default: vue.withCtx(() => [
              vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "自动签到" }, {
                default: vue.withCtx(() => [
                  vue.createVNode(vue.unref(elementPlus.ElSwitch), {
                    modelValue: signInSwitch.value,
                    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => signInSwitch.value = $event),
                    "inline-prompt": "",
                    "active-text": "是",
                    "inactive-text": "否",
                    onChange: changeEvent
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ], 64);
      };
    }
  };
  const SignIn = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-46fc6531"]]);
  var globalMenuName;
  function showHomeUi(menuName) {
    globalMenuName = menuName;
    console.log(globalMenuName);
    if (menuName === "文件" || menuName === "收藏夹" || menuName === "密码箱") {
      setTimeout(function() {
        home();
      }, 200);
    }
  }
  function initHomeUi() {
    let menu = $2(".nav-menu--Lm1q6");
    if (menu.length !== 0) {
      $2(".nav-tab-item--WhAQf").on("click", function(e) {
        showHomeUi(e.currentTarget.textContent);
      });
      setInterval(function() {
        let node = $2(".is-active--8atYr:eq(0)");
        if (node.length > 0) {
          if (node.text() !== globalMenuName) {
            showHomeUi(node.text());
          }
        }
      }, 700);
      setTimeout(function() {
        let node = $2(".is-active--8atYr:eq(0)");
        if (node.length > 0) {
          showHomeUi(node.text());
        }
      }, 300);
    } else {
      setTimeout(initHomeUi, 500);
    }
  }
  function signInUi() {
    let storage = $2(".storage-wrapper--h-rcS");
    if (storage.length !== 0) {
      let app = vue.createApp(SignIn);
      app.mount(
        (() => {
          const app2 = document.createElement("div");
          storage.prepend(app2);
          return app2;
        })()
      );
    } else {
      setTimeout(signInUi, 500);
    }
  }
  const ui = () => {
    if (user.home()) {
      initHomeUi();
      signInUi();
    } else {
      share();
    }
  };
  var sessionLoadding = false;
  var listenArray = new Array();
  let interceptRequest = function() {
    axios2.interceptors.request.use(async function(config) {
      let token = user.getToken();
      if (token == null) {
        showError$1("当前登录凭证获取为空,请刷新或重新登录");
        throw "token 为空了";
      } else if (!user.isExpires(token)) {
        showError$1("Token已失效,请刷新或重新登录");
        throw "Token已失效,请刷新或重新登录";
      }
      let isToken = config.headers._token;
      config.headers["authorization"] = "".concat(token.token_type || "", " ").concat(token.access_token || "");
      config.headers["fileId"] = token.user_id;
      if (isToken != null && isToken == false) {
        delete config.headers._token;
        return config;
      }
      let session_ref = store.getItem("LG_session_Ref");
      if (session_ref != "" && session_ref == "true") {
        await new Promise((resolve, reject) => {
          function check() {
            if (store.getItem("LG_session_Ref") == "") {
              resolve();
            } else {
              setTimeout(check, 200);
            }
          }
          check();
        });
      }
      if (sessionLoadding) {
        await new Promise((resolve, reject) => {
          listenArray.push(function() {
            resolve();
          });
        });
      }
      let d = user.getDeviceId();
      let s2 = user.getSignature();
      if (d == "" || s2 == "") {
        sessionLoadding = true;
        let rest = await user.session(token, function() {
        });
        if (rest.deviceId) {
          d = rest.deviceId;
        }
        if (rest.signature) {
          s2 = rest.signature;
        }
      }
      sessionLoadding = false;
      if (listenArray.length > 0) {
        listenArray.forEach((i2) => {
          i2 && i2();
        });
        listenArray = new Array();
      }
      config.headers["x-device-id"] = d;
      config.headers["x-signature"] = s2;
      return config;
    }, function(error) {
      console.log("出现异常", error);
      return Promise.reject(error);
    });
    axios2.interceptors.response.use(function(response) {
      return response;
    }, function(error) {
      let repsonse = error.response;
      if (repsonse && repsonse.status == 401 && repsonse.data.code == "UserDeviceOffline") {
        user.clearSession();
        showError$1("当前设备已失效,请刷新重试");
        elementPlus.ElMessageBox.alert("请确认是否有下线设备操作,当前设备已失效", "刷新session失败", {
          confirmButtonText: "刷新试一试",
          callback: (action) => {
            location.href = location.href;
          }
        });
      }
      if (repsonse && repsonse.status == 400 && repsonse.data.code == "DeviceSessionSignatureInvalid") {
        user.removeSession();
        elementPlus.ElMessageBox.alert("当前设备session过去,点击刷新session", "session过期", {
          confirmButtonText: "刷新",
          callback: (action) => {
            location.href = location.href;
          }
        });
        error.skip = true;
      }
      if (repsonse && repsonse.status == 400 && repsonse.data.message == "not found device info") {
        user.clearSession();
        showError$1("当前设备已失效,请刷新重试");
        elementPlus.ElMessageBox.alert("请确认是否有下线设备操作,当前设备已失效", "设备失效", {
          confirmButtonText: "刷新试一试",
          callback: (action) => {
            location.href = location.href;
          }
        });
      }
      console.error("错误信息:", repsonse.data.message);
      return Promise.reject(error);
    });
  };
  const apiConfig = () => {
    axios2.defaults.baseURL = "https://api.aliyundrive.com";
    interceptRequest();
  };
  var exports$2 = {};
  function isSurrogatePair$1(msg, i2) {
    if ((msg.charCodeAt(i2) & 64512) !== 55296) {
      return false;
    }
    if (i2 < 0 || i2 + 1 >= msg.length) {
      return false;
    }
    return (msg.charCodeAt(i2 + 1) & 64512) === 56320;
  }
  function toArray$1(msg, enc) {
    if (Array.isArray(msg))
      return msg.slice();
    if (!msg)
      return [];
    var res = [];
    if (typeof msg === "string") {
      if (!enc) {
        var p = 0;
        for (var i2 = 0; i2 < msg.length; i2++) {
          var c = msg.charCodeAt(i2);
          if (c < 128) {
            res[p++] = c;
          } else if (c < 2048) {
            res[p++] = c >> 6 | 192;
            res[p++] = c & 63 | 128;
          } else if (isSurrogatePair$1(msg, i2)) {
            c = 65536 + ((c & 1023) << 10) + (msg.charCodeAt(++i2) & 1023);
            res[p++] = c >> 18 | 240;
            res[p++] = c >> 12 & 63 | 128;
            res[p++] = c >> 6 & 63 | 128;
            res[p++] = c & 63 | 128;
          } else {
            res[p++] = c >> 12 | 224;
            res[p++] = c >> 6 & 63 | 128;
            res[p++] = c & 63 | 128;
          }
        }
      } else if (enc === "hex") {
        msg = msg.replace(/[^a-z0-9]+/ig, "");
        if (msg.length % 2 !== 0)
          msg = "0" + msg;
        for (i2 = 0; i2 < msg.length; i2 += 2)
          res.push(parseInt(msg[i2] + msg[i2 + 1], 16));
      }
    } else {
      for (i2 = 0; i2 < msg.length; i2++)
        res[i2] = msg[i2] | 0;
    }
    return res;
  }
  exports$2.toArray = toArray$1;
  function toHex$2(msg) {
    var res = "";
    for (var i2 = 0; i2 < msg.length; i2++)
      res += zero2$1(msg[i2].toString(16));
    return res;
  }
  exports$2.toHex = toHex$2;
  function htonl$1(w) {
    var res = w >>> 24 | w >>> 8 & 65280 | w << 8 & 16711680 | (w & 255) << 24;
    return res >>> 0;
  }
  exports$2.htonl = htonl$1;
  function toHex32$1(msg, endian) {
    var res = "";
    for (var i2 = 0; i2 < msg.length; i2++) {
      var w = msg[i2];
      if (endian === "little")
        w = htonl$1(w);
      res += zero8$1(w.toString(16));
    }
    return res;
  }
  exports$2.toHex32 = toHex32$1;
  function zero2$1(word) {
    if (word.length === 1)
      return "0" + word;
    else
      return word;
  }
  exports$2.zero2 = zero2$1;
  function zero8$1(word) {
    if (word.length === 7)
      return "0" + word;
    else if (word.length === 6)
      return "00" + word;
    else if (word.length === 5)
      return "000" + word;
    else if (word.length === 4)
      return "0000" + word;
    else if (word.length === 3)
      return "00000" + word;
    else if (word.length === 2)
      return "000000" + word;
    else if (word.length === 1)
      return "0000000" + word;
    else
      return word;
  }
  exports$2.zero8 = zero8$1;
  function join32$1(msg, start2, end, endian) {
    var len2 = end - start2;
    var res = new Array(len2 / 4);
    for (var i2 = 0, k = start2; i2 < res.length; i2++, k += 4) {
      var w;
      if (endian === "big")
        w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3];
      else
        w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k];
      res[i2] = w >>> 0;
    }
    return res;
  }
  exports$2.join32 = join32$1;
  function split32$1(msg, endian) {
    var res = new Array(msg.length * 4);
    for (var i2 = 0, k = 0; i2 < msg.length; i2++, k += 4) {
      var m = msg[i2];
      if (endian === "big") {
        res[k] = m >>> 24;
        res[k + 1] = m >>> 16 & 255;
        res[k + 2] = m >>> 8 & 255;
        res[k + 3] = m & 255;
      } else {
        res[k + 3] = m >>> 24;
        res[k + 2] = m >>> 16 & 255;
        res[k + 1] = m >>> 8 & 255;
        res[k] = m & 255;
      }
    }
    return res;
  }
  exports$2.split32 = split32$1;
  function rotr32$3(w, b) {
    return w >>> b | w << 32 - b;
  }
  exports$2.rotr32 = rotr32$3;
  function rotl32$3(w, b) {
    return w << b | w >>> 32 - b;
  }
  exports$2.rotl32 = rotl32$3;
  function sum32$5(a, b) {
    return a + b >>> 0;
  }
  exports$2.sum32 = sum32$5;
  function sum32_3$2(a, b, c) {
    return a + b + c >>> 0;
  }
  exports$2.sum32_3 = sum32_3$2;
  function sum32_4$4(a, b, c, d) {
    return a + b + c + d >>> 0;
  }
  exports$2.sum32_4 = sum32_4$4;
  function sum32_5$4(a, b, c, d, e) {
    return a + b + c + d + e >>> 0;
  }
  exports$2.sum32_5 = sum32_5$4;
  function sum64$2(buf, pos, ah, al) {
    var bh = buf[pos];
    var bl = buf[pos + 1];
    var lo = al + bl >>> 0;
    var hi = (lo < al ? 1 : 0) + ah + bh;
    buf[pos] = hi >>> 0;
    buf[pos + 1] = lo;
  }
  exports$2.sum64 = sum64$2;
  function sum64_hi$2(ah, al, bh, bl) {
    var lo = al + bl >>> 0;
    var hi = (lo < al ? 1 : 0) + ah + bh;
    return hi >>> 0;
  }
  exports$2.sum64_hi = sum64_hi$2;
  function sum64_lo$2(ah, al, bh, bl) {
    var lo = al + bl;
    return lo >>> 0;
  }
  exports$2.sum64_lo = sum64_lo$2;
  function sum64_4_hi$2(ah, al, bh, bl, ch, cl, dh, dl) {
    var carry = 0;
    var lo = al;
    lo = lo + bl >>> 0;
    carry += lo < al ? 1 : 0;
    lo = lo + cl >>> 0;
    carry += lo < cl ? 1 : 0;
    lo = lo + dl >>> 0;
    carry += lo < dl ? 1 : 0;
    var hi = ah + bh + ch + dh + carry;
    return hi >>> 0;
  }
  exports$2.sum64_4_hi = sum64_4_hi$2;
  function sum64_4_lo$2(ah, al, bh, bl, ch, cl, dh, dl) {
    var lo = al + bl + cl + dl;
    return lo >>> 0;
  }
  exports$2.sum64_4_lo = sum64_4_lo$2;
  function sum64_5_hi$2(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
    var carry = 0;
    var lo = al;
    lo = lo + bl >>> 0;
    carry += lo < al ? 1 : 0;
    lo = lo + cl >>> 0;
    carry += lo < cl ? 1 : 0;
    lo = lo + dl >>> 0;
    carry += lo < dl ? 1 : 0;
    lo = lo + el >>> 0;
    carry += lo < el ? 1 : 0;
    var hi = ah + bh + ch + dh + eh + carry;
    return hi >>> 0;
  }
  exports$2.sum64_5_hi = sum64_5_hi$2;
  function sum64_5_lo$2(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
    var lo = al + bl + cl + dl + el;
    return lo >>> 0;
  }
  exports$2.sum64_5_lo = sum64_5_lo$2;
  function rotr64_hi$2(ah, al, num) {
    var r2 = al << 32 - num | ah >>> num;
    return r2 >>> 0;
  }
  exports$2.rotr64_hi = rotr64_hi$2;
  function rotr64_lo$2(ah, al, num) {
    var r2 = ah << 32 - num | al >>> num;
    return r2 >>> 0;
  }
  exports$2.rotr64_lo = rotr64_lo$2;
  function shr64_hi$2(ah, al, num) {
    return ah >>> num;
  }
  exports$2.shr64_hi = shr64_hi$2;
  function shr64_lo$2(ah, al, num) {
    var r2 = ah << 32 - num | al >>> num;
    return r2 >>> 0;
  }
  exports$2.shr64_lo = shr64_lo$2;
  exports$2.inherits = function(subClass, superClass) {
    var F = function() {
    };
    F.prototype = superClass.prototype;
    subClass.prototype = new F();
    subClass.prototype.constructor = subClass;
  };
  const utils$n = {
    ...exports$2
  };
  function BlockHash$5() {
    this.pending = null;
    this.pendingTotal = 0;
    this.blockSize = this.constructor.blockSize;
    this.outSize = this.constructor.outSize;
    this.hmacStrength = this.constructor.hmacStrength;
    this.padLength = this.constructor.padLength / 8;
    this.endian = "big";
    this._delta8 = this.blockSize / 8;
    this._delta32 = this.blockSize / 32;
  }
  BlockHash$5.prototype.update = function update(msg, enc) {
    msg = utils$n.toArray(msg, enc);
    if (!this.pending)
      this.pending = msg;
    else
      this.pending = this.pending.concat(msg);
    this.pendingTotal += msg.length;
    if (this.pending.length >= this._delta8) {
      msg = this.pending;
      var r2 = msg.length % this._delta8;
      this.pending = msg.slice(msg.length - r2, msg.length);
      if (this.pending.length === 0)
        this.pending = null;
      msg = utils$n.join32(msg, 0, msg.length - r2, this.endian);
      for (var i2 = 0; i2 < msg.length; i2 += this._delta32)
        this._update(msg, i2, i2 + this._delta32);
    }
    return this;
  };
  BlockHash$5.prototype.digest = function digest(enc) {
    this.update(this._pad());
    return this._digest(enc);
  };
  BlockHash$5.prototype._pad = function pad() {
    var len2 = this.pendingTotal;
    var bytes = this._delta8;
    var k = bytes - (len2 + this.padLength) % bytes;
    var res = new Array(k + this.padLength);
    res[0] = 128;
    for (var i2 = 1; i2 < k; i2++)
      res[i2] = 0;
    len2 <<= 3;
    if (this.endian === "big") {
      for (var t2 = 8; t2 < this.padLength; t2++)
        res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = len2 >>> 24 & 255;
      res[i2++] = len2 >>> 16 & 255;
      res[i2++] = len2 >>> 8 & 255;
      res[i2++] = len2 & 255;
    } else {
      res[i2++] = len2 & 255;
      res[i2++] = len2 >>> 8 & 255;
      res[i2++] = len2 >>> 16 & 255;
      res[i2++] = len2 >>> 24 & 255;
      res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = 0;
      res[i2++] = 0;
      for (t2 = 8; t2 < this.padLength; t2++)
        res[i2++] = 0;
    }
    return res;
  };
  var rotr32$2 = utils$n.rotr32;
  var exports$1 = {};
  function ft_1$2(s2, x, y, z) {
    if (s2 === 0)
      return ch32$3(x, y, z);
    if (s2 === 1 || s2 === 3)
      return p32$1(x, y, z);
    if (s2 === 2)
      return maj32$3(x, y, z);
  }
  exports$1.ft_1 = ft_1$2;
  function ch32$3(x, y, z) {
    return x & y ^ ~x & z;
  }
  exports$1.ch32 = ch32$3;
  function maj32$3(x, y, z) {
    return x & y ^ x & z ^ y & z;
  }
  exports$1.maj32 = maj32$3;
  function p32$1(x, y, z) {
    return x ^ y ^ z;
  }
  exports$1.p32 = p32$1;
  function s0_256$3(x) {
    return rotr32$2(x, 2) ^ rotr32$2(x, 13) ^ rotr32$2(x, 22);
  }
  exports$1.s0_256 = s0_256$3;
  function s1_256$3(x) {
    return rotr32$2(x, 6) ^ rotr32$2(x, 11) ^ rotr32$2(x, 25);
  }
  exports$1.s1_256 = s1_256$3;
  function g0_256$3(x) {
    return rotr32$2(x, 7) ^ rotr32$2(x, 18) ^ x >>> 3;
  }
  exports$1.g0_256 = g0_256$3;
  function g1_256$3(x) {
    return rotr32$2(x, 17) ^ rotr32$2(x, 19) ^ x >>> 10;
  }
  exports$1.g1_256 = g1_256$3;
  const shaCommon$2 = {
    ...exports$1
  };
  var sum32$4 = utils$n.sum32;
  var sum32_4$3 = utils$n.sum32_4;
  var sum32_5$3 = utils$n.sum32_5;
  var ch32$2 = shaCommon$2.ch32;
  var maj32$2 = shaCommon$2.maj32;
  var s0_256$2 = shaCommon$2.s0_256;
  var s1_256$2 = shaCommon$2.s1_256;
  var g0_256$2 = shaCommon$2.g0_256;
  var g1_256$2 = shaCommon$2.g1_256;
  var sha256_K$1 = [
    1116352408,
    1899447441,
    3049323471,
    3921009573,
    961987163,
    1508970993,
    2453635748,
    2870763221,
    3624381080,
    310598401,
    607225278,
    1426881987,
    1925078388,
    2162078206,
    2614888103,
    3248222580,
    3835390401,
    4022224774,
    264347078,
    604807628,
    770255983,
    1249150122,
    1555081692,
    1996064986,
    2554220882,
    2821834349,
    2952996808,
    3210313671,
    3336571891,
    3584528711,
    113926993,
    338241895,
    666307205,
    773529912,
    1294757372,
    1396182291,
    1695183700,
    1986661051,
    2177026350,
    2456956037,
    2730485921,
    2820302411,
    3259730800,
    3345764771,
    3516065817,
    3600352804,
    4094571909,
    275423344,
    430227734,
    506948616,
    659060556,
    883997877,
    958139571,
    1322822218,
    1537002063,
    1747873779,
    1955562222,
    2024104815,
    2227730452,
    2361852424,
    2428436474,
    2756734187,
    3204031479,
    3329325298
  ];
  function SHA256$2() {
    if (!(this instanceof SHA256$2))
      return new SHA256$2();
    BlockHash$5.call(this);
    this.h = [
      1779033703,
      3144134277,
      1013904242,
      2773480762,
      1359893119,
      2600822924,
      528734635,
      1541459225
    ];
    this.k = sha256_K$1;
    this.W = new Array(64);
  }
  utils$n.inherits(SHA256$2, BlockHash$5);
  SHA256$2.blockSize = 512;
  SHA256$2.outSize = 256;
  SHA256$2.hmacStrength = 192;
  SHA256$2.padLength = 64;
  SHA256$2.prototype._update = function _update(msg, start2) {
    var W = this.W;
    for (var i2 = 0; i2 < 16; i2++)
      W[i2] = msg[start2 + i2];
    for (; i2 < W.length; i2++)
      W[i2] = sum32_4$3(g1_256$2(W[i2 - 2]), W[i2 - 7], g0_256$2(W[i2 - 15]), W[i2 - 16]);
    var a = this.h[0];
    var b = this.h[1];
    var c = this.h[2];
    var d = this.h[3];
    var e = this.h[4];
    var f2 = this.h[5];
    var g = this.h[6];
    var h = this.h[7];
    for (i2 = 0; i2 < W.length; i2++) {
      var T1 = sum32_5$3(h, s1_256$2(e), ch32$2(e, f2, g), this.k[i2], W[i2]);
      var T2 = sum32$4(s0_256$2(a), maj32$2(a, b, c));
      h = g;
      g = f2;
      f2 = e;
      e = sum32$4(d, T1);
      d = c;
      c = b;
      b = a;
      a = sum32$4(T1, T2);
    }
    this.h[0] = sum32$4(this.h[0], a);
    this.h[1] = sum32$4(this.h[1], b);
    this.h[2] = sum32$4(this.h[2], c);
    this.h[3] = sum32$4(this.h[3], d);
    this.h[4] = sum32$4(this.h[4], e);
    this.h[5] = sum32$4(this.h[5], f2);
    this.h[6] = sum32$4(this.h[6], g);
    this.h[7] = sum32$4(this.h[7], h);
  };
  SHA256$2.prototype._digest = function digest(enc) {
    if (enc === "hex")
      return utils$n.toHex32(this.h, "big");
    else
      return utils$n.split32(this.h, "big");
  };
  function safeAdd(x, y) {
    var lsw = (x & 65535) + (y & 65535);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return msw << 16 | lsw & 65535;
  }
  function bitRotateLeft(num, cnt) {
    return num << cnt | num >>> 32 - cnt;
  }
  function md5cmn(q, a, b, x, s2, t2) {
    return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t2)), s2), b);
  }
  function md5ff(a, b, c, d, x, s2, t2) {
    return md5cmn(b & c | ~b & d, a, b, x, s2, t2);
  }
  function md5gg(a, b, c, d, x, s2, t2) {
    return md5cmn(b & d | c & ~d, a, b, x, s2, t2);
  }
  function md5hh(a, b, c, d, x, s2, t2) {
    return md5cmn(b ^ c ^ d, a, b, x, s2, t2);
  }
  function md5ii(a, b, c, d, x, s2, t2) {
    return md5cmn(c ^ (b | ~d), a, b, x, s2, t2);
  }
  function binlMD5(x, len2) {
    x[len2 >> 5] |= 128 << len2 % 32;
    x[(len2 + 64 >>> 9 << 4) + 14] = len2;
    var i2;
    var olda;
    var oldb;
    var oldc;
    var oldd;
    var a = 1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d = 271733878;
    for (i2 = 0; i2 < x.length; i2 += 16) {
      olda = a;
      oldb = b;
      oldc = c;
      oldd = d;
      a = md5ff(a, b, c, d, x[i2], 7, -680876936);
      d = md5ff(d, a, b, c, x[i2 + 1], 12, -389564586);
      c = md5ff(c, d, a, b, x[i2 + 2], 17, 606105819);
      b = md5ff(b, c, d, a, x[i2 + 3], 22, -1044525330);
      a = md5ff(a, b, c, d, x[i2 + 4], 7, -176418897);
      d = md5ff(d, a, b, c, x[i2 + 5], 12, 1200080426);
      c = md5ff(c, d, a, b, x[i2 + 6], 17, -1473231341);
      b = md5ff(b, c, d, a, x[i2 + 7], 22, -45705983);
      a = md5ff(a, b, c, d, x[i2 + 8], 7, 1770035416);
      d = md5ff(d, a, b, c, x[i2 + 9], 12, -1958414417);
      c = md5ff(c, d, a, b, x[i2 + 10], 17, -42063);
      b = md5ff(b, c, d, a, x[i2 + 11], 22, -1990404162);
      a = md5ff(a, b, c, d, x[i2 + 12], 7, 1804603682);
      d = md5ff(d, a, b, c, x[i2 + 13], 12, -40341101);
      c = md5ff(c, d, a, b, x[i2 + 14], 17, -1502002290);
      b = md5ff(b, c, d, a, x[i2 + 15], 22, 1236535329);
      a = md5gg(a, b, c, d, x[i2 + 1], 5, -165796510);
      d = md5gg(d, a, b, c, x[i2 + 6], 9, -1069501632);
      c = md5gg(c, d, a, b, x[i2 + 11], 14, 643717713);
      b = md5gg(b, c, d, a, x[i2], 20, -373897302);
      a = md5gg(a, b, c, d, x[i2 + 5], 5, -701558691);
      d = md5gg(d, a, b, c, x[i2 + 10], 9, 38016083);
      c = md5gg(c, d, a, b, x[i2 + 15], 14, -660478335);
      b = md5gg(b, c, d, a, x[i2 + 4], 20, -405537848);
      a = md5gg(a, b, c, d, x[i2 + 9], 5, 568446438);
      d = md5gg(d, a, b, c, x[i2 + 14], 9, -1019803690);
      c = md5gg(c, d, a, b, x[i2 + 3], 14, -187363961);
      b = md5gg(b, c, d, a, x[i2 + 8], 20, 1163531501);
      a = md5gg(a, b, c, d, x[i2 + 13], 5, -1444681467);
      d = md5gg(d, a, b, c, x[i2 + 2], 9, -51403784);
      c = md5gg(c, d, a, b, x[i2 + 7], 14, 1735328473);
      b = md5gg(b, c, d, a, x[i2 + 12], 20, -1926607734);
      a = md5hh(a, b, c, d, x[i2 + 5], 4, -378558);
      d = md5hh(d, a, b, c, x[i2 + 8], 11, -2022574463);
      c = md5hh(c, d, a, b, x[i2 + 11], 16, 1839030562);
      b = md5hh(b, c, d, a, x[i2 + 14], 23, -35309556);
      a = md5hh(a, b, c, d, x[i2 + 1], 4, -1530992060);
      d = md5hh(d, a, b, c, x[i2 + 4], 11, 1272893353);
      c = md5hh(c, d, a, b, x[i2 + 7], 16, -155497632);
      b = md5hh(b, c, d, a, x[i2 + 10], 23, -1094730640);
      a = md5hh(a, b, c, d, x[i2 + 13], 4, 681279174);
      d = md5hh(d, a, b, c, x[i2], 11, -358537222);
      c = md5hh(c, d, a, b, x[i2 + 3], 16, -722521979);
      b = md5hh(b, c, d, a, x[i2 + 6], 23, 76029189);
      a = md5hh(a, b, c, d, x[i2 + 9], 4, -640364487);
      d = md5hh(d, a, b, c, x[i2 + 12], 11, -421815835);
      c = md5hh(c, d, a, b, x[i2 + 15], 16, 530742520);
      b = md5hh(b, c, d, a, x[i2 + 2], 23, -995338651);
      a = md5ii(a, b, c, d, x[i2], 6, -198630844);
      d = md5ii(d, a, b, c, x[i2 + 7], 10, 1126891415);
      c = md5ii(c, d, a, b, x[i2 + 14], 15, -1416354905);
      b = md5ii(b, c, d, a, x[i2 + 5], 21, -57434055);
      a = md5ii(a, b, c, d, x[i2 + 12], 6, 1700485571);
      d = md5ii(d, a, b, c, x[i2 + 3], 10, -1894986606);
      c = md5ii(c, d, a, b, x[i2 + 10], 15, -1051523);
      b = md5ii(b, c, d, a, x[i2 + 1], 21, -2054922799);
      a = md5ii(a, b, c, d, x[i2 + 8], 6, 1873313359);
      d = md5ii(d, a, b, c, x[i2 + 15], 10, -30611744);
      c = md5ii(c, d, a, b, x[i2 + 6], 15, -1560198380);
      b = md5ii(b, c, d, a, x[i2 + 13], 21, 1309151649);
      a = md5ii(a, b, c, d, x[i2 + 4], 6, -145523070);
      d = md5ii(d, a, b, c, x[i2 + 11], 10, -1120210379);
      c = md5ii(c, d, a, b, x[i2 + 2], 15, 718787259);
      b = md5ii(b, c, d, a, x[i2 + 9], 21, -343485551);
      a = safeAdd(a, olda);
      b = safeAdd(b, oldb);
      c = safeAdd(c, oldc);
      d = safeAdd(d, oldd);
    }
    return [a, b, c, d];
  }
  function binl2rstr(input) {
    var i2;
    var output = "";
    var length32 = input.length * 32;
    for (i2 = 0; i2 < length32; i2 += 8) {
      output += String.fromCharCode(input[i2 >> 5] >>> i2 % 32 & 255);
    }
    return output;
  }
  function rstr2binl(input) {
    var i2;
    var output = [];
    output[(input.length >> 2) - 1] = void 0;
    for (i2 = 0; i2 < output.length; i2 += 1) {
      output[i2] = 0;
    }
    var length8 = input.length * 8;
    for (i2 = 0; i2 < length8; i2 += 8) {
      output[i2 >> 5] |= (input.charCodeAt(i2 / 8) & 255) << i2 % 32;
    }
    return output;
  }
  function rstrMD5(s2) {
    return binl2rstr(binlMD5(rstr2binl(s2), s2.length * 8));
  }
  function rstrHMACMD5(key2, data) {
    var i2;
    var bkey = rstr2binl(key2);
    var ipad = [];
    var opad = [];
    var hash2;
    ipad[15] = opad[15] = void 0;
    if (bkey.length > 16) {
      bkey = binlMD5(bkey, key2.length * 8);
    }
    for (i2 = 0; i2 < 16; i2 += 1) {
      ipad[i2] = bkey[i2] ^ 909522486;
      opad[i2] = bkey[i2] ^ 1549556828;
    }
    hash2 = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
    return binl2rstr(binlMD5(opad.concat(hash2), 512 + 128));
  }
  function rstr2hex(input) {
    var hexTab = "0123456789abcdef";
    var output = "";
    var x;
    var i2;
    for (i2 = 0; i2 < input.length; i2 += 1) {
      x = input.charCodeAt(i2);
      output += hexTab.charAt(x >>> 4 & 15) + hexTab.charAt(x & 15);
    }
    return output;
  }
  function str2rstrUTF8(input) {
    return unescape(encodeURIComponent(input));
  }
  function rawMD5(s2) {
    return rstrMD5(str2rstrUTF8(s2));
  }
  function hexMD5(s2) {
    return rstr2hex(rawMD5(s2));
  }
  function rawHMACMD5(k, d) {
    return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
  }
  function hexHMACMD5(k, d) {
    return rstr2hex(rawHMACMD5(k, d));
  }
  function md5(string, key2, raw) {
    if (!key2) {
      if (!raw) {
        return hexMD5(string);
      }
      return rawMD5(string);
    }
    if (!raw) {
      return hexHMACMD5(key2, string);
    }
    return rawHMACMD5(key2, string);
  }
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  function getAugmentedNamespace(n) {
    if (n.__esModule)
      return n;
    var f2 = n.default;
    if (typeof f2 == "function") {
      var a = function a2() {
        if (this instanceof a2) {
          var args = [null];
          args.push.apply(args, arguments);
          var Ctor = Function.bind.apply(f2, args);
          return new Ctor();
        }
        return f2.apply(this, arguments);
      };
      a.prototype = f2.prototype;
    } else
      a = {};
    Object.defineProperty(a, "__esModule", { value: true });
    Object.keys(n).forEach(function(k) {
      var d = Object.getOwnPropertyDescriptor(n, k);
      Object.defineProperty(a, k, d.get ? d : {
        enumerable: true,
        get: function() {
          return n[k];
        }
      });
    });
    return a;
  }
  const errors = {
    IMPOSSIBLE_CASE: "Impossible case. Please create issue.",
    TWEAK_ADD: "The tweak was out of range or the resulted private key is invalid",
    TWEAK_MUL: "The tweak was out of range or equal to zero",
    CONTEXT_RANDOMIZE_UNKNOW: "Unknow error on context randomization",
    SECKEY_INVALID: "Private Key is invalid",
    PUBKEY_PARSE: "Public Key could not be parsed",
    PUBKEY_SERIALIZE: "Public Key serialization error",
    PUBKEY_COMBINE: "The sum of the public keys is not valid",
    SIG_PARSE: "Signature could not be parsed",
    SIGN: "The nonce generation function failed, or the private key was invalid",
    RECOVER: "Public key could not be recover",
    ECDH: "Scalar was invalid (zero or overflow)"
  };
  function assert$g(cond, msg) {
    if (!cond)
      throw new Error(msg);
  }
  function isUint8Array(name2, value, length) {
    assert$g(value instanceof Uint8Array, `Expected ${name2} to be an Uint8Array`);
    if (length !== void 0) {
      if (Array.isArray(length)) {
        const numbers = length.join(", ");
        const msg = `Expected ${name2} to be an Uint8Array with length [${numbers}]`;
        assert$g(length.includes(value.length), msg);
      } else {
        const msg = `Expected ${name2} to be an Uint8Array with length ${length}`;
        assert$g(value.length === length, msg);
      }
    }
  }
  function isCompressed(value) {
    assert$g(toTypeString(value) === "Boolean", "Expected compressed to be a Boolean");
  }
  function getAssertedOutput(output = (len2) => new Uint8Array(len2), length) {
    if (typeof output === "function")
      output = output(length);
    isUint8Array("output", output, length);
    return output;
  }
  function toTypeString(value) {
    return Object.prototype.toString.call(value).slice(8, -1);
  }
  var lib = (secp256k12) => {
    return {
      contextRandomize(seed) {
        assert$g(
          seed === null || seed instanceof Uint8Array,
          "Expected seed to be an Uint8Array or null"
        );
        if (seed !== null)
          isUint8Array("seed", seed, 32);
        switch (secp256k12.contextRandomize(seed)) {
          case 1:
            throw new Error(errors.CONTEXT_RANDOMIZE_UNKNOW);
        }
      },
      privateKeyVerify(seckey) {
        isUint8Array("private key", seckey, 32);
        return secp256k12.privateKeyVerify(seckey) === 0;
      },
      privateKeyNegate(seckey) {
        isUint8Array("private key", seckey, 32);
        switch (secp256k12.privateKeyNegate(seckey)) {
          case 0:
            return seckey;
          case 1:
            throw new Error(errors.IMPOSSIBLE_CASE);
        }
      },
      privateKeyTweakAdd(seckey, tweak) {
        isUint8Array("private key", seckey, 32);
        isUint8Array("tweak", tweak, 32);
        switch (secp256k12.privateKeyTweakAdd(seckey, tweak)) {
          case 0:
            return seckey;
          case 1:
            throw new Error(errors.TWEAK_ADD);
        }
      },
      privateKeyTweakMul(seckey, tweak) {
        isUint8Array("private key", seckey, 32);
        isUint8Array("tweak", tweak, 32);
        switch (secp256k12.privateKeyTweakMul(seckey, tweak)) {
          case 0:
            return seckey;
          case 1:
            throw new Error(errors.TWEAK_MUL);
        }
      },
      publicKeyVerify(pubkey) {
        isUint8Array("public key", pubkey, [33, 65]);
        return secp256k12.publicKeyVerify(pubkey) === 0;
      },
      publicKeyCreate(seckey, compressed = true, output) {
        isUint8Array("private key", seckey, 32);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyCreate(output, seckey)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.SECKEY_INVALID);
          case 2:
            throw new Error(errors.PUBKEY_SERIALIZE);
        }
      },
      publicKeyConvert(pubkey, compressed = true, output) {
        isUint8Array("public key", pubkey, [33, 65]);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyConvert(output, pubkey)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.PUBKEY_SERIALIZE);
        }
      },
      publicKeyNegate(pubkey, compressed = true, output) {
        isUint8Array("public key", pubkey, [33, 65]);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyNegate(output, pubkey)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.IMPOSSIBLE_CASE);
          case 3:
            throw new Error(errors.PUBKEY_SERIALIZE);
        }
      },
      publicKeyCombine(pubkeys, compressed = true, output) {
        assert$g(Array.isArray(pubkeys), "Expected public keys to be an Array");
        assert$g(pubkeys.length > 0, "Expected public keys array will have more than zero items");
        for (const pubkey of pubkeys) {
          isUint8Array("public key", pubkey, [33, 65]);
        }
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyCombine(output, pubkeys)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.PUBKEY_COMBINE);
          case 3:
            throw new Error(errors.PUBKEY_SERIALIZE);
        }
      },
      publicKeyTweakAdd(pubkey, tweak, compressed = true, output) {
        isUint8Array("public key", pubkey, [33, 65]);
        isUint8Array("tweak", tweak, 32);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyTweakAdd(output, pubkey, tweak)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.TWEAK_ADD);
        }
      },
      publicKeyTweakMul(pubkey, tweak, compressed = true, output) {
        isUint8Array("public key", pubkey, [33, 65]);
        isUint8Array("tweak", tweak, 32);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.publicKeyTweakMul(output, pubkey, tweak)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.TWEAK_MUL);
        }
      },
      signatureNormalize(sig) {
        isUint8Array("signature", sig, 64);
        switch (secp256k12.signatureNormalize(sig)) {
          case 0:
            return sig;
          case 1:
            throw new Error(errors.SIG_PARSE);
        }
      },
      signatureExport(sig, output) {
        isUint8Array("signature", sig, 64);
        output = getAssertedOutput(output, 72);
        const obj = { output, outputlen: 72 };
        switch (secp256k12.signatureExport(obj, sig)) {
          case 0:
            return output.slice(0, obj.outputlen);
          case 1:
            throw new Error(errors.SIG_PARSE);
          case 2:
            throw new Error(errors.IMPOSSIBLE_CASE);
        }
      },
      signatureImport(sig, output) {
        isUint8Array("signature", sig);
        output = getAssertedOutput(output, 64);
        switch (secp256k12.signatureImport(output, sig)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.SIG_PARSE);
          case 2:
            throw new Error(errors.IMPOSSIBLE_CASE);
        }
      },
      ecdsaSign(msg32, seckey, options = {}, output) {
        isUint8Array("message", msg32, 32);
        isUint8Array("private key", seckey, 32);
        assert$g(toTypeString(options) === "Object", "Expected options to be an Object");
        if (options.data !== void 0)
          isUint8Array("options.data", options.data);
        if (options.noncefn !== void 0)
          assert$g(toTypeString(options.noncefn) === "Function", "Expected options.noncefn to be a Function");
        output = getAssertedOutput(output, 64);
        const obj = { signature: output, recid: null };
        switch (secp256k12.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) {
          case 0:
            return obj;
          case 1:
            throw new Error(errors.SIGN);
          case 2:
            throw new Error(errors.IMPOSSIBLE_CASE);
        }
      },
      ecdsaVerify(sig, msg32, pubkey) {
        isUint8Array("signature", sig, 64);
        isUint8Array("message", msg32, 32);
        isUint8Array("public key", pubkey, [33, 65]);
        switch (secp256k12.ecdsaVerify(sig, msg32, pubkey)) {
          case 0:
            return true;
          case 3:
            return false;
          case 1:
            throw new Error(errors.SIG_PARSE);
          case 2:
            throw new Error(errors.PUBKEY_PARSE);
        }
      },
      ecdsaRecover(sig, recid, msg32, compressed = true, output) {
        isUint8Array("signature", sig, 64);
        assert$g(
          toTypeString(recid) === "Number" && recid >= 0 && recid <= 3,
          "Expected recovery id to be a Number within interval [0, 3]"
        );
        isUint8Array("message", msg32, 32);
        isCompressed(compressed);
        output = getAssertedOutput(output, compressed ? 33 : 65);
        switch (secp256k12.ecdsaRecover(output, sig, recid, msg32)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.SIG_PARSE);
          case 2:
            throw new Error(errors.RECOVER);
          case 3:
            throw new Error(errors.IMPOSSIBLE_CASE);
        }
      },
      ecdh(pubkey, seckey, options = {}, output) {
        isUint8Array("public key", pubkey, [33, 65]);
        isUint8Array("private key", seckey, 32);
        assert$g(toTypeString(options) === "Object", "Expected options to be an Object");
        if (options.data !== void 0)
          isUint8Array("options.data", options.data);
        if (options.hashfn !== void 0) {
          assert$g(toTypeString(options.hashfn) === "Function", "Expected options.hashfn to be a Function");
          if (options.xbuf !== void 0)
            isUint8Array("options.xbuf", options.xbuf, 32);
          if (options.ybuf !== void 0)
            isUint8Array("options.ybuf", options.ybuf, 32);
          isUint8Array("output", output);
        } else {
          output = getAssertedOutput(output, 32);
        }
        switch (secp256k12.ecdh(output, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) {
          case 0:
            return output;
          case 1:
            throw new Error(errors.PUBKEY_PARSE);
          case 2:
            throw new Error(errors.ECDH);
        }
      }
    };
  };
  var elliptic$2 = {};
  const name = "elliptic";
  const version = "6.5.4";
  const description = "EC cryptography";
  const main = "lib/elliptic.js";
  const files = [
    "lib"
  ];
  const scripts = {
    lint: "eslint lib test",
    "lint:fix": "npm run lint -- --fix",
    unit: "istanbul test _mocha --reporter=spec test/index.js",
    test: "npm run lint && npm run unit",
    version: "grunt dist && git add dist/"
  };
  const repository = {
    type: "git",
    url: "git@github.com:indutny/elliptic"
  };
  const keywords = [
    "EC",
    "Elliptic",
    "curve",
    "Cryptography"
  ];
  const author = "Fedor Indutny <fedor@indutny.com>";
  const license = "MIT";
  const bugs = {
    url: "https://github.com/indutny/elliptic/issues"
  };
  const homepage = "https://github.com/indutny/elliptic";
  const devDependencies = {
    brfs: "^2.0.2",
    coveralls: "^3.1.0",
    eslint: "^7.6.0",
    grunt: "^1.2.1",
    "grunt-browserify": "^5.3.0",
    "grunt-cli": "^1.3.2",
    "grunt-contrib-connect": "^3.0.0",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-uglify": "^5.0.0",
    "grunt-mocha-istanbul": "^5.0.2",
    "grunt-saucelabs": "^9.0.1",
    istanbul: "^0.4.5",
    mocha: "^8.0.1"
  };
  const dependencies = {
    "bn.js": "^4.11.9",
    brorand: "^1.1.0",
    "hash.js": "^1.0.0",
    "hmac-drbg": "^1.0.1",
    inherits: "^2.0.4",
    "minimalistic-assert": "^1.0.1",
    "minimalistic-crypto-utils": "^1.0.1"
  };
  const require$$0$1 = {
    name,
    version,
    description,
    main,
    files,
    scripts,
    repository,
    keywords,
    author,
    license,
    bugs,
    homepage,
    devDependencies,
    dependencies
  };
  var utils$m = {};
  var bnExports = {};
  var bn = {
    get exports() {
      return bnExports;
    },
    set exports(v) {
      bnExports = v;
    }
  };
  const __viteBrowserExternal = {};
  const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
    __proto__: null,
    default: __viteBrowserExternal
  }, Symbol.toStringTag, { value: "Module" }));
  const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
  (function(module) {
    (function(module2, exports) {
      function assert2(val, msg) {
        if (!val)
          throw new Error(msg || "Assertion failed");
      }
      function inherits2(ctor, superCtor) {
        ctor.super_ = superCtor;
        var TempCtor = function() {
        };
        TempCtor.prototype = superCtor.prototype;
        ctor.prototype = new TempCtor();
        ctor.prototype.constructor = ctor;
      }
      function BN2(number, base2, endian) {
        if (BN2.isBN(number)) {
          return number;
        }
        this.negative = 0;
        this.words = null;
        this.length = 0;
        this.red = null;
        if (number !== null) {
          if (base2 === "le" || base2 === "be") {
            endian = base2;
            base2 = 10;
          }
          this._init(number || 0, base2 || 10, endian || "be");
        }
      }
      if (typeof module2 === "object") {
        module2.exports = BN2;
      } else {
        exports.BN = BN2;
      }
      BN2.BN = BN2;
      BN2.wordSize = 26;
      var Buffer3;
      try {
        if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
          Buffer3 = window.Buffer;
        } else {
          Buffer3 = require$$0.Buffer;
        }
      } catch (e) {
      }
      BN2.isBN = function isBN(num) {
        if (num instanceof BN2) {
          return true;
        }
        return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
      };
      BN2.max = function max(left, right) {
        if (left.cmp(right) > 0)
          return left;
        return right;
      };
      BN2.min = function min(left, right) {
        if (left.cmp(right) < 0)
          return left;
        return right;
      };
      BN2.prototype._init = function init(number, base2, endian) {
        if (typeof number === "number") {
          return this._initNumber(number, base2, endian);
        }
        if (typeof number === "object") {
          return this._initArray(number, base2, endian);
        }
        if (base2 === "hex") {
          base2 = 16;
        }
        assert2(base2 === (base2 | 0) && base2 >= 2 && base2 <= 36);
        number = number.toString().replace(/\s+/g, "");
        var start2 = 0;
        if (number[0] === "-") {
          start2++;
          this.negative = 1;
        }
        if (start2 < number.length) {
          if (base2 === 16) {
            this._parseHex(number, start2, endian);
          } else {
            this._parseBase(number, base2, start2);
            if (endian === "le") {
              this._initArray(this.toArray(), base2, endian);
            }
          }
        }
      };
      BN2.prototype._initNumber = function _initNumber(number, base2, endian) {
        if (number < 0) {
          this.negative = 1;
          number = -number;
        }
        if (number < 67108864) {
          this.words = [number & 67108863];
          this.length = 1;
        } else if (number < 4503599627370496) {
          this.words = [
            number & 67108863,
            number / 67108864 & 67108863
          ];
          this.length = 2;
        } else {
          assert2(number < 9007199254740992);
          this.words = [
            number & 67108863,
            number / 67108864 & 67108863,
            1
          ];
          this.length = 3;
        }
        if (endian !== "le")
          return;
        this._initArray(this.toArray(), base2, endian);
      };
      BN2.prototype._initArray = function _initArray(number, base2, endian) {
        assert2(typeof number.length === "number");
        if (number.length <= 0) {
          this.words = [0];
          this.length = 1;
          return this;
        }
        this.length = Math.ceil(number.length / 3);
        this.words = new Array(this.length);
        for (var i2 = 0; i2 < this.length; i2++) {
          this.words[i2] = 0;
        }
        var j, w;
        var off = 0;
        if (endian === "be") {
          for (i2 = number.length - 1, j = 0; i2 >= 0; i2 -= 3) {
            w = number[i2] | number[i2 - 1] << 8 | number[i2 - 2] << 16;
            this.words[j] |= w << off & 67108863;
            this.words[j + 1] = w >>> 26 - off & 67108863;
            off += 24;
            if (off >= 26) {
              off -= 26;
              j++;
            }
          }
        } else if (endian === "le") {
          for (i2 = 0, j = 0; i2 < number.length; i2 += 3) {
            w = number[i2] | number[i2 + 1] << 8 | number[i2 + 2] << 16;
            this.words[j] |= w << off & 67108863;
            this.words[j + 1] = w >>> 26 - off & 67108863;
            off += 24;
            if (off >= 26) {
              off -= 26;
              j++;
            }
          }
        }
        return this.strip();
      };
      function parseHex4Bits(string, index) {
        var c = string.charCodeAt(index);
        if (c >= 65 && c <= 70) {
          return c - 55;
        } else if (c >= 97 && c <= 102) {
          return c - 87;
        } else {
          return c - 48 & 15;
        }
      }
      function parseHexByte(string, lowerBound, index) {
        var r2 = parseHex4Bits(string, index);
        if (index - 1 >= lowerBound) {
          r2 |= parseHex4Bits(string, index - 1) << 4;
        }
        return r2;
      }
      BN2.prototype._parseHex = function _parseHex(number, start2, endian) {
        this.length = Math.ceil((number.length - start2) / 6);
        this.words = new Array(this.length);
        for (var i2 = 0; i2 < this.length; i2++) {
          this.words[i2] = 0;
        }
        var off = 0;
        var j = 0;
        var w;
        if (endian === "be") {
          for (i2 = number.length - 1; i2 >= start2; i2 -= 2) {
            w = parseHexByte(number, start2, i2) << off;
            this.words[j] |= w & 67108863;
            if (off >= 18) {
              off -= 18;
              j += 1;
              this.words[j] |= w >>> 26;
            } else {
              off += 8;
            }
          }
        } else {
          var parseLength = number.length - start2;
          for (i2 = parseLength % 2 === 0 ? start2 + 1 : start2; i2 < number.length; i2 += 2) {
            w = parseHexByte(number, start2, i2) << off;
            this.words[j] |= w & 67108863;
            if (off >= 18) {
              off -= 18;
              j += 1;
              this.words[j] |= w >>> 26;
            } else {
              off += 8;
            }
          }
        }
        this.strip();
      };
      function parseBase(str, start2, end, mul) {
        var r2 = 0;
        var len2 = Math.min(str.length, end);
        for (var i2 = start2; i2 < len2; i2++) {
          var c = str.charCodeAt(i2) - 48;
          r2 *= mul;
          if (c >= 49) {
            r2 += c - 49 + 10;
          } else if (c >= 17) {
            r2 += c - 17 + 10;
          } else {
            r2 += c;
          }
        }
        return r2;
      }
      BN2.prototype._parseBase = function _parseBase(number, base2, start2) {
        this.words = [0];
        this.length = 1;
        for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base2) {
          limbLen++;
        }
        limbLen--;
        limbPow = limbPow / base2 | 0;
        var total = number.length - start2;
        var mod = total % limbLen;
        var end = Math.min(total, total - mod) + start2;
        var word = 0;
        for (var i2 = start2; i2 < end; i2 += limbLen) {
          word = parseBase(number, i2, i2 + limbLen, base2);
          this.imuln(limbPow);
          if (this.words[0] + word < 67108864) {
            this.words[0] += word;
          } else {
            this._iaddn(word);
          }
        }
        if (mod !== 0) {
          var pow = 1;
          word = parseBase(number, i2, number.length, base2);
          for (i2 = 0; i2 < mod; i2++) {
            pow *= base2;
          }
          this.imuln(pow);
          if (this.words[0] + word < 67108864) {
            this.words[0] += word;
          } else {
            this._iaddn(word);
          }
        }
        this.strip();
      };
      BN2.prototype.copy = function copy2(dest) {
        dest.words = new Array(this.length);
        for (var i2 = 0; i2 < this.length; i2++) {
          dest.words[i2] = this.words[i2];
        }
        dest.length = this.length;
        dest.negative = this.negative;
        dest.red = this.red;
      };
      BN2.prototype.clone = function clone() {
        var r2 = new BN2(null);
        this.copy(r2);
        return r2;
      };
      BN2.prototype._expand = function _expand(size) {
        while (this.length < size) {
          this.words[this.length++] = 0;
        }
        return this;
      };
      BN2.prototype.strip = function strip() {
        while (this.length > 1 && this.words[this.length - 1] === 0) {
          this.length--;
        }
        return this._normSign();
      };
      BN2.prototype._normSign = function _normSign() {
        if (this.length === 1 && this.words[0] === 0) {
          this.negative = 0;
        }
        return this;
      };
      BN2.prototype.inspect = function inspect() {
        return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
      };
      var zeros = [
        "",
        "0",
        "00",
        "000",
        "0000",
        "00000",
        "000000",
        "0000000",
        "00000000",
        "000000000",
        "0000000000",
        "00000000000",
        "000000000000",
        "0000000000000",
        "00000000000000",
        "000000000000000",
        "0000000000000000",
        "00000000000000000",
        "000000000000000000",
        "0000000000000000000",
        "00000000000000000000",
        "000000000000000000000",
        "0000000000000000000000",
        "00000000000000000000000",
        "000000000000000000000000",
        "0000000000000000000000000"
      ];
      var groupSizes = [
        0,
        0,
        25,
        16,
        12,
        11,
        10,
        9,
        8,
        8,
        7,
        7,
        7,
        7,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5,
        5
      ];
      var groupBases = [
        0,
        0,
        33554432,
        43046721,
        16777216,
        48828125,
        60466176,
        40353607,
        16777216,
        43046721,
        1e7,
        19487171,
        35831808,
        62748517,
        7529536,
        11390625,
        16777216,
        24137569,
        34012224,
        47045881,
        64e6,
        4084101,
        5153632,
        6436343,
        7962624,
        9765625,
        11881376,
        14348907,
        17210368,
        20511149,
        243e5,
        28629151,
        33554432,
        39135393,
        45435424,
        52521875,
        60466176
      ];
      BN2.prototype.toString = function toString2(base2, padding) {
        base2 = base2 || 10;
        padding = padding | 0 || 1;
        var out;
        if (base2 === 16 || base2 === "hex") {
          out = "";
          var off = 0;
          var carry = 0;
          for (var i2 = 0; i2 < this.length; i2++) {
            var w = this.words[i2];
            var word = ((w << off | carry) & 16777215).toString(16);
            carry = w >>> 24 - off & 16777215;
            if (carry !== 0 || i2 !== this.length - 1) {
              out = zeros[6 - word.length] + word + out;
            } else {
              out = word + out;
            }
            off += 2;
            if (off >= 26) {
              off -= 26;
              i2--;
            }
          }
          if (carry !== 0) {
            out = carry.toString(16) + out;
          }
          while (out.length % padding !== 0) {
            out = "0" + out;
          }
          if (this.negative !== 0) {
            out = "-" + out;
          }
          return out;
        }
        if (base2 === (base2 | 0) && base2 >= 2 && base2 <= 36) {
          var groupSize = groupSizes[base2];
          var groupBase = groupBases[base2];
          out = "";
          var c = this.clone();
          c.negative = 0;
          while (!c.isZero()) {
            var r2 = c.modn(groupBase).toString(base2);
            c = c.idivn(groupBase);
            if (!c.isZero()) {
              out = zeros[groupSize - r2.length] + r2 + out;
            } else {
              out = r2 + out;
            }
          }
          if (this.isZero()) {
            out = "0" + out;
          }
          while (out.length % padding !== 0) {
            out = "0" + out;
          }
          if (this.negative !== 0) {
            out = "-" + out;
          }
          return out;
        }
        assert2(false, "Base should be between 2 and 36");
      };
      BN2.prototype.toNumber = function toNumber() {
        var ret = this.words[0];
        if (this.length === 2) {
          ret += this.words[1] * 67108864;
        } else if (this.length === 3 && this.words[2] === 1) {
          ret += 4503599627370496 + this.words[1] * 67108864;
        } else if (this.length > 2) {
          assert2(false, "Number can only safely store up to 53 bits");
        }
        return this.negative !== 0 ? -ret : ret;
      };
      BN2.prototype.toJSON = function toJSON() {
        return this.toString(16);
      };
      BN2.prototype.toBuffer = function toBuffer(endian, length) {
        assert2(typeof Buffer3 !== "undefined");
        return this.toArrayLike(Buffer3, endian, length);
      };
      BN2.prototype.toArray = function toArray2(endian, length) {
        return this.toArrayLike(Array, endian, length);
      };
      BN2.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
        var byteLength2 = this.byteLength();
        var reqLength = length || Math.max(1, byteLength2);
        assert2(byteLength2 <= reqLength, "byte array longer than desired length");
        assert2(reqLength > 0, "Requested array length <= 0");
        this.strip();
        var littleEndian = endian === "le";
        var res = new ArrayType(reqLength);
        var b, i2;
        var q = this.clone();
        if (!littleEndian) {
          for (i2 = 0; i2 < reqLength - byteLength2; i2++) {
            res[i2] = 0;
          }
          for (i2 = 0; !q.isZero(); i2++) {
            b = q.andln(255);
            q.iushrn(8);
            res[reqLength - i2 - 1] = b;
          }
        } else {
          for (i2 = 0; !q.isZero(); i2++) {
            b = q.andln(255);
            q.iushrn(8);
            res[i2] = b;
          }
          for (; i2 < reqLength; i2++) {
            res[i2] = 0;
          }
        }
        return res;
      };
      if (Math.clz32) {
        BN2.prototype._countBits = function _countBits(w) {
          return 32 - Math.clz32(w);
        };
      } else {
        BN2.prototype._countBits = function _countBits(w) {
          var t2 = w;
          var r2 = 0;
          if (t2 >= 4096) {
            r2 += 13;
            t2 >>>= 13;
          }
          if (t2 >= 64) {
            r2 += 7;
            t2 >>>= 7;
          }
          if (t2 >= 8) {
            r2 += 4;
            t2 >>>= 4;
          }
          if (t2 >= 2) {
            r2 += 2;
            t2 >>>= 2;
          }
          return r2 + t2;
        };
      }
      BN2.prototype._zeroBits = function _zeroBits(w) {
        if (w === 0)
          return 26;
        var t2 = w;
        var r2 = 0;
        if ((t2 & 8191) === 0) {
          r2 += 13;
          t2 >>>= 13;
        }
        if ((t2 & 127) === 0) {
          r2 += 7;
          t2 >>>= 7;
        }
        if ((t2 & 15) === 0) {
          r2 += 4;
          t2 >>>= 4;
        }
        if ((t2 & 3) === 0) {
          r2 += 2;
          t2 >>>= 2;
        }
        if ((t2 & 1) === 0) {
          r2++;
        }
        return r2;
      };
      BN2.prototype.bitLength = function bitLength() {
        var w = this.words[this.length - 1];
        var hi = this._countBits(w);
        return (this.length - 1) * 26 + hi;
      };
      function toBitArray(num) {
        var w = new Array(num.bitLength());
        for (var bit = 0; bit < w.length; bit++) {
          var off = bit / 26 | 0;
          var wbit = bit % 26;
          w[bit] = (num.words[off] & 1 << wbit) >>> wbit;
        }
        return w;
      }
      BN2.prototype.zeroBits = function zeroBits() {
        if (this.isZero())
          return 0;
        var r2 = 0;
        for (var i2 = 0; i2 < this.length; i2++) {
          var b = this._zeroBits(this.words[i2]);
          r2 += b;
          if (b !== 26)
            break;
        }
        return r2;
      };
      BN2.prototype.byteLength = function byteLength2() {
        return Math.ceil(this.bitLength() / 8);
      };
      BN2.prototype.toTwos = function toTwos(width) {
        if (this.negative !== 0) {
          return this.abs().inotn(width).iaddn(1);
        }
        return this.clone();
      };
      BN2.prototype.fromTwos = function fromTwos(width) {
        if (this.testn(width - 1)) {
          return this.notn(width).iaddn(1).ineg();
        }
        return this.clone();
      };
      BN2.prototype.isNeg = function isNeg() {
        return this.negative !== 0;
      };
      BN2.prototype.neg = function neg() {
        return this.clone().ineg();
      };
      BN2.prototype.ineg = function ineg() {
        if (!this.isZero()) {
          this.negative ^= 1;
        }
        return this;
      };
      BN2.prototype.iuor = function iuor(num) {
        while (this.length < num.length) {
          this.words[this.length++] = 0;
        }
        for (var i2 = 0; i2 < num.length; i2++) {
          this.words[i2] = this.words[i2] | num.words[i2];
        }
        return this.strip();
      };
      BN2.prototype.ior = function ior(num) {
        assert2((this.negative | num.negative) === 0);
        return this.iuor(num);
      };
      BN2.prototype.or = function or(num) {
        if (this.length > num.length)
          return this.clone().ior(num);
        return num.clone().ior(this);
      };
      BN2.prototype.uor = function uor(num) {
        if (this.length > num.length)
          return this.clone().iuor(num);
        return num.clone().iuor(this);
      };
      BN2.prototype.iuand = function iuand(num) {
        var b;
        if (this.length > num.length) {
          b = num;
        } else {
          b = this;
        }
        for (var i2 = 0; i2 < b.length; i2++) {
          this.words[i2] = this.words[i2] & num.words[i2];
        }
        this.length = b.length;
        return this.strip();
      };
      BN2.prototype.iand = function iand(num) {
        assert2((this.negative | num.negative) === 0);
        return this.iuand(num);
      };
      BN2.prototype.and = function and(num) {
        if (this.length > num.length)
          return this.clone().iand(num);
        return num.clone().iand(this);
      };
      BN2.prototype.uand = function uand(num) {
        if (this.length > num.length)
          return this.clone().iuand(num);
        return num.clone().iuand(this);
      };
      BN2.prototype.iuxor = function iuxor(num) {
        var a;
        var b;
        if (this.length > num.length) {
          a = this;
          b = num;
        } else {
          a = num;
          b = this;
        }
        for (var i2 = 0; i2 < b.length; i2++) {
          this.words[i2] = a.words[i2] ^ b.words[i2];
        }
        if (this !== a) {
          for (; i2 < a.length; i2++) {
            this.words[i2] = a.words[i2];
          }
        }
        this.length = a.length;
        return this.strip();
      };
      BN2.prototype.ixor = function ixor(num) {
        assert2((this.negative | num.negative) === 0);
        return this.iuxor(num);
      };
      BN2.prototype.xor = function xor(num) {
        if (this.length > num.length)
          return this.clone().ixor(num);
        return num.clone().ixor(this);
      };
      BN2.prototype.uxor = function uxor(num) {
        if (this.length > num.length)
          return this.clone().iuxor(num);
        return num.clone().iuxor(this);
      };
      BN2.prototype.inotn = function inotn(width) {
        assert2(typeof width === "number" && width >= 0);
        var bytesNeeded = Math.ceil(width / 26) | 0;
        var bitsLeft = width % 26;
        this._expand(bytesNeeded);
        if (bitsLeft > 0) {
          bytesNeeded--;
        }
        for (var i2 = 0; i2 < bytesNeeded; i2++) {
          this.words[i2] = ~this.words[i2] & 67108863;
        }
        if (bitsLeft > 0) {
          this.words[i2] = ~this.words[i2] & 67108863 >> 26 - bitsLeft;
        }
        return this.strip();
      };
      BN2.prototype.notn = function notn(width) {
        return this.clone().inotn(width);
      };
      BN2.prototype.setn = function setn(bit, val) {
        assert2(typeof bit === "number" && bit >= 0);
        var off = bit / 26 | 0;
        var wbit = bit % 26;
        this._expand(off + 1);
        if (val) {
          this.words[off] = this.words[off] | 1 << wbit;
        } else {
          this.words[off] = this.words[off] & ~(1 << wbit);
        }
        return this.strip();
      };
      BN2.prototype.iadd = function iadd(num) {
        var r2;
        if (this.negative !== 0 && num.negative === 0) {
          this.negative = 0;
          r2 = this.isub(num);
          this.negative ^= 1;
          return this._normSign();
        } else if (this.negative === 0 && num.negative !== 0) {
          num.negative = 0;
          r2 = this.isub(num);
          num.negative = 1;
          return r2._normSign();
        }
        var a, b;
        if (this.length > num.length) {
          a = this;
          b = num;
        } else {
          a = num;
          b = this;
        }
        var carry = 0;
        for (var i2 = 0; i2 < b.length; i2++) {
          r2 = (a.words[i2] | 0) + (b.words[i2] | 0) + carry;
          this.words[i2] = r2 & 67108863;
          carry = r2 >>> 26;
        }
        for (; carry !== 0 && i2 < a.length; i2++) {
          r2 = (a.words[i2] | 0) + carry;
          this.words[i2] = r2 & 67108863;
          carry = r2 >>> 26;
        }
        this.length = a.length;
        if (carry !== 0) {
          this.words[this.length] = carry;
          this.length++;
        } else if (a !== this) {
          for (; i2 < a.length; i2++) {
            this.words[i2] = a.words[i2];
          }
        }
        return this;
      };
      BN2.prototype.add = function add(num) {
        var res;
        if (num.negative !== 0 && this.negative === 0) {
          num.negative = 0;
          res = this.sub(num);
          num.negative ^= 1;
          return res;
        } else if (num.negative === 0 && this.negative !== 0) {
          this.negative = 0;
          res = num.sub(this);
          this.negative = 1;
          return res;
        }
        if (this.length > num.length)
          return this.clone().iadd(num);
        return num.clone().iadd(this);
      };
      BN2.prototype.isub = function isub(num) {
        if (num.negative !== 0) {
          num.negative = 0;
          var r2 = this.iadd(num);
          num.negative = 1;
          return r2._normSign();
        } else if (this.negative !== 0) {
          this.negative = 0;
          this.iadd(num);
          this.negative = 1;
          return this._normSign();
        }
        var cmp = this.cmp(num);
        if (cmp === 0) {
          this.negative = 0;
          this.length = 1;
          this.words[0] = 0;
          return this;
        }
        var a, b;
        if (cmp > 0) {
          a = this;
          b = num;
        } else {
          a = num;
          b = this;
        }
        var carry = 0;
        for (var i2 = 0; i2 < b.length; i2++) {
          r2 = (a.words[i2] | 0) - (b.words[i2] | 0) + carry;
          carry = r2 >> 26;
          this.words[i2] = r2 & 67108863;
        }
        for (; carry !== 0 && i2 < a.length; i2++) {
          r2 = (a.words[i2] | 0) + carry;
          carry = r2 >> 26;
          this.words[i2] = r2 & 67108863;
        }
        if (carry === 0 && i2 < a.length && a !== this) {
          for (; i2 < a.length; i2++) {
            this.words[i2] = a.words[i2];
          }
        }
        this.length = Math.max(this.length, i2);
        if (a !== this) {
          this.negative = 1;
        }
        return this.strip();
      };
      BN2.prototype.sub = function sub(num) {
        return this.clone().isub(num);
      };
      function smallMulTo(self2, num, out) {
        out.negative = num.negative ^ self2.negative;
        var len2 = self2.length + num.length | 0;
        out.length = len2;
        len2 = len2 - 1 | 0;
        var a = self2.words[0] | 0;
        var b = num.words[0] | 0;
        var r2 = a * b;
        var lo = r2 & 67108863;
        var carry = r2 / 67108864 | 0;
        out.words[0] = lo;
        for (var k = 1; k < len2; k++) {
          var ncarry = carry >>> 26;
          var rword = carry & 67108863;
          var maxJ = Math.min(k, num.length - 1);
          for (var j = Math.max(0, k - self2.length + 1); j <= maxJ; j++) {
            var i2 = k - j | 0;
            a = self2.words[i2] | 0;
            b = num.words[j] | 0;
            r2 = a * b + rword;
            ncarry += r2 / 67108864 | 0;
            rword = r2 & 67108863;
          }
          out.words[k] = rword | 0;
          carry = ncarry | 0;
        }
        if (carry !== 0) {
          out.words[k] = carry | 0;
        } else {
          out.length--;
        }
        return out.strip();
      }
      var comb10MulTo = function comb10MulTo2(self2, num, out) {
        var a = self2.words;
        var b = num.words;
        var o = out.words;
        var c = 0;
        var lo;
        var mid;
        var hi;
        var a0 = a[0] | 0;
        var al0 = a0 & 8191;
        var ah0 = a0 >>> 13;
        var a1 = a[1] | 0;
        var al1 = a1 & 8191;
        var ah1 = a1 >>> 13;
        var a2 = a[2] | 0;
        var al2 = a2 & 8191;
        var ah2 = a2 >>> 13;
        var a3 = a[3] | 0;
        var al3 = a3 & 8191;
        var ah3 = a3 >>> 13;
        var a4 = a[4] | 0;
        var al4 = a4 & 8191;
        var ah4 = a4 >>> 13;
        var a5 = a[5] | 0;
        var al5 = a5 & 8191;
        var ah5 = a5 >>> 13;
        var a6 = a[6] | 0;
        var al6 = a6 & 8191;
        var ah6 = a6 >>> 13;
        var a7 = a[7] | 0;
        var al7 = a7 & 8191;
        var ah7 = a7 >>> 13;
        var a8 = a[8] | 0;
        var al8 = a8 & 8191;
        var ah8 = a8 >>> 13;
        var a9 = a[9] | 0;
        var al9 = a9 & 8191;
        var ah9 = a9 >>> 13;
        var b0 = b[0] | 0;
        var bl0 = b0 & 8191;
        var bh0 = b0 >>> 13;
        var b1 = b[1] | 0;
        var bl1 = b1 & 8191;
        var bh1 = b1 >>> 13;
        var b2 = b[2] | 0;
        var bl2 = b2 & 8191;
        var bh2 = b2 >>> 13;
        var b3 = b[3] | 0;
        var bl3 = b3 & 8191;
        var bh3 = b3 >>> 13;
        var b4 = b[4] | 0;
        var bl4 = b4 & 8191;
        var bh4 = b4 >>> 13;
        var b5 = b[5] | 0;
        var bl5 = b5 & 8191;
        var bh5 = b5 >>> 13;
        var b6 = b[6] | 0;
        var bl6 = b6 & 8191;
        var bh6 = b6 >>> 13;
        var b7 = b[7] | 0;
        var bl7 = b7 & 8191;
        var bh7 = b7 >>> 13;
        var b8 = b[8] | 0;
        var bl8 = b8 & 8191;
        var bh8 = b8 >>> 13;
        var b9 = b[9] | 0;
        var bl9 = b9 & 8191;
        var bh9 = b9 >>> 13;
        out.negative = self2.negative ^ num.negative;
        out.length = 19;
        lo = Math.imul(al0, bl0);
        mid = Math.imul(al0, bh0);
        mid = mid + Math.imul(ah0, bl0) | 0;
        hi = Math.imul(ah0, bh0);
        var w0 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;
        w0 &= 67108863;
        lo = Math.imul(al1, bl0);
        mid = Math.imul(al1, bh0);
        mid = mid + Math.imul(ah1, bl0) | 0;
        hi = Math.imul(ah1, bh0);
        lo = lo + Math.imul(al0, bl1) | 0;
        mid = mid + Math.imul(al0, bh1) | 0;
        mid = mid + Math.imul(ah0, bl1) | 0;
        hi = hi + Math.imul(ah0, bh1) | 0;
        var w1 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;
        w1 &= 67108863;
        lo = Math.imul(al2, bl0);
        mid = Math.imul(al2, bh0);
        mid = mid + Math.imul(ah2, bl0) | 0;
        hi = Math.imul(ah2, bh0);
        lo = lo + Math.imul(al1, bl1) | 0;
        mid = mid + Math.imul(al1, bh1) | 0;
        mid = mid + Math.imul(ah1, bl1) | 0;
        hi = hi + Math.imul(ah1, bh1) | 0;
        lo = lo + Math.imul(al0, bl2) | 0;
        mid = mid + Math.imul(al0, bh2) | 0;
        mid = mid + Math.imul(ah0, bl2) | 0;
        hi = hi + Math.imul(ah0, bh2) | 0;
        var w2 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;
        w2 &= 67108863;
        lo = Math.imul(al3, bl0);
        mid = Math.imul(al3, bh0);
        mid = mid + Math.imul(ah3, bl0) | 0;
        hi = Math.imul(ah3, bh0);
        lo = lo + Math.imul(al2, bl1) | 0;
        mid = mid + Math.imul(al2, bh1) | 0;
        mid = mid + Math.imul(ah2, bl1) | 0;
        hi = hi + Math.imul(ah2, bh1) | 0;
        lo = lo + Math.imul(al1, bl2) | 0;
        mid = mid + Math.imul(al1, bh2) | 0;
        mid = mid + Math.imul(ah1, bl2) | 0;
        hi = hi + Math.imul(ah1, bh2) | 0;
        lo = lo + Math.imul(al0, bl3) | 0;
        mid = mid + Math.imul(al0, bh3) | 0;
        mid = mid + Math.imul(ah0, bl3) | 0;
        hi = hi + Math.imul(ah0, bh3) | 0;
        var w3 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;
        w3 &= 67108863;
        lo = Math.imul(al4, bl0);
        mid = Math.imul(al4, bh0);
        mid = mid + Math.imul(ah4, bl0) | 0;
        hi = Math.imul(ah4, bh0);
        lo = lo + Math.imul(al3, bl1) | 0;
        mid = mid + Math.imul(al3, bh1) | 0;
        mid = mid + Math.imul(ah3, bl1) | 0;
        hi = hi + Math.imul(ah3, bh1) | 0;
        lo = lo + Math.imul(al2, bl2) | 0;
        mid = mid + Math.imul(al2, bh2) | 0;
        mid = mid + Math.imul(ah2, bl2) | 0;
        hi = hi + Math.imul(ah2, bh2) | 0;
        lo = lo + Math.imul(al1, bl3) | 0;
        mid = mid + Math.imul(al1, bh3) | 0;
        mid = mid + Math.imul(ah1, bl3) | 0;
        hi = hi + Math.imul(ah1, bh3) | 0;
        lo = lo + Math.imul(al0, bl4) | 0;
        mid = mid + Math.imul(al0, bh4) | 0;
        mid = mid + Math.imul(ah0, bl4) | 0;
        hi = hi + Math.imul(ah0, bh4) | 0;
        var w4 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;
        w4 &= 67108863;
        lo = Math.imul(al5, bl0);
        mid = Math.imul(al5, bh0);
        mid = mid + Math.imul(ah5, bl0) | 0;
        hi = Math.imul(ah5, bh0);
        lo = lo + Math.imul(al4, bl1) | 0;
        mid = mid + Math.imul(al4, bh1) | 0;
        mid = mid + Math.imul(ah4, bl1) | 0;
        hi = hi + Math.imul(ah4, bh1) | 0;
        lo = lo + Math.imul(al3, bl2) | 0;
        mid = mid + Math.imul(al3, bh2) | 0;
        mid = mid + Math.imul(ah3, bl2) | 0;
        hi = hi + Math.imul(ah3, bh2) | 0;
        lo = lo + Math.imul(al2, bl3) | 0;
        mid = mid + Math.imul(al2, bh3) | 0;
        mid = mid + Math.imul(ah2, bl3) | 0;
        hi = hi + Math.imul(ah2, bh3) | 0;
        lo = lo + Math.imul(al1, bl4) | 0;
        mid = mid + Math.imul(al1, bh4) | 0;
        mid = mid + Math.imul(ah1, bl4) | 0;
        hi = hi + Math.imul(ah1, bh4) | 0;
        lo = lo + Math.imul(al0, bl5) | 0;
        mid = mid + Math.imul(al0, bh5) | 0;
        mid = mid + Math.imul(ah0, bl5) | 0;
        hi = hi + Math.imul(ah0, bh5) | 0;
        var w5 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;
        w5 &= 67108863;
        lo = Math.imul(al6, bl0);
        mid = Math.imul(al6, bh0);
        mid = mid + Math.imul(ah6, bl0) | 0;
        hi = Math.imul(ah6, bh0);
        lo = lo + Math.imul(al5, bl1) | 0;
        mid = mid + Math.imul(al5, bh1) | 0;
        mid = mid + Math.imul(ah5, bl1) | 0;
        hi = hi + Math.imul(ah5, bh1) | 0;
        lo = lo + Math.imul(al4, bl2) | 0;
        mid = mid + Math.imul(al4, bh2) | 0;
        mid = mid + Math.imul(ah4, bl2) | 0;
        hi = hi + Math.imul(ah4, bh2) | 0;
        lo = lo + Math.imul(al3, bl3) | 0;
        mid = mid + Math.imul(al3, bh3) | 0;
        mid = mid + Math.imul(ah3, bl3) | 0;
        hi = hi + Math.imul(ah3, bh3) | 0;
        lo = lo + Math.imul(al2, bl4) | 0;
        mid = mid + Math.imul(al2, bh4) | 0;
        mid = mid + Math.imul(ah2, bl4) | 0;
        hi = hi + Math.imul(ah2, bh4) | 0;
        lo = lo + Math.imul(al1, bl5) | 0;
        mid = mid + Math.imul(al1, bh5) | 0;
        mid = mid + Math.imul(ah1, bl5) | 0;
        hi = hi + Math.imul(ah1, bh5) | 0;
        lo = lo + Math.imul(al0, bl6) | 0;
        mid = mid + Math.imul(al0, bh6) | 0;
        mid = mid + Math.imul(ah0, bl6) | 0;
        hi = hi + Math.imul(ah0, bh6) | 0;
        var w6 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;
        w6 &= 67108863;
        lo = Math.imul(al7, bl0);
        mid = Math.imul(al7, bh0);
        mid = mid + Math.imul(ah7, bl0) | 0;
        hi = Math.imul(ah7, bh0);
        lo = lo + Math.imul(al6, bl1) | 0;
        mid = mid + Math.imul(al6, bh1) | 0;
        mid = mid + Math.imul(ah6, bl1) | 0;
        hi = hi + Math.imul(ah6, bh1) | 0;
        lo = lo + Math.imul(al5, bl2) | 0;
        mid = mid + Math.imul(al5, bh2) | 0;
        mid = mid + Math.imul(ah5, bl2) | 0;
        hi = hi + Math.imul(ah5, bh2) | 0;
        lo = lo + Math.imul(al4, bl3) | 0;
        mid = mid + Math.imul(al4, bh3) | 0;
        mid = mid + Math.imul(ah4, bl3) | 0;
        hi = hi + Math.imul(ah4, bh3) | 0;
        lo = lo + Math.imul(al3, bl4) | 0;
        mid = mid + Math.imul(al3, bh4) | 0;
        mid = mid + Math.imul(ah3, bl4) | 0;
        hi = hi + Math.imul(ah3, bh4) | 0;
        lo = lo + Math.imul(al2, bl5) | 0;
        mid = mid + Math.imul(al2, bh5) | 0;
        mid = mid + Math.imul(ah2, bl5) | 0;
        hi = hi + Math.imul(ah2, bh5) | 0;
        lo = lo + Math.imul(al1, bl6) | 0;
        mid = mid + Math.imul(al1, bh6) | 0;
        mid = mid + Math.imul(ah1, bl6) | 0;
        hi = hi + Math.imul(ah1, bh6) | 0;
        lo = lo + Math.imul(al0, bl7) | 0;
        mid = mid + Math.imul(al0, bh7) | 0;
        mid = mid + Math.imul(ah0, bl7) | 0;
        hi = hi + Math.imul(ah0, bh7) | 0;
        var w7 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;
        w7 &= 67108863;
        lo = Math.imul(al8, bl0);
        mid = Math.imul(al8, bh0);
        mid = mid + Math.imul(ah8, bl0) | 0;
        hi = Math.imul(ah8, bh0);
        lo = lo + Math.imul(al7, bl1) | 0;
        mid = mid + Math.imul(al7, bh1) | 0;
        mid = mid + Math.imul(ah7, bl1) | 0;
        hi = hi + Math.imul(ah7, bh1) | 0;
        lo = lo + Math.imul(al6, bl2) | 0;
        mid = mid + Math.imul(al6, bh2) | 0;
        mid = mid + Math.imul(ah6, bl2) | 0;
        hi = hi + Math.imul(ah6, bh2) | 0;
        lo = lo + Math.imul(al5, bl3) | 0;
        mid = mid + Math.imul(al5, bh3) | 0;
        mid = mid + Math.imul(ah5, bl3) | 0;
        hi = hi + Math.imul(ah5, bh3) | 0;
        lo = lo + Math.imul(al4, bl4) | 0;
        mid = mid + Math.imul(al4, bh4) | 0;
        mid = mid + Math.imul(ah4, bl4) | 0;
        hi = hi + Math.imul(ah4, bh4) | 0;
        lo = lo + Math.imul(al3, bl5) | 0;
        mid = mid + Math.imul(al3, bh5) | 0;
        mid = mid + Math.imul(ah3, bl5) | 0;
        hi = hi + Math.imul(ah3, bh5) | 0;
        lo = lo + Math.imul(al2, bl6) | 0;
        mid = mid + Math.imul(al2, bh6) | 0;
        mid = mid + Math.imul(ah2, bl6) | 0;
        hi = hi + Math.imul(ah2, bh6) | 0;
        lo = lo + Math.imul(al1, bl7) | 0;
        mid = mid + Math.imul(al1, bh7) | 0;
        mid = mid + Math.imul(ah1, bl7) | 0;
        hi = hi + Math.imul(ah1, bh7) | 0;
        lo = lo + Math.imul(al0, bl8) | 0;
        mid = mid + Math.imul(al0, bh8) | 0;
        mid = mid + Math.imul(ah0, bl8) | 0;
        hi = hi + Math.imul(ah0, bh8) | 0;
        var w8 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;
        w8 &= 67108863;
        lo = Math.imul(al9, bl0);
        mid = Math.imul(al9, bh0);
        mid = mid + Math.imul(ah9, bl0) | 0;
        hi = Math.imul(ah9, bh0);
        lo = lo + Math.imul(al8, bl1) | 0;
        mid = mid + Math.imul(al8, bh1) | 0;
        mid = mid + Math.imul(ah8, bl1) | 0;
        hi = hi + Math.imul(ah8, bh1) | 0;
        lo = lo + Math.imul(al7, bl2) | 0;
        mid = mid + Math.imul(al7, bh2) | 0;
        mid = mid + Math.imul(ah7, bl2) | 0;
        hi = hi + Math.imul(ah7, bh2) | 0;
        lo = lo + Math.imul(al6, bl3) | 0;
        mid = mid + Math.imul(al6, bh3) | 0;
        mid = mid + Math.imul(ah6, bl3) | 0;
        hi = hi + Math.imul(ah6, bh3) | 0;
        lo = lo + Math.imul(al5, bl4) | 0;
        mid = mid + Math.imul(al5, bh4) | 0;
        mid = mid + Math.imul(ah5, bl4) | 0;
        hi = hi + Math.imul(ah5, bh4) | 0;
        lo = lo + Math.imul(al4, bl5) | 0;
        mid = mid + Math.imul(al4, bh5) | 0;
        mid = mid + Math.imul(ah4, bl5) | 0;
        hi = hi + Math.imul(ah4, bh5) | 0;
        lo = lo + Math.imul(al3, bl6) | 0;
        mid = mid + Math.imul(al3, bh6) | 0;
        mid = mid + Math.imul(ah3, bl6) | 0;
        hi = hi + Math.imul(ah3, bh6) | 0;
        lo = lo + Math.imul(al2, bl7) | 0;
        mid = mid + Math.imul(al2, bh7) | 0;
        mid = mid + Math.imul(ah2, bl7) | 0;
        hi = hi + Math.imul(ah2, bh7) | 0;
        lo = lo + Math.imul(al1, bl8) | 0;
        mid = mid + Math.imul(al1, bh8) | 0;
        mid = mid + Math.imul(ah1, bl8) | 0;
        hi = hi + Math.imul(ah1, bh8) | 0;
        lo = lo + Math.imul(al0, bl9) | 0;
        mid = mid + Math.imul(al0, bh9) | 0;
        mid = mid + Math.imul(ah0, bl9) | 0;
        hi = hi + Math.imul(ah0, bh9) | 0;
        var w9 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;
        w9 &= 67108863;
        lo = Math.imul(al9, bl1);
        mid = Math.imul(al9, bh1);
        mid = mid + Math.imul(ah9, bl1) | 0;
        hi = Math.imul(ah9, bh1);
        lo = lo + Math.imul(al8, bl2) | 0;
        mid = mid + Math.imul(al8, bh2) | 0;
        mid = mid + Math.imul(ah8, bl2) | 0;
        hi = hi + Math.imul(ah8, bh2) | 0;
        lo = lo + Math.imul(al7, bl3) | 0;
        mid = mid + Math.imul(al7, bh3) | 0;
        mid = mid + Math.imul(ah7, bl3) | 0;
        hi = hi + Math.imul(ah7, bh3) | 0;
        lo = lo + Math.imul(al6, bl4) | 0;
        mid = mid + Math.imul(al6, bh4) | 0;
        mid = mid + Math.imul(ah6, bl4) | 0;
        hi = hi + Math.imul(ah6, bh4) | 0;
        lo = lo + Math.imul(al5, bl5) | 0;
        mid = mid + Math.imul(al5, bh5) | 0;
        mid = mid + Math.imul(ah5, bl5) | 0;
        hi = hi + Math.imul(ah5, bh5) | 0;
        lo = lo + Math.imul(al4, bl6) | 0;
        mid = mid + Math.imul(al4, bh6) | 0;
        mid = mid + Math.imul(ah4, bl6) | 0;
        hi = hi + Math.imul(ah4, bh6) | 0;
        lo = lo + Math.imul(al3, bl7) | 0;
        mid = mid + Math.imul(al3, bh7) | 0;
        mid = mid + Math.imul(ah3, bl7) | 0;
        hi = hi + Math.imul(ah3, bh7) | 0;
        lo = lo + Math.imul(al2, bl8) | 0;
        mid = mid + Math.imul(al2, bh8) | 0;
        mid = mid + Math.imul(ah2, bl8) | 0;
        hi = hi + Math.imul(ah2, bh8) | 0;
        lo = lo + Math.imul(al1, bl9) | 0;
        mid = mid + Math.imul(al1, bh9) | 0;
        mid = mid + Math.imul(ah1, bl9) | 0;
        hi = hi + Math.imul(ah1, bh9) | 0;
        var w10 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;
        w10 &= 67108863;
        lo = Math.imul(al9, bl2);
        mid = Math.imul(al9, bh2);
        mid = mid + Math.imul(ah9, bl2) | 0;
        hi = Math.imul(ah9, bh2);
        lo = lo + Math.imul(al8, bl3) | 0;
        mid = mid + Math.imul(al8, bh3) | 0;
        mid = mid + Math.imul(ah8, bl3) | 0;
        hi = hi + Math.imul(ah8, bh3) | 0;
        lo = lo + Math.imul(al7, bl4) | 0;
        mid = mid + Math.imul(al7, bh4) | 0;
        mid = mid + Math.imul(ah7, bl4) | 0;
        hi = hi + Math.imul(ah7, bh4) | 0;
        lo = lo + Math.imul(al6, bl5) | 0;
        mid = mid + Math.imul(al6, bh5) | 0;
        mid = mid + Math.imul(ah6, bl5) | 0;
        hi = hi + Math.imul(ah6, bh5) | 0;
        lo = lo + Math.imul(al5, bl6) | 0;
        mid = mid + Math.imul(al5, bh6) | 0;
        mid = mid + Math.imul(ah5, bl6) | 0;
        hi = hi + Math.imul(ah5, bh6) | 0;
        lo = lo + Math.imul(al4, bl7) | 0;
        mid = mid + Math.imul(al4, bh7) | 0;
        mid = mid + Math.imul(ah4, bl7) | 0;
        hi = hi + Math.imul(ah4, bh7) | 0;
        lo = lo + Math.imul(al3, bl8) | 0;
        mid = mid + Math.imul(al3, bh8) | 0;
        mid = mid + Math.imul(ah3, bl8) | 0;
        hi = hi + Math.imul(ah3, bh8) | 0;
        lo = lo + Math.imul(al2, bl9) | 0;
        mid = mid + Math.imul(al2, bh9) | 0;
        mid = mid + Math.imul(ah2, bl9) | 0;
        hi = hi + Math.imul(ah2, bh9) | 0;
        var w11 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;
        w11 &= 67108863;
        lo = Math.imul(al9, bl3);
        mid = Math.imul(al9, bh3);
        mid = mid + Math.imul(ah9, bl3) | 0;
        hi = Math.imul(ah9, bh3);
        lo = lo + Math.imul(al8, bl4) | 0;
        mid = mid + Math.imul(al8, bh4) | 0;
        mid = mid + Math.imul(ah8, bl4) | 0;
        hi = hi + Math.imul(ah8, bh4) | 0;
        lo = lo + Math.imul(al7, bl5) | 0;
        mid = mid + Math.imul(al7, bh5) | 0;
        mid = mid + Math.imul(ah7, bl5) | 0;
        hi = hi + Math.imul(ah7, bh5) | 0;
        lo = lo + Math.imul(al6, bl6) | 0;
        mid = mid + Math.imul(al6, bh6) | 0;
        mid = mid + Math.imul(ah6, bl6) | 0;
        hi = hi + Math.imul(ah6, bh6) | 0;
        lo = lo + Math.imul(al5, bl7) | 0;
        mid = mid + Math.imul(al5, bh7) | 0;
        mid = mid + Math.imul(ah5, bl7) | 0;
        hi = hi + Math.imul(ah5, bh7) | 0;
        lo = lo + Math.imul(al4, bl8) | 0;
        mid = mid + Math.imul(al4, bh8) | 0;
        mid = mid + Math.imul(ah4, bl8) | 0;
        hi = hi + Math.imul(ah4, bh8) | 0;
        lo = lo + Math.imul(al3, bl9) | 0;
        mid = mid + Math.imul(al3, bh9) | 0;
        mid = mid + Math.imul(ah3, bl9) | 0;
        hi = hi + Math.imul(ah3, bh9) | 0;
        var w12 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;
        w12 &= 67108863;
        lo = Math.imul(al9, bl4);
        mid = Math.imul(al9, bh4);
        mid = mid + Math.imul(ah9, bl4) | 0;
        hi = Math.imul(ah9, bh4);
        lo = lo + Math.imul(al8, bl5) | 0;
        mid = mid + Math.imul(al8, bh5) | 0;
        mid = mid + Math.imul(ah8, bl5) | 0;
        hi = hi + Math.imul(ah8, bh5) | 0;
        lo = lo + Math.imul(al7, bl6) | 0;
        mid = mid + Math.imul(al7, bh6) | 0;
        mid = mid + Math.imul(ah7, bl6) | 0;
        hi = hi + Math.imul(ah7, bh6) | 0;
        lo = lo + Math.imul(al6, bl7) | 0;
        mid = mid + Math.imul(al6, bh7) | 0;
        mid = mid + Math.imul(ah6, bl7) | 0;
        hi = hi + Math.imul(ah6, bh7) | 0;
        lo = lo + Math.imul(al5, bl8) | 0;
        mid = mid + Math.imul(al5, bh8) | 0;
        mid = mid + Math.imul(ah5, bl8) | 0;
        hi = hi + Math.imul(ah5, bh8) | 0;
        lo = lo + Math.imul(al4, bl9) | 0;
        mid = mid + Math.imul(al4, bh9) | 0;
        mid = mid + Math.imul(ah4, bl9) | 0;
        hi = hi + Math.imul(ah4, bh9) | 0;
        var w13 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;
        w13 &= 67108863;
        lo = Math.imul(al9, bl5);
        mid = Math.imul(al9, bh5);
        mid = mid + Math.imul(ah9, bl5) | 0;
        hi = Math.imul(ah9, bh5);
        lo = lo + Math.imul(al8, bl6) | 0;
        mid = mid + Math.imul(al8, bh6) | 0;
        mid = mid + Math.imul(ah8, bl6) | 0;
        hi = hi + Math.imul(ah8, bh6) | 0;
        lo = lo + Math.imul(al7, bl7) | 0;
        mid = mid + Math.imul(al7, bh7) | 0;
        mid = mid + Math.imul(ah7, bl7) | 0;
        hi = hi + Math.imul(ah7, bh7) | 0;
        lo = lo + Math.imul(al6, bl8) | 0;
        mid = mid + Math.imul(al6, bh8) | 0;
        mid = mid + Math.imul(ah6, bl8) | 0;
        hi = hi + Math.imul(ah6, bh8) | 0;
        lo = lo + Math.imul(al5, bl9) | 0;
        mid = mid + Math.imul(al5, bh9) | 0;
        mid = mid + Math.imul(ah5, bl9) | 0;
        hi = hi + Math.imul(ah5, bh9) | 0;
        var w14 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;
        w14 &= 67108863;
        lo = Math.imul(al9, bl6);
        mid = Math.imul(al9, bh6);
        mid = mid + Math.imul(ah9, bl6) | 0;
        hi = Math.imul(ah9, bh6);
        lo = lo + Math.imul(al8, bl7) | 0;
        mid = mid + Math.imul(al8, bh7) | 0;
        mid = mid + Math.imul(ah8, bl7) | 0;
        hi = hi + Math.imul(ah8, bh7) | 0;
        lo = lo + Math.imul(al7, bl8) | 0;
        mid = mid + Math.imul(al7, bh8) | 0;
        mid = mid + Math.imul(ah7, bl8) | 0;
        hi = hi + Math.imul(ah7, bh8) | 0;
        lo = lo + Math.imul(al6, bl9) | 0;
        mid = mid + Math.imul(al6, bh9) | 0;
        mid = mid + Math.imul(ah6, bl9) | 0;
        hi = hi + Math.imul(ah6, bh9) | 0;
        var w15 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;
        w15 &= 67108863;
        lo = Math.imul(al9, bl7);
        mid = Math.imul(al9, bh7);
        mid = mid + Math.imul(ah9, bl7) | 0;
        hi = Math.imul(ah9, bh7);
        lo = lo + Math.imul(al8, bl8) | 0;
        mid = mid + Math.imul(al8, bh8) | 0;
        mid = mid + Math.imul(ah8, bl8) | 0;
        hi = hi + Math.imul(ah8, bh8) | 0;
        lo = lo + Math.imul(al7, bl9) | 0;
        mid = mid + Math.imul(al7, bh9) | 0;
        mid = mid + Math.imul(ah7, bl9) | 0;
        hi = hi + Math.imul(ah7, bh9) | 0;
        var w16 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;
        w16 &= 67108863;
        lo = Math.imul(al9, bl8);
        mid = Math.imul(al9, bh8);
        mid = mid + Math.imul(ah9, bl8) | 0;
        hi = Math.imul(ah9, bh8);
        lo = lo + Math.imul(al8, bl9) | 0;
        mid = mid + Math.imul(al8, bh9) | 0;
        mid = mid + Math.imul(ah8, bl9) | 0;
        hi = hi + Math.imul(ah8, bh9) | 0;
        var w17 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;
        w17 &= 67108863;
        lo = Math.imul(al9, bl9);
        mid = Math.imul(al9, bh9);
        mid = mid + Math.imul(ah9, bl9) | 0;
        hi = Math.imul(ah9, bh9);
        var w18 = (c + lo | 0) + ((mid & 8191) << 13) | 0;
        c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;
        w18 &= 67108863;
        o[0] = w0;
        o[1] = w1;
        o[2] = w2;
        o[3] = w3;
        o[4] = w4;
        o[5] = w5;
        o[6] = w6;
        o[7] = w7;
        o[8] = w8;
        o[9] = w9;
        o[10] = w10;
        o[11] = w11;
        o[12] = w12;
        o[13] = w13;
        o[14] = w14;
        o[15] = w15;
        o[16] = w16;
        o[17] = w17;
        o[18] = w18;
        if (c !== 0) {
          o[19] = c;
          out.length++;
        }
        return out;
      };
      if (!Math.imul) {
        comb10MulTo = smallMulTo;
      }
      function bigMulTo(self2, num, out) {
        out.negative = num.negative ^ self2.negative;
        out.length = self2.length + num.length;
        var carry = 0;
        var hncarry = 0;
        for (var k = 0; k < out.length - 1; k++) {
          var ncarry = hncarry;
          hncarry = 0;
          var rword = carry & 67108863;
          var maxJ = Math.min(k, num.length - 1);
          for (var j = Math.max(0, k - self2.length + 1); j <= maxJ; j++) {
            var i2 = k - j;
            var a = self2.words[i2] | 0;
            var b = num.words[j] | 0;
            var r2 = a * b;
            var lo = r2 & 67108863;
            ncarry = ncarry + (r2 / 67108864 | 0) | 0;
            lo = lo + rword | 0;
            rword = lo & 67108863;
            ncarry = ncarry + (lo >>> 26) | 0;
            hncarry += ncarry >>> 26;
            ncarry &= 67108863;
          }
          out.words[k] = rword;
          carry = ncarry;
          ncarry = hncarry;
        }
        if (carry !== 0) {
          out.words[k] = carry;
        } else {
          out.length--;
        }
        return out.strip();
      }
      function jumboMulTo(self2, num, out) {
        var fftm = new FFTM();
        return fftm.mulp(self2, num, out);
      }
      BN2.prototype.mulTo = function mulTo(num, out) {
        var res;
        var len2 = this.length + num.length;
        if (this.length === 10 && num.length === 10) {
          res = comb10MulTo(this, num, out);
        } else if (len2 < 63) {
          res = smallMulTo(this, num, out);
        } else if (len2 < 1024) {
          res = bigMulTo(this, num, out);
        } else {
          res = jumboMulTo(this, num, out);
        }
        return res;
      };
      function FFTM(x, y) {
        this.x = x;
        this.y = y;
      }
      FFTM.prototype.makeRBT = function makeRBT(N) {
        var t2 = new Array(N);
        var l = BN2.prototype._countBits(N) - 1;
        for (var i2 = 0; i2 < N; i2++) {
          t2[i2] = this.revBin(i2, l, N);
        }
        return t2;
      };
      FFTM.prototype.revBin = function revBin(x, l, N) {
        if (x === 0 || x === N - 1)
          return x;
        var rb = 0;
        for (var i2 = 0; i2 < l; i2++) {
          rb |= (x & 1) << l - i2 - 1;
          x >>= 1;
        }
        return rb;
      };
      FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
        for (var i2 = 0; i2 < N; i2++) {
          rtws[i2] = rws[rbt[i2]];
          itws[i2] = iws[rbt[i2]];
        }
      };
      FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
        this.permute(rbt, rws, iws, rtws, itws, N);
        for (var s2 = 1; s2 < N; s2 <<= 1) {
          var l = s2 << 1;
          var rtwdf = Math.cos(2 * Math.PI / l);
          var itwdf = Math.sin(2 * Math.PI / l);
          for (var p = 0; p < N; p += l) {
            var rtwdf_ = rtwdf;
            var itwdf_ = itwdf;
            for (var j = 0; j < s2; j++) {
              var re = rtws[p + j];
              var ie = itws[p + j];
              var ro = rtws[p + j + s2];
              var io = itws[p + j + s2];
              var rx = rtwdf_ * ro - itwdf_ * io;
              io = rtwdf_ * io + itwdf_ * ro;
              ro = rx;
              rtws[p + j] = re + ro;
              itws[p + j] = ie + io;
              rtws[p + j + s2] = re - ro;
              itws[p + j + s2] = ie - io;
              if (j !== l) {
                rx = rtwdf * rtwdf_ - itwdf * itwdf_;
                itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
                rtwdf_ = rx;
              }
            }
          }
        }
      };
      FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
        var N = Math.max(m, n) | 1;
        var odd = N & 1;
        var i2 = 0;
        for (N = N / 2 | 0; N; N = N >>> 1) {
          i2++;
        }
        return 1 << i2 + 1 + odd;
      };
      FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
        if (N <= 1)
          return;
        for (var i2 = 0; i2 < N / 2; i2++) {
          var t2 = rws[i2];
          rws[i2] = rws[N - i2 - 1];
          rws[N - i2 - 1] = t2;
          t2 = iws[i2];
          iws[i2] = -iws[N - i2 - 1];
          iws[N - i2 - 1] = -t2;
        }
      };
      FFTM.prototype.normalize13b = function normalize13b(ws, N) {
        var carry = 0;
        for (var i2 = 0; i2 < N / 2; i2++) {
          var w = Math.round(ws[2 * i2 + 1] / N) * 8192 + Math.round(ws[2 * i2] / N) + carry;
          ws[i2] = w & 67108863;
          if (w < 67108864) {
            carry = 0;
          } else {
            carry = w / 67108864 | 0;
          }
        }
        return ws;
      };
      FFTM.prototype.convert13b = function convert13b(ws, len2, rws, N) {
        var carry = 0;
        for (var i2 = 0; i2 < len2; i2++) {
          carry = carry + (ws[i2] | 0);
          rws[2 * i2] = carry & 8191;
          carry = carry >>> 13;
          rws[2 * i2 + 1] = carry & 8191;
          carry = carry >>> 13;
        }
        for (i2 = 2 * len2; i2 < N; ++i2) {
          rws[i2] = 0;
        }
        assert2(carry === 0);
        assert2((carry & ~8191) === 0);
      };
      FFTM.prototype.stub = function stub(N) {
        var ph = new Array(N);
        for (var i2 = 0; i2 < N; i2++) {
          ph[i2] = 0;
        }
        return ph;
      };
      FFTM.prototype.mulp = function mulp(x, y, out) {
        var N = 2 * this.guessLen13b(x.length, y.length);
        var rbt = this.makeRBT(N);
        var _ = this.stub(N);
        var rws = new Array(N);
        var rwst = new Array(N);
        var iwst = new Array(N);
        var nrws = new Array(N);
        var nrwst = new Array(N);
        var niwst = new Array(N);
        var rmws = out.words;
        rmws.length = N;
        this.convert13b(x.words, x.length, rws, N);
        this.convert13b(y.words, y.length, nrws, N);
        this.transform(rws, _, rwst, iwst, N, rbt);
        this.transform(nrws, _, nrwst, niwst, N, rbt);
        for (var i2 = 0; i2 < N; i2++) {
          var rx = rwst[i2] * nrwst[i2] - iwst[i2] * niwst[i2];
          iwst[i2] = rwst[i2] * niwst[i2] + iwst[i2] * nrwst[i2];
          rwst[i2] = rx;
        }
        this.conjugate(rwst, iwst, N);
        this.transform(rwst, iwst, rmws, _, N, rbt);
        this.conjugate(rmws, _, N);
        this.normalize13b(rmws, N);
        out.negative = x.negative ^ y.negative;
        out.length = x.length + y.length;
        return out.strip();
      };
      BN2.prototype.mul = function mul(num) {
        var out = new BN2(null);
        out.words = new Array(this.length + num.length);
        return this.mulTo(num, out);
      };
      BN2.prototype.mulf = function mulf(num) {
        var out = new BN2(null);
        out.words = new Array(this.length + num.length);
        return jumboMulTo(this, num, out);
      };
      BN2.prototype.imul = function imul(num) {
        return this.clone().mulTo(num, this);
      };
      BN2.prototype.imuln = function imuln(num) {
        assert2(typeof num === "number");
        assert2(num < 67108864);
        var carry = 0;
        for (var i2 = 0; i2 < this.length; i2++) {
          var w = (this.words[i2] | 0) * num;
          var lo = (w & 67108863) + (carry & 67108863);
          carry >>= 26;
          carry += w / 67108864 | 0;
          carry += lo >>> 26;
          this.words[i2] = lo & 67108863;
        }
        if (carry !== 0) {
          this.words[i2] = carry;
          this.length++;
        }
        return this;
      };
      BN2.prototype.muln = function muln(num) {
        return this.clone().imuln(num);
      };
      BN2.prototype.sqr = function sqr() {
        return this.mul(this);
      };
      BN2.prototype.isqr = function isqr() {
        return this.imul(this.clone());
      };
      BN2.prototype.pow = function pow(num) {
        var w = toBitArray(num);
        if (w.length === 0)
          return new BN2(1);
        var res = this;
        for (var i2 = 0; i2 < w.length; i2++, res = res.sqr()) {
          if (w[i2] !== 0)
            break;
        }
        if (++i2 < w.length) {
          for (var q = res.sqr(); i2 < w.length; i2++, q = q.sqr()) {
            if (w[i2] === 0)
              continue;
            res = res.mul(q);
          }
        }
        return res;
      };
      BN2.prototype.iushln = function iushln(bits) {
        assert2(typeof bits === "number" && bits >= 0);
        var r2 = bits % 26;
        var s2 = (bits - r2) / 26;
        var carryMask = 67108863 >>> 26 - r2 << 26 - r2;
        var i2;
        if (r2 !== 0) {
          var carry = 0;
          for (i2 = 0; i2 < this.length; i2++) {
            var newCarry = this.words[i2] & carryMask;
            var c = (this.words[i2] | 0) - newCarry << r2;
            this.words[i2] = c | carry;
            carry = newCarry >>> 26 - r2;
          }
          if (carry) {
            this.words[i2] = carry;
            this.length++;
          }
        }
        if (s2 !== 0) {
          for (i2 = this.length - 1; i2 >= 0; i2--) {
            this.words[i2 + s2] = this.words[i2];
          }
          for (i2 = 0; i2 < s2; i2++) {
            this.words[i2] = 0;
          }
          this.length += s2;
        }
        return this.strip();
      };
      BN2.prototype.ishln = function ishln(bits) {
        assert2(this.negative === 0);
        return this.iushln(bits);
      };
      BN2.prototype.iushrn = function iushrn(bits, hint, extended) {
        assert2(typeof bits === "number" && bits >= 0);
        var h;
        if (hint) {
          h = (hint - hint % 26) / 26;
        } else {
          h = 0;
        }
        var r2 = bits % 26;
        var s2 = Math.min((bits - r2) / 26, this.length);
        var mask = 67108863 ^ 67108863 >>> r2 << r2;
        var maskedWords = extended;
        h -= s2;
        h = Math.max(0, h);
        if (maskedWords) {
          for (var i2 = 0; i2 < s2; i2++) {
            maskedWords.words[i2] = this.words[i2];
          }
          maskedWords.length = s2;
        }
        if (s2 === 0)
          ;
        else if (this.length > s2) {
          this.length -= s2;
          for (i2 = 0; i2 < this.length; i2++) {
            this.words[i2] = this.words[i2 + s2];
          }
        } else {
          this.words[0] = 0;
          this.length = 1;
        }
        var carry = 0;
        for (i2 = this.length - 1; i2 >= 0 && (carry !== 0 || i2 >= h); i2--) {
          var word = this.words[i2] | 0;
          this.words[i2] = carry << 26 - r2 | word >>> r2;
          carry = word & mask;
        }
        if (maskedWords && carry !== 0) {
          maskedWords.words[maskedWords.length++] = carry;
        }
        if (this.length === 0) {
          this.words[0] = 0;
          this.length = 1;
        }
        return this.strip();
      };
      BN2.prototype.ishrn = function ishrn(bits, hint, extended) {
        assert2(this.negative === 0);
        return this.iushrn(bits, hint, extended);
      };
      BN2.prototype.shln = function shln(bits) {
        return this.clone().ishln(bits);
      };
      BN2.prototype.ushln = function ushln(bits) {
        return this.clone().iushln(bits);
      };
      BN2.prototype.shrn = function shrn(bits) {
        return this.clone().ishrn(bits);
      };
      BN2.prototype.ushrn = function ushrn(bits) {
        return this.clone().iushrn(bits);
      };
      BN2.prototype.testn = function testn(bit) {
        assert2(typeof bit === "number" && bit >= 0);
        var r2 = bit % 26;
        var s2 = (bit - r2) / 26;
        var q = 1 << r2;
        if (this.length <= s2)
          return false;
        var w = this.words[s2];
        return !!(w & q);
      };
      BN2.prototype.imaskn = function imaskn(bits) {
        assert2(typeof bits === "number" && bits >= 0);
        var r2 = bits % 26;
        var s2 = (bits - r2) / 26;
        assert2(this.negative === 0, "imaskn works only with positive numbers");
        if (this.length <= s2) {
          return this;
        }
        if (r2 !== 0) {
          s2++;
        }
        this.length = Math.min(s2, this.length);
        if (r2 !== 0) {
          var mask = 67108863 ^ 67108863 >>> r2 << r2;
          this.words[this.length - 1] &= mask;
        }
        return this.strip();
      };
      BN2.prototype.maskn = function maskn(bits) {
        return this.clone().imaskn(bits);
      };
      BN2.prototype.iaddn = function iaddn(num) {
        assert2(typeof num === "number");
        assert2(num < 67108864);
        if (num < 0)
          return this.isubn(-num);
        if (this.negative !== 0) {
          if (this.length === 1 && (this.words[0] | 0) < num) {
            this.words[0] = num - (this.words[0] | 0);
            this.negative = 0;
            return this;
          }
          this.negative = 0;
          this.isubn(num);
          this.negative = 1;
          return this;
        }
        return this._iaddn(num);
      };
      BN2.prototype._iaddn = function _iaddn(num) {
        this.words[0] += num;
        for (var i2 = 0; i2 < this.length && this.words[i2] >= 67108864; i2++) {
          this.words[i2] -= 67108864;
          if (i2 === this.length - 1) {
            this.words[i2 + 1] = 1;
          } else {
            this.words[i2 + 1]++;
          }
        }
        this.length = Math.max(this.length, i2 + 1);
        return this;
      };
      BN2.prototype.isubn = function isubn(num) {
        assert2(typeof num === "number");
        assert2(num < 67108864);
        if (num < 0)
          return this.iaddn(-num);
        if (this.negative !== 0) {
          this.negative = 0;
          this.iaddn(num);
          this.negative = 1;
          return this;
        }
        this.words[0] -= num;
        if (this.length === 1 && this.words[0] < 0) {
          this.words[0] = -this.words[0];
          this.negative = 1;
        } else {
          for (var i2 = 0; i2 < this.length && this.words[i2] < 0; i2++) {
            this.words[i2] += 67108864;
            this.words[i2 + 1] -= 1;
          }
        }
        return this.strip();
      };
      BN2.prototype.addn = function addn(num) {
        return this.clone().iaddn(num);
      };
      BN2.prototype.subn = function subn(num) {
        return this.clone().isubn(num);
      };
      BN2.prototype.iabs = function iabs() {
        this.negative = 0;
        return this;
      };
      BN2.prototype.abs = function abs() {
        return this.clone().iabs();
      };
      BN2.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
        var len2 = num.length + shift;
        var i2;
        this._expand(len2);
        var w;
        var carry = 0;
        for (i2 = 0; i2 < num.length; i2++) {
          w = (this.words[i2 + shift] | 0) + carry;
          var right = (num.words[i2] | 0) * mul;
          w -= right & 67108863;
          carry = (w >> 26) - (right / 67108864 | 0);
          this.words[i2 + shift] = w & 67108863;
        }
        for (; i2 < this.length - shift; i2++) {
          w = (this.words[i2 + shift] | 0) + carry;
          carry = w >> 26;
          this.words[i2 + shift] = w & 67108863;
        }
        if (carry === 0)
          return this.strip();
        assert2(carry === -1);
        carry = 0;
        for (i2 = 0; i2 < this.length; i2++) {
          w = -(this.words[i2] | 0) + carry;
          carry = w >> 26;
          this.words[i2] = w & 67108863;
        }
        this.negative = 1;
        return this.strip();
      };
      BN2.prototype._wordDiv = function _wordDiv(num, mode) {
        var shift = this.length - num.length;
        var a = this.clone();
        var b = num;
        var bhi = b.words[b.length - 1] | 0;
        var bhiBits = this._countBits(bhi);
        shift = 26 - bhiBits;
        if (shift !== 0) {
          b = b.ushln(shift);
          a.iushln(shift);
          bhi = b.words[b.length - 1] | 0;
        }
        var m = a.length - b.length;
        var q;
        if (mode !== "mod") {
          q = new BN2(null);
          q.length = m + 1;
          q.words = new Array(q.length);
          for (var i2 = 0; i2 < q.length; i2++) {
            q.words[i2] = 0;
          }
        }
        var diff = a.clone()._ishlnsubmul(b, 1, m);
        if (diff.negative === 0) {
          a = diff;
          if (q) {
            q.words[m] = 1;
          }
        }
        for (var j = m - 1; j >= 0; j--) {
          var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0);
          qj = Math.min(qj / bhi | 0, 67108863);
          a._ishlnsubmul(b, qj, j);
          while (a.negative !== 0) {
            qj--;
            a.negative = 0;
            a._ishlnsubmul(b, 1, j);
            if (!a.isZero()) {
              a.negative ^= 1;
            }
          }
          if (q) {
            q.words[j] = qj;
          }
        }
        if (q) {
          q.strip();
        }
        a.strip();
        if (mode !== "div" && shift !== 0) {
          a.iushrn(shift);
        }
        return {
          div: q || null,
          mod: a
        };
      };
      BN2.prototype.divmod = function divmod(num, mode, positive) {
        assert2(!num.isZero());
        if (this.isZero()) {
          return {
            div: new BN2(0),
            mod: new BN2(0)
          };
        }
        var div, mod, res;
        if (this.negative !== 0 && num.negative === 0) {
          res = this.neg().divmod(num, mode);
          if (mode !== "mod") {
            div = res.div.neg();
          }
          if (mode !== "div") {
            mod = res.mod.neg();
            if (positive && mod.negative !== 0) {
              mod.iadd(num);
            }
          }
          return {
            div,
            mod
          };
        }
        if (this.negative === 0 && num.negative !== 0) {
          res = this.divmod(num.neg(), mode);
          if (mode !== "mod") {
            div = res.div.neg();
          }
          return {
            div,
            mod: res.mod
          };
        }
        if ((this.negative & num.negative) !== 0) {
          res = this.neg().divmod(num.neg(), mode);
          if (mode !== "div") {
            mod = res.mod.neg();
            if (positive && mod.negative !== 0) {
              mod.isub(num);
            }
          }
          return {
            div: res.div,
            mod
          };
        }
        if (num.length > this.length || this.cmp(num) < 0) {
          return {
            div: new BN2(0),
            mod: this
          };
        }
        if (num.length === 1) {
          if (mode === "div") {
            return {
              div: this.divn(num.words[0]),
              mod: null
            };
          }
          if (mode === "mod") {
            return {
              div: null,
              mod: new BN2(this.modn(num.words[0]))
            };
          }
          return {
            div: this.divn(num.words[0]),
            mod: new BN2(this.modn(num.words[0]))
          };
        }
        return this._wordDiv(num, mode);
      };
      BN2.prototype.div = function div(num) {
        return this.divmod(num, "div", false).div;
      };
      BN2.prototype.mod = function mod(num) {
        return this.divmod(num, "mod", false).mod;
      };
      BN2.prototype.umod = function umod(num) {
        return this.divmod(num, "mod", true).mod;
      };
      BN2.prototype.divRound = function divRound(num) {
        var dm = this.divmod(num);
        if (dm.mod.isZero())
          return dm.div;
        var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
        var half = num.ushrn(1);
        var r2 = num.andln(1);
        var cmp = mod.cmp(half);
        if (cmp < 0 || r2 === 1 && cmp === 0)
          return dm.div;
        return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
      };
      BN2.prototype.modn = function modn(num) {
        assert2(num <= 67108863);
        var p = (1 << 26) % num;
        var acc = 0;
        for (var i2 = this.length - 1; i2 >= 0; i2--) {
          acc = (p * acc + (this.words[i2] | 0)) % num;
        }
        return acc;
      };
      BN2.prototype.idivn = function idivn(num) {
        assert2(num <= 67108863);
        var carry = 0;
        for (var i2 = this.length - 1; i2 >= 0; i2--) {
          var w = (this.words[i2] | 0) + carry * 67108864;
          this.words[i2] = w / num | 0;
          carry = w % num;
        }
        return this.strip();
      };
      BN2.prototype.divn = function divn(num) {
        return this.clone().idivn(num);
      };
      BN2.prototype.egcd = function egcd(p) {
        assert2(p.negative === 0);
        assert2(!p.isZero());
        var x = this;
        var y = p.clone();
        if (x.negative !== 0) {
          x = x.umod(p);
        } else {
          x = x.clone();
        }
        var A = new BN2(1);
        var B = new BN2(0);
        var C = new BN2(0);
        var D = new BN2(1);
        var g = 0;
        while (x.isEven() && y.isEven()) {
          x.iushrn(1);
          y.iushrn(1);
          ++g;
        }
        var yp = y.clone();
        var xp = x.clone();
        while (!x.isZero()) {
          for (var i2 = 0, im = 1; (x.words[0] & im) === 0 && i2 < 26; ++i2, im <<= 1)
            ;
          if (i2 > 0) {
            x.iushrn(i2);
            while (i2-- > 0) {
              if (A.isOdd() || B.isOdd()) {
                A.iadd(yp);
                B.isub(xp);
              }
              A.iushrn(1);
              B.iushrn(1);
            }
          }
          for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1)
            ;
          if (j > 0) {
            y.iushrn(j);
            while (j-- > 0) {
              if (C.isOdd() || D.isOdd()) {
                C.iadd(yp);
                D.isub(xp);
              }
              C.iushrn(1);
              D.iushrn(1);
            }
          }
          if (x.cmp(y) >= 0) {
            x.isub(y);
            A.isub(C);
            B.isub(D);
          } else {
            y.isub(x);
            C.isub(A);
            D.isub(B);
          }
        }
        return {
          a: C,
          b: D,
          gcd: y.iushln(g)
        };
      };
      BN2.prototype._invmp = function _invmp(p) {
        assert2(p.negative === 0);
        assert2(!p.isZero());
        var a = this;
        var b = p.clone();
        if (a.negative !== 0) {
          a = a.umod(p);
        } else {
          a = a.clone();
        }
        var x1 = new BN2(1);
        var x2 = new BN2(0);
        var delta = b.clone();
        while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
          for (var i2 = 0, im = 1; (a.words[0] & im) === 0 && i2 < 26; ++i2, im <<= 1)
            ;
          if (i2 > 0) {
            a.iushrn(i2);
            while (i2-- > 0) {
              if (x1.isOdd()) {
                x1.iadd(delta);
              }
              x1.iushrn(1);
            }
          }
          for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1)
            ;
          if (j > 0) {
            b.iushrn(j);
            while (j-- > 0) {
              if (x2.isOdd()) {
                x2.iadd(delta);
              }
              x2.iushrn(1);
            }
          }
          if (a.cmp(b) >= 0) {
            a.isub(b);
            x1.isub(x2);
          } else {
            b.isub(a);
            x2.isub(x1);
          }
        }
        var res;
        if (a.cmpn(1) === 0) {
          res = x1;
        } else {
          res = x2;
        }
        if (res.cmpn(0) < 0) {
          res.iadd(p);
        }
        return res;
      };
      BN2.prototype.gcd = function gcd(num) {
        if (this.isZero())
          return num.abs();
        if (num.isZero())
          return this.abs();
        var a = this.clone();
        var b = num.clone();
        a.negative = 0;
        b.negative = 0;
        for (var shift = 0; a.isEven() && b.isEven(); shift++) {
          a.iushrn(1);
          b.iushrn(1);
        }
        do {
          while (a.isEven()) {
            a.iushrn(1);
          }
          while (b.isEven()) {
            b.iushrn(1);
          }
          var r2 = a.cmp(b);
          if (r2 < 0) {
            var t2 = a;
            a = b;
            b = t2;
          } else if (r2 === 0 || b.cmpn(1) === 0) {
            break;
          }
          a.isub(b);
        } while (true);
        return b.iushln(shift);
      };
      BN2.prototype.invm = function invm(num) {
        return this.egcd(num).a.umod(num);
      };
      BN2.prototype.isEven = function isEven() {
        return (this.words[0] & 1) === 0;
      };
      BN2.prototype.isOdd = function isOdd() {
        return (this.words[0] & 1) === 1;
      };
      BN2.prototype.andln = function andln(num) {
        return this.words[0] & num;
      };
      BN2.prototype.bincn = function bincn(bit) {
        assert2(typeof bit === "number");
        var r2 = bit % 26;
        var s2 = (bit - r2) / 26;
        var q = 1 << r2;
        if (this.length <= s2) {
          this._expand(s2 + 1);
          this.words[s2] |= q;
          return this;
        }
        var carry = q;
        for (var i2 = s2; carry !== 0 && i2 < this.length; i2++) {
          var w = this.words[i2] | 0;
          w += carry;
          carry = w >>> 26;
          w &= 67108863;
          this.words[i2] = w;
        }
        if (carry !== 0) {
          this.words[i2] = carry;
          this.length++;
        }
        return this;
      };
      BN2.prototype.isZero = function isZero() {
        return this.length === 1 && this.words[0] === 0;
      };
      BN2.prototype.cmpn = function cmpn(num) {
        var negative = num < 0;
        if (this.negative !== 0 && !negative)
          return -1;
        if (this.negative === 0 && negative)
          return 1;
        this.strip();
        var res;
        if (this.length > 1) {
          res = 1;
        } else {
          if (negative) {
            num = -num;
          }
          assert2(num <= 67108863, "Number is too big");
          var w = this.words[0] | 0;
          res = w === num ? 0 : w < num ? -1 : 1;
        }
        if (this.negative !== 0)
          return -res | 0;
        return res;
      };
      BN2.prototype.cmp = function cmp(num) {
        if (this.negative !== 0 && num.negative === 0)
          return -1;
        if (this.negative === 0 && num.negative !== 0)
          return 1;
        var res = this.ucmp(num);
        if (this.negative !== 0)
          return -res | 0;
        return res;
      };
      BN2.prototype.ucmp = function ucmp(num) {
        if (this.length > num.length)
          return 1;
        if (this.length < num.length)
          return -1;
        var res = 0;
        for (var i2 = this.length - 1; i2 >= 0; i2--) {
          var a = this.words[i2] | 0;
          var b = num.words[i2] | 0;
          if (a === b)
            continue;
          if (a < b) {
            res = -1;
          } else if (a > b) {
            res = 1;
          }
          break;
        }
        return res;
      };
      BN2.prototype.gtn = function gtn(num) {
        return this.cmpn(num) === 1;
      };
      BN2.prototype.gt = function gt(num) {
        return this.cmp(num) === 1;
      };
      BN2.prototype.gten = function gten(num) {
        return this.cmpn(num) >= 0;
      };
      BN2.prototype.gte = function gte(num) {
        return this.cmp(num) >= 0;
      };
      BN2.prototype.ltn = function ltn(num) {
        return this.cmpn(num) === -1;
      };
      BN2.prototype.lt = function lt(num) {
        return this.cmp(num) === -1;
      };
      BN2.prototype.lten = function lten(num) {
        return this.cmpn(num) <= 0;
      };
      BN2.prototype.lte = function lte(num) {
        return this.cmp(num) <= 0;
      };
      BN2.prototype.eqn = function eqn(num) {
        return this.cmpn(num) === 0;
      };
      BN2.prototype.eq = function eq(num) {
        return this.cmp(num) === 0;
      };
      BN2.red = function red(num) {
        return new Red(num);
      };
      BN2.prototype.toRed = function toRed(ctx) {
        assert2(!this.red, "Already a number in reduction context");
        assert2(this.negative === 0, "red works only with positives");
        return ctx.convertTo(this)._forceRed(ctx);
      };
      BN2.prototype.fromRed = function fromRed() {
        assert2(this.red, "fromRed works only with numbers in reduction context");
        return this.red.convertFrom(this);
      };
      BN2.prototype._forceRed = function _forceRed(ctx) {
        this.red = ctx;
        return this;
      };
      BN2.prototype.forceRed = function forceRed(ctx) {
        assert2(!this.red, "Already a number in reduction context");
        return this._forceRed(ctx);
      };
      BN2.prototype.redAdd = function redAdd(num) {
        assert2(this.red, "redAdd works only with red numbers");
        return this.red.add(this, num);
      };
      BN2.prototype.redIAdd = function redIAdd(num) {
        assert2(this.red, "redIAdd works only with red numbers");
        return this.red.iadd(this, num);
      };
      BN2.prototype.redSub = function redSub(num) {
        assert2(this.red, "redSub works only with red numbers");
        return this.red.sub(this, num);
      };
      BN2.prototype.redISub = function redISub(num) {
        assert2(this.red, "redISub works only with red numbers");
        return this.red.isub(this, num);
      };
      BN2.prototype.redShl = function redShl(num) {
        assert2(this.red, "redShl works only with red numbers");
        return this.red.shl(this, num);
      };
      BN2.prototype.redMul = function redMul(num) {
        assert2(this.red, "redMul works only with red numbers");
        this.red._verify2(this, num);
        return this.red.mul(this, num);
      };
      BN2.prototype.redIMul = function redIMul(num) {
        assert2(this.red, "redMul works only with red numbers");
        this.red._verify2(this, num);
        return this.red.imul(this, num);
      };
      BN2.prototype.redSqr = function redSqr() {
        assert2(this.red, "redSqr works only with red numbers");
        this.red._verify1(this);
        return this.red.sqr(this);
      };
      BN2.prototype.redISqr = function redISqr() {
        assert2(this.red, "redISqr works only with red numbers");
        this.red._verify1(this);
        return this.red.isqr(this);
      };
      BN2.prototype.redSqrt = function redSqrt() {
        assert2(this.red, "redSqrt works only with red numbers");
        this.red._verify1(this);
        return this.red.sqrt(this);
      };
      BN2.prototype.redInvm = function redInvm() {
        assert2(this.red, "redInvm works only with red numbers");
        this.red._verify1(this);
        return this.red.invm(this);
      };
      BN2.prototype.redNeg = function redNeg() {
        assert2(this.red, "redNeg works only with red numbers");
        this.red._verify1(this);
        return this.red.neg(this);
      };
      BN2.prototype.redPow = function redPow(num) {
        assert2(this.red && !num.red, "redPow(normalNum)");
        this.red._verify1(this);
        return this.red.pow(this, num);
      };
      var primes = {
        k256: null,
        p224: null,
        p192: null,
        p25519: null
      };
      function MPrime(name2, p) {
        this.name = name2;
        this.p = new BN2(p, 16);
        this.n = this.p.bitLength();
        this.k = new BN2(1).iushln(this.n).isub(this.p);
        this.tmp = this._tmp();
      }
      MPrime.prototype._tmp = function _tmp() {
        var tmp = new BN2(null);
        tmp.words = new Array(Math.ceil(this.n / 13));
        return tmp;
      };
      MPrime.prototype.ireduce = function ireduce(num) {
        var r2 = num;
        var rlen;
        do {
          this.split(r2, this.tmp);
          r2 = this.imulK(r2);
          r2 = r2.iadd(this.tmp);
          rlen = r2.bitLength();
        } while (rlen > this.n);
        var cmp = rlen < this.n ? -1 : r2.ucmp(this.p);
        if (cmp === 0) {
          r2.words[0] = 0;
          r2.length = 1;
        } else if (cmp > 0) {
          r2.isub(this.p);
        } else {
          if (r2.strip !== void 0) {
            r2.strip();
          } else {
            r2._strip();
          }
        }
        return r2;
      };
      MPrime.prototype.split = function split(input, out) {
        input.iushrn(this.n, 0, out);
      };
      MPrime.prototype.imulK = function imulK(num) {
        return num.imul(this.k);
      };
      function K256() {
        MPrime.call(
          this,
          "k256",
          "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"
        );
      }
      inherits2(K256, MPrime);
      K256.prototype.split = function split(input, output) {
        var mask = 4194303;
        var outLen = Math.min(input.length, 9);
        for (var i2 = 0; i2 < outLen; i2++) {
          output.words[i2] = input.words[i2];
        }
        output.length = outLen;
        if (input.length <= 9) {
          input.words[0] = 0;
          input.length = 1;
          return;
        }
        var prev = input.words[9];
        output.words[output.length++] = prev & mask;
        for (i2 = 10; i2 < input.length; i2++) {
          var next = input.words[i2] | 0;
          input.words[i2 - 10] = (next & mask) << 4 | prev >>> 22;
          prev = next;
        }
        prev >>>= 22;
        input.words[i2 - 10] = prev;
        if (prev === 0 && input.length > 10) {
          input.length -= 10;
        } else {
          input.length -= 9;
        }
      };
      K256.prototype.imulK = function imulK(num) {
        num.words[num.length] = 0;
        num.words[num.length + 1] = 0;
        num.length += 2;
        var lo = 0;
        for (var i2 = 0; i2 < num.length; i2++) {
          var w = num.words[i2] | 0;
          lo += w * 977;
          num.words[i2] = lo & 67108863;
          lo = w * 64 + (lo / 67108864 | 0);
        }
        if (num.words[num.length - 1] === 0) {
          num.length--;
          if (num.words[num.length - 1] === 0) {
            num.length--;
          }
        }
        return num;
      };
      function P224() {
        MPrime.call(
          this,
          "p224",
          "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"
        );
      }
      inherits2(P224, MPrime);
      function P192() {
        MPrime.call(
          this,
          "p192",
          "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"
        );
      }
      inherits2(P192, MPrime);
      function P25519() {
        MPrime.call(
          this,
          "25519",
          "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"
        );
      }
      inherits2(P25519, MPrime);
      P25519.prototype.imulK = function imulK(num) {
        var carry = 0;
        for (var i2 = 0; i2 < num.length; i2++) {
          var hi = (num.words[i2] | 0) * 19 + carry;
          var lo = hi & 67108863;
          hi >>>= 26;
          num.words[i2] = lo;
          carry = hi;
        }
        if (carry !== 0) {
          num.words[num.length++] = carry;
        }
        return num;
      };
      BN2._prime = function prime(name2) {
        if (primes[name2])
          return primes[name2];
        var prime2;
        if (name2 === "k256") {
          prime2 = new K256();
        } else if (name2 === "p224") {
          prime2 = new P224();
        } else if (name2 === "p192") {
          prime2 = new P192();
        } else if (name2 === "p25519") {
          prime2 = new P25519();
        } else {
          throw new Error("Unknown prime " + name2);
        }
        primes[name2] = prime2;
        return prime2;
      };
      function Red(m) {
        if (typeof m === "string") {
          var prime = BN2._prime(m);
          this.m = prime.p;
          this.prime = prime;
        } else {
          assert2(m.gtn(1), "modulus must be greater than 1");
          this.m = m;
          this.prime = null;
        }
      }
      Red.prototype._verify1 = function _verify1(a) {
        assert2(a.negative === 0, "red works only with positives");
        assert2(a.red, "red works only with red numbers");
      };