"use strict";(()=>{var It=Object.defineProperty;var K=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable;var M=(t,e,r)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R=(t,e)=>{for(var r in e||(e={}))Bt.call(e,r)&&M(t,r,e[r]);if(K)for(var r of K(e))Ut.call(e,r)&&M(t,r,e[r]);return t};var l=(t,e,r)=>(M(t,typeof e!="symbol"?e+"":e,r),r);var v=(t,e,r)=>new Promise((o,i)=>{var n=c=>{try{a(r.next(c))}catch(d){i(d)}},s=c=>{try{a(r.throw(c))}catch(d){i(d)}},a=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,s);a((r=r.apply(t,e)).next())});var h=navigator.userAgent||"";var E=/android/i.test(h),k=/iphone|ipad|ipod/i.test(h),Q=/micromessenger\/([\d.]+)/i.test(h),oe=/(weibo).*weibo__([\d.]+)/i.test(h),ne=/(baiduboxapp)\/([\d.]+)/i.test(h),J=/qq\/([\d.]+)/i.test(h),ie=/(qqbrowser)\/([\d.]+)/i.test(h),se=/qzone\/.*_qz_([\d.]+)/i.test(h),Z=()=>E?"Android":k?"iOS":"pc",ae=/chrome\/[\d.]+ mobile safari\/[\d.]+/i.test(h)&&E&&h.indexOf("Version")<0;var g={UNIVERSAL_LINK:"https://oia.xiaohongshu.com/oia",URL_SCHEMA:"xhsdiscover://js_share_sdk",APP_STORE_LINK:"http://www.xiaohongshu.com/web_api/sns/v1/catalan/ios/5b61227acd30d845a70d3107",YINGYONGBAO:"http://a.app.qq.com/o/simple.jsp?pkgname=com.xingin.xhs",TIMEOUT:1e3};var Y={isCombo:!0,maxComboNum:5,collectTime:5e3};var Tt=function(t,e,r,o){function i(n){return n instanceof r?n:new r(function(s){s(n)})}return new(r||(r=Promise))(function(n,s){function a(p){try{d(o.next(p))}catch(_){s(_)}}function c(p){try{d(o.throw(p))}catch(_){s(_)}}function d(p){p.done?n(p.value):i(p.value).then(a,c)}d((o=o.apply(t,e||[])).next())})},m=Function("return this")();m.__APM_COMBO_CACHE_GROUP__=null;var Mt=null;function Rt(t){return Object.prototype.toString.call(t)==="[object Object]"}function X(t,e){let r={method:"POST",headers:{"Content-Type":"text/plain"},body:e};return Rt(e)&&(r.body=JSON.stringify(e)),fetch(t,r)}function tt(t,e={},{request:r=null,isCombo:o=!0,maxComboNum:i=5,collectTime:n=i*1e3,callback:s=null}={}){if(!t||JSON.stringify(e)==="{}")return;let a=()=>Tt(this,void 0,void 0,function*(){var c;if(!((c=m.__APM_COMBO_CACHE_GROUP__)===null||c===void 0)&&c.data.length){let{key:d,data:p,timer:_}=m.__APM_COMBO_CACHE_GROUP__;return clearTimeout(_),m.__APM_COMBO_CACHE_GROUP__=null,yield(r||X).call(null,d,p)}return null});return new Promise((c,d)=>{var p,_;if(!o)r.call(null,t,e);else if(t){if(Mt=t,!((p=m.__APM_COMBO_CACHE_GROUP__)===null||p===void 0)&&p.key||(m.__APM_COMBO_CACHE_GROUP__={key:t,data:[],timer:setTimeout(()=>{var b;let w=(b=m.__APM_COMBO_CACHE_GROUP__)===null||b===void 0?void 0:b.data;a().then(T=>{s==null||s(w),c(T)}).catch(T=>{d(T)})},n)}),m.__APM_COMBO_CACHE_GROUP__.data.push(e),m.__APM_COMBO_CACHE_GROUP__.data.length>=i){let b=(_=m.__APM_COMBO_CACHE_GROUP__)===null||_===void 0?void 0:_.data;a().then(w=>{s==null||s(b),c(w)}).catch(w=>{d(w)})}}else d(`\u63A5\u53E3 url: ${t} \u4E0D\u80FD\u4E3A\u7A7A`)})}function et(t,e,{request:r}){return(r||X).call(null,t,e)}var C=class{constructor(e,r=Y){this.endpoint=e,this.config=r;let{request:o,requestCallback:i,isCombo:n,maxComboNum:s,collectTime:a}=this.config;this.url=e,this.request=o,this.requestCallback=i,this.maxComboNum=s,this.isCombo=n,this.collectTime=a}push(e){return tt(this.url,e,{request:this.request,isCombo:this.isCombo,maxComboNum:this.maxComboNum,collectTime:this.collectTime,callback:this.requestCallback})}flush(e){return et(this.url,e,{request:this.request})}};var kt=new C("https://spider-tracker.xiaohongshu.com/api/data",{request:(t,e)=>fetch(t,{method:"POST",headers:{accept:"application/json, text/plain, */*","accept-language":"zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,fr;q=0.6","cache-control":"no-cache","content-type":"application/json","Biz-Type":1663676682},body:JSON.stringify(e)}).then(o=>o.json()),isCombo:!1});function Nt(t){try{let e={context:{app_id:26,session_id:"",platform:"Web",user_agent:navigator.userAgent||"",artifact_name:"goten",artifact_version:"0.0.1",user_id:"goten_js_sdk_mock_user_id",group_user_id:"",attributes:{}},event_info:{module_key:t,action:"CLICK",page_key:"goten",event_seq:5,event_time:Date.now(),event_id:"",route_matched_path:"",url:"goten",attributes:{}}};kt.push(e)}catch(e){console.warn("[light track not support]:",e)}}var S=Nt;function rt(t,e){let r=setTimeout(()=>{t==null||t()},e);typeof document.addEventListener=="undefined"||typeof document.hidden=="undefined"?console.log("This function requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API."):(document.addEventListener("visibilitychange",()=>{document.hidden&&clearTimeout(r)}),window.onpagehide=()=>{clearTimeout(r)})}function qt(){return rt(()=>{window.location.href=g.APP_STORE_LINK},g.TIMEOUT)}function Lt(t){return rt(()=>{window.location.href=`${g.YINGYONGBAO}?android_schema=${encodeURIComponent(t)}`},g.TIMEOUT)}function ot(t){S("growth_js_sdk_share");let{universalLink:e,urlSchema:r,supportUniversal:o}=t;k?Q||J||o?window.location.href=e:(window.location.href=r,qt()):E?(window.location.href=r,Lt(r)):console.log("\u8BF7\u5728\u79FB\u52A8\u7AEF\u8BBE\u5907\u8C03\u8BD5")}var ut="3.7.5",Vt=ut,Ft=typeof atob=="function",jt=typeof btoa=="function",A=typeof Buffer=="function",nt=typeof TextDecoder=="function"?new TextDecoder:void 0,it=typeof TextEncoder=="function"?new TextEncoder:void 0,Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",O=Array.prototype.slice.call(Dt),I=(t=>{let e={};return t.forEach((r,o)=>e[r]=o),e})(O),Gt=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,u=String.fromCharCode.bind(String),st=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),dt=t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),pt=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),lt=t=>{let e,r,o,i,n="",s=t.length%3;for(let a=0;a255||(o=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");e=r<<16|o<<8|i,n+=O[e>>18&63]+O[e>>12&63]+O[e>>6&63]+O[e&63]}return s?n.slice(0,s-3)+"===".substring(s):n},L=jt?t=>btoa(t):A?t=>Buffer.from(t,"binary").toString("base64"):lt,N=A?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let o=0,i=t.length;oe?dt(N(t)):N(t),Ht=t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?u(192|e>>>6)+u(128|e&63):u(224|e>>>12&15)+u(128|e>>>6&63)+u(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return u(240|e>>>18&7)+u(128|e>>>12&63)+u(128|e>>>6&63)+u(128|e&63)}},zt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,ft=t=>t.replace(zt,Ht),at=A?t=>Buffer.from(t,"utf8").toString("base64"):it?t=>N(it.encode(t)):t=>L(ft(t)),y=(t,e=!1)=>e?dt(at(t)):at(t),ct=t=>y(t,!0),$t=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Wt=t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return u((r>>>10)+55296)+u((r&1023)+56320);case 3:return u((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return u((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},ht=t=>t.replace($t,Wt),mt=t=>{if(t=t.replace(/\s+/g,""),!Gt.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r="",o,i;for(let n=0;n>16&255):i===64?u(e>>16&255,e>>8&255):u(e>>16&255,e>>8&255,e&255);return r},V=Ft?t=>atob(pt(t)):A?t=>Buffer.from(t,"base64").toString("binary"):mt,_t=A?t=>st(Buffer.from(t,"base64")):t=>st(V(t).split("").map(e=>e.charCodeAt(0))),gt=t=>_t(xt(t)),Kt=A?t=>Buffer.from(t,"base64").toString("utf8"):nt?t=>nt.decode(_t(t)):t=>ht(V(t)),xt=t=>pt(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),q=t=>Kt(xt(t)),Qt=t=>{if(typeof t!="string")return!1;let e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},bt=t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),Ct=function(){let t=(e,r)=>Object.defineProperty(String.prototype,e,bt(r));t("fromBase64",function(){return q(this)}),t("toBase64",function(e){return y(this,e)}),t("toBase64URI",function(){return y(this,!0)}),t("toBase64URL",function(){return y(this,!0)}),t("toUint8Array",function(){return gt(this)})},yt=function(){let t=(e,r)=>Object.defineProperty(Uint8Array.prototype,e,bt(r));t("toBase64",function(e){return B(this,e)}),t("toBase64URI",function(){return B(this,!0)}),t("toBase64URL",function(){return B(this,!0)})},Jt=()=>{Ct(),yt()},At={version:ut,VERSION:Vt,atob:V,atobPolyfill:mt,btoa:L,btoaPolyfill:lt,fromBase64:q,toBase64:y,encode:y,encodeURI:ct,encodeURL:ct,utob:ft,btou:ht,decode:q,isValid:Qt,fromUint8Array:B,toUint8Array:gt,extendString:Ct,extendUint8Array:yt,extendBuiltins:Jt};var U=class extends Error{constructor(r){super(r||"Validation Error");l(this,"errCode");l(this,"message");this.errCode=10001,this.message=r||"Validation Error"}},F=class extends U{constructor(r){super(r||"Validation Error");l(this,"errCode");l(this,"message");this.errCode=10002,this.message=r||"Validation Error"}},f={ValidationError:U,PropertyRequiredError:F};var j=class extends Error{constructor(r){super(r||"Unauthorized Error");l(this,"errCode");l(this,"message");this.errCode=20001,this.message=r||"Unauthorized Error"}},D=class extends Error{constructor(r){super(r||"InternalServer Error");l(this,"errCode");l(this,"message");this.errCode=20002,this.message=r||"Unauthorized Error"}},G=class extends Error{constructor(r){super(r||"BadRequest Error");l(this,"errCode");l(this,"message");this.errCode=20003,this.message=r||"Unauthorized Error"}},H={UnauthorizedError:j,InternalServerError:D,BadRequestError:G};var Zt="//edith.xiaohongshu.com/api/sns/v1/ext/check/token";function Yt(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=r.length;for(let i=0;ic.json())}function wt(t,e){let r=Object.entries(e).map(([o,i])=>`${encodeURIComponent(o)}=${encodeURIComponent(i)}`).join("&");return`${t}?${r}`}function vt(t,e){return v(this,null,function*(){let r="";try{let a=yield Xt(t,e);if(a.success)r=a.data.data_code;else throw a}catch(a){throw new H.UnauthorizedError(a==null?void 0:a.msg)}let{URL_SCHEMA:o,UNIVERSAL_LINK:i}=g,n=wt(`${o}`,{share_code:r,app_key:e.appKey,session_id:Ot});return{universalLink:wt(i,{deeplink:n}),urlSchema:n}})}var te={propertyRequiredError:{code:10001,message:"No field"},validationError:{code:10002,message:"Invalid data"}},z=te;var $=t=>`${z.propertyRequiredError.message}: ${t}`,x=t=>`${z.validationError.message}: ${t}`;function ee(t){return t.length?Array.isArray(t)&&t.every(e=>typeof e=="string"&&(e.startsWith("https")||e.startsWith("http"))):!1}function P(t){return typeof t=="string"}function Et(t){let{type:e,images:r,video:o,title:i,cover:n,content:s}=t!=null?t:{};if(!e)throw new f.PropertyRequiredError($("type"));switch(e){case"normal":if(r){if(!ee(r))throw new f.ValidationError(x("images"))}else throw new f.PropertyRequiredError($("images"));break;case"video":if(o)if(P(o)){if(!o.startsWith("https")&&!o.startsWith("http"))throw new f.ValidationError(x("video"))}else throw new f.ValidationError(x("video"));else throw new f.PropertyRequiredError($("video"));break;default:throw new f.ValidationError(x("type"))}if(i&&!P(i))throw new f.ValidationError(x("title"));if(n&&P(i)&&!n.startsWith("https")&&!n.startsWith("http"))throw new f.ValidationError(x("cover"));if(s&&!P(s))throw new f.ValidationError(x("content"));return!0}var W=class{share(i){return v(this,arguments,function*({shareInfo:e,verifyConfig:r,fail:o}){S("growth_js_sdk_share");try{Et(e);let{universalLink:n,urlSchema:s}=(yield vt(e,r))||{};ot({universalLink:n,urlSchema:s,supportUniversal:!0})}catch(n){o==null||o(n)}})}},St=new W;window.xhs=St;var Ge=St;})();