10 lines
6.0 KiB
JavaScript
10 lines
6.0 KiB
JavaScript
import{$ as e,I as t,N as n,R as r,W as i,Z as a,f as o,h as s,i as c,n as l,w as u}from"./client-CmW03vy2.js";import{p as d,t as f}from"./index-DVruj17R.js";function p(){let e=r(d,null);return e===null&&o(`use-message`,"No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),e}function m(){let e=f();return h(e.refreshTokenAction,e.getToken)}function h(e,t){return c(g(e,l(t)))}function g(e,t){return async n=>{let r;try{r=await t(n)}catch{await e(),r=await t(n)}if(r&&typeof r==`object`&&`code`in r&&r.code!==0)throw Error(`message`in r&&typeof r.message==`string`?r.message:`Ошибка запроса`);return r}}function _(e){let t=0;for(let n=0;n<e.length;++n)e[n]===`&`&&++t;return t}var v=/\s*,(?![^(]*\))\s*/g,y=/\s+/g;function b(e,t){let n=[];return t.split(v).forEach(t=>{let r=_(t);if(!r){e.forEach(e=>{n.push((e&&e+` `)+t)});return}else if(r===1){e.forEach(e=>{n.push(t.replace(`&`,e))});return}let i=[t];for(;r--;){let t=[];i.forEach(n=>{e.forEach(e=>{t.push(n.replace(`&`,e))})}),i=t}i.forEach(e=>n.push(e))}),n}function x(e,t){let n=[];return t.split(v).forEach(t=>{e.forEach(e=>{n.push((e&&e+` `)+t)})}),n}function S(e){let t=[``];return e.forEach(e=>{e&&=e.trim(),e&&(t=e.includes(`&`)?b(t,e):x(t,e))}),t.join(`, `).replace(y,` `)}var C=/[A-Z]/g;function w(e){return e.replace(C,e=>`-`+e.toLowerCase())}function T(e,t=` `){return typeof e==`object`&&e?` {
|
|
`+Object.entries(e).map(e=>t+` ${w(e[0])}: ${e[1]};`).join(`
|
|
`)+`
|
|
`+t+`}`:`: ${e};`}function E(e,t,n){return typeof e==`function`?e({context:t.context,props:n}):e}function D(e,t,n,r){if(!t)return``;let i=E(t,n,r);if(!i)return``;if(typeof i==`string`)return`${e} {\n${i}\n}`;let a=Object.keys(i);if(a.length===0)return n.config.keepEmptyBlock?e+` {
|
|
}`:``;let o=e?[e+` {`]:[];return a.forEach(e=>{let t=i[e];if(e===`raw`){o.push(`
|
|
`+t+`
|
|
`);return}e=w(e),t!=null&&o.push(` ${e}${T(t)}`)}),e&&o.push(`}`),o.join(`
|
|
`)}function O(e,t,n){e&&e.forEach(e=>{if(Array.isArray(e))O(e,t,n);else if(typeof e==`function`){let r=e(t);Array.isArray(r)?O(r,t,n):r&&n(r)}else e&&n(e)})}function k(e,t,n,r,i,a){let o=e.$;!o||typeof o==`string`?t.push(o):typeof o==`function`?t.push(o({context:r.context,props:i})):(o.before&&o.before(r.context),!o.$||typeof o.$==`string`?t.push(o.$):o.$&&t.push(o.$({context:r.context,props:i})));let s=S(t),c=D(s,e.props,r,i);a&&c&&a.insertRule(c),!a&&c.length&&n.push(c),e.children&&O(e.children,{context:r.context,props:i},e=>{if(typeof e==`string`){let t=D(s,{raw:e},r,i);a?a.insertRule(t):n.push(t)}else k(e,t,n,r,i,a)}),t.pop(),o&&o.after&&o.after(r.context)}function A(e,t,n,r=!1){let i=[];return k(e,[],i,t,n,r?e.instance.__styleSheet:void 0),r?``:i.join(`
|
|
|
|
`)}function j(e){if(!e)return;let t=e.parentElement;t&&t.removeChild(e)}function M(e){return document.querySelector(`style[cssr-id="${e}"]`)}function N(e){let t=document.createElement(`style`);return t.setAttribute(`cssr-id`,e),t}window&&(window.__cssrContext={});function P(e){let t=e.getAttribute(`mount-count`);return t===null?null:Number(t)}function F(e,t){e.setAttribute(`mount-count`,String(t))}function I(e,t,n,r){let{els:i}=t;if(n===void 0)i.forEach(j),t.els=[];else{let e=M(n);if(e&&i.includes(e)){let a=P(e);r?a===null?console.error(`[css-render/unmount]: The style with target='${n}' is mounted in count mode.`):a<=1?(j(e),t.els=i.filter(t=>t!==e)):F(e,a-1):a===null?(j(e),t.els=i.filter(t=>t!==e)):console.error(`[css-render/unmount]: The style with target='${n}' is mounted in no-count mode.`)}}}function L(e,t){e.push(t)}function R(e,t,n,r,i,a,o,c,l){if(o&&!l){if(n===void 0){console.error("[css-render/mount]: `id` is required in `boost` mode.");return}let i=window.__cssrContext;i[n]||(i[n]=!0,A(t,e,r,o));return}let u,{els:d}=t,f;if(n===void 0&&(f=t.render(r),n=s(f)),l){l(n,f??t.render(r));return}let p=M(n);if(c||p===null){if(u=p===null?N(n):p,f===void 0&&(f=t.render(r)),u.textContent=f,p!==null)return;if(i){let e=document.head.getElementsByTagName(`style`)[0]||null;document.head.insertBefore(u,e)}else document.head.appendChild(u);a&&F(u,1),L(d,u)}else{let e=P(p);a?e===null?console.error(`[css-render/mount]: The style with id='${n}' has been mounted in no-count mode.`):F(p,e+1):e!==null&&console.error(`[css-render/mount]: The style with id='${n}' has been mounted in count mode.`)}return p??u}function z(e){return A(this,this.instance,e)}function B(e={}){let{target:t,id:n,ssr:r,props:i,count:a=!1,head:o=!1,boost:s=!1,force:c=!1}=e;return R(this.instance,this,n??t,i,o,a,s,c,r)}function V(e={}){let{id:t,target:n,delay:r=0,count:i=!1}=e;r===0?I(this.instance,this,t??n,i):setTimeout(()=>I(this.instance,this,t??n,i),r)}var H=function(e,t,n,r){return{instance:e,$:t,props:n,children:r,els:[],render:z,mount:B,unmount:V}},U=function(e,t,n,r){return Array.isArray(t)?H(e,{$:null},null,t):Array.isArray(n)?H(e,t,null,n):Array.isArray(r)?H(e,t,n,r):H(e,t,n,null)};function W(e={}){let t=null,n={c:((...e)=>U(n,...e)),use:(e,...t)=>e.install(n,...t),find:M,context:{},config:e,get __styleSheet(){if(!t){let e=document.createElement(`style`);return document.head.appendChild(e),t=document.styleSheets[document.styleSheets.length-1],t}return t}};return n}var{c:G}=W(),K=G(`.xicon`,{width:`1em`,height:`1em`,display:`inline-flex`},[G(`svg`,{width:`1em`,height:`1em`}),G(`svg:not([fill])`,{fill:`currentColor`})]),q=()=>{K.mount({id:`xicons-icon`})},J={size:[String,Number],color:String,tag:String},Y=Symbol(`IconConfigInjection`);n({name:`IconConfigProvider`,props:J,setup(t,{slots:n}){return a(Y,t),()=>e(n,`default`)}});var X=`span`,Z=n({name:`Icon`,props:J,setup(n,{slots:a}){let o=r(Y,null),s=u(()=>{let e=n.size??o?.size;if(e!==void 0)return typeof e==`number`||/^\d+$/.test(e)?`${e}px`:e}),c=u(()=>{let{color:e}=n;return e===void 0?o?o.color:void 0:e}),l=u(()=>{let{tag:e}=n;return e===void 0?o?.tag??X:e});return i(()=>{q()}),()=>t(l.value,{class:`xicon`,style:{color:c.value,fontSize:s.value}},[e(a,`default`)])}});export{m as n,p as r,Z as t}; |