PageSourceSearch

https://trakkr.ai/assets/perception-story-api-DCRrjDnx.js

js trakkr.ai collected 2026-09-28 08:31:23 UTC 4,101 bytes, 1 lines download raw bytes

1import{al as C,B as P}from"./index-1YQNuixL.js";const R="/100 in overall AI perception across ";function z(e){if(typeof e!="string")return!1;const t=e.trim();return t.includes(R)&&t.endsWith(" tracked brands.")}function B(e){return typeof e!="string"||z(e)?"":e.trim()}function c(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function r(e){return Array.isArray(e)?e:[]}function m(e,t=0){return typeof e=="number"&&Number.isFinite(e)?e:t}function p(e,t=""){return typeof e=="string"?e:t}function E(e){return e==="positive"||e==="negative"||e==="mixed"?e:"mixed"}function M(e){return e==="new"||e==="up"||e==="down"||e==="flat"?e:"flat"}function N(e){if(!c(e))return null;const t=p(e.label).trim();return t?{...e,label:t,sentiment:E(e.sentiment),frequency:m(e.frequency,1),models:r(e.models),theme:p(e.theme),category:typeof e.category=="string"?e.category:null,trend:M(e.trend),evidence:r(e.evidence),sources:r(e.sources)}:null}function j(e){if(!c(e))return null;const t=p(e.label).trim();return t?{...e,label:t,detail:p(e.detail)}:null}function F(e){if(!c(e))return null;const t=p(e.title).trim();return t?{...e,title:t,detail:p(e.detail),attribute:typeof e.attribute=="string"?e.attribute:null,priority:e.priority==="high"||e.priority==="medium"||e.priority==="low"?e.priority:"medium",sources:r(e.sources)}:null}function D(e){if(!c(e))return null;const t=c(e.recognition)?e.recognition:{},i=c(e.competitive_perception)?e.competitive_perception:{},a=c(i.map_mid)?i.map_mid:{},_={...t,known:m(t.known),total:m(t.total),models:r(t.models)},g={...i,map:r(i.map),map_mid:{x:m(a.x),y:m(a.y)},attribute_ownership:r(i.attribute_ownership)};return{...e,recognition:_,attributes:r(e.attributes).map(N).filter(o=>!!o),model_takes:r(e.model_takes),moved:r(e.moved).map(j).filter(o=>!!o),recommendations:r(e.recommendations).map(F).filter(o=>!!o),competitive_perception:g}}async function I(e){try{const t=await C(`${P}/api/perception/story?brand_id=${encodeURIComponent(e)}`);return t?l(t):null}catch(t){throw console.error("Error fetching perception story:",t),new Error("Failed to fetch perception story data")}}function l(e){const t=n(e.semantic_dna),i=n(e.winning_use_cases),a=n(e.losing_use_cases),_=n(e.perception_gaps),g=s(e.model_breakdown),o=s(e.category_scores),h=n(e.recommendations),A=n(e.top_cited_domains),S=n(e.source_perception_map),k=s(e.competitor_narratives),y=s(e.narrative),d=s(e.semantic_dna),f=s(e.use_case_mapping),u=s(e.perception_gaps);return{run_date:e.run_date,brand_id:e.brand_id,total_prompts_analyzed:e.total_prompts_analyzed||0,total_responses_processed:e.total_responses_processed||0,narrative:{summary:B(y.summary||e.narrative_summary),positioning:y.positioning||e.positioning_statement||"",tone:"",key_themes:n(y.key_themes??e.key_themes)},perception_score:e.perception_score,perception_percentile:e.perception_percentile,perception_change_7d:e.perception_change_7d,semantic_dna:{semantic_dna:t.length>0?t:n(d.semantic_dna),primary_descriptors:n(d.primary_descriptors??e.primary_descriptors),emerging_descriptors:n(d.emerging_descriptors??e.emerging_descriptors),fading_descriptors:n(d.fading_descriptors??e.fading_descriptors)},use_case_mapping:{winning_use_cases:i.length>0?i:n(f.winning_use_cases),losing_use_cases:a.length>0?a:n(f.losing_use_cases),use_case_coverage_score:f.use_case_coverage_score||e.use_case_coverage_score||0},perception_gaps:{perception_gaps:_.length>0?_:n(u.perception_gaps),alignment_score:u.alignment_score||e.alignment_score||0},category_scores:o,common_concerns:n(e.common_concerns),model_breakdown:g,recommendations:h,top_cited_domains:A,source_perception_map:S,competitor_narratives:k}}function b(e,t){if(e==null)return t;if(typeof e=="object")return e;if(typeof e=="string")try{return JSON.parse(e)}catch{return t}return t}function n(e){const t=b(e,[]);return Array.isArray(t)?t:[]}function s(e){const t=b(e,{});return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}const O=Object.freeze(Object.defineProperty({__proto__:null,getPerceptionStory:I,normalizeStoryData:l},Symbol.toStringTag,{value:"Module"}));export{I as g,D as n,O as p};

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.