OwlCyberSecurity - MANAGER
Edit File: presto-search-bar2.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{d as defineCustomElement$1}from"./presto-search-bar-ui2.js";const getConstructor=e=>null!=e?e.constructor:null,instanceOf=(e,t)=>Boolean(e&&t&&e instanceof t),isNullOrUndefined=e=>null==e,isObject$1=e=>getConstructor(e)===Object,isString$1=e=>getConstructor(e)===String,isArray$1=e=>Array.isArray(e),isNodeList=e=>instanceOf(e,NodeList),isElement=e=>null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument,isEmpty=e=>isNullOrUndefined(e)||(isString$1(e)||isArray$1(e)||isNodeList(e))&&!e.length||isObject$1(e)&&!Object.keys(e).length,is={nullOrUndefined:isNullOrUndefined,object:isObject$1,string:isString$1,nodeList:isNodeList,element:isElement,empty:isEmpty,array:isArray$1};function isArray(e){return Array.isArray?Array.isArray(e):"[object Array]"===getTag(e)}const INFINITY=1/0;function baseToString(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function toString(e){return null==e?"":baseToString(e)}function isString(e){return"string"==typeof e}function isNumber(e){return"number"==typeof e}function isBoolean(e){return!0===e||!1===e||isObjectLike(e)&&"[object Boolean]"==getTag(e)}function isObject(e){return"object"==typeof e}function isObjectLike(e){return isObject(e)&&null!==e}function isDefined(e){return null!=e}function isBlank(e){return!e.trim().length}function getTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const EXTENDED_SEARCH_UNAVAILABLE="Extended search is not available",INCORRECT_INDEX_TYPE="Incorrect 'index' type",LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY=e=>`Invalid value for key ${e}`,PATTERN_LENGTH_TOO_LARGE=e=>`Pattern length exceeds max of ${e}.`,MISSING_KEY_PROPERTY=e=>`Missing ${e} property in key`,INVALID_KEY_WEIGHT_VALUE=e=>`Property 'weight' in key '${e}' must be a positive integer`,hasOwn=Object.prototype.hasOwnProperty;class KeyStore{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let r=createKey(e);t+=r.weight,this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function createKey(e){let t=null,r=null,n=null,i=1,s=null;if(isString(e)||isArray(e))n=e,t=createKeyPath(e),r=createKeyId(e);else{if(!hasOwn.call(e,"name"))throw new Error(MISSING_KEY_PROPERTY("name"));const o=e.name;if(n=o,hasOwn.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(INVALID_KEY_WEIGHT_VALUE(o));t=createKeyPath(o),r=createKeyId(o),s=e.getFn}return{path:t,id:r,weight:i,src:n,getFn:s}}function createKeyPath(e){return isArray(e)?e:e.split(".")}function createKeyId(e){return isArray(e)?e.join("."):e}function get(e,t){let r=[],n=!1;const i=(e,t,s)=>{if(isDefined(e))if(t[s]){const o=e[t[s]];if(!isDefined(o))return;if(s===t.length-1&&(isString(o)||isNumber(o)||isBoolean(o)))r.push(toString(o));else if(isArray(o)){n=!0;for(let e=0,r=o.length;e<r;e+=1)i(o[e],t,s+1)}else t.length&&i(o,t,s+1)}else r.push(e)};return i(e,isString(t)?t.split("."):t,0),n?r:r[0]}const MatchOptions={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},BasicOptions={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},FuzzyOptions={location:0,threshold:.6,distance:100},AdvancedOptions={useExtendedSearch:!1,getFn:get,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Config={...BasicOptions,...MatchOptions,...FuzzyOptions,...AdvancedOptions};const SPACE=/[^ ]+/g;function norm(e=1,t=3){const r=new Map,n=Math.pow(10,t);return{get(t){const i=t.match(SPACE).length;if(r.has(i))return r.get(i);const s=1/Math.pow(i,.5*e),o=parseFloat(Math.round(s*n)/n);return r.set(i,o),o},clear(){r.clear()}}}class FuseIndex{constructor({getFn:e=Config.getFn,fieldNormWeight:t=Config.fieldNormWeight}={}){this.norm=norm(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach(((e,t)=>{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,isString(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();isString(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,r=this.size();t<r;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!isDefined(e)||isBlank(e))return;let r={v:e,i:t,n:this.norm.get(e)};this.records.push(r)}_addObject(e,t){let r={i:t,$:{}};this.keys.forEach(((t,n)=>{let i=t.getFn?t.getFn(e):this.getFn(e,t.path);if(isDefined(i))if(isArray(i)){let e=[];const t=[{nestedArrIndex:-1,value:i}];for(;t.length;){const{nestedArrIndex:r,value:n}=t.pop();if(isDefined(n))if(isString(n)&&!isBlank(n)){let t={v:n,i:r,n:this.norm.get(n)};e.push(t)}else isArray(n)&&n.forEach(((e,r)=>{t.push({nestedArrIndex:r,value:e})}))}r.$[n]=e}else if(isString(i)&&!isBlank(i)){let e={v:i,n:this.norm.get(i)};r.$[n]=e}})),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function createIndex(e,t,{getFn:r=Config.getFn,fieldNormWeight:n=Config.fieldNormWeight}={}){const i=new FuseIndex({getFn:r,fieldNormWeight:n});return i.setKeys(e.map(createKey)),i.setSources(t),i.create(),i}function parseIndex(e,{getFn:t=Config.getFn,fieldNormWeight:r=Config.fieldNormWeight}={}){const{keys:n,records:i}=e,s=new FuseIndex({getFn:t,fieldNormWeight:r});return s.setKeys(n),s.setIndexRecords(i),s}function computeScore$1(e,{errors:t=0,currentLocation:r=0,expectedLocation:n=0,distance:i=Config.distance,ignoreLocation:s=Config.ignoreLocation}={}){const o=t/e.length;if(s)return o;const c=Math.abs(n-r);return i?o+c/i:c?1:o}function convertMaskToIndices(e=[],t=Config.minMatchCharLength){let r=[],n=-1,i=-1,s=0;for(let o=e.length;s<o;s+=1){let o=e[s];o&&-1===n?n=s:o||-1===n||(i=s-1,i-n+1>=t&&r.push([n,i]),n=-1)}return e[s-1]&&s-n>=t&&r.push([n,s-1]),r}const MAX_BITS=32;function search(e,t,r,{location:n=Config.location,distance:i=Config.distance,threshold:s=Config.threshold,findAllMatches:o=Config.findAllMatches,minMatchCharLength:c=Config.minMatchCharLength,includeMatches:a=Config.includeMatches,ignoreLocation:h=Config.ignoreLocation}={}){if(t.length>32)throw new Error("Pattern length exceeds max of 32.");const l=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let g=s,f=d;const p=c>1||a,m=p?Array(u):[];let y;for(;(y=e.indexOf(t,f))>-1;){let e=computeScore$1(t,{currentLocation:y,expectedLocation:d,distance:i,ignoreLocation:h});if(g=Math.min(e,g),f=y+l,p){let e=0;for(;e<l;)m[y+e]=1,e+=1}}f=-1;let v=[],M=1,x=l+u;const C=1<<l-1;for(let n=0;n<l;n+=1){let s=0,c=x;for(;s<c;)computeScore$1(t,{errors:n,currentLocation:d+c,expectedLocation:d,distance:i,ignoreLocation:h})<=g?s=c:x=c,c=Math.floor((x-s)/2+s);x=c;let a=Math.max(1,d-c+1),y=o?u:Math.min(d+c,u)+l,S=Array(y+2);S[y+1]=(1<<n)-1;for(let s=y;s>=a;s-=1){let o=s-1,c=r[e.charAt(o)];if(p&&(m[o]=+!!c),S[s]=(S[s+1]<<1|1)&c,n&&(S[s]|=(v[s+1]|v[s])<<1|1|v[s+1]),S[s]&C&&(M=computeScore$1(t,{errors:n,currentLocation:o,expectedLocation:d,distance:i,ignoreLocation:h}),M<=g)){if(g=M,f=o,f<=d)break;a=Math.max(1,2*d-f)}}if(computeScore$1(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:i,ignoreLocation:h})>g)break;v=S}const S={isMatch:f>=0,score:Math.max(.001,M)};if(p){const e=convertMaskToIndices(m,c);e.length?a&&(S.indices=e):S.isMatch=!1}return S}function createPatternAlphabet(e){let t={};for(let r=0,n=e.length;r<n;r+=1){const i=e.charAt(r);t[i]=(t[i]||0)|1<<n-r-1}return t}class BitapSearch{constructor(e,{location:t=Config.location,threshold:r=Config.threshold,distance:n=Config.distance,includeMatches:i=Config.includeMatches,findAllMatches:s=Config.findAllMatches,minMatchCharLength:o=Config.minMatchCharLength,isCaseSensitive:c=Config.isCaseSensitive,ignoreLocation:a=Config.ignoreLocation}={}){if(this.options={location:t,threshold:r,distance:n,includeMatches:i,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:c,ignoreLocation:a},this.pattern=c?e:e.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(e,t)=>{this.chunks.push({pattern:e,alphabet:createPatternAlphabet(e),startIndex:t})},l=this.pattern.length;if(l>32){let e=0;const t=l%32,r=l-t;for(;e<r;)h(this.pattern.substr(e,32),e),e+=32;if(t){const e=l-32;h(this.pattern.substr(e),e)}}else h(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,includeMatches:r}=this.options;if(t||(e=e.toLowerCase()),this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}const{location:n,distance:i,threshold:s,findAllMatches:o,minMatchCharLength:c,ignoreLocation:a}=this.options;let h=[],l=0,u=!1;this.chunks.forEach((({pattern:t,alphabet:d,startIndex:g})=>{const{isMatch:f,score:p,indices:m}=search(e,t,d,{location:n+g,distance:i,threshold:s,findAllMatches:o,minMatchCharLength:c,includeMatches:r,ignoreLocation:a});f&&(u=!0),l+=p,f&&m&&(h=[...h,...m])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&r&&(d.indices=h),d}}class BaseMatch{constructor(e){this.pattern=e}static isMultiMatch(e){return getMatch(e,this.multiRegex)}static isSingleMatch(e){return getMatch(e,this.singleRegex)}search(){}}function getMatch(e,t){const r=e.match(t);return r?r[1]:null}class ExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class InverseExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class PrefixExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class InversePrefixExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class SuffixExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class InverseSuffixExactMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class FuzzyMatch extends BaseMatch{constructor(e,{location:t=Config.location,threshold:r=Config.threshold,distance:n=Config.distance,includeMatches:i=Config.includeMatches,findAllMatches:s=Config.findAllMatches,minMatchCharLength:o=Config.minMatchCharLength,isCaseSensitive:c=Config.isCaseSensitive,ignoreLocation:a=Config.ignoreLocation}={}){super(e),this._bitapSearch=new BitapSearch(e,{location:t,threshold:r,distance:n,includeMatches:i,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:c,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class IncludeMatch extends BaseMatch{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,r=0;const n=[],i=this.pattern.length;for(;(t=e.indexOf(this.pattern,r))>-1;)r=t+i,n.push([t,r-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const searchers=[ExactMatch,IncludeMatch,PrefixExactMatch,InversePrefixExactMatch,InverseSuffixExactMatch,SuffixExactMatch,InverseExactMatch,FuzzyMatch],searchersLen=searchers.length,SPACE_RE=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,OR_TOKEN="|";function parseQuery(e,t={}){return e.split("|").map((e=>{let r=e.trim().split(SPACE_RE).filter((e=>e&&!!e.trim())),n=[];for(let e=0,i=r.length;e<i;e+=1){const i=r[e];let s=!1,o=-1;for(;!s&&++o<searchersLen;){const e=searchers[o];let r=e.isMultiMatch(i);r&&(n.push(new e(r,t)),s=!0)}if(!s)for(o=-1;++o<searchersLen;){const e=searchers[o];let r=e.isSingleMatch(i);if(r){n.push(new e(r,t));break}}}return n}))}const MultiMatchSet=new Set([FuzzyMatch.type,IncludeMatch.type]);class ExtendedSearch{constructor(e,{isCaseSensitive:t=Config.isCaseSensitive,includeMatches:r=Config.includeMatches,minMatchCharLength:n=Config.minMatchCharLength,ignoreLocation:i=Config.ignoreLocation,findAllMatches:s=Config.findAllMatches,location:o=Config.location,threshold:c=Config.threshold,distance:a=Config.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:r,minMatchCharLength:n,findAllMatches:s,ignoreLocation:i,location:o,threshold:c,distance:a},this.pattern=t?e:e.toLowerCase(),this.query=parseQuery(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:n}=this.options;e=n?e:e.toLowerCase();let i=0,s=[],o=0;for(let n=0,c=t.length;n<c;n+=1){const c=t[n];s.length=0,i=0;for(let t=0,n=c.length;t<n;t+=1){const n=c[t],{isMatch:a,indices:h,score:l}=n.search(e);if(!a){o=0,i=0,s.length=0;break}if(i+=1,o+=l,r){const e=n.constructor.type;MultiMatchSet.has(e)?s=[...s,...h]:s.push(h)}}if(i){let e={isMatch:!0,score:o/i};return r&&(e.indices=s),e}}return{isMatch:!1,score:1}}}const registeredSearchers=[];function register(...e){registeredSearchers.push(...e)}function createSearcher(e,t){for(let r=0,n=registeredSearchers.length;r<n;r+=1){let n=registeredSearchers[r];if(n.condition(e,t))return new n(e,t)}return new BitapSearch(e,t)}const LogicalOperator={AND:"$and",OR:"$or"},KeyType={PATH:"$path",PATTERN:"$val"},isExpression=e=>!(!e[LogicalOperator.AND]&&!e[LogicalOperator.OR]),isPath=e=>!!e[KeyType.PATH],isLeaf=e=>!isArray(e)&&isObject(e)&&!isExpression(e),convertToExplicit=e=>({[LogicalOperator.AND]:Object.keys(e).map((t=>({[t]:e[t]})))});function parse(e,t,{auto:r=!0}={}){const n=e=>{let i=Object.keys(e);const s=isPath(e);if(!s&&i.length>1&&!isExpression(e))return n(convertToExplicit(e));if(isLeaf(e)){const n=s?e[KeyType.PATH]:i[0],o=s?e[KeyType.PATTERN]:e[n];if(!isString(o))throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(n));const c={keyId:createKeyId(n),pattern:o};return r&&(c.searcher=createSearcher(o,t)),c}let o={children:[],operator:i[0]};return i.forEach((t=>{const r=e[t];isArray(r)&&r.forEach((e=>{o.children.push(n(e))}))})),o};return isExpression(e)||(e=convertToExplicit(e)),n(e)}function computeScore(e,{ignoreFieldNorm:t=Config.ignoreFieldNorm}){e.forEach((e=>{let r=1;e.matches.forEach((({key:e,norm:n,score:i})=>{const s=e?e.weight:null;r*=Math.pow(0===i&&s?Number.EPSILON:i,(s||1)*(t?1:n))})),e.score=r}))}function transformMatches(e,t){const r=e.matches;t.matches=[],isDefined(r)&&r.forEach((e=>{if(!isDefined(e.indices)||!e.indices.length)return;const{indices:r,value:n}=e;let i={indices:r,value:n};e.key&&(i.key=e.key.src),e.idx>-1&&(i.refIndex=e.idx),t.matches.push(i)}))}function transformScore(e,t){t.score=e.score}function format(e,t,{includeMatches:r=Config.includeMatches,includeScore:n=Config.includeScore}={}){const i=[];return r&&i.push(transformMatches),n&&i.push(transformScore),e.map((e=>{const{idx:r}=e,n={item:t[r],refIndex:r};return i.length&&i.forEach((t=>{t(e,n)})),n}))}class Fuse{constructor(e,t={},r){this.options={...Config,...t},this.options.useExtendedSearch,this._keyStore=new KeyStore(this.options.keys),this.setCollection(e,r)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof FuseIndex))throw new Error(INCORRECT_INDEX_TYPE);this._myIndex=t||createIndex(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){isDefined(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let r=0,n=this._docs.length;r<n;r+=1){const i=this._docs[r];e(i,r)&&(this.removeAt(r),r-=1,n-=1,t.push(i))}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:r,includeScore:n,shouldSort:i,sortFn:s,ignoreFieldNorm:o}=this.options;let c=isString(e)?isString(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return computeScore(c,{ignoreFieldNorm:o}),i&&c.sort(s),isNumber(t)&&t>-1&&(c=c.slice(0,t)),format(c,this._docs,{includeMatches:r,includeScore:n})}_searchStringList(e){const t=createSearcher(e,this.options),{records:r}=this._myIndex,n=[];return r.forEach((({v:e,i:r,n:i})=>{if(!isDefined(e))return;const{isMatch:s,score:o,indices:c}=t.searchIn(e);s&&n.push({item:e,idx:r,matches:[{score:o,value:e,norm:i,indices:c}]})})),n}_searchLogical(e){const t=parse(e,this.options),r=(e,t,n)=>{if(!e.children){const{keyId:r,searcher:i}=e,s=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(t,r),searcher:i});return s&&s.length?[{idx:n,item:t,matches:s}]:[]}const i=[];for(let s=0,o=e.children.length;s<o;s+=1){const o=e.children[s],c=r(o,t,n);if(c.length)i.push(...c);else if(e.operator===LogicalOperator.AND)return[]}return i},n=this._myIndex.records,i={},s=[];return n.forEach((({$:e,i:n})=>{if(isDefined(e)){let o=r(t,e,n);o.length&&(i[n]||(i[n]={idx:n,item:e,matches:[]},s.push(i[n])),o.forEach((({matches:e})=>{i[n].matches.push(...e)})))}})),s}_searchObjectList(e){const t=createSearcher(e,this.options),{keys:r,records:n}=this._myIndex,i=[];return n.forEach((({$:e,i:n})=>{if(!isDefined(e))return;let s=[];r.forEach(((r,n)=>{s.push(...this._findMatches({key:r,value:e[n],searcher:t}))})),s.length&&i.push({idx:n,item:e,matches:s})})),i}_findMatches({key:e,value:t,searcher:r}){if(!isDefined(t))return[];let n=[];if(isArray(t))t.forEach((({v:t,i:i,n:s})=>{if(!isDefined(t))return;const{isMatch:o,score:c,indices:a}=r.searchIn(t);o&&n.push({score:c,key:e,value:t,idx:i,norm:s,indices:a})}));else{const{v:i,n:s}=t,{isMatch:o,score:c,indices:a}=r.searchIn(i);o&&n.push({score:c,key:e,value:i,norm:s,indices:a})}return n}}function isHLS(e){return"string"==typeof e&&e.includes(".m3u8")}function getParents(e){for(var t=[];e.parentNode&&"body"!=e.parentNode.nodeName.toLowerCase();)e=e.parentNode,t.push(e);return t}function setAttributes(e,t){is.element(e)&&!is.empty(t)&&Object.entries(t).filter((([,e])=>!is.nullOrUndefined(e))).forEach((([t,r])=>e.setAttribute(t,r)))}function createElement(e,t,r){const n=document.createElement(e);return is.object(t)&&setAttributes(n,t),is.string(r)&&(n.innerText=r),n}Fuse.version="6.6.2",Fuse.createIndex=createIndex,Fuse.parseIndex=parseIndex,Fuse.config=Config,Fuse.parseQuery=parse,register(ExtendedSearch);const vttToJson=e=>e?["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce(((t,r)=>(e[r]&&(t[r]=e[r]),t)),{cues:e.cues&&Array.prototype.map.call(e.cues,(function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}}))}):null,fuzzySearch=(e,t,r)=>{if(is.empty(t))return[];if(is.empty(r))return[];if(!is.string(e))return[];const n=Object.assign(Object.assign(Object.assign({},null==r?void 0:r.minMatchCharLength),null==r?void 0:r.threshold),{shouldSort:!1,includeMatches:!0,threshold:.3,keys:["text"]});return null!==t&&t&&0!==t.length?new Fuse(t,n).search(e):[]},searchInJson=(e,t,r)=>{if(!is.string(e))return[];if(is.empty(t))return[];if(is.empty(r))return[];const n=fuzzySearch(e,t,r);return n&&Array.prototype.map.call(n,(function(e){return{time:Math.ceil(e.item.startTime),label:""}}))};function searchVtt(e,t){var r,n,i,s;if(!e)return;if(!(null===(r=null==e?void 0:e.media)||void 0===r?void 0:r.textTracks)||0===(null===(i=null===(n=null==e?void 0:e.media)||void 0===n?void 0:n.textTracks)||void 0===i?void 0:i.length))return;const o=e.media.textTracks,c=(null===(s=e.config.preset)||void 0===s?void 0:s.search)||"";let a="";if(a=-1===e.captions.currentTrack?getCues(e):o[e.captions.currentTrack],is.empty(a))return[];const h=vttToJson(a);return is.empty(h)?[]:searchInJson(t,null==h?void 0:h.cues,c)}function removeOldMarkers(e){var t;if(!e)return;if(!(null==e?void 0:e.elements)||!(null===(t=null==e?void 0:e.elements)||void 0===t?void 0:t.progress))return;let r=e.elements.progress.querySelectorAll(".plyr__progress__marker");if(!is.empty(r))for(var n=0;n<r.length;n++)r[n].remove()}function setMarkers(e,t){if(!e)return;if(removeOldMarkers(e),!(null==t?void 0:t.length))return;const r=document.createDocumentFragment(),n=document.createDocumentFragment();t.forEach((t=>{const r=createElement("span",{class:"plyr__progress__marker"},""),i=t.time/e.duration*100+"%";r.addEventListener("click",(()=>{e.currentTime=t.time})),r.style.left=i,n.appendChild(r)})),r.appendChild(n),e.elements.markers={points:n,tip:null},e.elements.progress.appendChild(r)}function cacheCues(e){var t,r,n,i,s,o;if(!(null===(r=null===(t=null==e?void 0:e.config.preset)||void 0===t?void 0:t.search)||void 0===r?void 0:r.enabled))return;if(!(null===(i=null===(n=null==e?void 0:e.media)||void 0===n?void 0:n.textTracks)||void 0===i?void 0:i.length)||0===(null===(o=null===(s=null==e?void 0:e.media)||void 0===s?void 0:s.textTracks)||void 0===o?void 0:o.length))return;if(-1!==(null==e?void 0:e.currentTrack))return;e.toggleCaptions(!0);let c=setInterval((()=>{var t;const r=null===(t=e.media.textTracks[0])||void 0===t?void 0:t.cues;(null==r?void 0:r.length)>0&&(setCues(e),e.toggleCaptions(!1),clearInterval(c))}),200)}function getCues(e){if(!e)return;const t=localStorage.getItem("presto-player-"+e.id+"-cues");return is.empty(t)?"":JSON.parse(t)}function setCues(e){var t,r,n,i,s;if(!e||!(null===(t=null==e?void 0:e.media)||void 0===t?void 0:t.textTracks)||0===(null===(n=null===(r=null==e?void 0:e.media)||void 0===r?void 0:r.textTracks)||void 0===n?void 0:n.length))return;const o=(null===(s=null===(i=null==e?void 0:e.media)||void 0===i?void 0:i.textTracks)||void 0===s?void 0:s[0])?vttToJson(e.media.textTracks[0]):{};is.empty(o)||localStorage.setItem("presto-player-"+e.id+"-cues",JSON.stringify(o))}const PrestoSearchBar=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.value=void 0,this.player=void 0,this.markers=void 0,this.currentMarkerLocation=-1}onSearch(e){if(this.value=e.detail,""===this.value)removeOldMarkers(this.player),this.markers=[];else{const e=searchVtt(this.player,this.value);this.player.config.markers={enabled:!0,points:e},this.markers=e,setMarkers(this.player,e)}}onPreviousNav(){this.currentMarkerLocation-1<0?this.currentMarkerLocation=this.markers.length-1:this.currentMarkerLocation--,this.player.currentTime=this.markers[this.currentMarkerLocation].time}onFocusChange(e){var t,r;!0===(null==e?void 0:e.detail)?this.player.config.hideControls=!1:this.player.config.hideControls=(null===(r=null===(t=this.player.config)||void 0===t?void 0:t.preset)||void 0===r?void 0:r.auto_hide)||!1}onNextNav(){this.currentMarkerLocation+1>this.markers.length-1?this.currentMarkerLocation=0:this.currentMarkerLocation++,this.player.currentTime=this.markers[this.currentMarkerLocation].time}render(){var e,t,r,n,i,s,o,c;if(!this.player)return"";if(!(null===(r=null===(t=null===(e=this.player)||void 0===e?void 0:e.media)||void 0===t?void 0:t.textTracks)||void 0===r?void 0:r.length)||0===(null===(s=null===(i=null===(n=this.player)||void 0===n?void 0:n.media)||void 0===i?void 0:i.textTracks)||void 0===s?void 0:s.length))return"";const a=null===(o=this.player.config.preset.search)||void 0===o?void 0:o.placeholder;return h("presto-search-bar-ui",{value:this.value,hasNavigation:(null===(c=this.markers)||void 0===c?void 0:c.length)>1,placeholder:a,onNextNav:()=>this.onNextNav(),onPreviousNav:()=>this.onPreviousNav(),onSearch:e=>this.onSearch(e),onFocusChange:e=>this.onFocusChange(e)})}},[0,"presto-search-bar",{value:[1],player:[8],markers:[32],currentMarkerLocation:[32]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["presto-search-bar","presto-search-bar-ui"].forEach((e=>{switch(e){case"presto-search-bar":customElements.get(e)||customElements.define(e,PrestoSearchBar);break;case"presto-search-bar-ui":customElements.get(e)||defineCustomElement$1()}}))}export{PrestoSearchBar as P,cacheCues as c,defineCustomElement as d,getParents as g,isHLS as i};