@mixpeek/prebid 1.0.0
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/CHANGELOG.md +153 -0
- package/ENDPOINTS.md +308 -0
- package/LICENSE +68 -0
- package/QUICKSTART.md +234 -0
- package/README.md +439 -0
- package/TESTING.md +341 -0
- package/dist/mixpeekContextAdapter.js +3 -0
- package/dist/mixpeekContextAdapter.js.LICENSE.txt +1 -0
- package/dist/mixpeekContextAdapter.js.map +1 -0
- package/docs/MIGRATION_V2.md +519 -0
- package/docs/api-reference.md +455 -0
- package/docs/health-check.md +348 -0
- package/docs/integration-guide.md +577 -0
- package/examples/publisher-demo/README.md +65 -0
- package/examples/publisher-demo/index.html +331 -0
- package/examples/publisher-demo/package.json +11 -0
- package/package.json +82 -0
- package/src/api/mixpeekClient.js +303 -0
- package/src/cache/cacheManager.js +245 -0
- package/src/config/constants.js +125 -0
- package/src/extractors/imageExtractor.js +142 -0
- package/src/extractors/pageExtractor.js +196 -0
- package/src/extractors/videoExtractor.js +228 -0
- package/src/modules/mixpeekContextAdapter.js +833 -0
- package/src/modules/mixpeekRtdProvider.js +305 -0
- package/src/prebid/prebidIntegration.js +117 -0
- package/src/utils/helpers.js +261 -0
- package/src/utils/iabMapping.js +367 -0
- package/src/utils/logger.js +64 -0
- package/src/utils/previousAdTracker.js +95 -0
package/TESTING.md
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Testing Guide
|
|
2
|
+
|
|
3
|
+
This document explains how to test the Mixpeek Context Adapter.
|
|
4
|
+
|
|
5
|
+
## Test Suites
|
|
6
|
+
|
|
7
|
+
### 1. Unit Tests
|
|
8
|
+
|
|
9
|
+
Test individual modules in isolation with mocked dependencies.
|
|
10
|
+
|
|
11
|
+
**Location**: `tests/unit/`
|
|
12
|
+
|
|
13
|
+
**Run**:
|
|
14
|
+
```bash
|
|
15
|
+
npm test
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Coverage**:
|
|
19
|
+
```bash
|
|
20
|
+
npm run test:coverage
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**What's Tested**:
|
|
24
|
+
- Helper utilities
|
|
25
|
+
- Cache manager
|
|
26
|
+
- API client (mocked)
|
|
27
|
+
- Content extractors
|
|
28
|
+
- Configuration validation
|
|
29
|
+
|
|
30
|
+
**Example Output**:
|
|
31
|
+
```
|
|
32
|
+
PASS tests/unit/helpers.test.js
|
|
33
|
+
PASS tests/unit/cacheManager.test.js
|
|
34
|
+
PASS tests/unit/mixpeekClient.test.js
|
|
35
|
+
|
|
36
|
+
Test Suites: 3 passed, 3 total
|
|
37
|
+
Tests: 42 passed, 42 total
|
|
38
|
+
Coverage: 87.3%
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Integration Tests
|
|
42
|
+
|
|
43
|
+
Test module interactions with mocked API responses.
|
|
44
|
+
|
|
45
|
+
**Location**: `tests/integration/`
|
|
46
|
+
|
|
47
|
+
**Run**:
|
|
48
|
+
```bash
|
|
49
|
+
npm test tests/integration/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**What's Tested**:
|
|
53
|
+
- Full adapter initialization
|
|
54
|
+
- Ad unit enrichment flow
|
|
55
|
+
- Event emission
|
|
56
|
+
- Error handling
|
|
57
|
+
- Cache integration
|
|
58
|
+
|
|
59
|
+
### 3. Live API Tests
|
|
60
|
+
|
|
61
|
+
Test against the real Mixpeek API (requires credentials).
|
|
62
|
+
|
|
63
|
+
**Location**: `tests/live-api/`
|
|
64
|
+
|
|
65
|
+
**Setup**:
|
|
66
|
+
```bash
|
|
67
|
+
# Set your API key
|
|
68
|
+
export MIXPEEK_API_KEY="sk_your_api_key"
|
|
69
|
+
export MIXPEEK_COLLECTION_ID="col_your_collection"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Run**:
|
|
73
|
+
```bash
|
|
74
|
+
npm run test:live
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**What's Tested**:
|
|
78
|
+
- Real API connectivity
|
|
79
|
+
- Document creation and retrieval
|
|
80
|
+
- Feature extractors
|
|
81
|
+
- Taxonomy classification
|
|
82
|
+
- Performance timing
|
|
83
|
+
- Error recovery
|
|
84
|
+
|
|
85
|
+
See [tests/live-api/README.md](tests/live-api/README.md) for detailed instructions.
|
|
86
|
+
|
|
87
|
+
## Running Tests
|
|
88
|
+
|
|
89
|
+
### All Tests
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Unit + Integration only (no API)
|
|
93
|
+
npm test
|
|
94
|
+
|
|
95
|
+
# Unit + Integration + Live API
|
|
96
|
+
npm run test:all
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Watch Mode
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm run test:watch
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Specific Test File
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx jest tests/unit/helpers.test.js
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Specific Test
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx jest -t "should generate a valid UUID"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Verbose Output
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm test -- --verbose
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Coverage Report
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run test:coverage
|
|
127
|
+
|
|
128
|
+
# Open HTML report
|
|
129
|
+
open coverage/lcov-report/index.html
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Writing Tests
|
|
133
|
+
|
|
134
|
+
### Unit Test Template
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
import { myFunction } from '../../src/utils/myModule.js'
|
|
138
|
+
|
|
139
|
+
describe('myModule', () => {
|
|
140
|
+
describe('myFunction', () => {
|
|
141
|
+
it('should do something', () => {
|
|
142
|
+
const result = myFunction('input')
|
|
143
|
+
expect(result).toBe('expected')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('should handle edge cases', () => {
|
|
147
|
+
expect(() => myFunction(null)).toThrow()
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Integration Test Template
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
import adapter from '../../src/modules/mixpeekContextAdapter.js'
|
|
157
|
+
|
|
158
|
+
describe('Feature Integration', () => {
|
|
159
|
+
beforeEach(() => {
|
|
160
|
+
adapter.clearCache()
|
|
161
|
+
global.fetch.mockClear()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should perform end-to-end operation', async () => {
|
|
165
|
+
// Setup
|
|
166
|
+
global.fetch.mockResolvedValueOnce({
|
|
167
|
+
ok: true,
|
|
168
|
+
json: async () => ({ data: 'mock' })
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
// Execute
|
|
172
|
+
const result = await adapter.someMethod()
|
|
173
|
+
|
|
174
|
+
// Assert
|
|
175
|
+
expect(result).toBeDefined()
|
|
176
|
+
expect(global.fetch).toHaveBeenCalled()
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Live API Test Template
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
describe('Live API Feature', () => {
|
|
185
|
+
test('should interact with real API', async () => {
|
|
186
|
+
if (skipIfNoApiKey()) return
|
|
187
|
+
|
|
188
|
+
// Your test using real API
|
|
189
|
+
const result = await client.someMethod()
|
|
190
|
+
|
|
191
|
+
expect(result).toBeDefined()
|
|
192
|
+
console.log('✓ Test passed:', result)
|
|
193
|
+
}, 30000) // Longer timeout for API calls
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Continuous Integration
|
|
198
|
+
|
|
199
|
+
### GitHub Actions
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
name: Test
|
|
203
|
+
|
|
204
|
+
on: [push, pull_request]
|
|
205
|
+
|
|
206
|
+
jobs:
|
|
207
|
+
test:
|
|
208
|
+
runs-on: ubuntu-latest
|
|
209
|
+
|
|
210
|
+
steps:
|
|
211
|
+
- uses: actions/checkout@v3
|
|
212
|
+
- uses: actions/setup-node@v3
|
|
213
|
+
with:
|
|
214
|
+
node-version: '18'
|
|
215
|
+
|
|
216
|
+
- run: npm install
|
|
217
|
+
- run: npm run lint
|
|
218
|
+
- run: npm test
|
|
219
|
+
- run: npm run test:coverage
|
|
220
|
+
|
|
221
|
+
# Live API tests (optional)
|
|
222
|
+
- name: Live API Tests
|
|
223
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
224
|
+
env:
|
|
225
|
+
MIXPEEK_API_KEY: ${{ secrets.MIXPEEK_API_KEY }}
|
|
226
|
+
MIXPEEK_COLLECTION_ID: ${{ secrets.MIXPEEK_COLLECTION_ID }}
|
|
227
|
+
run: npm run test:live
|
|
228
|
+
|
|
229
|
+
- name: Upload Coverage
|
|
230
|
+
uses: codecov/codecov-action@v3
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Debugging Tests
|
|
234
|
+
|
|
235
|
+
### Enable Debug Logging
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
DEBUG=* npm test
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Run Single Test
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npx jest -t "specific test name" --verbose
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Inspect Failed Tests
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
npm test -- --no-coverage --verbose
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Debug in VS Code
|
|
254
|
+
|
|
255
|
+
Create `.vscode/launch.json`:
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"version": "0.2.0",
|
|
260
|
+
"configurations": [
|
|
261
|
+
{
|
|
262
|
+
"type": "node",
|
|
263
|
+
"request": "launch",
|
|
264
|
+
"name": "Jest Debug",
|
|
265
|
+
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
|
266
|
+
"args": ["--runInBand", "--no-cache"],
|
|
267
|
+
"console": "integratedTerminal",
|
|
268
|
+
"internalConsoleOptions": "neverOpen"
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Test Coverage Goals
|
|
275
|
+
|
|
276
|
+
| Metric | Target | Current |
|
|
277
|
+
|--------|--------|---------|
|
|
278
|
+
| Lines | 80% | 87% |
|
|
279
|
+
| Functions | 80% | 85% |
|
|
280
|
+
| Branches | 80% | 82% |
|
|
281
|
+
| Statements | 80% | 87% |
|
|
282
|
+
|
|
283
|
+
## Common Issues
|
|
284
|
+
|
|
285
|
+
### Tests Fail After Module Changes
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Clear Jest cache
|
|
289
|
+
npx jest --clearCache
|
|
290
|
+
|
|
291
|
+
# Reinstall dependencies
|
|
292
|
+
rm -rf node_modules && npm install
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Mock Not Working
|
|
296
|
+
|
|
297
|
+
Ensure mocks are set up before imports:
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
// Mock BEFORE importing
|
|
301
|
+
jest.mock('../../src/api/mixpeekClient.js')
|
|
302
|
+
|
|
303
|
+
// Then import
|
|
304
|
+
import MixpeekClient from '../../src/api/mixpeekClient.js'
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Async Test Timing Out
|
|
308
|
+
|
|
309
|
+
Increase timeout:
|
|
310
|
+
|
|
311
|
+
```javascript
|
|
312
|
+
test('long running test', async () => {
|
|
313
|
+
// test code
|
|
314
|
+
}, 30000) // 30 seconds
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Or set globally in `jest.config.js`:
|
|
318
|
+
|
|
319
|
+
```javascript
|
|
320
|
+
module.exports = {
|
|
321
|
+
testTimeout: 10000
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Best Practices
|
|
326
|
+
|
|
327
|
+
1. **Test Behavior, Not Implementation**: Test what the code does, not how it does it
|
|
328
|
+
2. **Use Descriptive Names**: Test names should clearly describe what's being tested
|
|
329
|
+
3. **One Assertion Per Test**: Keep tests focused and simple
|
|
330
|
+
4. **Arrange-Act-Assert**: Structure tests in three clear phases
|
|
331
|
+
5. **Mock External Dependencies**: Don't rely on external services in unit tests
|
|
332
|
+
6. **Clean Up**: Reset state between tests with `beforeEach`/`afterEach`
|
|
333
|
+
7. **Test Edge Cases**: Include tests for error conditions and boundary values
|
|
334
|
+
8. **Keep Tests Fast**: Unit tests should run in milliseconds
|
|
335
|
+
|
|
336
|
+
## Resources
|
|
337
|
+
|
|
338
|
+
- [Jest Documentation](https://jestjs.io/docs/getting-started)
|
|
339
|
+
- [Testing Best Practices](https://github.com/goldbergyoni/javascript-testing-best-practices)
|
|
340
|
+
- [Mixpeek API Docs](https://docs.mixpeek.com)
|
|
341
|
+
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! For license information please see mixpeekContextAdapter.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MixpeekContextAdapter=t():e.MixpeekContextAdapter=t()}(this,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>Ee});var r="undefined"!=typeof process&&process.env&&process.env.MIXPEEK_API_ENDPOINT?process.env.MIXPEEK_API_ENDPOINT:"undefined"!=typeof window&&window.MIXPEEK_API_ENDPOINT?window.MIXPEEK_API_ENDPOINT:"https://api.mixpeek.com",n={COLLECTIONS:"/v1/collections",DOCUMENTS:"/v1/collections/{collectionId}/documents",FEATURES:"/v1/collections/{collectionId}/documents/{documentId}/features",FEATURE_EXTRACTORS:"/v1/collections/features/extractors",RETRIEVERS:"/v1/retrievers/debug-inference"},o="auto",i="video",a="mixpeek_ctx_",c="Mixpeek-Prebid-Adapter/".concat("1.0.0");function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}const f=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.debug=!1,this.prefix="[".concat("mixpeek","]")},t=[{key:"setDebug",value:function(e){this.debug=e}},{key:"info",value:function(){if(this.debug){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[this.prefix].concat(r))}}},{key:"warn",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[this.prefix].concat(r))}},{key:"error",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[this.prefix].concat(r))}},{key:"group",value:function(e){this.debug&&console.group&&console.group("".concat(this.prefix," ").concat(e))}},{key:"groupEnd",value:function(){this.debug&&console.groupEnd&&console.groupEnd()}},{key:"time",value:function(e){this.debug&&console.time&&console.time("".concat(this.prefix," ").concat(e))}},{key:"timeEnd",value:function(e){this.debug&&console.timeEnd&&console.timeEnd("".concat(this.prefix," ").concat(e))}},{key:"table",value:function(e){this.debug&&console.table&&console.table(e)}}],t&&l(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function h(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(p(e)+" is not iterable")}function d(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return m(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(m(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,m(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,m(f,"constructor",l),m(l,"constructor",u),u.displayName="GeneratorFunction",m(l,o,"GeneratorFunction"),m(f),m(f,o,"Generator"),m(f,n,function(){return this}),m(f,"toString",function(){return"[object Generator]"}),(d=function(){return{w:i,m:h}})()}function m(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,r,n){function i(t,r){m(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},m(e,t,r,n)}function y(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function g(e){return null!==e&&"object"===p(e)&&!Array.isArray(e)}function b(e,t){var r=Object.assign({},e);return g(e)&&g(t)&&Object.keys(t).forEach(function(n){var o,i,a;g(t[n])&&n in e?r[n]=b(e[n],t[n]):Object.assign(r,(o={},i=n,a=t[n],(i=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(i))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,o))}),r}function w(e){var t=[];return e.apiKey&&"string"==typeof e.apiKey||t.push("apiKey is required and must be a string"),e.collectionId&&"string"==typeof e.collectionId||t.push("collectionId is required and must be a string"),e.timeout&&("number"!=typeof e.timeout||e.timeout<0)&&t.push("timeout must be a positive number"),e.cacheTTL&&("number"!=typeof e.cacheTTL||e.cacheTTL<0)&&t.push("cacheTTL must be a positive number"),t.length>0?{valid:!1,errors:t,code:"INVALID_CONFIG"}:{valid:!0}}function x(e){try{return new URL(e).hostname}catch(e){return""}}function _(e){return e?e.replace(/\s+/g," ").replace(/[\r\n\t]/g," ").trim():""}function A(){return"undefined"!=typeof window&&"undefined"!=typeof document}function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{return JSON.parse(e)}catch(e){return f.warn("Failed to parse JSON:",e),t}}function I(e){return k.apply(this,arguments)}function k(){var e;return e=d().m(function e(t){var r,n,o,i,a,c,u=arguments;return d().w(function(e){for(;;)switch(e.n){case 0:r=u.length>1&&void 0!==u[1]?u[1]:3,n=u.length>2&&void 0!==u[2]?u[2]:100,i=d().m(function e(){var i,a,u;return d().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t();case 1:return a=e.v,e.a(2,{v:a});case 2:if(e.p=2,u=e.v,o=u,!(c<r)){e.n=3;break}return i=n*Math.pow(2,c-1),f.warn("Attempt ".concat(c," failed, retrying in ").concat(i,"ms...")),e.n=3,new Promise(function(e){return setTimeout(e,i)});case 3:return e.a(2)}},e,null,[[0,2]])}),c=1;case 1:if(!(c<=r)){e.n=4;break}return e.d(h(i()),2);case 2:if(!(a=e.v)){e.n=3;break}return e.a(2,a.v);case 3:c++,e.n=1;break;case 4:throw o;case 5:return e.a(2)}},e)}),k=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){y(i,n,o,a,c,"next",e)}function c(e){y(i,n,o,a,c,"throw",e)}a(void 0)})},k.apply(this,arguments)}function E(e){return new Promise(function(t,r){setTimeout(function(){return r(new Error("Timeout"))},e)})}function C(e,t){return Promise.race([e,E(t)])}function O(){return Math.floor(Date.now()/1e3)}function j(e,t){return O()-e>t}function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||B(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){if(e){if("string"==typeof e)return q(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(e,t):void 0}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,D(n.key),n)}}function D(e){var t=function(e){if("object"!=P(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}const L=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.memoryCache=new Map,this.useLocalStorage=this._checkLocalStorageAvailable(),this.ttl=300},t=[{key:"_checkLocalStorageAvailable",value:function(){try{var e="__mixpeek_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return f.warn("localStorage not available, using memory cache only"),!1}}},{key:"_getCacheKey",value:function(e){return"".concat(a).concat("v1","_").concat(e)}},{key:"setTTL",value:function(e){this.ttl=e}},{key:"get",value:function(e){var t=this._getCacheKey(e);if(this.memoryCache.has(t)){var r=this.memoryCache.get(t);if(!j(r.timestamp,this.ttl))return f.info("Cache hit (memory):",e),r.data;f.info("Cache expired (memory):",e),this.memoryCache.delete(t)}if(this.useLocalStorage)try{var n=localStorage.getItem(t);if(n){var o=S(n);if(o&&!j(o.timestamp,this.ttl))return f.info("Cache hit (localStorage):",e),this.memoryCache.set(t,o),o.data;f.info("Cache expired (localStorage):",e),localStorage.removeItem(t)}}catch(e){f.warn("Error reading from localStorage:",e)}return f.info("Cache miss:",e),null}},{key:"set",value:function(e,t){var r=this._getCacheKey(e),n={data:t,timestamp:O()};try{return this.memoryCache.set(r,n),this.useLocalStorage&&localStorage.setItem(r,JSON.stringify(n)),f.info("Cached:",e),!0}catch(e){return f.warn("Error setting cache:",e),!1}}},{key:"remove",value:function(e){var t=this._getCacheKey(e);try{return this.memoryCache.delete(t),this.useLocalStorage&&localStorage.removeItem(t),f.info("Cache removed:",e),!0}catch(e){return f.warn("Error removing cache:",e),!1}}},{key:"clear",value:function(){try{return this.memoryCache.clear(),this.useLocalStorage&&Object.keys(localStorage).forEach(function(e){e.startsWith(a)&&localStorage.removeItem(e)}),f.info("Cache cleared"),!0}catch(e){return f.warn("Error clearing cache:",e),!1}}},{key:"getStats",value:function(){var e=0,t=0;if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(r){r.startsWith(a)&&(t++,e+=localStorage.getItem(r).length)})}catch(e){f.warn("Error getting cache stats:",e)}return{memoryCount:this.memoryCache.size,localStorageCount:t,localStorageSize:e,ttl:this.ttl}}},{key:"prune",value:function(){var e,t=this,r=0,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=B(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(this.memoryCache.entries());try{for(n.s();!(e=n.n()).done;){var o=T(e.value,2),i=o[0];j(o[1].timestamp,this.ttl)&&(this.memoryCache.delete(i),r++)}}catch(e){n.e(e)}finally{n.f()}if(this.useLocalStorage)try{Object.keys(localStorage).forEach(function(e){if(e.startsWith(a)){var n=S(localStorage.getItem(e));n&&j(n.timestamp,t.ttl)&&(localStorage.removeItem(e),r++)}})}catch(e){f.warn("Error pruning cache:",e)}return r>0&&f.info("Pruned ".concat(r," expired cache items")),r}}],t&&F(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}function M(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return R(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(R(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,R(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,R(f,"constructor",l),R(l,"constructor",u),u.displayName="GeneratorFunction",R(l,o,"GeneratorFunction"),R(f),R(f,o,"Generator"),R(f,n,function(){return this}),R(f,"toString",function(){return"[object Generator]"}),(M=function(){return{w:i,m:h}})()}function R(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}R=function(e,t,r,n){function i(t,r){R(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},R(e,t,r,n)}function G(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach(function(t){z(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function H(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function U(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){H(i,n,o,a,c,"next",e)}function c(e){H(i,n,o,a,c,"throw",e)}a(void 0)})}}function z(e,t,r){return(t=V(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,V(n.key),n)}}function V(e){var t=function(e){if("object"!=N(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==N(t)?t:t+""}const X=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.apiKey=t.apiKey||"",this.endpoint=t.endpoint||r,this.namespace=t.namespace||null,this.timeout=t.timeout||250,this.retryAttempts=t.retryAttempts||2},t=[{key:"configure",value:function(e){Object.assign(this,e)}},{key:"_buildHeaders",value:function(){var e=z(z(z({},"Content-Type","application/json"),"Authorization","Bearer ".concat(this.apiKey)),"User-Agent",c);return this.namespace&&(e["X-Namespace"]=this.namespace),e}},{key:"_request",value:(d=U(M().m(function e(t){var r,n,o,i,a,c,u,l=arguments;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=l.length>1&&void 0!==l[1]?l[1]:{},n="".concat(this.endpoint).concat(t),o=this._buildHeaders(),i=K(K({},r),{},{headers:K(K({},o),r.headers)}),f.info("API Request: ".concat(r.method||"GET"," ").concat(n)),f.time("API Request: ".concat(t)),e.p=1,e.n=2,C(fetch(n,i),this.timeout);case 2:if(a=e.v,f.timeEnd("API Request: ".concat(t)),a.ok){e.n=4;break}return e.n=3,this._handleErrorResponse(a);case 3:throw e.v;case 4:return e.n=5,a.json();case 5:return c=e.v,f.info("API Response:",{status:a.status,path:t}),e.a(2,c);case 6:if(e.p=6,u=e.v,f.timeEnd("API Request: ".concat(t)),"Timeout"!==u.message){e.n=7;break}throw{code:"API_TIMEOUT",message:"Request timeout after ".concat(this.timeout,"ms"),path:t};case 7:throw u;case 8:return e.a(2)}},e,this,[[1,6]])})),function(e){return d.apply(this,arguments)})},{key:"_handleErrorResponse",value:(h=U(M().m(function e(t){var r,n;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return r="API error: ".concat(t.status," ").concat(t.statusText),e.p=1,e.n=2,t.json();case 2:n=e.v,r=n.message||n.error||r,e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2,{code:"API_ERROR",message:r,status:t.status})}},e,null,[[1,3]])})),function(e){return h.apply(this,arguments)})},{key:"createDocument",value:(s=U(M().m(function e(t,r){var o,i,a=this;return M().w(function(e){for(;;)if(0===e.n)return o=n.DOCUMENTS.replace("{collectionId}",t),i={object_id:r.objectId||v(),metadata:r.metadata||{},features:r.features||[]},e.a(2,I(function(){return a._request(o,{method:"POST",body:JSON.stringify(i)})},this.retryAttempts))},e,this)})),function(e,t){return s.apply(this,arguments)})},{key:"getDocument",value:(l=U(M().m(function e(t,r){var o;return M().w(function(e){for(;;)if(0===e.n)return o="".concat(n.DOCUMENTS.replace("{collectionId}",t),"/").concat(r),e.a(2,this._request(o,{method:"GET"}))},e,this)})),function(e,t){return l.apply(this,arguments)})},{key:"processContent",value:(u=U(M().m(function e(t,r){var n,o,i,a,c=this,u=arguments;return M().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:[],f.group("Processing content with Mixpeek"),f.info("Collection:",t),f.info("Feature Extractors:",n),e.p=1,o=n.map(function(e){var t={feature_extractor_id:"string"==typeof e?e:e.feature_extractor_id};return"object"===N(e)&&e.payload?t.payload=e.payload:t.payload=c._buildFeaturePayload(r),t}),e.n=2,this.createDocument(t,{objectId:this._generateContentId(r),metadata:{url:r.url,title:r.title,timestamp:Date.now()},features:o});case 2:return i=e.v,f.info("Document created:",i.document_id),f.groupEnd(),e.a(2,i);case 3:throw e.p=3,a=e.v,f.error("Error processing content:",a),f.groupEnd(),a;case 4:return e.a(2)}},e,this,[[1,3]])})),function(e,t){return u.apply(this,arguments)})},{key:"_buildFeaturePayload",value:function(e){var t={};return e.text&&(t.text=e.text),e.url&&(t.url=e.url),e.src&&void 0!==e.duration&&(t.video_url=e.src,t.title=e.title,t.description=e.description),e.src&&e.width&&e.height&&!e.duration&&(t.image_url=e.src,t.alt_text=e.alt),e.metadata&&(t.metadata=e.metadata),t}},{key:"_generateContentId",value:function(e){return e.url?"url_".concat(e.url.split("?")[0]):e.src?"src_".concat(e.src.split("?")[0]):v()}},{key:"listFeatureExtractors",value:(a=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request(n.FEATURE_EXTRACTORS,{method:"GET"}))},e,this)})),function(){return a.apply(this,arguments)})},{key:"getFeatureExtractor",value:(i=U(M().m(function e(t){var r;return M().w(function(e){for(;;)if(0===e.n)return r=n.FEATURE_EXTRACTORS+"/".concat(t),e.a(2,this._request(r,{method:"GET"}))},e,this)})),function(e){return i.apply(this,arguments)})},{key:"healthCheck",value:(o=U(M().m(function e(){return M().w(function(e){for(;;)if(0===e.n)return e.a(2,this._request("/v1/health",{method:"GET"}))},e,this)})),function(){return o.apply(this,arguments)})}],t&&W(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,o,i,a,u,l,s,h,d}();function J(e){var t,r=e.querySelector("h1"),n=e.querySelector('[itemprop="headline"]');return _((null===(t=r||n)||void 0===t?void 0:t.textContent)||"")}function $(e){var t=e.querySelector('[itemprop="author"]')||e.querySelector('[rel="author"]')||e.querySelector(".author");return _((null==t?void 0:t.textContent)||"")}function Q(e){var t=e.querySelector('[itemprop="datePublished"]')||e.querySelector("time[datetime]");return(null==t?void 0:t.getAttribute("datetime"))||(null==t?void 0:t.textContent)||""}function Y(){return null!==document.querySelector("article")||null!==document.querySelector('[itemtype*="Article"]')||null!==document.querySelector('meta[property="og:type"][content="article"]')}function Z(e){if(e.src)return e.src;var t=e.querySelector("source");return t&&t.src?t.src:e.currentSrc?e.currentSrc:""}function ee(e){var t,r,n=e.getAttribute("data-title")||e.getAttribute("title")||e.getAttribute("aria-label");if(n)return _(n);var o=e.closest("[data-video-title]");if(o)return _(o.getAttribute("data-video-title"));var i=(null===(t=e.previousElementSibling)||void 0===t?void 0:t.querySelector("h1, h2, h3"))||(null===(r=e.parentElement)||void 0===r?void 0:r.querySelector("h1, h2, h3"));return i?_(i.textContent):""}function te(e){var t=e.getAttribute("data-description")||e.getAttribute("aria-description");if(t)return _(t);var r=e.closest("[data-video-description]");return r?_(r.getAttribute("data-video-description")):""}function re(e){var t={};return Array.from(e.attributes).forEach(function(e){if(e.name.startsWith("data-")){var r=e.name.replace("data-","").replace(/-/g,"_");t[r]=e.value}}),t}function ne(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return r>0?t/r:0}function oe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ie(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ie(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ae={node_technology:"IAB19",node_tech_computing:"IAB19",node_tech_ai:"IAB19-11",node_tech_artificial_intelligence:"IAB19-11",node_tech_machine_learning:"IAB19-11",node_tech_software:"IAB19-18",node_tech_hardware:"IAB19-19",node_tech_mobile:"IAB19-20",node_electronics_phones:"IAB19-20",node_tech_internet:"IAB19-21",sports:"IAB17",sports_football:"IAB17-3",sports_soccer:"IAB17-44",sports_basketball:"IAB17-4",sports_baseball:"IAB17-5",sports_tennis:"IAB17-37",news:"IAB12",news_politics:"IAB12-2",news_business:"IAB12-3",news_technology:"IAB12-6",business:"IAB13",business_finance:"IAB13-7",business_investing:"IAB13-5",entertainment:"IAB9",entertainment_movies:"IAB9-7",entertainment_tv:"IAB9-23",entertainment_music:"IAB9-8",health:"IAB7",health_fitness:"IAB7-18",health_nutrition:"IAB7-30",travel:"IAB20",travel_hotels:"IAB20-12",food:"IAB8",food_cooking:"IAB8-5",food_restaurants:"IAB8-9",automotive:"IAB2",automotive_cars:"IAB2",real_estate:"IAB21",education:"IAB5",fashion:"IAB18",fashion_beauty:"IAB18-1",home:"IAB10",home_garden:"IAB10-3",science:"IAB15",arts:"IAB1",arts_design:"IAB1-4"},ce={technology:"IAB19",tech:"IAB19",ai:"IAB19-11","artificial intelligence":"IAB19-11","machine learning":"IAB19-11",software:"IAB19-18",hardware:"IAB19-19",mobile:"IAB19-20",computing:"IAB19",sports:"IAB17",football:"IAB17-3",soccer:"IAB17-44",basketball:"IAB17-4",baseball:"IAB17-5",news:"IAB12",politics:"IAB12-2",business:"IAB13",finance:"IAB13-7",investing:"IAB13-5",entertainment:"IAB9",movies:"IAB9-7",television:"IAB9-23",music:"IAB9-8",gaming:"IAB9-30",health:"IAB7",fitness:"IAB7-18",wellness:"IAB7",nutrition:"IAB7-30",travel:"IAB20",food:"IAB8",automotive:"IAB2",cars:"IAB2","real estate":"IAB21",education:"IAB5",fashion:"IAB18",home:"IAB10",science:"IAB15",arts:"IAB1"};function ue(e){return!(!e||"string"!=typeof e)&&/^IAB\d+(-\d+)?$/.test(e)}function le(e){if(!e||"string"!=typeof e)return null;var t=e.match(/IAB\d+(-\d+)?/);return t?t[0]:null}function se(e){if(!e)return null;if(e.label){if(ue(e.label))return e.label;var t=le(e.label);if(t)return t}if(e.nodeId||e.node_id){var r=e.nodeId||e.node_id;if(ue(r))return r;var n=le(r);if(n)return n}if(e.nodeId||e.node_id){var o=(e.nodeId||e.node_id).toLowerCase();if(ae[o])return ae[o];for(var i=o.replace(/[_-]/g,""),a=0,c=Object.entries(ae);a<c.length;a++){var u=oe(c[a],2),l=u[0],s=u[1];if(l.replace(/[_-]/g,"")===i)return s}}if(e.label){var f=e.label.toLowerCase();if(ce[f])return ce[f];for(var h=0,d=Object.entries(ce);h<d.length;h++){var m=oe(d[h],2),y=m[0],p=m[1];if(f.includes(y))return p}}if(e.path)for(var v=Array.isArray(e.path)?e.path.join(" ").toLowerCase():e.path.toLowerCase(),g=0,b=Object.entries(ce);g<b.length;g++){var w=oe(b[g],2),x=w[0],_=w[1];if(v.includes(x))return _}return null}function fe(e){return fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fe(e)}function he(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,de(n.key),n)}}function de(e){var t=function(e){if("object"!=fe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=fe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fe(t)?t:t+""}var me="mixpeek_prev_ad_v1";const ye=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.lastAd=null,this.storageAvailable=this._checkLocalStorage(),this._loadFromStorage()},t=[{key:"_checkLocalStorage",value:function(){if(!A())return!1;try{var e="__mixpeek_prev_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch(e){return!1}}},{key:"_loadFromStorage",value:function(){if(this.storageAvailable)try{var e=localStorage.getItem(me);if(e){var t=S(e);t&&"object"===fe(t)&&(this.lastAd=t)}}catch(e){f.warn("Failed to load previous ad from storage:",e)}}},{key:"_persist",value:function(){if(this.storageAvailable)try{localStorage.setItem(me,JSON.stringify(this.lastAd))}catch(e){f.warn("Failed to persist previous ad:",e)}}},{key:"record",value:function(e){var t,r;if(e&&"object"===fe(e)){var n={creativeId:e.creativeId||e.creative_id||null,bidder:e.bidder||e.bidderCode||null,adUnitCode:e.adUnitCode||null,cpm:"number"==typeof e.cpm?e.cpm:null,currency:e.currency||null,categories:Array.isArray(null===(t=e.meta)||void 0===t?void 0:t.adServerCatId)?e.meta.adServerCatId:null!==(r=e.meta)&&void 0!==r&&r.primaryCat?[e.meta.primaryCat]:[],timestamp:Date.now()};this.lastAd=n,this._persist()}}},{key:"getLast",value:function(){return this.lastAd}},{key:"clear",value:function(){if(this.lastAd=null,this.storageAvailable)try{localStorage.removeItem(me)}catch(e){}}}],t&&he(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function pe(e){return pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pe(e)}function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(r),!0).forEach(function(t){be(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ve(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function be(e,t,r){return(t=Ie(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function we(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,l=Object.create(u.prototype);return xe(l,"_invoke",function(r,n,o){var i,c,u,l=0,s=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,u=e,h.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!f&&l&&!o&&t<s.length;t++){var o,i=s[t],d=h.p,m=i[2];r>3?(o=m===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,h.v=n,h.n=i[1]):d<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,h.n=m,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,m){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),c=s,u=m;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(h.n=-1),d(c,u)):h.n=u:h.v=u);try{if(l=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,c=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function u(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(xe(t={},n,function(){return this}),t),f=l.prototype=c.prototype=Object.create(s);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,xe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,xe(f,"constructor",l),xe(l,"constructor",u),u.displayName="GeneratorFunction",xe(l,o,"GeneratorFunction"),xe(f),xe(f,o,"Generator"),xe(f,n,function(){return this}),xe(f,"toString",function(){return"[object Generator]"}),(we=function(){return{w:i,m:h}})()}function xe(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}xe=function(e,t,r,n){function i(t,r){xe(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},xe(e,t,r,n)}function _e(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function Ae(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){_e(i,n,o,a,c,"next",e)}function c(e){_e(i,n,o,a,c,"throw",e)}a(void 0)})}}function Se(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ie(n.key),n)}}function Ie(e){var t=function(e){if("object"!=pe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=pe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==pe(t)?t:t+""}var ke=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={},this.client=null,this.initialized=!1,this.processing=!1,this.contextData=null,this.events={},this.healthCheckPerformed=!1},t=[{key:"init",value:(l=Ae(we().m(function e(t){var r,n;return we().w(function(e){for(;;)switch(e.n){case 0:if(f.info("Initializing Mixpeek Context Adapter"),f.group("Configuration"),(r=w(t)).valid){e.n=1;break}return f.error("Invalid configuration:",r.errors),f.groupEnd(),e.a(2,!1);case 1:if(this.config=b({endpoint:"https://api.mixpeek.com",timeout:250,cacheTTL:300,retryAttempts:2,mode:o,enableCache:!0,debug:!1,healthCheck:"lazy",featureExtractors:["taxonomy"],batchSize:1},t),f.setDebug(this.config.debug),this.client=new X({apiKey:this.config.apiKey,endpoint:this.config.endpoint,namespace:this.config.namespace,timeout:this.config.timeout,retryAttempts:this.config.retryAttempts}),this.config.enableCache&&L.setTTL(this.config.cacheTTL),f.table({"API Endpoint":this.config.endpoint,"Collection ID":this.config.collectionId,Namespace:this.config.namespace||"default",Mode:this.config.mode,Timeout:"".concat(this.config.timeout,"ms"),"Cache TTL":"".concat(this.config.cacheTTL,"s"),"Feature Extractors":this.config.featureExtractors.join(", "),"Health Check":this.config.healthCheck}),f.groupEnd(),"eager"!==this.config.healthCheck){e.n=3;break}return f.info("Performing health check..."),e.n=2,this._performHealthCheck();case 2:(n=e.v).healthy?f.info("Health check passed:",n.message):(f.warn("Health check failed, but continuing initialization"),f.warn("API may be unavailable:",n.error)),e.n=4;break;case 3:"lazy"===this.config.healthCheck&&f.info("Health check will be performed on first request");case 4:return this.initialized=!0,f.info("Mixpeek Context Adapter initialized successfully"),e.a(2,!0)}},e,this)})),function(e){return l.apply(this,arguments)})},{key:"_performHealthCheck",value:(u=Ae(we().m(function e(){var t,r,n,o;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,t=performance.now(),e.n=1,this.client.healthCheck();case 1:return r=e.v,n=performance.now()-t,e.a(2,{healthy:!0,status:r.status||"ok",version:r.version,latency:Math.round(n),message:"API responding in ".concat(Math.round(n),"ms")});case 2:return e.p=2,o=e.v,e.a(2,{healthy:!1,error:o.message,message:"API health check failed"})}},e,this,[[0,2]])})),function(){return u.apply(this,arguments)})},{key:"enrichAdUnits",value:(c=Ae(we().m(function e(t){var r,n,o,i,a;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.initialized){e.n=1;break}return f.warn("Adapter not initialized"),e.a(2,t);case 1:if(!this.processing){e.n=2;break}return f.warn("Already processing context"),e.a(2,t);case 2:return this.processing=!0,r=performance.now(),e.p=3,e.n=4,this.getContext();case 4:if(n=e.v){e.n=5;break}return f.warn("No context data available"),e.a(2,t);case 5:return this.contextData=n,o=this._injectTargetingKeys(t,n),i=performance.now()-r,f.info("Context enrichment completed in ".concat(i.toFixed(2),"ms")),i>100&&f.warn("Enrichment took ".concat(i.toFixed(2),"ms (threshold: ").concat(100,"ms)")),this._emitEvent("mixpeekContextReady",n),e.a(2,o);case 6:return e.p=6,a=e.v,f.error("Error enriching ad units:",a),this._emitEvent("mixpeekContextError",a),e.a(2,t);case 7:return e.p=7,this.processing=!1,e.f(7);case 8:return e.a(2)}},e,this,[[3,6,7,8]])})),function(e){return c.apply(this,arguments)})},{key:"getContext",value:(a=Ae(we().m(function e(){var t,r,n,o,i,a,c,u;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(f.time("getContext"),e.p=1,"lazy"!==this.config.healthCheck||this.healthCheckPerformed){e.n=3;break}return f.info("Performing lazy health check..."),e.n=2,this._performHealthCheck();case 2:t=e.v,this.healthCheckPerformed=!0,t.healthy?f.info("Health check passed:",t.message):(f.warn("Health check failed:",t.error),f.warn("Proceeding anyway, errors will be handled gracefully"));case 3:return r=this._detectContentMode(),f.info("Content mode:",r),e.n=4,this._extractContent(r);case 4:if(n=e.v){e.n=5;break}return f.warn("No content extracted"),f.timeEnd("getContext"),e.a(2,null);case 5:if(o=this._generateCacheKey(n,r),!this.config.enableCache){e.n=6;break}if(!(i=L.get(o))){e.n=6;break}return f.info("Using cached context"),f.timeEnd("getContext"),this._emitEvent("mixpeekContextCached",i),e.a(2,i);case 6:return f.info("Processing content with Mixpeek API"),this._emitEvent("mixpeekApiRequest",{content:n,mode:r}),e.n=7,this.client.processContent(this.config.collectionId,n,this.config.featureExtractors);case 7:return a=e.v,this._emitEvent("mixpeekApiResponse",a),c=this._parseContext(a,n,r),this.config.enableCache&&L.set(o,c),f.timeEnd("getContext"),e.a(2,c);case 8:throw e.p=8,u=e.v,f.error("Error getting context:",u),f.timeEnd("getContext"),u;case 9:return e.a(2)}},e,this,[[1,8]])})),function(){return a.apply(this,arguments)})},{key:"_detectContentMode",value:function(){return this.config.mode!==o?this.config.mode:null!==document.querySelector("video")||null!==document.querySelector('iframe[src*="youtube.com"]')||null!==document.querySelector('iframe[src*="vimeo.com"]')?i:(Y()||(e=document.querySelectorAll("img"),Array.from(e).some(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200})),"page");var e}},{key:"_extractContent",value:(n=Ae(we().m(function e(t){var r;return we().w(function(e){for(;;)switch(e.n){case 0:if(A()){e.n=1;break}return f.warn("Not in browser environment"),e.a(2,null);case 1:f.info("Extracting ".concat(t," content")),r=t,e.n=r===i?2:"image"===r?3:4;break;case 2:return e.a(2,this._extractVideoContent());case 3:return e.a(2,this._extractImageContent());case 4:return e.a(2,this._extractPageContent());case 5:return e.a(2)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"_extractPageContent",value:function(){var e=function(){f.time("extractPageContent");try{var e={url:window.location.href,domain:x(window.location.href),title:document.title,description:(i=document.querySelector('meta[name="description"]')||document.querySelector('meta[property="og:description"]'),i?_(i.content):""),text:(o=document.body.cloneNode(!0),o.querySelectorAll("script, style, iframe, nav, footer, aside, .ad, .advertisement").forEach(function(e){return e.remove()}),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e4;return!e||e.length<=t?e:(f.warn("Content truncated from ".concat(e.length," to ").concat(t," characters")),e.substring(0,t))}(_(o.textContent||o.innerText||""),5e4)),keywords:(n=document.querySelector('meta[name="keywords"]'),n?n.content.split(",").map(function(e){return e.trim()}).filter(Boolean):[]),ogTags:(r={},document.querySelectorAll('meta[property^="og:"]').forEach(function(e){var t=e.getAttribute("property").replace("og:","");r[t]=e.content}),r),structuredData:(t=[],document.querySelectorAll('script[type="application/ld+json"]').forEach(function(e){try{var r=JSON.parse(e.textContent);t.push(r)}catch(e){f.warn("Failed to parse structured data:",e)}}),t),language:document.documentElement.lang||"en"};return f.timeEnd("extractPageContent"),f.info("Extracted page content:",{url:e.url,textLength:e.text.length,keywords:e.keywords.length}),e}catch(e){return f.error("Error extracting page content:",e),f.timeEnd("extractPageContent"),null}var t,r,n,o,i}();if(!e)return null;if(Y()){var t=function(){try{var e=document.querySelector("article")||document.querySelector('[role="article"]')||document.querySelector(".article")||document.querySelector(".post");return e?{headline:J(e),author:$(e),datePublished:Q(e),content:_(e.textContent||e.innerText||"")}:null}catch(e){return f.warn("Error extracting article content:",e),null}}();if(t)return ge(ge({},e),{},{article:t})}var r=function(){var e,t,r,n=document.querySelector('meta[property="og:image"]');return n?{src:n.content,alt:(null===(e=document.querySelector('meta[property="og:image:alt"]'))||void 0===e?void 0:e.content)||"",width:parseInt((null===(t=document.querySelector('meta[property="og:image:width"]'))||void 0===t?void 0:t.content)||"0"),height:parseInt((null===(r=document.querySelector('meta[property="og:image:height"]'))||void 0===r?void 0:r.content)||"0")}:null}();return r&&(e.featuredImage=r),e}},{key:"_extractVideoContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"video";f.time("extractVideoContent");try{var t=function(e){return Array.from(document.querySelectorAll(e)).sort(function(e,t){var r=(e.videoWidth||e.width||0)*(e.videoHeight||e.height||0);return(t.videoWidth||t.width||0)*(t.videoHeight||t.height||0)-r})}(e);if(0===t.length)return f.info("No video elements found"),f.timeEnd("extractVideoContent"),null;var r=t[0],n={src:Z(r),poster:r.poster||"",title:ee(r),description:te(r),duration:r.duration||0,currentTime:r.currentTime||0,dimensions:{width:r.videoWidth||r.width||0,height:r.videoHeight||r.height||0},metadata:re(r)};return f.timeEnd("extractVideoContent"),f.info("Extracted video content:",{src:n.src,title:n.title,duration:n.duration}),n}catch(e){return f.error("Error extracting video content:",e),f.timeEnd("extractVideoContent"),null}}(this.config.videoSelector||"video");if(!e){var t=function(){var e=document.querySelector('iframe[src*="youtube.com"]');if(e){var t=e.src,r=t.match(/embed\/([^?]+)/);return{platform:"youtube",videoId:r?r[1]:"",src:t}}var n=document.querySelector('iframe[src*="vimeo.com"]');if(n){var o=n.src,i=o.match(/video\/(\d+)/);return{platform:"vimeo",videoId:i?i[1]:"",src:o}}return null}();return t?ge(ge({},t),{},{type:"embedded"}):null}return ge(ge({},e),{},{type:"native"})}},{key:"_extractImageContent",value:function(){var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;f.time("extractImages");try{var t=Array.from(document.querySelectorAll("img")).filter(function(e){var t=e.naturalWidth||e.width||0,r=e.naturalHeight||e.height||0;return t>=200&&r>=200}).filter(function(e){var t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility}).filter(function(e){return!e.closest('.ad, .advertisement, [id*="ad-"], [class*="ad-"]')}).sort(function(e,t){var r=(e.naturalWidth||e.width||0)*(e.naturalHeight||e.height||0);return(t.naturalWidth||t.width||0)*(t.naturalHeight||t.height||0)-r}).slice(0,e).map(function(e){return{src:e.src,alt:_(e.alt||""),title:_(e.title||""),width:e.naturalWidth||e.width||0,height:e.naturalHeight||e.height||0,aspectRatio:ne(e)}});return f.timeEnd("extractImages"),f.info("Extracted ".concat(t.length," images")),t}catch(e){return f.error("Error extracting images:",e),f.timeEnd("extractImages"),[]}}(this.config.maxImages||5);return 0===e.length?null:{images:e,primaryImage:e[0],count:e.length}}},{key:"_generateCacheKey",value:function(e,t){var r=t;if(e.url)r+="_".concat(e.url);else if(e.src)r+="_".concat(e.src);else if(e.images){var n;r+="_".concat((null===(n=e.images[0])||void 0===n?void 0:n.src)||"")}return function(e){var t=0;if(0===e.length)return t.toString();for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t).toString(36)}(r+="_".concat(this.config.featureExtractors.sort().join("_")))}},{key:"_parseContext",value:function(e,t,r){var n,o={documentId:e.document_id,mode:r,content:{url:t.url||t.src||"",title:t.title||"",type:r}};if(e.enrichments&&e.enrichments.taxonomies){var i=e.enrichments.taxonomies;if(i.length>0){var a=i[0];o.taxonomy={label:a.label,nodeId:a.node_id,path:a.path,score:a.score,all:i}}}return e.enrichments&&(e.enrichments.brand_safety&&(o.brandSafety=e.enrichments.brand_safety),e.enrichments.keywords&&(o.keywords=e.enrichments.keywords),e.enrichments.sentiment&&(o.sentiment=e.enrichments.sentiment),e.enrichments.embeddings&&(o.embeddingId=(null===(n=e.enrichments.embeddings[0])||void 0===n?void 0:n.id)||null)),o}},{key:"_injectTargetingKeys",value:function(e,t){var r=this._buildTargetingKeys(t);return f.info("Targeting keys:",r),e.map(function(e){return e.ortb2Imp||(e.ortb2Imp={}),e.ortb2Imp.ext||(e.ortb2Imp.ext={}),e.ortb2Imp.ext.data||(e.ortb2Imp.ext.data={}),Object.assign(e.ortb2Imp.ext.data,r),e.bids||(e.bids=[]),e.bids=e.bids.map(function(e){return e.params||(e.params={}),e.params.keywords||(e.params.keywords={}),Object.assign(e.params.keywords,r),e}),e})}},{key:"_buildTargetingKeys",value:function(e){var t,r={};if(e.taxonomy){r.hb_mixpeek_category=e.taxonomy.label,r.hb_mixpeek_node=e.taxonomy.nodeId,r.hb_mixpeek_path=Array.isArray(e.taxonomy.path)?e.taxonomy.path.join("/"):e.taxonomy.path,r.hb_mixpeek_score=e.taxonomy.score.toFixed(2);var n=e.taxonomy.label.match(/IAB\d+-\d+/);n&&(r.hb_mixpeek_taxonomy=n[0])}e.brandSafety&&(r.hb_mixpeek_safety="number"==typeof e.brandSafety?e.brandSafety.toFixed(2):(null===(t=e.brandSafety.score)||void 0===t?void 0:t.toFixed(2))||"0"),e.keywords&&(r.hb_mixpeek_keywords=Array.isArray(e.keywords)?e.keywords.slice(0,10).join(","):e.keywords),e.sentiment&&(r.hb_mixpeek_sentiment="string"==typeof e.sentiment?e.sentiment:e.sentiment.label||"neutral"),e.embeddingId&&(r.hb_mixpeek_embed=e.embeddingId);var o=ye.getLast();return o&&(o.creativeId&&(r.hb_mixpeek_prev_creative=String(o.creativeId)),o.bidder&&(r.hb_mixpeek_prev_bidder=String(o.bidder)),o.adUnitCode&&(r.hb_mixpeek_prev_adunit=String(o.adUnitCode)),Array.isArray(o.categories)&&o.categories.length>0&&(r.hb_mixpeek_prev_cat=o.categories.slice(0,5).join(","))),r}},{key:"formatForOrtb2SiteContent",value:function(e){var t;if(!e)return null;var r={};if(e.taxonomy){var n=se(e.taxonomy);n&&(r.cat=[n],r.cattax=6),e.taxonomy.label&&(r.genre=e.taxonomy.label)}return e.keywords&&(r.keywords=Array.isArray(e.keywords)?e.keywords.join(","):e.keywords),A()&&document.documentElement.lang&&(r.language=document.documentElement.lang),A()&&(document.title&&(r.title=document.title),window.location.href&&(r.url=window.location.href)),e.content&&(e.content.url&&!r.url&&(r.url=e.content.url),e.content.title&&!r.title&&(r.title=e.content.title)),r.ext={data:{mixpeek:{documentId:e.documentId,mode:e.mode,score:null===(t=e.taxonomy)||void 0===t?void 0:t.score,brandSafety:e.brandSafety,sentiment:e.sentiment,embeddingId:e.embeddingId}}},r}},{key:"formatForOrtb2Fragments",value:function(e){if(!e)return null;var t=this.formatForOrtb2SiteContent(e);return t?{global:{site:{content:t}}}:null}},{key:"formatAsDataSegments",value:function(e){if(!e||!e.taxonomy)return[];var t=[],r=se(e.taxonomy);return r&&t.push({id:r,name:e.taxonomy.label,value:e.taxonomy.score.toString()}),e.taxonomy.all&&Array.isArray(e.taxonomy.all)&&e.taxonomy.all.slice(1,5).forEach(function(e){var r=se(e);r&&t.push({id:r,name:e.label,value:e.score.toString()})}),t}},{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"_emitEvent",value:function(e,t){this.events[e]&&this.events[e].forEach(function(r){try{r(t)}catch(t){f.error("Error in event callback for ".concat(e,":"),t)}}),A()&&window.pbjs&&window.pbjs.emit(e,t)}},{key:"getContextData",value:function(){return this.contextData}},{key:"clearCache",value:function(){L.clear(),f.info("Cache cleared")}},{key:"getCacheStats",value:function(){return L.getStats()}},{key:"healthCheck",value:(r=Ae(we().m(function e(){var t,r;return we().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.client){e.n=1;break}return e.a(2,{status:"error",message:"Client not initialized"});case 1:return e.p=1,e.n=2,this.client.healthCheck();case 2:return t=e.v,e.a(2,ge({status:"ok"},t));case 3:return e.p=3,r=e.v,e.a(2,{status:"error",message:r.message})}},e,this,[[1,3]])})),function(){return r.apply(this,arguments)})}],t&&Se(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a,c,u,l}());const Ee=ke;return A()&&(window.MixpeekContextAdapter=ke),t})());
|
|
3
|
+
//# sourceMappingURL=mixpeekContextAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|