Files
2026-06-14 14:00:24 +08:00

8 lines
11 KiB
JavaScript
Executable File

/**
* Skipped minification because the original files appears to be already minified.
* Original file: /npm/[email protected]/dist/device.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function i(t){var e=j.call(t,E),i=t[E];try{t[E]=void 0;var n=!0}catch(t){}var s=A.call(t);return n&&(e?t[E]=i:delete t[E]),s}function n(t){return _.call(t)}function s(t){return null==t?void 0===t?S:W:$&&$ in Object(t)?L(t):D(t)}function o(t){return null!=t&&"object"==typeof t}function a(t){return"symbol"==typeof t||B(t)&&U(t)==z}function r(t){if("number"==typeof t)return t;if(R(t))return F;if(g(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=g(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(H,"");var i=q.test(t);return i||G.test(t)?J(t.slice(2),i?2:8):I.test(t)?F:+t}function c(t,e,i){function n(e){var i=l,n=f;return l=f=void 0,v=e,m=t.apply(n,i)}function s(t){return v=t,b=setTimeout(r,e),y?n(t):m}function o(t){var i=t-w,n=t-v,s=e-i;return C?X(s,p-n):s}function a(t){var i=t-w,n=t-v;return void 0===w||i>=e||i<0||C&&n>=p}function r(){var t=T();if(a(t))return c(t);b=setTimeout(r,o(t))}function c(t){return b=void 0,x&&l?n(t):(l=f=void 0,m)}function h(){void 0!==b&&clearTimeout(b),v=0,l=w=f=b=void 0}function u(){return void 0===b?m:c(T())}function d(){var t=T(),i=a(t);if(l=arguments,f=this,w=t,i){if(void 0===b)return s(w);if(C)return b=setTimeout(r,e),n(w)}return void 0===b&&(b=setTimeout(r,e)),m}var l,f,p,m,b,w,v=0,y=!1,C=!1,x=!0;if("function"!=typeof t)throw new TypeError(Q);return e=K(e)||0,g(i)&&(y=!!i.leading,C="maxWait"in i,p=C?V(K(i.maxWait)||0,e):p,x="trailing"in i?!!i.trailing:x),d.cancel=h,d.flush=u,d}function h(t,e,i){var n=!0,s=!0;if("function"!=typeof t)throw new TypeError(Z);return g(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),Y(t,e,{leading:n,maxWait:e,trailing:s})}Object.defineProperty(exports,"__esModule",{value:!0});var u="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=t(function(t,e){"use strict";function i(t,e){return t.classList?!!e&&t.classList.contains(e):-1!==(" "+t.className+" ").indexOf(" "+e+" ")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i,t.exports=e.default}),l=t(function(t,e){"use strict";function i(t,e){t.classList?t.classList.add(e):(0,n.default)(t)||(t.className=t.className+" "+e)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var n=function(t){return t&&t.__esModule?t:{default:t}}(d);t.exports=e.default}),f=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s)"+e+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")},p=t(function(t,e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.hasClass=e.removeClass=e.addClass=void 0;var n=i(l),s=i(f),o=i(d);e.addClass=n.default,e.removeClass=s.default,e.hasClass=o.default,e.default={addClass:n.default,removeClass:s.default,hasClass:o.default}}),m=p.removeClass,b=p.addClass,g=e,w="object"==typeof u&&u&&u.Object===Object&&u,v=w,y="object"==typeof self&&self&&self.Object===Object&&self,C=v||y||Function("return this")(),x=C,k=function(){return x.Date.now()},T=k,O=x.Symbol,P=O,N=Object.prototype,j=N.hasOwnProperty,A=N.toString,E=P?P.toStringTag:void 0,L=i,M=Object.prototype,_=M.toString,D=n,W="[object Null]",S="[object Undefined]",$=P?P.toStringTag:void 0,U=s,B=o,z="[object Symbol]",R=a,F=NaN,H=/^\s+|\s+$/g,I=/^[-+]0x[0-9a-f]+$/i,q=/^0b[01]+$/i,G=/^0o[0-7]+$/i,J=parseInt,K=r,Q="Expected a function",V=Math.max,X=Math.min,Y=c,Z="Expected a function",tt=h,et=null,it=[],nt=function(){et&&(clearTimeout(et),et=null)},st=function(t){if(t&&it.push(t),"undefined"!=typeof document){nt();for(var e=0,i=it.length;e<i;e++)it[e](document);return void(it.length=0)}nt(),setTimeout(function(){st()},100)},ot=function(){return"undefined"!=typeof document?window.navigator.userAgent:""},at=function(t){return RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent)},rt=null,ct=function(t){var e=this;void 0===t&&(t=null),this.state={addedClasses:!1},this.matchCache={},this.featureCache={},this.classes="",this.setUserAgent(t),this.callback=null,"undefined"!=typeof document||this.userAgent||st(function(){e.setUserAgent()})},ht={features:{},deviceorientation:{},ie9:{},touchDevice:{},touch:{},ios:{},iphone:{},ipod:{},ipad:{},android:{},androidPhone:{},androidTablet:{},blackberry:{},blackberryPhone:{},blackberryTablet:{},windows:{},ie10:{},windowsPhone:{},windowsTablet:{},fxos:{},fxosPhone:{},fxosTablet:{},meego:{},cordova:{},nodeWebkit:{},mobile:{},tablet:{},desktop:{},television:{},portrait:{},landscape:{}},ut={device:{}};ut.device.get=function(){return rt||(rt=new ct),rt},ct.prototype.match=function(t){return this.matchCache[t]||(this.matchCache[t]=this.userAgent.indexOf(t)>-1),this.matchCache[t]},ct.prototype.feature=function(t){return this.featureCache[t]},ct.prototype.addFeature=function(t,e){return this.featureCache[t]||(this.featureCache[t]=e),e},ct.prototype.setUserAgent=function(t){void 0===t&&(t=null),this.userAgent=t||this.userAgent||ot(),this.userAgent&&(nt(),this.matchCache={},this.userAgent=this.userAgent.toLowerCase())},ct.prototype.onOrientationChange=function(t){},ct.prototype.getClasses=function(){return this.classes?this.classes:(this.userAgent||this.setUserAgent(),this.landscape?this.classes+="landscape ":this.classes+="portrait ",this.touch&&(this.classes+="touch "),this.ios?this.ipad?this.classes+="ios ipad tablet ":this.iphone?this.classes+="ios iphone mobile ":this.ipod&&(this.classes+="ios ipod mobile "):this.android?this.androidTablet?this.classes+="android tablet ":this.classes+="android mobile ":this.blackberry?this.blackberryTablet?this.classes+="blackberry tablet ":this.classes+="blackberry mobile ":this.windows?this.windowsTablet?this.classes+="windows tablet ":this.windowsPhone?this.classes+="windows mobile ":this.classes+="windows desktop ":this.fxos?this.fxosTablet?this.classes+="fxos tablet ":this.classes+="fxos mobile ":this.meego?this.classes+="meego mobile ":this.nodeWebkit?this.classes+="node-webkit ":this.television?this.classes+="television ":this.desktop&&(this.classes+="desktop "),this.cordova&&(this.classes+="cordova "),!this.desktop&&this.deviceorientation&&(this.classes+="deviceorientation "),this.classes=this.classes.slice(0,-1),this.classes)},ct.prototype.addClasses=function(t){if(!this.targetNode){if(this.targetNode=t,t||"undefined"==typeof document||(this.targetNode=document.documentElement),!this.targetNode)return;this.userAgent||this.setUserAgent(),this.commitClasses(),this.addListener()}},ct.prototype.addListener=function(){var t=this;if(!this.hasListener){this.hasListener=!0,this.handleOrientation=this.handleOrientation.bind(this),this.onResize=tt(this.handleOrientation,200);var e=function(){setTimeout(function(){t.handleOrientation()},10)};"onorientationchange"in window?window.addEventListener("orientationchange",e,!1):window.addEventListener("resize",this.onResize,!1),e()}},ct.prototype.handleOrientation=function(){this.onOrientationChange(this.landscape),this.targetNode&&(this.landscape?(m(this.targetNode,"portrait"),b(this.targetNode,"landscape")):(m(this.targetNode,"landscape"),b(this.targetNode,"portrait")))},ct.prototype.commitClasses=function(){!this.state.addedClasses&&this.targetNode&&(this.state.addedClasses=!0,this.targetNode.className+=this.getClasses())},ht.features.get=function(){return{wheelEvent:this.feature("wheelEvent")||this.addFeature("wheelEvent","onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll")}},ht.deviceorientation.get=function(){return this.canOrientate||(this.canOrientate="ondeviceorientation"in window||"deviceorientation"in window),!this.desktop&&this.canOrientate},ht.ie9.get=function(){return this.matchCache.ie9||"undefined"!=typeof document&&(this.matchCache.ie9=this.windows&&at(10)),this.matchCache.ie9||!1},ht.touchDevice.get=function(){return this.matchCache.touchDevice||"undefined"!=typeof document&&(this.matchCache.touchDevice=!(!navigator||!navigator.userAgent)&&navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/)),this.matchCache.touchDevice||!1},ht.touch.get=function(){return this.matchCache.touch||"undefined"!=typeof document&&(this.matchCache.touch="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch||navigator&&navigator.msMaxTouchPoints>0||navigator&&navigator.maxTouchPoints),this.matchCache.touch||!1},ht.ios.get=function(){return this.iphone||this.ipod||this.ipad},ht.iphone.get=function(){return!this.windows&&this.match("iphone")},ht.ipod.get=function(){return this.match("ipod")},ht.ipad.get=function(){return this.match("ipad")},ht.android.get=function(){return!this.windows&&this.match("android")},ht.androidPhone.get=function(){return this.android&&this.match("mobile")},ht.androidTablet.get=function(){return this.android&&!this.match("mobile")},ht.blackberry.get=function(){return this.match("blackberry")||this.match("bb10")||this.match("rim")},ht.blackberryPhone.get=function(){return this.blackberry&&!this.match("tablet")},ht.blackberryTablet.get=function(){return this.blackberry&&this.match("tablet")},ht.windows.get=function(){return this.match("windows")},ht.ie10.get=function(){return this.matchCache.ie10||"undefined"!=typeof document&&(this.matchCache.ie10=this.windows&&at(10)),this.matchCache.ie10||!1},ht.windowsPhone.get=function(){return this.windows&&this.match("phone")},ht.windowsTablet.get=function(){return this.windows&&this.match("touch")&&!this.windowsPhone},ht.fxos.get=function(){return(this.match("(mobile;")||this.match("(tablet;"))&&this.match("; rv:")},ht.fxosPhone.get=function(){return this.fxos&&this.match("mobile")},ht.fxosTablet.get=function(){return this.fxos&&this.match("tablet")},ht.meego.get=function(){return this.match("meego")},ht.cordova.get=function(){return window.cordova&&"file:"===location.protocol},ht.nodeWebkit.get=function(){return"object"==typeof window.process},ht.mobile.get=function(){return this.androidPhone||this.iphone||this.ipod||this.windowsPhone||this.blackberryPhone||this.fxosPhone||this.meego},ht.tablet.get=function(){return this.ipad||this.androidTablet||this.blackberryTablet||this.windowsTablet||this.fxosTablet},ht.desktop.get=function(){return!this.tablet&&!this.mobile},ht.television.get=function(){var t,e=this,i=["googletv","viera","smarttv","internet.tv","netcast","nettv","appletv","boxee","kylo","roku","dlnadoc","roku","pov_tv","hbbtv","ce-html"];for(t=0;t++<i.length;)if(e.match(i[t]))return!0;return!1},ht.portrait.get=function(){return"orientation"in window?0===window.orientation:"undefined"!=typeof window&&window.innerHeight/window.innerWidth>1},ht.landscape.get=function(){return"undefined"!=typeof window&&("orientation"in window?0!==window.orientation:window.innerHeight/window.innerWidth<1)},Object.defineProperties(ct.prototype,ht),Object.defineProperties(ct,ut);var dt=new ct;exports.device=dt,exports.default=ct;
//# sourceMappingURL=device.js.map