const e="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),t="undefined"!=typeof uni&&"undefined"==typeof window,n=e||t,o="undefined"!=typeof uni,r=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:o?uni:"undefined"!=typeof window?window:{},s=r&&window&&window.navigator&&window.navigator.userAgent||"",c=/Android/i.test(s),l=/(?:Windows Phone)/.test(s),a=/(?:SymbianOS)/.test(s),u=/OpenHarmony/i.test(s),d=r&&("ontouchstart"in window||navigator.maxTouchPoints>0)&&function(){if(r){if(/Tablet|Pad/i.test(s))return!0;if(180===window.orientation||0===window.orientation)return window.innerWidth>=768&&window.innerHeight>=1024;if(90===window.orientation||-90===window.orientation)return window.innerWidth>=1024&&window.innerHeight>=768}return!1}(),f=/iPhone/i.test(s)||/iPod/i.test(s),w=e,h=c||l||a||f||d||u,m=r&&!h,p=t&&!e;function g(){let e="";return m?e="pc":h?e="h5":w?e="wechat":p&&(e="app"),e}function b(t){const{count:n=1,sourceType:r=["album"],mediaType:s,dom:c}=t;return new Promise(((t,l)=>{o?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:r,mediaType:s,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:r,success:e=>{t({files:e})},error:e=>{l(e)}}):((null==c?void 0:c.click)&&c.click(),c.value="",null==c||c.addEventListener("change",(e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)<=0||t({files:e.target.files[0]})}),!1))}))}function y(e){return b(Object.assign({mediaType:["image"]},e))}function S(e){return b(Object.assign({mediaType:["video"]},e))}const E=new Map;function v(e,t){E.set(e,t)}function T(e,t){if(!e)return Promise.reject(new Error(`getBoundingClientRect get error selector ${typeof e}.`));if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)return Promise.reject(new Error(`getBoundingClientRect can't find ${e} dom.`));const n=t.getBoundingClientRect();return Promise.resolve({id:t.id,top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,x:n.x,y:n.y})}if(o){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(E.get(t));return new Promise(((t,o)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function C(e){if(o)throw new Error("getBoundingClientRectSync can not use in uni-app.");if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getBoundingClientRectSync can't find ${e} dom.`);const n=t.getBoundingClientRect();return{id:t.id,top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,x:n.x,y:n.y}}throw new Error("getBoundingClientRectSync occur error.")}function P(e,t){if(!e)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof e}.`));if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);return t?Promise.resolve({id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}):Promise.reject(new Error(`getScrollInfo can't find ${e} dom.`))}if(o){if(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(E.get(t));return new Promise(((t,o)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function x(e){if(o)throw new Error("getScrollInfoSync can not use in uni-app.");if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getScrollInfoSync can't find ${e} dom.`);return{id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}throw new Error("getScrollInfoSync() occur error.")}function R(e,t){if(o){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.createSelectorQuery().in(E.get(t));return new Promise(((t,o)=>{n.select(e).fields({rect:!0,size:!0,scrollOffset:!0},(e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`get ${e} fields timeout.`))),500)}))}return Promise.reject(new Error("getFields occur error"))}class L{constructor(){if(L.instance)return L.instance;L.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){r&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(r){const{domRefs:t,ignoreDomRefs:n,handler:o,button:r=0}=e;this.button=r,this.listener=e=>{const r=Array.isArray(n)?n:[n];for(const t of r)if(t&&t.contains(e.target))return;const i=Array.isArray(t)?t:[t];for(const t of i)if(t&&t.contains(e.target)&&this.button===e.button)return;o(e),this.remove()}}}remove(){this.listener=null,this.button=-1}}function k(e){const{element:t,onLongPress:n,options:o={}}=e;if(!t||!n)throw new Error("addLongPressEventListener missing arguments");const{duration:r=800,eventDelegation:i}=o;let s;function c(){clearTimeout(s),a()}function l(){clearTimeout(s),a()}function a(){t.removeEventListener("pointerup",c),t.removeEventListener("pointermove",l)}t.addEventListener("pointerdown",(e=>{const o=e.target,a=(null==i?void 0:i.subSelector)?o.closest(i.subSelector)||void 0:o,u=e.currentTarget;s=setTimeout((()=>n(e,a,u)),r),t.addEventListener("pointerup",c),t.addEventListener("pointermove",l)}))}const I={PROTOCOLS:["javascript:","vbscript:","file:","about:","ftp:","ws:","wss:","mailto:","tel:","sms:","gopher:","data:","blob:"],HTML_TAGS:["","]]>","n)return"about:blank";try{let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/g,"");t=t.normalize("NFKC"),t=t.replace(/\s+/g," ").trim();let n=t;const s=new Set;let c=0;for(;c<5;)try{const e=decodeURIComponent(n);if(s.has(e))break;s.add(e),n=e,c++}catch(e){break}const l=function(){const e=[],t=Object.keys(I);for(let n=0;n1){const e=o[0].split(":");i=e[0]||"",s=e[1]||""}const c=r.split(":"),l=c[0],a=c[1]||"";return{href:e,protocol:(n[1]||"").toLowerCase(),host:r,hostname:l,port:a,pathname:n[5]||"",search:n[6]||"",hash:n[8]||"",username:i,password:s}}(t),u=a.protocol.replace(":","").toLowerCase()+":";let d=!1;for(let e=0;e{if(e&&n.push({type:"text",text:e}),r[i]){const e=r[i];let t=e;e.toLowerCase().startsWith("www.")&&(t="https://"+e),n.push({type:"url",text:e,url:t}),i++}})),n}(e);return t.map((e=>{if("url"===e.type){const t=j(e.url);return"about:blank"===t?{type:"text",text:e.text}:Object.assign(Object.assign({},e),{url:t})}return e}))}console.log("UniversalAPI.VERSION:2.4.0");const O=new L;export{i as TUIGlobal,k as addLongPressListener,y as chooseImage,S as chooseVideo,T as getBoundingClientRect,C as getBoundingClientRectSync,R as getFields,g as getPlatform,P as getScrollInfo,x as getScrollInfoSync,f as isIOS,O as outsideClick,A as parseTextAndValidateUrls,j as sanitizeUrl,v as setInstanceMapping};