UNPKG

ewuit

Version:

an easy web ui inspect tool

419 lines (392 loc) 34.5 kB
(function(I,$){typeof exports=="object"&&typeof module!="undefined"?module.exports=$():typeof define=="function"&&define.amd?define($):(I=typeof globalThis!="undefined"?globalThis:I||self,I.Ewuit=$())})(this,function(){"use strict";var I=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},$=function(t){return t&&t.Math==Math&&t},f=$(typeof globalThis=="object"&&globalThis)||$(typeof window=="object"&&window)||$(typeof self=="object"&&self)||$(typeof I=="object"&&I)||function(){return this}()||Function("return this")(),et={},O=function(t){try{return!!t()}catch{return!0}},ir=O,x=!ir(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),cr=O,Mt=!cr(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),lr=Mt,N=Function.prototype.call,rt=lr?N.bind(N):function(){return N.apply(N,arguments)},zt={},Nt={}.propertyIsEnumerable,Kt=Object.getOwnPropertyDescriptor,vr=Kt&&!Nt.call({1:2},1);zt.f=vr?function(e){var r=Kt(this,e);return!!r&&r.enumerable}:Nt;var Ut=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},Wt=Mt,Gt=Function.prototype,ur=Gt.bind,nt=Gt.call,sr=Wt&&ur.bind(nt,nt),m=Wt?function(t){return t&&sr(t)}:function(t){return t&&function(){return nt.apply(t,arguments)}},Vt=m,dr=Vt({}.toString),fr=Vt("".slice),pr=function(t){return fr(dr(t),8,-1)},hr=f,br=m,yr=O,gr=pr,ot=hr.Object,mr=br("".split),wr=yr(function(){return!ot("z").propertyIsEnumerable(0)})?function(t){return gr(t)=="String"?mr(t,""):ot(t)}:ot,$r=f,Sr=$r.TypeError,Ht=function(t){if(t==null)throw Sr("Can't call method on "+t);return t},Or=wr,xr=Ht,K=function(t){return Or(xr(t))},w=function(t){return typeof t=="function"},Tr=w,L=function(t){return typeof t=="object"?t!==null:Tr(t)},at=f,Er=w,Cr=function(t){return Er(t)?t:void 0},U=function(t,e){return arguments.length<2?Cr(at[t]):at[t]&&at[t][e]},Pr=m,Ir=Pr({}.isPrototypeOf),jr=U,kr=jr("navigator","userAgent")||"",Yt=f,it=kr,qt=Yt.process,Xt=Yt.Deno,Jt=qt&&qt.versions||Xt&&Xt.version,Zt=Jt&&Jt.v8,g,W;Zt&&(g=Zt.split("."),W=g[0]>0&&g[0]<4?1:+(g[0]+g[1])),!W&&it&&(g=it.match(/Edge\/(\d+)/),(!g||g[1]>=74)&&(g=it.match(/Chrome\/(\d+)/),g&&(W=+g[1])));var Rr=W,Qt=Rr,Lr=O,te=!!Object.getOwnPropertySymbols&&!Lr(function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Qt&&Qt<41}),_r=te,ee=_r&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Ar=f,Dr=U,Br=w,Fr=Ir,Mr=ee,zr=Ar.Object,re=Mr?function(t){return typeof t=="symbol"}:function(t){var e=Dr("Symbol");return Br(e)&&Fr(e.prototype,zr(t))},Nr=f,Kr=Nr.String,Ur=function(t){try{return Kr(t)}catch{return"Object"}},Wr=f,Gr=w,Vr=Ur,Hr=Wr.TypeError,Yr=function(t){if(Gr(t))return t;throw Hr(Vr(t)+" is not a function")},qr=Yr,Xr=function(t,e){var r=t[e];return r==null?void 0:qr(r)},Jr=f,ct=rt,lt=w,vt=L,Zr=Jr.TypeError,Qr=function(t,e){var r,n;if(e==="string"&&lt(r=t.toString)&&!vt(n=ct(r,t))||lt(r=t.valueOf)&&!vt(n=ct(r,t))||e!=="string"&&lt(r=t.toString)&&!vt(n=ct(r,t)))return n;throw Zr("Can't convert object to primitive value")},ut={exports:{}},ne=f,tn=Object.defineProperty,st=function(t,e){try{tn(ne,t,{value:e,configurable:!0,writable:!0})}catch{ne[t]=e}return e},en=f,rn=st,oe="__core-js_shared__",nn=en[oe]||rn(oe,{}),dt=nn,ae=dt;(ut.exports=function(t,e){return ae[t]||(ae[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.21.1",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE",source:"https://github.com/zloirock/core-js"});var on=f,an=Ht,cn=on.Object,ie=function(t){return cn(an(t))},ln=m,vn=ie,un=ln({}.hasOwnProperty),T=Object.hasOwn||function(e,r){return un(vn(e),r)},sn=m,dn=0,fn=Math.random(),pn=sn(1 .toString),ce=function(t){return"Symbol("+(t===void 0?"":t)+")_"+pn(++dn+fn,36)},hn=f,bn=ut.exports,le=T,yn=ce,ve=te,ue=ee,j=bn("wks"),E=hn.Symbol,se=E&&E.for,gn=ue?E:E&&E.withoutSetter||yn,de=function(t){if(!le(j,t)||!(ve||typeof j[t]=="string")){var e="Symbol."+t;ve&&le(E,t)?j[t]=E[t]:ue&&se?j[t]=se(e):j[t]=gn(e)}return j[t]},mn=f,wn=rt,fe=L,pe=re,$n=Xr,Sn=Qr,On=de,xn=mn.TypeError,Tn=On("toPrimitive"),En=function(t,e){if(!fe(t)||pe(t))return t;var r=$n(t,Tn),n;if(r){if(e===void 0&&(e="default"),n=wn(r,t,e),!fe(n)||pe(n))return n;throw xn("Can't convert object to primitive value")}return e===void 0&&(e="number"),Sn(t,e)},Cn=En,Pn=re,he=function(t){var e=Cn(t,"string");return Pn(e)?e:e+""},In=f,be=L,ft=In.document,jn=be(ft)&&be(ft.createElement),ye=function(t){return jn?ft.createElement(t):{}},kn=x,Rn=O,Ln=ye,ge=!kn&&!Rn(function(){return Object.defineProperty(Ln("div"),"a",{get:function(){return 7}}).a!=7}),_n=x,An=rt,Dn=zt,Bn=Ut,Fn=K,Mn=he,zn=T,Nn=ge,me=Object.getOwnPropertyDescriptor;et.f=_n?me:function(e,r){if(e=Fn(e),r=Mn(r),Nn)try{return me(e,r)}catch{}if(zn(e,r))return Bn(!An(Dn.f,e,r),e[r])};var _={},Kn=x,Un=O,we=Kn&&Un(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),$e=f,Wn=L,Gn=$e.String,Vn=$e.TypeError,G=function(t){if(Wn(t))return t;throw Vn(Gn(t)+" is not an object")},Hn=f,Yn=x,qn=ge,Xn=we,V=G,Se=he,Jn=Hn.TypeError,pt=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,ht="enumerable",bt="configurable",yt="writable";_.f=Yn?Xn?function(e,r,n){if(V(e),r=Se(r),V(n),typeof e=="function"&&r==="prototype"&&"value"in n&&yt in n&&!n[yt]){var o=Zn(e,r);o&&o[yt]&&(e[r]=n.value,n={configurable:bt in n?n[bt]:o[bt],enumerable:ht in n?n[ht]:o[ht],writable:!1})}return pt(e,r,n)}:pt:function(e,r,n){if(V(e),r=Se(r),V(n),qn)try{return pt(e,r,n)}catch{}if("get"in n||"set"in n)throw Jn("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var Qn=x,to=_,eo=Ut,gt=Qn?function(t,e,r){return to.f(t,e,eo(1,r))}:function(t,e,r){return t[e]=r,t},Oe={exports:{}},ro=m,no=w,mt=dt,oo=ro(Function.toString);no(mt.inspectSource)||(mt.inspectSource=function(t){return oo(t)});var xe=mt.inspectSource,ao=f,io=w,co=xe,Te=ao.WeakMap,lo=io(Te)&&/native code/.test(co(Te)),vo=ut.exports,uo=ce,Ee=vo("keys"),Ce=function(t){return Ee[t]||(Ee[t]=uo(t))},wt={},so=lo,Pe=f,$t=m,fo=L,po=gt,St=T,Ot=dt,ho=Ce,bo=wt,Ie="Object already initialized",xt=Pe.TypeError,yo=Pe.WeakMap,H,A,Y,go=function(t){return Y(t)?A(t):H(t,{})},mo=function(t){return function(e){var r;if(!fo(e)||(r=A(e)).type!==t)throw xt("Incompatible receiver, "+t+" required");return r}};if(so||Ot.state){var C=Ot.state||(Ot.state=new yo),wo=$t(C.get),je=$t(C.has),$o=$t(C.set);H=function(t,e){if(je(C,t))throw new xt(Ie);return e.facade=t,$o(C,t,e),e},A=function(t){return wo(C,t)||{}},Y=function(t){return je(C,t)}}else{var k=ho("state");bo[k]=!0,H=function(t,e){if(St(t,k))throw new xt(Ie);return e.facade=t,po(t,k,e),e},A=function(t){return St(t,k)?t[k]:{}},Y=function(t){return St(t,k)}}var So={set:H,get:A,has:Y,enforce:go,getterFor:mo},Tt=x,Oo=T,ke=Function.prototype,xo=Tt&&Object.getOwnPropertyDescriptor,Et=Oo(ke,"name"),To=Et&&function(){}.name==="something",Eo=Et&&(!Tt||Tt&&xo(ke,"name").configurable),Co={EXISTS:Et,PROPER:To,CONFIGURABLE:Eo},Po=f,Re=w,Io=T,Le=gt,jo=st,ko=xe,_e=So,Ro=Co.CONFIGURABLE,Lo=_e.get,_o=_e.enforce,Ao=String(String).split("String");(Oe.exports=function(t,e,r,n){var o=n?!!n.unsafe:!1,a=n?!!n.enumerable:!1,c=n?!!n.noTargetGet:!1,i=n&&n.name!==void 0?n.name:e,v;if(Re(r)&&(String(i).slice(0,7)==="Symbol("&&(i="["+String(i).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!Io(r,"name")||Ro&&r.name!==i)&&Le(r,"name",i),v=_o(r),v.source||(v.source=Ao.join(typeof i=="string"?i:""))),t===Po){a?t[e]=r:jo(e,r);return}else o?!c&&t[e]&&(a=!0):delete t[e];a?t[e]=r:Le(t,e,r)})(Function.prototype,"toString",function(){return Re(this)&&Lo(this).source||ko(this)});var Ae={},Do=Math.ceil,Bo=Math.floor,Ct=function(t){var e=+t;return e!==e||e===0?0:(e>0?Bo:Do)(e)},Fo=Ct,Mo=Math.max,zo=Math.min,No=function(t,e){var r=Fo(t);return r<0?Mo(r+e,0):zo(r,e)},Ko=Ct,Uo=Math.min,Wo=function(t){return t>0?Uo(Ko(t),9007199254740991):0},Go=Wo,De=function(t){return Go(t.length)},Vo=K,Ho=No,Yo=De,Be=function(t){return function(e,r,n){var o=Vo(e),a=Yo(o),c=Ho(n,a),i;if(t&&r!=r){for(;a>c;)if(i=o[c++],i!=i)return!0}else for(;a>c;c++)if((t||c in o)&&o[c]===r)return t||c||0;return!t&&-1}},qo={includes:Be(!0),indexOf:Be(!1)},Xo=m,Pt=T,Jo=K,Zo=qo.indexOf,Qo=wt,Fe=Xo([].push),Me=function(t,e){var r=Jo(t),n=0,o=[],a;for(a in r)!Pt(Qo,a)&&Pt(r,a)&&Fe(o,a);for(;e.length>n;)Pt(r,a=e[n++])&&(~Zo(o,a)||Fe(o,a));return o},It=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ta=Me,ea=It,ra=ea.concat("length","prototype");Ae.f=Object.getOwnPropertyNames||function(e){return ta(e,ra)};var ze={};ze.f=Object.getOwnPropertySymbols;var na=U,oa=m,aa=Ae,ia=ze,ca=G,la=oa([].concat),va=na("Reflect","ownKeys")||function(e){var r=aa.f(ca(e)),n=ia.f;return n?la(r,n(e)):r},Ne=T,ua=va,sa=et,da=_,fa=function(t,e,r){for(var n=ua(e),o=da.f,a=sa.f,c=0;c<n.length;c++){var i=n[c];!Ne(t,i)&&!(r&&Ne(r,i))&&o(t,i,a(e,i))}},pa=O,ha=w,ba=/#|\.prototype\./,D=function(t,e){var r=ga[ya(t)];return r==wa?!0:r==ma?!1:ha(e)?pa(e):!!e},ya=D.normalize=function(t){return String(t).replace(ba,".").toLowerCase()},ga=D.data={},ma=D.NATIVE="N",wa=D.POLYFILL="P",$a=D,jt=f,Sa=et.f,Oa=gt,xa=Oe.exports,Ta=st,Ea=fa,Ca=$a,Pa=function(t,e){var r=t.target,n=t.global,o=t.stat,a,c,i,v,h,b;if(n?c=jt:o?c=jt[r]||Ta(r,{}):c=(jt[r]||{}).prototype,c)for(i in e){if(h=e[i],t.noTargetGet?(b=Sa(c,i),v=b&&b.value):v=c[i],a=Ca(n?i:r+(o?".":"#")+i,t.forced),!a&&v!==void 0){if(typeof h==typeof v)continue;Ea(h,v)}(t.sham||v&&v.sham)&&Oa(h,"sham",!0),xa(c,i,h,t)}},Ke={},Ia=Me,ja=It,ka=Object.keys||function(e){return Ia(e,ja)},Ra=x,La=we,_a=_,Aa=G,Da=K,Ba=ka;Ke.f=Ra&&!La?Object.defineProperties:function(e,r){Aa(e);for(var n=Da(r),o=Ba(r),a=o.length,c=0,i;a>c;)_a.f(e,i=o[c++],n[i]);return e};var Fa=U,Ma=Fa("document","documentElement"),za=G,Na=Ke,Ue=It,Ka=wt,Ua=Ma,Wa=ye,Ga=Ce,We=">",Ge="<",kt="prototype",Rt="script",Ve=Ga("IE_PROTO"),Lt=function(){},He=function(t){return Ge+Rt+We+t+Ge+"/"+Rt+We},Ye=function(t){t.write(He("")),t.close();var e=t.parentWindow.Object;return t=null,e},Va=function(){var t=Wa("iframe"),e="java"+Rt+":",r;return t.style.display="none",Ua.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(He("document.F=Object")),r.close(),r.F},q,X=function(){try{q=new ActiveXObject("htmlfile")}catch{}X=typeof document!="undefined"?document.domain&&q?Ye(q):Va():Ye(q);for(var t=Ue.length;t--;)delete X[kt][Ue[t]];return X()};Ka[Ve]=!0;var Ha=Object.create||function(e,r){var n;return e!==null?(Lt[kt]=za(e),n=new Lt,Lt[kt]=null,n[Ve]=e):n=X(),r===void 0?n:Na.f(n,r)},Ya=de,qa=Ha,Xa=_,_t=Ya("unscopables"),At=Array.prototype;At[_t]==null&&Xa.f(At,_t,{configurable:!0,value:qa(null)});var Ja=function(t){At[_t][t]=!0},Za=Pa,Qa=ie,ti=De,ei=Ct,ri=Ja;Za({target:"Array",proto:!0},{at:function(e){var r=Qa(this),n=ti(r),o=ei(e),a=o>=0?o:n+o;return a<0||a>=n?void 0:r[a]}}),ri("at");var S;(function(t){t.ATTRIBUTE="attribute",t.DISTANCE="distance"})(S||(S={}));/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var Dt=function(){return Dt=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},Dt.apply(this,arguments)};function B(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,a=[],c;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(i){c={error:i}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(c)throw c.error}}return a}function qe(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,a;n<o;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))}function p(t,e){var r=document.createElement(t);return e&&ui(r,e),r}function ni(t,e){e===void 0&&(e=1e3);var r=0;return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];r+e>=Date.now()||(r=Date.now(),t.apply(this,o))}}function oi(t){var e;t===void 0&&(t=!1);var r=p("div");R(r),r.attachShadow({mode:"open"});var n=r.shadowRoot;J(r,"click");var o=document.body.cloneNode(!0),a=document.head.cloneNode(!0);return t||(ai(r),J(r,"wheel",function(){Ft("\u7981\u6B62\u9875\u9762\u6EDA\u52A8")}),P(r,`::-webkit-scrollbar{ width:0 !important; }`)),(e=o.querySelector(".".concat(Bt)))===null||e===void 0||e.remove(),o.querySelectorAll('div[class^="ewuit-comp-"]').forEach(function(c){c.remove()}),n==null||n.append(a),n==null||n.append(o),y(r,{position:"absolute",left:"0px",top:"0px",width:"100%"}),Xe(o,document.body),setTimeout(function(){y(r,{zIndex:"5000"})},500),r}function Xe(t,e){if((e==null?void 0:e.scrollTop)&&t&&(t.scrollTop=e.scrollTop,t.style.overflowY="hidden"),(e==null?void 0:e.scrollLeft)&&t&&(t.scrollLeft=e.scrollLeft,t.style.overflowX="hidden"),t!=null&&t.getAttribute("onclick")&&(t.removeAttribute("onclick"),t.onclick=function(){}),(t==null?void 0:t.tagName.toLowerCase())!=="script"&&(t==null?void 0:t.className)===(e==null?void 0:e.className)){var r=["margin","padding","border","fontSize"],n=getComputedStyle(e);r.forEach(function(c){t.style&&(t.style[c]=n[c])})}if((e==null?void 0:e.childElementCount)>0&&(t==null?void 0:t.childElementCount)>0){var o=Array.from(e.children),a=Array.from(t.children);o.forEach(function(c,i){var v=a[i];Xe(v,c)})}}function ai(t){J(t,"touchmove",function(){Ft("\u7981\u6B62\u5C4F\u5E55\u6ED1\u52A8")})}function J(t,e,r){t&&t.addEventListener(e,function(n){n.preventDefault(),typeof r=="function"&&r()},{passive:!1})}function y(t,e){t!=null&&t.style&&Object.assign(t.style,e)}function d(t,e){e===void 0&&(e="block");var r=function(n){n!=null&&n.style&&(n.style.display=e)};setTimeout(function(){[t].flat().forEach(r)})}function Je(){return document.documentElement.clientHeight}function Z(){return document.documentElement.clientWidth}function ii(t){var e;return t.childElementCount===0&&((e=t==null?void 0:t.textContent)===null||e===void 0?void 0:e.replace(/\n|\s/g,""))}function ci(t){var e=["img","image"],r=t.tagName.toLowerCase(),n=getComputedStyle(t).backgroundImage!=="none";return e.includes(r)||n}function li(t,e,r){r=Dt({pixelConversion:function(u){return"".concat(u)}},r);var n=r||{},o=n.pixelConversion,a=o===void 0?F:o,c=n.styles,i={fontSize:"\u5B57\u53F7",fontFamily:"\u5B57\u4F53",color:"\u5B57\u8272",backgroundColor:"\u80CC\u666F",borderRadius:"\u5706\u89D2",border:"\u63CF\u8FB9"},v=i[t];switch(t){case"fontFamily":break;case"color":case"backgroundColor":e=Ze("".concat(e));break;case"fontSize":case"borderRadius":e="".concat(e).split(" ").map(function(u){return a(u)}).join(" ");break;case"border":if(c){var h=c.borderWidth,b=c.borderStyle,l=c.borderColor;e="".concat(a(h)," ").concat(b," ").concat(Ze(l))}break}return{label:v,value:e}}function vi(t){return t.toString(16)}function Ze(t){t=t.replace(/[()\srgba]/g,"");var e=t.split(",").map(function(n){return+n});e.length===3&&e.push(0);var r="#".concat(e.slice(0,3).map(function(n){var o=vi(n);return o.length===1?"0".concat(o):o}).join("")," ").concat(e[3]*100,"%");return r}function P(t,e){var r=p("style");r.textContent=e,t.append(r)}function R(t){document.documentElement.append(t)}function ui(t,e){var r;if(e=[e].flat(),t instanceof Array){t.forEach(function(n){var o;(o=n.classList).add.apply(o,qe([],B(e),!1))});return}(r=t.classList).add.apply(r,qe([],B(e),!1))}function F(t,e,r){e===void 0&&(e="px"),r===void 0&&(r=Z());var n=Z();typeof t=="string"&&(t=+t.replace("px",""));var o=(t/(n/r)).toFixed(1);return"".concat(o.replace(".0","")).concat(e)}function M(t){return t.getClientRects()[0]}function si(t){var e=getComputedStyle(document.documentElement);return e.getPropertyValue(t)}function z(t,e){document.documentElement.style.setProperty(t,e,"important")}function s(t,e){return e===void 0&&(e="px"),"".concat(t).concat(e)}var di=`@charset "UTF-8"; .ewuit-ui-tool-panel { position: fixed; right: 30px; bottom: 60px; width: 40px; height: 40px; border-radius: 50%; background: rgba(0, 0, 0, 0.2); text-align: center; line-height: 40px; z-index: 9999; cursor: pointer; transition: all 0.2s ease-out; } .ewuit-ui-tool-panel::before { content: "\u{1F680}"; } .ewuit-ui-tool-panel.active { background: rgba(251, 243, 25, 0.2); } .ewuit-ui-tool-panel.active::before { content: "\u{1F389}"; } .ewuit-ui-tool-panel div { transition: all 0.2s ease-out; } .ewuit-ui-tool-panel.active .attr-btn, .ewuit-ui-tool-panel.active .distance-btn { cursor: pointer; width: 40px; height: 40px; border-radius: 50%; background: rgba(158, 158, 158, 0.3); position: absolute; bottom: 0px; } .ewuit-ui-tool-panel.active .attr-btn.active, .ewuit-ui-tool-panel.active .distance-btn.active { background-color: #1a161a; } .ewuit-ui-tool-panel.active .attr-btn.active::before, .ewuit-ui-tool-panel.active .distance-btn.active::before { color: #fff; } .ewuit-ui-tool-panel.active .attr-btn { transform: translate(-40px, -30px); } .ewuit-ui-tool-panel.active .attr-btn::before { content: "\u5C5E\u6027"; font-size: 12px; color: #000; } .ewuit-ui-tool-panel.active .distance-btn { transform: translate(-40px, 30px); } .ewuit-ui-tool-panel.active .distance-btn::before { content: "\u95F4\u8DDD"; font-size: 12px; color: #000; }`,Bt="ewuit-ui-tool-panel",Qe=function(){function t(){}return t.bindTogglePanel=function(e){var r=this,n=this.unIndependenceButtonList.reduce(function(i,v){return i[r.btnTypeMap.get(v)]=v.classList.contains("active"),i},{}),o=e.target;o.classList.toggle("active"),this.btnTypeMap.has(o)&&this.unIndependenceButtonList.forEach(function(i){i!==o&&i.classList.remove("active")});var a=this.unIndependenceButtonList.reduce(function(i,v){return i[r.btnTypeMap.get(v)]=v.classList.contains("active"),i},{}),c=Object.keys(n).reduce(function(i,v){return a[v]!==n[v]&&(i[v]=a[v]),i},{});Object.keys(c).sort(function(i,v){return c[i]-c[v]}).forEach(function(i){var v;typeof((v=r==null?void 0:r.callbackList)===null||v===void 0?void 0:v[i])=="function"&&r.callbackList[i](c[i])})},t.init=function(e){if(e===void 0&&(e={}),this.callbackList=e,!this.isExist()){this.independenceButtonList=[],this.unIndependenceButtonList=[];var r=p("div");r.classList.add(Bt),P(r,di);var n=p("div","attr-btn");this.btnTypeMap.set(n,S.ATTRIBUTE);var o=p("div","distance-btn");this.btnTypeMap.set(o,S.DISTANCE),this.unIndependenceButtonList.push(n,o),r.appendChild(n),r.appendChild(o),R(r),this.ui=r,J(r,"touchmove"),this.ui.addEventListener("click",this.bindTogglePanel.bind(this))}},t.destroy=function(){this.ui&&(this.ui.removeEventListener("click",this.bindTogglePanel.bind(this)),this.ui.remove())},t.isExist=function(){return!!document.querySelector(Bt)},t.btnTypeMap=new WeakMap,t.independenceButtonList=[],t.unIndependenceButtonList=[],t}(),fi=`.ewuit-toast-wrapper { text-align: center; position: fixed; z-index: 10000; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; } .ewuit-toast-wrapper p { display: block; padding: 20px 12px; max-width: 252px; background-color: #1a161a; border-radius: 10px; color: #ffffff; margin: 0 auto; margin-top: 46vh; font-weight: 400; font-family: var(--ewuit-font-family); font-size: var(--toast-font-size); text-align: center; transform: scale(var(--toast-scale)); } `;function pi(t,e){t===void 0&&(t=""),e===void 0&&(e=500);var r=p("div","ewuit-toast-wrapper");P(r,fi);var n=p("p");n.textContent=t,r.append(n),R(r),setTimeout(function(){r.remove()},e)}var Ft=ni(pi,500);function tr(t,e,r){typeof r!="function"&&(r=function(b){return"".concat(b)});var n=M(t),o=n.top,a=n.left,c=n.width,i=n.height;y(e,{width:s(c),height:s(i),left:s(a),top:s(o)}),e.setAttribute("data-w",r(c)),e.setAttribute("data-h",r(i));var v=Z()-50>c+a;e.style.setProperty("--ewuit-comp-cover-left",v?"auto":"-46px"),e.style.setProperty("--ewuit-comp-cover-right",v?"0":"auto");var h=o>20;e.style.setProperty("--ewuit-comp-cover-bottom",h?"auto":"20px"),e.style.setProperty("--ewuit-comp-cover-top",h?"-20px":"auto")}var hi=function(){function t(){this.clickStack=[]}return t.prototype.handle=function(e,r){var n=e.target;return this.frequentClickRemove(n,r)},t.prototype.frequentClickRemove=function(e,r){r===void 0&&(r=3),this.clickStack.push(e),this.clickStack.length===r+1&&this.clickStack.shift();var n=this.clickStack.reduce(function(o,a,c){return a===e?o+1:c!==0?o-1:o},0);return n===r-1&&Ft("\u518D\u70B9\u51FB\u4E00\u6B21\u5373\u53EF\u79FB\u9664\u6B64\u8282\u70B9",1200),n===r?(e.style.visibility="hidden",this.clear(),!1):!0},t.prototype.clear=function(){this.clickStack=[]},t}(),er=new hi,rr=`.ewuit-comp-cover { background-color: rgba( 196, 64, 255, 0.1 ); border: var(--cover-border-width) solid var(--cover-first-color); border-radius: var( --cover-attribute-border-radius ); /* \u90E8\u5206\u7B2C\u4E09\u65B9\u9875\u9762\u90E8\u5206\u5143\u7D20\u5C42\u7EA7\u975E\u5E38\u9AD8 */ position: fixed; z-index: 9999; /* \u5141\u8BB8\u4E8B\u4EF6\u7A7F\u900F\uFF0C\u8FD9\u6837\u53EF\u4EE5\u9009\u53D6\u5B50\u5143\u7D20 */ pointer-events: none; /* \u9ED8\u8BA4\u4E0D\u5C55\u793A */ display: none; box-sizing: border-box; } .ewuit-comp-cover::after, .ewuit-comp-cover::before { position: absolute; display: block; font-weight: 400; font-family: var(--ewuit-font-family); font-size: var(--cover-font-size); color: var(--cover-first-color); line-height: var(--cover-font-size); border-radius: 2px; z-index: 1; padding: 0 4px; background-color: rgba( 255, 255, 255, 0.7 ); padding: 5px; box-sizing: border-box; word-break: keep-all; pointer-events: none; } .ewuit-comp-cover::before { left: 50%; top: var(--ewuit-comp-cover-top); bottom: var( --ewuit-comp-cover-bottom ); -webkit-transform: translateX(-50%); transform: translateX(-50%); content: attr(data-w); box-sizing: border-box; } .ewuit-comp-cover::after { left: var(--ewuit-comp-cover-left); right: var(--ewuit-comp-cover-right); top: 50%; transform: translateX( calc(100% + 3px) ) translateY(-50%); content: attr(data-h); } .ewuit-comp-modal { min-width: var(--modal-max-width); max-width: var(--modal-min-width); position: fixed; /* \u6BD4\u81EA\u5DF1\u7684cover \u4F4E\u4E00\u5C42 */ z-index: 9998; left: 100px; pointer-events: none; } .ewuit-comp-wrapper { opacity: 0.95; background: #1a161a; border-radius: var( --modal-border-radius ); padding-left: var( --modal-padding-left ); padding-right: var( --modal-padding-left ); padding-top: var(--modal-padding-top); padding-bottom: var( --modal-padding-top ); float: left; } .ewuit-comp-modal p { font-weight: 400; font-family: var(--ewuit-font-family); font-size: var(--modal-font-size); color: #ffffff; padding-bottom: var( --modal-padding-top ); margin: 0; } .ewuit-comp-modal p:last-child { padding-bottom: 0; } .ewuit-comp-modal p span { margin-right: 15px; } `,bi=function(){function t(){this.initCover(),this.initAttrModal(),this.cfg={pixelConversion:F}}return t.prototype.config=function(e){return e&&Object.assign(this.cfg,e),this.cfg},t.prototype.handle=function(e){if(!er.handle(e)){this.clear();return}this.clickDom=e.target,this.refreshCover(),this.refreshModal()},t.prototype.initCover=function(){var e=p("div","ewuit-comp-cover");P(e,rr),R(e),this.coverDom=e},t.prototype.initAttrModal=function(){var e=this,r=p("div","ewuit-comp-modal");d(r,"none"),P(r,rr),r.addEventListener("click",function(){e.clear()}),R(r),this.modalDom=r},t.prototype.refreshModal=function(){var e=this,r=this.clickDom,n=getComputedStyle(r),o=M(r),a=this.cfg.pixelConversion||F,c=[],i=[];ii(r)&&(i=["fontFamily","fontSize","color"]),ci(r)&&(i=["borderRadius","border","backgroundColor"]),i.length===0&&(i=["borderRadius","border","backgroundColor"]),c=i.map(function(v){return li(v,n[v],{pixelConversion:a,styles:n})}),c.unshift({label:"\u5BBD\u9AD8",value:"".concat(a(o.width),"/").concat(a(o.height))}),this.modalDom.innerHTML=`<div class="ewuit-comp-wrapper"> `.concat(c.map(function(v){return"<p><span>".concat(v.label,":</span> ").concat(v.value,"</p>")}).join(""),` </div>`),d(this.modalDom),setTimeout(function(){var v=0,h=0,b=+si("--modal-scale")||1,l=Je(),u=Z(),$i=200*b,nr=10,or=o.left<u/2?s(o.left+v):"auto",ar=o.bottom+$i<l?s(o.bottom+nr+h):"auto",Si=or==="auto"?s(u-o.left-o.width+v):"auto",Oi=ar==="auto"?s(l-o.top+nr+h):"auto";y(e.modalDom,{left:or,top:ar,right:Si,bottom:Oi})})},t.prototype.refreshCover=function(){z("--cover-attribute-border-radius",getComputedStyle(this.clickDom).borderRadius),tr(this.clickDom,this.coverDom,this.cfg.pixelConversion),d(this.coverDom)},t.prototype.clear=function(){d(this.coverDom,"none"),d(this.modalDom,"none")},t}(),Q=new bi,yi=`div[class^='ewuit-comp-cover-'] { position: fixed; z-index: 9999; pointer-events: none; display: none; box-sizing: border-box; } div.ewuit-comp-cover-first { background-color: rgba( 196, 64, 255, 0.1 ); border: var(--cover-border-width) solid var(--cover-first-color); border-radius: var( --cover-distance-first-border-radius ); pointer-events: none; } .ewuit-comp-cover-first::after, .ewuit-comp-cover-first::before { pointer-events: none; position: absolute; display: var(--cover-size-display); font-weight: 400; font-family: var(--ewuit-font-family); font-size: var(--cover-font-size); color: var(--cover-first-color); line-height: var(--cover-font-size); border-radius: 2px; z-index: 1; padding: 0 4px; background-color: rgba( 255, 255, 255, 0.7 ); padding: 5px; box-sizing: border-box; word-break: keep-all; } .ewuit-comp-cover-first::before { left: 50%; top: var(--ewuit-comp-cover-top); bottom: var( --ewuit-comp-cover-bottom ); transform: translateX(-50%); content: attr(data-w); box-sizing: border-box; } .ewuit-comp-cover-first::after { left: var(--ewuit-comp-cover-left); right: var(--ewuit-comp-cover-right); top: 50%; transform: translateX( calc(100% + 3px) ) translateY(-50%); content: attr(data-h); } div.ewuit-comp-cover-second { background-color: rgba( 37, 144, 255, 0.1 ); border: var(--cover-border-width) solid var(--cover-second-color); border-radius: var( --cover-distance-second-border-radius ); pointer-events: none; } div.ewuit-comp-rulers { display: none; } div.ruler { position: fixed; width: 100%; height: 100%; border: var(--cover-border-width) dashed var(--cover-second-color); z-index: 9998; pointer-events: none; box-sizing: border-box; word-break: keep-all; pointer-events: none; } /* \u6C34\u5E73 */ div.ruler.h { border-left: 0; border-right: 0; left: 0; } /* \u5782\u76F4 */ div.ruler.v { border-top: 0; border-bottom: 0; top: 0; } div.distance { position: fixed; background: var(--cover-first-color); z-index: 9998; } div.distance.v { width: var(--cover-border-width); } div.distance.h { height: var(--cover-border-width); } div.distance.h::after, div.distance.v::before { pointer-events: none; word-break: keep-all; content: attr(data-v); position: absolute; font-weight: 400; font-family: var(--ewuit-font-family); font-size: var(--distance-font-size); line-height: var( --distance-font-size ); color: var(--cover-first-color); background-color: rgba( 255, 255, 255, 0.7 ); padding: 5px; display: var( --cover-distance-display ); } div.distance.h::after { left: 50%; transform: translateX(-50%); top: 4px; } div.distance.v::before { top: 50%; left: 4px; transform: translateY(-50%); } `,gi=function(){function t(){this.domStack=[],this.compDom=p("div","ewuit-comp-distance-wrapper"),R(this.compDom),P(this.compDom,yi),this.initCover(),this.initRulers(),this.initDistanceLine(),this.cfg={pixelConversion:F}}return t.prototype.config=function(e){return e&&Object.assign(this.cfg,e),this.cfg},t.prototype.initCover=function(){this.firstCover=p("div","ewuit-comp-cover-first"),this.secondCover=p("div","ewuit-comp-cover-second"),this.compDom.append(this.firstCover),this.compDom.append(this.secondCover)},t.prototype.initRulers=function(){var e=p("div","ewuit-comp-rulers"),r=p("div",["ruler","v"]),n=p("div",["ruler","h"]);this.compDom.append(e),e.append(r),e.append(n),this.rulers=e,this.vRuler=r,this.hRuler=n},t.prototype.initDistanceLine=function(){var e=p("div","ewuit-distanceWrapper"),r=p("div",["distance","v"]),n=p("div",["distance","v"]),o=p("div",["distance","h"]),a=p("div",["distance","h"]);e.append(r,n,o,a),this.compDom.append(e),this.distanceList=[r,n,o,a],this.distanceWrapper=e},t.prototype.handle=function(e){if(!er.handle(e,4)){this.clear();return}var r=e.target,n=this.domStack,o=n.at(-1)===r;o||n.push(r),o&&n.length===2&&n.shift(),n.length===3&&n.shift(),z("--cover-size-display",n.length===1?"block":"none"),z("--cover-distance-display",n.length===1?"none":"block"),this.refreshCover(),this.refreshRulers(),this.refreshDistance()},t.prototype.refreshRulers=function(){var e=this.domStack[1];if(!e){d(this.rulers,"none");return}var r=M(e),n=r.left,o=r.width,a=r.height,c=r.top;y(this.vRuler,{left:s(n),width:s(o)}),y(this.hRuler,{top:s(c),height:s(a)}),d(this.rulers)},t.prototype.refreshCover=function(){var e=B(this.domStack,2),r=e[0],n=e[1];z("--cover-distance-first-border-radius",getComputedStyle(r).borderRadius),this.updateCover(r,this.firstCover),z("--cover-distance-second-border-radius",getComputedStyle(r).borderRadius),this.updateCover(n,this.secondCover)},t.prototype.refreshDistance=function(){var e=this.cfg.pixelConversion,r=e===void 0?F:e;d(this.distanceList,"none");var n=B(this.domStack,2),o=n[0],a=n[1],c=B(this.distanceList,4),i=c[0],v=c[1],h=c[2],b=c[3];if(!!a){var l=M(o),u=M(a);l.top>u.bottom&&(i.setAttribute("data-v",r(l.top-u.bottom)),y(i,{height:s(l.top-u.bottom),left:s(l.left+l.width/2),top:s(u.bottom)}),d(i)),l.top<u.bottom&&l.top>u.top&&l.bottom<u.bottom&&(i.setAttribute("data-v",r(l.top-u.top)),y(i,{height:s(l.top-u.top),left:s(l.left+l.width/2),top:s(u.top)}),d(i)),l.left>u.right&&(h.setAttribute("data-v",r(l.left-u.right)),y(h,{width:s(l.left-u.right),left:s(u.right),top:s(l.top+l.height/2)}),d(h)),l.left<u.right&&l.left>u.left&&l.right<=u.right&&(h.setAttribute("data-v",r(l.left-u.left)),y(h,{width:s(l.left-u.left),left:s(u.left),top:s(l.top+l.height/2)}),d(h)),l.right<u.left&&(b.setAttribute("data-v",r(u.left-l.right)),y(b,{width:s(u.left-l.right),left:s(l.right),top:s(l.top+l.height/2)}),d(b)),l.right>u.left&&l.right<u.right&&l.left>=u.left&&(b.setAttribute("data-v",r(u.right-l.right)),y(b,{width:s(u.right-l.right),left:s(l.right),top:s(l.top+l.height/2)}),d(b)),l.bottom<u.top&&(v.setAttribute("data-v",r(u.top-l.bottom)),y(v,{height:s(u.top-l.bottom),left:s(l.left+l.width/2),top:s(l.bottom)}),d(v)),l.bottom>u.top&&l.bottom<u.bottom&&l.top>=u.top&&(v.setAttribute("data-v",r(u.bottom-l.bottom)),y(v,{height:s(u.bottom-l.bottom),left:s(l.left+l.width/2),top:s(l.bottom)}),d(v)),d(this.distanceWrapper)}},t.prototype.updateCover=function(e,r){if(!e){d(r,"none");return}tr(e,r,this.cfg.pixelConversion),d(r)},t.prototype.clear=function(){this.domStack=[],d(this.firstCover,"none"),d(this.secondCover,"none"),d(this.rulers,"none"),d(this.distanceWrapper,"none")},t}(),tt=new gi,mi=`:root { /* Font */ --ewuit-font-family: PingFangSC-Regular; /* Toast */ --toast-font-size: 14px; --toast-scale: 1; /* Cover */ --cover-font-size: 8px; --cover-border-width: 0.75px; --cover-first-color: #b000ff; --cover-second-color: #2590ff; --cover-size-display: none; --cover-distance-display: none; --cover-attribute-border-radius: 0; --cover-distance-first-border-radius: 0; --cover-distance-second-border-radius: 0; /* Distance Tool */ --distance-font-size: 8px; /* Attribute Tool */ --modal-font-size: 12px; --modal-min-width: 180px; --modal-max-width: 220px; --modal-border-radius: 10px; --modal-padding-left: 15px; --modal-padding-top: 12px; --modal-scale: 1; /* JS */ --ewuit-comp-cover-top: 0; --ewuit-comp-cover-bottom: 0; --ewuit-comp-cover-left: 0; --ewuit-comp-cover-right: 0; } `,wi=function(){function t(e){var r,n;this.shadowPage=null,this.options=e,P(document.documentElement,mi),Q.config((r=e==null?void 0:e.toolConfig)===null||r===void 0?void 0:r.attribute),tt.config((n=e==null?void 0:e.toolConfig)===null||n===void 0?void 0:n.distance)}return t.prototype.openUI=function(){var e=this;Qe.init({distance:function(r){e.call(S.DISTANCE,r)},attribute:function(r){e.call(S.ATTRIBUTE,r)}})},t.prototype.closeUI=function(){Qe.destroy()},t.prototype.call=function(e,r){var n,o,a;if(r===void 0&&(r=!0),r){if(this.shadowPage)return;if(this.shadowPage=oi((n=this===null||this===void 0?void 0:this.options)===null||n===void 0?void 0:n.scroll),document.body.setAttribute("hidden","true"),document.body.scrollHeight>=Je()){var c=document.body;c.setAttribute("data-overflow",c.style.overflow),c.style.overflow="hidden"}}else if(this.shadowPage){this.shadowPage.remove(),document.body.removeAttribute("hidden"),document.body.style.overflow=document.body.getAttribute("data-overflow")||"visible",this.shadowPage=null,Q.clear(),tt.clear();return}var i=(a=(o=this.shadowPage)===null||o===void 0?void 0:o.shadowRoot)===null||a===void 0?void 0:a.querySelector("body");switch(e){case S.ATTRIBUTE:i==null||i.addEventListener("click",Q.handle.bind(Q));break;case S.DISTANCE:i==null||i.addEventListener("click",tt.handle.bind(tt));break}},t}();return wi}); //# sourceMappingURL=index.min.js.map