@sv-print/plugin-cloud 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";var ln=Object.defineProperty,nn=Object.defineProperties;var sn=Object.getOwnPropertyDescriptors;var _t=Object.getOwnPropertySymbols;var rn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var et=(n,e,t)=>e in n?ln(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,He=(n,e)=>{for(var t in e||(e={}))rn.call(e,t)&&et(n,t,e[t]);if(_t)for(var t of _t(e))on.call(e,t)&&et(n,t,e[t]);return n},Ze=(n,e)=>nn(n,sn(e));var Q=(n,e,t)=>et(n,typeof e!="symbol"?e+"":e,t);var j=(n,e,t)=>new Promise((l,s)=>{var i=f=>{try{o(t.next(f))}catch(a){s(a)}},r=f=>{try{o(t.throw(f))}catch(a){s(a)}},o=f=>f.done?l(f.value):Promise.resolve(f.value).then(i,r);o((t=t.apply(n,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ol=require("sv-print");class cl{constructor(e){Q(this,"host");Q(this,"tokenGetter");Q(this,"onUnauthorizedCb");Q(this,"adapter");this.host=(e.host||"").replace(/\/+$/,""),this.adapter=e.requestAdapter}setTokenGetter(e){this.tokenGetter=e}setOnUnauthorized(e){this.onUnauthorizedCb=e}notifyUnauthorized(){var e;try{(e=this.onUnauthorizedCb)==null||e.call(this)}catch(t){}}apiUrl(e){if(/^https?:\/\//i.test(e))return e;const t=e.startsWith("/")?e:`/${e}`;return`${this.host}/api${t}`}absUrl(e){return/^https?:\/\//i.test(e)?e:`${this.host}${e.startsWith("/")?e:`/${e}`}`}buildUrl(e,t){let l=this.apiUrl(e);if(t){const s=new URLSearchParams;Object.keys(t).forEach(r=>{const o=t[r];o==null||o===""||(Array.isArray(o)?o.forEach(f=>s.append(r,String(f))):s.append(r,String(o)))});const i=s.toString();i&&(l+=(l.includes("?")?"&":"?")+i)}return l}buildHeaders(e,t=!0){var s;const l=He({"Content-Type":"application/json"},e||{});if(t){const i=(s=this.tokenGetter)==null?void 0:s.call(this);i&&(l.Authorization=`Bearer ${i}`)}return l}request(s,i){return j(this,arguments,function*(e,t,l={}){const r=this.buildUrl(t,l.params),o=this.buildHeaders(l.headers,l.auth!==!1);if(this.adapter){const a=yield this.adapter({url:r,method:e.toUpperCase(),headers:o,body:l.body});return this.unwrap(a)}const f=yield fetch(r,{method:e.toUpperCase(),headers:o,body:l.body===void 0?void 0:JSON.stringify(l.body)});return this.parseResponse(f)})}parseResponse(e){return j(this,null,function*(){const t=yield e.text();let l;try{l=t?JSON.parse(t):void 0}catch(s){l=void 0}if(!e.ok){e.status===401&&this.notifyUnauthorized();const s=(l==null?void 0:l.msg)||(l==null?void 0:l.message)||`HTTP ${e.status}`;throw new Error(s)}if(l!==void 0)return this.unwrap(l)})}unwrap(e){if(e&&typeof e=="object"&&"code"in e){if(!(e.code===1||e.isOk===!0))throw(e.code===401||e.statusCode===401)&&this.notifyUnauthorized(),new Error(e.msg||e.message||"请求失败");return e.data!==void 0?e.data:e}return e}get(e,t){return this.request("GET",e,t)}post(e,t){return this.request("POST",e,t)}patch(e,t){return this.request("PATCH",e,t)}del(e,t){return this.request("DELETE",e,t)}}const al="sv-print-oauth",ul="sv_print_cloud_auth",fl=`${ul}_active`,cn="sv_print_cloud_oauth_state_",an="sv_print_cloud_oauth_code_";function dl(n,e){var f;let t;try{t=new URL(n,((f=globalThis.location)==null?void 0:f.origin)||"http://localhost")}catch(a){return null}const l=t.hash.replace(/^#\/?/,""),s=a=>t.searchParams.get(a)||new URLSearchParams(l).get(a),i=s("state")||void 0;if(e&&i&&i!==e)return null;const r=s("error")||s("error_description");if(r)return{state:i,error:r};const o=s("code");return o?{state:i,code:o}:null}function rt(n){return`${an}${n}`}function un(n){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(rt(n)))||null}catch(t){return null}}function fn(n){var e;try{(e=globalThis.localStorage)==null||e.removeItem(rt(n))}catch(t){}}function _l(){var l,s;const n=dl(((l=globalThis.location)==null?void 0:l.href)||"");if(!(n!=null&&n.code))return!1;const e=globalThis.opener;if(!e)return!1;const t=n.state||"";try{(s=globalThis.localStorage)==null||s.setItem(rt(t),n.code)}catch(i){}try{e.postMessage({type:al,code:n.code,state:t},"*")}catch(i){}try{history.replaceState(null,"",globalThis.location.pathname+globalThis.location.hash)}catch(i){}try{globalThis.close()}catch(i){}return!0}class pl{constructor(e){Q(this,"id","oauth");Q(this,"label","授权登录");Q(this,"autoLogin");this.oauth=e}canLogin(){var e,t;return!!((e=this.oauth)!=null&&e.clientId&&((t=this.oauth)!=null&&t.authorizeOrigin))}get stateKey(){var e;return`${cn}${((e=this.oauth)==null?void 0:e.clientId)||"default"}`}redirectUri(){var e,t;return((e=this.oauth)==null?void 0:e.redirectUri)||((t=globalThis.location)==null?void 0:t.origin)||""}scopeStr(){var t;const e=(t=this.oauth)==null?void 0:t.scope;return e?Array.isArray(e)?e.join(","):e:""}randomState(){const e=globalThis.crypto;return e!=null&&e.randomUUID?e.randomUUID():`svp-${Date.now()}-${Math.random().toString(36).slice(2)}`}authorizeBase(){var e;return(((e=this.oauth)==null?void 0:e.authorizeOrigin)||"").replace(/\/+$/,"")}isAbsoluteAuthorize(){return/^https?:\/\//i.test(this.authorizeBase())}expectedMessageOrigin(){var t;const e=this.authorizeBase();if(!this.isAbsoluteAuthorize())return((t=globalThis.location)==null?void 0:t.origin)||"";try{return new URL(e).origin}catch(l){return e}}buildAuthorizeUrl(e){var s;const t=new URLSearchParams({client_id:((s=this.oauth)==null?void 0:s.clientId)||"",redirect_uri:this.redirectUri(),state:e}),l=this.scopeStr();return l&&t.set("scope",l),`${this.authorizeBase()}/oauth/authorize?${t.toString()}`}parseMessage(e,t){const l=this.expectedMessageOrigin();if(l&&e.origin!==l)return null;const s=e.data;return!s||s.type!==al||s.state!==t?null:{code:s.code,error:s.error}}waitInIframe(e,t){return new Promise((l,s)=>{let i=!1,r=null;const o=document.createElement("div");o.className="svp-cloud-oauth-overlay",o.innerHTML=`
2
+ <div class="svp-cloud-oauth-box">
3
+ <div class="svp-cloud-oauth-head">
4
+ <span>登录 sv-print-cloud</span>
5
+ <button type="button" class="svp-cloud-oauth-close" aria-label="关闭">×</button>
6
+ </div>
7
+ <iframe class="svp-cloud-oauth-frame" allow="clipboard-write"></iframe>
8
+ </div>`;const f=o.querySelector("iframe");f.src=e;const a=o.querySelector(".svp-cloud-oauth-close"),_=()=>{window.removeEventListener("message",m),r&&clearTimeout(r),o.remove()},h=p=>{i||(i=!0,_(),p())},m=p=>{const q=this.parseMessage(p,t);q&&(q.error?h(()=>s(new Error(`授权被拒绝:${q.error}`))):q.code&&h(()=>l(q.code)))};a.onclick=()=>h(()=>s(new Error("已取消授权"))),o.onclick=p=>{p.target===o&&h(()=>s(new Error("已取消授权")))},window.addEventListener("message",m),r=setTimeout(()=>h(()=>s(new Error("授权超时,请重试"))),5*60*1e3),document.body.appendChild(o)})}waitInWindow(e,t,l){return new Promise((s,i)=>{const r=`svp-cloud-oauth-${this.id}`,o=l?window.open(e,r,l):window.open(e,r);if(!o){i(new Error("授权窗口被浏览器拦截,请允许弹窗后重试"));return}let f=!1,a=null,_=null;const h=()=>{window.removeEventListener("message",p),a&&clearTimeout(a),_&&clearInterval(_),fn(t)},m=q=>{if(!f){f=!0,h();try{o.close()}catch(S){}q()}},p=q=>{const S=this.parseMessage(q,t);S&&(S.error?m(()=>i(new Error(`授权被拒绝:${S.error}`))):S.code&&m(()=>s(S.code)))};window.addEventListener("message",p),_=setInterval(()=>{const q=un(t);if(q){m(()=>s(q));return}try{const S=dl(o.location.href,t);if(S!=null&&S.error){m(()=>i(new Error(`授权被拒绝:${S.error}`)));return}if(S!=null&&S.code){m(()=>s(S.code));return}}catch(S){}o.closed&&m(()=>i(new Error("已取消授权")))},300),a=setTimeout(()=>m(()=>i(new Error("授权超时,请重试"))),5*60*1e3)})}waitForCode(e){var s,i;const t=this.buildAuthorizeUrl(e),l=((s=this.oauth)==null?void 0:s.mode)||"iframe";if(l==="custom"){const r=(i=this.oauth)==null?void 0:i.authorize;return r?Promise.resolve(r(t,e)).then(o=>{if(!o)throw new Error("自定义授权未返回 code");return o}):Promise.reject(new Error("mode=custom 需配置 authorize 回调"))}return l==="popup"?this.waitInWindow(t,e,"width=520,height=720,menubar=no,toolbar=no,location=yes,status=no,resizable=yes,scrollbars=yes"):l==="page"?this.waitInWindow(t,e,""):this.waitInIframe(t,e)}exchangeToken(e,t,l){return j(this,null,function*(){var i,r,o;if((i=this.oauth)!=null&&i.exchangeToken)return this.oauth.exchangeToken(t,l);const s=(r=this.oauth)==null?void 0:r.clientSecret;if(!s)throw new Error("未配置 clientSecret 或 exchangeToken,无法换取 token");return e.client.post("/auth/member/oauth/token",{auth:!1,body:{code:t,client_id:(o=this.oauth)==null?void 0:o.clientId,client_secret:s}})})}login(e){return j(this,null,function*(){var s;if(!this.canLogin())throw new Error("未配置 OAuth(缺少 clientId 或 authorizeOrigin)");const t=this.randomState();try{(s=globalThis.sessionStorage)==null||s.setItem(this.stateKey,t)}catch(i){}const l=yield this.waitForCode(t);return this.exchangeToken(e,l,t)})}logout(e){return j(this,null,function*(){try{yield e.client.post("/auth/member/oauth/revoke",{auth:!0})}catch(t){}})}getUser(e){return j(this,null,function*(){var l;const t=((l=this.oauth)==null?void 0:l.getProfileUrl)||"/auth/member/profile";return e.client.get(t,{auth:!0})})}getClientInfo(e){return j(this,null,function*(){var t;return(t=this.oauth)!=null&&t.clientId?e.client.get(`/auth/member/oauth/client/${this.oauth.clientId}`,{auth:!1}):null})}}class hl{constructor(e){Q(this,"id","token");Q(this,"label","访问令牌");Q(this,"token");this.token=e.token}canLogin(){return!0}init(e){var l;const t=(l=this.token)==null?void 0:l.trim();t&&e.emit({accessToken:t})}login(){return j(this,null,function*(){var t;const e=(t=this.token)==null?void 0:t.trim();if(!e)throw new Error("请先填写访问令牌");return{accessToken:e}})}renderLogin(e,t){e.innerHTML=`
9
+ <div class="svp-cloud-auth-form">
10
+ <p class="svp-cloud-auth-hint">粘贴访问令牌(accessToken),保存后立即生效。</p>
11
+ <textarea class="svp-cloud-auth-input svp-cloud-auth-textarea" rows="3" placeholder="accessToken"></textarea>
12
+ <div class="svp-cloud-auth-error"></div>
13
+ <div class="svp-cloud-auth-actions">
14
+ <button type="button" class="svp-btn svp-btn-primary svp-btn-sm svp-cloud-auth-submit">保存并登录</button>
15
+ </div>
16
+ </div>`;const l=e.querySelector("textarea"),s=e.querySelector(".svp-cloud-auth-error"),i=e.querySelector(".svp-cloud-auth-submit");this.token&&(l.value=this.token),i.onclick=()=>{const r=l.value.trim();if(!r){s.textContent="请输入访问令牌";return}s.textContent="",this.token=r,t.emit({accessToken:r})}}destroyLogin(e){e.innerHTML=""}}class ml{constructor(e){Q(this,"id","host");Q(this,"label","宿主托管");Q(this,"getUser");Q(this,"getClientInfo");this.cfg=e,e.getUser&&(this.getUser=()=>e.getUser()),e.getClientInfo&&(this.getClientInfo=()=>e.getClientInfo())}canLogin(){var e;return typeof((e=this.cfg)==null?void 0:e.getToken)=="function"}init(e){return j(this,null,function*(){try{const t=yield this.cfg.getToken();t!=null&&t.accessToken&&e.emit(t)}catch(t){}})}login(){return j(this,null,function*(){const e=yield this.cfg.getToken();if(!(e!=null&&e.accessToken))throw new Error("宿主未返回有效令牌");return e})}logout(){return j(this,null,function*(){var e,t;yield(t=(e=this.cfg).logout)==null?void 0:t.call(e)})}}class vl{constructor(e){Q(this,"id","local");Q(this,"label","本地账号");Q(this,"getUser");this.cfg=e,e.getUser&&(this.getUser=()=>e.getUser())}canLogin(){var e;return typeof((e=this.cfg)==null?void 0:e.login)=="function"}login(){return j(this,null,function*(){throw new Error("请在设置面板的账户中登录")})}logout(){return j(this,null,function*(){var e,t;yield(t=(e=this.cfg).logout)==null?void 0:t.call(e)})}renderLogin(e,t){const l=this.cfg.title||"账号登录";e.innerHTML=`
17
+ <div class="svp-cloud-auth-form">
18
+ <p class="svp-cloud-auth-hint">${l}</p>
19
+ <input class="svp-cloud-auth-input svp-cloud-auth-user" type="text" autocomplete="username" placeholder="账号" />
20
+ <input class="svp-cloud-auth-input svp-cloud-auth-pass" type="password" autocomplete="current-password" placeholder="密码" />
21
+ <div class="svp-cloud-auth-error"></div>
22
+ <div class="svp-cloud-auth-actions">
23
+ <button type="button" class="svp-btn svp-btn-primary svp-btn-sm svp-cloud-auth-submit">登录</button>
24
+ </div>
25
+ </div>`;const s=e.querySelector(".svp-cloud-auth-user"),i=e.querySelector(".svp-cloud-auth-pass"),r=e.querySelector(".svp-cloud-auth-error"),o=e.querySelector(".svp-cloud-auth-submit");o&&(o.onclick=()=>j(this,null,function*(){const f=s.value.trim(),a=i.value;if(!f||!a){r.textContent="请输入账号与密码";return}r.textContent="",o.disabled=!0;const _=o.textContent;o.textContent="登录中...";try{const h=yield this.cfg.login(f,a);if(!(h!=null&&h.accessToken))throw new Error("登录返回的凭据无效");t.emit(h)}catch(h){r.textContent=(h==null?void 0:h.message)||"登录失败"}finally{o.disabled=!1,o.textContent=_}}))}destroyLogin(e){e.innerHTML=""}}class ot{constructor(){Q(this,"id","none");Q(this,"label","未配置")}canLogin(){return!1}login(){return j(this,null,function*(){throw new Error("未配置登录方式")})}}function bl(n){if(!n)return[];const e=Array.isArray(n)?n:[n],t=new Set,l=[];for(const s of e){const i=s==null?void 0:s.type;if(i){if(t.has(i)){console.warn(`[cloud] 重复的登录方式已忽略:${i}`);continue}t.add(i),l.push(s)}}return l}function gl(n,e=!1){let t;switch(n.type){case"oauth":t=new pl(n);break;case"token":t=new hl(n);break;case"host":t=new ml(n);break;case"local":t=new vl(n);break;default:return new ot}return e&&n.type!=="local"&&(t.autoLogin=!0),t}function kl(n){return`${ul}_${n||"default"}`}function yl(){return wl(fl,null)||null}function $e(n){Tl(fl,n)}function wl(n,e){var l;const t=globalThis;return(l=t.SVPrint)!=null&&l.getPreferences?t.SVPrint.getPreferences(n,e):ol.getPreferences(n,e)}function Tl(n,e){var l;const t=globalThis;if((l=t.SVPrint)!=null&&l.setPreferences){t.SVPrint.setPreferences(n,e);return}ol.setPreferences(n,e)}class dn{constructor(e){this.key=e}get(){return wl(this.key,null)||null}set(e){Tl(this.key,e)}}class _n{constructor(e){this.key=e}get(){var e;try{const t=(e=globalThis.sessionStorage)==null?void 0:e.getItem(this.key);return t?JSON.parse(t):null}catch(t){return null}}set(e){var t,l;try{e?(t=globalThis.sessionStorage)==null||t.setItem(this.key,JSON.stringify(e)):(l=globalThis.sessionStorage)==null||l.removeItem(this.key)}catch(s){}}}class pn{constructor(){Q(this,"token",null)}get(){return this.token}set(e){this.token=e}}function ql(n){return new dn(n)}function hn(n){return new _n(n)}function mn(){return new pn}function ct(n,e,t=!1){return n.storageKey?t?`${n.storageKey}_${e}`:n.storageKey:kl(e)}function Cl(n,e,t=!1){return n.storage?n.storage:ql(ct(n,e,t))}class Sl{constructor(e,t){Q(this,"client");Q(this,"config");Q(this,"entries",[]);Q(this,"storages",new Map);Q(this,"active");Q(this,"multi");Q(this,"token",null);Q(this,"listeners",[]);Q(this,"loginEl");this.config=e,this.client=t,this.entries=bl(e.auth).map(s=>({cfg:s,provider:gl(s,!!e.autoLogin)})),this.entries.length||(this.entries=[{cfg:null,provider:new ot}]),this.multi=this.entries.length>1,this.active=this.pickInitial(),this.token=this.storageOf(this.active).get(),this.client.setTokenGetter(()=>{var s;return((s=this.token)==null?void 0:s.accessToken)||null}),this.client.setOnUnauthorized(()=>this.onUnauthorized());const l=_l();this.runInit(!l)}pickInitial(){const e=yl(),t=e?this.entries.find(r=>r.provider.id===e):void 0;if(t)return t;const l=this.config.defaultAuth?this.entries.find(r=>r.provider.id===this.config.defaultAuth):void 0;if(l)return $e(l.provider.id),l;const i=this.entries.find(r=>{var o;return(o=this.storageOf(r).get())==null?void 0:o.accessToken})||this.entries[0];return $e(i.provider.id),i}storageOf(e){const t=e.provider.id;let l=this.storages.get(t);return l||(l=Cl(this.config,t,this.multi),this.storages.set(t,l)),l}ctx(){return{client:this.client,config:this.config,storage:this.storageOf(this.active),emit:e=>this.writeToken(e)}}runInit(e=!1){var t,l;try{const s=(l=(t=this.active.provider).init)==null?void 0:l.call(t,this.ctx());s&&typeof s.then=="function"&&s.catch(()=>{})}catch(s){}e&&this.maybeAutoLogin()}maybeAutoLogin(){this.active.provider.autoLogin&&(this.isLoggedIn()||!this.canLogin()||this.login().catch(e=>console.warn("[cloud] 自动登录失败:",(e==null?void 0:e.message)||e)))}writeToken(e){this.token=e,this.storageOf(this.active).set(e),this.notify()}notify(){this.listeners.forEach(e=>e(this.token))}onUnauthorized(){this.token&&this.writeToken(null)}get type(){return this.active.provider.id}get label(){return this.active.provider.label}get activeId(){return this.active.provider.id}get providers(){return this.entries.map(e=>({id:e.provider.id,label:e.provider.label,canLogin:e.provider.canLogin()}))}get providerConfig(){return this.active.cfg}get storageKey(){return ct(this.config,this.active.provider.id,this.multi)}get hasCustomLoginUI(){return typeof this.active.provider.renderLogin=="function"}renderLogin(e){var t,l;this.loginEl=e,(l=(t=this.active.provider).renderLogin)==null||l.call(t,e,this.ctx())}destroyLogin(e){var t,l;(l=(t=this.active.provider).destroyLogin)==null||l.call(t,e),this.loginEl===e&&(this.loginEl=void 0)}switchProvider(e){return j(this,null,function*(){var l,s;const t=this.entries.find(i=>i.provider.id===e);if(!(!t||t===this.active)){if(this.loginEl)try{(s=(l=this.active.provider).destroyLogin)==null||s.call(l,this.loginEl)}catch(i){}this.active=t,$e(e),this.token=this.storageOf(t).get(),this.notify(),this.runInit()}})}canLogin(){return this.active.provider.canLogin()}isLoggedIn(){var e;return!!((e=this.token)!=null&&e.accessToken)}getToken(){var e;return((e=this.token)==null?void 0:e.accessToken)||null}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}login(){return j(this,null,function*(){if(!this.canLogin())throw new Error("未配置登录方式");const e=yield this.active.provider.login(this.ctx());if(!(e!=null&&e.accessToken))throw new Error("登录返回的凭据无效");return this.writeToken(e),e})}logout(){return j(this,null,function*(){var e,t;try{yield(t=(e=this.active.provider).logout)==null?void 0:t.call(e,this.ctx())}catch(l){}this.writeToken(null)})}getUser(){return j(this,null,function*(){const e=this.active.provider.getUser;return e?e(this.ctx()):this.client.get(this.profileUrl(),{auth:!0})})}getClientInfo(){return j(this,null,function*(){const e=this.active.provider.getClientInfo;if(e)return e(this.ctx());const t=this.clientId();return t?this.client.get(`/auth/member/oauth/client/${t}`,{auth:!1}):null})}oauthCfg(){const e=this.active.cfg;return e&&e.type==="oauth"?e:null}profileUrl(){var e;return((e=this.oauthCfg())==null?void 0:e.getProfileUrl)||"/auth/member/profile"}clientId(){var e;return(e=this.oauthCfg())==null?void 0:e.clientId}}const vn="/api/socket.io",pt="/socket.io";class Pl{constructor(e){Q(this,"host");Q(this,"socket",null);Q(this,"ticket",null);Q(this,"handlers",new Map);this.host=(e.host||"").replace(/\/+$/,"")}getIo(){const e=globalThis.io;if(!e)throw new Error("未检测到 socket.io(window.io),无法连接中转服务");return e}resolveBase(){var t;const e=((t=globalThis.location)==null?void 0:t.origin)||"";if(!this.host)return{origin:e,path:vn};if(/^https?:\/\//i.test(this.host)){const l=new URL(this.host);return{origin:l.origin,path:`${l.pathname.replace(/\/+$/,"")}${pt}`}}return{origin:e,path:`${this.host.replace(/\/+$/,"")}${pt}`}}ensureNetworkPermission(){return j(this,null,function*(){try{const e=globalThis.hiwebSocket;if(e!=null&&e.requestNetworkPermission){const t=yield e.requestNetworkPermission();if(t&&t.granted===!1)throw new Error(t.msg||"本地网络访问权限被拒绝")}}catch(e){if(e!=null&&e.message)throw e}})}attachHandlers(e){for(const[t,l]of this.handlers)for(const s of l)e.on(t,s)}on(e,t){var l,s;this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t),(s=(l=this.socket)==null?void 0:l.on)==null||s.call(l,e,t)}off(e,t){var l,s,i,r,o;t?((l=this.handlers.get(e))==null||l.delete(t),(i=(s=this.socket)==null?void 0:s.off)==null||i.call(s,e,t)):(this.handlers.delete(e),(o=(r=this.socket)==null?void 0:r.off)==null||o.call(r,e))}waitFor(e,t=15e3){return new Promise((l,s)=>{const i=o=>{clearTimeout(r),this.off(e,i),l(o)},r=setTimeout(()=>{this.off(e,i),s(new Error(`等待中转事件 ${e} 超时`))},t);this.on(e,i)})}emit(e,t={}){var l;return(l=this.socket)!=null&&l.connected?(this.socket.emit(e,t),!0):!1}connect(e){return j(this,null,function*(){var r;if((r=this.socket)!=null&&r.connected)return this.socket;yield this.ensureNetworkPermission();const t=this.getIo(),l=(e.namespace||"/transit").startsWith("/")?e.namespace||"/transit":`/${e.namespace}`,{origin:s,path:i}=this.resolveBase();return this.ticket=e,new Promise((o,f)=>{const a=t(`${s}${l}`,{auth:{token:e.ticket,clientType:"web"},path:i,transports:["websocket","polling"],reconnection:!0}),_=setTimeout(()=>{var p,q;(p=a.off)==null||p.call(a,"connect",h),(q=a.off)==null||q.call(a,"connect_error",m),f(new Error("连接中转服务超时"))},1e4),h=()=>{clearTimeout(_),this.socket=a,this.attachHandlers(a),o(a)},m=p=>{var q;clearTimeout(_),(q=a.close)==null||q.call(a),f(new Error((p==null?void 0:p.message)||"连接中转服务失败"))};a.on("connect",h),a.on("connect_error",m)})})}getClients(e=8e3){return j(this,null,function*(){const t=this.waitFor("clients",e);if(!this.emit("getClients",{}))throw new Error("中转服务未连接");const l=yield t;return Array.isArray(l)?l:l&&typeof l=="object"?Object.values(l):[]})}getPrinters(e,t=6e3){return j(this,null,function*(){if(e){const i=this.waitFor("printerList",t).catch(()=>null);this.emit("refreshPrinterList",{client:e});const r=yield i;if(Array.isArray(r)&&r.length)return r}const l=yield this.getClients(),s=e?l.find(i=>i.clientId===e):l.find(i=>i.clientType==="electron");return(s==null?void 0:s.printerList)||[]})}print(e,t=6e4){return j(this,null,function*(){var s;if(!(e!=null&&e.client))throw new Error("缺少目标客户端 client");if(!((s=this.socket)!=null&&s.connected))throw new Error("中转服务未连接");const l=new Promise((i,r)=>{const o=_=>{this.off("error",f),clearTimeout(a),i(_||{})},f=_=>{this.off("success",o),clearTimeout(a),r(new Error((_==null?void 0:_.msg)||"客户端打印失败"))},a=setTimeout(()=>{this.off("success",o),this.off("error",f),r(new Error("等待打印回执超时"))},t);this.on("success",o),this.on("error",f)});return this.socket.emit("print",e),l})}isConnected(){var e;return!!((e=this.socket)!=null&&e.connected)}disconnect(){var e,t,l,s;try{(t=(e=this.socket)==null?void 0:e.removeAllListeners)==null||t.call(e),(s=(l=this.socket)==null?void 0:l.disconnect)==null||s.call(l)}catch(i){}this.socket=null,this.ticket=null}}class El{constructor(e,t,l,s){Q(this,"client");Q(this,"transit");Q(this,"auth");Q(this,"config");this.config=e,this.client=t,this.transit=l,this.auth=s}requireLogin(){var e;if(!((e=this.auth)!=null&&e.canLogin()))throw new Error("未配置登录方式");if(!this.auth.isLoggedIn())throw new Error("请先登录后再使用模板")}render(){return j(this,arguments,function*(e={}){var s,i,r,o;const t=this.du(),l={template:(r=e.template)!=null?r:(i=(s=t==null?void 0:t.printTemplate)==null?void 0:s.getJson)==null?void 0:i.call(s),print_data:(o=e.print_data)!=null?o:t==null?void 0:t.printData,options:e.options,renderer_id:e.renderer_id,type:e.type};return e.template_id!==void 0&&(delete l.template,l.template_id=e.template_id),this.client.post(e.sync?"/print/render/sync":"/print/render",{body:l})})}getRenderTask(e){return this.client.get(`/print/render/tasks/${e}`)}waitRender(l){return j(this,arguments,function*(e,t={}){var o,f;const s=(o=t.interval)!=null?o:1500,i=(f=t.timeout)!=null?f:6e4,r=Date.now();for(;;){const a=yield this.getRenderTask(e),_=Number(a.status);if(_===2)return a;if(_===3||_===4||_===5)throw new Error(a.error_message||`渲染失败(status=${_})`);if(Date.now()-r>i)throw new Error("渲染超时");yield new Promise(h=>setTimeout(h,s))}})}cloudPrint(e){var s,i,r,o;const t=this.du(),l={device_id:e.device_id,template_id:e.template_id,template_data:(r=e.template_data)!=null?r:(i=(s=t==null?void 0:t.printTemplate)==null?void 0:s.getJson)==null?void 0:i.call(s),preview_data:(o=e.preview_data)!=null?o:t==null?void 0:t.printData,print_type:e.print_type,print_options:e.print_options,remark:e.remark};return this.client.post("/member/cloud/print/submit",{body:l})}getDevices(){return this.client.get("/member/cloud/device")}getJobs(e){return this.client.get("/member/cloud/print/jobs",{params:e})}cancelJob(e){return this.client.post(`/member/cloud/print/jobs/${e}/cancel`)}retryJob(e){return this.client.post(`/member/cloud/print/jobs/${e}/retry`)}getTransitTicket(){return this.client.post("/member/transit/ticket",{body:{}})}ensureTransitConnected(){return j(this,null,function*(){if(!this.transit.isConnected()){const e=yield this.getTransitTicket();yield this.transit.connect(e)}return this.transit})}getTransitClients(){return j(this,null,function*(){return(yield this.ensureTransitConnected()).getClients()})}getTransitPrinters(e){return j(this,null,function*(){return(yield this.ensureTransitConnected()).getPrinters(e)})}transitPrint(){return j(this,arguments,function*(e={}){var o,f,a,_,h;if(!e.clientId)throw new Error("请选择目标中转客户端");if(!e.printer)throw new Error("请选择打印机");const t=yield this.ensureTransitConnected(),l=this.du(),s=(a=e.template)!=null?a:(f=(o=l==null?void 0:l.printTemplate)==null?void 0:o.getJson)==null?void 0:f.call(o),i=typeof s=="string"?s:JSON.stringify(s!=null?s:null),r=typeof e.print_options=="string"?e.print_options:e.print_options?JSON.stringify(e.print_options):void 0;return t.print({client:e.clientId,template:i,printer:e.printer,template_snapshot:i,preview_data:(h=(_=e.preview_data)!=null?_:l==null?void 0:l.printData)!=null?h:null,print_type:e.print_type||"template",print_options:r})})}disconnectTransit(){this.transit.disconnect()}listTemplates(e={}){var t,l,s;return this.client.get("/print/template",{auth:!1,params:{keyword:e.keyword,category_id:e.category_id,industry_id:e.industry_id,template_type:e.template_type,is_free:e.is_free,is_recommend:e.is_recommend,page:(t=e.page)!=null?t:1,pageSize:(s=(l=e.pageSize)!=null?l:this.config.templateCenterPageSize)!=null?s:12}})}getTemplateData(e){return this.client.get(`/print/template/${e}/data`)}applyTemplate(e){return j(this,null,function*(){var r,o;this.requireLogin();const t=yield this.getTemplateData(e.template_id),l=this.parseMaybeJson((r=t==null?void 0:t.template_data)!=null?r:t),s=this.parseMaybeJson(t==null?void 0:t.preview_data),i=this.du();if(!((o=i==null?void 0:i.printTemplate)!=null&&o.update))throw new Error("设计器未就绪");return i.printTemplate.update(l),s!=null&&(i.printData=s),this.useTemplate(e.template_id).catch(()=>{}),{template_data:l,preview_data:s}})}useRandomTemplate(){return j(this,arguments,function*(e={}){var _;this.requireLogin();const t=(_=e.pageSize)!=null?_:20,l=yield this.listTemplates(Ze(He({},e),{page:1,pageSize:t})),s=l.total||0;if(!s&&!(l.list||[]).length)throw new Error("没有可用模板");const i=Math.max(1,Math.ceil(s/t)),r=Math.floor(Math.random()*i)+1,f=((r===1?l:yield this.listTemplates(Ze(He({},e),{page:r,pageSize:t}))).list||[]).slice();for(let h=f.length-1;h>0;h--){const m=Math.floor(Math.random()*(h+1));[f[h],f[m]]=[f[m],f[h]]}let a=null;for(const h of f.slice(0,5))try{return yield this.applyTemplate(h),h}catch(m){a=m}throw a||new Error("没有可用模板")})}parseMaybeJson(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}useTemplate(e){return this.client.post(`/print/template/use/${e}`)}getCategories(){return this.client.get("/print/category",{auth:!1})}getIndustries(){return this.client.get("/print/industry",{auth:!1})}du(){return globalThis.__cloudDesignerUtils}}function at(n,e){!n||n.__cloudExtended||(n.serverRender=function(t={}){var l,s;return e.render(Ze(He({},t),{template:(s=t.template)!=null?s:(l=n.getJson)==null?void 0:l.call(n)}))},n.cloudPrint=function(t){return e.cloudPrint(He({},t))},n.transitPrint=function(t={}){return e.transitPrint(t)},n.restoreCloud=function(){delete n.serverRender,delete n.cloudPrint,delete n.transitPrint,delete n.restoreCloud,delete n.__cloudExtended},n.__cloudExtended=!0)}const ht="cloud-template-center";function bn(n,e,t){const l=e.templateCenter||{};if(l.enable===!1)return;const s=n==null?void 0:n.header;if(!(s!=null&&s.updateMenuList))return;const i={cloudMenu:ht,icon:l.icon||"sv-templates",title:l.menuTitle||"模板中心",click:()=>t()};s.updateMenuList(r=>{var a;if(r.some(_=>_&&_.cloudMenu===ht))return;const o=(a=l.menuOrder)!=null?a:0,f=o<0?Math.max(0,r.length+1+o):Math.min(o,r.length);r.splice(f,0,i)})}let Ve;function gn(n){Ve=n,typeof globalThis!="undefined"&&(globalThis.__cloudDesignerUtils=n)}function mt(){return Ve||(typeof globalThis!="undefined"&&globalThis.__cloudDesignerUtils&&(Ve=globalThis.__cloudDesignerUtils),Ve)}let Il;function kn(n){Il=n}function Ll(){return Il}const yn=n=>({hook:"onDesigned",name:"cloudOnDesigned",description:"云打印插件 - 挂载模板中心/API/菜单",priority:1,run:({designerUtils:e})=>{const t=globalThis,l=new cl(n),s=new Sl(n,l),i=new Pl(n),r=new El(n,l,i,s);gn(e),kn({config:n,client:l,auth:s,transit:i,service:r}),setTimeout(()=>{const o=t.$("#SVPrint");if(!o||!o.length){console.warn("[cloud] #SVPrint not found");return}Promise.resolve().then(()=>Xn).then(({default:f})=>{var m;let a=null;try{a=new f({target:o[0],props:{auth:s,service:r,designerUtils:e,pageSize:(m=n.templateCenterPageSize)!=null?m:12}})}catch(p){console.error("[cloud] template center mount error:",p)}const h={render:p=>r.render(p),getRenderTask:p=>r.getRenderTask(p),cloudPrint:p=>r.cloudPrint(p),getDevices:()=>r.getDevices(),getJobs:p=>r.getJobs(p),cancelJob:p=>r.cancelJob(p),retryJob:p=>r.retryJob(p),transitPrint:p=>r.transitPrint(p),getTransitClients:()=>r.getTransitClients(),getTransitPrinters:p=>r.getTransitPrinters(p),applyTemplate:p=>r.applyTemplate(p),useRandomTemplate:p=>r.useRandomTemplate(p),templateCenter:{show:()=>{var p;return(p=a==null?void 0:a.show)==null?void 0:p.call(a)},hide:()=>{var p;return(p=a==null?void 0:a.hide)==null?void 0:p.call(a)},toggle:()=>{var p;return(p=a==null?void 0:a.toggle)==null?void 0:p.call(a)},isOpen:()=>{var p;return!!((p=a==null?void 0:a.isOpen)!=null&&p.call(a))},list:p=>r.listTemplates(p)},auth:{type:s.type,label:s.label,providers:s.providers,activeId:s.activeId,switchProvider:p=>s.switchProvider(p),canLogin:()=>s.canLogin(),isLoggedIn:()=>s.isLoggedIn(),getToken:()=>s.getToken(),login:()=>s.login(),logout:()=>s.logout(),getUser:()=>s.getUser(),getClientInfo:()=>s.getClientInfo(),onChange:p=>s.onChange(p)},config:n};e.cloud=h,bn(e,n,()=>{var p;return(p=a==null?void 0:a.show)==null?void 0:p.call(a)}),e.printTemplate&&at(e.printTemplate,r)}).catch(f=>{console.error("[cloud] component init error:",f)})},200)}}),tt=new WeakMap,wn=n=>({hook:"onSettings",name:"cloudOnSettings",description:"云打印插件 - 设置面板 tab",priority:1,run:e=>{if((e==null?void 0:e.type)==="tabs"&&n.enableSettingsTab!==!1)return{key:"cloud",label:"云打印",icon:"sv-cloud",sort:n.settingsTabSort||2,render:t=>{const l=Ll();if(!l){t.innerHTML='<div class="settings-empty">云打印插件未初始化</div>';return}Promise.resolve().then(()=>Vs).then(({default:s})=>{const i=new s({target:t,props:{config:l.config,auth:l.auth,service:l.service}});tt.set(t,i)})},destroy:t=>{var s;const l=tt.get(t);(s=l==null?void 0:l.$destroy)==null||s.call(l),tt.delete(t)}}}}),Tn=()=>({hook:"newPrintTemplate",name:"cloudNewPrintTemplate",description:"云打印插件 - 模板扩展",priority:1,run:({template:n})=>{const e=Ll();!e||!n||at(n,e.service)}});function qn(n={}){return{name:"cloud",description:"sv-print plugin: cloud",hooks:[yn(n),wn(n),Tn()],leastHiprintVersion:"0.3.42"}}function ie(){}function Ml(n){return n()}function vt(){return Object.create(null)}function ke(n){n.forEach(Ml)}function Al(n){return typeof n=="function"}let xe;function qe(n,e){return xe||(xe=document.createElement("a")),xe.href=e,n===xe.href}function ut(n,e){return n!=n?e==e:n!==e}function Cn(n){return Object.keys(n).length===0}function Ce(n){return n==null?"":n}function c(n,e){n.appendChild(e)}function g(n,e,t){n.insertBefore(e,t||null)}function b(n){n.parentNode&&n.parentNode.removeChild(n)}function d(n){return document.createElement(n)}function O(n){return document.createTextNode(n)}function w(){return O(" ")}function Ae(){return O("")}function Y(n,e,t,l){return n.addEventListener(e,t,l),()=>n.removeEventListener(e,t,l)}function u(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Sn(n){let e;return{p(...t){e=t,e.forEach(l=>n.push(l))},r(){e.forEach(t=>n.splice(n.indexOf(t),1))}}}function Pn(n){return Array.from(n.childNodes)}function F(n,e){e=""+e,n.data!==e&&(n.data=e)}function je(n,e){n.value=e==null?"":e}function we(n,e,t,l){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}function Be(n,e,t){for(let l=0;l<n.options.length;l+=1){const s=n.options[l];if(s.__value===e){s.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function lt(n){const e=n.querySelector(":checked");return e&&e.__value}function Le(n,e,t){n.classList[t?"add":"remove"](e)}let Ye;function We(n){Ye=n}function En(){if(!Ye)throw new Error("Function called outside component initialization");return Ye}function In(n){En().$$.on_mount.push(n)}const Re=[],st=[];let Ke=[];const bt=[],Ln=Promise.resolve();let it=!1;function Mn(){it||(it=!0,Ln.then(Ol))}function Fe(n){Ke.push(n)}const nt=new Set;let Je=0;function Ol(){if(Je!==0)return;const n=Ye;do{try{for(;Je<Re.length;){const e=Re[Je];Je++,We(e),An(e.$$)}}catch(e){throw Re.length=0,Je=0,e}for(We(null),Re.length=0,Je=0;st.length;)st.pop()();for(let e=0;e<Ke.length;e+=1){const t=Ke[e];nt.has(t)||(nt.add(t),t())}Ke.length=0}while(Re.length);for(;bt.length;)bt.pop()();it=!1,nt.clear(),We(n)}function An(n){if(n.fragment!==null){n.update(),ke(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Fe)}}function On(n){const e=[],t=[];Ke.forEach(l=>n.indexOf(l)===-1?e.push(l):t.push(l)),t.forEach(l=>l()),Ke=e}const zn=new Set;function zl(n,e){n&&n.i&&(zn.delete(n),n.i(e))}function Se(n,e){n.d(1),e.delete(n.key)}function Pe(n,e,t,l,s,i,r,o,f,a,_,h){let m=n.length,p=i.length,q=m;const S={};for(;q--;)S[n[q].key]=q;const y=[],k=new Map,v=new Map,E=[];for(q=p;q--;){const C=h(s,i,q),M=t(C);let L=r.get(M);L?E.push(()=>L.p(C,e)):(L=a(M,C),L.c()),k.set(M,y[q]=L),M in S&&v.set(M,Math.abs(q-S[M]))}const N=new Set,D=new Set;function J(C){zl(C,1),C.m(o,_),r.set(C.key,C),_=C.first,p--}for(;m&&p;){const C=y[p-1],M=n[m-1],L=C.key,A=M.key;C===M?(_=C.first,m--,p--):k.has(A)?!r.has(L)||N.has(L)?J(C):D.has(A)?m--:v.get(L)>v.get(A)?(D.add(L),J(C)):(N.add(A),m--):(f(M,r),m--)}for(;m--;){const C=n[m];k.has(C.key)||f(C,r)}for(;p;)J(y[p-1]);return ke(E),y}function Un(n,e,t,l){const{fragment:s,after_update:i}=n.$$;s&&s.m(e,t),l||Fe(()=>{const r=n.$$.on_mount.map(Ml).filter(Al);n.$$.on_destroy?n.$$.on_destroy.push(...r):ke(r),n.$$.on_mount=[]}),i.forEach(Fe)}function Nn(n,e){const t=n.$$;t.fragment!==null&&(On(t.after_update),ke(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Dn(n,e){n.$$.dirty[0]===-1&&(Re.push(n),Mn(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Ul(n,e,t,l,s,i,r,o=[-1]){const f=Ye;We(n);const a=n.$$={fragment:null,ctx:[],props:i,update:ie,not_equal:s,bound:vt(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:vt(),dirty:o,skip_bound:!1,root:e.target||(f?f.$$.root:null)};let _=!1;if(a.ctx=t?t(n,e.props||{},(h,m,...p)=>{const q=p.length?p[0]:m;return a.ctx&&s(a.ctx[h],a.ctx[h]=q)&&(!a.skip_bound&&a.bound[h]&&a.bound[h](q),_&&Dn(n,h)),m}):[],a.update(),_=!0,ke(a.before_update),a.fragment=l?l(a.ctx):!1,e.target){if(e.hydrate){const h=Pn(e.target);a.fragment&&a.fragment.l(h),h.forEach(b)}else a.fragment&&a.fragment.c();e.intro&&zl(n.$$.fragment),Un(n,e.target,e.anchor,e.customElement),Ol()}We(f)}class Nl{$destroy(){Nn(this,1),this.$destroy=ie}$on(e,t){if(!Al(t))return ie;const l=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return l.push(t),()=>{const s=l.indexOf(t);s!==-1&&l.splice(s,1)}}$set(e){this.$$set&&!Cn(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function gt(n,e,t){const l=n.slice();return l[46]=e[t],l}function kt(n,e,t){const l=n.slice();return l[49]=e[t],l}function yt(n,e,t){const l=n.slice();return l[52]=e[t],l}function wt(n){let e,t,l;return{c(){e=d("button"),e.textContent="×",u(e,"class","tc-search-clear svelte-1qg2qyu"),u(e,"aria-label","清空搜索")},m(s,i){g(s,e,i),t||(l=Y(e,"click",n[17]),t=!0)},p:ie,d(s){s&&b(e),t=!1,l()}}}function Tt(n,e){let t,l=e[52].industry_name+"",s,i,r;function o(){return e[33](e[52])}return{key:n,first:null,c(){t=d("button"),s=O(l),u(t,"class","tc-chip svelte-1qg2qyu"),Le(t,"active",e[2]===e[52].industry_id),this.first=t},m(f,a){g(f,t,a),c(t,s),i||(r=Y(t,"click",o),i=!0)},p(f,a){e=f,a[0]&2048&&l!==(l=e[52].industry_name+"")&&F(s,l),a[0]&2052&&Le(t,"active",e[2]===e[52].industry_id)},d(f){f&&b(t),i=!1,r()}}}function qt(n,e){let t,l=e[49].category_name+"",s,i,r;function o(){return e[35](e[49])}return{key:n,first:null,c(){t=d("button"),s=O(l),u(t,"class","tc-chip svelte-1qg2qyu"),Le(t,"active",e[10]===e[49].category_id),this.first=t},m(f,a){g(f,t,a),c(t,s),i||(r=Y(t,"click",o),i=!0)},p(f,a){e=f,a[0]&8192&&l!==(l=e[49].category_name+"")&&F(s,l),a[0]&9216&&Le(t,"active",e[10]===e[49].category_id)},d(f){f&&b(t),i=!1,r()}}}function Hn(n){let e;return{c(){e=d("div"),e.textContent="暂无模板",u(e,"class","settings-empty")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Jn(n){let e;return{c(){e=d("div"),e.textContent="加载中...",u(e,"class","settings-empty")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Rn(n){let e,t;return{c(){e=d("div"),t=O(n[6]),u(e,"class","settings-empty")},m(l,s){g(l,e,s),c(e,t)},p(l,s){s[0]&64&&F(t,l[6])},d(l){l&&b(e)}}}function Kn(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-preview"></i>',u(e,"class","tc-noimg svelte-1qg2qyu")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function jn(n){let e,t,l;return{c(){e=d("img"),qe(e.src,t=n[46].preview_img)||u(e,"src",t),u(e,"alt",l=n[46].template_name),u(e,"loading","lazy"),u(e,"class","svelte-1qg2qyu")},m(s,i){g(s,e,i)},p(s,i){i[0]&128&&!qe(e.src,t=s[46].preview_img)&&u(e,"src",t),i[0]&128&&l!==(l=s[46].template_name)&&u(e,"alt",l)},d(s){s&&b(e)}}}function Ct(n){let e;return{c(){e=d("span"),e.textContent="查看大图",u(e,"class","tc-zoom svelte-1qg2qyu")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function Bn(n){var i;let e,t=((i=n[46].price)!=null?i:0)+"",l,s;return{c(){e=d("span"),l=O(t),s=O(" 积分"),u(e,"class","tc-tag paid svelte-1qg2qyu")},m(r,o){g(r,e,o),c(e,l),c(e,s)},p(r,o){var f;o[0]&128&&t!==(t=((f=r[46].price)!=null?f:0)+"")&&F(l,t)},d(r){r&&b(e)}}}function Fn(n){let e;return{c(){e=d("span"),e.textContent="免费",u(e,"class","tc-tag svelte-1qg2qyu")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function St(n){let e;return{c(){e=d("span"),e.textContent="推荐",u(e,"class","tc-tag rec svelte-1qg2qyu")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function Pt(n){let e,t=n[46].industry_name+"",l;return{c(){e=d("span"),l=O(t),u(e,"class","tc-tag plain svelte-1qg2qyu")},m(s,i){g(s,e,i),c(e,l)},p(s,i){i[0]&128&&t!==(t=s[46].industry_name+"")&&F(l,t)},d(s){s&&b(e)}}}function Et(n){let e,t=n[46].category_name+"",l;return{c(){e=d("span"),l=O(t),u(e,"class","tc-tag plain svelte-1qg2qyu")},m(s,i){g(s,e,i),c(e,l)},p(s,i){i[0]&128&&t!==(t=s[46].category_name+"")&&F(l,t)},d(s){s&&b(e)}}}function It(n,e){var _e,pe;let t,l,s,i,r,o,f=e[46].template_name+"",a,_,h,m,p,q,S,y,k,v,E,N,D=((_e=e[46].use_cnt)!=null?_e:0)+"",J,C,M,L,A=((pe=e[46].share_cnt)!=null?pe:0)+"",U,P,I,H,X,G,Z;function R(ne,K){return ne[46].preview_img?jn:Kn}let B=R(e),V=B(e),te=e[46].preview_img&&Ct();function ee(){return e[36](e[46])}function Te(ne,K){return ne[46].is_free?Fn:Bn}let ae=Te(e),re=ae(e),ue=e[46].is_recommend&&St(),oe=e[46].industry_name&&Pt(e),le=e[46].category_name&&Et(e);function fe(){return e[37](e[46])}return{key:n,first:null,c(){t=d("div"),l=d("div"),V.c(),s=w(),te&&te.c(),i=w(),r=d("div"),o=d("div"),a=O(f),h=w(),m=d("div"),re.c(),p=w(),ue&&ue.c(),q=w(),oe&&oe.c(),S=w(),le&&le.c(),y=w(),k=d("div"),v=d("div"),E=d("span"),N=O("使用 "),J=O(D),C=w(),M=d("span"),L=O("分享 "),U=O(A),P=w(),I=d("button"),H=O("去使用"),X=w(),u(l,"class","tc-thumb svelte-1qg2qyu"),u(o,"class","tc-name svelte-1qg2qyu"),u(o,"title",_=e[46].template_name),u(m,"class","tc-tags svelte-1qg2qyu"),u(r,"class","tc-meta svelte-1qg2qyu"),u(E,"title","使用量"),u(M,"title","分享量"),u(v,"class","tc-stats svelte-1qg2qyu"),u(I,"class","svp-btn svp-btn-xs svp-btn-primary tc-use svelte-1qg2qyu"),I.disabled=e[5],u(k,"class","tc-actions svelte-1qg2qyu"),u(t,"class","tc-card svelte-1qg2qyu"),this.first=t},m(ne,K){g(ne,t,K),c(t,l),V.m(l,null),c(l,s),te&&te.m(l,null),c(t,i),c(t,r),c(r,o),c(o,a),c(r,h),c(r,m),re.m(m,null),c(m,p),ue&&ue.m(m,null),c(m,q),oe&&oe.m(m,null),c(m,S),le&&le.m(m,null),c(t,y),c(t,k),c(k,v),c(v,E),c(E,N),c(E,J),c(v,C),c(v,M),c(M,L),c(M,U),c(k,P),c(k,I),c(I,H),c(t,X),G||(Z=[Y(l,"click",ee),Y(I,"click",fe)],G=!0)},p(ne,K){var de,$;e=ne,B===(B=R(e))&&V?V.p(e,K):(V.d(1),V=B(e),V&&(V.c(),V.m(l,s))),e[46].preview_img?te||(te=Ct(),te.c(),te.m(l,null)):te&&(te.d(1),te=null),K[0]&128&&f!==(f=e[46].template_name+"")&&F(a,f),K[0]&128&&_!==(_=e[46].template_name)&&u(o,"title",_),ae===(ae=Te(e))&&re?re.p(e,K):(re.d(1),re=ae(e),re&&(re.c(),re.m(m,p))),e[46].is_recommend?ue||(ue=St(),ue.c(),ue.m(m,q)):ue&&(ue.d(1),ue=null),e[46].industry_name?oe?oe.p(e,K):(oe=Pt(e),oe.c(),oe.m(m,S)):oe&&(oe.d(1),oe=null),e[46].category_name?le?le.p(e,K):(le=Et(e),le.c(),le.m(m,null)):le&&(le.d(1),le=null),K[0]&128&&D!==(D=((de=e[46].use_cnt)!=null?de:0)+"")&&F(J,D),K[0]&128&&A!==(A=(($=e[46].share_cnt)!=null?$:0)+"")&&F(U,A),K[0]&32&&(I.disabled=e[5])},d(ne){ne&&b(t),V.d(),te&&te.d(),re.d(),ue&&ue.d(),oe&&oe.d(),le&&le.d(),G=!1,ke(Z)}}}function Lt(n){let e,t,l,s,i,r,o;return{c(){e=d("div"),t=d("img"),s=w(),i=d("button"),i.innerHTML='<i class="svicon sv-close"></i>',qe(t.src,l=n[12])||u(t,"src",l),u(t,"alt","模板预览"),u(t,"class","svelte-1qg2qyu"),u(i,"class","svp-cloud-tc-preview-close svelte-1qg2qyu"),u(i,"aria-label","关闭"),u(e,"class","svp-cloud-tc-preview svelte-1qg2qyu")},m(f,a){g(f,e,a),c(e,t),c(e,s),c(e,i),r||(o=[Y(i,"click",n[40]),Y(e,"click",n[41])],r=!0)},p(f,a){a[0]&4096&&!qe(t.src,l=f[12])&&u(t,"src",l)},d(f){f&&b(e),r=!1,ke(o)}}}function Gn(n){let e,t,l,s,i,r,o,f,a,_,h,m,p,q,S,y,k,v=[],E=new Map,N,D,J,C,M,L,A=[],U=new Map,P,I,H,X,G=[],Z=new Map,R,B,V,te,ee,Te,ae,re,ue,oe,le,fe,_e,pe,ne,K,de,$,ye,ve,Oe,Me,be=n[9]&&wt(n),ze=n[11];const Ue=z=>z[52].industry_id;for(let z=0;z<ze.length;z+=1){let W=yt(n,ze,z),se=Ue(W);E.set(se,v[z]=Tt(se,W))}let Ne=n[13];const Ge=z=>z[49].category_id;for(let z=0;z<Ne.length;z+=1){let W=kt(n,Ne,z),se=Ge(W);U.set(se,A[z]=qt(se,W))}function De(z,W){if(z[6])return Rn;if(z[4]&&z[7].length===0)return Jn;if(z[7].length===0)return Hn}let Ie=De(n),ge=Ie&&Ie(n),Ee=n[7];const Xe=z=>z[46].template_id;for(let z=0;z<Ee.length;z+=1){let W=gt(n,Ee,z),se=Xe(W);Z.set(se,G[z]=It(se,W))}let he=n[12]&&Lt(n);return{c(){e=d("div"),t=d("div"),l=d("div"),s=d("div"),s.textContent="模板中心",i=w(),r=d("div"),o=d("input"),f=w(),be&&be.c(),a=w(),_=d("button"),_.innerHTML='<i class="svicon sv-close"></i>',h=w(),m=d("div"),p=d("div"),q=d("span"),q.textContent="行业",S=w(),y=d("button"),y.textContent="全部",k=w();for(let z=0;z<v.length;z+=1)v[z].c();N=w(),D=d("div"),J=d("span"),J.textContent="分类",C=w(),M=d("button"),M.textContent="全部",L=w();for(let z=0;z<A.length;z+=1)A[z].c();P=w(),I=d("div"),ge&&ge.c(),H=w(),X=d("div");for(let z=0;z<G.length;z+=1)G[z].c();R=w(),B=d("div"),V=d("button"),te=O("上一页"),Te=w(),ae=d("span"),re=O(n[8]),ue=O(" / "),oe=O(n[14]),le=O("(共 "),fe=O(n[1]),_e=O(")"),pe=w(),ne=d("button"),K=O("下一页"),ye=w(),he&&he.c(),ve=Ae(),u(s,"class","svp-cloud-tc-title svelte-1qg2qyu"),u(o,"class","svp-input svp-cloud-tc-search svelte-1qg2qyu"),u(o,"placeholder","搜索模板名称"),u(r,"class","tc-search-wrap svelte-1qg2qyu"),u(_,"class","svp-btn svp-btn-xs svp-btn-outline"),u(_,"aria-label","关闭"),u(l,"class","svp-cloud-tc-head svelte-1qg2qyu"),u(q,"class","tc-filter-label svelte-1qg2qyu"),u(y,"class","tc-chip svelte-1qg2qyu"),Le(y,"active",n[2]===""),u(p,"class","tc-filter svelte-1qg2qyu"),u(J,"class","tc-filter-label svelte-1qg2qyu"),u(M,"class","tc-chip svelte-1qg2qyu"),Le(M,"active",n[10]===""),u(D,"class","tc-filter svelte-1qg2qyu"),u(m,"class","svp-cloud-tc-filters svelte-1qg2qyu"),u(X,"class","svp-cloud-tc-grid svelte-1qg2qyu"),u(I,"class","svp-cloud-tc-body svelte-1qg2qyu"),u(V,"class","svp-btn svp-btn-xs svp-btn-outline"),V.disabled=ee=n[8]<=1||n[4],u(ae,"class","tc-page svelte-1qg2qyu"),u(ne,"class","svp-btn svp-btn-xs svp-btn-outline"),ne.disabled=de=n[8]>=n[14]||n[4],u(B,"class","svp-cloud-tc-foot svelte-1qg2qyu"),u(t,"class","svp-modal-box svp-cloud-tc-box svelte-1qg2qyu"),u(t,"role","dialog"),u(t,"aria-modal","true"),u(e,"class",$=Ce(`svp-modal svp-cloud-tc ${n[3]?"svp-modal-open modal-open":""}`)+" svelte-1qg2qyu")},m(z,W){g(z,e,W),c(e,t),c(t,l),c(l,s),c(l,i),c(l,r),c(r,o),je(o,n[9]),c(r,f),be&&be.m(r,null),c(l,a),c(l,_),c(t,h),c(t,m),c(m,p),c(p,q),c(p,S),c(p,y),c(p,k);for(let se=0;se<v.length;se+=1)v[se]&&v[se].m(p,null);c(m,N),c(m,D),c(D,J),c(D,C),c(D,M),c(D,L);for(let se=0;se<A.length;se+=1)A[se]&&A[se].m(D,null);c(t,P),c(t,I),ge&&ge.m(I,null),c(I,H),c(I,X);for(let se=0;se<G.length;se+=1)G[se]&&G[se].m(X,null);c(t,R),c(t,B),c(B,V),c(V,te),c(B,Te),c(B,ae),c(ae,re),c(ae,ue),c(ae,oe),c(ae,le),c(ae,fe),c(ae,_e),c(B,pe),c(B,ne),c(ne,K),g(z,ye,W),he&&he.m(z,W),g(z,ve,W),Oe||(Me=[Y(o,"input",n[31]),Y(o,"input",n[16]),Y(_,"click",n[0]),Y(y,"click",n[32]),Y(M,"click",n[34]),Y(V,"click",n[38]),Y(ne,"click",n[39]),Y(t,"click",Vn),Y(e,"click",n[22])],Oe=!0)},p(z,W){W[0]&512&&o.value!==z[9]&&je(o,z[9]),z[9]?be?be.p(z,W):(be=wt(z),be.c(),be.m(r,null)):be&&(be.d(1),be=null),W[0]&4&&Le(y,"active",z[2]===""),W[0]&526340&&(ze=z[11],v=Pe(v,W,Ue,1,z,ze,E,p,Se,Tt,null,yt)),W[0]&1024&&Le(M,"active",z[10]===""),W[0]&271360&&(Ne=z[13],A=Pe(A,W,Ge,1,z,Ne,U,D,Se,qt,null,kt)),Ie===(Ie=De(z))&&ge?ge.p(z,W):(ge&&ge.d(1),ge=Ie&&Ie(z),ge&&(ge.c(),ge.m(I,H))),W[0]&3145888&&(Ee=z[7],G=Pe(G,W,Xe,1,z,Ee,Z,X,Se,It,null,gt)),W[0]&272&&ee!==(ee=z[8]<=1||z[4])&&(V.disabled=ee),W[0]&256&&F(re,z[8]),W[0]&16384&&F(oe,z[14]),W[0]&2&&F(fe,z[1]),W[0]&16656&&de!==(de=z[8]>=z[14]||z[4])&&(ne.disabled=de),W[0]&8&&$!==($=Ce(`svp-modal svp-cloud-tc ${z[3]?"svp-modal-open modal-open":""}`)+" svelte-1qg2qyu")&&u(e,"class",$),z[12]?he?he.p(z,W):(he=Lt(z),he.c(),he.m(ve.parentNode,ve)):he&&(he.d(1),he=null)},i:ie,o:ie,d(z){z&&b(e),be&&be.d();for(let W=0;W<v.length;W+=1)v[W].d();for(let W=0;W<A.length;W+=1)A[W].d();ge&&ge.d();for(let W=0;W<G.length;W+=1)G[W].d();z&&b(ye),he&&he.d(z),z&&b(ve),Oe=!1,ke(Me)}}}function Vn(n){n.stopPropagation()}function Wn(n,e,t){let l,s,{auth:i}=e,{service:r}=e,{designerUtils:o}=e,{pageSize:f=12}=e,a=!1,_=!1,h=!1,m="",p=[],q=0,S=1,y="",k="",v="",E=[],N=[],D="",J=!1,C=null;function M(){t(3,a=!0),J||P(),I(1)}function L(){t(3,a=!1),t(12,D="")}function A(){a?L():M()}function U(){return a}function P(){return j(this,null,function*(){J=!0;try{const[K,de]=yield Promise.all([r.getCategories().catch(()=>[]),r.getIndustries().catch(()=>[])]);t(30,E=K||[]),t(11,N=de||[])}catch(K){}})}function I(K=1){return j(this,null,function*(){var de;t(4,_=!0),t(6,m="");try{const $=yield r.listTemplates({keyword:y,category_id:k===""?void 0:k,industry_id:v===""?void 0:v,page:K,pageSize:f}),ye=($==null?void 0:$.list)||($==null?void 0:$.items)||(Array.isArray($)?$:[]);t(7,p=ye),t(1,q=(de=$==null?void 0:$.total)!=null?de:ye.length),t(8,S=K)}catch($){t(6,m=($==null?void 0:$.message)||"加载模板失败"),t(7,p=[]),t(1,q=0)}finally{t(4,_=!1)}})}function H(){clearTimeout(C),C=setTimeout(()=>I(1),350)}function X(){t(9,y=""),I(1)}function G(K){t(10,k=k===K?"":K),I(1)}function Z(K){v!==K&&t(10,k=""),t(2,v=v===K?"":K),I(1)}function R(K){K.preview_img&&t(12,D=K.preview_img)}function B(){return j(this,null,function*(){var K;return i.isLoggedIn()?!0:((K=o==null?void 0:o.showModal)==null||K.call(o,{title:"需要登录",content:"使用模板中心模板需要先登录 sv-print 账号。",showCancel:!0,submitText:"去登录",submit:()=>j(this,null,function*(){var de;try{yield i.login(),yield I(S)}catch($){(de=o==null?void 0:o.showToast)==null||de.call(o,($==null?void 0:$.message)||"登录失败",{type:"error"})}})}),!1)})}function V(K){return j(this,null,function*(){var de;(yield B())&&((de=o==null?void 0:o.showModal)==null||de.call(o,{title:"使用模板",content:`确定使用「${K.template_name}」?将覆盖当前设计内容与打印数据。`,submitText:"覆盖使用",submit:()=>j(this,null,function*(){var $,ye;t(5,h=!0);try{yield r.applyTemplate(K),($=o==null?void 0:o.showToast)==null||$.call(o,"模板已应用",{type:"success"}),L()}catch(ve){(ye=o==null?void 0:o.showToast)==null||ye.call(o,(ve==null?void 0:ve.message)||"模板应用失败",{type:"error"})}finally{t(5,h=!1)}})}))})}function te(){L()}function ee(){y=this.value,t(9,y)}const Te=()=>{t(2,v=""),I(1)},ae=K=>Z(K.industry_id),re=()=>{t(10,k=""),I(1)},ue=K=>G(K.category_id),oe=K=>R(K),le=K=>V(K),fe=()=>I(S-1),_e=()=>I(S+1),pe=()=>t(12,D=""),ne=()=>t(12,D="");return n.$$set=K=>{"auth"in K&&t(23,i=K.auth),"service"in K&&t(24,r=K.service),"designerUtils"in K&&t(25,o=K.designerUtils),"pageSize"in K&&t(26,f=K.pageSize)},n.$$.update=()=>{n.$$.dirty[0]&67108866&&t(14,l=Math.max(1,Math.ceil(q/f))),n.$$.dirty[0]&1073741828&&t(13,s=v===""?E:E.filter(K=>K.industry_id==null||K.industry_id===v))},[L,q,v,a,_,h,m,p,S,y,k,N,D,s,l,I,H,X,G,Z,R,V,te,i,r,o,f,M,A,U,E,ee,Te,ae,re,ue,oe,le,fe,_e,pe,ne]}class Yn extends Nl{constructor(e){super(),Ul(this,e,Wn,Gn,ut,{auth:23,service:24,designerUtils:25,pageSize:26,show:27,hide:0,toggle:28,isOpen:29},null,[-1,-1])}get show(){return this.$$.ctx[27]}get hide(){return this.$$.ctx[0]}get toggle(){return this.$$.ctx[28]}get isOpen(){return this.$$.ctx[29]}}const Xn=Object.freeze(Object.defineProperty({__proto__:null,default:Yn},Symbol.toStringTag,{value:"Module"}));function Mt(n,e,t){const l=n.slice();return l[88]=e[t],l}function At(n,e,t){const l=n.slice();return l[102]=e[t],l}function Ot(n,e,t){const l=n.slice();return l[94]=e[t],l}function zt(n,e,t){const l=n.slice();return l[97]=e[t],l}function Ut(n,e,t){const l=n.slice();return l[91]=e[t],l}function Nt(n,e,t){const l=n.slice();return l[88]=e[t],l}function Dt(n,e,t){const l=n.slice();return l[105]=e[t],l}function Ht(n,e){let t,l,s,i=e[105].label+"",r,o,f,a,_;function h(){return e[63](e[105])}return{key:n,first:null,c(){t=d("button"),l=d("i"),s=w(),r=O(i),o=w(),u(l,"class","svicon "+e[105].icon+" svelte-qx44lr"),u(t,"class",f=Ce(`cloud-nav-item ${e[6]===e[105].key?"cloud-nav-active":""}`)+" svelte-qx44lr"),this.first=t},m(m,p){g(m,t,p),c(t,l),c(t,s),c(t,r),c(t,o),a||(_=Y(t,"click",h),a=!0)},p(m,p){e=m,p[0]&64&&f!==(f=Ce(`cloud-nav-item ${e[6]===e[105].key?"cloud-nav-active":""}`)+" svelte-qx44lr")&&u(t,"class",f)},d(m){m&&b(t),a=!1,_()}}}function Qn(n){let e,t,l,s,i,r,o=(n[0].host||"/api")+"",f,a,_,h,m,p,q,S,y,k,v,E,N,D,J,C=n[5]&&Jt(n);return{c(){e=d("div"),t=d("div"),t.textContent="连接配置",l=w(),s=d("div"),i=d("span"),i.textContent="服务端 host",r=d("code"),f=O(o),a=w(),_=d("span"),_.textContent="登录方式",h=d("code"),m=O(n[38]),p=O("("),q=O(n[2]),S=O(")"),y=w(),k=d("span"),k.textContent="存储 key",v=d("code"),E=O(n[37]),N=w(),C&&C.c(),D=w(),J=d("div"),J.textContent="以上为插件初始化时的只读配置;实际使用时请通过插件设置修改。",u(t,"class","settings-subtitle"),u(i,"class","svelte-qx44lr"),u(r,"class","svelte-qx44lr"),u(_,"class","svelte-qx44lr"),u(h,"class","svelte-qx44lr"),u(k,"class","svelte-qx44lr"),u(v,"class","svelte-qx44lr"),u(s,"class","cloud-kv svelte-qx44lr"),u(J,"class","settings-hint"),u(e,"class","settings-section")},m(M,L){g(M,e,L),c(e,t),c(e,l),c(e,s),c(s,i),c(s,r),c(r,f),c(s,a),c(s,_),c(s,h),c(h,m),c(h,p),c(h,q),c(h,S),c(s,y),c(s,k),c(s,v),c(v,E),c(s,N),C&&C.m(s,null),c(e,D),c(e,J)},p(M,L){L[0]&1&&o!==(o=(M[0].host||"/api")+"")&&F(f,o),L[1]&128&&F(m,M[38]),L[0]&4&&F(q,M[2]),L[1]&64&&F(E,M[37]),M[5]?C?C.p(M,L):(C=Jt(M),C.c(),C.m(s,null)):C&&(C.d(1),C=null)},d(M){M&&b(e),C&&C.d()}}}function Zn(n){let e,t,l,s,i,r=n[29]?"已连接":"未连接",o,f,a,_,h,m,p;function q(v,E){return v[29]?ns:ls}let S=q(n),y=S(n),k=n[29]&&Rt(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="中转打印",s=w(),i=d("span"),o=O(r),a=w(),_=d("p"),_.textContent=`通过短期 ticket
26
+ 直连中转服务(socket.io),打印指令实时送达本地客户端,不产生云打印任务记录。`,h=w(),m=d("div"),y.c(),p=w(),k&&k.c(),u(l,"class","settings-subtitle"),we(l,"margin","0"),u(i,"class",f=Ce(`svp-badge svp-badge-sm ${n[29]?"badge-on":""}`)+" svelte-qx44lr"),u(t,"class","svp-flex-row svp-justify-between"),we(t,"margin-bottom","10px"),u(_,"class","settings-hint"),u(m,"class","form-actions"),u(e,"class","settings-section")},m(v,E){g(v,e,E),c(e,t),c(t,l),c(t,s),c(t,i),c(i,o),c(e,a),c(e,_),c(e,h),c(e,m),y.m(m,null),c(e,p),k&&k.m(e,null)},p(v,E){E[0]&536870912&&r!==(r=v[29]?"已连接":"未连接")&&F(o,r),E[0]&536870912&&f!==(f=Ce(`svp-badge svp-badge-sm ${v[29]?"badge-on":""}`)+" svelte-qx44lr")&&u(i,"class",f),S===(S=q(v))&&y?y.p(v,E):(y.d(1),y=S(v),y&&(y.c(),y.m(m,null))),v[29]?k?k.p(v,E):(k=Rt(v),k.c(),k.m(e,null)):k&&(k.d(1),k=null)},d(v){v&&b(e),y.d(),k&&k.d()}}}function xn(n){let e,t,l,s,i,r,o,f,a,_,h,m,p,q,S,y,k,v,E,N,D,J,C,M,L;function A(G,Z){return G[20].length===0?fs:us}let U=A(n),P=U(n);function I(G,Z){return G[23]?ps:G[22].length===0?_s:ds}let H=I(n),X=H(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="云设备",s=w(),i=d("button"),r=d("i"),o=O(" 刷新"),f=w(),P.c(),a=w(),_=d("div"),h=d("button"),m=d("i"),p=O(" 下发云打印"),q=w(),S=d("div"),y=w(),k=d("div"),v=d("div"),v.textContent="打印任务",E=w(),N=d("button"),D=d("i"),J=O(" 刷新"),C=w(),X.c(),u(l,"class","settings-subtitle"),we(l,"margin","0"),u(r,"class","svicon sv-refresh"),u(i,"class","svp-btn svp-btn-ghost svp-btn-xs"),i.disabled=n[10],u(t,"class","svp-flex-row svp-justify-between"),we(t,"margin-bottom","10px"),u(m,"class","svicon sv-print"),u(h,"class","svp-btn svp-btn-primary svp-btn-sm"),h.disabled=n[10],u(_,"class","form-actions"),u(S,"class","settings-divider"),u(v,"class","settings-subtitle"),we(v,"margin","0"),u(D,"class","svicon sv-refresh"),u(N,"class","svp-btn svp-btn-ghost svp-btn-xs"),N.disabled=n[23],u(k,"class","svp-flex-row svp-justify-between"),we(k,"margin-bottom","10px"),u(e,"class","settings-section")},m(G,Z){g(G,e,Z),c(e,t),c(t,l),c(t,s),c(t,i),c(i,r),c(i,o),c(e,f),P.m(e,null),c(e,a),c(e,_),c(_,h),c(h,m),c(h,p),c(e,q),c(e,S),c(e,y),c(e,k),c(k,v),c(k,E),c(k,N),c(N,D),c(N,J),c(e,C),X.m(e,null),M||(L=[Y(i,"click",n[50]),Y(h,"click",n[52]),Y(N,"click",n[51])],M=!0)},p(G,Z){Z[0]&1024&&(i.disabled=G[10]),U===(U=A(G))&&P?P.p(G,Z):(P.d(1),P=U(G),P&&(P.c(),P.m(e,a))),Z[0]&1024&&(h.disabled=G[10]),Z[0]&8388608&&(N.disabled=G[23]),H===(H=I(G))&&X?X.p(G,Z):(X.d(1),X=H(G),X&&(X.c(),X.m(e,null)))},d(G){G&&b(e),P.d(),X.d(),M=!1,ke(L)}}}function $n(n){let e,t,l,s,i,r,o,f,a,_,h,m,p,q,S,y,k,v,E,N,D,J,C;function M(I,H){return I[10]?ms:hs}let L=M(n),A=L(n),U=n[19]&&Gt(),P=n[4]&&Vt(n);return{c(){e=d("div"),t=d("div"),t.textContent="服务端渲染",l=w(),s=d("p"),s.textContent="使用当前设计器模板与打印数据提交服务端渲染。",i=w(),r=d("div"),o=d("label"),o.textContent="输出类型",f=w(),a=d("select"),_=d("option"),_.textContent="pdf",h=d("option"),h.textContent="img",m=d("option"),m.textContent="html",p=w(),q=d("label"),S=d("input"),y=O(`
27
+ 同步返回`),k=w(),v=d("div"),E=d("button"),A.c(),N=w(),U&&U.c(),D=w(),P&&P.c(),u(t,"class","settings-subtitle"),u(s,"class","settings-hint"),u(o,"class","form-label"),_.__value="pdf",_.value=_.__value,h.__value="img",h.value=h.__value,m.__value="html",m.value=m.__value,u(a,"class","svp-select svp-select-sm"),n[17]===void 0&&Fe(()=>n[70].call(a)),u(r,"class","form-row"),u(S,"type","checkbox"),u(S,"class","svp-checkbox svp-checkbox-sm svp-checkbox-primary"),u(q,"class","cloud-checkbox-label svelte-qx44lr"),u(E,"class","svp-btn svp-btn-primary svp-btn-sm"),E.disabled=n[10],u(v,"class","form-actions"),u(e,"class","settings-section")},m(I,H){g(I,e,H),c(e,t),c(e,l),c(e,s),c(e,i),c(e,r),c(r,o),c(r,f),c(r,a),c(a,_),c(a,h),c(a,m),Be(a,n[17],!0),c(e,p),c(e,q),c(q,S),S.checked=n[18],c(q,y),c(e,k),c(e,v),c(v,E),A.m(E,null),c(e,N),U&&U.m(e,null),c(e,D),P&&P.m(e,null),J||(C=[Y(a,"change",n[70]),Y(S,"change",n[71]),Y(E,"click",n[49])],J=!0)},p(I,H){H[0]&131072&&Be(a,I[17]),H[0]&262144&&(S.checked=I[18]),L!==(L=M(I))&&(A.d(1),A=L(I),A&&(A.c(),A.m(E,null))),H[0]&1024&&(E.disabled=I[10]),I[19]?U||(U=Gt(),U.c(),U.m(e,D)):U&&(U.d(1),U=null),I[4]?P?P.p(I,H):(P=Vt(I),P.c(),P.m(e,null)):P&&(P.d(1),P=null)},d(I){I&&b(e),A.d(),U&&U.d(),P&&P.d(),J=!1,ke(C)}}}function es(n){let e,t,l,s,i,r,o,f,a,_,h,m,p,q,S,y,k,v,E,N,D,J;function C(A,U){return A[16]?Cs:A[15].length===0?qs:Ts}let M=C(n),L=M(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="模板中心",s=w(),i=d("button"),r=d("i"),o=O(" 随机使用模板"),_=w(),h=d("p"),h.textContent="一键更新当前设计器的模板 JSON 与打印数据(需登录)。列表浏览免登录。",m=w(),p=d("div"),q=d("input"),S=w(),y=d("button"),k=O("搜索"),v=w(),E=d("button"),E.textContent="弹窗浏览",N=w(),L.c(),u(l,"class","settings-subtitle"),we(l,"margin","0"),u(r,"class","svicon sv-refresh"),u(i,"class","svp-btn svp-btn-primary svp-btn-xs"),i.disabled=f=n[10]||!n[7],u(i,"title",a=n[7]?"随机取一个模板并覆盖当前设计内容与打印数据":"请先登录"),u(t,"class","svp-flex-row svp-justify-between"),we(t,"margin-bottom","10px"),u(h,"class","settings-hint"),u(q,"class","svp-input svp-input-sm svp-w-full"),u(q,"placeholder","搜索模板名称"),u(y,"class","svp-btn svp-btn-outline svp-btn-sm"),y.disabled=n[16],u(E,"class","svp-btn svp-btn-ghost svp-btn-sm"),u(E,"title","打开模板中心弹窗"),u(p,"class","cloud-search-row svelte-qx44lr"),u(e,"class","settings-section")},m(A,U){g(A,e,U),c(e,t),c(t,l),c(t,s),c(t,i),c(i,r),c(i,o),c(e,_),c(e,h),c(e,m),c(e,p),c(p,q),je(q,n[14]),c(p,S),c(p,y),c(y,k),c(p,v),c(p,E),c(e,N),L.m(e,null),D||(J=[Y(i,"click",n[47]),Y(q,"input",n[66]),Y(q,"keydown",n[67]),Y(y,"click",n[46]),Y(E,"click",n[68])],D=!0)},p(A,U){U[0]&1152&&f!==(f=A[10]||!A[7])&&(i.disabled=f),U[0]&128&&a!==(a=A[7]?"随机取一个模板并覆盖当前设计内容与打印数据":"请先登录")&&u(i,"title",a),U[0]&16384&&q.value!==A[14]&&je(q,A[14]),U[0]&65536&&(y.disabled=A[16]),M===(M=C(A))&&L?L.p(A,U):(L.d(1),L=M(A),L&&(L.c(),L.m(e,null)))},d(A){A&&b(e),L.d(),D=!1,ke(J)}}}function ts(n){let e,t,l,s,i,r,o,f,a,_=n[39]&&Zt(n);function h(k,v){return k[9]?As:Ms}let m=h(n),p=m(n);function q(k,v){return k[7]?Us:k[2]==="none"?zs:Os}let S=q(n),y=S(n);return{c(){e=d("div"),t=d("div"),l=d("div"),l.textContent="账户",s=w(),i=d("span"),r=O(n[38]),o=w(),_&&_.c(),f=w(),p.c(),a=w(),y.c(),u(l,"class","settings-subtitle"),we(l,"margin","0"),u(i,"class","svp-badge svp-badge-sm"),u(t,"class","svp-flex-row svp-justify-between"),we(t,"margin-bottom","10px"),u(e,"class","settings-section")},m(k,v){g(k,e,v),c(e,t),c(t,l),c(t,s),c(t,i),c(i,r),c(e,o),_&&_.m(e,null),c(e,f),p.m(e,null),c(e,a),y.m(e,null)},p(k,v){v[1]&128&&F(r,k[38]),k[39]?_?_.p(k,v):(_=Zt(k),_.c(),_.m(e,f)):_&&(_.d(1),_=null),m===(m=h(k))&&p?p.p(k,v):(p.d(1),p=m(k),p&&(p.c(),p.m(e,a))),S===(S=q(k))&&y?y.p(k,v):(y.d(1),y=S(k),y&&(y.c(),y.m(e,null)))},d(k){k&&b(e),_&&_.d(),p.d(),y.d()}}}function Jt(n){let e,t,l=(n[5].authorizeOrigin||"未配置")+"",s,i,r,o,f,a,_,h,m=(n[5].clientId||"未配置")+"",p,q,S,y,k;return{c(){e=d("span"),e.textContent="授权页源",t=d("code"),s=O(l),i=w(),r=d("span"),r.textContent="授权方式",o=d("code"),f=O(n[34]),a=w(),_=d("span"),_.textContent="client_id",h=d("code"),p=O(m),q=w(),S=d("span"),S.textContent="scope",y=d("code"),k=O(n[35]),u(e,"class","svelte-qx44lr"),u(t,"class","svelte-qx44lr"),u(r,"class","svelte-qx44lr"),u(o,"class","svelte-qx44lr"),u(_,"class","svelte-qx44lr"),u(h,"class","svelte-qx44lr"),u(S,"class","svelte-qx44lr"),u(y,"class","svelte-qx44lr")},m(v,E){g(v,e,E),g(v,t,E),c(t,s),g(v,i,E),g(v,r,E),g(v,o,E),c(o,f),g(v,a,E),g(v,_,E),g(v,h,E),c(h,p),g(v,q,E),g(v,S,E),g(v,y,E),c(y,k)},p(v,E){E[0]&32&&l!==(l=(v[5].authorizeOrigin||"未配置")+"")&&F(s,l),E[1]&8&&F(f,v[34]),E[0]&32&&m!==(m=(v[5].clientId||"未配置")+"")&&F(p,m),E[1]&16&&F(k,v[35])},d(v){v&&b(e),v&&b(t),v&&b(i),v&&b(r),v&&b(o),v&&b(a),v&&b(_),v&&b(h),v&&b(q),v&&b(S),v&&b(y)}}}function ls(n){let e,t,l;function s(o,f){return o[10]?is:ss}let i=s(n),r=i(n);return{c(){e=d("button"),r.c(),u(e,"class","svp-btn svp-btn-primary svp-btn-sm"),e.disabled=n[10]},m(o,f){g(o,e,f),r.m(e,null),t||(l=Y(e,"click",n[55]),t=!0)},p(o,f){i!==(i=s(o))&&(r.d(1),r=i(o),r&&(r.c(),r.m(e,null))),f[0]&1024&&(e.disabled=o[10])},d(o){o&&b(e),r.d(),t=!1,l()}}}function ns(n){let e,t,l,s,i,r,o;return{c(){e=d("button"),e.textContent="断开连接",t=w(),l=d("button"),s=d("i"),i=O(" 刷新客户端"),u(e,"class","svp-btn svp-btn-ghost svp-btn-sm"),u(s,"class","svicon sv-refresh"),u(l,"class","svp-btn svp-btn-outline svp-btn-sm"),l.disabled=n[10]},m(f,a){g(f,e,a),g(f,t,a),g(f,l,a),c(l,s),c(l,i),r||(o=[Y(e,"click",n[56]),Y(l,"click",n[55])],r=!0)},p(f,a){a[0]&1024&&(l.disabled=f[10])},d(f){f&&b(e),f&&b(t),f&&b(l),r=!1,ke(o)}}}function ss(n){let e,t;return{c(){e=d("i"),t=O(" 连接中转服务"),u(e,"class","svicon sv-flow")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function is(n){let e,t;return{c(){e=d("i"),t=O(" 连接中..."),u(e,"class","svicon sv-refresh svp-spin svelte-qx44lr")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function Rt(n){let e,t,l,s,i,r,o,f,a=[],_=new Map,h,m,p,q,S,y,k,v,E,N,D,J,C,M,L;function A(R,B){return R[24].length===0?os:rs}let U=A(n),P=U(n),I=n[26];const H=R=>R[88].name||R[88].displayName;for(let R=0;R<I.length;R+=1){let B=Mt(n,I,R),V=H(B);_.set(V,a[R]=jt(V,B))}function X(R,B){return R[10]?as:cs}let G=X(n),Z=G(n);return{c(){e=d("div"),t=w(),P.c(),l=w(),s=d("div"),i=d("label"),i.textContent="打印机",r=w(),o=d("select"),f=d("option"),f.textContent="请选择打印机";for(let R=0;R<a.length;R+=1)a[R].c();h=w(),m=d("button"),p=d("i"),S=w(),y=d("div"),k=d("label"),k.textContent="打印选项",v=w(),E=d("textarea"),N=w(),D=d("div"),J=d("button"),Z.c(),u(e,"class","settings-divider"),u(i,"class","form-label"),f.__value="",f.value=f.__value,u(o,"class","svp-select svp-select-sm svp-w-full"),n[27]===void 0&&Fe(()=>n[78].call(o)),u(p,"class","svicon sv-refresh"),u(m,"class","svp-btn svp-btn-ghost svp-btn-xs"),m.disabled=q=n[10]||!n[25],u(s,"class","form-row"),u(k,"class","form-label"),u(E,"class","svp-textarea svp-w-full"),u(E,"rows","6"),u(E,"placeholder",'可选,JSON 格式,如 {"paperName":"A4","copies":1}'),u(y,"class","form-row"),u(J,"class","svp-btn svp-btn-primary svp-btn-sm"),J.disabled=C=n[10]||!n[25]||!n[27],u(D,"class","form-actions")},m(R,B){g(R,e,B),g(R,t,B),P.m(R,B),g(R,l,B),g(R,s,B),c(s,i),c(s,r),c(s,o),c(o,f);for(let V=0;V<a.length;V+=1)a[V]&&a[V].m(o,null);Be(o,n[27],!0),c(s,h),c(s,m),c(m,p),g(R,S,B),g(R,y,B),c(y,k),c(y,v),c(y,E),je(E,n[28]),g(R,N,B),g(R,D,B),c(D,J),Z.m(J,null),M||(L=[Y(o,"change",n[78]),Y(m,"click",n[79]),Y(E,"input",n[80]),Y(J,"click",n[59])],M=!0)},p(R,B){U===(U=A(R))&&P?P.p(R,B):(P.d(1),P=U(R),P&&(P.c(),P.m(l.parentNode,l))),B[0]&67108864&&(I=R[26],a=Pe(a,B,H,1,R,I,_,o,Se,jt,null,Mt)),B[0]&201326592&&Be(o,R[27]),B[0]&50332672&&q!==(q=R[10]||!R[25])&&(m.disabled=q),B[0]&268435456&&je(E,R[28]),G!==(G=X(R))&&(Z.d(1),Z=G(R),Z&&(Z.c(),Z.m(J,null))),B[0]&251659264&&C!==(C=R[10]||!R[25]||!R[27])&&(J.disabled=C)},d(R){R&&b(e),R&&b(t),P.d(R),R&&b(l),R&&b(s);for(let B=0;B<a.length;B+=1)a[B].d();R&&b(S),R&&b(y),R&&b(N),R&&b(D),Z.d(),M=!1,ke(L)}}}function rs(n){let e,t,l,s,i=[],r=new Map,o,f,a=n[24];const _=h=>h[102].clientId;for(let h=0;h<a.length;h+=1){let m=At(n,a,h),p=_(m);r.set(p,i[h]=Kt(p,m))}return{c(){e=d("div"),t=d("label"),t.textContent="客户端",l=w(),s=d("select");for(let h=0;h<i.length;h+=1)i[h].c();u(t,"class","form-label"),u(s,"class","svp-select svp-select-sm svp-w-full"),n[25]===void 0&&Fe(()=>n[76].call(s)),u(e,"class","form-row")},m(h,m){g(h,e,m),c(e,t),c(e,l),c(e,s);for(let p=0;p<i.length;p+=1)i[p]&&i[p].m(s,null);Be(s,n[25],!0),o||(f=[Y(s,"change",n[76]),Y(s,"change",n[77])],o=!0)},p(h,m){m[0]&16777216&&(a=h[24],i=Pe(i,m,_,1,h,a,r,s,Se,Kt,null,At)),m[0]&50331648&&Be(s,h[25])},d(h){h&&b(e);for(let m=0;m<i.length;m+=1)i[m].d();o=!1,ke(f)}}}function os(n){let e;return{c(){e=d("div"),e.textContent="暂无在线客户端(需桌面客户端 sv-print-client 在线)",u(e,"class","settings-empty"),we(e,"margin-bottom","10px")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Kt(n,e){let t,l=(e[102].hostname||e[102].clientId)+"",s,i=e[102].platform?` · ${e[102].platform}`:"",r,o,f;return{key:n,first:null,c(){t=d("option"),s=O(l),r=O(i),o=w(),t.__value=f=e[102].clientId,t.value=t.__value,this.first=t},m(a,_){g(a,t,_),c(t,s),c(t,r),c(t,o)},p(a,_){e=a,_[0]&16777216&&l!==(l=(e[102].hostname||e[102].clientId)+"")&&F(s,l),_[0]&16777216&&i!==(i=e[102].platform?` · ${e[102].platform}`:"")&&F(r,i),_[0]&16777216&&f!==(f=e[102].clientId)&&(t.__value=f,t.value=t.__value)},d(a){a&&b(t)}}}function jt(n,e){let t,l=(e[88].displayName||e[88].name)+"",s,i=e[88].isDefault?"(默认)":"",r,o,f;return{key:n,first:null,c(){t=d("option"),s=O(l),r=O(i),o=w(),t.__value=f=e[88].name||e[88].displayName,t.value=t.__value,this.first=t},m(a,_){g(a,t,_),c(t,s),c(t,r),c(t,o)},p(a,_){e=a,_[0]&67108864&&l!==(l=(e[88].displayName||e[88].name)+"")&&F(s,l),_[0]&67108864&&i!==(i=e[88].isDefault?"(默认)":"")&&F(r,i),_[0]&67108864&&f!==(f=e[88].name||e[88].displayName)&&(t.__value=f,t.value=t.__value)},d(a){a&&b(t)}}}function cs(n){let e,t;return{c(){e=d("i"),t=O(" 直发打印"),u(e,"class","svicon sv-print")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function as(n){let e,t;return{c(){e=d("i"),t=O(" 发送中..."),u(e,"class","svicon sv-refresh svp-spin svelte-qx44lr")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function us(n){let e,t=[],l=new Map,s=n[20];const i=r=>r[97].device_id||r[97].id;for(let r=0;r<s.length;r+=1){let o=zt(n,s,r),f=i(o);l.set(f,t[r]=Bt(f,o))}return{c(){e=d("div");for(let r=0;r<t.length;r+=1)t[r].c();u(e,"class","cloud-device-list svelte-qx44lr")},m(r,o){g(r,e,o);for(let f=0;f<t.length;f+=1)t[f]&&t[f].m(e,null)},p(r,o){o[0]&3145728&&(s=r[20],t=Pe(t,o,i,1,r,s,l,e,Se,Bt,null,zt))},d(r){r&&b(e);for(let o=0;o<t.length;o+=1)t[o].d()}}}function fs(n){let e;return{c(){e=d("div"),e.textContent="点击刷新获取云设备",u(e,"class","settings-empty")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Bt(n,e){let t,l,s,i=!1,r,o,f,a,_=(e[97].device_name||e[97].name||e[97].device_id)+"",h,m,p,q=e[97].status===1?"在线":"离线",S,y,k,v,E,N;return v=Sn(e[73][0]),{key:n,first:null,c(){t=d("label"),l=d("input"),r=w(),o=d("i"),f=w(),a=d("span"),h=O(_),m=w(),p=d("span"),S=O(q),y=w(),u(l,"type","radio"),u(l,"name","cloudDevice"),l.__value=s=String(e[97].device_id||e[97].id),l.value=l.__value,u(o,"class","svicon sv-printer svelte-qx44lr"),u(a,"class","cloud-device-name svelte-qx44lr"),u(p,"class","cloud-device-status svelte-qx44lr"),u(t,"class",k=Ce(`cloud-device-item ${e[21]===String(e[97].device_id||e[97].id)?"active":""}`)+" svelte-qx44lr"),v.p(l),this.first=t},m(D,J){g(D,t,J),c(t,l),l.checked=l.__value===e[21],c(t,r),c(t,o),c(t,f),c(t,a),c(a,h),c(t,m),c(t,p),c(p,S),c(t,y),E||(N=Y(l,"change",e[72]),E=!0)},p(D,J){e=D,J[0]&1048576&&s!==(s=String(e[97].device_id||e[97].id))&&(l.__value=s,l.value=l.__value,i=!0),(i||J[0]&3145728)&&(l.checked=l.__value===e[21]),J[0]&1048576&&_!==(_=(e[97].device_name||e[97].name||e[97].device_id)+"")&&F(h,_),J[0]&1048576&&q!==(q=e[97].status===1?"在线":"离线")&&F(S,q),J[0]&3145728&&k!==(k=Ce(`cloud-device-item ${e[21]===String(e[97].device_id||e[97].id)?"active":""}`)+" svelte-qx44lr")&&u(t,"class",k)},d(D){D&&b(t),v.r(),E=!1,N()}}}function ds(n){let e,t,l,s,i=[],r=new Map,o=n[22];const f=a=>a[94].id||a[94].job_id;for(let a=0;a<o.length;a+=1){let _=Ot(n,o,a),h=f(_);r.set(h,i[a]=Ft(h,_))}return{c(){e=d("table"),t=d("thead"),t.innerHTML='<tr><th class="svelte-qx44lr">ID</th><th class="svelte-qx44lr">设备</th><th class="svelte-qx44lr">状态</th><th class="svelte-qx44lr">操作</th></tr>',l=w(),s=d("tbody");for(let a=0;a<i.length;a+=1)i[a].c();u(e,"class","cloud-table svelte-qx44lr")},m(a,_){g(a,e,_),c(e,t),c(e,l),c(e,s);for(let h=0;h<i.length;h+=1)i[h]&&i[h].m(s,null)},p(a,_){_[0]&4194304|_[1]&12582912&&(o=a[22],i=Pe(i,_,f,1,a,o,r,s,Se,Ft,null,Ot))},d(a){a&&b(e);for(let _=0;_<i.length;_+=1)i[_].d()}}}function _s(n){let e;return{c(){e=d("div"),e.textContent="暂无打印任务",u(e,"class","settings-empty")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function ps(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-qx44lr"></i> 查询中...',u(e,"class","cloud-loading svelte-qx44lr")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Ft(n,e){var M;let t,l,s=(e[94].id||e[94].job_id||"-")+"",i,r,o,f=(e[94].device_id||"-")+"",a,_,h,m=((M=e[94].status)!=null?M:"-")+"",p,q,S,y,k,v,E,N,D;function J(){return e[74](e[94])}function C(){return e[75](e[94])}return{key:n,first:null,c(){t=d("tr"),l=d("td"),i=O(s),r=w(),o=d("td"),a=O(f),_=w(),h=d("td"),p=O(m),q=w(),S=d("td"),y=d("button"),y.textContent="重试",k=w(),v=d("button"),v.textContent="取消",E=w(),u(l,"class","svelte-qx44lr"),u(o,"class","cloud-cell-ellipsis svelte-qx44lr"),u(h,"class","svelte-qx44lr"),u(y,"class","svp-btn svp-btn-ghost svp-btn-xs"),u(v,"class","svp-btn svp-btn-ghost svp-btn-xs"),u(S,"class","cloud-cell-actions svelte-qx44lr"),this.first=t},m(L,A){g(L,t,A),c(t,l),c(l,i),c(t,r),c(t,o),c(o,a),c(t,_),c(t,h),c(h,p),c(t,q),c(t,S),c(S,y),c(S,k),c(S,v),c(t,E),N||(D=[Y(y,"click",J),Y(v,"click",C)],N=!0)},p(L,A){var U;e=L,A[0]&4194304&&s!==(s=(e[94].id||e[94].job_id||"-")+"")&&F(i,s),A[0]&4194304&&f!==(f=(e[94].device_id||"-")+"")&&F(a,f),A[0]&4194304&&m!==(m=((U=e[94].status)!=null?U:"-")+"")&&F(p,m)},d(L){L&&b(t),N=!1,ke(D)}}}function hs(n){let e,t;return{c(){e=d("i"),t=O(" 执行渲染"),u(e,"class","svicon sv-cloud-disk")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function ms(n){let e,t;return{c(){e=d("i"),t=O(" 渲染中..."),u(e,"class","svicon sv-refresh svp-spin svelte-qx44lr")},m(l,s){g(l,e,s),g(l,t,s)},d(l){l&&b(e),l&&b(t)}}}function Gt(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-qx44lr"></i> 渲染中,等待任务完成...',u(e,"class","cloud-loading svelte-qx44lr")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function Vt(n){let e,t,l,s,i;function r(a,_){return a[31]?bs:vs}let o=r(n),f=o(n);return{c(){e=d("div"),t=w(),l=d("div"),l.textContent="渲染结果",s=w(),f.c(),i=Ae(),u(e,"class","settings-divider"),u(l,"class","settings-subtitle")},m(a,_){g(a,e,_),g(a,t,_),g(a,l,_),g(a,s,_),f.m(a,_),g(a,i,_)},p(a,_){o===(o=r(a))&&f?f.p(a,_):(f.d(1),f=o(a),f&&(f.c(),f.m(i.parentNode,i)))},d(a){a&&b(e),a&&b(t),a&&b(l),a&&b(s),f.d(a),a&&b(i)}}}function vs(n){var J;let e,t,l,s=((J=n[4].task_id)!=null?J:"-")+"",i,r,o,f,a=(n[4].file_path||"-")+"",_,h,m,p,q,S,y=n[4].file_size&&Wt(n),k=n[4].file_url&&Yt(n),v=n[4].render_ms&&Xt(n);function E(C,M){return C[32]?ks:gs}let N=E(n),D=N(n);return{c(){e=d("div"),t=d("span"),t.textContent="任务 ID",l=d("code"),i=O(s),r=w(),o=d("span"),o.textContent="文件路径",f=d("code"),_=O(a),h=w(),y&&y.c(),m=w(),k&&k.c(),p=w(),v&&v.c(),q=w(),D.c(),S=Ae(),u(t,"class","svelte-qx44lr"),u(l,"class","svelte-qx44lr"),u(o,"class","svelte-qx44lr"),u(f,"class","svelte-qx44lr"),u(e,"class","cloud-kv svelte-qx44lr")},m(C,M){g(C,e,M),c(e,t),c(e,l),c(l,i),c(e,r),c(e,o),c(e,f),c(f,_),c(e,h),y&&y.m(e,null),c(e,m),k&&k.m(e,null),c(e,p),v&&v.m(e,null),g(C,q,M),D.m(C,M),g(C,S,M)},p(C,M){var L;M[0]&16&&s!==(s=((L=C[4].task_id)!=null?L:"-")+"")&&F(i,s),M[0]&16&&a!==(a=(C[4].file_path||"-")+"")&&F(_,a),C[4].file_size?y?y.p(C,M):(y=Wt(C),y.c(),y.m(e,m)):y&&(y.d(1),y=null),C[4].file_url?k?k.p(C,M):(k=Yt(C),k.c(),k.m(e,p)):k&&(k.d(1),k=null),C[4].render_ms?v?v.p(C,M):(v=Xt(C),v.c(),v.m(e,null)):v&&(v.d(1),v=null),N===(N=E(C))&&D?D.p(C,M):(D.d(1),D=N(C),D&&(D.c(),D.m(S.parentNode,S)))},d(C){C&&b(e),y&&y.d(),k&&k.d(),v&&v.d(),C&&b(q),D.d(C),C&&b(S)}}}function bs(n){let e,t,l,s=(n[4].error_message||"渲染失败")+"",i;return{c(){e=d("div"),t=d("i"),l=w(),i=O(s),u(t,"class","svicon sv-close"),u(e,"class","cloud-msg msg-error svelte-qx44lr")},m(r,o){g(r,e,o),c(e,t),c(e,l),c(e,i)},p(r,o){o[0]&16&&s!==(s=(r[4].error_message||"渲染失败")+"")&&F(i,s)},d(r){r&&b(e)}}}function Wt(n){let e,t,l;return{c(){e=d("span"),e.textContent="文件大小",t=d("code"),l=O(n[30]),u(e,"class","svelte-qx44lr"),u(t,"class","svelte-qx44lr")},m(s,i){g(s,e,i),g(s,t,i),c(t,l)},p(s,i){i[0]&1073741824&&F(l,s[30])},d(s){s&&b(e),s&&b(t)}}}function Yt(n){let e,t,l=n[4].file_url+"",s;return{c(){e=d("span"),e.textContent="文件地址",t=d("code"),s=O(l),u(e,"class","svelte-qx44lr"),u(t,"class","svelte-qx44lr")},m(i,r){g(i,e,r),g(i,t,r),c(t,s)},p(i,r){r[0]&16&&l!==(l=i[4].file_url+"")&&F(s,l)},d(i){i&&b(e),i&&b(t)}}}function Xt(n){let e,t,l=n[4].render_ms+"",s,i;return{c(){e=d("span"),e.textContent="渲染耗时",t=d("code"),s=O(l),i=O(" ms"),u(e,"class","svelte-qx44lr"),u(t,"class","svelte-qx44lr")},m(r,o){g(r,e,o),g(r,t,o),c(t,s),c(t,i)},p(r,o){o[0]&16&&l!==(l=r[4].render_ms+"")&&F(s,l)},d(r){r&&b(e),r&&b(t)}}}function gs(n){let e;return{c(){e=d("div"),e.textContent="任务未返回文件地址(同步渲染可能只返回文件内容)。",u(e,"class","settings-hint")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function ks(n){let e,t,l,s,i,r;function o(_,h){return _[17]==="img"?ws:ys}let f=o(n),a=f(n);return{c(){e=d("div"),t=d("a"),l=d("i"),s=O(" 下载文件"),i=w(),a.c(),r=Ae(),u(l,"class","svicon sv-cloud-disk"),u(t,"class","svp-btn svp-btn-outline svp-btn-sm"),u(t,"href",n[32]),u(t,"target","_blank"),u(t,"rel","noopener"),u(e,"class","form-actions")},m(_,h){g(_,e,h),c(e,t),c(t,l),c(t,s),g(_,i,h),a.m(_,h),g(_,r,h)},p(_,h){h[1]&2&&u(t,"href",_[32]),f===(f=o(_))&&a?a.p(_,h):(a.d(1),a=f(_),a&&(a.c(),a.m(r.parentNode,r)))},d(_){_&&b(e),_&&b(i),a.d(_),_&&b(r)}}}function ys(n){let e,t;return{c(){e=d("iframe"),u(e,"class","cloud-render-frame svelte-qx44lr"),qe(e.src,t=n[32])||u(e,"src",t),u(e,"title","渲染结果预览")},m(l,s){g(l,e,s)},p(l,s){s[1]&2&&!qe(e.src,t=l[32])&&u(e,"src",t)},d(l){l&&b(e)}}}function ws(n){let e,t;return{c(){e=d("img"),u(e,"class","cloud-render-img svelte-qx44lr"),we(e,"object-fit","contain"),qe(e.src,t=n[32])||u(e,"src",t),u(e,"alt","渲染结果")},m(l,s){g(l,e,s)},p(l,s){s[1]&2&&!qe(e.src,t=l[32])&&u(e,"src",t)},d(l){l&&b(e)}}}function Ts(n){let e,t=[],l=new Map,s=n[15];const i=r=>r[91].template_id;for(let r=0;r<s.length;r+=1){let o=Ut(n,s,r),f=i(o);l.set(f,t[r]=Qt(f,o))}return{c(){e=d("div");for(let r=0;r<t.length;r+=1)t[r].c();u(e,"class","cloud-tpl-list svelte-qx44lr")},m(r,o){g(r,e,o);for(let f=0;f<t.length;f+=1)t[f]&&t[f].m(e,null)},p(r,o){o[0]&33920|o[1]&131072&&(s=r[15],t=Pe(t,o,i,1,r,s,l,e,Se,Qt,null,Ut))},d(r){r&&b(e);for(let o=0;o<t.length;o+=1)t[o].d()}}}function qs(n){let e;return{c(){e=d("div"),e.textContent="暂无模板",u(e,"class","settings-empty")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Cs(n){let e;return{c(){e=d("div"),e.innerHTML='<i class="svicon sv-refresh svp-spin svelte-qx44lr"></i> 加载中...',u(e,"class","cloud-loading svelte-qx44lr")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Ss(n){let e;return{c(){e=d("i"),u(e,"class","svicon sv-preview")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Ps(n){let e,t,l;return{c(){e=d("img"),qe(e.src,t=n[91].preview_img)||u(e,"src",t),u(e,"alt",l=n[91].template_name),u(e,"loading","lazy"),u(e,"class","svelte-qx44lr")},m(s,i){g(s,e,i)},p(s,i){i[0]&32768&&!qe(e.src,t=s[91].preview_img)&&u(e,"src",t),i[0]&32768&&l!==(l=s[91].template_name)&&u(e,"alt",l)},d(s){s&&b(e)}}}function Es(n){var i;let e,t=((i=n[91].price)!=null?i:0)+"",l,s;return{c(){e=O("· "),l=O(t),s=O(" 积分")},m(r,o){g(r,e,o),g(r,l,o),g(r,s,o)},p(r,o){var f;o[0]&32768&&t!==(t=((f=r[91].price)!=null?f:0)+"")&&F(l,t)},d(r){r&&b(e),r&&b(l),r&&b(s)}}}function Is(n){let e;return{c(){e=O("· 免费")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Qt(n,e){var Z,R;let t,l,s,i,r,o=e[91].template_name+"",f,a,_,h,m,p=((Z=e[91].use_cnt)!=null?Z:0)+"",q,S,y=((R=e[91].share_cnt)!=null?R:0)+"",k,v,E,N,D,J,C,M,L;function A(B,V){return B[91].preview_img?Ps:Ss}let U=A(e),P=U(e);function I(B,V){return B[91].is_free?Is:Es}let H=I(e),X=H(e);function G(){return e[69](e[91])}return{key:n,first:null,c(){t=d("div"),l=d("div"),P.c(),s=w(),i=d("div"),r=d("span"),f=O(o),_=w(),h=d("span"),m=O("使用 "),q=O(p),S=O(" · 分享 "),k=O(y),v=w(),X.c(),E=w(),N=d("button"),D=O("使用"),C=w(),u(l,"class","cloud-tpl-thumb svelte-qx44lr"),u(r,"class","cloud-tpl-name svelte-qx44lr"),u(r,"title",a=e[91].template_name),u(h,"class","cloud-tpl-meta svelte-qx44lr"),u(i,"class","cloud-tpl-info svelte-qx44lr"),u(N,"class","svp-btn svp-btn-primary svp-btn-xs"),N.disabled=J=e[10]||!e[7],u(t,"class","cloud-tpl-item svelte-qx44lr"),this.first=t},m(B,V){g(B,t,V),c(t,l),P.m(l,null),c(t,s),c(t,i),c(i,r),c(r,f),c(i,_),c(i,h),c(h,m),c(h,q),c(h,S),c(h,k),c(h,v),X.m(h,null),c(t,E),c(t,N),c(N,D),c(t,C),M||(L=Y(N,"click",G),M=!0)},p(B,V){var te,ee;e=B,U===(U=A(e))&&P?P.p(e,V):(P.d(1),P=U(e),P&&(P.c(),P.m(l,null))),V[0]&32768&&o!==(o=e[91].template_name+"")&&F(f,o),V[0]&32768&&a!==(a=e[91].template_name)&&u(r,"title",a),V[0]&32768&&p!==(p=((te=e[91].use_cnt)!=null?te:0)+"")&&F(q,p),V[0]&32768&&y!==(y=((ee=e[91].share_cnt)!=null?ee:0)+"")&&F(k,y),H===(H=I(e))&&X?X.p(e,V):(X.d(1),X=H(e),X&&(X.c(),X.m(h,null))),V[0]&1152&&J!==(J=e[10]||!e[7])&&(N.disabled=J)},d(B){B&&b(t),P.d(),X.d(),M=!1,L()}}}function Zt(n){let e,t=[],l=new Map,s=n[41];const i=r=>r[88].id;for(let r=0;r<s.length;r+=1){let o=Nt(n,s,r),f=i(o);l.set(f,t[r]=xt(f,o))}return{c(){e=d("div");for(let r=0;r<t.length;r+=1)t[r].c();u(e,"class","cloud-provider-tabs svelte-qx44lr")},m(r,o){g(r,e,o);for(let f=0;f<t.length;f+=1)t[f]&&t[f].m(e,null)},p(r,o){o[0]&1028|o[1]&3072&&(s=r[41],t=Pe(t,o,i,1,r,s,l,e,Se,xt,null,Nt))},d(r){r&&b(e);for(let o=0;o<t.length;o+=1)t[o].d()}}}function Ls(n){let e;return{c(){e=d("span"),e.textContent="!",u(e,"class","cloud-provider-warn svelte-qx44lr")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function xt(n,e){let t,l=e[88].label+"",s,i,r,o,f,a,_=!e[88].canLogin&&Ls();function h(){return e[64](e[88])}return{key:n,first:null,c(){t=d("button"),s=O(l),i=w(),_&&_.c(),r=w(),u(t,"class",o=Ce(`cloud-provider-tab ${e[88].id===e[2]?"active":""}`)+" svelte-qx44lr"),t.disabled=e[10],u(t,"title",e[88].canLogin?e[88].label:`${e[88].label}(配置不完整)`),this.first=t},m(m,p){g(m,t,p),c(t,s),c(t,i),_&&_.m(t,null),c(t,r),f||(a=Y(t,"click",h),f=!0)},p(m,p){e=m,p[0]&4&&o!==(o=Ce(`cloud-provider-tab ${e[88].id===e[2]?"active":""}`)+" svelte-qx44lr")&&u(t,"class",o),p[0]&1024&&(t.disabled=e[10])},d(m){m&&b(t),_&&_.d(),f=!1,a()}}}function Ms(n){let e,t,l,s,i=n[5]&&$t(n);return{c(){e=d("p"),t=O(n[33]),l=w(),i&&i.c(),s=Ae(),u(e,"class","settings-hint"),we(e,"margin","0 0 8px")},m(r,o){g(r,e,o),c(e,t),g(r,l,o),i&&i.m(r,o),g(r,s,o)},p(r,o){o[1]&4&&F(t,r[33]),r[5]?i?i.p(r,o):(i=$t(r),i.c(),i.m(s.parentNode,s)):i&&(i.d(1),i=null)},d(r){r&&b(e),r&&b(l),i&&i.d(r),r&&b(s)}}}function As(n){let e,t,l,s,i,r=(n[9].client_name||n[9].client_id)+"",o,f,a,_=n[9].client_id+"",h,m,p=n[9].client_type===2&&el();return{c(){e=d("div"),t=d("i"),l=w(),s=d("div"),i=d("span"),o=O(r),f=w(),a=d("span"),h=O(_),m=w(),p&&p.c(),u(t,"class","svicon sv-cloud svelte-qx44lr"),u(i,"class","cloud-client-name svelte-qx44lr"),u(a,"class","cloud-client-id svelte-qx44lr"),u(s,"class","cloud-client-info svelte-qx44lr"),u(e,"class","cloud-client-box svelte-qx44lr")},m(q,S){g(q,e,S),c(e,t),c(e,l),c(e,s),c(s,i),c(i,o),c(s,f),c(s,a),c(a,h),c(e,m),p&&p.m(e,null)},p(q,S){S[0]&512&&r!==(r=(q[9].client_name||q[9].client_id)+"")&&F(o,r),S[0]&512&&_!==(_=q[9].client_id+"")&&F(h,_),q[9].client_type===2?p||(p=el(),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},d(q){q&&b(e),p&&p.d()}}}function $t(n){let e,t,l,s=(n[5].clientId||"未配置")+"",i;return{c(){e=d("div"),t=d("span"),t.textContent="接入方",l=d("code"),i=O(s),u(t,"class","svelte-qx44lr"),u(l,"class","svelte-qx44lr"),u(e,"class","cloud-kv svelte-qx44lr")},m(r,o){g(r,e,o),c(e,t),c(e,l),c(l,i)},p(r,o){o[0]&32&&s!==(s=(r[5].clientId||"未配置")+"")&&F(i,s)},d(r){r&&b(e)}}}function el(n){let e;return{c(){e=d("span"),e.textContent="匿名接入",u(e,"class","svp-badge svp-badge-sm")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function Os(n){let e;function t(i,r){return i[1].hasCustomLoginUI?Ds:Ns}let l=t(n),s=l(n);return{c(){e=d("div"),s.c(),u(e,"class","cloud-login-box svelte-qx44lr")},m(i,r){g(i,e,r),s.m(e,null)},p(i,r){l===(l=t(i))&&s?s.p(i,r):(s.d(1),s=l(i),s&&(s.c(),s.m(e,null)))},d(i){i&&b(e),s.d()}}}function zs(n){let e;return{c(){e=d("div"),e.innerHTML='<div class="settings-hint">未配置登录方式,仅可浏览模板中心。</div>',u(e,"class","cloud-login-box svelte-qx44lr")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Us(n){var D,J,C,M;let e,t,l,s,i=(((D=n[8])==null?void 0:D.member_name)||((J=n[8])==null?void 0:J.member_account)||"已登录")+"",r,o,f,a=(((C=n[8])==null?void 0:C.member_account)||"")+"",_,h,m,p,q,S,y;function k(L,A){var U;return(U=L[8])!=null&&U.member_avatar?Ks:Rs}let v=k(n),E=v(n),N=typeof((M=n[8])==null?void 0:M.points)=="number"&&nl(n);return{c(){e=d("div"),E.c(),t=w(),l=d("div"),s=d("span"),r=O(i),o=w(),f=d("span"),_=O(a),h=w(),N&&N.c(),m=w(),p=d("button"),q=O("退出登录"),u(s,"class","cloud-user-name svelte-qx44lr"),u(f,"class","cloud-user-sub svelte-qx44lr"),u(l,"class","cloud-user-info svelte-qx44lr"),u(p,"class","svp-btn svp-btn-outline svp-btn-sm"),p.disabled=n[10],u(e,"class","cloud-user-box svelte-qx44lr")},m(L,A){g(L,e,A),E.m(e,null),c(e,t),c(e,l),c(l,s),c(s,r),c(l,o),c(l,f),c(f,_),c(f,h),N&&N.m(f,null),c(e,m),c(e,p),c(p,q),S||(y=Y(p,"click",n[45]),S=!0)},p(L,A){var U,P,I,H;v===(v=k(L))&&E?E.p(L,A):(E.d(1),E=v(L),E&&(E.c(),E.m(e,t))),A[0]&256&&i!==(i=(((U=L[8])==null?void 0:U.member_name)||((P=L[8])==null?void 0:P.member_account)||"已登录")+"")&&F(r,i),A[0]&256&&a!==(a=(((I=L[8])==null?void 0:I.member_account)||"")+"")&&F(_,a),typeof((H=L[8])==null?void 0:H.points)=="number"?N?N.p(L,A):(N=nl(L),N.c(),N.m(f,null)):N&&(N.d(1),N=null),A[0]&1024&&(p.disabled=L[10])},d(L){L&&b(e),E.d(),N&&N.d(),S=!1,y()}}}function Ns(n){let e,t,l,s,i,r;function o(h,m){return h[10]?Js:Hs}let f=o(n),a=f(n),_=!n[36]&&tl();return{c(){e=d("button"),a.c(),l=w(),_&&_.c(),s=Ae(),u(e,"class","svp-btn svp-btn-primary svp-btn-sm"),e.disabled=t=n[10]||!n[36]},m(h,m){g(h,e,m),a.m(e,null),g(h,l,m),_&&_.m(h,m),g(h,s,m),i||(r=Y(e,"click",n[44]),i=!0)},p(h,m){f===(f=o(h))&&a?a.p(h,m):(a.d(1),a=f(h),a&&(a.c(),a.m(e,null))),m[0]&1024|m[1]&32&&t!==(t=h[10]||!h[36])&&(e.disabled=t),h[36]?_&&(_.d(1),_=null):_||(_=tl(),_.c(),_.m(s.parentNode,s))},d(h){h&&b(e),a.d(),h&&b(l),_&&_.d(h),h&&b(s),i=!1,r()}}}function Ds(n){let e=n[2],t,l=ll(n);return{c(){l.c(),t=Ae()},m(s,i){l.m(s,i),g(s,t,i)},p(s,i){i[0]&4&&ut(e,e=s[2])?(l.d(1),l=ll(s),l.c(),l.m(t.parentNode,t)):l.p(s,i)},d(s){s&&b(t),l.d(s)}}}function Hs(n){let e,t,l=n[2]==="oauth"?"去授权登录":"登录",s;return{c(){e=d("i"),t=w(),s=O(l),u(e,"class","svicon sv-cloud")},m(i,r){g(i,e,r),g(i,t,r),g(i,s,r)},p(i,r){r[0]&4&&l!==(l=i[2]==="oauth"?"去授权登录":"登录")&&F(s,l)},d(i){i&&b(e),i&&b(t),i&&b(s)}}}function Js(n){let e,t;return{c(){e=d("i"),t=O(" 登录中..."),u(e,"class","svicon sv-refresh svp-spin svelte-qx44lr")},m(l,s){g(l,e,s),g(l,t,s)},p:ie,d(l){l&&b(e),l&&b(t)}}}function tl(n){let e;return{c(){e=d("div"),e.textContent="登录方式配置不完整,请检查插件配置。",u(e,"class","settings-hint")},m(t,l){g(t,e,l)},d(t){t&&b(e)}}}function ll(n){let e;return{c(){e=d("div"),u(e,"class","cloud-auth-custom")},m(t,l){g(t,e,l),n[65](e)},p:ie,d(t){t&&b(e),n[65](null)}}}function Rs(n){let e;return{c(){e=d("i"),u(e,"class","svicon sv-client cloud-avatar-icon svelte-qx44lr")},m(t,l){g(t,e,l)},p:ie,d(t){t&&b(e)}}}function Ks(n){let e,t;return{c(){e=d("img"),u(e,"class","cloud-avatar svelte-qx44lr"),qe(e.src,t=n[8].member_avatar)||u(e,"src",t),u(e,"alt","avatar")},m(l,s){g(l,e,s)},p(l,s){s[0]&256&&!qe(e.src,t=l[8].member_avatar)&&u(e,"src",t)},d(l){l&&b(e)}}}function nl(n){let e,t=n[8].points+"",l;return{c(){e=O("· 积分 "),l=O(t)},m(s,i){g(s,e,i),g(s,l,i)},p(s,i){i[0]&256&&t!==(t=s[8].points+"")&&F(l,t)},d(s){s&&b(e),s&&b(l)}}}function sl(n){let e,t,l,s;return{c(){e=d("div"),t=d("i"),l=w(),s=O(n[13]),u(t,"class","svicon sv-print"),u(e,"class","cloud-msg msg-success svelte-qx44lr")},m(i,r){g(i,e,r),c(e,t),c(e,l),c(e,s)},p(i,r){r[0]&8192&&F(s,i[13])},d(i){i&&b(e)}}}function il(n){let e,t,l,s;return{c(){e=d("div"),t=d("i"),l=w(),s=O(n[11]),u(t,"class","svicon sv-close"),u(e,"class","cloud-msg msg-error svelte-qx44lr")},m(i,r){g(i,e,r),c(e,t),c(e,l),c(e,s)},p(i,r){r[0]&2048&&F(s,i[11])},d(i){i&&b(e)}}}function rl(n){let e,t;return{c(){e=d("pre"),t=O(n[12]),u(e,"class","cloud-output svelte-qx44lr")},m(l,s){g(l,e,s),c(e,t)},p(l,s){s[0]&4096&&F(t,l[12])},d(l){l&&b(e)}}}function js(n){let e,t,l,s,i,r,o,f,a,_=n[7]?"已登录":"未登录",h,m,p=[],q=new Map,S,y,k,v,E,N=n[40];const D=P=>P[105].key;for(let P=0;P<N.length;P+=1){let I=Dt(n,N,P),H=D(I);q.set(H,p[P]=Ht(H,I))}function J(P,I){if(P[6]==="account")return ts;if(P[6]==="template")return es;if(P[6]==="render")return $n;if(P[6]==="cloudPrint")return xn;if(P[6]==="transit")return Zn;if(P[6]==="config")return Qn}let C=J(n),M=C&&C(n),L=n[13]&&sl(n),A=n[11]&&il(n),U=n[12]&&rl(n);return{c(){e=d("p"),e.textContent="通过 sv-print-cloud 云服务进行服务端渲染、云打印与中转打印。首次使用请在「账户」中登录。",t=w(),l=d("div"),s=d("div"),i=d("div"),r=d("span"),f=w(),a=d("span"),h=O(_),m=w();for(let P=0;P<p.length;P+=1)p[P].c();S=w(),y=d("div"),M&&M.c(),k=w(),L&&L.c(),v=w(),A&&A.c(),E=w(),U&&U.c(),u(e,"class","settings-hint"),u(r,"class",o=Ce(`cloud-status-dot ${n[7]?"dot-on":"dot-off"}`)+" svelte-qx44lr"),u(a,"class","cloud-status-text svelte-qx44lr"),u(i,"class","cloud-status-bar svelte-qx44lr"),u(s,"class","cloud-sidebar svelte-qx44lr"),u(y,"class","cloud-content svelte-qx44lr"),u(l,"class","cloud-layout svelte-qx44lr")},m(P,I){g(P,e,I),g(P,t,I),g(P,l,I),c(l,s),c(s,i),c(i,r),c(i,f),c(i,a),c(a,h),c(s,m);for(let H=0;H<p.length;H+=1)p[H]&&p[H].m(s,null);c(l,S),c(l,y),M&&M.m(y,null),c(y,k),L&&L.m(y,null),c(y,v),A&&A.m(y,null),c(y,E),U&&U.m(y,null)},p(P,I){I[0]&128&&o!==(o=Ce(`cloud-status-dot ${P[7]?"dot-on":"dot-off"}`)+" svelte-qx44lr")&&u(r,"class",o),I[0]&128&&_!==(_=P[7]?"已登录":"未登录")&&F(h,_),I[0]&64|I[1]&4608&&(N=P[40],p=Pe(p,I,D,1,P,N,q,s,Se,Ht,null,Dt)),C===(C=J(P))&&M?M.p(P,I):(M&&M.d(1),M=C&&C(P),M&&(M.c(),M.m(y,k))),P[13]?L?L.p(P,I):(L=sl(P),L.c(),L.m(y,v)):L&&(L.d(1),L=null),P[11]?A?A.p(P,I):(A=il(P),A.c(),A.m(y,E)):A&&(A.d(1),A=null),P[12]?U?U.p(P,I):(U=rl(P),U.c(),U.m(y,null)):U&&(U.d(1),U=null)},i:ie,o:ie,d(P){P&&b(e),P&&b(t),P&&b(l);for(let I=0;I<p.length;I+=1)p[I].d();M&&M.d(),L&&L.d(),A&&A.d(),U&&U.d()}}}function Bs(n,e=1){if(!Number.isFinite(n)||n<0)return"—";if(n<1024)return`${n} B`;const t=["KB","MB","GB","TB","PB"];let l=n,s=-1;do l/=1024,s++;while(l>=1024&&s<t.length-1);return`${l.toFixed(e).replace(/\.0+$/,"")} ${t[s]}`}function Fs(n,e,t){let l,s,i,r,o,f,a,_,h,m,p,q,S,{config:y}=e,{auth:k}=e,{service:v}=e;const E=[{key:"account",label:"账户",icon:"sv-client"},{key:"template",label:"模板中心",icon:"sv-templates"},{key:"render",label:"服务端渲染",icon:"sv-cloud-disk"},{key:"cloudPrint",label:"云打印",icon:"sv-printer"},{key:"transit",label:"中转打印",icon:"sv-flow"}];y.settingsTabShowConfig!=!1&&E.push({key:"config",label:"连接配置",icon:"sv-setting"});const N={iframe:"设计器内弹层",popup:"独立弹窗",page:"新标签页",custom:"自定义"},D={oauth:"跳转 sv-print 授权页完成授权后获取访问令牌,令牌失效需重新授权。",token:"直接使用访问令牌接入,无需授权流程;令牌由接入方自行提供与维护。",host:"访问令牌由宿主系统提供,插件不参与认证,登录态跟随宿主。",local:"使用宿主账号密码登录,由宿主校验通过后返回访问令牌。",none:"未配置登录方式,仅可浏览模板中心,写操作需先配置登录方式。"};let J="account",C=k.activeId,M=k.providers,L=k.isLoggedIn(),A,U=null,P=null,I=!1,H="",X="",G="",Z="",R=[],B=!1,V="pdf",te=!0,ee=null,Te=!1,ae=[],re="",ue=[],oe=!1,le=[],fe="",_e=[],pe="",ne="",K=!1;In(()=>{const T=k.onChange(x=>{const ce=!!(x!=null&&x.accessToken),me=ce!==L;t(7,L=ce),ce||t(8,U=null),ce&&me&&Me()});return de(),L&&Me(),()=>T==null?void 0:T()});function de(){k.getClientInfo().then(T=>t(9,P=T)).catch(()=>t(9,P=null))}function $(T){return j(this,null,function*(){if(!(T===C||I)){t(10,I=!0),t(11,H="");try{yield k.switchProvider(T),t(2,C=k.activeId),t(7,L=k.isLoggedIn()),t(8,U=null),t(9,P=null),de(),L&&(yield Me())}catch(x){t(11,H=(x==null?void 0:x.message)||"切换登录方式失败")}finally{t(10,I=!1)}}})}function ye(T,x="success"){var ce,me;(me=(ce=mt())==null?void 0:ce.showToast)==null||me.call(ce,T,{type:x})}function ve(T){t(13,G=T),setTimeout(()=>t(13,G=""),3e3)}function Oe(T){t(6,J=T),t(11,H=""),t(12,X=""),T==="template"&&R.length===0&&Ue()}function Me(){return j(this,null,function*(){try{t(8,U=yield k.getUser())}catch(T){t(8,U=null)}})}function be(){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{yield k.login(),yield Me()}catch(T){t(11,H=(T==null?void 0:T.message)||"登录失败")}finally{t(10,I=!1)}})}function ze(){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{yield k.logout(),t(8,U=null)}finally{t(10,I=!1)}})}function Ue(){return j(this,null,function*(){t(16,B=!0),t(11,H="");try{const T=yield v.listTemplates({keyword:Z,page:1,pageSize:5});t(15,R=(T==null?void 0:T.list)||[])}catch(T){t(11,H=(T==null?void 0:T.message)||"加载模板失败")}finally{t(16,B=!1)}})}function Ne(){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{const T=yield v.useRandomTemplate({keyword:Z||void 0});ve(`已随机应用模板:${T.template_name}`),ye(`已应用模板:${T.template_name}`)}catch(T){t(11,H=(T==null?void 0:T.message)||"随机使用模板失败")}finally{t(10,I=!1)}})}function Ge(T){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{yield v.applyTemplate(T),ve(`已应用模板:${T.template_name}`),ye(`已应用模板:${T.template_name}`)}catch(x){t(11,H=(x==null?void 0:x.message)||"应用模板失败")}finally{t(10,I=!1)}})}function De(T,x){return j(this,null,function*(){t(10,I=!0),t(11,H=""),t(12,X=`${T} 调用中...`);try{const ce=yield x();t(12,X=`// ${T}
28
+ ${JSON.stringify(ce,null,2)}`)}catch(ce){t(11,H=`${T} 失败:${(ce==null?void 0:ce.message)||ce}`),t(12,X="")}finally{t(10,I=!1)}})}function Ie(){return j(this,null,function*(){t(10,I=!0),t(11,H=""),t(12,X=""),t(4,ee=null),t(19,Te=!1);try{const T=yield v.render({sync:te,type:V});if(t(4,ee=T),!te&&(T==null?void 0:T.task_id)!==void 0){t(19,Te=!0);try{t(4,ee=yield v.waitRender(T.task_id))}finally{t(19,Te=!1)}}(Number(ee==null?void 0:ee.status)===2||!!(ee!=null&&ee.file_url))&&(ve("渲染成功"),ye("渲染成功"))}catch(T){t(11,H=`服务端渲染失败:${(T==null?void 0:T.message)||T}`),t(4,ee=null)}finally{t(10,I=!1)}})}function ge(){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{const T=yield v.getDevices();t(20,ae=(T==null?void 0:T.list)||T||[]),!re&&ae.length&&t(21,re=String(ae[0].device_id||ae[0].id)),ve(`已获取 ${ae.length} 个云设备`)}catch(T){t(11,H=(T==null?void 0:T.message)||"获取云设备失败")}finally{t(10,I=!1)}})}function Ee(){return j(this,null,function*(){t(23,oe=!0),t(11,H="");try{const T=yield v.getJobs({page:1,pageSize:10});t(22,ue=(T==null?void 0:T.list)||[])}catch(T){t(11,H=(T==null?void 0:T.message)||"获取云任务失败")}finally{t(23,oe=!1)}})}function Xe(){return j(this,null,function*(){if(!re){t(11,H="请先选择云设备");return}yield De("云打印下发",()=>v.cloudPrint({device_id:re,print_options:{type:V}})),Ee()})}function he(T){return j(this,null,function*(){yield De("取消云任务",()=>v.cancelJob(T)),Ee()})}function z(T){return j(this,null,function*(){yield De("重试云任务",()=>v.retryJob(T)),Ee()})}function W(){return j(this,null,function*(){t(10,I=!0),t(11,H="");try{const T=yield v.getTransitClients();t(24,le=T.filter(x=>x.clientType==="electron")),t(29,K=!0),!fe&&le.length&&t(25,fe=le[0].clientId),ve(`已连接,${le.length} 个在线客户端`),fe&&(yield Qe(fe))}catch(T){t(29,K=!1),t(11,H=(T==null?void 0:T.message)||"获取中转客户端失败")}finally{t(10,I=!1)}})}function se(){v.disconnectTransit(),t(29,K=!1),t(24,le=[]),t(26,_e=[]),t(25,fe=""),t(27,pe="")}function Qe(){return j(this,arguments,function*(T=fe){var x,ce;if(!T){t(11,H="请先选择中转客户端");return}t(10,I=!0),t(11,H="");try{const me=yield v.getTransitPrinters(T);t(26,_e=Array.isArray(me)?me:(me==null?void 0:me.list)||[]),_e.some(dt=>(dt.name||dt.displayName)===pe)||t(27,pe=((x=_e[0])==null?void 0:x.name)||((ce=_e[0])==null?void 0:ce.displayName)||""),ve(`已获取 ${_e.length} 台打印机`)}catch(me){t(11,H=(me==null?void 0:me.message)||"获取中转打印机失败")}finally{t(10,I=!1)}})}function ft(T){t(25,fe=T),t(27,pe=""),t(26,_e=[]),Qe(T)}function Dl(){return j(this,null,function*(){if(!fe){t(11,H="请选择目标中转客户端");return}if(!pe){t(11,H="请选择打印机");return}let T;if(ne.trim())try{T=JSON.parse(ne.trim())}catch(x){t(11,H="打印选项不是合法的 JSON");return}t(10,I=!0),t(11,H=""),t(13,G="");try{const x=yield v.transitPrint({clientId:fe,printer:pe,print_options:T});t(13,G=`客户端打印成功${x!=null&&x.msg?`:${x.msg}`:""}`),ye(G)}catch(x){t(11,H=`中转打印失败:${(x==null?void 0:x.message)||x}`)}finally{t(10,I=!1)}})}const Hl=[[]],Jl=T=>Oe(T.key),Rl=T=>$(T.id);function Kl(T){st[T?"unshift":"push"](()=>{A=T,t(3,A)})}function jl(){Z=this.value,t(14,Z)}const Bl=T=>T.key==="Enter"&&Ue(),Fl=()=>{var T,x,ce,me;return(me=(ce=(x=(T=mt())==null?void 0:T.cloud)==null?void 0:x.templateCenter)==null?void 0:ce.show)==null?void 0:me.call(ce)},Gl=T=>Ge(T);function Vl(){V=lt(this),t(17,V)}function Wl(){te=this.checked,t(18,te)}function Yl(){re=this.__value,t(21,re)}const Xl=T=>z(T.id||T.job_id),Ql=T=>he(T.id||T.job_id);function Zl(){fe=lt(this),t(25,fe),t(24,le)}const xl=()=>ft(fe);function $l(){pe=lt(this),t(27,pe),t(26,_e)}const en=()=>Qe();function tn(){ne=this.value,t(28,ne)}return n.$$set=T=>{"config"in T&&t(0,y=T.config),"auth"in T&&t(1,k=T.auth),"service"in T&&t(60,v=T.service)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(62,s=M.find(T=>T.id===C)),n.$$.dirty[0]&6&&t(61,i=C?k.providerConfig:null),n.$$.dirty[0]&2|n.$$.dirty[2]&1&&t(38,r=(s==null?void 0:s.label)||k.label),n.$$.dirty[0]&6&&t(37,o=C?k.storageKey:""),n.$$.dirty[2]&1&&t(36,f=!!(s!=null&&s.canLogin)),n.$$.dirty[1]&1073741824&&t(5,a=i&&i.type==="oauth"?i:null),n.$$.dirty[0]&32&&t(35,_=Array.isArray(a==null?void 0:a.scope)?a==null?void 0:a.scope.join(", "):(a==null?void 0:a.scope)||"(默认全部)"),n.$$.dirty[0]&32&&t(34,h=N[(a==null?void 0:a.mode)||"iframe"]||"设计器内弹层"),n.$$.dirty[0]&4&&t(33,m=D[C]||""),n.$$.dirty[0]&14&&A&&C&&k.renderLogin(A),n.$$.dirty[0]&16&&t(32,p=(ee==null?void 0:ee.file_url)||""),n.$$.dirty[0]&16&&t(31,q=Number(ee==null?void 0:ee.status)===3),n.$$.dirty[0]&16&&t(30,S=Bs((ee==null?void 0:ee.file_size)||0))},t(39,l=M.length>1),[y,k,C,A,ee,a,J,L,U,P,I,H,X,G,Z,R,B,V,te,Te,ae,re,ue,oe,le,fe,_e,pe,ne,K,S,q,p,m,h,_,f,o,r,l,E,M,$,Oe,be,ze,Ue,Ne,Ge,Ie,ge,Ee,Xe,he,z,W,se,Qe,ft,Dl,v,i,s,Jl,Rl,Kl,jl,Bl,Fl,Gl,Vl,Wl,Yl,Hl,Xl,Ql,Zl,xl,$l,en,tn]}class Gs extends Nl{constructor(e){super(),Ul(this,e,Fs,js,ut,{config:0,auth:1,service:60},null,[-1,-1,-1,-1])}}const Vs=Object.freeze(Object.defineProperty({__proto__:null,default:Gs},Symbol.toStringTag,{value:"Module"}));exports.AuthManager=Sl;exports.CloudClient=cl;exports.CloudService=El;exports.HostAuthProvider=ml;exports.LocalAuthProvider=vl;exports.NoneAuthProvider=ot;exports.OAuthAuthProvider=pl;exports.TokenAuthProvider=hl;exports.TransitClient=Pl;exports.createAuthProvider=gl;exports.default=qn;exports.defaultStorageKey=kl;exports.extendTemplate=at;exports.memoryStorageToken=mn;exports.normalizeAuthConfig=bl;exports.preferencesTokenStorage=ql;exports.readActiveProvider=yl;exports.relayOAuthCallback=_l;exports.resolveStorage=Cl;exports.resolveStorageKey=ct;exports.sessionStorageToken=hn;exports.writeActiveProvider=$e;