UNPKG

on-screen-keyboard-detector

Version:

Detects presence of the On-Screen-Keyboard in mobile browsers

19 lines (18 loc) 27.8 kB
/* @license On-screen keyboard detector (OSKD) v.2.3.0 (c) 2020-2021 Matthias Seemann OSKD may be freely distributed under the MIT license. */ function t(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function n(n){return function e(i){return 0===arguments.length||t(i)?e:n.apply(this,arguments)}}function e(e){return function i(r,s){switch(arguments.length){case 0:return i;case 1:return t(r)?i:n((function(t){return e(r,t)}));default:return t(r)&&t(s)?i:t(r)?n((function(t){return e(t,s)})):t(s)?n((function(t){return e(r,t)})):e(r,s)}}}function i(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(t){return n.apply(this,arguments)};case 2:return function(t,e){return n.apply(this,arguments)};case 3:return function(t,e,i){return n.apply(this,arguments)};case 4:return function(t,e,i,r){return n.apply(this,arguments)};case 5:return function(t,e,i,r,s){return n.apply(this,arguments)};case 6:return function(t,e,i,r,s,o){return n.apply(this,arguments)};case 7:return function(t,e,i,r,s,o,u){return n.apply(this,arguments)};case 8:return function(t,e,i,r,s,o,u,c){return n.apply(this,arguments)};case 9:return function(t,e,i,r,s,o,u,c,h){return n.apply(this,arguments)};case 10:return function(t,e,i,r,s,o,u,c,h,f){return n.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function r(i){return function r(s,o,u){switch(arguments.length){case 0:return r;case 1:return t(s)?r:e((function(t,n){return i(s,t,n)}));case 2:return t(s)&&t(o)?r:t(s)?e((function(t,n){return i(t,o,n)})):t(o)?e((function(t,n){return i(s,t,n)})):n((function(t){return i(s,o,t)}));default:return t(s)&&t(o)&&t(u)?r:t(s)&&t(o)?e((function(t,n){return i(t,n,u)})):t(s)&&t(u)?e((function(t,n){return i(t,o,n)})):t(o)&&t(u)?e((function(t,n){return i(s,t,n)})):t(s)?n((function(t){return i(t,o,u)})):t(o)?n((function(t){return i(s,t,u)})):t(u)?n((function(t){return i(s,o,t)})):i(s,o,u)}}}var s=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};var o=n((function(t){return!!s(t)||!!t&&("object"==typeof t&&(!function(t){return"[object String]"===Object.prototype.toString.call(t)}(t)&&(1===t.nodeType?!!t.length:0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),u=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)},t}();var c=e((function(t,n){return i(t.length,(function(){return t.apply(n,arguments)}))}));function h(t,n,e){for(var i=e.next();!i.done;){if((n=t["@@transducer/step"](n,i.value))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}i=e.next()}return t["@@transducer/result"](n)}function f(t,n,e,i){return t["@@transducer/result"](e[i](c(t["@@transducer/step"],t),n))}var a="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function p(t,n,e){if("function"==typeof t&&(t=function(t){return new u(t)}(t)),o(e))return function(t,n,e){for(var i=0,r=e.length;i<r;){if((n=t["@@transducer/step"](n,e[i]))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}i+=1}return t["@@transducer/result"](n)}(t,n,e);if("function"==typeof e["fantasy-land/reduce"])return f(t,n,e,"fantasy-land/reduce");if(null!=e[a])return h(t,n,e[a]());if("function"==typeof e.next)return h(t,n,e);if("function"==typeof e.reduce)return f(t,n,e,"reduce");throw new TypeError("reduce: list must be array or iterable")}var l=r(p);function v(t,n){return function(){return n.call(this,t.apply(this,arguments))}}function d(t,n){return function(){var e=arguments.length;if(0===e)return n();var i=arguments[e-1];return s(i)||"function"!=typeof i[t]?n.apply(this,arguments):i[t].apply(i,Array.prototype.slice.call(arguments,0,e-1))}}var y=n(d("tail",r(d("slice",(function(t,n,e){return Array.prototype.slice.call(e,t,n)})))(1,1/0)));var k=function(t,n,e){return void 0===e&&(e=!1),new g(t,n,e)},m=function(t,n){return void 0===n&&(n=!1),k("resize",t,n)},w=function(t,n){return void 0===n&&(n=!1),k("scroll",t,n)},g=function(t,n,e){this.event=t,this.node=n,this.capture=e}; /** @license MIT License (c) copyright 2015-2016 original author or authors */g.prototype.run=function(t,n){var e=this,i=function(e){return function(t,n,e){try{e.event(t,n)}catch(n){e.error(t,n)}} /** @license MIT License (c) copyright 2010-2016 original author or authors */(n.currentTime(),e,t)};return this.node.addEventListener(this.event,i,this.capture),{dispose:function(){return e.node.removeEventListener(e.event,i,e.capture)}}};function b(t){return function n(e,i){switch(arguments.length){case 0:return n;case 1:return function(n){return t(e,n)};default:return t(e,i)}}}var _,T=function(){function t(t,n){this.origin=t,this.scheduler=n}return t.prototype.currentTime=function(){return this.scheduler.currentTime()-this.origin},t.prototype.scheduleTask=function(t,n,e,i){return this.scheduler.scheduleTask(t+this.origin,n,e,i)},t.prototype.relative=function(n){return new t(n+this.origin,this.scheduler)},t.prototype.cancel=function(t){return this.scheduler.cancel(t)},t.prototype.cancelAll=function(t){return this.scheduler.cancelAll(t)},t}(),A=b((function(t,n){return n.scheduleTask(0,0,-1,t)})),x=(_=function(t,n,e){return e.scheduleTask(0,t,-1,n)},function t(n,e,i){switch(arguments.length){case 0:return t;case 1:return b((function(t,e){return _(n,t,e)}));case 2:return function(t){return _(n,e,t)};default:return _(n,e,i)}}),E=function(t){return t.dispose()},O=b((function(t,n){return new T(t,n)}));function V(t,n,e){for(var i=n,r=0,s=e.length;r<s;++r)i=t(i,e[r],r);return i}function S(t){return function n(e,i){switch(arguments.length){case 0:return n;case 1:return function(n){return t(e,n)};default:return t(e,i)}}}var R=new(function(){function t(){}return t.prototype.dispose=function(){},t}()),j=function(t){return new N(t)},N=function(){function t(t){this.disposed=!1,this.disposable=t}return t.prototype.dispose=function(){this.disposed||(this.disposed=!0,this.disposable&&(this.disposable.dispose(),this.disposable=void 0))},t}(),D=function(t){var n=V(q,[],t);return 0===n.length?R:new I(n)},P=S((function(t,n){return D([t,n])})),q=function(t,n){return function(t){return t===R}(n)?t:n instanceof I?function(t,n){var e=t.length,i=n.length,r=new Array(e+i),s=0;for(s=0;s<e;s++)r[s]=t[s];for(var o=0;o<i;o++)r[s++]=n[o];return r}(t,n.disposables): /** @license MIT License (c) copyright 2010-2016 original author or authors */ function(t,n){for(var e=n.length,i=new Array(e+1),r=0;r<e;++r)i[r]=n[r];return i[e]=t,i}(n,t)},I=function(){function t(t){this.disposables=t}return t.prototype.dispose=function(){F(C(this.disposables))},t}(),C=function(t){return V(M,[],t)},M=function(t,n){try{n.dispose()}catch(n){t.push(n)}return t},F=function(t){if(t.length>0)throw new B(t.length+" errors",t)},B=function t(n,e){this.name="DisposeAllError",this.message=n,this.errors=e,Error.call(this,n),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.stack=""+this.stack+H(this.errors)};B.prototype=Object.create(Error.prototype);var H=function(t){return V(L,"",t)},L=function(t,n,e){return t+"\n["+(e+1)+"] "+n.stack},z=function(t){return function n(e,i,r){switch(arguments.length){case 0:return n;case 1:return S((function(n,i){return t(e,n,i)}));case 2:return function(n){return t(e,i,n)};default:return t(e,i,r)}}}((function(t,n,e){try{n.dispose()}catch(n){e.error(t,n)}})),K=function(t,n){return(K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function W(t,n){function e(){this.constructor=t}K(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)} /** @license MIT License (c) copyright 2010-2016 original author or authors */function X(t){throw t}var G=function(t){return new U(t)},J=function(){function t(t){this.sink=t,this.active=!0}return t.prototype.dispose=function(){this.active=!1},t.prototype.run=function(t){this.active&&this.runIfActive(t)},t.prototype.error=function(t,n){if(!this.active)return function(t){setTimeout(X,0,t)}(n);this.sink.error(t,n)},t}(),Q=(function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.runEvent=n,r.value=e,r}W(n,t),n.prototype.runIfActive=function(t){this.runEvent(t,this.value,this.sink)}}(J),function(t){function n(n,e){var i=t.call(this,e)||this;return i.value=n,i}return W(n,t),n.prototype.runIfActive=function(t){this.sink.event(t,this.value)},n}(J)),U=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return W(n,t),n.prototype.runIfActive=function(t){this.sink.end(t)},n}(J),Y=(function(t){function n(n,e){var i=t.call(this,e)||this;return i.value=n,i}W(n,t),n.prototype.runIfActive=function(t){this.sink.error(t,this.value)}}(J),function(){return $}),Z=function(t){return t===$},$=new(function(){function t(){}return t.prototype.run=function(t,n){return A(G(t),n)},t}()),tt=function(){function t(){this.disposable=void 0,this.disposed=!1}return t.prototype.setDisposable=function(t){if(void 0!==this.disposable)throw new Error("setDisposable called more than once");this.disposable=t,this.disposed&&t.dispose()},t.prototype.dispose=function(){this.disposed||(this.disposed=!0,void 0!==this.disposable&&this.disposable.dispose())},t}(),nt=b((function(t,n){return new Promise((function(e,i){return function(t,n,e,i){var r=new tt,s=new et(e,i,r);r.setDisposable(t.run(s,n))}(t,n,e,i)}))}));var et=function(){function t(t,n,e){this._end=t,this._error=n,this._disposable=e,this.active=!0}return t.prototype.event=function(){},t.prototype.end=function(){this.active&&this.dispose(this._error,this._end,void 0)},t.prototype.error=function(t,n){this.dispose(this._error,this._error,n)},t.prototype.dispose=function(t,n,e){this.active=!1,function(t,n,e,i){try{i.dispose()}catch(n){return void t(n)}n(e)}(t,n,e,this._disposable)},t}();var it=function(){function t(t,n){this.sink=n,this.offset=t}return t.prototype.event=function(t,n){this.sink.event(t+this.offset,n)},t.prototype.error=function(t,n){this.sink.error(t+this.offset,n)},t.prototype.end=function(t){this.sink.end(t+this.offset)},t}(),rt=function(){function t(t,n){this.origin=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(st(this.origin,t),O(this.origin,n))},t}(),st=function(t,n){return n instanceof it?new it(t+n.offset,n.sink):new it(t,n)},ot=function(){function t(t){this.sink=t}return t.prototype.end=function(t){return this.sink.end(t)},t.prototype.error=function(t,n){return this.sink.error(t,n)},t}(),ut=(function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.step=n,r.seed=e,r}W(n,t),n.prototype.event=function(t,n){var e=this.step(this.seed,n);this.seed=e.seed,this.sink.event(t,e.value)}}(ot),function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.f=n,r.value=e,r}W(n,t),n.prototype.event=function(t,n){var e=this.f;this.value=e(this.value,n),this.sink.event(t,this.value)}}(ot),function(t){function n(n,e,i,r){var s=t.call(this,i)||this;return s.f=n,s.scheduler=r,s.active=!0,s.disposable=j(e.run(s,r)),s}W(n,t),n.prototype.event=function(t,n){this.active&&this.sink.event(t,n)},n.prototype.end=function(t){this.active&&(z(t,this.disposable,this.sink),this.startNext(t,this.sink))},n.prototype.startNext=function(t,n){try{this.disposable=this.continue(this.f,t,n)}catch(e){n.error(t,e)}},n.prototype.continue=function(t,n,e){return function(t,n,e){return e.run(t,n)}(e,this.scheduler,(i=n,r=t(),new rt(i,r)));var i,r},n.prototype.dispose=function(){return this.active=!1,this.disposable.dispose()}}(ot),function(){function t(t,n){this.p=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new ct(this.p,t),n)},t.create=function(n,e){return Z(e)?e:e instanceof t?new t(ht(e.p,n),e.source):new t(n,e)},t}()),ct=function(t){function n(n,e){var i=t.call(this,e)||this;return i.p=n,i}return W(n,t),n.prototype.event=function(t,n){(0,this.p)(n)&&this.sink.event(t,n)},n}(ot),ht=function(t,n){return function(e){return t(e)&&n(e)}},ft=function(){function t(t,n,e){this.p=t,this.f=n,this.source=e}return t.prototype.run=function(t,n){return this.source.run(new at(this.p,this.f,t),n)},t}(),at=function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.p=n,r.f=e,r}return W(n,t),n.prototype.event=function(t,n){var e=this.f;(0,this.p)(n)&&this.sink.event(t,e(n))},n}(ot),pt=function(){function t(t,n){this.f=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new lt(this.f,t),n)},t.create=function(n,e){return Z(e)?Y():e instanceof t?new t(function(t,n){return function(e){return t(n(e))}}(n,e.f),e.source):e instanceof ut?new ft(e.p,n,e.source):new t(n,e)},t}(),lt=function(t){function n(n,e){var i=t.call(this,e)||this;return i.f=n,i}return W(n,t),n.prototype.event=function(t,n){var e=this.f;this.sink.event(t,e(n))},n}(ot),vt=function(){function t(t,n){this.source=n,this.f=t}return t.prototype.run=function(t,n){return this.source.run(new dt(this.f,t),n)},t}(),dt=function(t){function n(n,e){var i=t.call(this,e)||this;return i.f=n,i}return W(n,t),n.prototype.event=function(t,n){(0,this.f)(n),this.sink.event(t,n)},n}(ot),yt=function(t){function n(n,e){var i=t.call(this,e)||this;return i.index=n,i.active=!0,i.value=void 0,i}return W(n,t),n.prototype.event=function(t,n){this.active&&(this.value=n,this.sink.event(t,this))},n.prototype.end=function(t){this.active&&(this.active=!1,this.sink.event(t,this))},n}(ot); /** @license MIT License (c) copyright 2010-2016 original author or authors */ function kt(t,n){switch(n.length){case 0:return t();case 1:return t(n[0]);case 2:return t(n[0],n[1]);case 3:return t(n[0],n[1],n[2]);case 4:return t(n[0],n[1],n[2],n[3]);case 5:return t(n[0],n[1],n[2],n[3],n[4]);default:return t.apply(void 0,n)}}!function(t){function n(n,e,i,r){var s=t.call(this,i)||this;return s.disposables=n,s.f=r,s.awaiting=e,s.values=new Array(e),s.hasValue=new Array(e).fill(!1),s.activeCount=e,s}W(n,t),n.prototype.event=function(t,n){if(n.active){var e=n.index,i=this.updateReady(e);this.values[e]=n.value,0===i&&this.sink.event(t,kt(this.f,this.values))}else this.dispose(t,n.index)},n.prototype.updateReady=function(t){return this.awaiting>0&&(this.hasValue[t]||(this.hasValue[t]=!0,this.awaiting-=1)),this.awaiting},n.prototype.dispose=function(t,n){z(t,this.disposables[n],this.sink),0==--this.activeCount&&this.sink.end(t)}}(ot);var mt=function(t){return wt(gt(t))},wt=function(t){return 0===t.length?Y():1===t.length?t[0]:new Tt(function(t,n,e){for(var i=n,r=0,s=e.length;r<s;++r)i=t(i,e[r],r);return i}(_t,[],t))},gt=function(t){return t.filter(bt)},bt=function(t){return!Z(t)},_t=function(t,n){return t.concat(n instanceof Tt?n.sources:n)},Tt=function(){function t(t){this.sources=t}return t.prototype.run=function(t,n){for(var e=this.sources.length,i=new Array(e),r=new Array(e),s=new At(i,r,t),o=void 0,u=0;u<e;++u)o=r[u]=new yt(u,s),i[u]=this.sources[u].run(o,n);return D(i)},t}(),At=function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.disposables=n,r.activeCount=e.length,r}return W(n,t),n.prototype.event=function(t,n){n.active?this.sink.event(t,n.value):this.dispose(t,n.index)},n.prototype.dispose=function(t,n){z(t,this.disposables[n],this.sink),0==--this.activeCount&&this.sink.end(t)},n}(ot),xt=(function(t){function n(n,e){var i=t.call(this,e)||this;return i.f=n,i.latest=new xt(i),i}W(n,t),n.prototype.event=function(t,n){if(this.latest.hasValue){var e=this.f;this.sink.event(t,e(this.latest.value,n))}}}(ot),function(t){function n(n){var e=t.call(this,n)||this;return e.hasValue=!1,e}return W(n,t),n.prototype.event=function(t,n){this.value=n,this.hasValue=!0},n.prototype.end=function(){},n}(ot)),Et=(function(t){function n(n,e,i,r){var s=t.call(this,i)||this;return s.skip=n,s.take=e,s.disposable=r,s}W(n,t),n.prototype.event=function(t,n){this.skip>0?this.skip-=1:0!==this.take&&(this.take-=1,this.sink.event(t,n),0===this.take&&(this.disposable.dispose(),this.sink.end(t)))}}(ot),function(t){function n(n,e,i){var r=t.call(this,e)||this;return r.p=n,r.active=!0,r.disposable=i,r}W(n,t),n.prototype.event=function(t,n){if(this.active){var e=this.p;this.active=e(n),this.active?this.sink.event(t,n):(this.disposable.dispose(),this.sink.end(t))}}}(ot),function(t){function n(n,e){var i=t.call(this,e)||this;return i.p=n,i.skipping=!0,i}W(n,t),n.prototype.event=function(t,n){if(this.skipping){var e=this.p;if(this.skipping=e(n),this.skipping)return}this.sink.event(t,n)}}(ot),function(t){function n(n,e){var i=t.call(this,e)||this;return i.p=n,i.skipping=!1,i}W(n,t),n.prototype.event=function(t,n){if(!this.skipping){var e=this.p;this.skipping=e(n),this.sink.event(t,n),this.skipping&&this.sink.end(t)}}}(ot),function(t){function n(n,e,i){var r=t.call(this,i)||this;return r.f=n,r.items=e,r.index=0,r}W(n,t),n.prototype.event=function(t,n){var e=this.f;this.sink.event(t,e(this.items[this.index],n)),this.index+=1}}(ot),function(t){function n(n,e,i,r){var s=t.call(this,r)||this;return s.f=n,s.sinks=i,s.buffers=e,s}W(n,t),n.prototype.event=function(t,n){if(n.active){var e=this.buffers,i=e[n.index];if(i.push(n.value),1===i.length()){if(!function(t){for(var n=0,e=t.length;n<e;++n)if(t[n].isEmpty())return!1;return!0}(e))return;Et(this.f,t,e,this.sink),function(t,n){for(var e=0,i=t.length;e<i;++e)if(t[e].isEmpty()&&!n[e].active)return!0;return!1}(this.buffers,this.sinks)&&this.sink.end(t)}}else this.dispose(t,n.index)},n.prototype.dispose=function(t,n){this.buffers[n].isEmpty()&&this.sink.end(t)}}(ot),function(t,n,e,i){return i.event(n,kt(t,function(t,n){for(var e=n.length,i=new Array(e),r=0;r<e;++r)i[r]=t(n[r]);return i}(Ot,e)))}),Ot=function(t){return t.shift()};var Vt=function(t){return St(Nt,t)},St=function(t,n){return Z(n)?Y():new Rt(t,n)},Rt=function(){function t(t,n){this.equals=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new jt(this.equals,t),n)},t}(),jt=function(t){function n(n,e){var i=t.call(this,e)||this;return i.equals=n,i.value=void 0,i.init=!0,i}return W(n,t),n.prototype.event=function(t,n){this.init?(this.init=!1,this.value=n,this.sink.event(t,n)):this.equals(this.value,n)||(this.value=n,this.sink.event(t,n))},n}(ot);function Nt(t,n){return t===n} /** @license MIT License (c) copyright 2010-2016 original author or authors */var Dt=function(){function t(t,n){this.maxSignal=t,this.source=n}return t.prototype.run=function(t,n){var e=new tt,i=this.source.run(t,n),r=this.maxSignal.run(new Pt(t,e),n);return e.setDisposable(P(i,r)),e},t}(),Pt=(function(t){function n(n,e){var i=t.call(this,e)||this;return i.min=n,i}W(n,t),n.prototype.event=function(t,n){this.min.allow&&this.sink.event(t,n)}}(ot),function(t){function n(n,e,i){var r=t.call(this,e)||this;return r.allow=!1,r.disposable=n.run(r,i),r}W(n,t),n.prototype.event=function(){this.allow=!0,this.dispose()},n.prototype.end=function(){},n.prototype.dispose=function(){this.disposable.dispose()}}(ot),function(t){function n(n,e){var i=t.call(this,n)||this;return i.disposable=e,i}return W(n,t),n.prototype.event=function(t){this.disposable.dispose(),this.sink.end(t)},n.prototype.end=function(){},n}(ot)),qt=(function(t){function n(n,e,i){var r=t.call(this,e)||this;return r.dt=n,r.scheduler=i,r.tasks=[],r}W(n,t),n.prototype.dispose=function(){this.tasks.forEach(E)},n.prototype.event=function(t,n){var e,i;this.tasks.push(x(this.dt,(e=n,i=this.sink,new Q(e,i)),this.scheduler))},n.prototype.end=function(){this.tasks.push(x(this.dt,G(this.sink),this.scheduler))}}(ot),function(t){function n(n,e){var i=t.call(this,e)||this;return i.time=0,i.period=n,i}W(n,t),n.prototype.event=function(t,n){t>=this.time&&(this.time=t+this.period,this.sink.event(t,n))}}(ot),function(){function t(t,n){this.dt=t,this.source=n}return t.prototype.run=function(t,n){return new It(this.dt,this.source,t,n)},t}()),It=function(){function t(t,n,e,i){this.dt=t,this.sink=e,this.scheduler=i,this.timer=null,this.disposable=n.run(this,i)}return t.prototype.event=function(t,n){this.clearTimer(),this.value=n,this.timer=x(this.dt,new Ct(this,n),this.scheduler)},t.prototype.handleEventFromTask=function(t,n){this.clearTimer(),this.sink.event(t,n)},t.prototype.end=function(t){this.clearTimer()&&(this.sink.event(t,this.value),this.value=void 0),this.sink.end(t)},t.prototype.error=function(t,n){this.clearTimer(),this.sink.error(t,n)},t.prototype.dispose=function(){this.clearTimer(),this.disposable.dispose()},t.prototype.clearTimer=function(){return null!==this.timer&&(this.timer.dispose(),this.timer=null,!0)},t}(),Ct=function(){function t(t,n){this.sink=t,this.value=n}return t.prototype.run=function(t){this.sink.handleEventFromTask(t,this.value)},t.prototype.error=function(t,n){this.sink.error(t,n)},t.prototype.dispose=function(){},t}(),Mt=b((function(t,n){return pt.create(t,n)})),Ft=b((function(t,n){return new vt(t,n)})),Bt=b((function(t,n){return new Dt(t,n)})),Ht=b((function(t,n){return Z(n)?Y():new qt(t,n)})),Lt=function(){var t=[];return[function(n){return zt(t,n)},new Kt(t)]},zt=function(t,n){return t.forEach((function(t){var e=t.sink;return function(t,n,e){try{e.event(t,n)}catch(n){e.error(t,n)}} /** @license MIT License (c) copyright 2010-2016 original author or authors */(t.scheduler.currentTime(),n,e)}))},Kt=function(){function t(t){this.sinks=t}return t.prototype.run=function(t,n){var e={sink:t,scheduler:n};return this.sinks.push(e),new Wt(e,this.sinks)},t}(),Wt=function(){function t(t,n){this.sink=t,this.sinks=n}return t.prototype.dispose=function(){var t=this.sinks.indexOf(this.sink);t>=0&&this.sinks.splice(t,1)},t}();var Xt=function(){function t(t,n,e,i,r){this.time=t,this.localOffset=n,this.period=e,this.task=i,this.scheduler=r,this.active=!0}return t.prototype.run=function(){return this.task.run(this.time-this.localOffset)},t.prototype.error=function(t){return this.task.error(this.time-this.localOffset,t)},t.prototype.dispose=function(){return this.active=!1,this.scheduler.cancel(this),this.task.dispose()},t}(),Gt=function(){function t(t,n){this.origin=t,this.scheduler=n}return t.prototype.currentTime=function(){return this.scheduler.currentTime()-this.origin},t.prototype.scheduleTask=function(t,n,e,i){return this.scheduler.scheduleTask(t+this.origin,n,e,i)},t.prototype.relative=function(n){return new t(n+this.origin,this.scheduler)},t.prototype.cancel=function(t){return this.scheduler.cancel(t)},t.prototype.cancelAll=function(t){return this.scheduler.cancelAll(t)},t}(),Jt=function(t){return Promise.resolve(t).then(Qt)};function Qt(t){try{return t.run()}catch(n){return t.error(n)}} /** @license MIT License (c) copyright 2010-2017 original author or authors */var Ut=function(){function t(t,n){var e=this;this._runReadyTasksBound=function(){return e._runReadyTasks()},this.timer=t,this.timeline=n,this._timer=null,this._nextArrival=1/0}return t.prototype.currentTime=function(){return this.timer.now()},t.prototype.scheduleTask=function(t,n,e,i){var r=this.currentTime()+Math.max(0,n),s=new Xt(r,t,e,i,this);return this.timeline.add(s),this._scheduleNextRun(),s},t.prototype.relative=function(t){return new Gt(t,this)},t.prototype.cancel=function(t){t.active=!1,this.timeline.remove(t)&&this._reschedule()},t.prototype.cancelAll=function(t){this.timeline.removeAll(t),this._reschedule()},t.prototype._reschedule=function(){this.timeline.isEmpty()?this._unschedule():this._scheduleNextRun()},t.prototype._unschedule=function(){this.timer.clearTimer(this._timer),this._timer=null},t.prototype._scheduleNextRun=function(){if(!this.timeline.isEmpty()){var t=this.timeline.nextArrival();null===this._timer?this._scheduleNextArrival(t):t<this._nextArrival&&(this._unschedule(),this._scheduleNextArrival(t))}},t.prototype._scheduleNextArrival=function(t){this._nextArrival=t;var n=Math.max(0,t-this.currentTime());this._timer=this.timer.setTimer(this._runReadyTasksBound,n)},t.prototype._runReadyTasks=function(){this._timer=null,this.timeline.runTasks(this.currentTime(),Qt),this._scheduleNextRun()},t}(),Yt=function(){function t(){this.tasks=[]}return t.prototype.nextArrival=function(){return this.isEmpty()?1/0:this.tasks[0].time},t.prototype.isEmpty=function(){return 0===this.tasks.length},t.prototype.add=function(t){$t(t,this.tasks)},t.prototype.remove=function(t){var n=en(tn(t),this.tasks);if(n>=0&&n<this.tasks.length){var e=this.tasks[n].events,i=function(t,n){for(var e=0,i=n.length;e<i;++e)if(t===n[e])return e;return-1}(t,e);if(i>=0)return e.splice(i,1),0===e.length&&this.tasks.splice(n,1),!0}return!1},t.prototype.removeAll=function(t){for(var n=0;n<this.tasks.length;++n)nn(t,this.tasks[n])},t.prototype.runTasks=function(t,n){for(var e=this.tasks,i=e.length,r=0;r<i&&e[r].time<=t;)++r;this.tasks=e.slice(r);for(var s=0;s<r;++s)this.tasks=Zt(n,e[s].events,this.tasks)},t}(); /** @license MIT License (c) copyright 2010-2017 original author or authors */function Zt(t,n,e){for(var i=0;i<n.length;++i){var r=n[i];r.active&&(t(r),r.period>=0&&r.active&&(r.time=r.time+r.period,$t(r,e)))}return e}function $t(t,n){var e=n.length,i=tn(t);if(0!==e){var r=en(i,n);r>=e?n.push(rn(i,[t])):function(t,n,e,i){var r=n[i];e===r.time?function(t,n){0===n.length||t.time>=n[n.length-1].time?n.push(t):function(t,n){for(var e=0;e<n.length;e++)if(t.time<n[e].time){n.splice(e,0,t);break}}(t,n)}(t,r.events):n.splice(i,0,rn(e,[t]))}(t,n,i,r)}else n.push(rn(i,[t]))}function tn(t){return Math.floor(t.time)}function nn(t,n){n.events=function(t,n){for(var e=n.length,i=new Array(e),r=0,s=void 0,o=0;o<e;++o)t(s=n[o])||(i[r]=s,++r);return i.length=r,i}(t,n.events)}function en(t,n){for(var e,i,r=0,s=n.length;r<s;){if(t===(i=n[e=Math.floor((r+s)/2)]).time)return e;t<i.time?s=e:r=e+1}return s}var rn=function(t,n){return{time:t,events:n}},sn=function(){function t(t){this._clock=t}return t.prototype.now=function(){return this._clock.now()},t.prototype.setTimer=function(t,n){return n<=0?function(t){var n=new on(t);return Jt(n),n}(t):setTimeout(t,n)},t.prototype.clearTimer=function(t){return t instanceof on?t.cancel():clearTimeout(t)},t}(),on=function(){function t(t){this.f=t,this.active=!0}return t.prototype.run=function(){if(this.active)return this.f()},t.prototype.error=function(t){throw t},t.prototype.cancel=function(){this.active=!1},t}(); /** @license MIT License (c) copyright 2010-2017 original author or authors */var un=function(){function t(t,n){this.origin=n,this.clock=t}return t.prototype.now=function(){return this.clock.now()-this.origin},t}(),cn=function(){function t(t,n){this.origin=n,this.hrtime=t}return t.prototype.now=function(){var t=this.hrtime(this.origin);return(1e9*t[0]+t[1])/1e6},t}(),hn=function(t){return new un(t,t.now())},fn=function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?hn(performance):"undefined"!=typeof process&&"function"==typeof process.hrtime?new cn(process.hrtime,process.hrtime()):hn(Date)},an=function(){return new Ut(pn(),new Yt)},pn=function(){return new sn(fn())};const ln="visualViewport"in window;function vn(){return ln}function dn(t){if(!vn())return console.warn("On-Screen-Keyboard detection not supported on this version of iOS"),()=>void 0;const[n,e]=Lt(),r=an(),s=function(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return i(arguments[0].length,l(v,arguments[0],y(arguments)))}(()=>mt([w(visualViewport),m(visualViewport),w(window)]),Ht(800),Ft(()=>{console.log(visualViewport.height*visualViewport.scale/document.documentElement.clientHeight)}),Mt(()=>visualViewport.height*visualViewport.scale/document.documentElement.clientHeight<.85),Vt,Mt(t=>t?"visible":"hidden"),Bt(e))();return nt(Ft(t,s),r),n}export{vn as isSupported,dn as subscribe};