@playpilot/tpi 5.2.1-beta.5 → 5.2.1-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/link-injections.js +1 -1
- package/package.json +1 -1
- package/src/lib/api.ts +2 -0
package/dist/link-injections.js
CHANGED
|
@@ -7,7 +7,7 @@ var yi=e=>{throw TypeError(e)};var wi=(e,t,n)=>t.has(e)||yi("Cannot "+n);var Cn=
|
|
|
7
7
|
opacity: ${s-u*_}
|
|
8
8
|
`}}Ia();var sl=Le('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M14 2L2 14M2 2L14 14" stroke="currentColor" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Br(e){var t=sl();k(e,t)}function ci(e,t){ae(t,!0);const n=L(t,"size",3,"margin(2)"),i=L(t,"onclick",3,()=>null),r=Ko(t,["$$slots","$$events","$$legacy","children","size","onclick"]);var a=Fe(),o=ne(a);Co(o,()=>t.href?"a":"button",!1,(s,l)=>{let d;N(()=>{d=Lo(s,d,{role:t.href?"link":"button",onclick:i(),class:"button",...r},"svelte-1qqv88o",s.namespaceURI===Ji,s.nodeName.includes("-")),xn(s,"--size",n())});var u=Fe(),f=ne(u);Pt(f,()=>t.children??st),k(l,u)}),k(e,a),oe()}function cl(e){C(e,e.v+1)}function ul(e){let t=0,n=Ee(0),i;return()=>{Za()&&(c(n),yn(()=>(t===0&&(i=Ke(()=>e(()=>cl(n)))),t+=1,()=>{Bn().then(()=>{t-=1,t===0&&(i==null||i(),i=void 0)})})))}}var zt,Wt;class dl{constructor(t,n){Pn(this,zt);Pn(this,Wt);jn(this,zt,t),jn(this,Wt,ul(n))}get current(){return Cn(this,Wt).call(this),Cn(this,zt).call(this)}}zt=new WeakMap,Wt=new WeakMap;const fl=/\(.+\)/;class vl extends dl{constructor(t,n){let i=fl.test(t)?t:`(${t})`;const r=window.matchMedia(i);super(()=>r.matches,a=>ko(r,"change",a))}}const ui=new vl("(prefers-reduced-motion: reduce)");var _l=(e,t)=>t()(),hl=I('<div class="modal svelte-aqwna4"><div class="dialog svelte-aqwna4" role="dialog" aria-labelledby="title" data-view-transition-new=""><div class="close svelte-aqwna4"><!></div> <!></div> <div class="backdrop svelte-aqwna4"></div></div>');function Fr(e,t){ae(t,!0);const n=L(t,"onclose",3,()=>null),i=L(t,"onscroll",3,()=>null);br("scope","modal"),Je(()=>{const f=document.body.style.overflowY;return document.body.style.overflowY="hidden",()=>document.body.style.overflowY=f||""});function r(f){return ui.current?Ft(f,{duration:0}):window.innerWidth<600?En(f,{duration:250,y:window.innerHeight}):ll(f,{duration:150,start:.85})}var a=hl();ce("keydown",pe,({key:f})=>{f==="Escape"&&n()()});var o=b(a),s=b(o),l=b(s);ci(l,{onclick:()=>n()(),children:(f,_)=>{Br(f)},$$slots:{default:!0}});var d=E(s,2);Pt(d,()=>t.children);var u=E(o,2);u.__click=[_l,n],ce("scroll",o,function(...f){var _;(_=i())==null||_.apply(this,f)}),je(7,o,()=>r),je(7,a,()=>Ft,()=>({duration:150})),k(e,a),oe()}fe(["click"]);const gl=[{slug:"100",name:"All",categories:{movie:100,series:100,documentary:100,kids:100,cinema:100,podcasts:100}},{slug:"999",name:"Unscripted",categories:{},media_format:"video"},{slug:"900",name:"Independent",categories:{},media_format:"video"},{slug:"113",name:"Game Show",categories:{series:36,kids:28},media_format:"video"},{slug:"112",name:"Film Noir",categories:{movie:37},media_format:"video"},{slug:"212",name:"Entertainment",categories:{kids:80,series:42,movie:42},media_format:"video"},{slug:"120",name:"News",categories:{series:26,documentary:36,kids:38},media_format:"video"},{slug:"208",name:"Short",categories:{movie:21,documentary:30,kids:36},media_format:"video"},{slug:"902",name:"Bollywood",categories:{},media_format:"video"},{slug:"240",name:"Concert",categories:{movie:45},media_format:"video"},{slug:"901",name:"Arthouse",categories:{},media_format:"video"},{slug:"903",name:"Alternate Version",categories:{},media_format:"video"},{slug:"121",name:"Reality TV",categories:{series:24},media_format:"video"},{slug:"202",name:"Culture",categories:{kids:40,documentary:84,series:44},media_format:"video"},{slug:"107",name:"Drama",categories:{series:82,movie:82,cinema:88,documentary:44},media_format:"video"},{slug:"105",name:"Crime",categories:{series:84,documentary:86,cinema:64,movie:84},media_format:"video"},{slug:"128",name:"Western",categories:{movie:12,series:12,documentary:24},media_format:"video"},{slug:"127",name:"Thriller",categories:{series:70,documentary:28,cinema:80,movie:70},media_format:"video"},{slug:"102",name:"Animation",categories:{series:50,cinema:50,kids:90,documentary:48,movie:50},media_format:"video"},{slug:"119",name:"Mystery",categories:{movie:76,cinema:70,kids:26,documentary:38,series:76},media_format:"video"},{slug:"227",name:"Science",categories:{series:22,kids:46,documentary:74},media_format:"video"},{slug:"108",name:"Nature",categories:{kids:48,documentary:76,series:28},media_format:"video"},{slug:"116",name:"War",categories:{movie:14,documentary:68,series:14,cinema:66},media_format:"video"},{slug:"123",name:"Sci-Fi",categories:{series:72,movie:72,cinema:68,kids:70,documentary:32},media_format:"video"},{slug:"106",name:"Documentary",categories:{kids:50},media_format:"video"},{slug:"232",name:"Stand-up",categories:{movie:18,series:18},media_format:"video"},{slug:"126",name:"Talk Show",categories:{kids:34,series:16},media_format:"video"},{slug:"111",name:"Fantasy",categories:{kids:78,cinema:74,documentary:42,movie:38,series:38},media_format:"video"},{slug:"114",name:"History",categories:{movie:35,kids:44,cinema:10,series:80,documentary:90},media_format:"video"},{slug:"109",name:"Adventure",categories:{kids:88,cinema:86,documentary:82,series:88,movie:88},media_format:"video"},{slug:"101",name:"Action",categories:{documentary:50,kids:86,series:90,cinema:90,movie:90},media_format:"video"},{slug:"124",name:"Horror",categories:{cinema:76,documentary:40,series:78,movie:80},media_format:"video"},{slug:"115",name:"Comedy",categories:{cinema:84,documentary:46,series:86,kids:82,movie:86},media_format:"video"},{slug:"104",name:"Biography",categories:{series:46,documentary:88,cinema:10,movie:46},media_format:"video"},{slug:"118",name:"Music",categories:{kids:72,cinema:9,documentary:78,movie:32,series:32},media_format:"video"},{slug:"125",name:"Sport",categories:{cinema:7,kids:68,series:20,documentary:70,movie:20},media_format:"video"},{slug:"122",name:"Romance",categories:{documentary:34,cinema:78,movie:74,series:74},media_format:"video"},{slug:"103",name:"Kids",categories:{kids:76},media_format:"video"},{slug:"222",name:"Lifestyle",categories:{documentary:80,kids:74,series:34},media_format:"video"},{slug:"117",name:"Musical",categories:{kids:30,movie:78,cinema:8,series:30},media_format:"video"},{slug:"129",name:"Anime",categories:{cinema:5,movie:48,kids:84,series:48},media_format:"video"},{slug:"110",name:"Family",categories:{series:40,cinema:40,movie:40},media_format:"video"}];var ml=I('<div class="genre svelte-1ebula3"> </div>'),pl=(e,t)=>C(t,!0),yl=I('<button class="genre expand svelte-1ebula3"> </button>'),wl=I("<!> <!>",1);function kl(e,t){ae(t,!0);let n=U(!1);const i=K(()=>c(n)?t.genres:[t.genres[0]]);var r=wl(),a=ne(r);at(a,17,()=>c(i),xt,(l,d)=>{var u=Fe();const f=K(()=>{var g;return(g=gl.find(v=>v.slug===c(d)))==null?void 0:g.name});var _=ne(u);{var m=g=>{var v=ml(),p=b(v);N(()=>G(p,ke(c(f)))),k(g,v)};q(_,g=>{c(f)&&g(m)})}k(l,u)});var o=E(a,2);{var s=l=>{var d=yl();d.__click=[pl,n];var u=b(d);N(()=>G(u,`+${t.genres.length-1}`)),k(l,d)};q(o,l=>{!c(n)&&t.genres.length>1&&l(s)})}k(e,r),oe()}fe(["click"]);function bl(e){let t=[];for(const n of e){let i=n;const r=t.find(s=>s.name===i.name),a=r==null?void 0:r.extra_info.category,o=i.extra_info.category;(a==="RENT"&&o==="BUY"||a==="BUY"&&o==="RENT")&&(t=t.filter(s=>s.name!==i.name),i={...i,extra_info:{...i.extra_info,category:"TVOD"}}),t.push(i)}return t}function xe(e,t=1){e.role="heading",e.ariaLevel=t.toString()}var xl=Le('<svg width="6" height="12" viewBox="0 0 6 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 11L5 6L0 1" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Sl(e){var t=xl();k(e,t)}function Ut(e){return e?e.replace("/src/img",""):null}var El=(e,t,n)=>t(n()),Tl=I('<div class="arrow svelte-g63n1y"><!></div>'),Il=I('<a target="_blank" class="playlink svelte-g63n1y" rel="sponsored"><img alt="" height="32" width="32" class="svelte-g63n1y"> <div><span class="name svelte-g63n1y"> </span> <div class="category svelte-g63n1y"> </div></div> <!></a>'),Al=I('<div class="playlink empty svelte-g63n1y"> </div>'),Cl=I('<div class="heading svelte-g63n1y"> </div> <div class="playlinks svelte-g63n1y"><!> <!></div>',1);function Pl(e,t){ae(t,!0);const n=L(t,"list",3,!1),i=so("scope")==="modal",r=K(()=>t.playlinks.filter(v=>!!v.logo_url)),a=K(()=>bl(c(r))),o={SVOD:ke("Stream"),BUY:ke("Buy"),RENT:ke("Rent"),TVOD:ke("Rent Or Buy")};function s(v){be(i?ye.TitleModalPlaylinkClick:ye.TitlePopoverPlaylinkClick,t.title,{playlink:v})}var l=Cl(),d=ne(l),u=b(d);N(()=>G(u,ke("Where To Stream Online"))),Qt(d,(v,p)=>xe==null?void 0:xe(v,p),()=>3);var f=E(d,2),_=b(f);at(_,17,()=>c(a),xt,(v,p)=>{let y=()=>c(p).name,w=()=>c(p).url,S=()=>c(p).logo_url,j=()=>c(p).highlighted,x=()=>c(p).cta_text,T=()=>c(p).extra_info.category;var H=Il();H.__click=[El,s,y];var M=b(H);N(()=>ue(M,"src",Ut(S())));var A=E(M,2),D=b(A),P=b(D),B=E(D,2),O=b(B);N(()=>G(O,x()||o[T()]||ke("Stream")));var z=E(A,2);{var F=V=>{var W=Tl(),J=b(W);Sl(J),k(V,W)};q(z,V=>{n()&&V(F)})}N(()=>{ue(H,"href",w()),ue(H,"data-playlink",y()),se(H,"highlighted",j()&&x()),G(P,y())}),k(v,H)});var m=E(_,2);{var g=v=>{var p=Al(),y=b(p);N(()=>G(y,ke("Title Unavailable"))),k(v,p)};q(m,v=>{t.playlinks.length||v(g)})}N(()=>se(f,"list",n())),k(e,l),oe()}fe(["click"]);var jl=(e,t)=>C(t,!0),Ml=I('<button class="show-more svelte-1u3je71">Show more</button>'),Ll=I('<div class="paragraph svelte-1u3je71" role="paragraph"> </div>'),Nl=I('<div><span class="paragraph svelte-1u3je71" role="paragraph"> <!> <!></span> <!></div>');function Ol(e,t){ae(t,!0);const n=L(t,"blurb",3,""),i=L(t,"limit",3,200);let r=U(!1);const a=K(()=>t.text.slice(0,i()));var o=Nl(),s=b(o),l=b(s),d=E(l);{var u=v=>{var p=Be("...");k(v,p)};q(d,v=>{!c(r)&&t.text.length>i()&&v(u)})}var f=E(d,2);{var _=v=>{var p=Ml();p.__click=[jl,r],k(v,p)};q(f,v=>{!c(r)&&(t.text.length>i()||n())&&v(_)})}var m=E(s,2);{var g=v=>{var p=Ll(),y=b(p);N(()=>G(y,n())),k(v,p)};q(m,v=>{c(r)&&v(g)})}N(()=>G(l,c(r)?t.text:c(a))),k(e,o),oe()}fe(["click"]);var Dl=Le('<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 0.351929L9.163 4.72803L14 5.43408L10.5 8.8385L11.326 13.648L7 11.3761L2.674 13.648L3.5 8.8385L0 5.43408L4.837 4.72803L7 0.351929Z" fill="#F6C045"></path></svg>');function Vr(e){var t=Dl();k(e,t)}var Rl=I('<div class="top svelte-1026zg0"><img class="poster svelte-1026zg0"></div>'),ql=I("<div> </div>"),Hl=I('<img alt="" class="svelte-1026zg0">'),Bl=I('<div class="content svelte-1026zg0" data-playpilot-link-injections-title=""><div class="header svelte-1026zg0"><!> <div class="heading svelte-1026zg0" id="title"> </div> <div class="info svelte-1026zg0"><div class="imdb svelte-1026zg0"><!> </div> <!> <div> </div> <div class="capitalize svelte-1026zg0"> </div> <!></div></div> <div class="main"><!> <!></div></div> <div class="background svelte-1026zg0"><!></div>',1);function Ur(e,t){ae(t,!0);const n=L(t,"small",3,!1),i=L(t,"compact",3,!1);let r=U(!1),a=U(!1),o=U(!1);var s=Bl(),l=ne(s),d=b(l),u=b(d);{var f=F=>{var V=Rl(),W=b(V);N(()=>ue(W,"src",Ut(t.title.standing_poster))),N(()=>{ue(W,"alt",`Movie poster for '${t.title.title??""}'`),se(W,"loaded",c(r))}),ce("load",W,()=>C(r,!0)),k(F,V)};q(u,F=>{i()||F(f)})}var _=E(u,2),m=b(_);Qt(_,(F,V)=>xe==null?void 0:xe(F,V),()=>2);var g=E(_,2),v=b(g),p=b(v);Vr(p);var y=E(p),w=E(v,2);kl(w,{get genres(){return t.title.genres}});var S=E(w,2),j=b(S),x=E(S,2),T=b(x);N(()=>G(T,ke(`Type: ${t.title.type}`)));var H=E(x,2);{var M=F=>{var V=ql(),W=b(V);N(()=>G(W,`${t.title.length??""} ${ke("Minutes")??""}`)),k(F,V)};q(H,F=>{!n()&&t.title.length&&F(M)})}var A=E(d,2),D=b(A);Pl(D,{get playlinks(){return t.title.providers},get title(){return t.title},list:!0});var P=E(D,2);{var B=F=>{Ol(F,{get text(){return t.title.description},get blurb(){return t.title.blurb}})};q(P,F=>{n()||F(B)})}var O=E(l,2),z=b(O);Ir(z,()=>c(o),F=>{var V=Hl();N(()=>ue(V,"src",Ut(c(o)?t.title.standing_poster:t.title.medium_poster))),N(()=>{se(V,"loaded",c(a)),se(V,"blur",c(o))}),ce("load",V,()=>C(a,!0)),ce("error",V,()=>C(o,!0)),k(F,V)}),N(()=>{se(l,"small",n()),se(l,"compact",i()),se(_,"truncate",n()),G(m,t.title.title),G(y,` ${t.title.imdb_score??""}`),G(j,t.title.year),se(O,"faded",i())}),k(e,s),oe()}function Fl(e,t){ae(t,!0),be(ye.TitleModalView,t.title);let n=!1;function i(){n||(be(ye.TitleModalScroll,t.title),n=!0)}Fr(e,{get onclose(){return t.onclose},onscroll:i,children:(r,a)=>{Ur(r,{get title(){return t.title}})},$$slots:{default:!0}}),oe()}var Vl=I('<div class="popover svelte-tb2xdq" tabindex="-1" aria-hidden="true"><div class="dialog svelte-tb2xdq" data-view-transition-old=""><!></div></div>');function Ul(e,t){ae(t,!0);let n=L(t,"maxHeight",15);br("scope","popover");let i=U(null),r=U(!1);Je(async()=>{await Bn(),a(),await Bn(),o()});function a(){if(!c(i))return;const{top:f,right:_,bottom:m,height:g}=c(i).getBoundingClientRect(),v=s();C(r,X(f-v<0&&window.innerHeight-m>f+g));const p=window.innerWidth-_-v;_+v>window.innerWidth&&(c(i).style.left=`${p}px`)}function o(){if(!c(i))return;const{top:f,height:_}=c(i).getBoundingClientRect(),m=s(),g=c(r)?window.innerHeight-f-m:f+_-m;n(Math.min(g,window.innerHeight*.8))}function s(){return parseFloat(getComputedStyle(document.documentElement).fontSize)}var l=Vl(),d=b(l),u=b(d);Pt(u,()=>t.children),$t(l,f=>C(i,f),()=>c(i)),N(()=>{se(l,"flip",c(r)),xn(l,"--max-height",n()?n()+"px":null)}),je(7,d,()=>En,()=>({duration:ui.current?0:100,y:10})),k(e,l),oe()}var zl=I('<div class="title-popover svelte-d86q0q" data-playpilot-title-popover="" role="region" aria-labelledby="title"><!></div>');function Wl(e,t){ae(t,!0);let n=U(0),i=U(null);be(ye.TitlePopoverView,t.title),Je(r);function r(){const s=t.event.target;if(!(s!=null&&s.getClientRects))return;const l=Array.from(s.getClientRects()),u=l.map(_=>_.x).map(_=>Math.abs(_-t.event.clientX)),f=l[u.indexOf(Math.min(...u))];c(i).style.top=f.top+window.scrollY+"px",c(i).style.left=f.left+window.scrollX+"px",c(i).style.height=f.height+"px"}var a=zl(),o=b(a);Ul(o,{get maxHeight(){return c(n)},set maxHeight(s){C(n,X(s))},children:(s,l)=>{var d=K(()=>!!c(n)&&c(n)<250);Ur(s,{get title(){return t.title},small:!0,get compact(){return c(d)}})},$$slots:{default:!0}}),$t(a,s=>C(i,s),()=>c(i)),k(e,a),oe()}var Kl=e=>e.stopPropagation(),Yl=(e,t,n,i)=>t(e,c(n).title_details,c(i)),Zl=I(' <span class="svelte-pfvkex"><button class="svelte-pfvkex"> </button></span>',1),Gl=(e,t,n,i)=>t(c(n).title_details,i()),Xl=I('<!> <a target="_blank"> </a>',1),Jl=I(" <!>.",1),Ql=I("<!> <br>",1),$l=I(" <br>",1),es=I('<span class="svelte-pfvkex"><!></span>'),ts=I('<p class="svelte-pfvkex"></p>');function ns(e,t){ae(t,!0);const n=L(t,"onclickmodal",3,()=>null);function i(l,d){be(ye.AfterArticlePlaylinkClick,l,{playlink:d})}function r(l,d,u){be(ye.AfterArticleModalButtonClick,d),n()(l,u)}var a=Fe(),o=ne(a);{var s=l=>{var d=ts();at(d,21,()=>t.linkInjections,xt,(u,f)=>{var _=es();const m=K(()=>{const{key:w,title:S,title_details:j,after_article_style:x}=c(f);return{key:w,title:S,title_details:j,after_article_style:x}}),g=K(()=>{var w;return((w=c(m).title_details)==null?void 0:w.providers)||[]});var v=b(_);{var p=w=>{var S=Ql(),j=ne(S);{var x=H=>{var M=Zl(),A=ne(M);N(()=>G(A,`"${c(m).title??""}" ${ke("Is Available To Stream")??""} `));var D=E(A);D.__click=[Kl];var P=b(D);P.__click=[Yl,r,m,f];var B=b(P);N(()=>G(B,ke("View Streaming Options"))),k(H,M)},T=H=>{var M=Jl(),A=ne(M);N(()=>G(A,`"${c(m).title??""}" ${ke("Is Available To Stream On")??""} `));var D=E(A);at(D,17,()=>c(g),xt,(P,B,O)=>{let z=()=>c(B).name,F=()=>c(B).url;var V=Xl(),W=ne(V);{var J=de=>{var Ae=Be();N(()=>G(Ae,O===c(g).length-1?`, ${ke("And")}`:",")),k(de,Ae)};q(W,de=>{O&&de(J)})}var ee=E(W,2);ee.__click=[Gl,i,m,z];var re=b(ee);N(()=>{ue(ee,"href",F()),G(re,z())}),k(P,V)}),k(H,M)};q(j,H=>{c(m).after_article_style==="modal_button"?H(x):H(T,!1)})}k(w,S)},y=w=>{var S=$l(),j=ne(S);N(()=>G(j,`"${c(m).title??""}" ${ke("Title Unavailable Suffix")??""} `)),k(w,S)};q(v,w=>{c(g).length?w(p):w(y,!1)})}N(()=>ue(_,"data-playpilot-injection-key",c(m).key)),k(u,_)}),k(l,d)};q(o,l=>{t.linkInjections.length&&l(s)})}k(e,a),oe()}fe(["click"]);function is(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function di(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||""}function Oi(e,t,n=[]){var a,o;const i=document.createTreeWalker(t);let r;for(;(r=i.nextNode())&&!((a=r.nodeValue)!=null&&a.includes(e)&&!n.includes(((o=r.parentNode)==null?void 0:o.nodeName)||"")););return r}function Di(e){const t=e.parentNode;return t?t.nodeName==="A"||!!t.closest("a"):!1}function rs(e,t,n,i){const r=is(t),a=di(t),o=e.slice(0,i),s=e.slice(i),l=/[-/\\^$*+?.()|[\]{}]/g,d=new RegExp(`${a.replace(l,"\\$&")}|${r.replace(l,"\\$&")}`),u=s.replace(d,n);return o+u}function as(e,t,n,i){return e.substring(0,n)+t+e.substring(i)}function Te(e){return di(e).toLowerCase().replace(/\s+/g,"")}function zr(e,t,n){const r=e.indexOf(t),a=Math.floor((n-t.length)/2);let o=Math.max(0,r-a),s=o+n;s>e.length&&(s=e.length,o=Math.max(0,s-n));let l=e.slice(o,s).trim();return o>0&&(l="…"+l),s<e.length&&(l+="…"),l}function os(e,t,n){const i=e.nodeType===Node.TEXT_NODE&&e.parentNode?e.parentElement:e;if(!i||!e.textContent)return{before:"",after:""};const r=i.innerText.indexOf(e.textContent),a=Ri(i.innerText.slice(0,t+r)),o=i.innerText.slice(n+r),s=Ri(qi(a,2)),l=qi(o,2);return{before:s,after:l}}function Ri(e){return e.split("").reverse().join("")}function qi(e,t=1){const n=e.match(/[^\s]+/g);return n?n.slice(0,t).join(" ").replace(/[.,!?;:]+$/u,""):""}function ls(e,t){let n=0,i=0;for(;(i=e.indexOf(t,i))!==-1;)n++,i+=t.length;return n}function ss(e,t,n){const i=[];let r=0;for(;r<=e.length;){const a=t?e.indexOf(t,r):r;if(a===-1&&t)break;const o=t?a+t.length:a,s=n?e.indexOf(n,o):e.length;if(n&&s===-1)break;const l=e.slice(o,s);i.push({match:l,index:o}),r=n?s+n.length:e.length+1}return i}function cs(e,t,n,i){const a=ss(e,n,i).filter(({match:s})=>di(s).includes(t));return a.length?a.reduce((s,l)=>!s||l.match.length<s.match.length?l:s):null}function us(e){var t,n;return{leadingSpaces:((t=e.match(/^\s*/))==null?void 0:t[0].length)||0,trailingSpaces:((n=e.match(/\s*$/))==null?void 0:n[0].length)||0}}function Wr(e){return e.ctrlKey||e.metaKey||e.button!==0}function ds(e,t){if(!document.startViewTransition||!t){e();return}document.startViewTransition(()=>{const n=document.querySelector("[data-view-transition-old]");if(!n)return;const i=window.getComputedStyle(n).getPropertyValue("view-transition-name");n.style.viewTransitionName="none",e();const r=document.querySelector("[data-view-transition-new]");r&&(r.style.viewTransitionName=i)})}const ut="data-playpilot-injection-key",Nt=`[${ut}]`;let vn=null,dt=null,Ot=null,Dt=null;function fi(e,t=""){const n=[],i=[e];for(;i.length>0;){const r=i.pop();if(n.includes(r)||t&&r.matches(t)||/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|H1)$/.test(r.tagName)||r.offsetWidth<=1)continue;const a=Array.from(r.childNodes).some(l=>{var d;return l.nodeType===Node.TEXT_NODE&&((d=l.nodeValue)==null?void 0:d.trim())!==""});if(a&&r.tagName==="LI"){const l=r.closest("ul, ol");l&&!n.includes(l)&&n.push(l);continue}const o=r.tagName==="P"&&!!r.textContent;if(a||o){n.push(r);continue}const s=Array.from(r.children);for(let l=s.length-1;l>=0;l--)i.push(s[l])}return n}function St(){var t;const e=(t=window.PlayPilotLinkInjections)==null?void 0:t.selector;if(e){const n=e.replace(/(:)/g,"\\$1"),i=document.querySelector(n);if(i)return i}return document.querySelector("article")||document.querySelector("main")||document.body}function Kr(e){return e.map(t=>t.innerText).join(`
|
|
9
9
|
|
|
10
|
-
`)}function fs(e,t={aiInjections:[],manualInjections:[]}){vi();const n=ws(t);if(!n)return[];const i=Te(e.map(l=>l.innerText).join(" ")),r=ks(n),a=r.filter(l=>i.includes(Te(l.sentence))),o={};for(const l of a){const d=e.findIndex(S=>Te(S.innerText).includes(Te(l.sentence))),u=e[d];if(!u)continue;const f=Oi(l.title,u,["A"]);if(!(f!=null&&f.nodeValue)||Di(f)){const S=Oi(l.title,u);if(S&&Di(S)){o[l.key]="Given text is already inside of a link.";continue}}const{injectionElement:_,linkElement:m}=vs(l),{phrase_before:g,phrase_after:v}=l;let p=-1,y=!1;if(ls(Te(u.innerText),Te(l.title))===1&&(p=u.innerHTML.indexOf(l.title)),p===-1&&(g||v)){const S=[g,l.title,v].filter(Boolean).join(" ");if(p=u.innerHTML.indexOf(S),p===-1){const j=cs(u.innerHTML,l.title,g||"",v||"");if(j){const{leadingSpaces:x,trailingSpaces:T}=us(j.match);m.innerHTML=j.match.trim();const H=j.index+x,M=j.index+j.match.length-T;u.innerHTML=as(u.innerHTML,_.outerHTML,H,M),p=j.index,y=!0}}}if(p===-1&&(f!=null&&f.nodeValue)){const S=u.innerHTML.indexOf(f.nodeValue),j=u.innerHTML.indexOf(l.sentence);p=Math.max(S,j,0)}p!==-1&&(y||(u.innerHTML=rs(u.innerHTML,l.title,_.outerHTML,p)))}hs(r),_s();const s=bs(n);return s.length&&ms(e,s),n.filter(l=>l.title_details).map((l,d)=>{const u=l.duplicate??(!l.manual&&xs(l,d,n)),f=document.querySelector(`[${ut}="${l.key}"]`),_=Tn(l)&&!l.inactive&&!l.after_article&&!f,m=!!e.find(v=>Te(v.innerText).includes(Te(l.sentence))),g=_?o[l.key]||(m?"The link failed to inject for unknown reasons.":"Given sentence was not found in the article."):"";return{...l,inactive:l.inactive??!1,duplicate:u,failed:_,failed_message:g}})}function vs(e){const t=document.createElement("span");t.dataset.playpilotInjectionKey=e.key;const n=document.createElement("a");return n.innerText=e.title,n.href=e.playpilot_url,n.target="_blank",n.rel="noopener nofollow noreferrer",t.insertAdjacentElement("beforeend",n),{injectionElement:t,linkElement:n}}function _s(){const e=Array.from(document.querySelectorAll(`${Nt} a`)),t=["--playpilot-injection-text-color","--playpilot-injection-text-color-hover","--playpilot-injection-font-weight","--playpilot-injection-font-weight-headings","--playpilot-injection-text-decoration","--playpilot-injection-text-decoration-hover","--playpilot-injection-background-color","--playpilot-injection-background-color-hover"];e.forEach(n=>{t.forEach(i=>{getComputedStyle(n).getPropertyValue(i)&&(n.dataset.usedCssVariables=`${n.dataset.usedCssVariables||""} ${i}`)})})}function hs(e){window.addEventListener("click",n=>{if(Wr(n))return;let i=n.target;if(!i||(i.hasAttribute(ut)||(i=i.closest(Nt)),!i))return;const r=i.getAttribute(ut);if(!r)return;const a=e.find(o=>r===o.key);a&&(n.preventDefault(),ds(()=>{_n(!1),Yr(n,a)},!ui.current&&window.innerWidth>=600&&!window.matchMedia("(pointer: coarse)").matches))}),window.addEventListener("mousemove",n=>{if(!dt)return;const i=n.target;i.hasAttribute("data-playpilot-title-popover")||i.closest("[data-playpilot-title-popover]")||i.hasAttribute(ut)||i.closest(Nt)||_n()}),Array.from(document.querySelectorAll(Nt)).forEach(n=>{const i=n.dataset.playpilotInjectionKey,r=e.find(a=>i===a.key);r&&(n.addEventListener("mouseenter",a=>{dt||gs(a,r)}),n.addEventListener("mouseleave",()=>vn=null))})}function Yr(e,t){Wr(e)||Dt||(e.preventDefault(),Dt=Jt(Fl,{target:$r(),props:{title:t.title_details,onclose:Zr}}))}function Zr(e=!0){Dt&&(bn(Dt,{outro:e}),Dt=null)}function gs(e,t){if(window.matchMedia("(pointer: coarse)").matches)return;dt&&_n();const n=e.currentTarget;vn=n,setTimeout(()=>{vn===n&&(dt=Jt(Wl,{target:$r(),props:{event:e,title:t.title_details}}))},100)}function _n(e=!0){dt&&(bn(dt,{outro:e}),vn=null,dt=null)}function ms(e,t){var o,s;if(Ot||!t.length)return;const n=document.createElement("div"),i=(o=window.PlayPilotLinkInjections)==null?void 0:o.after_article_selector,r=(i?document.querySelector(i):null)||e[e.length-1],a=((s=window.PlayPilotLinkInjections)==null?void 0:s.after_article_insert_position)||"afterend";n.dataset.playpilotAfterArticlePlaylinks="true",r.insertAdjacentElement(a,n),Ot=Jt(ns,{target:n,props:{linkInjections:t,onclickmodal:(l,d)=>Yr(l,d)}})}function ps(){var e;Ot&&(bn(Ot),(e=document.querySelector("[data-playpilot-after-article-playlinks]"))==null||e.remove(),Ot=null)}function vi(){document.querySelectorAll(Nt).forEach(t=>ys(t.getAttribute(ut)||"")),ps(),Zr(!1),_n(!1)}function ys(e){var i;const t=document.querySelector(`[${ut}="${e}"]`);if(!t)return;const n=(i=t.querySelector("a"))==null?void 0:i.innerHTML;t.outerHTML=n||""}function ws({aiInjections:e,manualInjections:t}){return[...t.map(n=>({...n,manual:!0})),...e]}function Gr(e){return{aiInjections:e.filter(t=>!t.manual),manualInjections:e.filter(t=>t.manual)}}function Xr(e){return!e.inactive&&!e.removed&&!e.duplicate&&!!e.title_details&&Tn(e)}function Tn(e){return e.in_text||e.in_text===void 0?!0:!!e.after_article}function ks(e){return Jr(e).filter(t=>t.in_text!==!1&&Xr(t))}function bs(e){return Jr(e).filter(t=>t.after_article===!0&&Xr(t))}function Jr(e){return e.filter(t=>t.removed||t.inactive?!1:t.manual&&!t.removed&&!t.inactive?!0:!e.some(n=>n.manual&&(n.removed||n.inactive)&&Qr(n,t)))}function xs(e,t,n){return n.some((i,r)=>t!==r&&i.manual&&Qr(i,e))}function Qr(e,t){return e.title===t.title&&Te(e.sentence)===Te(t.sentence)}function $r(){return document.querySelector("[data-playpilot-link-injections]")||document.body}function _i(){const e=St();return{content_heading:Ss(e),content_modified_time:Es(e),content_published_time:Ts(e)}}function Ss(e){const t=e.querySelector("h1")||document.querySelector("h1");return(t==null?void 0:t.innerText.trim())||null}function Es(e){const t=document.querySelector('meta[property*="modified_time"]')||document.querySelector('meta[name*="modified_time"]')||e.querySelector('[itemprop="dateModified"]')||document.querySelector('[itemprop="dateModified"]')||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?hi(n):null}function Ts(e){const t=document.querySelector('meta[property*="published_time"]')||document.querySelector('meta[name*="published_time"]')||e.querySelector('[itemprop="datePublished"]')||document.querySelector('[itemprop="datePublished"]')||e.querySelector("time")||document.querySelector("time")||e.querySelector("[datetime]")||document.querySelector("[datetime]")||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?hi(n):null}function hi(e){try{return new Date(e).toISOString()}catch{return null}}let On=null;async function en(e,{url:t=ai(),hash:n=rl(e||""),params:i={}}={}){const r=new Headers({"Content-Type":"application/json"}),a=In(),o=Rr()?await Dr():!1,s=Hr();if(!a)throw new Error("No token was provided");i.metadata=_i(),i.run_ai&&(i.hash=n,i.page_text=e);const l=await fetch(Sn+`/external-pages/?api-token=${a}&include_title_details=true${o?"&editorial_mode_enabled=true":""}&language=${s}`,{headers:r,method:"POST",body:JSON.stringify({url:t,...i})});if(!l.ok)throw l;return await l.json()}async function Hi(e,{requireCompletedResult:t=!1,runAiWhenRelevant:n=!1,pollInterval:i=3e3,maxTries:r=600,onpoll:a=()=>null}={}){let o=0;On&&clearTimeout(On);const s=async(l,d)=>{let u;try{if(u=await en(e),n&&(u=await Is(e,u)),t&&u.ai_enabled&&u.ai_running)throw new Error;u.manual_injections=Bi(u.manual_injections||[]),u.ai_injections=Bi(u.ai_injections||[]),l(u);return}catch{if(o++,o>=r){r>1&&console.error("Max poll limit exceeded. Please return later."),l();return}u&&a(u),On=setTimeout(()=>s(l),i)}};return new Promise(s)}async function Is(e,t){if(!e||!t.ai_enabled||t.ai_running)return t;const n=_i().content_modified_time,i=t.content_modified_time?hi(t.content_modified_time):null,r=n&&i===n;return t.ai_last_run&&r?t:await en(e,{params:{run_ai:!0}})}async function As(e,t){var o;const n=(o=window.PlayPilotLinkInjections)==null?void 0:o.selector,r=e.filter(s=>s.manual).map(s=>({sid:s.sid,title:s.title,sentence:s.sentence,phrase_before:s.phrase_before,phrase_after:s.phrase_after,playpilot_url:s.playpilot_url,after_article:!!s.after_article,after_article_style:s.after_article_style||null,in_text:s.in_text??!0,inactive:!!s.inactive,removed:!!s.removed}));if(!await en(t,{params:{private_token:li(),manual_injections:r,content_text_selector:n}}))throw new Error("saveLinkInjections response was faulty");return e}async function Cs(){const e=new Headers({"Content-Type":"application/json"}),t=In();if(!t)throw new Error("No token was provided");const n=await fetch(Sn+`/domains/config?api-token=${t}`,{headers:e});if(!n.ok)throw n;try{return await n.json()||null}catch{return null}}function Bi(e){return e.map(t=>({...t,key:ea(t.sid)}))}function ea(e){return e+"-"+qr()}function In(){var e;return(e=window.PlayPilotLinkInjections)==null?void 0:e.token}function Ps(){const e=navigator.userAgent.toLowerCase();return/bot|crawl|spider|google|baidu|bing|msn|teoma|slurp|yandex|facebookexternalhit|facebot/i.test(e)}var js=Le('<svg width="8" height="4" viewBox="0 0 8 4" fill="none" class="svelte-by11ix"><path d="M1 0.5L4 3.5L7 0.5" stroke="currentColor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ms(e,t){const n=L(t,"expanded",3,!1);var i=js();N(()=>se(i,"expanded",n())),k(e,i)}var Ls=Le('<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="17" r="1" fill="var(--playpilot-warning)"></circle><path d="M12 10L12 14" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M3.44722 18.1056L10.2111 4.57771C10.9482 3.10361 13.0518 3.10362 13.7889 4.57771L20.5528 18.1056C21.2177 19.4354 20.2507 21 18.7639 21H5.23607C3.7493 21 2.78231 19.4354 3.44722 18.1056Z" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ns(e){var t=Ls();k(e,t)}function Os(e,t,n){t(!t()),n()(t())}var Ds=I('<button class="switch svelte-91s87b"><div class="label svelte-91s87b"><!></div> <div class="track svelte-91s87b"><div class="knob svelte-91s87b"></div></div></button>');function Wn(e,t){ae(t,!0);let n=L(t,"active",15),i=L(t,"fullwidth",3,!1),r=L(t,"label",3,""),a=L(t,"onclick",3,()=>null);var o=Ds();o.__click=[Os,n,a];var s=b(o),l=b(s);Pt(l,()=>t.children),N(()=>{ue(o,"aria-label",`Toggle ${r()??""} ${(n()?"off":"on")??""}`),se(o,"active",n()),se(o,"fullwidth",i())}),k(e,o),oe()}fe(["click"]);var Rs=I('<input type="text" autocomplete="off" class="svelte-1vrer3i">');function gi(e,t){let n=L(t,"value",15),i=L(t,"label",3,""),r=L(t,"name",3,""),a=L(t,"readonly",3,!1),o=L(t,"oninput",3,()=>null);var s=Rs();s.__input=function(...l){var d;(d=o())==null||d.apply(this,l)},N(()=>{ue(s,"name",r()),ue(s,"aria-label",i()),ue(s,"placeholder",i()),s.readOnly=a()}),Bo(s,n),k(e,s)}fe(["input"]);var qs=Le('<path d="M13.5833 13.6667L4.41667 13.6667M5.5 1.5H12.5C13.9001 1.5 14.6002 1.5 15.135 1.77248C15.6054 2.01217 15.9878 2.39462 16.2275 2.86502C16.5 3.3998 16.5 4.09987 16.5 5.5V12.5C16.5 13.9001 16.5 14.6002 16.2275 15.135C15.9878 15.6054 15.6054 15.9878 15.135 16.2275C14.6002 16.5 13.9001 16.5 12.5 16.5H5.5C4.09987 16.5 3.3998 16.5 2.86502 16.2275C2.39462 15.9878 2.01217 15.6054 1.77248 15.135C1.5 14.6002 1.5 13.9001 1.5 12.5V5.5C1.5 4.09987 1.5 3.3998 1.77248 2.86502C2.01217 2.39462 2.39462 2.01217 2.86502 1.77248C3.3998 1.5 4.09987 1.5 5.5 1.5Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Hs=Le('<path d="M13.5833 8.58342H4.41667M5.5 1.50009H12.5C13.9001 1.50009 14.6002 1.50009 15.135 1.77258C15.6054 2.01226 15.9878 2.39471 16.2275 2.86512C16.5 3.39989 16.5 4.09996 16.5 5.50009V12.5001C16.5 13.9002 16.5 14.6003 16.2275 15.1351C15.9878 15.6055 15.6054 15.9879 15.135 16.2276C14.6002 16.5001 13.9001 16.5001 12.5 16.5001H5.5C4.09987 16.5001 3.3998 16.5001 2.86502 16.2276C2.39462 15.9879 2.01217 15.6055 1.77248 15.1351C1.5 14.6003 1.5 13.9002 1.5 12.5001V5.50009C1.5 4.09996 1.5 3.39989 1.77248 2.86512C2.01217 2.39471 2.39462 2.01226 2.86502 1.77258C3.3998 1.50009 4.09987 1.50009 5.5 1.50009Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Bs=Le('<svg width="18" height="18" viewBox="0 0 18 18" fill="none"><!></svg>');function Fi(e,t){const n=L(t,"align",3,"bottom");var i=Bs(),r=b(i);{var a=s=>{var l=qs();k(s,l)},o=s=>{var l=Fe(),d=ne(l);{var u=f=>{var _=Hs();k(f,_)};q(d,f=>{n()==="center"&&f(u)},!0)}k(s,l)};q(r,s=>{n()==="bottom"?s(a):s(o,!1)})}k(e,i)}var Fs=I("<div><!></div>");function ht(e,t){ae(t,!0);const n=L(t,"type",3,"error"),i=L(t,"fixed",3,!1);var r=Fs(),a=b(r);Pt(a,()=>t.children),N(()=>{No(r,`alert ${n()??""} svelte-df5n87`),se(r,"fixed",i())}),k(e,r),oe()}var Vs=I("<!> In-text Playlink",1),Us=I("<!> Bottom Playlink",1),zs=I('<div class="alert svelte-1shw34x"><!></div>'),Ws=(e,t)=>t().after_article_style="playlinks",Ks=(e,t)=>t().after_article_style="modal_button",Ys=I('<div><div class="label svelte-1shw34x">Bottom playlinks style</div> <div class="group svelte-1shw34x" role="listbox" tabindex="0" aria-label="Playlink type"><button role="option" id="playlinks-in-text" class="svelte-1shw34x">Playlinks sentence</button> <button role="option" id="playlinks-after-article" class="svelte-1shw34x">Modal button</button> <div class="active-marker svelte-1shw34x"></div></div></div>'),Zs=I('<div class="switches svelte-1shw34x"><!> <!></div> <!> <!>',1);function Gs(e,t){ae(t,!0);const n=L(t,"linkInjection",7),i=K(()=>n().after_article_style==="modal_button");var r=Zs(),a=ne(r),o=b(a),s=K(()=>n().in_text??!0);Wn(o,{fullwidth:!0,get active(){return c(s)},onclick:g=>{n().in_text=g,n().manual=!0},label:"In-text Playlink",children:(g,v)=>{var p=Vs(),y=ne(p);Fi(y,{align:"center"}),k(g,p)},$$slots:{default:!0}});var l=E(o,2),d=K(()=>n().after_article??!1);Wn(l,{fullwidth:!0,get active(){return c(d)},onclick:g=>{n().after_article=g,n().manual=!0},label:"Bottom Playlink",children:(g,v)=>{var p=Us(),y=ne(p);Fi(y,{align:"bottom"}),k(g,p)},$$slots:{default:!0}});var u=E(a,2);{var f=g=>{var v=zs(),p=b(v);ht(p,{type:"warning",children:(y,w)=>{var S=Be("At least one layout option must be selected for the playlink to be visible.");k(y,S)},$$slots:{default:!0}}),je(3,v,()=>Vt,()=>({duration:200})),k(g,v)};q(u,g=>{Tn(n())||g(f)})}var _=E(u,2);{var m=g=>{var v=Ys(),p=E(b(v),2),y=b(p);y.__click=[Ws,n];var w=E(y,2);w.__click=[Ks,n];var S=E(w,2);N(()=>{ue(p,"aria-activedescendant",`playlinks-${(c(i)?"after-article":"in-text")??""}`),ue(y,"aria-selected",!c(i)||null),se(y,"active",!c(i)),ue(w,"aria-selected",c(i)||null),se(w,"active",c(i)),se(S,"right",c(i))}),je(3,v,()=>Vt,()=>({duration:100})),k(g,v)};q(_,g=>{n().after_article&&g(m)})}k(e,r),oe()}fe(["click"]);var Xs=Le('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.99984 10.8333C10.4601 10.8333 10.8332 10.4602 10.8332 10C10.8332 9.53977 10.4601 9.16668 9.99984 9.16668C9.5396 9.16668 9.1665 9.53977 9.1665 10C9.1665 10.4602 9.5396 10.8333 9.99984 10.8333Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 5.00001C10.4601 5.00001 10.8332 4.62691 10.8332 4.16668C10.8332 3.70644 10.4601 3.33334 9.99984 3.33334C9.5396 3.33334 9.1665 3.70644 9.1665 4.16668C9.1665 4.62691 9.5396 5.00001 9.99984 5.00001Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 16.6667C10.4601 16.6667 10.8332 16.2936 10.8332 15.8333C10.8332 15.3731 10.4601 15 9.99984 15C9.5396 15 9.1665 15.3731 9.1665 15.8333C9.1665 16.2936 9.5396 16.6667 9.99984 16.6667Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Js(e){var t=Xs();k(e,t)}var Qs=(e,t)=>C(t,!c(t)),$s=I('<div class="content svelte-zpsd2z"><!></div>'),ec=I('<div class="context-menu svelte-zpsd2z"><button class="svelte-zpsd2z"><!></button> <!></div>');function tc(e,t){ae(t,!0);let n=U(!1),i=U(null);function r(u){var _;const f=u.target;f===c(i)||(_=c(i))!=null&&_.contains(f)||C(n,!1)}var a=ec();ce("click",pe,r);var o=b(a);o.__click=[Qs,n];var s=b(o);Js(s),$t(o,u=>C(i,u),()=>c(i));var l=E(o,2);{var d=u=>{var f=$s(),_=b(f);Pt(_,()=>t.children),je(1,f,()=>En,()=>({duration:150,y:5})),k(u,f)};q(l,u=>{c(n)&&u(d)})}N(()=>{ue(o,"aria-label",t.ariaLabel),ue(o,"aria-expanded",c(n))}),k(e,a),oe()}fe(["click"]);function nc(e,t,n,i){var r,a;c(t)&&(be(ye.ManualReport,n.linkInjection.title_details,{report_reason:c(t),sid:n.linkInjection.sid,title:n.linkInjection.title,sentence:n.linkInjection.sentence,failed:(r=n.linkInjection.failed)==null?void 0:r.toString(),failed_message:n.linkInjection.failed_message,manual:(a=n.linkInjection.manual)==null?void 0:a.toString()}),C(i,!0),setTimeout(n.onclose,3e3))}var ic=(e,t,n)=>C(t,X(n())),rc=I('<option class="svelte-o5qkco"> </option>'),ac=I('<div class="sent svelte-o5qkco">Report has been sent, thank you! Closing window...</div>'),oc=I('<button class="submit svelte-o5qkco">Send report</button>'),lc=I('<div class="form svelte-o5qkco"><div class="heading svelte-o5qkco">Report issue</div> <div class="info svelte-o5qkco"><div><strong class="svelte-o5qkco">Title</strong> </div> <div><strong class="svelte-o5qkco">Sentence</strong> </div></div> <label for="reason">What would you like to report?</label> <select id="reason" name="reason" class="svelte-o5qkco"><option class="svelte-o5qkco">Select an issue...</option><!></select> <div><!></div></div>');function sc(e,t){ae(t,!0);const n=[{value:"failed_injection",label:"The link failed to appear on the page."},{value:"layout_issue",label:"The link is breaking the layout or formatting of my page."},{value:"wrong_content",label:"The link points to the wrong movie or show."},{value:"inappropriate_title",label:"The link points to an inappropriate movie or show."},{value:"broken_link",label:"The link is broken or leads to an error page."},{value:"other",label:"My issue is not listed, but please have a look regardless."}];let i=U(""),r=U(!1);Fr(e,{get onclose(){return t.onclose},children:(a,o)=>{var s=lc(),l=b(s);Qt(l,(x,T)=>xe==null?void 0:xe(x,T),()=>2);var d=E(l,2),u=b(d),f=E(b(u)),_=E(u,2),m=E(b(_));N(()=>G(m,`:
|
|
10
|
+
`)}function fs(e,t={aiInjections:[],manualInjections:[]}){vi();const n=ws(t);if(!n)return[];const i=Te(e.map(l=>l.innerText).join(" ")),r=ks(n),a=r.filter(l=>i.includes(Te(l.sentence))),o={};for(const l of a){const d=e.findIndex(S=>Te(S.innerText).includes(Te(l.sentence))),u=e[d];if(!u)continue;const f=Oi(l.title,u,["A"]);if(!(f!=null&&f.nodeValue)||Di(f)){const S=Oi(l.title,u);if(S&&Di(S)){o[l.key]="Given text is already inside of a link.";continue}}const{injectionElement:_,linkElement:m}=vs(l),{phrase_before:g,phrase_after:v}=l;let p=-1,y=!1;if(ls(Te(u.innerText),Te(l.title))===1&&(p=u.innerHTML.indexOf(l.title)),p===-1&&(g||v)){const S=[g,l.title,v].filter(Boolean).join(" ");if(p=u.innerHTML.indexOf(S),p===-1){const j=cs(u.innerHTML,l.title,g||"",v||"");if(j){const{leadingSpaces:x,trailingSpaces:T}=us(j.match);m.innerHTML=j.match.trim();const H=j.index+x,M=j.index+j.match.length-T;u.innerHTML=as(u.innerHTML,_.outerHTML,H,M),p=j.index,y=!0}}}if(p===-1&&(f!=null&&f.nodeValue)){const S=u.innerHTML.indexOf(f.nodeValue),j=u.innerHTML.indexOf(l.sentence);p=Math.max(S,j,0)}p!==-1&&(y||(u.innerHTML=rs(u.innerHTML,l.title,_.outerHTML,p)))}hs(r),_s();const s=bs(n);return s.length&&ms(e,s),n.filter(l=>l.title_details).map((l,d)=>{const u=l.duplicate??(!l.manual&&xs(l,d,n)),f=document.querySelector(`[${ut}="${l.key}"]`),_=Tn(l)&&!l.inactive&&!l.after_article&&!f,m=!!e.find(v=>Te(v.innerText).includes(Te(l.sentence))),g=_?o[l.key]||(m?"The link failed to inject for unknown reasons.":"Given sentence was not found in the article."):"";return{...l,inactive:l.inactive??!1,duplicate:u,failed:_,failed_message:g}})}function vs(e){const t=document.createElement("span");t.dataset.playpilotInjectionKey=e.key;const n=document.createElement("a");return n.innerText=e.title,n.href=e.playpilot_url,n.target="_blank",n.rel="noopener nofollow noreferrer",t.insertAdjacentElement("beforeend",n),{injectionElement:t,linkElement:n}}function _s(){const e=Array.from(document.querySelectorAll(`${Nt} a`)),t=["--playpilot-injection-text-color","--playpilot-injection-text-color-hover","--playpilot-injection-font-weight","--playpilot-injection-font-weight-headings","--playpilot-injection-text-decoration","--playpilot-injection-text-decoration-hover","--playpilot-injection-background-color","--playpilot-injection-background-color-hover"];e.forEach(n=>{t.forEach(i=>{getComputedStyle(n).getPropertyValue(i)&&(n.dataset.usedCssVariables=`${n.dataset.usedCssVariables||""} ${i}`)})})}function hs(e){window.addEventListener("click",n=>{if(Wr(n))return;let i=n.target;if(!i||(i.hasAttribute(ut)||(i=i.closest(Nt)),!i))return;const r=i.getAttribute(ut);if(!r)return;const a=e.find(o=>r===o.key);a&&(n.preventDefault(),ds(()=>{_n(!1),Yr(n,a)},!ui.current&&window.innerWidth>=600&&!window.matchMedia("(pointer: coarse)").matches))}),window.addEventListener("mousemove",n=>{if(!dt)return;const i=n.target;i.hasAttribute("data-playpilot-title-popover")||i.closest("[data-playpilot-title-popover]")||i.hasAttribute(ut)||i.closest(Nt)||_n()}),Array.from(document.querySelectorAll(Nt)).forEach(n=>{const i=n.dataset.playpilotInjectionKey,r=e.find(a=>i===a.key);r&&(n.addEventListener("mouseenter",a=>{dt||gs(a,r)}),n.addEventListener("mouseleave",()=>vn=null))})}function Yr(e,t){Wr(e)||Dt||(e.preventDefault(),Dt=Jt(Fl,{target:$r(),props:{title:t.title_details,onclose:Zr}}))}function Zr(e=!0){Dt&&(bn(Dt,{outro:e}),Dt=null)}function gs(e,t){if(window.matchMedia("(pointer: coarse)").matches)return;dt&&_n();const n=e.currentTarget;vn=n,setTimeout(()=>{vn===n&&(dt=Jt(Wl,{target:$r(),props:{event:e,title:t.title_details}}))},100)}function _n(e=!0){dt&&(bn(dt,{outro:e}),vn=null,dt=null)}function ms(e,t){var o,s;if(Ot||!t.length)return;const n=document.createElement("div"),i=(o=window.PlayPilotLinkInjections)==null?void 0:o.after_article_selector,r=(i?document.querySelector(i):null)||e[e.length-1],a=((s=window.PlayPilotLinkInjections)==null?void 0:s.after_article_insert_position)||"afterend";n.dataset.playpilotAfterArticlePlaylinks="true",r.insertAdjacentElement(a,n),Ot=Jt(ns,{target:n,props:{linkInjections:t,onclickmodal:(l,d)=>Yr(l,d)}})}function ps(){var e;Ot&&(bn(Ot),(e=document.querySelector("[data-playpilot-after-article-playlinks]"))==null||e.remove(),Ot=null)}function vi(){document.querySelectorAll(Nt).forEach(t=>ys(t.getAttribute(ut)||"")),ps(),Zr(!1),_n(!1)}function ys(e){var i;const t=document.querySelector(`[${ut}="${e}"]`);if(!t)return;const n=(i=t.querySelector("a"))==null?void 0:i.innerHTML;t.outerHTML=n||""}function ws({aiInjections:e,manualInjections:t}){return[...t.map(n=>({...n,manual:!0})),...e]}function Gr(e){return{aiInjections:e.filter(t=>!t.manual),manualInjections:e.filter(t=>t.manual)}}function Xr(e){return!e.inactive&&!e.removed&&!e.duplicate&&!!e.title_details&&Tn(e)}function Tn(e){return e.in_text||e.in_text===void 0?!0:!!e.after_article}function ks(e){return Jr(e).filter(t=>t.in_text!==!1&&Xr(t))}function bs(e){return Jr(e).filter(t=>t.after_article===!0&&Xr(t))}function Jr(e){return e.filter(t=>t.removed||t.inactive?!1:t.manual&&!t.removed&&!t.inactive?!0:!e.some(n=>n.manual&&(n.removed||n.inactive)&&Qr(n,t)))}function xs(e,t,n){return n.some((i,r)=>t!==r&&i.manual&&Qr(i,e))}function Qr(e,t){return e.title===t.title&&Te(e.sentence)===Te(t.sentence)}function $r(){return document.querySelector("[data-playpilot-link-injections]")||document.body}function _i(){const e=St();return{content_heading:Ss(e),content_modified_time:Es(e),content_published_time:Ts(e)}}function Ss(e){const t=e.querySelector("h1")||document.querySelector("h1");return(t==null?void 0:t.innerText.trim())||null}function Es(e){const t=document.querySelector('meta[property*="modified_time"]')||document.querySelector('meta[name*="modified_time"]')||e.querySelector('[itemprop="dateModified"]')||document.querySelector('[itemprop="dateModified"]')||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?hi(n):null}function Ts(e){const t=document.querySelector('meta[property*="published_time"]')||document.querySelector('meta[name*="published_time"]')||e.querySelector('[itemprop="datePublished"]')||document.querySelector('[itemprop="datePublished"]')||e.querySelector("time")||document.querySelector("time")||e.querySelector("[datetime]")||document.querySelector("[datetime]")||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?hi(n):null}function hi(e){try{return new Date(e).toISOString()}catch{return null}}let On=null;async function en(e,{url:t=ai(),hash:n=rl(e||""),params:i={}}={}){const r=new Headers({"Content-Type":"application/json"}),a=In(),o=Rr()?await Dr():!1,s=Hr();if(!a)throw new Error("No token was provided");i.metadata=_i(),i.run_ai&&(i.hash=n,i.page_text=e);const l=await fetch(Sn+`/external-pages/?api-token=${a}&include_title_details=true${o?"&editorial_mode_enabled=true":""}&language=${s}`,{headers:r,method:"POST",body:JSON.stringify({url:t,...i})});if(!l.ok)throw l;const d=await l.json();return window.PlayPilotLinkInjections.last_successful_fetch=d,d}async function Hi(e,{requireCompletedResult:t=!1,runAiWhenRelevant:n=!1,pollInterval:i=3e3,maxTries:r=600,onpoll:a=()=>null}={}){let o=0;On&&clearTimeout(On);const s=async(l,d)=>{let u;try{if(u=await en(e),n&&(u=await Is(e,u)),t&&u.ai_enabled&&u.ai_running)throw new Error;u.manual_injections=Bi(u.manual_injections||[]),u.ai_injections=Bi(u.ai_injections||[]),l(u);return}catch{if(o++,o>=r){r>1&&console.error("Max poll limit exceeded. Please return later."),l();return}u&&a(u),On=setTimeout(()=>s(l),i)}};return new Promise(s)}async function Is(e,t){if(!e||!t.ai_enabled||t.ai_running)return t;const n=_i().content_modified_time,i=t.content_modified_time?hi(t.content_modified_time):null,r=n&&i===n;return t.ai_last_run&&r?t:await en(e,{params:{run_ai:!0}})}async function As(e,t){var o;const n=(o=window.PlayPilotLinkInjections)==null?void 0:o.selector,r=e.filter(s=>s.manual).map(s=>({sid:s.sid,title:s.title,sentence:s.sentence,phrase_before:s.phrase_before,phrase_after:s.phrase_after,playpilot_url:s.playpilot_url,after_article:!!s.after_article,after_article_style:s.after_article_style||null,in_text:s.in_text??!0,inactive:!!s.inactive,removed:!!s.removed}));if(!await en(t,{params:{private_token:li(),manual_injections:r,content_text_selector:n}}))throw new Error("saveLinkInjections response was faulty");return e}async function Cs(){const e=new Headers({"Content-Type":"application/json"}),t=In();if(!t)throw new Error("No token was provided");const n=await fetch(Sn+`/domains/config?api-token=${t}`,{headers:e});if(!n.ok)throw n;try{return await n.json()||null}catch{return null}}function Bi(e){return e.map(t=>({...t,key:ea(t.sid)}))}function ea(e){return e+"-"+qr()}function In(){var e;return(e=window.PlayPilotLinkInjections)==null?void 0:e.token}function Ps(){const e=navigator.userAgent.toLowerCase();return/bot|crawl|spider|google|baidu|bing|msn|teoma|slurp|yandex|facebookexternalhit|facebot/i.test(e)}var js=Le('<svg width="8" height="4" viewBox="0 0 8 4" fill="none" class="svelte-by11ix"><path d="M1 0.5L4 3.5L7 0.5" stroke="currentColor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ms(e,t){const n=L(t,"expanded",3,!1);var i=js();N(()=>se(i,"expanded",n())),k(e,i)}var Ls=Le('<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="17" r="1" fill="var(--playpilot-warning)"></circle><path d="M12 10L12 14" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M3.44722 18.1056L10.2111 4.57771C10.9482 3.10361 13.0518 3.10362 13.7889 4.57771L20.5528 18.1056C21.2177 19.4354 20.2507 21 18.7639 21H5.23607C3.7493 21 2.78231 19.4354 3.44722 18.1056Z" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ns(e){var t=Ls();k(e,t)}function Os(e,t,n){t(!t()),n()(t())}var Ds=I('<button class="switch svelte-91s87b"><div class="label svelte-91s87b"><!></div> <div class="track svelte-91s87b"><div class="knob svelte-91s87b"></div></div></button>');function Wn(e,t){ae(t,!0);let n=L(t,"active",15),i=L(t,"fullwidth",3,!1),r=L(t,"label",3,""),a=L(t,"onclick",3,()=>null);var o=Ds();o.__click=[Os,n,a];var s=b(o),l=b(s);Pt(l,()=>t.children),N(()=>{ue(o,"aria-label",`Toggle ${r()??""} ${(n()?"off":"on")??""}`),se(o,"active",n()),se(o,"fullwidth",i())}),k(e,o),oe()}fe(["click"]);var Rs=I('<input type="text" autocomplete="off" class="svelte-1vrer3i">');function gi(e,t){let n=L(t,"value",15),i=L(t,"label",3,""),r=L(t,"name",3,""),a=L(t,"readonly",3,!1),o=L(t,"oninput",3,()=>null);var s=Rs();s.__input=function(...l){var d;(d=o())==null||d.apply(this,l)},N(()=>{ue(s,"name",r()),ue(s,"aria-label",i()),ue(s,"placeholder",i()),s.readOnly=a()}),Bo(s,n),k(e,s)}fe(["input"]);var qs=Le('<path d="M13.5833 13.6667L4.41667 13.6667M5.5 1.5H12.5C13.9001 1.5 14.6002 1.5 15.135 1.77248C15.6054 2.01217 15.9878 2.39462 16.2275 2.86502C16.5 3.3998 16.5 4.09987 16.5 5.5V12.5C16.5 13.9001 16.5 14.6002 16.2275 15.135C15.9878 15.6054 15.6054 15.9878 15.135 16.2275C14.6002 16.5 13.9001 16.5 12.5 16.5H5.5C4.09987 16.5 3.3998 16.5 2.86502 16.2275C2.39462 15.9878 2.01217 15.6054 1.77248 15.135C1.5 14.6002 1.5 13.9001 1.5 12.5V5.5C1.5 4.09987 1.5 3.3998 1.77248 2.86502C2.01217 2.39462 2.39462 2.01217 2.86502 1.77248C3.3998 1.5 4.09987 1.5 5.5 1.5Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Hs=Le('<path d="M13.5833 8.58342H4.41667M5.5 1.50009H12.5C13.9001 1.50009 14.6002 1.50009 15.135 1.77258C15.6054 2.01226 15.9878 2.39471 16.2275 2.86512C16.5 3.39989 16.5 4.09996 16.5 5.50009V12.5001C16.5 13.9002 16.5 14.6003 16.2275 15.1351C15.9878 15.6055 15.6054 15.9879 15.135 16.2276C14.6002 16.5001 13.9001 16.5001 12.5 16.5001H5.5C4.09987 16.5001 3.3998 16.5001 2.86502 16.2276C2.39462 15.9879 2.01217 15.6055 1.77248 15.1351C1.5 14.6003 1.5 13.9002 1.5 12.5001V5.50009C1.5 4.09996 1.5 3.39989 1.77248 2.86512C2.01217 2.39471 2.39462 2.01226 2.86502 1.77258C3.3998 1.50009 4.09987 1.50009 5.5 1.50009Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Bs=Le('<svg width="18" height="18" viewBox="0 0 18 18" fill="none"><!></svg>');function Fi(e,t){const n=L(t,"align",3,"bottom");var i=Bs(),r=b(i);{var a=s=>{var l=qs();k(s,l)},o=s=>{var l=Fe(),d=ne(l);{var u=f=>{var _=Hs();k(f,_)};q(d,f=>{n()==="center"&&f(u)},!0)}k(s,l)};q(r,s=>{n()==="bottom"?s(a):s(o,!1)})}k(e,i)}var Fs=I("<div><!></div>");function ht(e,t){ae(t,!0);const n=L(t,"type",3,"error"),i=L(t,"fixed",3,!1);var r=Fs(),a=b(r);Pt(a,()=>t.children),N(()=>{No(r,`alert ${n()??""} svelte-df5n87`),se(r,"fixed",i())}),k(e,r),oe()}var Vs=I("<!> In-text Playlink",1),Us=I("<!> Bottom Playlink",1),zs=I('<div class="alert svelte-1shw34x"><!></div>'),Ws=(e,t)=>t().after_article_style="playlinks",Ks=(e,t)=>t().after_article_style="modal_button",Ys=I('<div><div class="label svelte-1shw34x">Bottom playlinks style</div> <div class="group svelte-1shw34x" role="listbox" tabindex="0" aria-label="Playlink type"><button role="option" id="playlinks-in-text" class="svelte-1shw34x">Playlinks sentence</button> <button role="option" id="playlinks-after-article" class="svelte-1shw34x">Modal button</button> <div class="active-marker svelte-1shw34x"></div></div></div>'),Zs=I('<div class="switches svelte-1shw34x"><!> <!></div> <!> <!>',1);function Gs(e,t){ae(t,!0);const n=L(t,"linkInjection",7),i=K(()=>n().after_article_style==="modal_button");var r=Zs(),a=ne(r),o=b(a),s=K(()=>n().in_text??!0);Wn(o,{fullwidth:!0,get active(){return c(s)},onclick:g=>{n().in_text=g,n().manual=!0},label:"In-text Playlink",children:(g,v)=>{var p=Vs(),y=ne(p);Fi(y,{align:"center"}),k(g,p)},$$slots:{default:!0}});var l=E(o,2),d=K(()=>n().after_article??!1);Wn(l,{fullwidth:!0,get active(){return c(d)},onclick:g=>{n().after_article=g,n().manual=!0},label:"Bottom Playlink",children:(g,v)=>{var p=Us(),y=ne(p);Fi(y,{align:"bottom"}),k(g,p)},$$slots:{default:!0}});var u=E(a,2);{var f=g=>{var v=zs(),p=b(v);ht(p,{type:"warning",children:(y,w)=>{var S=Be("At least one layout option must be selected for the playlink to be visible.");k(y,S)},$$slots:{default:!0}}),je(3,v,()=>Vt,()=>({duration:200})),k(g,v)};q(u,g=>{Tn(n())||g(f)})}var _=E(u,2);{var m=g=>{var v=Ys(),p=E(b(v),2),y=b(p);y.__click=[Ws,n];var w=E(y,2);w.__click=[Ks,n];var S=E(w,2);N(()=>{ue(p,"aria-activedescendant",`playlinks-${(c(i)?"after-article":"in-text")??""}`),ue(y,"aria-selected",!c(i)||null),se(y,"active",!c(i)),ue(w,"aria-selected",c(i)||null),se(w,"active",c(i)),se(S,"right",c(i))}),je(3,v,()=>Vt,()=>({duration:100})),k(g,v)};q(_,g=>{n().after_article&&g(m)})}k(e,r),oe()}fe(["click"]);var Xs=Le('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.99984 10.8333C10.4601 10.8333 10.8332 10.4602 10.8332 10C10.8332 9.53977 10.4601 9.16668 9.99984 9.16668C9.5396 9.16668 9.1665 9.53977 9.1665 10C9.1665 10.4602 9.5396 10.8333 9.99984 10.8333Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 5.00001C10.4601 5.00001 10.8332 4.62691 10.8332 4.16668C10.8332 3.70644 10.4601 3.33334 9.99984 3.33334C9.5396 3.33334 9.1665 3.70644 9.1665 4.16668C9.1665 4.62691 9.5396 5.00001 9.99984 5.00001Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 16.6667C10.4601 16.6667 10.8332 16.2936 10.8332 15.8333C10.8332 15.3731 10.4601 15 9.99984 15C9.5396 15 9.1665 15.3731 9.1665 15.8333C9.1665 16.2936 9.5396 16.6667 9.99984 16.6667Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Js(e){var t=Xs();k(e,t)}var Qs=(e,t)=>C(t,!c(t)),$s=I('<div class="content svelte-zpsd2z"><!></div>'),ec=I('<div class="context-menu svelte-zpsd2z"><button class="svelte-zpsd2z"><!></button> <!></div>');function tc(e,t){ae(t,!0);let n=U(!1),i=U(null);function r(u){var _;const f=u.target;f===c(i)||(_=c(i))!=null&&_.contains(f)||C(n,!1)}var a=ec();ce("click",pe,r);var o=b(a);o.__click=[Qs,n];var s=b(o);Js(s),$t(o,u=>C(i,u),()=>c(i));var l=E(o,2);{var d=u=>{var f=$s(),_=b(f);Pt(_,()=>t.children),je(1,f,()=>En,()=>({duration:150,y:5})),k(u,f)};q(l,u=>{c(n)&&u(d)})}N(()=>{ue(o,"aria-label",t.ariaLabel),ue(o,"aria-expanded",c(n))}),k(e,a),oe()}fe(["click"]);function nc(e,t,n,i){var r,a;c(t)&&(be(ye.ManualReport,n.linkInjection.title_details,{report_reason:c(t),sid:n.linkInjection.sid,title:n.linkInjection.title,sentence:n.linkInjection.sentence,failed:(r=n.linkInjection.failed)==null?void 0:r.toString(),failed_message:n.linkInjection.failed_message,manual:(a=n.linkInjection.manual)==null?void 0:a.toString()}),C(i,!0),setTimeout(n.onclose,3e3))}var ic=(e,t,n)=>C(t,X(n())),rc=I('<option class="svelte-o5qkco"> </option>'),ac=I('<div class="sent svelte-o5qkco">Report has been sent, thank you! Closing window...</div>'),oc=I('<button class="submit svelte-o5qkco">Send report</button>'),lc=I('<div class="form svelte-o5qkco"><div class="heading svelte-o5qkco">Report issue</div> <div class="info svelte-o5qkco"><div><strong class="svelte-o5qkco">Title</strong> </div> <div><strong class="svelte-o5qkco">Sentence</strong> </div></div> <label for="reason">What would you like to report?</label> <select id="reason" name="reason" class="svelte-o5qkco"><option class="svelte-o5qkco">Select an issue...</option><!></select> <div><!></div></div>');function sc(e,t){ae(t,!0);const n=[{value:"failed_injection",label:"The link failed to appear on the page."},{value:"layout_issue",label:"The link is breaking the layout or formatting of my page."},{value:"wrong_content",label:"The link points to the wrong movie or show."},{value:"inappropriate_title",label:"The link points to an inappropriate movie or show."},{value:"broken_link",label:"The link is broken or leads to an error page."},{value:"other",label:"My issue is not listed, but please have a look regardless."}];let i=U(""),r=U(!1);Fr(e,{get onclose(){return t.onclose},children:(a,o)=>{var s=lc(),l=b(s);Qt(l,(x,T)=>xe==null?void 0:xe(x,T),()=>2);var d=E(l,2),u=b(d),f=E(b(u)),_=E(u,2),m=E(b(_));N(()=>G(m,`:
|
|
11
11
|
${zr(t.linkInjection.sentence,t.linkInjection.title,100)??""}`));var g=E(d,4),v=b(g);v.value=((v.__value="")==null,"");var p=E(v);at(p,17,()=>n,xt,(x,T)=>{let H=()=>c(T).value,M=()=>c(T).label;var A=rc(),D={};A.__click=[ic,i,H];var P=b(A);N(()=>{D!==(D=H())&&(A.value=(A.__value=H())==null?"":H()),G(P,M())}),k(x,A)});var y=E(g,2),w=b(y);{var S=x=>{var T=ac();je(1,T,()=>Ft,()=>({duration:200})),k(x,T)},j=x=>{var T=oc();T.__click=[nc,i,t,r],N(()=>T.disabled=!c(i)),k(x,T)};q(w,x=>{c(r)?x(S):x(j,!1)})}N(()=>G(f,`: ${t.linkInjection.title??""}`)),Vo(g,()=>c(i),x=>C(i,x)),k(a,s)},$$slots:{default:!0}}),oe()}fe(["click"]);function cc(e,t,n){requestAnimationFrame(()=>t());const i=e.target;if(["BUTTON","INPUT"].includes(i.nodeName)||i.closest("button")||i.closest("input"))return;const r=n()[0];r&&r.scrollIntoView({behavior:"smooth"})}function uc(e,t){const n=Jt(sc,{target:document.body,props:{linkInjection:t(),onclose:()=>bn(n)}})}var dc=(e,t)=>C(t,!c(t)),fc=I('<button class="expand-sentence svelte-lo6h85"> </button>'),vc=I('<button class="context-menu-action svelte-lo6h85">Remove</button> <button class="context-menu-action svelte-lo6h85">Report issue</button>',1),_c=(e,t)=>C(t,!c(t)),hc=I('<div class="warning svelte-lo6h85" aria-label="Invalid playlink settings"><!></div>'),gc=I('<div class="actions svelte-lo6h85"><button class="expand svelte-lo6h85" aria-label="Expand"><!></button> <!> <!></div>'),mc=I('<div class="expanded svelte-lo6h85"><div class="label svelte-lo6h85">Link URL</div> <!> <div class="label offset svelte-lo6h85">Layout options</div> <div class="type-select svelte-lo6h85"><!></div></div>'),pc=I('<div class="item svelte-lo6h85"><div class="header svelte-lo6h85"><img class="poster svelte-lo6h85" alt="" width="32" height="48"> <div class="info svelte-lo6h85"><div class="title svelte-lo6h85"> </div> <div class="sentence svelte-lo6h85"><!> <!></div></div> <div class="context-menu svelte-lo6h85"><!></div></div> <div class="content svelte-lo6h85"><!> <!></div></div>');function yc(e,t){ae(t,!0);const n=L(t,"linkInjection",15),i=L(t,"onremove",3,()=>null),r=L(t,"onhighlight",3,()=>null),a=K(()=>n()||{}),o=K(()=>c(a).key),s=K(()=>c(a).sentence),l=K(()=>c(a).title_details),d=K(()=>c(a).failed),u=K(()=>c(a).failed_message),f=K(()=>c(a).inactive),_=K(()=>c(l)),m=K(()=>zr(n().sentence,n().title,60));let g=U(!1),v=U(!1),p=U(!1),y=U(null);Je(()=>{c(d)&&be(ye.InjectionFailed,c(_),{phrase:n().title,sentence:c(s)})});function w(Q=!0){j().forEach(le=>{le.classList.toggle("playpilot-injection-highlight",Q)})}function S(Q){let te=Q.target,le=te==null?void 0:te.dataset.playpilotInjectionKey;te&&!le&&(te=te.closest(`[data-playpilot-injection-key="${c(o)}"]`),le=te==null?void 0:te.dataset.playpilotInjectionKey),C(p,le===c(o)),c(y)&&c(p)&&r()(c(y))}function j(){const Q=Array.from(document.querySelectorAll(`[data-playpilot-injection-key="${c(o)}"]`));return Q.length?Q:fi(St()).filter(te=>Te(te.innerText).includes(Te(n().sentence)))||[]}var x=pc();ce("mouseover",pe,S),x.__click=[cc,w,j];var T=b(x),H=b(T);N(()=>ue(H,"src",Ut(c(_).standing_poster)));var M=E(H,2),A=b(M),D=b(A),P=E(A,2),B=b(P);Ao(B,()=>(c(v)?c(s):c(m)).replace(n().title,`<em>${n().title}</em>`));var O=E(B,2);{var z=Q=>{var te=fc();te.__click=[dc,v];var le=b(te);N(()=>G(le,c(v)?"Less":"More")),k(Q,te)};q(O,Q=>{c(m).length<c(s).length&&Q(z)})}var F=E(M,2),V=b(F);tc(V,{ariaLabel:"More options",children:(Q,te)=>{var le=vc(),Ce=ne(le);Ce.__click=function(...ot){var R;(R=i())==null||R.apply(this,ot)};var Qe=E(Ce,2);Qe.__click=[uc,n],k(Q,le)},$$slots:{default:!0}});var W=E(T,2),J=b(W);{var ee=Q=>{ht(Q,{children:(te,le)=>{var Ce=Be();N(()=>G(Ce,c(u))),k(te,Ce)},$$slots:{default:!0}})},re=Q=>{var te=gc(),le=b(te);le.__click=[_c,g];var Ce=b(le);Ms(Ce,{get expanded(){return c(g)}});var Qe=E(le,2);{var ot=ve=>{var Se=hc(),Ne=b(Se);Ns(Ne),je(3,Se,()=>Ft,()=>({duration:100})),k(ve,Se)};q(Qe,ve=>{Tn(n())||ve(ot)})}var R=E(Qe,2),Y=K(()=>c(f)?"Inactive":"Visible"),_e=K(()=>!n().inactive);Wn(R,{get label(){return c(Y)},get active(){return c(_e)},onclick:ve=>{n(n().inactive=!ve,!0),n(n().manual=!0,!0)},children:(ve,Se)=>{var Ne=Be();N(()=>G(Ne,c(f)?"Inactive":"Visible")),k(ve,Ne)},$$slots:{default:!0}}),N(()=>ue(le,"aria-expanded",c(g))),k(Q,te)};q(J,Q=>{c(d)?Q(ee):Q(re,!1)})}var de=E(J,2);{var Ae=Q=>{var te=mc(),le=E(b(te),2);gi(le,{oninput:()=>n(n().manual=!0,!0),label:"Playlink URL",get value(){return n().playpilot_url},set value(ot){n(n().playpilot_url=ot,!0)}});var Ce=E(le,4),Qe=b(Ce);Gs(Qe,{get linkInjection(){return n()}}),je(3,te,()=>Vt,()=>({duration:100})),k(Q,te)};q(de,Q=>{c(g)&&Q(Ae)})}$t(x,Q=>C(y,Q),()=>c(y)),N(()=>{se(x,"highlighted",c(p)),se(x,"inactive",c(f)),G(D,c(_).title)}),ce("mouseenter",x,()=>w(!0)),ce("mouseleave",x,()=>w(!1)),ce("error",H,({target:Q})=>Q.src=Lr),je(6,x,()=>Vt,()=>({duration:200})),k(e,x),oe()}fe(["click"]);var wc=I('<button class="drag-handle svelte-19mcc5g" aria-label="Move editor"></button>');function kc(e,t){ae(t,!0);let n=L(t,"element",7),i=L(t,"position",23,()=>({x:0,y:0})),r=L(t,"limit",19,()=>({x:0,y:0})),a=L(t,"onchange",3,()=>null),o=!1,s={x:0,y:0},l=i();Je(()=>{d(i().x,i().y)});function d(v,p){const y=window.innerWidth,w=window.innerHeight,S=n().clientWidth,j=n().clientHeight;v=Math.min(Math.max(v,r().x),y-S-r().x),p=Math.min(Math.max(p,r().y),w-j-r().y),n().style.right=v+"px",n().style.bottom=Math.max(p,r().y)+"px",i({x:v,y:p}),a()(i())}function u(v){var p,y;return{x:v.pageX||((p=v.touches)==null?void 0:p[0].pageX)||0,y:v.pageY||((y=v.touches)==null?void 0:y[0].pageY)||0}}function f(v){o=!0,s=u(v),l=i()}function _(v){if(!o)return;const p=u(v),y=p.x-s.x,w=p.y-s.y,S=l.x-y,j=l.y-w;d(S,j)}function m(){o&&(o=!1)}var g=wc();ce("mousemove",pe,_),ce("touchmove",pe,_,void 0,!0),ce("mouseup",pe,m),ce("touchend",pe,m),ce("resize",pe,()=>d(i().x,i().y)),g.__mousedown=f,g.__touchstart=f,k(e,g),oe()}fe(["mousedown","touchstart"]);var bc=I('<button class="resize-handle svelte-sxkuxk" aria-label="Move editor"></button>');function xc(e,t){ae(t,!0);let n=L(t,"element",7),i=L(t,"height",7,200),r=L(t,"onchange",3,()=>null);const a=16;let o=!1,s=0,l=i();Je(()=>{i()&&d(i())});function d(v){const p=window.getComputedStyle(n()).minHeight||"0",y=Math.max(parseInt(p),Math.min(v,m()));n().style.height=`${y}px`,i(y),r()(y)}function u(v){var p,y;o=!0,s=v.pageY||((y=(p=v.touches)==null?void 0:p[0])==null?void 0:y.pageY)||0,l=n().clientHeight}function f(v){var S,j;if(!o)return;const p=v.pageY||((j=(S=v.touches)==null?void 0:S[0])==null?void 0:j.pageY)||0,y=s-p,w=l+y;d(w)}function _(){o=!1}function m(){const v=window.innerHeight-n().getBoundingClientRect().bottom;return Math.max(window.innerHeight-a*2-v,0)}var g=bc();ce("mousemove",pe,f),ce("touchmove",pe,f,void 0,!0),ce("mouseup",pe,_),ce("touchend",pe,_),ce("resize",pe,()=>{i()&&d(i())}),g.__mousedown=u,g.__touchstart=u,k(e,g),oe()}fe(["mousedown","touchstart"]);var Sc=Le('<svg width="4" height="8" viewBox="0 0 4 8" fill="none"><path d="M3.5 7L0.5 4L3.5 1" stroke="currentcolor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ec(e){var t=Sc();k(e,t)}async function Tc(e){const t=new Headers({"Content-Type":"application/json"}),n=In();if(!n)throw new Error("No token was provided");const i=await fetch(Sn+`/search/titles/?api-token=${n}&query=${e}`,{headers:t});if(!i.ok)throw i;return await i.json()}var Ic=Le('<svg viewBox="0 -960 960 960" width="18" height="18"><path fill="currentColor" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"></path></svg>');function Ac(e){var t=Ic();k(e,t)}var Cc=I("<div> </div>"),Pc=e=>e.stopImmediatePropagation(),jc=I('<button class="item svelte-rjq94e"><img class="poster svelte-rjq94e" alt="" width="28" height="42"> <div class="content"><div class="name svelte-rjq94e"> </div> <div class="meta svelte-rjq94e"><div class="imdb svelte-rjq94e"><!> </div> <div> </div> <div> </div> <!></div></div> <a target="_blank" class="open-in-new-tab svelte-rjq94e"><!></a></button>');function Vi(e,t){ae(t,!0);const n=L(t,"hoverable",3,!0),i=L(t,"onclick",3,()=>null);var r=jc();r.__click=function(...x){var T;(T=i())==null||T.apply(this,x)};var a=b(r);N(()=>ue(a,"src",Ut(t.title.standing_poster)));var o=E(a,2),s=b(o),l=b(s),d=E(s,2),u=b(d),f=b(u);Vr(f);var _=E(f),m=E(u,2),g=b(m),v=E(m,2),p=b(v),y=E(v,2);{var w=x=>{var T=Cc(),H=b(T);N(()=>G(H,`${t.title.length??""} min`)),k(x,T)};q(y,x=>{t.title.length&&x(w)})}var S=E(o,2);S.__click=[Pc];var j=b(S);Ac(j),N(()=>{se(r,"hoverable",n()),G(l,t.title.title),G(_,` ${t.title.imdb_score??""}`),G(g,t.title.year),G(p,t.title.type),ue(S,"href",`${Mr}/${t.title.type??""}/${t.title.slug??""}`)}),ce("error",a,({target:x})=>x.src=Lr),k(e,r),oe()}fe(["click"]);var Mc=I('<em class="empty svelte-1olb8n0">No results found</em>'),Lc=I('<div class="results svelte-1olb8n0" data-testid="search-results"></div>'),Nc=I('<div class="selected svelte-1olb8n0"><!></div>'),Oc=I('<div class="search svelte-1olb8n0"><!> <!> <!></div>');function Dc(e,t){ae(t,!0);let n=L(t,"onselect",3,()=>null),i=L(t,"query",15),r=U(X([])),a=U(null),o=U(!1);pn(()=>{i()&&s(i())});async function s(v){C(o,!0);try{C(r,X(await Tc(v)))}finally{C(o,!1)}}function l(v){i(v.title),C(a,X(v)),n()(v)}var d=Oc(),u=b(d);gi(u,{oninput:()=>C(a,null),name:"search",label:"Search...",get value(){return i()},set value(v){i(v)}});var f=E(u,2);{var _=v=>{var p=Lc();at(p,21,()=>c(r),y=>y.sid,(y,w)=>{Vi(y,{get title(){return c(w)},onclick:()=>l(c(w))})},y=>{var w=Fe(),S=ne(w);{var j=x=>{var T=Mc();k(x,T)};q(S,x=>{c(o)||x(j)})}k(y,w)}),k(v,p)};q(f,v=>{i()&&!c(a)&&v(_)})}var m=E(f,2);{var g=v=>{var p=Nc(),y=b(p);Vi(y,{get title(){return c(a)},hoverable:!1}),k(v,p)};q(m,v=>{c(a)&&v(g)})}k(e,d),oe()}function Rc(e,t=e.anchorNode){if(!e.anchorNode||!t)return{start:-1,end:-1};const n=e.toString().trim(),i=e.toString().search(/\S/);if(e.anchorNode===t&&t.nodeType===Node.TEXT_NODE){const d=Math.min(e.anchorOffset,e.focusOffset)+i;return{start:d,end:d+n.length}}const r=e.getRangeAt(0),a=r.cloneRange();a.selectNodeContents(t),a.setEnd(r.startContainer,r.startOffset);const s=a.toString().length+i,l=s+n.length;return{start:s,end:l}}function qc(e,t,n,i,r,a,o,s){if(!c(t)||!c(n))return;const l=c(n).type==="movie"?"movie":"show",d=Mr+`/${l}/${c(n).slug}`,u={sid:c(n).sid,title:c(t),sentence:c(i),phrase_before:c(r),phrase_after:c(a),playpilot_url:d,key:ea(c(n).sid),title_details:c(n),manual:!0};o.onsave(u),s()()}var Hc=I('<div class="error svelte-1i8p6op"><!></div>'),Bc=I('<label for="text" class="svelte-1i8p6op">Paired title</label> <!>',1),Fc=I('<section class="layout svelte-1i8p6op"><div class="header svelte-1i8p6op"><!> <div class="heading svelte-1i8p6op">Add Playlink manually</div></div> <p class="svelte-1i8p6op">Highlight the text section in your post that you want to turn into a Playlink.</p> <label for="text" class="svelte-1i8p6op">Selected text</label> <!> <!> <!> <button class="save svelte-1i8p6op">Add playlink</button></section>');function Vc(e,t){ae(t,!0);const n=L(t,"pageText",3,""),i=L(t,"onclose",3,()=>null);let r=U(""),a=U(""),o=U(null),s=U(""),l=U(""),d=U(""),u=U("");Je(f);function f(){const A=window.getSelection();if(!(A!=null&&A.anchorNode)||A.anchorNode.parentElement&&!St().contains(A.anchorNode.parentElement))return;const D=A.toString().trim();if(!D)return;C(d,""),C(r,X(D));const P=A.getRangeAt(0).cloneContents();if(Array.from(P.childNodes).filter(ee=>{var re;return(re=ee.textContent)==null?void 0:re.trim()}).find(ee=>{var re;return ee.nodeName==="A"||((re=ee.querySelector)==null?void 0:re.call(ee,"a"))})){C(d,"Selection is or contains a link. Injections can not be created around already existing links.");return}C(u,X(c(r)));const{node:O,sentence:z}=_(A,D);if(!O)return;C(a,X(z));const{start:F,end:V}=Rc(A,O);(ee=>(C(l,X(ee.before)),C(s,X(ee.after))))(os(O,F,V)),z.includes(c(l))||C(l,""),z.includes(c(s))||C(s,"");const W=A.getRangeAt(0).commonAncestorContainer.textContent,J=Te(n());(!W||!J.includes(Te(W)))&&C(d,"Selection was not inside of given content")}function _(A,D){const P=A.getRangeAt(0),B=St();let O=P.startContainer;for(;(O.textContent||"").length<=D.length*3&&O.parentNode&&O.parentNode.textContent!==B.textContent;)O=O.parentNode;if(!O||!O.textContent)return{node:null,sentence:""};const z=O.textContent,F=m(O,P.startContainer,P.startOffset),V=m(O,P.endContainer,P.endOffset),W=z.slice(0,F).lastIndexOf("."),J=z.slice(V).match(/[.!?]/),ee=J?V+J.index:z.length,re=W===-1?0:W+1,de=ee,Ae=z.slice(re,de+1).trim();return{node:O,sentence:Ae}}function m(A,D,P){let B=0;const O=A,z=F=>{var V;if(F===D)return B+=P,!0;F.nodeType===Node.TEXT_NODE&&(B+=((V=F.textContent)==null?void 0:V.length)||0);for(let W=F.firstChild;W;W=W.nextSibling)if(z(W))return!0;return!1};return z(O),B}function g(A){var D,P;C(o,X(A)),(P=(D=window.getSelection())==null?void 0:D.removeAllRanges)==null||P.call(D)}var v=Fc();ce("mouseup",pe,f);var p=b(v),y=b(p);ci(y,{get onclick(){return i()},size:"24px",children:(A,D)=>{Ec(A)},$$slots:{default:!0}});var w=E(y,2);Qt(w,(A,D)=>xe==null?void 0:xe(A,D),()=>2);var S=E(p,6);gi(S,{get value(){return c(r)},label:"Select text on the page",name:"selected-text",readonly:!0});var j=E(S,2);{var x=A=>{var D=Hc(),P=b(D);ht(P,{children:(B,O)=>{var z=Be();N(()=>G(z,c(d))),k(B,z)},$$slots:{default:!0}}),k(A,D)};q(j,A=>{c(d)&&A(x)})}var T=E(j,2);{var H=A=>{var D=Bc(),P=E(ne(D),2);Ir(P,()=>c(a)+c(r),B=>{Dc(B,{onselect:g,get query(){return c(u)},set query(O){C(u,X(O))}})}),k(A,D)};q(T,A=>{c(d)||A(H)})}var M=E(T,2);M.__click=[qc,r,o,a,l,s,t,i],N(()=>M.disabled=!c(r)||!c(o)),k(e,v),oe()}fe(["click"]);const Kn="PlayPilotEditorialSessionId",ta=5e3,Uc=ta*2;async function zc(e){const{ai_enabled:t,injections_enabled:n,ai_last_run:i,session_id:r,session_last_ping:a}=await en(e),o=ia(r||null,a||null),s={ai_enabled:t,ai_last_run:i,injections_enabled:n,session_id:r,session_last_ping:a};return o?await na(e):s}async function na(e){const t=ra(),n=new Date(Date.now()).toISOString(),i={session_id:t,session_last_ping:n.toString()},{ai_enabled:r,injections_enabled:a,ai_last_run:o}=await en(e,{params:i});return{ai_enabled:r,ai_last_run:o,injections_enabled:a,...i}}function ia(e,t){if(!e||!t)return!0;const n=Date.now(),i=new Date(t),r=ra();return n-i.getTime()>Uc?!0:r===e}function ra(){return sessionStorage.getItem(Kn)||Wc()}function Wc(){const e=sessionStorage.getItem(Kn)||qr();return sessionStorage.setItem(Kn,e),e}function Kc(e,t,n){na(t()),n()()}var Yc=I('<p class="svelte-2m2urs"><strong>Someone else is currently editing this document.</strong> Wait for them to exit the page or take over edit permissions, preventing them from making more changes.</p> <button class="button svelte-2m2urs">Take over editing</button>',1),Zc=I('<div class="alert svelte-2m2urs"><!></div>');function Gc(e,t){ae(t,!0);const n=L(t,"pageText",3,""),i=L(t,"onpoll",3,()=>null),r=L(t,"onallow",3,()=>null),a=L(t,"ondisallow",3,()=>null),o=L(t,"ontakeover",3,()=>null);let s=null,l=U(!0);Je(()=>(d(),()=>{s&&clearInterval(s)}));function d(){u(),s=setInterval(u,ta)}async function u(){const g=await zc(n());g&&(C(l,X(ia(g.session_id||null,g.session_last_ping||null))),c(l)?r()():a()(),i()({injectionsEnabled:!!g.injections_enabled,aiEnabled:!!g.ai_enabled}))}var f=Fe(),_=ne(f);{var m=g=>{var v=Zc(),p=b(v);ht(p,{type:"warning",children:(y,w)=>{var S=Yc(),j=E(ne(S),2);j.__click=[Kc,n,o],k(y,S)},$$slots:{default:!0}}),k(g,v)};q(_,g=>{c(l)||g(m)})}k(e,f),oe()}fe(["click"]);var Xc=Le('<svg width="24px" height="24px" viewBox="0 0 64 64" stroke-width="3" stroke="currentColor" fill="none"><circle cx="34.52" cy="11.43" r="5.82"></circle><circle cx="53.63" cy="31.6" r="5.82"></circle><circle cx="34.52" cy="50.57" r="5.82"></circle><circle cx="15.16" cy="42.03" r="5.82"></circle><circle cx="15.16" cy="19.27" r="5.82"></circle><circle cx="34.51" cy="29.27" r="4.7"></circle><line x1="20.17" y1="16.3" x2="28.9" y2="12.93"></line><line x1="38.6" y1="15.59" x2="49.48" y2="27.52"></line><line x1="50.07" y1="36.2" x2="38.67" y2="46.49"></line><line x1="18.36" y1="24.13" x2="30.91" y2="46.01"></line><line x1="20.31" y1="44.74" x2="28.7" y2="48.63"></line><line x1="17.34" y1="36.63" x2="31.37" y2="16.32"></line><line x1="20.52" y1="21.55" x2="30.34" y2="27.1"></line><line x1="39.22" y1="29.8" x2="47.81" y2="30.45"></line><line x1="34.51" y1="33.98" x2="34.52" y2="44.74"></line></svg>');function Jc(e){var t=Xc();k(e,t)}var Qc=I('<strong class="svelte-1kpafo0">AI processing is disabled.</strong> Enable AI from the <a href="https://partner.playpilot.net" class="svelte-1kpafo0">Partner Portal</a>',1),$c=I('<span class="svelte-1kpafo0">.</span>'),eu=I(`<strong class="svelte-1kpafo0">AI links are currently processing.</strong> This can take several minutes. We'll insert all found injections once ready. <div class="message svelte-1kpafo0"> <span class="ellipses svelte-1kpafo0"></span></div> <div class="loading-bar svelte-1kpafo0"><div class="loading-bar-progress svelte-1kpafo0"><div class="loading-bar-fill svelte-1kpafo0" data-testid="loading-bar"></div></div> <div class="loading-bar-label svelte-1kpafo0"> </div></div>`,1),tu=(e,t)=>C(t,!0),nu=I('<p class="svelte-1kpafo0"><strong class="svelte-1kpafo0">AI has finished processing.</strong> <br class="svelte-1kpafo0"> <!></p> <button class="dismiss svelte-1kpafo0">Dismiss</button>',1),iu=I('<div class="animator svelte-1kpafo0" data-test-id="animator"></div>'),ru=I('<div class="ai-indicator svelte-1kpafo0" data-testid="ai-indicator"><div class="content svelte-1kpafo0"><div class="icon svelte-1kpafo0"><!></div> <div class="svelte-1kpafo0"><!></div></div> <div class="border svelte-1kpafo0"><!></div></div>');function au(e,t){const n=L(t,"aiRunning",3,!1),i=L(t,"aiEnabled",3,!1),r=L(t,"message",3,""),a=L(t,"percentage",3,0),o=L(t,"aiInjectionsCount",3,0),s=o();let l=U(!1);var d=Fe(),u=ne(d);{var f=_=>{var m=ru(),g=b(m),v=b(g),p=b(v);Jc(p);var y=E(v,2),w=b(y);{var S=M=>{var A=Qc();k(M,A)},j=M=>{var A=Fe(),D=ne(A);{var P=O=>{var z=eu(),F=E(ne(z),2),V=b(F),W=E(V);at(W,20,()=>({length:3}),xt,(te,le)=>{var Ce=$c();k(te,Ce)});var J=E(F,2),ee=b(J),re=b(ee);const de=K(()=>`${Math.max(a(),3)??""}%`);N(()=>xn(re,"width",c(de)));var Ae=E(ee,2),Q=b(Ae);N(()=>G(Q,`${Math.floor(a())??""}%`)),N(()=>G(V,`${r()??""} `)),k(O,z)},B=O=>{var z=nu(),F=ne(z),V=E(b(F),4);{var W=re=>{var de=Be("No new injections where found.");k(re,de)},J=re=>{var de=Be();N(()=>G(de,`${o()??""} Injections where found and added to the page.`)),k(re,de)};q(V,re=>{s===o()?re(W):re(J,!1)})}var ee=E(F,2);ee.__click=[tu,l],k(O,z)};q(D,O=>{n()?O(P):O(B,!1)},!0)}k(M,A)};q(w,M=>{i()?M(j,!1):M(S)})}var x=E(g,2),T=b(x);{var H=M=>{var A=iu();k(M,A)};q(T,M=>{n()&&M(H)})}N(()=>se(m,"running",n())),k(_,m)};q(u,_=>{c(l)||_(f)})}k(e,d)}fe(["click"]);async function ou(e,t,n,i,r,a,o){try{C(t,!0),C(n,!1),i(await As(i(),r())),C(a,X(c(o)))}catch{C(n,!0)}finally{C(t,!1)}}var lu=I('<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:400,600,700">'),su=I('<div class="handles svelte-11aj6xq"><div class="handle svelte-11aj6xq"><!></div> <div class="handle svelte-11aj6xq"><!></div></div>'),cu=I('<div class="loading svelte-11aj6xq">Loading...</div>'),uu=I('<div class="bubble svelte-11aj6xq"> </div> <!>',1),du=I(`<strong>Playlinks are currently not published.</strong> Visitors to this page will not see any of the injected links.
|
|
12
12
|
Publish playlinks from the <a href="https://partner.playpilot.net">Partner Portal.</a>`,1),fu=I('<div class="alert svelte-11aj6xq"><!></div>'),vu=I('<div class="error svelte-11aj6xq"><!></div>'),_u=I('<div class="empty svelte-11aj6xq">No links available. Add links manually by clicking the + button and select text to add a link to.</div>'),hu=I('<button class="save svelte-11aj6xq"> </button>'),gu=I('<!> <!> <div class="items svelte-11aj6xq"></div> <!>',1),mu=I("<!> <!> <!>",1),pu=I('<div class="panel playpilot-styled-scrollbar svelte-11aj6xq"><!></div>'),yu=I('<section class="editor playpilot-styled-scrollbar svelte-11aj6xq"><!> <header class="header svelte-11aj6xq"><div class="heading svelte-11aj6xq">Playlinks</div> <!></header> <!> <!></section>');function wu(e,t){ae(t,!0);let n=L(t,"linkInjections",15),i=L(t,"pageText",3,""),r=L(t,"loading",3,!1),a=L(t,"injectionsEnabled",7,!1),o=L(t,"aiStatus",23,()=>({})),s=L(t,"onreinitialize",3,()=>null);const l="editor-position",d="editor-height",u=JSON.parse(localStorage.getItem(l)||'{ "x": 0, "y": 0 }'),f=parseInt(localStorage.getItem(d)||"0");let _=U(null),m=U(!1),g=U(!1),v=U(!1),p=U(!0),y=U(0),w=U("");const S=K(()=>sn(o().aiEnabled,!1)),j=K(()=>sn(o().aiRunning,!1)),x=K(()=>JSON.stringify(n())),T=K(()=>!c(j)&&c(p)),H=K(()=>c(w)&&c(w)!==c(x)),M=K(()=>n().filter(R=>R.title_details&&!R.removed&&!R.duplicate&&(R.manual||!R.manual&&!R.failed))),A=K(()=>P(c(M))),D=K(()=>!r()&&Ke(()=>o().aiRunning));pn(()=>{r()||Ke(()=>{requestAnimationFrame(()=>C(w,X(c(x)))),V()})});function P(R){return R.sort((Y,_e)=>Y.failed!==_e.failed?Y.failed?1:-1:Y.title_details.title.localeCompare(_e.title_details.title))}function B(R,Y){localStorage.setItem(R,Y)}function O(R){const Y=n().findIndex(_e=>_e.key===R);n(n()[Y].manual=!0,!0),n(n()[Y].removed=!0,!0),n([...n()])}function z(R){if(!c(_))return;const Y=R.offsetTop,_e=Y+R.offsetHeight,ve=c(_).scrollTop,Se=ve+c(_).clientHeight;Y>=ve&&_e<=Se||c(_).scrollTo({top:Y-c(_).clientHeight/2,behavior:"smooth"})}function F(R){const Y=R.target;C(y,X(Y.scrollTop))}function V(){const R={total:n().length,failed_automatic:n().filter(Y=>Y.failed&&!Y.manual).length,failed_manual:n().filter(Y=>Y.failed&&Y.manual).length,final_injected:c(M).length};be(ye.TotalInjectionsCount,null,R)}var W=yu();bo(R=>{var Y=lu();k(R,Y)});var J=b(W);{var ee=R=>{var Y=su(),_e=b(Y),ve=b(_e);xc(ve,{get element(){return c(_)},height:f,onchange:Ze=>B(d,JSON.stringify(Ze))});var Se=E(_e,2),Ne=b(Se);kc(Ne,{get element(){return c(_)},position:u,limit:{x:16,y:16},onchange:Ze=>B(l,JSON.stringify(Ze))}),k(R,Y)};q(J,R=>{c(_)&&!r()&&R(ee)})}var re=E(J,2),de=b(re);Qt(de,R=>xe==null?void 0:xe(R));var Ae=E(de,2);{var Q=R=>{var Y=cu();k(R,Y)},te=R=>{var Y=Fe(),_e=ne(Y);{var ve=Se=>{var Ne=uu(),Ze=ne(Ne),Oe=b(Ze),tn=E(Ze,2);ci(tn,{onclick:()=>C(m,!0),size:"24px","aria-label":"Add manual injection",children:(nn,mi)=>{var rn=Be("+");k(nn,rn)},$$slots:{default:!0}}),N(()=>{ue(Ze,"aria-label",`${c(M).length??""} found playlinks`),G(Oe,c(M).length)}),k(Se,Ne)};q(_e,Se=>{c(T)&&Se(ve)},!0)}k(R,Y)};q(Ae,R=>{r()?R(Q):R(te,!1)})}var le=E(re,2);{var Ce=R=>{var Y=mu(),_e=ne(Y);Gc(_e,{get pageText(){return i()},onallow:()=>C(p,!0),ondisallow:()=>C(p,!1),get ontakeover(){return s()},onpoll:Oe=>{a(Oe.injectionsEnabled),o({...o(),aiEnabled:Oe.aiEnabled})}});var ve=E(_e,2);{var Se=Oe=>{au(Oe,Zo(o,{get aiInjectionsCount(){return Gr(n()).aiInjections.length}}))};q(ve,Oe=>{c(p)&&(c(D)||!c(S))&&Oe(Se)})}var Ne=E(ve,2);{var Ze=Oe=>{var tn=gu(),nn=ne(tn);{var mi=he=>{var ge=fu(),$e=b(ge);ht($e,{type:"warning",children:(lt,sa)=>{var An=du();k(lt,An)},$$slots:{default:!0}}),k(he,ge)};q(nn,he=>{a()||he(mi)})}var rn=E(nn,2);{var aa=he=>{var ge=vu(),$e=b(ge);ht($e,{children:(lt,sa)=>{var An=Be("Something went wrong, check your links below.");k(lt,An)},$$slots:{default:!0}}),je(7,ge,()=>Vt,()=>({duration:150})),k(he,ge)};q(rn,he=>{c(v)&&he(aa)})}var pi=E(rn,2);at(pi,21,()=>c(A),he=>he.key,(he,ge)=>{const $e=K(()=>n().findIndex(lt=>lt.key===c(ge).key));yc(he,{onremove:()=>O(c(ge).key),onhighlight:z,get linkInjection(){return n()[c($e)]},set linkInjection(lt){n(n()[c($e)]=lt,!0)}})},he=>{var ge=_u();k(he,ge)});var oa=E(pi,2);{var la=he=>{var ge=hu();ge.__click=[ou,g,v,n,i,w,x];var $e=b(ge);N(()=>{ge.disabled=c(g),G($e,c(g)?"Saving...":"Save links")}),je(1,ge,()=>Ft,()=>({duration:100})),k(he,ge)};q(oa,he=>{c(H)&&n().length&&c(p)&&he(la)})}k(Oe,tn)};q(Ne,Oe=>{c(T)&&Oe(Ze)})}k(R,Y)};q(le,R=>{r()||R(Ce)})}var Qe=E(le,2);{var ot=R=>{var Y=pu(),_e=b(Y);Vc(_e,{get pageText(){return i()},onclose:()=>C(m,!1),onsave:ve=>n().push(ve)}),N(()=>xn(Y,"top",`${c(y)??""}px`)),je(3,Y,()=>En,()=>({x:Math.min(window.innerWidth,320),duration:200,opacity:1})),k(R,Y)};q(Qe,R=>{c(m)&&R(ot)})}$t(W,R=>C(_,R),()=>c(_)),N(()=>{se(W,"panel-open",c(m)),se(W,"loading",r())}),ce("scroll",W,F),k(e,W),oe()}fe(["click"]);var ku=Le('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 57.48 62.96"><defs><style>.playpilot-logo{fill:url(#playpilot-linear-gradient);}</style><linearGradient id="playpilot-linear-gradient" x1="-90.03" y1="-40.23" x2="-34.8" y2="-101.48" gradientTransform="translate(74.02 108.65)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#de00b9"></stop><stop offset="0.99" stop-color="#ff557b"></stop></linearGradient></defs><path class="playpilot-logo" d="M57.48,31.48C57.48,22.17,20.85,2.19,9.2.18,7.42-.12,3.78-.37,1.36,2.25-4.32,8.39,9.62,21.5,9.62,31.48S-4.32,54.57,1.36,60.72c2.42,2.61,6.06,2.37,7.84,2.06C20.85,60.78,57.48,40.79,57.48,31.48Z"></path></svg>');function bu(e){var t=ku();k(e,t)}var xu=I('<div class="trigger svelte-qee95d"><button type="button" class="button svelte-qee95d" title="Show PlayPilot TPI editor"><!></button> <button type="button" class="button close svelte-qee95d" title="Close PlayPilot TPI"><!></button></div>');function Su(e,t){var n=xu(),i=b(n);i.__click=function(...s){var l;(l=t.onclick)==null||l.apply(this,s)};var r=b(i);bu(r);var a=E(i,2);a.__click=function(...s){var l;(l=t.onclose)==null||l.apply(this,s)};var o=b(a);Br(o),k(e,n)}fe(["click"]);var Eu=I('<div class="playpilot-link-injections svelte-13rmd3g" data-playpilot-link-injections=""><!> <!></div>');function Tu(e,t){ae(t,!0);let n=U(null),i=U(X([])),r=U(null),a=U(X(Rr())),o=U(!!li()),s=U(!1),l=U(!0),d=U(!0),u=U(X([]));const f=K(()=>c(r)||{}),_=K(()=>sn(c(f).ai_injections,()=>[],!0)),m=K(()=>sn(c(f).manual_injections,()=>[],!0)),g=K(()=>Kr(c(i)));pn(()=>{c(a)&&!c(l)&&p()}),Je(()=>{if(!Ps())return(async()=>(await v(),be(ye.ArticlePageView)))(),()=>vi()});async function v(){C(l,!0),c(a)&&C(s,X(await Dr()));try{const P=await Cs(),B=ai();if(C(d,!!(P!=null&&P.exclude_urls_pattern&&B.match(new RegExp(P.exclude_urls_pattern)))),c(d))return;P!=null&&P.custom_style&&x(P.custom_style||""),S((P==null?void 0:P.html_selector)||"",(P==null?void 0:P.exclude_elements_selector)||"")}catch(P){be(ye.FetchingConfigFailed),console.error("TPI Config failed to fetch",P);return}try{if(C(r,X(await Hi(c(g),{maxTries:1,runAiWhenRelevant:!0}))),C(l,!1),!c(r))return;if($o({organizationSid:c(r).organization_sid,domainSid:c(r).domain_sid}),!c(r).ai_running||!c(r).ai_enabled){w({aiInjections:c(_),manualInjections:c(m)});return}if(!c(a))return;C(r,X(await Hi(c(g),{requireCompletedResult:!0,onpoll:P=>C(r,X(P))}))),w({aiInjections:c(_),manualInjections:c(m)})}catch(P){console.error(P),be(ye.InjectionError,null,{message:P.message})}}function p(){w(Gr(c(u)))}function y(){C(a,!1),requestAnimationFrame(()=>{C(a,!0),v()})}function w(P={aiInjections:c(_),manualInjections:c(m)}){const B=fs(c(i),P);JSON.stringify(B)!==JSON.stringify(c(u))&&C(u,X(B));const O=B.filter(z=>!z.failed);O.length&&(c(a)||be(ye.ArticleInjected,null,{manual:O.filter(z=>z.manual).length,ai:O.filter(z=>!z.manual).length}))}function S(P,B){P&&(window.PlayPilotLinkInjections.selector=P),C(n,X(St())),C(i,X(fi(c(n),B)))}function j(){C(a,!0),nl(),v()}function x(P){const B="playpilot-custom-style",O=document.getElementById(B),z=O||document.createElement("style");z.textContent=`[data-playpilot-link-injections] { ${P} }`,z.id=B,O||document.body.appendChild(z)}var T=Eu(),H=b(T);{var M=P=>{Su(P,{onclick:j,onclose:()=>{C(o,!1),tl()}})};q(H,P=>{!c(d)&&c(o)&&!c(a)&&P(M)})}var A=E(H,2);{var D=P=>{var B=Fe(),O=ne(B);Go(O,{onerror:F=>be(ye.EditorError,null,{message:F.message}),failed:F=>{ht(F,{fixed:!0,children:(V,W)=>{var J=Be("An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!");k(V,J)},$$slots:{default:!0}})}},F=>{var V=K(()=>{var J;return(J=c(r))==null?void 0:J.injections_enabled}),W=K(()=>{var J,ee,re,de,Ae;return{aiEnabled:(J=c(r))==null?void 0:J.ai_enabled,aiRunning:((ee=c(r))==null?void 0:ee.ai_running)&&((re=c(r))==null?void 0:re.ai_enabled),message:(de=c(r))==null?void 0:de.ai_progress_message,percentage:(Ae=c(r))==null?void 0:Ae.ai_progress_percentage}});wu(F,{get pageText(){return c(g)},get loading(){return c(l)},onreinitialize:y,get injectionsEnabled(){return c(V)},get aiStatus(){return c(W)},get linkInjections(){return c(u)},set linkInjections(J){C(u,X(J))}})}),k(P,B)};q(A,P=>{!c(d)&&c(a)&&c(s)&&P(D)})}k(e,T),oe()}window.PlayPilotLinkInjections={token:"",editorial_token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,app:null,last_successful_fetch:null,initialize(e={token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,editorial_token:"",last_successful_fetch:null}){if(!e.token){console.error("An API token is required.");return}this.token=e.token,this.editorial_token=e.editorial_token,this.selector=e.selector,this.after_article_selector=e.after_article_selector,this.after_article_insert_position=e.after_article_insert_position,this.language=e.language,this.organization_sid=e.organization_sid,this.domain_sid=e.domain_sid,this.app&&this.destroy();const t=document.createElement("div");t.id="playpilot-link-injection",document.body.insertAdjacentElement("beforeend",t),this.app=Jt(Tu,{target:t})},destroy(){if(!this.app)return;this.app=null;const e=document.getElementById("playpilot-link-injection");e&&e.remove(),vi()},debug(){const e=St(),t=fi(e);console.group("PlayPilot Link Injection Debug"),console.groupCollapsed("Config"),console.table(Object.entries(this)),console.groupEnd(),console.groupCollapsed("Elements"),console.log("Parent element",e),console.log("Valid elements",t),console.groupEnd(),console.groupCollapsed("Last fetch"),console.log(this.last_successful_fetch),console.groupEnd(),console.groupCollapsed("Meta"),console.log(_i()),console.groupEnd(),console.groupCollapsed("Page text"),console.log(Kr(t)),console.groupEnd(),console.groupEnd()}};
|
|
13
13
|
|
package/package.json
CHANGED