PageSourceSearch

https://skaler.app/js/AppAdSpy-C0Uy1Rt5.js

js skaler.app collected 2026-10-05 08:39:39 UTC 11,386 bytes, 1 lines download raw bytes

1var e=Object.defineProperty,s=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,n=(s,t,a)=>t in s?e(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,o=(e,s)=>{for(var t in s||(s={}))i.call(s,t)&&n(e,t,s[t]);if(a)for(var t of a(s))r.call(s,t)&&n(e,t,s[t]);return e},l=(e,a)=>s(e,t(a)),d=(e,s,t)=>new Promise((a,i)=>{var r=e=>{try{o(t.next(e))}catch(s){i(s)}},n=e=>{try{o(t.throw(e))}catch(s){i(s)}},o=e=>e.done?a(e.value):Promise.resolve(e.value).then(r,n);o((t=t.apply(e,s)).next())});import{j as c}from"./ui-vendor-zV4gZgpo.js";import{r as m}from"./react-vendor-DyX69ilc.js";import{D as g,F as u,B as p,e as h,f as _,g as v,h as j,O as x,C as b,I as f}from"./app-CGDaYhQU.js";import{T as y,a as k,b as A,c as w}from"./tabs-1k0sPfDf.js";import{J as L}from"./sonner-vendor-Bx-SvwPS.js";import{A as S}from"./AdDiscoveryCard-DRAAliMV.js";import{S as N,a as D,b as R,c as $,d as C}from"./select-CSkE6VfE.js";import{u as T}from"./useTranscription-CcaT8VAF.js";import{bl as I,L as E,f as O,S as U,E as P}from"./icons-vendor-Bbrdcj6W.js";import"./utils-vendor-DbelTbfa.js";import"./router-vendor-DMB53j7L.js";import"./supabase-vendor-CJcmUcsc.js";import"./query-vendor-LoqAjdH_.js";import"./themes-vendor-hhwauyIy.js";import"./gtm-vendor-CiBQ5uun.js";import"./animations-vendor-BILZFG-k.js";import"./date-vendor-C-aSTXnx.js";import"./sentry-vendor-B4an4q2q.js";import"./badge-BIvSRQIm.js";import"./dropdown-menu-C2EvNCMT.js";import"./languages-DPqIAP1e.js";import"./format-CHjbt9dW.js";import"./ImportDiscoveryAdDialog-CBYxWHKu.js";import"./fileValidation-wure6oE7.js";const F=new class{constructor(e="placeholder_token"){var s,t;n(this,"symbol"!=typeof(s="accessToken")?s+"":s,t),this.accessToken=e}setAccessToken(e){this.accessToken=e}fetchAllAdCategories(e){return d(this,null,function*(){try{const s=yield this.fetchAdsForPage(e);return s&&0!==s.length?{longestRunningAds:this.getLongestRunningAds(s),biggestSpendersEU:this.getBiggestSpendersEU(s),mostLikedAds:this.getMostLikedAds(s),highestRatioAds:this.getHighestLikeCommentRatioAds(s)}:{longestRunningAds:[],biggestSpendersEU:[],mostLikedAds:[],highestRatioAds:[]}}catch(s){throw s}})}fetchAdsForPage(e){return d(this,arguments,function*(e,s={}){try{const t=["id","ad_creative_body","ad_creative_link_title","ad_delivery_start_time","ad_delivery_stop_time","page_name","currency","funding_entity","impressions","spend","publisher_platforms","demographic_distribution","region_distribution","thumbnail_url","page_id"];s.fields,s.limit;return this.getMockAds(e)}catch(t){throw t}})}getLongestRunningAds(e){return[...e].filter(e=>e.ad_delivery_start_time).sort((e,s)=>new Date(e.ad_delivery_start_time).getTime()-new Date(s.ad_delivery_start_time).getTime()).slice(0,10)}getBiggestSpendersEU(e){return[...e].filter(e=>{var s;return e.spend&&(null==(s=e.region_distribution)?void 0:s.some(e=>"Europe"===e.region))}).sort((e,s)=>{var t,a;const i=(null==(t=e.spend)?void 0:t.upper_bound)||0;return((null==(a=s.spend)?void 0:a.upper_bound)||0)-i}).slice(0,10)}getMostLikedAds(e){return[...e].filter(e=>void 0!==e.like_count).sort((e,s)=>{const t=e.like_count||0;return(s.like_count||0)-t}).slice(0,10)}getHighestLikeCommentRatioAds(e){return[...e].filter(e=>e.like_count&&e.like_count>0&&e.comment_count&&e.comment_count>0).map(e=>{const s=(e.like_count||0)/(e.comment_count||1);return l(o({},e),{like_comment_ratio:s})}).sort((e,s)=>{const t=e.like_comment_ratio||0;return(s.like_comment_ratio||0)-t}).slice(0,10)}getMockAds(e){const s=[];for(let t=1;t<=30;t++){const a=new Date;a.setDate(a.getDate()-30*t);const i=new Date(a);t%3==0&&i.setDate(i.getDate()+90),s.push({id:`ad_${e}_${t}`,ad_creative_body:`This is a sample ad creative #${t} for page ID ${e}. It includes compelling copy to attract customers.`,ad_creative_link_title:`Amazing Offer #${t}`,ad_delivery_start_time:a.toISOString(),ad_delivery_stop_time:t%3==0?void 0:i.toISOString(),page_name:`Brand for ${e}`,funding_entity:"Sample Company LLC",currency:"USD",impressions:{lower_bound:1e4*t,upper_bound:2e4*t},spend:{lower_bound:1e3*t,upper_bound:2e3*t},publisher_platforms:["facebook","instagram"],media_type:t%2==0?"video":"image",thumbnail_url:`https://picsum.photos/400/300?random=${t}`,video_url:t%2==0?`https://example.com/video${t}.mp4`:void 0,image_url:t%2==0?void 0:`https://picsum.photos/800/600?random=${t}`,like_count:Math.floor(1e3*Math.random())*t,comment_count:Math.floor(100*Math.random())*t,share_count:Math.floor(50*Math.random())*t})}return s}},M=({asset:e,triggerClassName:s})=>{const[t,a]=m.useState(!1),[i,r]=m.useState(""),[n,o]=m.useState(!1),{boards:l,isLoading:x}=T();return c.jsxs(g,{open:t,onOpenChange:a,children:[c.jsx(u,{asChild:!0,children:c.jsxs(p,{variant:"outline",size:"sm",className:`${s||""}`,children:[c.jsx(I,{className:"h-4 w-4 mr-2"}),"Save to Board"]})}),c.jsxs(h,{children:[c.jsxs(_,{children:[c.jsx(v,{children:"Save to Board"}),c.jsx(j,{children:"Select a board to save this ad to your library"})]}),c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsx("div",{className:"space-y-2",children:c.jsxs(N,{value:i,onValueChange:r,disabled:x||n,children:[c.jsx(D,{children:c.jsx(R,{placeholder:"Select a board"})}),c.jsx($,{children:x?c.jsx(C,{value:"loading",disabled:!0,children:"Loading boards..."}):0===l.length?c.jsx(C,{value:"none",disabled:!0,children:"No boards available"}):l.map(e=>c.jsx(C,{value:e.id,children:e.name},e.id))})]})}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx(p,{variant:"outline",onClick:()=>a(!1),disabled:n,children:"Cancel"}),c.jsx(p,{onClick:()=>d(void 0,null,function*(){if(i){o(!0);try{yield new Promise(e=>setTimeout(e,1e3)),L.success("Ad saved to board successfully!"),a(!1)}catch(e){L.error("Failed to save ad to board")}finally{o(!1)}}else L.error("Please select a board")}),disabled:!i||n,children:n?c.jsxs(c.Fragment,{children:[c.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):c.jsxs(c.Fragment,{children:[c.jsx(O,{className:"h-4 w-4 mr-2"}),"Save"]})})]})]})]})]})},B=()=>{const{hasActiveSubscription:e}=x(),[s,t]=m.useState({url:"",isLoading:!1,pageId:null,longestRunningAds:[],biggestSpendersEU:[],mostLikedAds:[],highestRatioAds:[],activeTab:"longest-running"}),a=e=>d(void 0,null,function*(){return L.info("This feature will be implemented in a future update."),!0}),i=t=>s.isLoading?Array(8).fill(0).map((e,s)=>c.jsx(b,{className:"aspect-video animate-pulse bg-gray-200"},s)):0===t.length?c.jsx("div",{className:"col-span-full py-12 text-center",children:c.jsx("p",{className:"text-gray-500",children:"No ads found in this category"})}):t.map(s=>{const t=(e=>{const s=e.image_url||e.video_url||e.thumbnail_url||"https://via.placeholder.com/600x400?text=No+Image",t="video"===e.media_type?"video":"image",a=`${e.page_name} - ${new Date(e.ad_delivery_start_time).toLocaleDateString()}`,i=[e.ad_creative_link_title||"",e.ad_creative_body||""].filter(
1Boolean),r=[`Started: ${new Date(e.ad_delivery_start_time).toLocaleDateString()}`,e.ad_delivery_stop_time?`Ended: ${new Date(e.ad_delivery_stop_time).toLocaleDateString()}`:"Still Running",e.spend?`Estimated Spend: ${e.currency||"USD"} ${e.spend.lower_bound}-${e.spend.upper_bound}`:"",e.like_count?`Likes: ${e.like_count}`:"",e.comment_count?`Comments: ${e.comment_count}`:"",e.share_count?`Shares: ${e.share_count}`:"",e.like_comment_ratio?`Like:Comment Ratio: ${e.like_comment_ratio.toFixed(2)}`:""].filter(Boolean);return{id:e.id,board_id:"facebook-ads",file_name:a,file_type:t,file_url:s,transcribed_text:[...i,"",...r],created_at:e.ad_delivery_start_time,asset_notes:`Original Facebook ad from ${e.page_name}.`}})(s);return c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"absolute top-2 left-2 z-10",children:c.jsx(M,{asset:t})}),c.jsx(S,{asset:t,onDelete:a,isVisible:!0,hasActiveSubscription:e,displayOptions:{adDetails:!0,adCopy:!0,languages:!1,platforms:!1,metricType:"reach"}})]},s.id)});return c.jsxs("div",{className:"container mx-auto py-6",children:[c.jsx(b,{className:"p-6 mb-6",children:c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Enter Facebook Ad Library URL"}),c.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Paste a URL from Facebook Ad Library to analyze ads for that brand"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("div",{className:"flex-grow",children:c.jsx(f,{placeholder:"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=ALL&view_all_page_id=109468687259803",value:s.url,onChange:e=>{t(l(o({},s),{url:e.target.value}))},className:"w-full"})}),c.jsx(p,{onClick:()=>d(void 0,null,function*(){try{const e=(e=>{try{const s=e.match(/view_all_page_id=(\d+)/);if(s&&s[1])return s[1];const t=e.match(/facebook\.com\/([^/]+)\/ads/);return t&&t[1]?t[1]:null}catch(s){return null}})(s.url);if(!e)return void L.error("Could not extract page ID from URL. Please use a valid Facebook Ad Library URL.");t(l(o({},s),{isLoading:!0,pageId:e}));const a=yield F.fetchAllAdCategories(e);t(l(o({},s),{isLoading:!1,pageId:e,longestRunningAds:a.longestRunningAds,biggestSpendersEU:a.biggestSpendersEU,mostLikedAds:a.mostLikedAds,highestRatioAds:a.highestRatioAds})),L.success(`Found ${a.longestRunningAds.length+a.biggestSpendersEU.length+a.mostLikedAds.length+a.highestRatioAds.length} ads`)}catch(e){L.error("An error occurred while analyzing ads. Please try again."),t(l(o({},s),{isLoading:!1}))}}),disabled:!s.url||s.isLoading,className:"whitespace-nowrap",children:s.isLoading?c.jsxs(c.Fragment,{children:[c.jsx(E,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(U,{className:"mr-2 h-4 w-4"}),"Analyze Ads"]})})]}),s.pageId&&c.jsxs("div",{className:"flex items-center text-sm text-gray-500",children:[c.jsxs("span",{className:"mr-2",children:["Analyzing ads for Page ID: ",s.pageId]}),c.jsx("a",{href:`https://www.facebook.com/${s.pageId}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 inline-flex items-center",children:c.jsx(P,{className:"h-3 w-3 ml-1"})})]})]})}),s.pageId&&c.jsxs(y,{defaultValue:"longest-running",className:"w-full",onValueChange:e=>t(l(o({},s),{activeTab:e})),children:[c.jsxs(k,{className:"mb-6",children:[c.jsx(A,{value:"longest-running",children:"Top 10 Longest Running"}),c.jsx(A,{value:"biggest-spenders",children:"Top 10 Biggest Spenders (EU)"}),c.jsx(A,{value:"most-liked",children:"Top 10 Most Liked"}),c.jsx(A,{value:"highest-ratio",children:"Top 10 Like:Comment Ratio"})]}),c.jsx(w,{value:"longest-running",children:c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:i(s.longestRunningAds)})}),c.jsx(w,{value:"biggest-spenders",children:c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:i(s.biggestSpendersEU)})}),c.jsx(w,{value:"most-liked",children:c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:i(s.mostLikedAds)})}),c.jsx(w,{value:"highest-ratio",children:c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:i(s.highestRatioAds)})})]})]})};export{B as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.