@arbetsformedlingen/yrkesvaljaren 2.2.0 → 2.3.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/README.md +20 -2
- package/dist/cjs/digi-service-job-selector.cjs.entry.js +85 -35
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/{types-DdzCbiye.js → types-B3W1Y40Q.js} +5 -4
- package/dist/collection/components/job-selector/job-selector-controller.js +20 -6
- package/dist/collection/components/job-selector/job-selector.js +66 -30
- package/dist/collection/components/job-selector/logic/adapter.utils.js +5 -4
- package/dist/components/digi-service-job-selector.js +1 -1
- package/dist/components/types.js +1 -1
- package/dist/esm/digi-service-job-selector.entry.js +85 -35
- package/dist/esm/index.js +2 -2
- package/dist/esm/{types-DVos4HHS.js → types-D9zmn-JR.js} +5 -4
- package/dist/types/components/job-selector/job-selector-controller.d.ts +10 -1
- package/dist/types/components/job-selector/job-selector.d.ts +3 -0
- package/dist/types/components/job-selector/logic/adapter.utils.d.ts +1 -1
- package/dist/types/components/job-selector/types.d.ts +17 -2
- package/dist/types/components.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/yrkesvaljaren/index.esm.js +1 -1
- package/dist/yrkesvaljaren/{p-DVos4HHS.js → p-D9zmn-JR.js} +1 -1
- package/dist/yrkesvaljaren/p-c2eb633a.entry.js +1 -0
- package/dist/yrkesvaljaren/yrkesvaljaren.esm.js +1 -1
- package/package.json +1 -1
- package/dist/yrkesvaljaren/p-0f19a308.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as a,Fragment as r}from"@stencil/core/internal/client";import{l as o,g as n,T as l,D as c,s as h,i as d,L as u,M as g,a as p,b as m,P as v,c as f,I as b,r as y,d as k}from"./types.js";import{d as w,A as S}from"./core-selector2.js";function x(t){return t.replace(/\b(?:(?:19|20)\d{2}|\d{2})(?:0[1-9]|1[0-2])(?:0[1-9]|[1-2][0-9]|3[0-1]|6[1-9]|[7-8][0-9]|9[0-1]) ?[-+]? ?\d{4}\b/g,"[personnummer]")}function C(t){return t.replace(/(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}._%+-]+@(?:[\p{L}\p{N}-]+\.)+\p{L}{2,}(?![\p{L}\p{N}])/gu,"[e-post]")}function I(t){let e=t.replace(/(?:\+46|\b0046|\b46)[ .-]*(?:\(0\)[ .-]*)?[1-9](?:[ ./-]*\d){6,9}\b/g,"[telefonnummer]");return e=e.replace(/\(0\d{1,3}\)[ .-]*\d(?:[ ./-]*\d){4,7}\b/g,"[telefonnummer]"),e=e.replace(/\b(?!\d{1,2}[./]\d{1,2}[./]\d{2,4}\b)0[1-9](?:[ ./-]*\d){6,9}\b/g,"[telefonnummer]"),e}function L(t){return t.replace(/\bSE ?\d{2}(?: ?\d{4}){5}\b/gi,"[kontonummer]")}function H(t){return t.normalize("NFKC").replace(/[\u00AD\u200B-\u200D\u2060\uFEFF]/g,"").replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g,"-").replace(/\s+/g," ").trim()}function V(t){const e=H(t);let i=C(e);return i=L(i),i=x(i),i=I(i),i!==e}function E(t,e=160){if(!t||"string"!=typeof t)return"";let i=H(t);return 0===i.length?"":(i=function(t){return t.replace(/\b(?:https?:\/\/|www\.)\S+/gi,"[url]").replace(/\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:se|com|nu|org|net|io|eu|info)\/\S*/g,"[url]")}(i),i=C(i),i=L(i),i=x(i),i=I(i),i=function(t){return t.replace(/(?<![\p{L}\p{N}])(?!\d{4}-\d{2}-\d{2}(?!\p{N})|\d{1,2}[./]\d{1,2}[./]\d{2,4}(?!\p{N}))\d(?:[ .-]?\d){7,}(?![\p{N}])/gu,"[nummer]")}(i),i=function(t){const e="gatan|vägen|gränd|stigen|allén|torget|gata",i=RegExp(`(?<![\\p{L}\\p{N}_])(?:\\p{L}+(?:${e})|\\p{L}+\\s+(?:${e}))\\s+\\d{1,4}(?:\\s?[A-Za-z])?(?![\\p{L}\\p{N}_])`,"giu");return t.replace(i,"[adress]").replace(/\b\d{3} ?\d{2}\s+(?!(?:[Kk]r|[Kk]ronor|SEK|[Ee]uro|[Tt]immar|[Ss]tycken|[Ss]t)(?![\p{L}]))[A-ZÅÄÖ]\p{Ll}+/gu,"[postadress]")}(i),i=function(t){const e="[A-ZÅÄÖÉ]\\p{Ll}+(?:-[A-ZÅÄÖÉ]\\p{Ll}+)?",i=RegExp(`(?<![\\p{L}\\p{N}_])((?:[Jj]ag\\s+heter|[Mm]itt\\s+(?:för|efter)?namn\\s+(?:är|e)|[Mm]vh|[Hh]älsningar|[Vv]änliga\\s+hälsningar|[Mm]ed\\s+vänlig\\s+hälsning)[,:]?\\s+)${e}(?:\\s+${e})?(?![\\p{L}\\p{N}_])`,"gu");return t.replace(i,((t,e)=>e+"[namn]"))}(i),i=i.replace(/\s+/g," ").trim(),i.length>e&&(i=i.slice(0,e).trim()),i)}function _(t){return E(t,120)}function D(t){return E(t,160)}let z=null;const M={saveHistory(t){z=t;try{localStorage.setItem("job-selector_history",JSON.stringify(t)),o.debug("[HistoryService] saveHistory - History saved.")}catch(t){o.error("Kunde inte spara historik.",t)}},loadHistory(){if(z)return z;try{const t=localStorage.getItem("job-selector_history");if(t)return z=JSON.parse(t),z}catch(t){o.error("Kunde inte läsa historik.",t)}return z=[],z},clearHistory(){z=[];try{localStorage.removeItem("job-selector_history"),o.debug("[HistoryService] clearHistory - History cleared.")}catch(t){o.error("Kunde inte rensa historik.",t)}}};class j{callbacks;config;cappedResults;state={status:"loading"};taxonomyData=[];popularItems=[];searchEngine=null;debounceTimer;validationTimer;isTouched=!1;activeErrorType=null;constructor(t,e){this.callbacks=t,this.config=e}getState(){return this.state}getActiveErrorType(){return this.activeErrorType}updateConfig(t){this.config={...this.config,...t},void 0===t.required&&void 0===t.requireSelection||this.runValidation()}getTaxonomyData(){if(this.taxonomyData.length>0)return this.taxonomyData;const t=n();return t&&t.length>0&&(o.debug("[Controller] getTaxonomyData - Late initializing from registry"),this.taxonomyData=t,this.popularItems=this.computePopularItems(this.taxonomyData),this.searchEngine=new l(this.taxonomyData)),this.taxonomyData}destroy(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.validationTimer&&(clearTimeout(this.validationTimer),this.validationTimer=void 0)}async initialize(t){o.debug("[Controller] initialize - START",{hasInitialData:!!t}),this.updateState({status:"loading"});const e=t&&t.length>0?t:n();e&&e.length>0?(o.debug("[Controller] initialize - Loaded taxonomy from registry"),this.setStateToActive(e,"registry",(new Date).toISOString())):(o.warn("[Controller] initialize - No taxonomy found in registry. Has registerTaxonomy() been called?"),this.updateState({status:"error",message:"Kunde inte hitta yrkesdata. Kontrollera att komponenten är initierad korrekt."}))}handleFocus(){this.isTouched=!0}setStateToActive(t,e,i){this.taxonomyData=t,this.popularItems=this.computePopularItems(this.taxonomyData),this.searchEngine=new l(this.taxonomyData);const s={dataSource:e,dataSourceDate:i};this.updateState(this.config.enableMultiple?{status:"multiSelect",inputValue:"",selectedItems:[],suggestions:[],validation:"idle",...s}:{status:"searching",inputValue:"",suggestions:[],validation:"idle",...s})}handleInput(t){this.isTouched=!0,o.debug("[Controller] handleInput - Value:",t);const e="error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0;if(clearTimeout(this.debounceTimer),""===t.trim()){const t="itemSelected"===this.state.status;return this.updateState(this.config.enableMultiple?{status:"multiSelect",inputValue:"",selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],suggestions:[],validation:"idle",validationContext:e,...this.getCommonState()}:{status:"searching",inputValue:"",suggestions:[],validation:"idle",validationContext:e,...this.getCommonState()}),t&&this.callbacks.onEmitSelection([]),void this.showHistory()}switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":this.updateState({status:"multiSelect",inputValue:t,selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],suggestions:"suggestions"in this.state?this.state.suggestions:"historyItems"in this.state?this.state.historyItems:[],validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0});break;case"itemSelected":case"searching":case"showingHistory":this.updateState({status:"searching",inputValue:t,suggestions:"suggestions"in this.state?this.state.suggestions:"historyItems"in this.state?this.state.historyItems:[],validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0});break;case"loading":case"error":return;default:return this.state}t.length>=this.config.minLength&&(this.debounceTimer=setTimeout((()=>this.performSearch(t)),c))}performSearch(t){if(this.searchEngine)switch(this.state.status){case"searching":case"multiSelect":{const e=this.config.maxResults,i=this.searchEngine.searchAsGeneric(t,e+1),s=i.slice(0,e).flatMap((t=>t.metadata?.originalResult?[t.metadata.originalResult]:[]));this.cappedResults=i.length>e?s:void 0,this.updateState({...this.state,suggestions:s});break}case"loading":case"error":case"itemSelected":case"showingHistory":case"multiSelectShowingHistory":return;default:return this.state}}addToHistory(t){if(!this.config.history)return;const e=M.loadHistory(),i=u.format(t.rawLabel,"",t.occupationLabel),s={...t,displaySegments:i,highlightedLabel:h(i)},a=e.filter((t=>!d(t,s))),r=[s,...a].slice(0,this.config.maxHistoryItems);M.saveHistory(r)}clearHistory(){M.clearHistory(),this.showHistory(!0)}computePopularItems(t,e=this.config.maxResults||g){if(!t||0===t.length)return[];if(!t.some((t=>"number"==typeof t.weight&&t.weight>0)))return t.slice(0,e);const i=[...t].sort(((t,e)=>(e.weight??0)-(t.weight??0))),s=new Set,a=[];for(const t of i){const i=t.occupation_name_preferred_label||t.preferred_label;if(s.has(i)||(s.add(i),a.push(t)),a.length===e)break}return a}showHistory(t=!1){if("loading"===this.state.status||"error"===this.state.status)return;if(!this.config.history)return;const e=M.loadHistory();let i=e,s=!1;0===e.length&&(!1===this.config.popular?i=[]:(0===this.popularItems.length&&this.taxonomyData.length>0&&(this.popularItems=this.computePopularItems(this.taxonomyData)),i=this.popularItems.map((t=>this.toSearchResult(t))),s=!0));const a=i.filter((t=>"ManualInput"===t.type?!0===this.config.manualInput:this.taxonomyData.some((e=>e.id===t.id)))).map((t=>{const e=u.format(t.rawLabel,"",t.occupationLabel);return{...t,displaySegments:e,highlightedLabel:h(e)}})),{dataSource:r,dataSourceDate:o}=this.getCommonState(),n="inputValue"in this.state?this.state.inputValue:"";(t||""===n.trim()||"showingHistory"===this.state.status||"multiSelectShowingHistory"===this.state.status)&&this.updateState(this.config.enableMultiple?{status:"multiSelectShowingHistory",selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],historyItems:a,inputValue:n,validation:"validation"in this.state?this.state.validation:"idle",validationContext:"error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0,dataSource:r,dataSourceDate:o,isPopularView:s}:{status:"showingHistory",historyItems:a,inputValue:n,validation:"validation"in this.state?this.state.validation:"idle",validationContext:"error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0,dataSource:r,dataSourceDate:o,isPopularView:s})}selectItem(t){o.debug("[Controller] selectItem",t),this.isTouched=!0,this.addToHistory(t);const e="error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0;switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":{const i="dataSource"in this.state?this.state.dataSource:void 0,s="dataSourceDate"in this.state?this.state.dataSourceDate:void 0,a="selectedItems"in this.state?this.state.selectedItems:[];if(a.findIndex((e=>d(e,t)))>-1)return;const r=[...a,t];this.updateState({...this.state,status:"multiSelect",selectedItems:r,inputValue:"",suggestions:[],validation:"idle",validationContext:e,dataSource:i,dataSourceDate:s}),this.callbacks.onEmitSelection(r.map((t=>this.toPublicSelection(t)))),this.showHistory(!0);break}case"searching":case"showingHistory":this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}),this.callbacks.onEmitSelection(this.toPublicSelection(t)),this.config.enableMultiple&&this.showHistory(!0);break;case"loading":case"error":break;case"itemSelected":this.updateState({...this.state,status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}),this.callbacks.onEmitSelection(this.toPublicSelection(t));break;default:o.warn("[Controller] selectItem - Unexpected state:",this.state)}this.runValidation()}clearSelection(){"itemSelected"===this.state.status&&(this.isTouched=!0,this.updateState({status:"searching",inputValue:this.state.inputValue||"",suggestions:[],validation:"idle",...this.getCommonState()}),this.callbacks.onEmitSelection([]),this.showHistory(),this.runValidation())}removeItem(t){switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":{const e=this.state.selectedItems.filter((e=>!d(e,t)));this.isTouched=!0,this.updateState({...this.state,selectedItems:e}),this.callbacks.onEmitSelection(e.map((t=>this.toPublicSelection(t)))),""===("inputValue"in this.state?this.state.inputValue:"")&&this.showHistory(),this.runValidation();break}}}handleBlur(){if(this.isTouched=!0,"searching"===this.state.status){const t=(this.state.inputValue||"").trim();if(""!==t){const e=this.findExactMatch(t);if(e)return void this.selectItem(this.toSearchResult(e))}}switch(this.state.status){case"searching":case"showingHistory":this.updateState({...this.state,status:"searching",inputValue:"inputValue"in this.state?this.state.inputValue:"",suggestions:[]});break;case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,status:"multiSelect",inputValue:"inputValue"in this.state?this.state.inputValue:"",suggestions:[]});break;case"loading":case"error":case"itemSelected":break;default:return this.state}this.runValidation()}runValidation(t=!1){if(t&&(this.isTouched=!0),!this.isTouched)return!0;if("loading"===this.state.status||"error"===this.state.status)return!0;const e=this.checkHasValue();let i=!0,s=null;const a="searching"===this.state.status||"multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status,r=""!==("inputValue"in this.state?this.state.inputValue:"").trim();a&&r?(i=!1,s="invalidInput"):this.config.required&&!e&&(i=!1,s="required"),this.activeErrorType=s;const o="error"===this.state.validation||"from-error"===this.state.validationContext;let n;switch(n=i?o&&e?"success":"idle":"invalidInput"===s||t||o?"error":"idle","success"===n&&(clearTimeout(this.validationTimer),this.validationTimer=setTimeout((()=>{const t="validation"in this.state&&"success"===this.state.validation;["itemSelected","multiSelect","multiSelectShowingHistory"].includes(this.state.status)&&t&&this.updateState({...this.state,validation:"idle",validationContext:void 0}),this.validationTimer=void 0}),3e3)),this.state.status){case"searching":case"showingHistory":case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,validation:n});break;case"itemSelected":"error"!==n&&this.updateState({...this.state,validation:n});break;default:return this.state}return this.callbacks.onEmitValidation({isValid:i,errorType:s}),i}selectItemById(t){if(!t||this.config.enableMultiple||!this.taxonomyData)return;const e=this.taxonomyData.find((e=>e.id===t));if(e){const t=this.toSearchResult(e);this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0})}this.runValidation()}selectItemsByIds(t){if(!t||!this.config.enableMultiple||!this.taxonomyData)return;const e=t.map((t=>this.taxonomyData.find((e=>e.id===t))));if(e.some((t=>!t)))return;const i=e.filter((t=>!!t)).map((t=>this.toSearchResult(t)));switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,selectedItems:i})}this.runValidation()}setSelection(t){const e=[],i=t.map((t=>{if(null!==t.id){const i=this.taxonomyData.filter((e=>e.id===t.id));if(0===i.length)return void e.push(t.id);let s;return t.related?.id?(s=i.find((e=>e.occupation_name_id===t.related?.id)),s||1!==i.length||(s=i[0])):s=i[0],s?this.toSearchResult(s):void e.push(t.id)}return this.createManualInputItem(t.preferred_label)}));if(e.length>0)return{ok:!1,invalidIds:e};const s=i,a=this.getCommonState();if(this.config.enableMultiple)this.updateState({...this.state,status:"multiSelect",selectedItems:s,inputValue:"",suggestions:[],validation:"idle",...a});else if(1===s.length){const t=s[0];this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",...a})}else this.updateState({status:"searching",inputValue:"",suggestions:[],validation:"idle",...a});return this.runValidation(),{ok:!0,selection:s.map((t=>this.toPublicSelection(t)))}}editSelection(){const t=this.state.selectedItem;if("itemSelected"!==this.state.status||!t||!this.searchEngine)return;const e=t.displayLabel,{dataSource:i,dataSourceDate:s}=this.state,a=this.searchEngine.searchAsGeneric(e,this.config.maxResults).flatMap((t=>t.metadata?.originalResult?[t.metadata.originalResult]:[]));this.updateState({status:"searching",inputValue:e,suggestions:a,validation:"idle",dataSource:i,dataSourceDate:s})}checkHasValue(){switch(this.state.status){case"itemSelected":return!0;case"multiSelect":case"multiSelectShowingHistory":return this.state.selectedItems.length>0;case"searching":case"showingHistory":return!this.config.requireSelection&&""!==("inputValue"in this.state?this.state.inputValue:"").trim();case"loading":case"error":return!1;default:return this.state}}getCommonState(){return{dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}}resetMultiSelection(){const t=this.getCommonState();this.updateState({...this.state,status:"multiSelect",selectedItems:[],inputValue:"",suggestions:[],validation:"idle",...t}),this.callbacks.onEmitSelection([])}updateState(t){this.state=t,this.callbacks.onStateChange(t)}toSearchResult(t){return{...t,rawLabel:t.preferred_label,displayLabel:t.occupation_name_preferred_label?`${t.preferred_label} (${t.occupation_name_preferred_label})`:t.preferred_label,highlightedLabel:t.preferred_label,score:3,occupationLabel:t.occupation_name_preferred_label,occupationId:t.occupation_name_id,ssyk_level_4_id:t.ssyk_level_4_id,ssyk_code_2012:t.ssyk_code_2012}}toPublicSelection(t){return p.toPublicSelection(t)}createManualInputItem(t){return{id:"",type:"ManualInput",preferred_label:t,rawLabel:t,displayLabel:t,highlightedLabel:t,score:1}}findExactMatch(t){const e=t.trim().toLowerCase(),i=this.taxonomyData.find((t=>!!t.occupation_name_preferred_label&&`${t.preferred_label} (${t.occupation_name_preferred_label})`.toLowerCase()===e));if(i)return i;const s=this.taxonomyData.filter((t=>t.preferred_label.toLowerCase()===e));return 1===s.length?s[0]:void 0}handleFreeTextSelection(t){if(!t)return;this.isTouched=!0;const e=this.findExactMatch(t);this.selectItem(e?this.toSearchResult(e):this.createManualInputItem(t))}hasMoreResults(t){return!!this.cappedResults&&t===this.cappedResults}loadMore(){this.config.maxResults+=10;const t="inputValue"in this.state?this.state.inputValue:"";t&&this.performSearch(t)}resetSearch(){switch(this.state.status){case"searching":case"multiSelect":this.updateState({...this.state,inputValue:"",suggestions:[]}),this.showHistory(!0);break;case"showingHistory":case"multiSelectShowingHistory":this.updateState({...this.state,inputValue:""});break;case"itemSelected":this.clearSelection()}}}o.setLevel(o.levels.SILENT);const F=/^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{4}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}$/,T=e(class t extends i{get hostElement(){return this}internals;name="yrkesvaljaren";taxonomyUrl;placeholder=v;label="Välj yrke";disabled=!1;enableMultiple=!1;showSearchIcon=!0;errorMessage;labelDescription;required=!1;manualInput=!1;feedback=!1;afOnSubmitJobSuggestion;suggestionState=null;history=!0;popular=!0;maxHistoryItems=10;enableSelectionAnimation=!1;afFocused=!1;populateInputOnSelect=!1;maxVisibleRows;minLength=f;maxResults=20;shouldFocusSuggestionInput=!1;shouldFocusConfirmation=!1;timers=new Set;schedule(t,e){const i=setTimeout((()=>{this.timers.delete(i),t()}),e);this.timers.add(i)}get requireSelection(){return!(this.manualInput||this.feedback)}size="medium";constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.afOnSubmitJobSuggestion=s(this,"afOnSubmitJobSuggestion",7),this.afJobSelectedEmitter=s(this,"afJobSelected",7),this.dataLoadFailedEmitter=s(this,"afJobDataLoadFailed",7),this.validationChangeEmitter=s(this,"afJobValidationChange",7),this.internals=this.attachInternals(),o.debug("[JobSelector] Constructor - enableMultiple:",this.enableMultiple)}state={status:"loading"};activeErrorType=null;animatingItemId=null;animationTimer;cloneSelection(t){return t.map((t=>null===t.id?{...t}:{...t,related:t.related?{...t.related}:void 0}))}rebuildValidJobIds(){const t=this.controller?.getTaxonomyData?.()??this.taxonomyData??[];this.validJobIds=new Set(t.map((t=>t.id)).filter(Boolean))}validateSelectionCandidate(t){const e="string"==typeof t?[t]:Array.isArray(t)?t:null;if(!e)return{ok:!1,reason:"invalid-input"};const i=e.some((t=>"string"==typeof t)),s=e.some((t=>"object"==typeof t&&null!==t));if(i&&s||e.some((t=>"string"!=typeof t&&("object"!=typeof t||null===t))))return{ok:!1,reason:"invalid-input"};const a=[],r=[],o=[];for(const t of e){if("string"==typeof t){const e=t.trim();if(!e)return{ok:!1,reason:"invalid-input"};if(F.test(e))r.push(e),a.push({id:e});else{if(!this.manualInput)return{ok:!1,reason:"manual-input-disabled"};o.push(e),a.push({type:"manual-input",id:null,preferred_label:e})}continue}if(!t||"object"!=typeof t)return{ok:!1,reason:"invalid-input"};const e=t;if("string"==typeof e.id){const t=e.id.trim();if(!t||"job-title"!==e.type&&"occupation-name"!==e.type||"string"!=typeof e.preferred_label||!e.preferred_label.trim())return{ok:!1,reason:"invalid-input"};let i;if(void 0!==e.related){const t=e.related;if(!t||"occupation-name"!==t.type||"string"!=typeof t.id||!t.id.trim()||"string"!=typeof t.preferred_label||!t.preferred_label.trim())return{ok:!1,reason:"invalid-input"};i={type:"occupation-name",id:t.id.trim(),preferred_label:t.preferred_label.trim()}}r.push(t),a.push(i?{id:t,related:i}:{id:t})}else{if(null!==e.id||"manual-input"!==e.type)return{ok:!1,reason:"invalid-input"};{if("string"!=typeof e.preferred_label||!e.preferred_label.trim())return{ok:!1,reason:"invalid-input"};if(!this.manualInput)return{ok:!1,reason:"manual-input-disabled"};const t=e.preferred_label.trim();o.push(t),a.push({type:"manual-input",id:null,preferred_label:t})}}}if(!this.enableMultiple&&a.length>1)return{ok:!1,reason:"multiple-disabled"};if(new Set(r).size!==r.length)return{ok:!1,reason:"duplicate-taxonomy-id"};if(new Set(o).size!==o.length)return{ok:!1,reason:"duplicate-manual-label"};const n=r.filter((t=>!this.validJobIds.has(t)));return n.length>0?{ok:!1,reason:"unknown-id",invalidIds:n}:{ok:!0,selection:a}}describeSelectionRejection(t){switch(t.reason){case"invalid-input":return"setSelection accepterar en sträng, en homogen strängarray eller en array med fullständiga JobSelectionItem-objekt.";case"data-unavailable":return"setSelection kan inte användas eftersom yrkesdata inte kunde laddas.";case"duplicate-taxonomy-id":return"selection får inte innehålla dubbla taxonomi-id:n.";case"duplicate-manual-label":return"selection får inte innehålla dubbla manuella labels.";case"multiple-disabled":return'flera värden kräver af-enable-multiple="true".';case"manual-input-disabled":return'manual-val kräver af-manual-input="true".';case"unknown-id":return"okända Concept ID:n: "+t.invalidIds?.join(", ")}}errorCodeForRejection(t){switch(t){case"unknown-id":return"unknown-id";case"manual-input-disabled":return"manual-input-disabled";case"multiple-disabled":return"multiple-disabled";default:return"invalid-input"}}rejectSelection(t,e){const i=this.describeSelectionRejection(e);return console.error(`[Yrkesväljaren] Ogiltig selection: ${i} Värdet accepterades inte; senaste giltiga val behålls.`,{selection:t,previousSelection:this.lastAcceptedSelection}),this.activeErrorType="invalidInput",this.validationChangeEmitter.emit({isValid:!1,errorType:"invalidInput"}),this.updateValidity(!1),new b(i,this.errorCodeForRejection(e.reason),e.invalidIds)}syncAcceptedSelection(t){const e=this.cloneSelection(t);if(this.lastAcceptedSelection=e,"invalidInput"===this.activeErrorType){const t=e.length>0||!this.required,i=t?null:"required";this.activeErrorType=i,this.validationChangeEmitter.emit({isValid:t,errorType:i}),this.updateValidity(t)}}applySelection(t){if(!this.controller)throw this.rejectSelection(t,{ok:!1,reason:"data-unavailable"});const e=this.validateSelectionCandidate(t);if(!e.ok)throw this.rejectSelection(t,e);const i=this.controller.setSelection(e.selection);if(!i.ok)throw this.rejectSelection(t,{ok:!1,reason:"unknown-id",invalidIds:i.invalidIds});return this.syncAcceptedSelection(i.selection),this.cloneSelection(i.selection)}watchRequired(t){this.controller.updateConfig({required:t})}watchManualInputOrFeedback(){this.feedback||(this.suggestionState=null),this.controller.updateConfig({requireSelection:this.requireSelection,manualInput:this.manualInput})}watchHistory(t){this.controller.updateConfig({history:t})}watchPopular(t){this.controller.updateConfig({popular:t})}watchEnableMultiple(t){this.controller.updateConfig({enableMultiple:t})}watchDisabled(t){t&&(this.afFocused=!1)}watchTaxonomyData(t){this.controller&&t&&t.length>0&&this.controller.initialize(t).then((()=>{this.rebuildValidJobIds(),this.restoreAcceptedSelectionAfterDataUpdate()}))}taxonomyData=[];afJobSelectedEmitter;syncFormValue(){if(this.state)if(this.enableMultiple){const t="multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status?this.state.selectedItems:[],e=new FormData;t.forEach((t=>{e.append(this.name,t.id||t.rawLabel)})),this.internals.setFormValue(e)}else{const t="itemSelected"===this.state.status?this.state.selectedItem:null;this.internals.setFormValue(t?t.id||t.rawLabel:null)}}handleFormValidationSync(t){this.updateValidity(t.detail.isValid)}dataLoadFailedEmitter;validationChangeEmitter;static nextId=0;componentId="job-selector-"+t.nextId++;observer;controller;validJobIds=new Set;lastAcceptedSelection=[];restoreAcceptedSelectionAfterDataUpdate(){if(0===this.lastAcceptedSelection.length)return;const t=this.controller.setSelection(this.lastAcceptedSelection);t.ok?this.syncAcceptedSelection(t.selection):this.rejectSelection(this.lastAcceptedSelection,{ok:!1,reason:"unknown-id",invalidIds:t.invalidIds})}async componentWillLoad(){o.setLevel(o.levels.WARN);const t=n();if(!(this.taxonomyData&&this.taxonomyData.length>0||t&&t.length>0)){this.state={status:"loading"};try{const t=await async function({taxonomyUrl:t,fetcher:e=t=>fetch(t)}){const i=t??"https://d3hng02m5bee8m.cloudfront.net/yrkesvaljaren/latest.json";o.debug("[JobSelector] Hämtar yrkesdata från: "+i);const s=await e(i);if(!s.ok)throw Error(`Kunde inte ladda yrkesdata från ${i}: ${s.status} ${s.statusText}`);const a=await s.json();if(!m(a))throw Error("Yrkesdatan har ett ogiltigt format.");return a}({taxonomyUrl:this.taxonomyUrl});y(t),o.debug("[JobSelector] Data-laddning lyckades.")}catch(t){return o.error("[JobSelector] Fel vid data-laddning:",t),this.state={status:"error",message:"Kunde inte ladda yrkesdata."},void this.dataLoadFailedEmitter.emit({error:t instanceof Error?t:Error(t+"")})}}this.controller=new j({onStateChange:t=>{this.state={...t},this.syncFormValue()},onEmitSelection:t=>{const e=t?Array.isArray(t)?t:[t]:[];this.syncAcceptedSelection(e),this.afJobSelectedEmitter.emit(e)},onEmitValidation:t=>{this.activeErrorType=t.errorType,this.validationChangeEmitter.emit(t)},onEmitDataLoadFailed:t=>{this.dataLoadFailedEmitter.emit({error:t})},onEmitStatusChange:()=>{}},{enableMultiple:this.enableMultiple,required:this.required,requireSelection:this.requireSelection,manualInput:this.manualInput,history:this.history,popular:this.popular,maxHistoryItems:this.maxHistoryItems,minLength:this.minLength,maxResults:this.maxResults}),await this.controller.initialize(this.taxonomyData),this.taxonomyData=this.controller.getTaxonomyData(),this.rebuildValidJobIds(),"invalidInput"===this.activeErrorType?this.updateValidity(!1):this.required&&0===this.lastAcceptedSelection.length?this.internals.setValidity({customError:!0},this.errorMessage||"Välj ett yrke från listan."):this.internals.setValidity({})}componentDidLoad(){this.handleHashFocus()}componentDidRender(){if(this.shouldFocusSuggestionInput&&"form"===this.suggestionState?.status){this.shouldFocusSuggestionInput=!1;const t=this.hostElement.shadowRoot?.querySelector(`#${this.componentId}-suggestion-motivation-input`);t&&this.schedule((()=>t.focus()),50)}this.shouldFocusConfirmation&&"submitted"===this.suggestionState?.status&&(this.shouldFocusConfirmation=!1,this.hostElement.shadowRoot?.querySelector(".yv-suggestion-close-btn")?.focus())}disconnectedCallback(){this.observer&&this.observer.disconnect(),this.controller&&this.controller.destroy(),clearTimeout(this.animationTimer),this.animationTimer=void 0,this.timers.forEach((t=>clearTimeout(t))),this.timers.clear()}handleHashFocus(){const t=window.location.hash;if(!t)return;const e=t.substring(1),i=this.hostElement.getAttribute("id");i&&e===i&&(this.setFocus(),this.hostElement.scrollIntoView({behavior:"smooth",block:"center"}),history.replaceState(null,"",window.location.pathname+window.location.search))}trackedSelectedJobs(){return this.lastAcceptedSelection.flatMap((t=>"manual-input"!==t.type?[t]:V(t.preferred_label)?[]:[{...t,preferred_label:_(t.preferred_label)}]))}emitJobSuggestion(t,e){const i={selectedJobs:this.trackedSelectedJobs(),suggestionJob:_(t),suggestionMotivation:D(e)};this.afOnSubmitJobSuggestion.emit(i)}closeSuggestion(){this.suggestionState=null,this.shouldFocusSuggestionInput=!1,this.setFocus()}submitSuggestion(){if(!this.suggestionState||!this.feedback)return;const{term:t,motivation:e}=this.suggestionState;if(V(e||""))return this.suggestionState={...this.suggestionState,piiError:!0},void(this.shouldFocusSuggestionInput=!0);this.emitJobSuggestion(t,e),this.shouldFocusSuggestionInput=!1,this.shouldFocusConfirmation=!0,this.suggestionState={status:"submitted",term:(t||"").trim(),motivation:""}}handleInput(t){this.afFocused=!0,"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.handleInput(t.detail)}handleCsSelect(t){this.afFocused=!0;const e=t.detail;this.enableSelectionAnimation&&(this.animatingItemId=e.id,clearTimeout(this.animationTimer),this.animationTimer=setTimeout((()=>{this.animatingItemId=null,this.animationTimer=void 0}),600));const i=e.metadata?.original;if(i&&"displayLabel"in i)"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.selectItem(i);else{if("ManualInput"===e.metadata?.type){const t=e.label;return this.feedback&&V(t)?void(this.suggestionState={status:"pii-blocked",term:"",motivation:""}):(this.manualInput&&this.controller.handleFreeTextSelection(t),this.feedback?(this.afFocused=!1,this.shouldFocusSuggestionInput=!0,this.suggestionState={status:"form",term:t,motivation:""},void(this.manualInput||this.controller.resetSearch())):void 0)}this.controller.selectItem({id:e.id,type:"unknown",preferred_label:e.label,rawLabel:e.label,displayLabel:e.label,highlightedLabel:e.highlightedLabel||e.label,score:1})}}handleCsClear(){"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.resetSearch()}handleCsClearHistory(){this.controller.clearHistory()}handleCsRequestHistory(){this.controller.showHistory()}handleCsLoadMore(){this.controller.loadMore()}handleCsRemoveItem(t){const e=t.detail,i=e.metadata?.original;i&&"displayLabel"in i&&this.controller.removeItem(i)}handleCsFocus(){this.afFocused=!0,this.controller.handleFocus()}handleCsBlur(){this.afFocused=!1,this.controller.handleBlur(),this.validate()}handleCsEditSelection(){this.afFocused=!0,this.controller.editSelection()}async updateData(){o.debug("[JobSelector] updateData called"),await this.controller.initialize(),this.taxonomyData=this.controller.getTaxonomyData(),this.rebuildValidJobIds(),this.restoreAcceptedSelectionAfterDataUpdate()}async setSelection(t){return this.applySelection(t)}async setFocus(){const t=this.hostElement.shadowRoot?.querySelector("core-selector");t&&"function"==typeof t.setFocus&&await t.setFocus()}async validate(t=!1){const e=await this.controller.runValidation(t);return this.updateValidity(e),e}async checkValidity(){return this.internals.checkValidity()}async reportValidity(){return this.internals.reportValidity()}async getValidity(){return this.internals.validity}async getValidationMessage(){return this.internals.validationMessage}updateValidity(t){t?this.internals.setValidity({}):this.internals.setValidity({customError:!0},"invalidInput"===this.activeErrorType?this.errorMessage||"Komponenten har fått ett ogiltigt värde.":this.errorMessage||"Välj ett yrke från listan.")}_mapSearchResultToGenericItem(t){const e=this.enableMultiple?("multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status)&&this.state.selectedItems.some((e=>d(e,t))):"itemSelected"===this.state.status&&!!this.state.selectedItem&&d(this.state.selectedItem,t);return{id:t.id,label:t.displayLabel,isSelected:this.animatingItemId===t.id||e,highlightedLabel:t.highlightedLabel,displaySegments:t.displaySegments,group:"occupation-name"===t.type?"Yrkesgrupper":"Yrkesbenämningar",metadata:{original:t}}}_mapStateToSelectorState(t){let e,i,s,a,r,o="loading",n="",l=[],c=[],h="idle",u=this.errorMessage||"";switch("validation"in t&&t.validation&&(h=t.validation,"error"===t.validation?"required"===this.activeErrorType||"invalidInput"===this.activeErrorType?u=this.errorMessage||"Välj ett yrke från listan.":this.errorMessage&&(u=this.errorMessage):"success"===t.validation&&(u="Tack!")),"message"in t&&t.message&&(u=t.message),"validationContext"in t&&(s=t.validationContext),t.status){case"loading":o="loading";break;case"error":o="error";break;case"searching":o="searching",n=t.inputValue,l=t.suggestions.map((t=>this._mapSearchResultToGenericItem(t))),e=this.controller?.hasMoreResults(t.suggestions);break;case"showingHistory":o="searching",n=t.inputValue||"",l=t.historyItems.map((t=>this._mapSearchResultToGenericItem(t)));break;case"itemSelected":o="itemSelected",i=this._mapSearchResultToGenericItem(t.selectedItem),i.highlightedLabel=k(i.label),n=t.inputValue||"";break;case"multiSelect":o="multiSelect",n=t.inputValue,l=t.suggestions.map((t=>this._mapSearchResultToGenericItem(t))),c=t.selectedItems.map((t=>this._mapSearchResultToGenericItem(t))),e=this.controller?.hasMoreResults(t.suggestions);break;case"multiSelectShowingHistory":o="multiSelect",n=t.inputValue||"",l=t.historyItems.map((t=>this._mapSearchResultToGenericItem(t))),c=t.selectedItems.map((t=>this._mapSearchResultToGenericItem(t)))}const g="showingHistory"===t.status||"multiSelectShowingHistory"===t.status;return"multiSelect"===o||"itemSelected"===o||"searching"===o?(c.length>0&&(l=l.filter((t=>!c.some((e=>{const i=e.metadata?.original,s=t.metadata?.original;return i&&s&&"rawLabel"in i&&"rawLabel"in s?d(i,s):e.id&&t.id?e.id===t.id:e.label===t.label}))))),g&&l.length>0?t.isPopularView?(a="Populära sökningar",r=!1):(r=!0,a=void 0):(a=void 0,r=!1)):(a=void 0,r=!1),"pii-blocked"===this.suggestionState?.status&&(h="error",u="Texten verkar innehålla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Skriv bara yrket du vill föreslå."),{status:o,inputValue:n,suggestions:l,selectedItem:i,selectedItems:c,validation:h,validationContext:s,message:u,listHeader:a,showHistoryHeader:r,isHistoryView:g,manualInputBlocked:"pii-blocked"===this.suggestionState?.status,hasMoreResults:e}}render(){const t=this._mapStateToSelectorState(this.state),e={disabled:this.disabled,placeholder:this.placeholder,minLength:this.minLength,maxResults:this.maxResults,enableMultiple:this.enableMultiple,showSearchIcon:this.showSearchIcon,requireSelection:this.requireSelection,size:this.size,enableSelectionAnimation:this.enableSelectionAnimation,populateInputOnSelect:this.populateInputOnSelect,maxVisibleRows:this.maxVisibleRows,manualInputBehavior:"select",showHistoryHeader:this.history&&!t.listHeader,listHeader:t.listHeader,enableInfiniteScroll:!0,isFeedback:this.feedback,manualInputMode:this.manualInput&&this.feedback?"combined":this.feedback?"feedback":"manual",feedbackTargetName:"yrke"};return a("div",{key:"12dea63f349ce625d4ea7041533dd328391532c2",class:"job-selector-wrapper"},"error"===this.state.status?a("div",{class:"error-message"},a(S,{variant:"error",role:"alert"},this.state.message||"Ett fel uppstod.")):a(r,null,a("core-selector",{id:this.componentId,componentId:this.componentId,state:t,config:e,label:this.label,labelDescription:this.labelDescription,size:this.size,afFocused:this.afFocused}),this.suggestionState&&"pii-blocked"!==this.suggestionState.status&&a("div",{key:"yv-suggestion-box",class:"yv-suggestion-box",role:"region","aria-label":"Föreslå saknat yrke"},"form"===this.suggestionState.status?a("div",{class:"yv-suggestion-form"},a("div",{class:"yv-suggestion-title",id:this.componentId+"-suggestion-title"},'Motivera varför "',a("strong",null,this.suggestionState.term),'" bör läggas till som yrke (frivilligt):'),a("div",{class:"yv-motivation-container"},a("div",{class:"yv-motivation-field-wrapper"},a("textarea",{id:this.componentId+"-suggestion-motivation-input","aria-labelledby":this.componentId+"-suggestion-title","aria-describedby":this.suggestionState.piiError?`${this.componentId}-motivation-pii-error ${this.componentId}-motivation-counter`:this.componentId+"-motivation-counter","aria-invalid":this.suggestionState.piiError?"true":"false",class:"yv-motivation-input",value:this.suggestionState.motivation,maxLength:160,rows:2,ref:t=>{t&&(t.style.height="auto",t.style.height=Math.max(t.scrollHeight,44)+"px")},onInput:t=>{const e=t.target;e.style.height="auto",e.style.height=Math.max(e.scrollHeight,44)+"px",this.suggestionState&&(this.suggestionState={...this.suggestionState,motivation:e.value,piiError:!1})}}),a("div",{id:this.componentId+"-motivation-counter",class:"yv-motivation-counter"},(this.suggestionState.motivation||"").length,"/160")),this.suggestionState.piiError&&a("div",{id:this.componentId+"-motivation-pii-error",class:"yv-suggestion-pii-error",role:"alert"},"Motiveringen verkar innehålla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Ta bort dem för att kunna skicka."),a("div",{class:"yv-suggestion-actions"},a("button",{type:"button",class:"yv-suggestion-submit-btn","aria-label":`Skicka förslag för "${this.suggestionState.term}" till Arbetsförmedlingen`,onClick:()=>this.submitSuggestion()},"Skicka"),a("button",{type:"button",class:"yv-suggestion-cancel-btn","aria-label":"Avbryt förslag",onClick:()=>this.closeSuggestion()},"Avbryt")))):"submitted"===this.suggestionState.status?a("div",{class:"yv-suggestion-success"},a("span",null,'Förslaget "',a("strong",null,this.suggestionState.term),'" har skickats in till Arbetsförmedlingen.'),a("button",{type:"button",class:"yv-suggestion-close-btn","aria-label":"Stäng bekräftelse",onClick:()=>this.closeSuggestion()},"Stäng")):null),a("div",{key:"yv-suggestion-live-region",class:"yv-sr-only",role:"status","aria-live":"polite"},"submitted"===this.suggestionState?.status?`Förslaget "${this.suggestionState.term}" har skickats in till Arbetsförmedlingen.`:"")))}static get delegatesFocus(){return!0}static get formAssociated(){return!0}static get watchers(){return{required:[{watchRequired:0}],manualInput:[{watchManualInputOrFeedback:0}],feedback:[{watchManualInputOrFeedback:0}],history:[{watchHistory:0}],popular:[{watchPopular:0}],enableMultiple:[{watchEnableMultiple:0}],disabled:[{watchDisabled:0}],taxonomyData:[{watchTaxonomyData:0}]}}static get style(){return":host{--digi--grayscale-0:#ffffff;--digi--grayscale-50:#fbfbfb;--digi--grayscale-100:#f4f4f4;--digi--grayscale-200:#ededed;--digi--grayscale-300:#e4e4e4;--digi--grayscale-400:#dddddd;--digi--grayscale-500:#cacaca;--digi--grayscale-600:#acacac;--digi--grayscale-700:#757575;--digi--grayscale-800:#5c5c5c;--digi--grayscale-900:#333333;--digi--grayscale-1000:#000000;--digi--global--color--cta--link--base:#1616b2;--digi--global--color--function--danger--base:#da0000;--digi--global--color--function--success--base:#008a20;--digi--global--color--function--success--lightest-3:#d4edda;--digi--global--color--function--warning--base:#ffe200;--af-text-color:var(--digi--color--text--primary, var(--digi--grayscale-900));--digi--global--typography--font-family--default:\"Open Sans\", Arial, sans-serif;--digi--global--typography--font-size--base:1rem;--digi--global--typography--font-size--small:0.875rem;--digi--global--typography--font-weight--regular:400;--digi--global--typography--font-weight--semibold:600;--digi--global--typography--font-weight--bold:700;--digi--global--typography--line-height--base:1.5;--digi--typography--label--font-size--desktop:1rem;--digi--typography--label--font-weight--desktop:600;--digi--typography--label--line-height--desktop:1.5;--digi--typography--label-description--font-size--desktop:1rem;--digi--typography--label-description--line-height--desktop:1.5;--digi--typography--tag--font-size--desktop:0.875rem;--digi--gutter--icon:0.625rem;--digi--gutter--smaller:0.75rem;--digi--gutter--small:0.875rem;--digi--gutter--medium:1rem;--digi--border-width--primary:1px;--digi--border-style--primary:solid;--digi--border-radius--primary:0;--digi--border-radius--secondary:6px;--af-tag-color:var(--digi--color--text--interactive--brand-primary, #091d54);--af-tag-background:var(--digi--color--background--interactive--default--secondary, var(--digi--grayscale-0));--af-tag-hover-background:var(--digi--color--background--interactive--hover--secondary, #ddf1fc)}.af-form-label{color:var(--af-text-color);display:flex;flex-direction:column;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--label--font-size--desktop);margin-bottom:0.5rem}.af-form-label__label{cursor:pointer;display:block;font-weight:var(--digi--typography--label--font-weight--desktop);line-height:var(--digi--typography--label--line-height--desktop)}.af-form-label__description{display:block;font-size:var(--digi--typography--label-description--font-size--desktop);line-height:var(--digi--typography--label-description--line-height--desktop);max-width:35rem}.af-validation-message{align-items:center;display:flex;flex-wrap:wrap}.af-validation-message__icon{flex:0 0 auto;height:1.25em;margin-inline-end:var(--digi--gutter--icon);width:1.25em}.af-validation-message__icon--success,.af-validation-message__icon--error{background-color:var(--af-validation-icon-color, currentColor);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain}.af-validation-message__icon--success{--af-validation-icon-color:var(--digi--color--icon--validation--success, var(--digi--global--color--function--success--base));-webkit-mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E\")}.af-validation-message__icon--error{--af-validation-icon-color:var(--digi--color--icon--validation--error, var(--digi--global--color--function--danger--base));-webkit-mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E\")}.af-validation-message__icon--warning{background:center / contain no-repeat url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='6.75' fill='%23333'/%3E%3Cpath d='m18 9c0 4.9717-4.0298 9-9 9-4.9702 0-9-4.0283-9-9 0-4.9688 4.0298-9 9-9 4.9702 0 9 4.0312 9 9zm-9 1.8145c-0.92196 0-1.6694 0.7474-1.6694 1.6694 0 0.92196 0.7474 1.6694 1.6694 1.6694s1.6694-0.7474 1.6694-1.6694c0-0.92196-0.7474-1.6694-1.6694-1.6694zm-1.3157-1.065c0.012593 0.23095 0.20355 0.41175 0.43483 0.41175h1.7618c0.23128 0 0.42224-0.1808 0.43483-0.41175l0.2692-4.9355c0.013609-0.24946-0.18501-0.45922-0.43483-0.45922h-2.3002c-0.24982 0-0.4484 0.20976-0.43479 0.45922l0.2692 4.9355z' fill='%23FFE200'/%3E%3C/svg%3E\");position:relative;top:3px}.af-validation-message__text{color:var(--af-text-color);flex:1;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--tag--font-size--desktop);transform:translateY(1px)}.af-validation-message__placeholder{visibility:hidden}.af-tag{display:block;max-width:100%;min-width:0}.af-tag__button{align-items:center;background:var(--af-tag-background);border:var(--digi--border-width--primary) var(--digi--border-style--primary) var(--af-tag-color);border-radius:var(--digi--border-radius--secondary);color:var(--af-tag-color);cursor:pointer;display:inline-flex;font-family:var(--digi--global--typography--font-family--default);font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold);gap:10px;height:auto;max-width:100%;min-height:unset;min-width:0;padding:6px 8px;text-align:left;white-space:normal}.af-tag__button:hover{background:var(--af-tag-hover-background)}.af-tag__button:focus-visible{background:var(--af-tag-hover-background);border-color:var(--af-tag-color);outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000));outline-offset:2px;box-shadow:0 0 0 5px var(--digi--color--background--primary, var(--digi--grayscale-0))}.af-tag__button:active{background:var(--af-tag-hover-background)}.af-tag__text{display:inline-block;max-width:100%;min-width:0;white-space:normal}.af-tag__text--break{overflow-wrap:anywhere;word-break:break-word}.af-icon{display:flex !important;min-height:1.4em !important;align-items:center !important}.af-icon--default-size{width:12px !important;height:12px !important}.af-tag__remove-icon{flex:0 0 auto;height:1em;width:1em}.af-icon.af-tag__remove-icon{min-height:0 !important}:host{--yrkesvaljaren-width:var(--af-width, 100%);--yrkesvaljaren-min-width:var(--af-min-width, 200px);--yrkesvaljaren-max-width:var(--af-max-width, none);--yrkesvaljaren-height:var(--af-height, auto);--yrkesvaljaren-min-height:var(--af-min-height, auto);--yrkesvaljaren-max-height:var(--af-max-height, none);--selector-width:var(--yrkesvaljaren-width);--selector-min-width:var(--yrkesvaljaren-min-width);--selector-max-width:var(--yrkesvaljaren-max-width);--selector-height:var(--yrkesvaljaren-height);--selector-min-height:var(--yrkesvaljaren-min-height);--selector-max-height:var(--yrkesvaljaren-max-height);--selector-font-family:var(--global-font-family, 'Open Sans', sans-serif);--selector-font-size:var(--sok-font-size, 1rem);--selector-text-color:var(--sok-text-color, var(--digi--color--text--primary, #212529));--selector-placeholder-color:var(--sok-placeholder-color, var(--digi--color--text--description, #6c757d));--selector-border-color:var(--sok-border-color, var(--digi--color--border--interactive--default--on-input, #d1d5db));--selector-focus-border-color:var(--sok-focus-border-color, #86b7fe);--selector-focus-shadow:var(--sok-focus-shadow, 0 0 0 0.25rem rgba(13, 110, 253, 0.25));--selector-background-color:var(--sok-background-color, var(--digi--color--background--interactive--default--input-elements, #fff));--selector-icon-color:var(--sok-icon-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-color:var(--sok-clear-button-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-hover-color:var(--sok-clear-button-hover-color, var(--digi--color--icon--primary, #212529));--selector-suggestion-background-color:var(--sok-suggestion-background-color, var(--digi--color--background--dropdown, #fff));--selector-suggestion-border-color:var(--sok-suggestion-border-color, var(--digi--color--divider--primary, #ced4da));--selector-suggestion-hover-background:var(--sok-suggestion-hover-background, var(--digi--color--background--interactive--hover--quarternary, #e9ecef));--selector-suggestion-active-background:var(--sok-suggestion-active-background, var(--digi--color--background--interactive--hover--quarternary, #dde4eb));--selector-suggestion-text-color:var(--sok-suggestion-text-color, var(--digi--color--text--primary, #212529));--selector-suggestion-highlight-weight:var(--sok-suggestion-highlight-weight, bold);--selector-error-color:var(--sok-error-color, var(--digi--color--border--interactive--validation--error, #dc3545));--selector-loading-color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d));display:flex;flex-direction:column;width:var(--yrkesvaljaren-width);min-width:var(--yrkesvaljaren-min-width);max-width:var(--yrkesvaljaren-max-width);height:var(--yrkesvaljaren-height);min-height:var(--yrkesvaljaren-min-height);max-height:var(--yrkesvaljaren-max-height);position:relative}:host([af-size=\"small\"]){--cs-size:small;--selector-container-min-height:32px;--selector-padding-y:2px;--selector-icon-size:1em;--selector-gap:4px}:host([af-size=\"medium\"]){--selector-container-min-height:40px;--selector-padding-y:6px}:host([af-size=\"large\"]){--selector-container-min-height:48px;--selector-padding-y:10px;--selector-icon-size:1.25em;--selector-gap:8px}*{box-sizing:border-box}.yrkesvaljaren-wrapper{display:flex;flex-direction:column;flex:1;min-height:inherit}core-selector{margin-top:0.5rem}.status-message{margin-top:0.5rem;font-size:0.9em;font-style:italic;color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d))}.history-header{font-size:0.875rem;color:var(--digi--color--text--description, var(--digi--grayscale-700, #757575));border-bottom:1px solid var(--selector-suggestion-border-color, #ced4da);margin-bottom:0px}.history-header a{color:inherit;text-decoration:underline}.history-header a:hover{color:var(--digi--color--text--interactive--primary, var(--digi--global--color--cta--link--base, #1616B2))}.yv-suggestion-box{margin-top:16px;padding:16px 20px;background:var(--digi--color--background--pop-out, var(--digi--grayscale-50, #fbfbfb));border:1px solid var(--digi--color--divider--secondary, var(--digi--grayscale-300, #e4e4e4));border-radius:var(--digi--border-radius--secondary, 6px);font-family:var(--digi--global--typography--font-family--default, \"Open Sans\", Arial, sans-serif);font-size:0.9375rem;line-height:1.4;color:var(--digi--color--text--primary, #333333)}.yv-suggestion-title{font-weight:var(--digi--global--typography--font-weight--semibold, 600);margin-bottom:10px}.yv-motivation-container{display:flex;flex-direction:column;gap:8px}.yv-motivation-field-wrapper{display:flex;flex-direction:column;gap:4px}.yv-motivation-input{width:100%;box-sizing:border-box;min-height:44px;max-height:180px;padding:8px 12px;font:inherit;color:inherit;background:var(--digi--color--background--interactive--default--input-elements, var(--digi--grayscale-0, #ffffff));border:1px solid var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-400, #dddddd));border-radius:var(--digi--border-radius--secondary, 6px);resize:vertical}.yv-motivation-input:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:1px}.yv-motivation-counter{align-self:flex-end;font-size:0.75rem;color:var(--digi--color--text--description, var(--digi--grayscale-800, #5c5c5c))}.yv-suggestion-actions{display:flex;gap:12px;align-items:center}.yv-suggestion-submit-btn,.yv-suggestion-cancel-btn,.yv-suggestion-close-btn{min-height:38px;padding:8px 16px;font:inherit;font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold, 600);border:1px solid transparent;border-radius:var(--digi--border-radius--secondary, 6px);cursor:pointer;white-space:nowrap}.yv-suggestion-submit-btn{background:var(--digi--color--background--interactive--default--primary, #000048);color:var(--digi--color--text--interactive--secondary, #ffffff)}.yv-suggestion-submit-btn:hover{background:var(--digi--color--background--interactive--hover--primary, #000028)}.yv-suggestion-cancel-btn{background:transparent;color:var(--digi--color--text--interactive--primary, #1616b2);text-decoration:underline}.yv-suggestion-close-btn{background:var(--digi--color--background--primary, var(--digi--grayscale-0, #ffffff));border-color:var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-600, #acacac));color:inherit}.yv-suggestion-submit-btn:focus-visible,.yv-suggestion-cancel-btn:focus-visible,.yv-suggestion-close-btn:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:2px}.yv-suggestion-pii-error{color:var(--cs-error-color, var(--digi--color--text--primary, #b10e1e))}.yv-suggestion-success{display:flex;justify-content:space-between;align-items:center;gap:16px;color:var(--digi--color--text--primary, #007a1c);font-weight:var(--digi--global--typography--font-weight--semibold, 600)}.yv-sr-only{position:absolute;top:0;left:0;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap}"}},[593,"digi-service-job-selector",{name:[513],taxonomyUrl:[513,"af-taxonomy-url"],placeholder:[513,"af-placeholder"],label:[513,"af-label"],disabled:[516],enableMultiple:[516,"af-enable-multiple"],showSearchIcon:[516,"af-show-search-icon"],errorMessage:[513,"af-error-message"],labelDescription:[513,"af-label-description"],required:[516,"af-required"],manualInput:[516,"af-manual-input"],feedback:[516,"af-feedback"],history:[516,"af-history"],popular:[516,"af-popular"],size:[513,"af-size"],taxonomyData:[1040],suggestionState:[32],afFocused:[32],state:[32],activeErrorType:[32],animatingItemId:[32],updateData:[64],setSelection:[64],setFocus:[64],validate:[64],checkValidity:[64],reportValidity:[64],getValidity:[64],getValidationMessage:[64]},[[0,"afJobValidationChange","handleFormValidationSync"],[8,"hashchange","handleHashFocus"],[0,"csInput","handleInput"],[0,"csSelect","handleCsSelect"],[0,"csClear","handleCsClear"],[0,"csClearHistory","handleCsClearHistory"],[0,"csRequestHistory","handleCsRequestHistory"],[0,"csLoadMore","handleCsLoadMore"],[0,"csRemoveItem","handleCsRemoveItem"],[0,"csFocus","handleCsFocus"],[0,"csBlur","handleCsBlur"],[0,"csEditSelection","handleCsEditSelection"]],{required:[{watchRequired:0}],manualInput:[{watchManualInputOrFeedback:0}],feedback:[{watchManualInputOrFeedback:0}],history:[{watchHistory:0}],popular:[{watchPopular:0}],enableMultiple:[{watchEnableMultiple:0}],disabled:[{watchDisabled:0}],taxonomyData:[{watchTaxonomyData:0}]}]);function A(){"undefined"!=typeof customElements&&["digi-service-job-selector","core-selector"].forEach((e=>{switch(e){case"digi-service-job-selector":customElements.get(t(e))||customElements.define(t(e),T);break;case"core-selector":customElements.get(t(e))||w()}}))}A();const R=T,q=A;export{R as DigiServiceJobSelector,q as defineCustomElement}
|
|
1
|
+
import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as a,Fragment as r}from"@stencil/core/internal/client";import{l as o,g as n,T as l,D as c,s as d,i as h,L as u,M as g,a as m,b as p,P as v,c as f,I as y,r as b,d as k}from"./types.js";import{d as S,A as w}from"./core-selector2.js";function x(t){return t.replace(/\b(?:(?:19|20)\d{2}|\d{2})(?:0[1-9]|1[0-2])(?:0[1-9]|[1-2][0-9]|3[0-1]|6[1-9]|[7-8][0-9]|9[0-1]) ?[-+]? ?\d{4}\b/g,"[personnummer]")}function C(t){return t.replace(/(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}._%+-]+@(?:[\p{L}\p{N}-]+\.)+\p{L}{2,}(?![\p{L}\p{N}])/gu,"[e-post]")}function I(t){let e=t.replace(/(?:\+46|\b0046|\b46)[ .-]*(?:\(0\)[ .-]*)?[1-9](?:[ ./-]*\d){6,9}\b/g,"[telefonnummer]");return e=e.replace(/\(0\d{1,3}\)[ .-]*\d(?:[ ./-]*\d){4,7}\b/g,"[telefonnummer]"),e=e.replace(/\b(?!\d{1,2}[./]\d{1,2}[./]\d{2,4}\b)0[1-9](?:[ ./-]*\d){6,9}\b/g,"[telefonnummer]"),e}function L(t){return t.replace(/\bSE ?\d{2}(?: ?\d{4}){5}\b/gi,"[kontonummer]")}function H(t){return t.normalize("NFKC").replace(/[\u00AD\u200B-\u200D\u2060\uFEFF]/g,"").replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g,"-").replace(/\s+/g," ").trim()}function V(t){const e=H(t);let i=C(e);return i=L(i),i=x(i),i=I(i),i!==e}function E(t,e=160){if(!t||"string"!=typeof t)return"";let i=H(t);return 0===i.length?"":(i=function(t){return t.replace(/\b(?:https?:\/\/|www\.)\S+/gi,"[url]").replace(/\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:se|com|nu|org|net|io|eu|info)\/\S*/g,"[url]")}(i),i=C(i),i=L(i),i=x(i),i=I(i),i=function(t){return t.replace(/(?<![\p{L}\p{N}])(?!\d{4}-\d{2}-\d{2}(?!\p{N})|\d{1,2}[./]\d{1,2}[./]\d{2,4}(?!\p{N}))\d(?:[ .-]?\d){7,}(?![\p{N}])/gu,"[nummer]")}(i),i=function(t){const e="gatan|vägen|gränd|stigen|allén|torget|gata",i=RegExp(`(?<![\\p{L}\\p{N}_])(?:\\p{L}+(?:${e})|\\p{L}+\\s+(?:${e}))\\s+\\d{1,4}(?:\\s?[A-Za-z])?(?![\\p{L}\\p{N}_])`,"giu");return t.replace(i,"[adress]").replace(/\b\d{3} ?\d{2}\s+(?!(?:[Kk]r|[Kk]ronor|SEK|[Ee]uro|[Tt]immar|[Ss]tycken|[Ss]t)(?![\p{L}]))[A-ZÅÄÖ]\p{Ll}+/gu,"[postadress]")}(i),i=function(t){const e="[A-ZÅÄÖÉ]\\p{Ll}+(?:-[A-ZÅÄÖÉ]\\p{Ll}+)?",i=RegExp(`(?<![\\p{L}\\p{N}_])((?:[Jj]ag\\s+heter|[Mm]itt\\s+(?:för|efter)?namn\\s+(?:är|e)|[Mm]vh|[Hh]älsningar|[Vv]änliga\\s+hälsningar|[Mm]ed\\s+vänlig\\s+hälsning)[,:]?\\s+)${e}(?:\\s+${e})?(?![\\p{L}\\p{N}_])`,"gu");return t.replace(i,((t,e)=>e+"[namn]"))}(i),i=i.replace(/\s+/g," ").trim(),i.length>e&&(i=i.slice(0,e).trim()),i)}function _(t){return E(t,120)}function D(t){return E(t,160)}let z=null;const j={saveHistory(t){z=t;try{localStorage.setItem("job-selector_history",JSON.stringify(t)),o.debug("[HistoryService] saveHistory - History saved.")}catch(t){o.error("Kunde inte spara historik.",t)}},loadHistory(){if(z)return z;try{const t=localStorage.getItem("job-selector_history");if(t)return z=JSON.parse(t),z}catch(t){o.error("Kunde inte läsa historik.",t)}return z=[],z},clearHistory(){z=[];try{localStorage.removeItem("job-selector_history"),o.debug("[HistoryService] clearHistory - History cleared.")}catch(t){o.error("Kunde inte rensa historik.",t)}}};class M{callbacks;config;cappedResults;state={status:"loading"};taxonomyData=[];popularItems=[];searchEngine=null;debounceTimer;validationTimer;isTouched=!1;activeErrorType=null;constructor(t,e){this.callbacks=t,this.config=e}getState(){return this.state}getActiveErrorType(){return this.activeErrorType}updateConfig(t){this.config={...this.config,...t},void 0===t.required&&void 0===t.requireSelection||this.runValidation()}getTaxonomyData(){if(this.taxonomyData.length>0)return this.taxonomyData;const t=n();return t&&t.length>0&&(o.debug("[Controller] getTaxonomyData - Late initializing from registry"),this.taxonomyData=t,this.popularItems=this.computePopularItems(this.taxonomyData),this.searchEngine=new l(this.taxonomyData)),this.taxonomyData}destroy(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.validationTimer&&(clearTimeout(this.validationTimer),this.validationTimer=void 0)}async initialize(t){o.debug("[Controller] initialize - START",{hasInitialData:!!t}),this.updateState({status:"loading"});const e=t&&t.length>0?t:n();e&&e.length>0?(o.debug("[Controller] initialize - Loaded taxonomy from registry"),this.setStateToActive(e,"registry",(new Date).toISOString())):(o.warn("[Controller] initialize - No taxonomy found in registry. Has registerTaxonomy() been called?"),this.updateState({status:"error",message:"Kunde inte hitta yrkesdata. Kontrollera att komponenten är initierad korrekt."}))}handleFocus(){this.isTouched=!0}setStateToActive(t,e,i){this.taxonomyData=t,this.popularItems=this.computePopularItems(this.taxonomyData),this.searchEngine=new l(this.taxonomyData);const s={dataSource:e,dataSourceDate:i};this.updateState(this.config.enableMultiple?{status:"multiSelect",inputValue:"",selectedItems:[],suggestions:[],validation:"idle",...s}:{status:"searching",inputValue:"",suggestions:[],validation:"idle",...s})}handleInput(t){this.isTouched=!0,o.debug("[Controller] handleInput - Value:",t);const e="error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0;if(clearTimeout(this.debounceTimer),""===t.trim()){const t="itemSelected"===this.state.status;return this.updateState(this.config.enableMultiple?{status:"multiSelect",inputValue:"",selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],suggestions:[],validation:"idle",validationContext:e,...this.getCommonState()}:{status:"searching",inputValue:"",suggestions:[],validation:"idle",validationContext:e,...this.getCommonState()}),t&&this.callbacks.onEmitSelection([]),void this.showHistory()}switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":this.updateState({status:"multiSelect",inputValue:t,selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],suggestions:"suggestions"in this.state?this.state.suggestions:"historyItems"in this.state?this.state.historyItems:[],validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0});break;case"itemSelected":case"searching":case"showingHistory":this.updateState({status:"searching",inputValue:t,suggestions:"suggestions"in this.state?this.state.suggestions:"historyItems"in this.state?this.state.historyItems:[],validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0});break;case"loading":case"error":return;default:return this.state}t.length>=this.config.minLength&&(this.debounceTimer=setTimeout((()=>this.performSearch(t)),c))}performSearch(t){if(this.searchEngine)switch(this.state.status){case"searching":case"multiSelect":{const e=this.config.maxResults,i=this.searchEngine.searchAsGeneric(t,e+1),s=i.slice(0,e).flatMap((t=>t.metadata?.originalResult?[t.metadata.originalResult]:[]));this.cappedResults=i.length>e?s:void 0,this.updateState({...this.state,suggestions:s});break}case"loading":case"error":case"itemSelected":case"showingHistory":case"multiSelectShowingHistory":return;default:return this.state}}addToHistory(t){if(!this.config.history)return;const e=j.loadHistory(),i=u.format(t.rawLabel,"",t.occupationLabel),s={...t,displaySegments:i,highlightedLabel:d(i)},a=e.filter((t=>!h(t,s))),r=[s,...a].slice(0,this.config.maxHistoryItems);j.saveHistory(r)}clearHistory(){j.clearHistory(),this.showHistory(!0)}computePopularItems(t,e=this.config.maxResults||g){if(!t||0===t.length)return[];if(!t.some((t=>"number"==typeof t.weight&&t.weight>0)))return t.slice(0,e);const i=[...t].sort(((t,e)=>(e.weight??0)-(t.weight??0))),s=new Set,a=[];for(const t of i){const i=t.occupation_name_preferred_label||t.preferred_label;if(s.has(i)||(s.add(i),a.push(t)),a.length===e)break}return a}showHistory(t=!1){if("loading"===this.state.status||"error"===this.state.status)return;if(!this.config.history)return;const e=j.loadHistory();let i=e,s=!1;0===e.length&&(!1===this.config.popular?i=[]:(0===this.popularItems.length&&this.taxonomyData.length>0&&(this.popularItems=this.computePopularItems(this.taxonomyData)),i=this.popularItems.map((t=>this.toSearchResult(t))),s=!0));const a=i.filter((t=>"ManualInput"===t.type?!0===this.config.manualInput:this.taxonomyData.some((e=>e.id===t.id)))).map((t=>{const e=u.format(t.rawLabel,"",t.occupationLabel);return{...t,displaySegments:e,highlightedLabel:d(e)}})),{dataSource:r,dataSourceDate:o}=this.getCommonState(),n="inputValue"in this.state?this.state.inputValue:"";(t||""===n.trim()||"showingHistory"===this.state.status||"multiSelectShowingHistory"===this.state.status)&&this.updateState(this.config.enableMultiple?{status:"multiSelectShowingHistory",selectedItems:"selectedItems"in this.state?this.state.selectedItems:[],historyItems:a,inputValue:n,validation:"validation"in this.state?this.state.validation:"idle",validationContext:"error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0,dataSource:r,dataSourceDate:o,isPopularView:s}:{status:"showingHistory",historyItems:a,inputValue:n,validation:"validation"in this.state?this.state.validation:"idle",validationContext:"error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0,dataSource:r,dataSourceDate:o,isPopularView:s})}selectItem(t){o.debug("[Controller] selectItem",t),this.isTouched=!0,this.addToHistory(t);const e="error"===this.state.validation||"from-error"===this.state.validationContext?"from-error":void 0;switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":{const i="dataSource"in this.state?this.state.dataSource:void 0,s="dataSourceDate"in this.state?this.state.dataSourceDate:void 0,a="selectedItems"in this.state?this.state.selectedItems:[];if(a.findIndex((e=>h(e,t)))>-1)return;const r=[...a,t];this.updateState({...this.state,status:"multiSelect",selectedItems:r,inputValue:"",suggestions:[],validation:"idle",validationContext:e,dataSource:i,dataSourceDate:s}),this.callbacks.onEmitSelection(r.map((t=>this.toPublicSelection(t)))),this.showHistory(!0);break}case"searching":case"showingHistory":this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}),this.callbacks.onEmitSelection(this.toPublicSelection(t)),this.config.enableMultiple&&this.showHistory(!0);break;case"loading":case"error":break;case"itemSelected":this.updateState({...this.state,status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",validationContext:e,dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}),this.callbacks.onEmitSelection(this.toPublicSelection(t));break;default:o.warn("[Controller] selectItem - Unexpected state:",this.state)}this.runValidation()}clearSelection(){"itemSelected"===this.state.status&&(this.isTouched=!0,this.updateState({status:"searching",inputValue:this.state.inputValue||"",suggestions:[],validation:"idle",...this.getCommonState()}),this.callbacks.onEmitSelection([]),this.showHistory(),this.runValidation())}removeItem(t){switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":{const e=this.state.selectedItems.filter((e=>!h(e,t)));this.isTouched=!0,this.updateState({...this.state,selectedItems:e}),this.callbacks.onEmitSelection(e.map((t=>this.toPublicSelection(t)))),""===("inputValue"in this.state?this.state.inputValue:"")&&this.showHistory(),this.runValidation();break}}}handleBlur(){if(this.isTouched=!0,"searching"===this.state.status){const t=(this.state.inputValue||"").trim();if(""!==t){const e=this.findExactMatch(t);if(e)return void this.selectItem(this.toSearchResult(e))}}switch(this.state.status){case"searching":case"showingHistory":this.updateState({...this.state,status:"searching",inputValue:"inputValue"in this.state?this.state.inputValue:"",suggestions:[]});break;case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,status:"multiSelect",inputValue:"inputValue"in this.state?this.state.inputValue:"",suggestions:[]});break;case"loading":case"error":case"itemSelected":break;default:return this.state}this.runValidation()}runValidation(t=!1){if(t&&(this.isTouched=!0),!this.isTouched)return!0;if("loading"===this.state.status||"error"===this.state.status)return!0;const e=this.checkHasValue();let i=!0,s=null;const a="searching"===this.state.status||"multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status,r=""!==("inputValue"in this.state?this.state.inputValue:"").trim();a&&r?(i=!1,s="invalidInput"):this.config.required&&!e&&(i=!1,s="required"),this.activeErrorType=s;const o="error"===this.state.validation||"from-error"===this.state.validationContext;let n;switch(n=i?o&&e?"success":"idle":"invalidInput"===s||t||o?"error":"idle","success"===n&&(clearTimeout(this.validationTimer),this.validationTimer=setTimeout((()=>{const t="validation"in this.state&&"success"===this.state.validation;["itemSelected","multiSelect","multiSelectShowingHistory"].includes(this.state.status)&&t&&this.updateState({...this.state,validation:"idle",validationContext:void 0}),this.validationTimer=void 0}),3e3)),this.state.status){case"searching":case"showingHistory":case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,validation:n});break;case"itemSelected":"error"!==n&&this.updateState({...this.state,validation:n});break;default:return this.state}return this.callbacks.onEmitValidation({isValid:i,errorType:s}),i}selectItemById(t){if(!t||this.config.enableMultiple||!this.taxonomyData)return;const e=this.taxonomyData.find((e=>e.id===t));if(e){const t=this.toSearchResult(e);this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0})}this.runValidation()}selectItemsByIds(t){if(!t||!this.config.enableMultiple||!this.taxonomyData)return;const e=t.map((t=>this.taxonomyData.find((e=>e.id===t))));if(e.some((t=>!t)))return;const i=e.filter((t=>!!t)).map((t=>this.toSearchResult(t)));switch(this.state.status){case"multiSelect":case"multiSelectShowingHistory":this.updateState({...this.state,selectedItems:i})}this.runValidation()}setSelection(t){const e=[];let i;const s=t.map((t=>{if(null!==t.id){const s=this.taxonomyData.filter((e=>e.id===t.id));if(0===s.length)return void e.push(t.id);const a=t.related?.id;let r;return a?(r=s.find((t=>t.occupation_name_id===a)),r||t.exact||1!==s.length||(r=s[0])):t.exact&&1!==s.length||(r=s[0]),r?this.toSearchResult(r):(e.push(t.id),void(t.exact&&(i??=t)))}return this.createManualInputItem(t.preferred_label)}));if(e.length>0)return i?{ok:!1,invalidIds:e,reference:i}:{ok:!1,invalidIds:e};const a=s,r=a.filter((t=>t.id));if(r.some(((t,e)=>r.findIndex((e=>h(e,t)))!==e)))return{ok:!1,invalidIds:[],duplicate:!0};const o=this.getCommonState();if(this.config.enableMultiple)this.updateState({...this.state,status:"multiSelect",selectedItems:a,inputValue:"",suggestions:[],validation:"idle",...o});else if(1===a.length){const t=a[0];this.updateState({status:"itemSelected",selectedItem:t,inputValue:t.preferred_label,validation:"idle",...o})}else this.updateState({status:"searching",inputValue:"",suggestions:[],validation:"idle",...o});return this.runValidation(),{ok:!0,selection:a.map((t=>this.toPublicSelection(t)))}}editSelection(){const t=this.state.selectedItem;if("itemSelected"!==this.state.status||!t||!this.searchEngine)return;const e=t.displayLabel,{dataSource:i,dataSourceDate:s}=this.state,a=this.searchEngine.searchAsGeneric(e,this.config.maxResults).flatMap((t=>t.metadata?.originalResult?[t.metadata.originalResult]:[]));this.updateState({status:"searching",inputValue:e,suggestions:a,validation:"idle",dataSource:i,dataSourceDate:s})}checkHasValue(){switch(this.state.status){case"itemSelected":return!0;case"multiSelect":case"multiSelectShowingHistory":return this.state.selectedItems.length>0;case"searching":case"showingHistory":return!this.config.requireSelection&&""!==("inputValue"in this.state?this.state.inputValue:"").trim();case"loading":case"error":return!1;default:return this.state}}getCommonState(){return{dataSource:"dataSource"in this.state?this.state.dataSource:void 0,dataSourceDate:"dataSourceDate"in this.state?this.state.dataSourceDate:void 0}}resetMultiSelection(){const t=this.getCommonState();this.updateState({...this.state,status:"multiSelect",selectedItems:[],inputValue:"",suggestions:[],validation:"idle",...t}),this.callbacks.onEmitSelection([])}updateState(t){this.state=t,this.callbacks.onStateChange(t)}toSearchResult(t){return{...t,rawLabel:t.preferred_label,displayLabel:t.occupation_name_preferred_label?`${t.preferred_label} (${t.occupation_name_preferred_label})`:t.preferred_label,highlightedLabel:t.preferred_label,score:3,occupationLabel:t.occupation_name_preferred_label,occupationId:t.occupation_name_id,ssyk_level_4_id:t.ssyk_level_4_id,ssyk_code_2012:t.ssyk_code_2012}}toPublicSelection(t){return m.toPublicSelection(t,(t=>this.taxonomyData.find((e=>e.id===t&&"occupation-name"===e.type))?.preferred_label?.trim()))}createManualInputItem(t){return{id:"",type:"ManualInput",preferred_label:t,rawLabel:t,displayLabel:t,highlightedLabel:t,score:1}}findExactMatch(t){const e=t.trim().toLowerCase(),i=this.taxonomyData.find((t=>!!t.occupation_name_preferred_label&&`${t.preferred_label} (${t.occupation_name_preferred_label})`.toLowerCase()===e));if(i)return i;const s=this.taxonomyData.filter((t=>t.preferred_label.toLowerCase()===e));return 1===s.length?s[0]:void 0}handleFreeTextSelection(t){if(!t)return;this.isTouched=!0;const e=this.findExactMatch(t);this.selectItem(e?this.toSearchResult(e):this.createManualInputItem(t))}hasMoreResults(t){return!!this.cappedResults&&t===this.cappedResults}loadMore(){this.config.maxResults+=10;const t="inputValue"in this.state?this.state.inputValue:"";t&&this.performSearch(t)}resetSearch(){switch(this.state.status){case"searching":case"multiSelect":this.updateState({...this.state,inputValue:"",suggestions:[]}),this.showHistory(!0);break;case"showingHistory":case"multiSelectShowingHistory":this.updateState({...this.state,inputValue:""});break;case"itemSelected":this.clearSelection()}}}o.setLevel(o.levels.SILENT);const F=/^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{4}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}$/;function T(t,e){return JSON.stringify([t,e??null])}const A=e(class t extends i{get hostElement(){return this}internals;name="yrkesvaljaren";taxonomyUrl;placeholder=v;label="Välj yrke";disabled=!1;enableMultiple=!1;showSearchIcon=!0;errorMessage;labelDescription;required=!1;manualInput=!1;feedback=!1;afOnSubmitJobSuggestion;suggestionState=null;history=!0;popular=!0;maxHistoryItems=10;enableSelectionAnimation=!1;afFocused=!1;populateInputOnSelect=!1;maxVisibleRows;minLength=f;maxResults=20;shouldFocusSuggestionInput=!1;shouldFocusConfirmation=!1;timers=new Set;schedule(t,e){const i=setTimeout((()=>{this.timers.delete(i),t()}),e);this.timers.add(i)}get requireSelection(){return!(this.manualInput||this.feedback)}size="medium";constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.afOnSubmitJobSuggestion=s(this,"afOnSubmitJobSuggestion",7),this.afJobSelectedEmitter=s(this,"afJobSelected",7),this.dataLoadFailedEmitter=s(this,"afJobDataLoadFailed",7),this.validationChangeEmitter=s(this,"afJobValidationChange",7),this.internals=this.attachInternals(),o.debug("[JobSelector] Constructor - enableMultiple:",this.enableMultiple)}state={status:"loading"};activeErrorType=null;animatingItemId=null;animationTimer;cloneSelection(t){return t.map((t=>null===t.id?{...t}:{...t,related:t.related?{...t.related}:void 0}))}rebuildValidJobIds(){const t=this.controller?.getTaxonomyData?.()??this.taxonomyData??[];this.validJobIds=new Set(t.map((t=>t.id)).filter(Boolean))}validateSelectionCandidate(t){const e="string"==typeof t?[t]:Array.isArray(t)?t:null;if(!e)return{ok:!1,reason:"invalid-input"};const i=e.some((t=>"string"==typeof t)),s=e.some((t=>"object"==typeof t&&null!==t));if(i&&s||e.some((t=>"string"!=typeof t&&("object"!=typeof t||null===t))))return{ok:!1,reason:"invalid-input"};const a=[],r=[],o=[],n=[];for(const t of e){if("string"==typeof t){const e=t.trim();if(!e)return{ok:!1,reason:"invalid-input"};if(F.test(e))r.push(e),o.push(T(e)),a.push({id:e});else{if(!this.manualInput)return{ok:!1,reason:"manual-input-disabled"};n.push(e),a.push({type:"manual-input",id:null,preferred_label:e})}continue}if(!t||"object"!=typeof t)return{ok:!1,reason:"invalid-input"};const e=t;if("string"==typeof e.id){const t=e.id.trim(),i=void 0===e.type&&void 0===e.preferred_label;if(!t||!i&&("job-title"!==e.type&&"occupation-name"!==e.type||"string"!=typeof e.preferred_label||!e.preferred_label.trim()))return{ok:!1,reason:"invalid-input"};let s;if(void 0!==e.related){const t=e.related;if(!(t&&"object"==typeof t&&"string"==typeof t.id&&t.id.trim()&&(i||"occupation-name"===t.type&&"string"==typeof t.preferred_label&&t.preferred_label.trim())))return{ok:!1,reason:"invalid-input"};s=t.id.trim()}r.push(t),o.push(T(t,s)),a.push({id:t,related:s?{id:s}:void 0,exact:i})}else{if(null!==e.id||"manual-input"!==e.type)return{ok:!1,reason:"invalid-input"};{if("string"!=typeof e.preferred_label||!e.preferred_label.trim())return{ok:!1,reason:"invalid-input"};if(!this.manualInput)return{ok:!1,reason:"manual-input-disabled"};const t=e.preferred_label.trim();n.push(t),a.push({type:"manual-input",id:null,preferred_label:t})}}}if(!this.enableMultiple&&a.length>1)return{ok:!1,reason:"multiple-disabled"};if(new Set(o).size!==o.length)return{ok:!1,reason:"duplicate-taxonomy-id"};if(new Set(n).size!==n.length)return{ok:!1,reason:"duplicate-manual-label"};const l=r.filter((t=>!this.validJobIds.has(t)));return l.length>0?{ok:!1,reason:"unknown-id",invalidIds:l}:{ok:!0,selection:a}}describeSelectionRejection(t){switch(t.reason){case"invalid-input":return"setSelection accepterar en sträng, en array med strängar eller en array med valobjekt eller referenser som { id, related: { id } }.";case"invalid-reference":{const{id:e,related:i}=t.reference;return i?`Yrkesbenämningen ${i.id} hör inte till valet ${e} i den laddade yrkesdatan.`:`Jobbtiteln ${e} hör till flera yrkesbenämningar. Ange yrkesbenämningens id i related.id.`}case"data-unavailable":return"setSelection kan inte användas eftersom yrkesdata inte kunde laddas.";case"duplicate-taxonomy-id":return"selection får inte innehålla samma yrke två gånger (samma taxonomi-id och related.id).";case"duplicate-manual-label":return"selection får inte innehålla dubbla manuella labels.";case"multiple-disabled":return'flera värden kräver af-enable-multiple="true".';case"manual-input-disabled":return'manual-val kräver af-manual-input="true".';case"unknown-id":return"okända Concept ID:n: "+t.invalidIds?.join(", ")}}errorCodeForRejection(t){switch(t){case"unknown-id":return"unknown-id";case"manual-input-disabled":return"manual-input-disabled";case"multiple-disabled":return"multiple-disabled";default:return"invalid-input"}}rejectSelection(t,e){const i=this.describeSelectionRejection(e);return console.error(`[Yrkesväljaren] Ogiltig selection: ${i} Värdet accepterades inte; senaste giltiga val behålls.`,{selection:t,previousSelection:this.lastAcceptedSelection}),this.activeErrorType="invalidInput",this.validationChangeEmitter.emit({isValid:!1,errorType:"invalidInput"}),this.updateValidity(!1),new y(i,this.errorCodeForRejection(e.reason),e.invalidIds)}syncAcceptedSelection(t,e){const i=this.cloneSelection(t);if(this.exactSelectionKeys=new Set(i.flatMap(((t,i)=>{if(null===t.id)return[];const s=T(t.id,t.related?.id),a=e?.[i];return(a?null!==a.id&&a.exact:this.exactSelectionKeys.has(s))?[s]:[]}))),this.lastAcceptedSelection=i,"invalidInput"===this.activeErrorType){const t=i.length>0||!this.required,e=t?null:"required";this.activeErrorType=e,this.validationChangeEmitter.emit({isValid:t,errorType:e}),this.updateValidity(t)}}applySelection(t){if(!this.controller)throw this.rejectSelection(t,{ok:!1,reason:"data-unavailable"});const e=this.validateSelectionCandidate(t);if(!e.ok)throw this.rejectSelection(t,e);const i=this.controller.setSelection(e.selection);if(!i.ok)throw this.rejectSelectionResolution(t,i);return this.syncAcceptedSelection(i.selection,e.selection),this.cloneSelection(i.selection)}rejectSelectionResolution(t,e){return this.rejectSelection(t,e.duplicate?{ok:!1,reason:"duplicate-taxonomy-id"}:e.reference?{ok:!1,reason:"invalid-reference",reference:e.reference}:{ok:!1,reason:"unknown-id",invalidIds:e.invalidIds})}watchRequired(t){this.controller.updateConfig({required:t})}watchManualInputOrFeedback(){this.feedback||(this.suggestionState=null),this.controller.updateConfig({requireSelection:this.requireSelection,manualInput:this.manualInput})}watchHistory(t){this.controller.updateConfig({history:t})}watchPopular(t){this.controller.updateConfig({popular:t})}watchEnableMultiple(t){this.controller.updateConfig({enableMultiple:t})}watchDisabled(t){t&&(this.afFocused=!1)}watchTaxonomyData(t){this.controller&&t&&t.length>0&&this.controller.initialize(t).then((()=>{this.rebuildValidJobIds(),this.restoreAcceptedSelectionAfterDataUpdate()}))}taxonomyData=[];afJobSelectedEmitter;syncFormValue(){if(this.state)if(this.enableMultiple){const t="multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status?this.state.selectedItems:[],e=new FormData;t.forEach((t=>{e.append(this.name,t.id||t.rawLabel)})),this.internals.setFormValue(e)}else{const t="itemSelected"===this.state.status?this.state.selectedItem:null;this.internals.setFormValue(t?t.id||t.rawLabel:null)}}handleFormValidationSync(t){this.updateValidity(t.detail.isValid)}dataLoadFailedEmitter;validationChangeEmitter;static nextId=0;componentId="job-selector-"+t.nextId++;observer;controller;validJobIds=new Set;lastAcceptedSelection=[];exactSelectionKeys=new Set;restoreAcceptedSelectionAfterDataUpdate(){if(0===this.lastAcceptedSelection.length)return;const t=this.lastAcceptedSelection.map((t=>null===t.id?t:{id:t.id,related:t.related,exact:this.exactSelectionKeys.has(T(t.id,t.related?.id))})),e=this.controller.setSelection(t);e.ok?this.syncAcceptedSelection(e.selection,t):this.rejectSelectionResolution(this.lastAcceptedSelection,e)}async componentWillLoad(){o.setLevel(o.levels.WARN);const t=n();if(!(this.taxonomyData&&this.taxonomyData.length>0||t&&t.length>0)){this.state={status:"loading"};try{const t=await async function({taxonomyUrl:t,fetcher:e=t=>fetch(t)}){const i=t??"https://d3hng02m5bee8m.cloudfront.net/yrkesvaljaren/latest.json";o.debug("[JobSelector] Hämtar yrkesdata från: "+i);const s=await e(i);if(!s.ok)throw Error(`Kunde inte ladda yrkesdata från ${i}: ${s.status} ${s.statusText}`);const a=await s.json();if(!p(a))throw Error("Yrkesdatan har ett ogiltigt format.");return a}({taxonomyUrl:this.taxonomyUrl});b(t),o.debug("[JobSelector] Data-laddning lyckades.")}catch(t){return o.error("[JobSelector] Fel vid data-laddning:",t),this.state={status:"error",message:"Kunde inte ladda yrkesdata."},void this.dataLoadFailedEmitter.emit({error:t instanceof Error?t:Error(t+"")})}}this.controller=new M({onStateChange:t=>{this.state={...t},this.syncFormValue()},onEmitSelection:t=>{const e=t?Array.isArray(t)?t:[t]:[];this.syncAcceptedSelection(e),this.afJobSelectedEmitter.emit(e)},onEmitValidation:t=>{this.activeErrorType=t.errorType,this.validationChangeEmitter.emit(t)},onEmitDataLoadFailed:t=>{this.dataLoadFailedEmitter.emit({error:t})},onEmitStatusChange:()=>{}},{enableMultiple:this.enableMultiple,required:this.required,requireSelection:this.requireSelection,manualInput:this.manualInput,history:this.history,popular:this.popular,maxHistoryItems:this.maxHistoryItems,minLength:this.minLength,maxResults:this.maxResults}),await this.controller.initialize(this.taxonomyData),this.taxonomyData=this.controller.getTaxonomyData(),this.rebuildValidJobIds(),"invalidInput"===this.activeErrorType?this.updateValidity(!1):this.required&&0===this.lastAcceptedSelection.length?this.internals.setValidity({customError:!0},this.errorMessage||"Välj ett yrke från listan."):this.internals.setValidity({})}componentDidLoad(){this.handleHashFocus()}componentDidRender(){if(this.shouldFocusSuggestionInput&&"form"===this.suggestionState?.status){this.shouldFocusSuggestionInput=!1;const t=this.hostElement.shadowRoot?.querySelector(`#${this.componentId}-suggestion-motivation-input`);t&&this.schedule((()=>t.focus()),50)}this.shouldFocusConfirmation&&"submitted"===this.suggestionState?.status&&(this.shouldFocusConfirmation=!1,this.hostElement.shadowRoot?.querySelector(".yv-suggestion-close-btn")?.focus())}disconnectedCallback(){this.observer&&this.observer.disconnect(),this.controller&&this.controller.destroy(),clearTimeout(this.animationTimer),this.animationTimer=void 0,this.timers.forEach((t=>clearTimeout(t))),this.timers.clear()}handleHashFocus(){const t=window.location.hash;if(!t)return;const e=t.substring(1),i=this.hostElement.getAttribute("id");i&&e===i&&(this.setFocus(),this.hostElement.scrollIntoView({behavior:"smooth",block:"center"}),history.replaceState(null,"",window.location.pathname+window.location.search))}trackedSelectedJobs(){return this.lastAcceptedSelection.flatMap((t=>"manual-input"!==t.type?[t]:V(t.preferred_label)?[]:[{...t,preferred_label:_(t.preferred_label)}]))}emitJobSuggestion(t,e){const i={selectedJobs:this.trackedSelectedJobs(),suggestionJob:_(t),suggestionMotivation:D(e)};this.afOnSubmitJobSuggestion.emit(i)}closeSuggestion(){this.suggestionState=null,this.shouldFocusSuggestionInput=!1,this.setFocus()}submitSuggestion(){if(!this.suggestionState||!this.feedback)return;const{term:t,motivation:e}=this.suggestionState;if(V(e||""))return this.suggestionState={...this.suggestionState,piiError:!0},void(this.shouldFocusSuggestionInput=!0);this.emitJobSuggestion(t,e),this.shouldFocusSuggestionInput=!1,this.shouldFocusConfirmation=!0,this.suggestionState={status:"submitted",term:(t||"").trim(),motivation:""}}handleInput(t){this.afFocused=!0,"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.handleInput(t.detail)}handleCsSelect(t){this.afFocused=!0;const e=t.detail;this.enableSelectionAnimation&&(this.animatingItemId=e.id,clearTimeout(this.animationTimer),this.animationTimer=setTimeout((()=>{this.animatingItemId=null,this.animationTimer=void 0}),600));const i=e.metadata?.original;if(i&&"displayLabel"in i)"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.selectItem(i);else{if("ManualInput"===e.metadata?.type){const t=e.label;return this.feedback&&V(t)?void(this.suggestionState={status:"pii-blocked",term:"",motivation:""}):(this.manualInput&&this.controller.handleFreeTextSelection(t),this.feedback?(this.afFocused=!1,this.shouldFocusSuggestionInput=!0,this.suggestionState={status:"form",term:t,motivation:""},void(this.manualInput||this.controller.resetSearch())):void 0)}this.controller.selectItem({id:e.id,type:"unknown",preferred_label:e.label,rawLabel:e.label,displayLabel:e.label,highlightedLabel:e.highlightedLabel||e.label,score:1})}}handleCsClear(){"pii-blocked"===this.suggestionState?.status&&(this.suggestionState=null),this.controller.resetSearch()}handleCsClearHistory(){this.controller.clearHistory()}handleCsRequestHistory(){this.controller.showHistory()}handleCsLoadMore(){this.controller.loadMore()}handleCsRemoveItem(t){const e=t.detail,i=e.metadata?.original;i&&"displayLabel"in i&&this.controller.removeItem(i)}handleCsFocus(){this.afFocused=!0,this.controller.handleFocus()}handleCsBlur(){this.afFocused=!1,this.controller.handleBlur(),this.validate()}handleCsEditSelection(){this.afFocused=!0,this.controller.editSelection()}async updateData(){o.debug("[JobSelector] updateData called"),await this.controller.initialize(),this.taxonomyData=this.controller.getTaxonomyData(),this.rebuildValidJobIds(),this.restoreAcceptedSelectionAfterDataUpdate()}async setSelection(t){return this.applySelection(t)}async setFocus(){const t=this.hostElement.shadowRoot?.querySelector("core-selector");t&&"function"==typeof t.setFocus&&await t.setFocus()}async validate(t=!1){const e=await this.controller.runValidation(t);return this.updateValidity(e),e}async checkValidity(){return this.internals.checkValidity()}async reportValidity(){return this.internals.reportValidity()}async getValidity(){return this.internals.validity}async getValidationMessage(){return this.internals.validationMessage}updateValidity(t){t?this.internals.setValidity({}):this.internals.setValidity({customError:!0},"invalidInput"===this.activeErrorType?this.errorMessage||"Komponenten har fått ett ogiltigt värde.":this.errorMessage||"Välj ett yrke från listan.")}_mapSearchResultToGenericItem(t){const e=this.enableMultiple?("multiSelect"===this.state.status||"multiSelectShowingHistory"===this.state.status)&&this.state.selectedItems.some((e=>h(e,t))):"itemSelected"===this.state.status&&!!this.state.selectedItem&&h(this.state.selectedItem,t);return{id:t.id,label:t.displayLabel,isSelected:this.animatingItemId===t.id||e,highlightedLabel:t.highlightedLabel,displaySegments:t.displaySegments,group:"occupation-name"===t.type?"Yrkesgrupper":"Yrkesbenämningar",metadata:{original:t}}}_mapStateToSelectorState(t){let e,i,s,a,r,o="loading",n="",l=[],c=[],d="idle",u=this.errorMessage||"";switch("validation"in t&&t.validation&&(d=t.validation,"error"===t.validation?"required"===this.activeErrorType||"invalidInput"===this.activeErrorType?u=this.errorMessage||"Välj ett yrke från listan.":this.errorMessage&&(u=this.errorMessage):"success"===t.validation&&(u="Tack!")),"message"in t&&t.message&&(u=t.message),"validationContext"in t&&(s=t.validationContext),t.status){case"loading":o="loading";break;case"error":o="error";break;case"searching":o="searching",n=t.inputValue,l=t.suggestions.map((t=>this._mapSearchResultToGenericItem(t))),e=this.controller?.hasMoreResults(t.suggestions);break;case"showingHistory":o="searching",n=t.inputValue||"",l=t.historyItems.map((t=>this._mapSearchResultToGenericItem(t)));break;case"itemSelected":o="itemSelected",i=this._mapSearchResultToGenericItem(t.selectedItem),i.highlightedLabel=k(i.label),n=t.inputValue||"";break;case"multiSelect":o="multiSelect",n=t.inputValue,l=t.suggestions.map((t=>this._mapSearchResultToGenericItem(t))),c=t.selectedItems.map((t=>this._mapSearchResultToGenericItem(t))),e=this.controller?.hasMoreResults(t.suggestions);break;case"multiSelectShowingHistory":o="multiSelect",n=t.inputValue||"",l=t.historyItems.map((t=>this._mapSearchResultToGenericItem(t))),c=t.selectedItems.map((t=>this._mapSearchResultToGenericItem(t)))}const g="showingHistory"===t.status||"multiSelectShowingHistory"===t.status;return"multiSelect"===o||"itemSelected"===o||"searching"===o?(c.length>0&&(l=l.filter((t=>!c.some((e=>{const i=e.metadata?.original,s=t.metadata?.original;return i&&s&&"rawLabel"in i&&"rawLabel"in s?h(i,s):e.id&&t.id?e.id===t.id:e.label===t.label}))))),g&&l.length>0?t.isPopularView?(a="Populära sökningar",r=!1):(r=!0,a=void 0):(a=void 0,r=!1)):(a=void 0,r=!1),"pii-blocked"===this.suggestionState?.status&&(d="error",u="Texten verkar innehålla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Skriv bara yrket du vill föreslå."),{status:o,inputValue:n,suggestions:l,selectedItem:i,selectedItems:c,validation:d,validationContext:s,message:u,listHeader:a,showHistoryHeader:r,isHistoryView:g,manualInputBlocked:"pii-blocked"===this.suggestionState?.status,hasMoreResults:e}}render(){const t=this._mapStateToSelectorState(this.state),e={disabled:this.disabled,placeholder:this.placeholder,minLength:this.minLength,maxResults:this.maxResults,enableMultiple:this.enableMultiple,showSearchIcon:this.showSearchIcon,requireSelection:this.requireSelection,size:this.size,enableSelectionAnimation:this.enableSelectionAnimation,populateInputOnSelect:this.populateInputOnSelect,maxVisibleRows:this.maxVisibleRows,manualInputBehavior:"select",showHistoryHeader:this.history&&!t.listHeader,listHeader:t.listHeader,enableInfiniteScroll:!0,isFeedback:this.feedback,manualInputMode:this.manualInput&&this.feedback?"combined":this.feedback?"feedback":"manual",feedbackTargetName:"yrke"};return a("div",{key:"d2042c1c0e5e76d8dfeedd2691de20d6fcf49c27",class:"job-selector-wrapper"},"error"===this.state.status?a("div",{class:"error-message"},a(w,{variant:"error",role:"alert"},this.state.message||"Ett fel uppstod.")):a(r,null,a("core-selector",{id:this.componentId,componentId:this.componentId,state:t,config:e,label:this.label,labelDescription:this.labelDescription,size:this.size,afFocused:this.afFocused}),this.suggestionState&&"pii-blocked"!==this.suggestionState.status&&a("div",{key:"yv-suggestion-box",class:"yv-suggestion-box",role:"region","aria-label":"Föreslå saknat yrke"},"form"===this.suggestionState.status?a("div",{class:"yv-suggestion-form"},a("div",{class:"yv-suggestion-title",id:this.componentId+"-suggestion-title"},'Motivera varför "',a("strong",null,this.suggestionState.term),'" bör läggas till som yrke (frivilligt):'),a("div",{class:"yv-motivation-container"},a("div",{class:"yv-motivation-field-wrapper"},a("textarea",{id:this.componentId+"-suggestion-motivation-input","aria-labelledby":this.componentId+"-suggestion-title","aria-describedby":this.suggestionState.piiError?`${this.componentId}-motivation-pii-error ${this.componentId}-motivation-counter`:this.componentId+"-motivation-counter","aria-invalid":this.suggestionState.piiError?"true":"false",class:"yv-motivation-input",value:this.suggestionState.motivation,maxLength:160,rows:2,ref:t=>{t&&(t.style.height="auto",t.style.height=Math.max(t.scrollHeight,44)+"px")},onInput:t=>{const e=t.target;e.style.height="auto",e.style.height=Math.max(e.scrollHeight,44)+"px",this.suggestionState&&(this.suggestionState={...this.suggestionState,motivation:e.value,piiError:!1})}}),a("div",{id:this.componentId+"-motivation-counter",class:"yv-motivation-counter"},(this.suggestionState.motivation||"").length,"/160")),this.suggestionState.piiError&&a("div",{id:this.componentId+"-motivation-pii-error",class:"yv-suggestion-pii-error",role:"alert"},"Motiveringen verkar innehålla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Ta bort dem för att kunna skicka."),a("div",{class:"yv-suggestion-actions"},a("button",{type:"button",class:"yv-suggestion-submit-btn","aria-label":`Skicka förslag för "${this.suggestionState.term}" till Arbetsförmedlingen`,onClick:()=>this.submitSuggestion()},"Skicka"),a("button",{type:"button",class:"yv-suggestion-cancel-btn","aria-label":"Avbryt förslag",onClick:()=>this.closeSuggestion()},"Avbryt")))):"submitted"===this.suggestionState.status?a("div",{class:"yv-suggestion-success"},a("span",null,'Förslaget "',a("strong",null,this.suggestionState.term),'" har skickats in till Arbetsförmedlingen.'),a("button",{type:"button",class:"yv-suggestion-close-btn","aria-label":"Stäng bekräftelse",onClick:()=>this.closeSuggestion()},"Stäng")):null),a("div",{key:"yv-suggestion-live-region",class:"yv-sr-only",role:"status","aria-live":"polite"},"submitted"===this.suggestionState?.status?`Förslaget "${this.suggestionState.term}" har skickats in till Arbetsförmedlingen.`:"")))}static get delegatesFocus(){return!0}static get formAssociated(){return!0}static get watchers(){return{required:[{watchRequired:0}],manualInput:[{watchManualInputOrFeedback:0}],feedback:[{watchManualInputOrFeedback:0}],history:[{watchHistory:0}],popular:[{watchPopular:0}],enableMultiple:[{watchEnableMultiple:0}],disabled:[{watchDisabled:0}],taxonomyData:[{watchTaxonomyData:0}]}}static get style(){return":host{--digi--grayscale-0:#ffffff;--digi--grayscale-50:#fbfbfb;--digi--grayscale-100:#f4f4f4;--digi--grayscale-200:#ededed;--digi--grayscale-300:#e4e4e4;--digi--grayscale-400:#dddddd;--digi--grayscale-500:#cacaca;--digi--grayscale-600:#acacac;--digi--grayscale-700:#757575;--digi--grayscale-800:#5c5c5c;--digi--grayscale-900:#333333;--digi--grayscale-1000:#000000;--digi--global--color--cta--link--base:#1616b2;--digi--global--color--function--danger--base:#da0000;--digi--global--color--function--success--base:#008a20;--digi--global--color--function--success--lightest-3:#d4edda;--digi--global--color--function--warning--base:#ffe200;--af-text-color:var(--digi--color--text--primary, var(--digi--grayscale-900));--digi--global--typography--font-family--default:\"Open Sans\", Arial, sans-serif;--digi--global--typography--font-size--base:1rem;--digi--global--typography--font-size--small:0.875rem;--digi--global--typography--font-weight--regular:400;--digi--global--typography--font-weight--semibold:600;--digi--global--typography--font-weight--bold:700;--digi--global--typography--line-height--base:1.5;--digi--typography--label--font-size--desktop:1rem;--digi--typography--label--font-weight--desktop:600;--digi--typography--label--line-height--desktop:1.5;--digi--typography--label-description--font-size--desktop:1rem;--digi--typography--label-description--line-height--desktop:1.5;--digi--typography--tag--font-size--desktop:0.875rem;--digi--gutter--icon:0.625rem;--digi--gutter--smaller:0.75rem;--digi--gutter--small:0.875rem;--digi--gutter--medium:1rem;--digi--border-width--primary:1px;--digi--border-style--primary:solid;--digi--border-radius--primary:0;--digi--border-radius--secondary:6px;--af-tag-color:var(--digi--color--text--interactive--brand-primary, #091d54);--af-tag-background:var(--digi--color--background--interactive--default--secondary, var(--digi--grayscale-0));--af-tag-hover-background:var(--digi--color--background--interactive--hover--secondary, #ddf1fc)}.af-form-label{color:var(--af-text-color);display:flex;flex-direction:column;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--label--font-size--desktop);margin-bottom:0.5rem}.af-form-label__label{cursor:pointer;display:block;font-weight:var(--digi--typography--label--font-weight--desktop);line-height:var(--digi--typography--label--line-height--desktop)}.af-form-label__description{display:block;font-size:var(--digi--typography--label-description--font-size--desktop);line-height:var(--digi--typography--label-description--line-height--desktop);max-width:35rem}.af-validation-message{align-items:center;display:flex;flex-wrap:wrap}.af-validation-message__icon{flex:0 0 auto;height:1.25em;margin-inline-end:var(--digi--gutter--icon);width:1.25em}.af-validation-message__icon--success,.af-validation-message__icon--error{background-color:var(--af-validation-icon-color, currentColor);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain}.af-validation-message__icon--success{--af-validation-icon-color:var(--digi--color--icon--validation--success, var(--digi--global--color--function--success--base));-webkit-mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E\")}.af-validation-message__icon--error{--af-validation-icon-color:var(--digi--color--icon--validation--error, var(--digi--global--color--function--danger--base));-webkit-mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E\")}.af-validation-message__icon--warning{background:center / contain no-repeat url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='6.75' fill='%23333'/%3E%3Cpath d='m18 9c0 4.9717-4.0298 9-9 9-4.9702 0-9-4.0283-9-9 0-4.9688 4.0298-9 9-9 4.9702 0 9 4.0312 9 9zm-9 1.8145c-0.92196 0-1.6694 0.7474-1.6694 1.6694 0 0.92196 0.7474 1.6694 1.6694 1.6694s1.6694-0.7474 1.6694-1.6694c0-0.92196-0.7474-1.6694-1.6694-1.6694zm-1.3157-1.065c0.012593 0.23095 0.20355 0.41175 0.43483 0.41175h1.7618c0.23128 0 0.42224-0.1808 0.43483-0.41175l0.2692-4.9355c0.013609-0.24946-0.18501-0.45922-0.43483-0.45922h-2.3002c-0.24982 0-0.4484 0.20976-0.43479 0.45922l0.2692 4.9355z' fill='%23FFE200'/%3E%3C/svg%3E\");position:relative;top:3px}.af-validation-message__text{color:var(--af-text-color);flex:1;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--tag--font-size--desktop);transform:translateY(1px)}.af-validation-message__placeholder{visibility:hidden}.af-tag{display:block;max-width:100%;min-width:0}.af-tag__button{align-items:center;background:var(--af-tag-background);border:var(--digi--border-width--primary) var(--digi--border-style--primary) var(--af-tag-color);border-radius:var(--digi--border-radius--secondary);color:var(--af-tag-color);cursor:pointer;display:inline-flex;font-family:var(--digi--global--typography--font-family--default);font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold);gap:10px;height:auto;max-width:100%;min-height:unset;min-width:0;padding:6px 8px;text-align:left;white-space:normal}.af-tag__button:hover{background:var(--af-tag-hover-background)}.af-tag__button:focus-visible{background:var(--af-tag-hover-background);border-color:var(--af-tag-color);outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000));outline-offset:2px;box-shadow:0 0 0 5px var(--digi--color--background--primary, var(--digi--grayscale-0))}.af-tag__button:active{background:var(--af-tag-hover-background)}.af-tag__text{display:inline-block;max-width:100%;min-width:0;white-space:normal}.af-tag__text--break{overflow-wrap:anywhere;word-break:break-word}.af-icon{display:flex !important;min-height:1.4em !important;align-items:center !important}.af-icon--default-size{width:12px !important;height:12px !important}.af-tag__remove-icon{flex:0 0 auto;height:1em;width:1em}.af-icon.af-tag__remove-icon{min-height:0 !important}:host{--yrkesvaljaren-width:var(--af-width, 100%);--yrkesvaljaren-min-width:var(--af-min-width, 200px);--yrkesvaljaren-max-width:var(--af-max-width, none);--yrkesvaljaren-height:var(--af-height, auto);--yrkesvaljaren-min-height:var(--af-min-height, auto);--yrkesvaljaren-max-height:var(--af-max-height, none);--selector-width:var(--yrkesvaljaren-width);--selector-min-width:var(--yrkesvaljaren-min-width);--selector-max-width:var(--yrkesvaljaren-max-width);--selector-height:var(--yrkesvaljaren-height);--selector-min-height:var(--yrkesvaljaren-min-height);--selector-max-height:var(--yrkesvaljaren-max-height);--selector-font-family:var(--global-font-family, 'Open Sans', sans-serif);--selector-font-size:var(--sok-font-size, 1rem);--selector-text-color:var(--sok-text-color, var(--digi--color--text--primary, #212529));--selector-placeholder-color:var(--sok-placeholder-color, var(--digi--color--text--description, #6c757d));--selector-border-color:var(--sok-border-color, var(--digi--color--border--interactive--default--on-input, #d1d5db));--selector-focus-border-color:var(--sok-focus-border-color, #86b7fe);--selector-focus-shadow:var(--sok-focus-shadow, 0 0 0 0.25rem rgba(13, 110, 253, 0.25));--selector-background-color:var(--sok-background-color, var(--digi--color--background--interactive--default--input-elements, #fff));--selector-icon-color:var(--sok-icon-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-color:var(--sok-clear-button-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-hover-color:var(--sok-clear-button-hover-color, var(--digi--color--icon--primary, #212529));--selector-suggestion-background-color:var(--sok-suggestion-background-color, var(--digi--color--background--dropdown, #fff));--selector-suggestion-border-color:var(--sok-suggestion-border-color, var(--digi--color--divider--primary, #ced4da));--selector-suggestion-hover-background:var(--sok-suggestion-hover-background, var(--digi--color--background--interactive--hover--quarternary, #e9ecef));--selector-suggestion-active-background:var(--sok-suggestion-active-background, var(--digi--color--background--interactive--hover--quarternary, #dde4eb));--selector-suggestion-text-color:var(--sok-suggestion-text-color, var(--digi--color--text--primary, #212529));--selector-suggestion-highlight-weight:var(--sok-suggestion-highlight-weight, bold);--selector-error-color:var(--sok-error-color, var(--digi--color--border--interactive--validation--error, #dc3545));--selector-loading-color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d));display:flex;flex-direction:column;width:var(--yrkesvaljaren-width);min-width:var(--yrkesvaljaren-min-width);max-width:var(--yrkesvaljaren-max-width);height:var(--yrkesvaljaren-height);min-height:var(--yrkesvaljaren-min-height);max-height:var(--yrkesvaljaren-max-height);position:relative}:host([af-size=\"small\"]){--cs-size:small;--selector-container-min-height:32px;--selector-padding-y:2px;--selector-icon-size:1em;--selector-gap:4px}:host([af-size=\"medium\"]){--selector-container-min-height:40px;--selector-padding-y:6px}:host([af-size=\"large\"]){--selector-container-min-height:48px;--selector-padding-y:10px;--selector-icon-size:1.25em;--selector-gap:8px}*{box-sizing:border-box}.yrkesvaljaren-wrapper{display:flex;flex-direction:column;flex:1;min-height:inherit}core-selector{margin-top:0.5rem}.status-message{margin-top:0.5rem;font-size:0.9em;font-style:italic;color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d))}.history-header{font-size:0.875rem;color:var(--digi--color--text--description, var(--digi--grayscale-700, #757575));border-bottom:1px solid var(--selector-suggestion-border-color, #ced4da);margin-bottom:0px}.history-header a{color:inherit;text-decoration:underline}.history-header a:hover{color:var(--digi--color--text--interactive--primary, var(--digi--global--color--cta--link--base, #1616B2))}.yv-suggestion-box{margin-top:16px;padding:16px 20px;background:var(--digi--color--background--pop-out, var(--digi--grayscale-50, #fbfbfb));border:1px solid var(--digi--color--divider--secondary, var(--digi--grayscale-300, #e4e4e4));border-radius:var(--digi--border-radius--secondary, 6px);font-family:var(--digi--global--typography--font-family--default, \"Open Sans\", Arial, sans-serif);font-size:0.9375rem;line-height:1.4;color:var(--digi--color--text--primary, #333333)}.yv-suggestion-title{font-weight:var(--digi--global--typography--font-weight--semibold, 600);margin-bottom:10px}.yv-motivation-container{display:flex;flex-direction:column;gap:8px}.yv-motivation-field-wrapper{display:flex;flex-direction:column;gap:4px}.yv-motivation-input{width:100%;box-sizing:border-box;min-height:44px;max-height:180px;padding:8px 12px;font:inherit;color:inherit;background:var(--digi--color--background--interactive--default--input-elements, var(--digi--grayscale-0, #ffffff));border:1px solid var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-400, #dddddd));border-radius:var(--digi--border-radius--secondary, 6px);resize:vertical}.yv-motivation-input:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:1px}.yv-motivation-counter{align-self:flex-end;font-size:0.75rem;color:var(--digi--color--text--description, var(--digi--grayscale-800, #5c5c5c))}.yv-suggestion-actions{display:flex;gap:12px;align-items:center}.yv-suggestion-submit-btn,.yv-suggestion-cancel-btn,.yv-suggestion-close-btn{min-height:38px;padding:8px 16px;font:inherit;font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold, 600);border:1px solid transparent;border-radius:var(--digi--border-radius--secondary, 6px);cursor:pointer;white-space:nowrap}.yv-suggestion-submit-btn{background:var(--digi--color--background--interactive--default--primary, #000048);color:var(--digi--color--text--interactive--secondary, #ffffff)}.yv-suggestion-submit-btn:hover{background:var(--digi--color--background--interactive--hover--primary, #000028)}.yv-suggestion-cancel-btn{background:transparent;color:var(--digi--color--text--interactive--primary, #1616b2);text-decoration:underline}.yv-suggestion-close-btn{background:var(--digi--color--background--primary, var(--digi--grayscale-0, #ffffff));border-color:var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-600, #acacac));color:inherit}.yv-suggestion-submit-btn:focus-visible,.yv-suggestion-cancel-btn:focus-visible,.yv-suggestion-close-btn:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:2px}.yv-suggestion-pii-error{color:var(--cs-error-color, var(--digi--color--text--primary, #b10e1e))}.yv-suggestion-success{display:flex;justify-content:space-between;align-items:center;gap:16px;color:var(--digi--color--text--primary, #007a1c);font-weight:var(--digi--global--typography--font-weight--semibold, 600)}.yv-sr-only{position:absolute;top:0;left:0;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap}"}},[593,"digi-service-job-selector",{name:[513],taxonomyUrl:[513,"af-taxonomy-url"],placeholder:[513,"af-placeholder"],label:[513,"af-label"],disabled:[516],enableMultiple:[516,"af-enable-multiple"],showSearchIcon:[516,"af-show-search-icon"],errorMessage:[513,"af-error-message"],labelDescription:[513,"af-label-description"],required:[516,"af-required"],manualInput:[516,"af-manual-input"],feedback:[516,"af-feedback"],history:[516,"af-history"],popular:[516,"af-popular"],size:[513,"af-size"],taxonomyData:[1040],suggestionState:[32],afFocused:[32],state:[32],activeErrorType:[32],animatingItemId:[32],updateData:[64],setSelection:[64],setFocus:[64],validate:[64],checkValidity:[64],reportValidity:[64],getValidity:[64],getValidationMessage:[64]},[[0,"afJobValidationChange","handleFormValidationSync"],[8,"hashchange","handleHashFocus"],[0,"csInput","handleInput"],[0,"csSelect","handleCsSelect"],[0,"csClear","handleCsClear"],[0,"csClearHistory","handleCsClearHistory"],[0,"csRequestHistory","handleCsRequestHistory"],[0,"csLoadMore","handleCsLoadMore"],[0,"csRemoveItem","handleCsRemoveItem"],[0,"csFocus","handleCsFocus"],[0,"csBlur","handleCsBlur"],[0,"csEditSelection","handleCsEditSelection"]],{required:[{watchRequired:0}],manualInput:[{watchManualInputOrFeedback:0}],feedback:[{watchManualInputOrFeedback:0}],history:[{watchHistory:0}],popular:[{watchPopular:0}],enableMultiple:[{watchEnableMultiple:0}],disabled:[{watchDisabled:0}],taxonomyData:[{watchTaxonomyData:0}]}]);function R(){"undefined"!=typeof customElements&&["digi-service-job-selector","core-selector"].forEach((e=>{switch(e){case"digi-service-job-selector":customElements.get(t(e))||customElements.define(t(e),A);break;case"core-selector":customElements.get(t(e))||S()}}))}R();const J=A,q=R;export{J as DigiServiceJobSelector,q as defineCustomElement}
|
package/dist/components/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,n,i,r={exports:{}},s=t((e||(e=1,n=r.exports,i=function(){var t=function(){},e="undefined",n=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],r={},s=null;function o(t,e){var n=t[e];if("function"==typeof n.bind)return n.bind(t);try{return Function.prototype.bind.call(n,t)}catch(e){return function(){return Function.prototype.apply.apply(n,[t,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var n=this.getLevel(),r=0;r<i.length;r++){var s=i[r];this[s]=r<n?t:this.methodFactory(s,n,this.name)}if(this.log=this.debug,typeof console===e&&n<this.levels.SILENT)return"No console available for logging"}function h(t){return function(){typeof console!==e&&(c.call(this),this[t].apply(this,arguments))}}function a(i,r,s){return function(i){return"debug"===i&&(i="log"),typeof console!==e&&("trace"===i&&n?u:void 0!==console[i]?o(console,i):void 0!==console.log?o(console,"log"):t)}(i)||h.apply(this,arguments)}function l(t,n){var o,u,h,l=this,f="loglevel";function d(){var t;if(typeof window!==e&&f){try{t=window.localStorage[f]}catch(t){}if(typeof t===e)try{var n=window.document.cookie,i=encodeURIComponent(f),r=n.indexOf(i+"=");-1!==r&&(t=/^([^;]+)/.exec(n.slice(r+i.length+1))[1])}catch(t){}return void 0===l.levels[t]&&(t=void 0),t}}function g(t){var e=t;if("string"==typeof e&&void 0!==l.levels[e.toUpperCase()]&&(e=l.levels[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=l.levels.SILENT)return e;throw new TypeError("log.setLevel() called with invalid level: "+t)}"string"==typeof t?f+=":"+t:"symbol"==typeof t&&(f=void 0),l.name=t,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=n||a,l.getLevel=function(){return null!=h?h:null!=u?u:o},l.setLevel=function(t,n){return h=g(t),!1!==n&&function(t){var n=(i[t]||"silent").toUpperCase();if(typeof window!==e&&f){try{return void(window.localStorage[f]=n)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"="+n+";"}catch(t){}}}(h),c.call(l)},l.setDefaultLevel=function(t){u=g(t),d()||l.setLevel(t,!1)},l.resetLevel=function(){h=null,function(){if(typeof window!==e&&f){try{window.localStorage.removeItem(f)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(t){}}}(),c.call(l)},l.enableAll=function(t){l.setLevel(l.levels.TRACE,t)},l.disableAll=function(t){l.setLevel(l.levels.SILENT,t)},l.rebuild=function(){if(s!==l&&(o=g(s.getLevel())),c.call(l),s===l)for(var t in r)r[t].rebuild()},o=g(s?s.getLevel():"WARN");var A=d();null!=A&&(h=g(A)),c.call(l)}(s=new l).getLogger=function(t){if("symbol"!=typeof t&&"string"!=typeof t||""===t)throw new TypeError("You must supply a name when creating a logger.");var e=r[t];return e||(e=r[t]=new l(t,s.methodFactory)),e};var f=typeof window!==e?window.log:void 0;return s.noConflict=function(){return typeof window!==e&&window.log===s&&(window.log=f),s},s.getLoggers=function(){return r},s.default=s,s},r.exports?r.exports=i():n.log=i()),r.exports));let o=[],u=null;function c(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function h(t){return"string"==typeof t&&t.trim().length>0}function a(t){return void 0===t||"string"==typeof t}function l(t){return!(!c(t)||!Array.isArray(t.data)||0===t.data.length)&&t.data.every((t=>function(t){return!!c(t)&&h(t.id)&&("job-title"===t.type||"occupation-name"===t.type)&&h(t.preferred_label)&&a(t.ssyk_level_4_id)&&a(t.ssyk_code_2012)&&a(t.occupation_name_id)&&a(t.occupation_name_preferred_label)&&(void 0===t.weight||"number"==typeof t.weight&&Number.isFinite(t.weight))&&(void 0===t.search_aliases||Array.isArray(t.search_aliases)&&t.search_aliases.every((t=>"string"==typeof t)))}(t)))}function f(t){if(!l(t))return void s.error("[TaxonomyRegistry] Felaktigt format på taxonomidata vid registrering.");o=function(t){const e=new Map;return t.filter((t=>{const n="job-title"===t.type?t.occupation_name_id??"":"",i=e.get(t.id)??new Set;return!i.has(n)&&(i.add(n),e.set(t.id,i),!0)}))}(t.data).map((t=>({...t})));const e=c(t.metadata)?t.metadata.labour_market_taxonomy_version:void 0;u=void 0!==e?String(e):void 0!==t.taxonomyVersion?String(t.taxonomyVersion):"unknown",s.debug(`[TaxonomyRegistry] Taxonomi version ${u} registrerades med ${o.length} yrken.`)}function d(){return 0===o.length&&s.warn("[TaxonomyRegistry] Ingen taxonomi är registrerad ännu! Anropa registerTaxonomy(data) först."),o}function g(t){return Array.isArray?Array.isArray(t):"[object Array]"===m(t)}function A(t){return null==t?"":function(t){if("string"==typeof t)return t;if("bigint"==typeof t)return t.toString();const e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}function p(t){return"string"==typeof t}function y(t){return"number"==typeof t}function C(t){return"object"==typeof t}function v(t){return null!=t}function w(t){return!t.trim().length}function m(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const M="Invalid doc index: must be a non-negative integer within the bounds of the docs array",F=Object.prototype.hasOwnProperty;var D=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{const n=B(t);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function B(t){let e=null,n=null,i=null,r=1,s=null;if(p(t)||g(t))i=t,e=E(t),n=x(t);else{if(!F.call(t,"name"))throw new Error("Missing name property in key");const o=t.name;if(i=o,F.call(t,"weight")&&void 0!==t.weight&&(r=t.weight,r<=0))throw new Error((t=>`Property 'weight' in key '${t}' must be a positive integer`)(x(o)));e=E(o),n=x(o),s=t.getFn??null}return{path:e,id:n,weight:r,src:i,getFn:s}}function E(t){return g(t)?t:t.split(".")}function x(t){return g(t)?t.join("."):t}const b=Object.freeze({isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:function(t,e){const n=[];let i=!1;const r=(t,e,s,o)=>{if(v(t))if(e[s]){const u=t[e[s]];if(!v(u))return;if(s===e.length-1&&(p(u)||y(u)||function(t){return!0===t||!1===t||function(t){return C(t)&&null!==t}(t)&&"[object Boolean]"==m(t)}(u)||"bigint"==typeof u))n.push(void 0!==o?{v:A(u),i:o}:A(u));else if(g(u)){i=!0;for(let t=0,n=u.length;t<n;t+=1)r(u[t],e,s+1,t)}else e.length&&r(u,e,s+1,o)}else n.push(void 0!==o?{v:t,i:o}:t)};return r(t,p(e)?e.split("."):e,0),i?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1});var k=class{constructor({getFn:t=b.getFn,fieldNormWeight:e=b.fieldNormWeight}={}){this.norm=function(t=1,e=3){const n=new Map,i=Math.pow(10,e);return{get(e){let r=0,s=!1;for(let t=0;t<e.length;t++)(o=e.charCodeAt(t))>=9&&o<=13||32===o||160===o?s=!1:s||(r++,s=!0);var o;if(0===r&&(r=1),n.has(r))return n.get(r);const u=Math.round(i/Math.pow(r,.5*t))/i;return n.set(r,u),u},clear(){n.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(p(this.docs[0]))for(let n=0;n<t;n++){const t=this._createStringRecord(this.docs[n],n);t&&(this.records[e++]=t)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(M);if(p(t)){const n=this._createStringRecord(t,e);return n&&this.records.push(n),n}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(M);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const n of t)Number.isInteger(n)&&n>=0&&e.add(n);if(0===e.size)return;this.records=this.records.filter((t=>!e.has(t.i)));const n=Array.from(e).sort(((t,e)=>t-e));for(const t of this.records){let e=0,i=n.length;for(;e<i;){const r=e+i>>>1;n[r]<t.i?e=r+1:i=r}t.i-=e}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!v(t)||w(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let e=0,i=this.keys.length;e<i;e++){const i=this.keys[e],r=i.getFn?i.getFn(t):this.getFn(t,i.path);if(v(r))if(g(r)){const t=[];for(let e=0,n=r.length;e<n;e+=1){const n=r[e];if(v(n))if(p(n)){if(!w(n)){const i={v:n,i:e,n:this.norm.get(n)};t.push(i)}}else if(v(n.v)){const e=p(n.v)?n.v:A(n.v);if(!w(e)){const i={v:e,i:n.i,n:this.norm.get(e)};t.push(i)}}}n.$[e]=t}else if(p(r)&&!w(r)){const t={v:r,n:this.norm.get(r)};n.$[e]=t}}return n}toJSON(){return{keys:this.keys.map((({getFn:t,...e})=>e)),records:this.records}}};function S(t,e,{getFn:n=b.getFn,fieldNormWeight:i=b.fieldNormWeight}={}){const r=new k({getFn:n,fieldNormWeight:i});return r.setKeys(t.map(B)),r.setSources(e),r.create(),r}function $(t){const e={};for(let n=0,i=t.length;n<i;n+=1){const r=t.charAt(n);e[r]=(e[r]||0)|1<<i-n-1}return e}function N(t){if(t.length<=1)return t;t.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]));const e=[t[0]];for(let n=1,i=t.length;n<i;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const L={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},I=new RegExp("["+Object.keys(L).join("")+"]","g"),R="function"==typeof String.prototype.normalize?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(I,(t=>L[t])):t=>t;var _=class{constructor(t,{location:e=b.location,threshold:n=b.threshold,distance:i=b.distance,includeMatches:r=b.includeMatches,findAllMatches:s=b.findAllMatches,minMatchCharLength:o=b.minMatchCharLength,isCaseSensitive:u=b.isCaseSensitive,ignoreDiacritics:c=b.ignoreDiacritics,ignoreLocation:h=b.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:i,includeMatches:r,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:h},t=u?t:t.toLowerCase(),t=c?R(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const a=(t,e)=>{this.chunks.push({pattern:t,alphabet:$(t),startIndex:e})},l=this.pattern.length;if(l>32){let t=0;const e=l%32,n=l-e;for(;t<n;)a(this.pattern.substr(t,32),t),t+=32;if(e){const t=l-32;a(this.pattern.substr(t),t)}}else a(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=e?t:t.toLowerCase(),t=n?R(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const e={isMatch:!0,score:0};return i&&(e.indices=[[0,t.length-1]]),e}const{location:r,distance:s,threshold:o,findAllMatches:u,minMatchCharLength:c,ignoreLocation:h}=this.options,a=[];let l=0,f=!1;this.chunks.forEach((({pattern:e,alphabet:n,startIndex:d})=>{const{isMatch:g,score:A,indices:p}=function(t,e,n,{location:i=b.location,distance:r=b.distance,threshold:s=b.threshold,findAllMatches:o=b.findAllMatches,minMatchCharLength:u=b.minMatchCharLength,includeMatches:c=b.includeMatches,ignoreLocation:h=b.ignoreLocation}={}){if(e.length>32)throw new Error("Pattern length exceeds max of 32.");const a=e.length,l=t.length,f=Math.max(0,Math.min(i,l));let d=s,g=f;const A=(t,e)=>{const n=t/a;if(h)return n;const i=Math.abs(f-e);return r?n+i/r:i?1:n},p=u>1||c,y=p?Array(l):[];let C;for(;(C=t.indexOf(e,g))>-1;){const t=A(0,C);if(d=Math.min(t,d),g=C+a,p){let t=0;for(;t<a;)y[C+t]=1,t+=1}}g=-1;let v=[],w=1,m=0,M=a+l;const F=1<<a-1;for(let e=0;e<a;e+=1){let i=0,r=M;for(;i<r;)A(e,f+r)<=d?i=r:M=r,r=Math.floor((M-i)/2+i);M=r;let s=Math.max(1,f-r+1);const u=o?l:Math.min(f+r,l)+a,c=Array(u+2);c[u+1]=(1<<e)-1;for(let i=u;i>=s;i-=1){const r=i-1;if(c[i]=(c[i+1]<<1|1)&n[t[r]],e&&(c[i]|=(v[i+1]|v[i])<<1|1|v[i+1]),c[i]&F&&(w=A(e,r),w<=d)){if(d=w,g=r,m=e,g<=f)break;s=Math.max(1,2*f-g)}}if(A(e+1,f)>d)break;v=c}if(p&&g>=0){const e=Math.min(l-1,g+a-1+m);for(let i=g;i<=e;i+=1)n[t[i]]&&(y[i]=1)}const D={isMatch:g>=0,score:Math.max(.001,w)};if(p){const t=function(t=[],e=b.minMatchCharLength){const n=[];let i=-1,r=-1,s=0;for(let o=t.length;s<o;s+=1){const o=t[s];o&&-1===i?i=s:o||-1===i||(r=s-1,r-i+1>=e&&n.push([i,r]),i=-1)}return t[s-1]&&s-i>=e&&n.push([i,s-1]),n}(y,u);t.length?c&&(D.indices=t):D.isMatch=!1}return D}(t,e,n,{location:r+d,distance:s,threshold:o,findAllMatches:u,minMatchCharLength:c,includeMatches:i,ignoreLocation:h});g&&(f=!0),l+=A,g&&p&&a.push(...p)}));const d={isMatch:f,score:f?l/this.chunks.length:1};return f&&i&&(d.indices=N(a)),d}};const j=new Set(["fuzzy","include"]),T=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n,i=0;const r=[],s=t.length;for(;(n=e.indexOf(t,i))>-1;)i=n+s,r.push([n,i-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=-1===e.indexOf(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new _(t,{location:e.location??b.location,threshold:e.threshold??b.threshold,distance:e.distance??b.distance,includeMatches:e.includeMatches??b.includeMatches,findAllMatches:e.findAllMatches??b.findAllMatches,minMatchCharLength:e.minMatchCharLength??b.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??b.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??b.ignoreDiacritics,ignoreLocation:e.ignoreLocation??b.ignoreLocation});return{type:"fuzzy",search:t=>n.searchIn(t)}}}],z=T.length;function O(t,e){const n=t.match(e);return n?n[1]:null}const W=[];function U(...t){W.push(...t)}function G(t,e){for(let n=0,i=W.length;n<i;n+=1){const i=W[n];if(i.condition(t,e))return new i(t,e)}return new _(t,e)}const J="$and",P="$path",K=t=>!(!t[J]&&!t.$or),Y=t=>({[J]:Object.keys(t).map((e=>({[e]:t[e]})))});function H(t,e,{auto:n=!0}={}){const i=t=>{if(p(t)){const i={keyId:null,pattern:t};return n&&(i.searcher=G(t,e)),i}const r=Object.keys(t),s=(t=>!!t[P])(t);if(!s&&r.length>1&&!K(t))return i(Y(t));if((t=>!g(t)&&C(t)&&!K(t))(t)){const i=s?t[P]:r[0],o=s?t.$val:t[i];if(!p(o))throw new Error((t=>`Invalid value for key ${t}`)(i));const u={keyId:x(i),pattern:o};return n&&(u.searcher=G(o,e)),u}const o={children:[],operator:r[0]};return r.forEach((e=>{const n=t[e];g(n)&&n.forEach((t=>{o.children.push(i(t))}))})),o};return K(t)||(t=Y(t)),i(t)}function q(t,{ignoreFieldNorm:e=b.ignoreFieldNorm}){let n=1;return t.forEach((({key:t,norm:i,score:r})=>{const s=t?t.weight:null;n*=Math.pow(0===r&&s?Number.EPSILON:r,(s||1)*(e?1:i))})),n}var V=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const i=e[t];e[t]=e[n],e[n]=i,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let i=t;do{const r=2*(t=i)+1,s=2*t+2;if(r<n&&this.comparator(e[r],e[i])>0&&(i=r),s<n&&this.comparator(e[s],e[i])>0&&(i=s),i!==t){const n=e[t];e[t]=e[i],e[i]=n}}while(i!==t)}};const Q=/[\p{L}\p{M}\p{N}_]+/gu,X=new WeakSet;function Z({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const i=function(t){if("function"==typeof t){let e=!1;return n=>{const i=t(n);if(!e&&(e=!0,!Array.isArray(i)||i.some((t=>"string"!=typeof t))))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(i)?"array containing non-strings":typeof i}.`);return i}}return t instanceof RegExp?(t.global||X.has(e=t)||(X.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`)),e=>e.match(t)||[]):t=>t.match(Q)||[];var e}(n);return{tokenize:n=>(t||(n=n.toLowerCase()),e&&(n=R(n)),i(n))}}function tt(t,e,n,i){const r=i.tokenize(e);if(!r.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const s=new Set(r);let o=t.docTermFieldHits.get(n);o||(o=new Map,t.docTermFieldHits.set(n,o));for(const e of s)o.set(e,(o.get(e)||0)+1),t.df.set(e,(t.df.get(e)||0)+1)}function et(t,e,n,i){const{i:r,v:s,$:o}=e;if(void 0===s){if(o)for(let e=0;e<n;e++){const n=o[e];if(n)if(Array.isArray(n))for(const e of n)tt(t,e.v,r,i);else tt(t,n.v,r,i)}}else tt(t,s,r,i)}function nt(t,e){const n=t.docFieldCount.get(e);if(void 0===n)return;t.fieldCount-=n,t.docFieldCount.delete(e);const i=t.docTermFieldHits.get(e);if(i){for(const[e,n]of i){const i=(t.df.get(e)||0)-n;i<=0?t.df.delete(e):t.df.set(e,i)}t.docTermFieldHits.delete(e)}}function it(t,e){if(0===e.length)return;const n=Array.from(new Set(e)).sort(((t,e)=>t-e));for(const e of n)nt(t,e);const i=t=>{let e=0,i=n.length;for(;e<i;){const r=e+i>>>1;n[r]<t?e=r+1:i=r}return t-e},r=n[0],s=new Map;for(const[e,n]of t.docFieldCount)s.set(e>r?i(e):e,n);t.docFieldCount=s;const o=new Map;for(const[e,n]of t.docTermFieldHits)o.set(e>r?i(e):e,n);t.docTermFieldHits=o}var rt=class{constructor(t,e,n){this.options={...b,...e},this._keyStore=new D(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=G(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof k))throw new Error("Incorrect 'index' type");if(this._myIndex=e||S(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const t=Z({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=function(t,e,n){const i={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const r of t)et(i,r,e,n);return i}(this._myIndex.records,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}add(t){if(!v(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const t=Z({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});!function(t,e,n,i){et(t,e,n,i)}(this._invertedIndex,e,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let i=0,r=this._docs.length;i<r;i+=1)t(this._docs[i],i)&&(e.push(this._docs[i]),n.push(i));if(n.length){this._invertedIndex&&it(this._invertedIndex,n);const t=new Set(n);this._docs=this._docs.filter(((e,n)=>!t.has(n))),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(M);this._invertedIndex&&it(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map((t=>this._keyStore.get(t.id)||t))}search(t,e){const{limit:n=-1}=e||{},{includeMatches:i,includeScore:r,shouldSort:s,sortFn:o,ignoreFieldNorm:u}=this.options;if(p(t)&&!t.trim()){let t=this._docs.map(((t,e)=>({item:t,refIndex:e})));return y(n)&&n>-1&&(t=t.slice(0,n)),t}const c=s&&y(n)&&n>0&&p(t),h=o,a=(t,e)=>h(t,e)||t.idx-e.idx;let l;if(c){const e=new V(n,a);p(this._docs[0])?this._searchStringList(t,{heap:e,ignoreFieldNorm:u}):this._searchObjectList(t,{heap:e,ignoreFieldNorm:u}),l=e.extractSorted()}else l=p(t)?p(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),function(t,{ignoreFieldNorm:e=b.ignoreFieldNorm}){t.forEach((t=>{t.score=q(t.matches,{ignoreFieldNorm:e})}))}(l,{ignoreFieldNorm:u}),s&&l.sort(p(t)?a:h),y(n)&&n>-1&&(l=l.slice(0,n));return function(t,e,{includeMatches:n=b.includeMatches,includeScore:i=b.includeScore}={}){return t.map((t=>{const{idx:r}=t,s={item:e[r],refIndex:r};return n&&(s.matches=function(t){const e=[];return t.matches.forEach((t=>{if(!v(t.indices)||!t.indices.length)return;const n={indices:t.indices,value:t.value};t.key&&(n.key=t.key.id),t.idx>-1&&(n.refIndex=t.idx),e.push(n)})),e}(t)),i&&(s.score=t.score),s}))}(l,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const i=this._getSearcher(t),r=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{records:s}=this._myIndex,o=e?null:[];return s.forEach((({v:t,i:s,n:u})=>{if(!v(t))return;const c=i.searchIn(t);if(c.isMatch){const i={score:c.score,value:t,norm:u,indices:c.indices};r&&(i.matchedMask=c.matchedMask,i.matchedTerms=c.matchedTerms,i.termCount=c.termCount);const h=[i];if(!r||this._coversAllTokens(h)){const i={item:t,idx:s,matches:h};e?(i.score=q(i.matches,{ignoreFieldNorm:n}),e.insert(i)):o.push(i)}}})),o}_searchLogical(t){const e=H(t,this.options),n=this._normalizedKeys(),i=(t,e,r)=>{if(!("children"in t)){const{keyId:i,searcher:s}=t;let o;return null===i?(o=[],n.forEach(((t,n)=>{o.push(...this._findMatches({key:t,value:e[n],searcher:s}))}))):o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(e,i),searcher:s}),o&&o.length?[{idx:r,item:e,matches:o}]:[]}const{children:s,operator:o}=t,u=[];for(let t=0,n=s.length;t<n;t+=1){const n=i(s[t],e,r);if(n.length)u.push(...n);else if(o===J)return[]}return u},r=this._myIndex.records,s=new Map,o=[];return r.forEach((({$:t,i:n})=>{if(v(t)){const r=i(e,t,n);r.length&&(s.has(n)||(s.set(n,{idx:n,item:t,matches:[]}),o.push(s.get(n))),r.forEach((({matches:t})=>{s.get(n).matches.push(...t)})))}})),o}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const i=this._getSearcher(t),r=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{records:s}=this._myIndex,o=this._normalizedKeys(),u=e?null:[];return s.forEach((({$:t,i:s})=>{if(!v(t))return;const c=[];let h=!1,a=!1;if(o.forEach(((e,n)=>{const r=this._findMatches({key:e,value:t[n],searcher:i});r.length?(c.push(...r),r[0].hasInverse&&(a=!0)):h=!0})),(!a||!h)&&c.length&&(!r||this._coversAllTokens(c))){const i={idx:s,item:t,matches:c};e?(i.score=q(i.matches,{ignoreFieldNorm:n}),e.insert(i)):u.push(i)}})),u}_findMatches({key:t,value:e,searcher:n}){if(!v(e))return[];const i=[];if(g(e))e.forEach((({v:e,i:r,n:s})=>{if(!v(e))return;const o=n.searchIn(e);if(o.isMatch){const n={score:o.score,key:t,value:e,idx:r,norm:s,indices:o.indices,hasInverse:o.hasInverse};void 0!==o.termCount&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),i.push(n)}}));else{const{v:r,n:s}=e,o=n.searchIn(r);if(o.isMatch){const e={score:o.score,key:t,value:r,norm:s,indices:o.indices,hasInverse:o.hasInverse};void 0!==o.termCount&&(e.matchedMask=o.matchedMask,e.matchedTerms=o.matchedTerms,e.termCount=o.termCount),i.push(e)}}return i}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(void 0===e)return!0;if(e<=31){let n=0;for(let e=0;e<t.length;e++)n|=t[e].matchedMask||0;return n===2**e-1}const n=new Set;for(let e=0;e<t.length;e++){const i=t[e].matchedTerms;if(i)for(const t of i)n.add(t)}return n.size===e}};rt.version="7.5.0",rt.createIndex=S,rt.parseIndex=function(t,{getFn:e=b.getFn,fieldNormWeight:n=b.fieldNormWeight}={}){const{keys:i,records:r}=t,s=new k({getFn:e,fieldNormWeight:n});return s.setKeys(i),s.setIndexRecords(r),s},rt.config=b,rt.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error("Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.");return G(t,{...b,...n}).searchIn(e)},rt.parseQuery=H,U(class{constructor(t,{isCaseSensitive:e=b.isCaseSensitive,ignoreDiacritics:n=b.ignoreDiacritics,includeMatches:i=b.includeMatches,minMatchCharLength:r=b.minMatchCharLength,ignoreLocation:s=b.ignoreLocation,findAllMatches:o=b.findAllMatches,location:u=b.location,threshold:c=b.threshold,distance:h=b.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:r,findAllMatches:o,ignoreLocation:s,location:u,threshold:c,distance:h},t=e?t:t.toLowerCase(),t=n?R(t):t,this.pattern=t,this.query=function(t,e={}){return t.replace(/\\\|/g,"\0").split("|").map((t=>{const n=function(t){const e=[],n=t.length;let i=0;for(;i<n;){for(;i<n&&" "===t[i];)i++;if(i>=n)break;let r=i;for(;r<n&&" "!==t[r]&&'"'!==t[r];)r++;if(r<n&&'"'===t[r]){for(r++;r<n;){if('"'===t[r]){const e=r+1;if(e>=n||" "===t[e]){r++;break}if("$"===t[e]&&(e+1>=n||" "===t[e+1])){r+=2;break}}r++}e.push(t.substring(i,r)),i=r}else{for(;r<n&&" "!==t[r];)r++;e.push(t.substring(i,r)),i=r}}return e}(t.replace(/\u0000/g,"|").trim()).filter((t=>t&&!!t.trim())),i=[];for(let t=0,r=n.length;t<r;t+=1){const r=n[t];let s=!1,o=-1;for(;!s&&++o<z;){const t=T[o],n=O(r,t.multiRegex);n&&(i.push(t.create(n,e)),s=!0)}if(!s)for(o=-1;++o<z;){const t=T[o],n=O(r,t.singleRegex);if(n){i.push(t.create(n,e));break}}}return i}))}(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:r}=this.options;t=i?t:t.toLowerCase(),t=r?R(t):t;let s=0;const o=[];let u=0,c=!1;for(let i=0,r=e.length;i<r;i+=1){const r=e[i];o.length=0,s=0,c=!1;for(let e=0,i=r.length;e<i;e+=1){const i=r[e],{isMatch:h,indices:a,score:l}=i.search(t);if(!h){u=0,s=0,o.length=0,c=!1;break}s+=1,u+=l,i.type.startsWith("inverse")&&(c=!0),n&&(j.has(i.type)?o.push(...a):o.push(a))}if(s){const t={isMatch:!0,score:u/s};return c&&(t.hasInverse=!0),n&&(t.indices=N(o)),t}}return{isMatch:!1,score:1}}}),U(class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Z({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:i,fieldCount:r}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const t of n){this.termSearchers.push(new _(t,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const n=i.get(t)||0,s=Math.log(1+(r-n+.5)/(n+.5));this.idfWeights.push(s)}this.combineAll="all"===e.tokenMatch,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,i=0,r=0,s=0;const o=this.combineAll&&!this.useMask?new Set:null;for(let u=0;u<this.termSearchers.length;u++){const c=this.termSearchers[u].searchIn(t),h=this.idfWeights[u];i+=h,c.isMatch&&(r++,n+=h*(1-c.score),c.indices&&e.push(...c.indices),this.combineAll&&(this.useMask?s|=1<<u:o.add(u)))}if(0===r)return{isMatch:!1,score:1};const u={isMatch:!0,score:Math.max(.001,i>0?1-n/i:0)};return this.options.includeMatches&&e.length&&(u.indices=N(e)),this.combineAll&&(this.useMask?u.matchedMask=s:u.matchedTerms=o,u.termCount=this.numTerms),u}}),rt.use=function(...t){t.forEach((t=>U(t)))};var st=rt;const ot=1,ut=100,ct=20,ht={keys:["preferred_label"],includeScore:!0,ignoreDiacritics:!0,ignoreFieldNorm:!0,threshold:.6,minMatchCharLength:1,ignoreLocation:!0,distance:100},at="T.ex. målare, florist, kock",lt={format:(t,e,n)=>{const i=function(t,e){if(!t)return[];if(!e||0===e.trim().length)return[{text:t,isMatch:!1}];const n=t.toLowerCase(),i=e.toLowerCase().split(/\s+/).filter((t=>t.length>0)),r=new Set;if(i.forEach((t=>{let e=0;for(;-1!==(e=n.indexOf(t,e));){for(let n=0;n<t.length;n++)r.add(e+n);e+=t.length}})),0===r.size&&i.forEach((e=>{const n=function(t,e){const n=t.toLowerCase(),i=e.length;let r=99,s=-1,o=0;const u=Math.max(3,i-2),c=Math.min(n.length,i+2);for(let t=0;t<=n.length-u;t++)for(let i=u;i<=c&&t+i<=n.length;i++){const u=ft(e,n.slice(t,t+i));u<r&&(r=u,s=t,o=i)}return r<=Math.max(2,Math.floor(.25*i))&&-1!==s?{start:s,length:o}:null}(t,e);if(n)for(let t=0;t<n.length;t++)r.add(n.start+t)})),0===r.size)return[{text:t,isMatch:!1}];const s=[];let o="",u=r.has(0);for(let e=0;e<t.length;e++){const n=r.has(e);n!==u?(o.length>0&&s.push({text:o,isMatch:u}),o=t[e],u=n):o+=t[e]}return o.length>0&&s.push({text:o,isMatch:u}),s}(t,e);return n?[...i,{text:" ",isMatch:!1},{text:`(${n})`,isMetadata:!0}]:i}};function ft(t,e){const n=t.length,i=e.length,r=Array.from({length:n+1},(()=>new Array(i+1).fill(0)));for(let t=0;t<=n;t++)r[t][0]=t;for(let t=0;t<=i;t++)r[0][t]=t;for(let s=1;s<=n;s++)for(let n=1;n<=i;n++)r[s][n]=t[s-1]===e[n-1]?r[s-1][n-1]:1+Math.min(r[s-1][n],r[s][n-1],r[s-1][n-1]);return r[n][i]}s.setLevel(s.levels.DEBUG);const dt=t=>t?t.toLowerCase().trim():"";function gt(t,e){return t.id&&e.id?t.id===e.id&&(t.occupationId??t.occupation_name_id??"")===(e.occupationId??e.occupation_name_id??""):t.rawLabel===e.rawLabel}function At(t){return t.sort(((t,e)=>{const n=t.score??0,i=e.score??0;if(n!==i)return i-n;const r=t.weight??0,s=e.weight??0;return r!==s?s-r:t.displayLabel.localeCompare(e.displayLabel,"sv")}))}function pt(t){return t.map((t=>t.isMatch?`<strong>${t.text}</strong>`:t.isMetadata?`<span class="occupation-variant-label">${t.text}</span>`:t.text)).join("")}const yt=t=>t?t.replace(/ (\([^)]+\))/g,' <span class="occupation-variant-label">$1</span>'):"";function Ct(t,e,n){return t===e?1:n.length>1?n.every((e=>t.includes(e)))?.98:null:t.startsWith(e)?.99:t.includes(e)?.95:null}function vt(t,e){const n=t.length,i=e.length,r=Array.from({length:n+1},(()=>new Array(i+1).fill(0)));for(let t=0;t<=n;t++)r[t][0]=t;for(let t=0;t<=i;t++)r[0][t]=t;for(let s=1;s<=n;s++)for(let n=1;n<=i;n++)r[s][n]=t[s-1]===e[n-1]?r[s-1][n-1]:1+Math.min(r[s-1][n],r[s][n-1],r[s-1][n-1]);return r[n][i]}function wt(t,e){const n=t.toLowerCase().trim(),i=e.toLowerCase().trim();return i.includes(" ")?vt(n,i)<=Math.max(2,Math.floor(.25*n.length))&&Math.abs(n.length-i.length)<=2:null!==function(t,e){const n=t.toLowerCase(),i=e.length;let r=99;const s=Math.max(3,i-2),o=Math.min(n.length,i+2);for(let t=0;t<=n.length-s;t++)for(let i=s;i<=o&&t+i<=n.length;i++){const s=vt(e,n.slice(t,t+i));s<r&&(r=s)}return r<=Math.max(2,Math.floor(.25*i))?r:null}(i,n)}function mt(t,e){return(t.search_aliases??[]).some((t=>dt(t)===e))}function Mt(t,e,n){const i=function(t){return t.occupation_name_preferred_label?`${t.preferred_label||""} (${t.occupation_name_preferred_label})`:t.preferred_label||""}(t),r=lt.format(t.preferred_label||"",e,t.occupation_name_preferred_label);return{id:t.id,type:t.type,preferred_label:t.preferred_label||"",rawLabel:t.preferred_label||"",displayLabel:i,highlightedLabel:pt(r),displaySegments:r,weight:t.weight??0,score:n,occupationId:t.occupation_name_id,occupationLabel:t.occupation_name_preferred_label,ssyk_level_4_id:t.ssyk_level_4_id,ssyk_code_2012:t.ssyk_code_2012}}function Ft(t){return"job-title"===t.type?`${t.id}|${t.occupation_name_id??""}`:t.id}function Dt(t,e,n,i){if(!n)return[];if(!e||!Array.isArray(e))return s.warn("[searchConcepts] Ogiltig items array."),[];if(!t||t.length<1)return[];const r=dt(t),o=r.split(" ").filter((t=>t.length>0)),u=[],c=new Set;for(const n of e){const e=Ct(dt(n.preferred_label),r,o),i=mt(n,r)?1:e;null!==i&&(u.push(Mt(n,t,i)),c.add(Ft(n)))}if(u.length>0)return At(u).slice(0,i);if(n){const e=n.search(r);if(0===e.length)return[];const s=e[0].score??1,o=[];let u=!1;for(const n of e){const e=Ft(n.item);if(c.has(e))continue;const i=n.score??1,h=1-i;if(h<.4)continue;if(i>s+.12)continue;const a=dt(n.item.preferred_label),l=n.item.weight??0,f=wt(r,a);f&&i<=.25&&(u=!0);let d=.7*h+.1*l;f&&(d+=.12);const g=Math.min(.84,Math.max(.4,d));o.push(Mt(n.item,t,g)),c.add(e)}const h=At(o);if(0===h.length)return[];const a=u?Math.min(5,i):Math.min(3,i);return h.slice(0,a)}return[]}const Bt={toGenericItem:t=>({id:t.id,label:t.preferred_label||"",description:t.occupation_name_preferred_label,metadata:{original:t,type:t.type,ssyk_level_4_id:t.ssyk_level_4_id,weight:t.weight}}),searchResultToGenericItem(t,e){const n=lt.format(t.preferred_label||"",e,t.occupation_name_preferred_label);return{id:t.id,label:t.preferred_label||"",displaySegments:n,highlightedLabel:pt(n),metadata:{original:t,ssyk_level_4_id:t.ssyk_level_4_id,weight:t.weight}}},fromGenericItem:t=>({id:t.id,preferred_label:t.label,weight:t.metadata?.weight,...t.metadata?.original}),toPublicSelection(t){const e=t.id||"",n=t.preferred_label||t.rawLabel||"";if(!e)return{type:"manual-input",id:null,preferred_label:n};if("job-title"!==t.type&&"occupation-name"!==t.type)throw new Error(`Ogiltig intern yrkestyp för ${e}: ${t.type}`);const i={type:t.type,id:e,preferred_label:n};t.ssyk_code_2012&&(i.ssyk_code_2012=t.ssyk_code_2012);const r=t.occupation_name_id||t.occupationId,s=t.occupation_name_preferred_label||t.occupationLabel;return"job-title"===t.type&&r&&s&&(i.related={type:"occupation-name",id:r,preferred_label:s}),i}};class Et{fuseInstance=null;items=[];constructor(t){this.items=t,this.fuseInstance=new st(t,ht)}search(t,e=20){return this.fuseInstance?Dt(t,this.items,this.fuseInstance,e).map((t=>Bt.toPublicSelection(t))):[]}searchAsGeneric(t,e=20){return this.fuseInstance?Dt(t,this.items,this.fuseInstance,e).map((t=>({id:t.id,label:t.displayLabel,description:t.occupationLabel,group:"job-title"===t.type?"Yrke":"Yrkesgrupp",metadata:{originalResult:t,highlightedLabel:t.highlightedLabel,score:t.score,weight:t.weight}}))):[]}updateData(t){this.items=t,this.fuseInstance=new st(t,ht)}}class xt extends Error{code;invalidIds;constructor(t,e,n){super(t),this.name="InvalidSelectionError",this.code=e,this.invalidIds=n}}export{ut as D,xt as I,lt as L,ct as M,at as P,Et as T,Bt as a,l as b,ot as c,yt as d,d as g,gt as i,s as l,f as r,pt as s}
|
|
1
|
+
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,n,i,r={exports:{}},s=t((e||(e=1,n=r.exports,i=function(){var t=function(){},e="undefined",n=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],r={},s=null;function o(t,e){var n=t[e];if("function"==typeof n.bind)return n.bind(t);try{return Function.prototype.bind.call(n,t)}catch(e){return function(){return Function.prototype.apply.apply(n,[t,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var n=this.getLevel(),r=0;r<i.length;r++){var s=i[r];this[s]=r<n?t:this.methodFactory(s,n,this.name)}if(this.log=this.debug,typeof console===e&&n<this.levels.SILENT)return"No console available for logging"}function h(t){return function(){typeof console!==e&&(c.call(this),this[t].apply(this,arguments))}}function a(i,r,s){return function(i){return"debug"===i&&(i="log"),typeof console!==e&&("trace"===i&&n?u:void 0!==console[i]?o(console,i):void 0!==console.log?o(console,"log"):t)}(i)||h.apply(this,arguments)}function l(t,n){var o,u,h,l=this,f="loglevel";function d(){var t;if(typeof window!==e&&f){try{t=window.localStorage[f]}catch(t){}if(typeof t===e)try{var n=window.document.cookie,i=encodeURIComponent(f),r=n.indexOf(i+"=");-1!==r&&(t=/^([^;]+)/.exec(n.slice(r+i.length+1))[1])}catch(t){}return void 0===l.levels[t]&&(t=void 0),t}}function g(t){var e=t;if("string"==typeof e&&void 0!==l.levels[e.toUpperCase()]&&(e=l.levels[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=l.levels.SILENT)return e;throw new TypeError("log.setLevel() called with invalid level: "+t)}"string"==typeof t?f+=":"+t:"symbol"==typeof t&&(f=void 0),l.name=t,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=n||a,l.getLevel=function(){return null!=h?h:null!=u?u:o},l.setLevel=function(t,n){return h=g(t),!1!==n&&function(t){var n=(i[t]||"silent").toUpperCase();if(typeof window!==e&&f){try{return void(window.localStorage[f]=n)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"="+n+";"}catch(t){}}}(h),c.call(l)},l.setDefaultLevel=function(t){u=g(t),d()||l.setLevel(t,!1)},l.resetLevel=function(){h=null,function(){if(typeof window!==e&&f){try{window.localStorage.removeItem(f)}catch(t){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(t){}}}(),c.call(l)},l.enableAll=function(t){l.setLevel(l.levels.TRACE,t)},l.disableAll=function(t){l.setLevel(l.levels.SILENT,t)},l.rebuild=function(){if(s!==l&&(o=g(s.getLevel())),c.call(l),s===l)for(var t in r)r[t].rebuild()},o=g(s?s.getLevel():"WARN");var A=d();null!=A&&(h=g(A)),c.call(l)}(s=new l).getLogger=function(t){if("symbol"!=typeof t&&"string"!=typeof t||""===t)throw new TypeError("You must supply a name when creating a logger.");var e=r[t];return e||(e=r[t]=new l(t,s.methodFactory)),e};var f=typeof window!==e?window.log:void 0;return s.noConflict=function(){return typeof window!==e&&window.log===s&&(window.log=f),s},s.getLoggers=function(){return r},s.default=s,s},r.exports?r.exports=i():n.log=i()),r.exports));let o=[],u=null;function c(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function h(t){return"string"==typeof t&&t.trim().length>0}function a(t){return void 0===t||"string"==typeof t}function l(t){return!(!c(t)||!Array.isArray(t.data)||0===t.data.length)&&t.data.every((t=>function(t){return!!c(t)&&h(t.id)&&("job-title"===t.type||"occupation-name"===t.type)&&h(t.preferred_label)&&a(t.ssyk_level_4_id)&&a(t.ssyk_code_2012)&&a(t.occupation_name_id)&&a(t.occupation_name_preferred_label)&&(void 0===t.weight||"number"==typeof t.weight&&Number.isFinite(t.weight))&&(void 0===t.search_aliases||Array.isArray(t.search_aliases)&&t.search_aliases.every((t=>"string"==typeof t)))}(t)))}function f(t){if(!l(t))return void s.error("[TaxonomyRegistry] Felaktigt format på taxonomidata vid registrering.");o=function(t){const e=new Map;return t.filter((t=>{const n="job-title"===t.type?t.occupation_name_id??"":"",i=e.get(t.id)??new Set;return!i.has(n)&&(i.add(n),e.set(t.id,i),!0)}))}(t.data).map((t=>({...t})));const e=c(t.metadata)?t.metadata.labour_market_taxonomy_version:void 0;u=void 0!==e?String(e):void 0!==t.taxonomyVersion?String(t.taxonomyVersion):"unknown",s.debug(`[TaxonomyRegistry] Taxonomi version ${u} registrerades med ${o.length} yrken.`)}function d(){return 0===o.length&&s.warn("[TaxonomyRegistry] Ingen taxonomi är registrerad ännu! Anropa registerTaxonomy(data) först."),o}function g(t){return Array.isArray?Array.isArray(t):"[object Array]"===m(t)}function A(t){return null==t?"":function(t){if("string"==typeof t)return t;if("bigint"==typeof t)return t.toString();const e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}function p(t){return"string"==typeof t}function y(t){return"number"==typeof t}function C(t){return"object"==typeof t}function v(t){return null!=t}function w(t){return!t.trim().length}function m(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const M="Invalid doc index: must be a non-negative integer within the bounds of the docs array",F=Object.prototype.hasOwnProperty;var D=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{const n=B(t);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function B(t){let e=null,n=null,i=null,r=1,s=null;if(p(t)||g(t))i=t,e=E(t),n=x(t);else{if(!F.call(t,"name"))throw new Error("Missing name property in key");const o=t.name;if(i=o,F.call(t,"weight")&&void 0!==t.weight&&(r=t.weight,r<=0))throw new Error((t=>`Property 'weight' in key '${t}' must be a positive integer`)(x(o)));e=E(o),n=x(o),s=t.getFn??null}return{path:e,id:n,weight:r,src:i,getFn:s}}function E(t){return g(t)?t:t.split(".")}function x(t){return g(t)?t.join("."):t}const b=Object.freeze({isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:function(t,e){const n=[];let i=!1;const r=(t,e,s,o)=>{if(v(t))if(e[s]){const u=t[e[s]];if(!v(u))return;if(s===e.length-1&&(p(u)||y(u)||function(t){return!0===t||!1===t||function(t){return C(t)&&null!==t}(t)&&"[object Boolean]"==m(t)}(u)||"bigint"==typeof u))n.push(void 0!==o?{v:A(u),i:o}:A(u));else if(g(u)){i=!0;for(let t=0,n=u.length;t<n;t+=1)r(u[t],e,s+1,t)}else e.length&&r(u,e,s+1,o)}else n.push(void 0!==o?{v:t,i:o}:t)};return r(t,p(e)?e.split("."):e,0),i?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1});var k=class{constructor({getFn:t=b.getFn,fieldNormWeight:e=b.fieldNormWeight}={}){this.norm=function(t=1,e=3){const n=new Map,i=Math.pow(10,e);return{get(e){let r=0,s=!1;for(let t=0;t<e.length;t++)(o=e.charCodeAt(t))>=9&&o<=13||32===o||160===o?s=!1:s||(r++,s=!0);var o;if(0===r&&(r=1),n.has(r))return n.get(r);const u=Math.round(i/Math.pow(r,.5*t))/i;return n.set(r,u),u},clear(){n.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(p(this.docs[0]))for(let n=0;n<t;n++){const t=this._createStringRecord(this.docs[n],n);t&&(this.records[e++]=t)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(M);if(p(t)){const n=this._createStringRecord(t,e);return n&&this.records.push(n),n}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(M);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const n of t)Number.isInteger(n)&&n>=0&&e.add(n);if(0===e.size)return;this.records=this.records.filter((t=>!e.has(t.i)));const n=Array.from(e).sort(((t,e)=>t-e));for(const t of this.records){let e=0,i=n.length;for(;e<i;){const r=e+i>>>1;n[r]<t.i?e=r+1:i=r}t.i-=e}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!v(t)||w(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let e=0,i=this.keys.length;e<i;e++){const i=this.keys[e],r=i.getFn?i.getFn(t):this.getFn(t,i.path);if(v(r))if(g(r)){const t=[];for(let e=0,n=r.length;e<n;e+=1){const n=r[e];if(v(n))if(p(n)){if(!w(n)){const i={v:n,i:e,n:this.norm.get(n)};t.push(i)}}else if(v(n.v)){const e=p(n.v)?n.v:A(n.v);if(!w(e)){const i={v:e,i:n.i,n:this.norm.get(e)};t.push(i)}}}n.$[e]=t}else if(p(r)&&!w(r)){const t={v:r,n:this.norm.get(r)};n.$[e]=t}}return n}toJSON(){return{keys:this.keys.map((({getFn:t,...e})=>e)),records:this.records}}};function S(t,e,{getFn:n=b.getFn,fieldNormWeight:i=b.fieldNormWeight}={}){const r=new k({getFn:n,fieldNormWeight:i});return r.setKeys(t.map(B)),r.setSources(e),r.create(),r}function $(t){const e={};for(let n=0,i=t.length;n<i;n+=1){const r=t.charAt(n);e[r]=(e[r]||0)|1<<i-n-1}return e}function N(t){if(t.length<=1)return t;t.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]));const e=[t[0]];for(let n=1,i=t.length;n<i;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const L={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},I=new RegExp("["+Object.keys(L).join("")+"]","g"),R="function"==typeof String.prototype.normalize?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(I,(t=>L[t])):t=>t;var _=class{constructor(t,{location:e=b.location,threshold:n=b.threshold,distance:i=b.distance,includeMatches:r=b.includeMatches,findAllMatches:s=b.findAllMatches,minMatchCharLength:o=b.minMatchCharLength,isCaseSensitive:u=b.isCaseSensitive,ignoreDiacritics:c=b.ignoreDiacritics,ignoreLocation:h=b.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:i,includeMatches:r,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:h},t=u?t:t.toLowerCase(),t=c?R(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const a=(t,e)=>{this.chunks.push({pattern:t,alphabet:$(t),startIndex:e})},l=this.pattern.length;if(l>32){let t=0;const e=l%32,n=l-e;for(;t<n;)a(this.pattern.substr(t,32),t),t+=32;if(e){const t=l-32;a(this.pattern.substr(t),t)}}else a(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=e?t:t.toLowerCase(),t=n?R(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const e={isMatch:!0,score:0};return i&&(e.indices=[[0,t.length-1]]),e}const{location:r,distance:s,threshold:o,findAllMatches:u,minMatchCharLength:c,ignoreLocation:h}=this.options,a=[];let l=0,f=!1;this.chunks.forEach((({pattern:e,alphabet:n,startIndex:d})=>{const{isMatch:g,score:A,indices:p}=function(t,e,n,{location:i=b.location,distance:r=b.distance,threshold:s=b.threshold,findAllMatches:o=b.findAllMatches,minMatchCharLength:u=b.minMatchCharLength,includeMatches:c=b.includeMatches,ignoreLocation:h=b.ignoreLocation}={}){if(e.length>32)throw new Error("Pattern length exceeds max of 32.");const a=e.length,l=t.length,f=Math.max(0,Math.min(i,l));let d=s,g=f;const A=(t,e)=>{const n=t/a;if(h)return n;const i=Math.abs(f-e);return r?n+i/r:i?1:n},p=u>1||c,y=p?Array(l):[];let C;for(;(C=t.indexOf(e,g))>-1;){const t=A(0,C);if(d=Math.min(t,d),g=C+a,p){let t=0;for(;t<a;)y[C+t]=1,t+=1}}g=-1;let v=[],w=1,m=0,M=a+l;const F=1<<a-1;for(let e=0;e<a;e+=1){let i=0,r=M;for(;i<r;)A(e,f+r)<=d?i=r:M=r,r=Math.floor((M-i)/2+i);M=r;let s=Math.max(1,f-r+1);const u=o?l:Math.min(f+r,l)+a,c=Array(u+2);c[u+1]=(1<<e)-1;for(let i=u;i>=s;i-=1){const r=i-1;if(c[i]=(c[i+1]<<1|1)&n[t[r]],e&&(c[i]|=(v[i+1]|v[i])<<1|1|v[i+1]),c[i]&F&&(w=A(e,r),w<=d)){if(d=w,g=r,m=e,g<=f)break;s=Math.max(1,2*f-g)}}if(A(e+1,f)>d)break;v=c}if(p&&g>=0){const e=Math.min(l-1,g+a-1+m);for(let i=g;i<=e;i+=1)n[t[i]]&&(y[i]=1)}const D={isMatch:g>=0,score:Math.max(.001,w)};if(p){const t=function(t=[],e=b.minMatchCharLength){const n=[];let i=-1,r=-1,s=0;for(let o=t.length;s<o;s+=1){const o=t[s];o&&-1===i?i=s:o||-1===i||(r=s-1,r-i+1>=e&&n.push([i,r]),i=-1)}return t[s-1]&&s-i>=e&&n.push([i,s-1]),n}(y,u);t.length?c&&(D.indices=t):D.isMatch=!1}return D}(t,e,n,{location:r+d,distance:s,threshold:o,findAllMatches:u,minMatchCharLength:c,includeMatches:i,ignoreLocation:h});g&&(f=!0),l+=A,g&&p&&a.push(...p)}));const d={isMatch:f,score:f?l/this.chunks.length:1};return f&&i&&(d.indices=N(a)),d}};const j=new Set(["fuzzy","include"]),T=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n,i=0;const r=[],s=t.length;for(;(n=e.indexOf(t,i))>-1;)i=n+s,r.push([n,i-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=-1===e.indexOf(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new _(t,{location:e.location??b.location,threshold:e.threshold??b.threshold,distance:e.distance??b.distance,includeMatches:e.includeMatches??b.includeMatches,findAllMatches:e.findAllMatches??b.findAllMatches,minMatchCharLength:e.minMatchCharLength??b.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??b.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??b.ignoreDiacritics,ignoreLocation:e.ignoreLocation??b.ignoreLocation});return{type:"fuzzy",search:t=>n.searchIn(t)}}}],z=T.length;function O(t,e){const n=t.match(e);return n?n[1]:null}const W=[];function U(...t){W.push(...t)}function G(t,e){for(let n=0,i=W.length;n<i;n+=1){const i=W[n];if(i.condition(t,e))return new i(t,e)}return new _(t,e)}const J="$and",P="$path",K=t=>!(!t[J]&&!t.$or),Y=t=>({[J]:Object.keys(t).map((e=>({[e]:t[e]})))});function H(t,e,{auto:n=!0}={}){const i=t=>{if(p(t)){const i={keyId:null,pattern:t};return n&&(i.searcher=G(t,e)),i}const r=Object.keys(t),s=(t=>!!t[P])(t);if(!s&&r.length>1&&!K(t))return i(Y(t));if((t=>!g(t)&&C(t)&&!K(t))(t)){const i=s?t[P]:r[0],o=s?t.$val:t[i];if(!p(o))throw new Error((t=>`Invalid value for key ${t}`)(i));const u={keyId:x(i),pattern:o};return n&&(u.searcher=G(o,e)),u}const o={children:[],operator:r[0]};return r.forEach((e=>{const n=t[e];g(n)&&n.forEach((t=>{o.children.push(i(t))}))})),o};return K(t)||(t=Y(t)),i(t)}function q(t,{ignoreFieldNorm:e=b.ignoreFieldNorm}){let n=1;return t.forEach((({key:t,norm:i,score:r})=>{const s=t?t.weight:null;n*=Math.pow(0===r&&s?Number.EPSILON:r,(s||1)*(e?1:i))})),n}var V=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const i=e[t];e[t]=e[n],e[n]=i,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let i=t;do{const r=2*(t=i)+1,s=2*t+2;if(r<n&&this.comparator(e[r],e[i])>0&&(i=r),s<n&&this.comparator(e[s],e[i])>0&&(i=s),i!==t){const n=e[t];e[t]=e[i],e[i]=n}}while(i!==t)}};const Q=/[\p{L}\p{M}\p{N}_]+/gu,X=new WeakSet;function Z({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const i=function(t){if("function"==typeof t){let e=!1;return n=>{const i=t(n);if(!e&&(e=!0,!Array.isArray(i)||i.some((t=>"string"!=typeof t))))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(i)?"array containing non-strings":typeof i}.`);return i}}return t instanceof RegExp?(t.global||X.has(e=t)||(X.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`)),e=>e.match(t)||[]):t=>t.match(Q)||[];var e}(n);return{tokenize:n=>(t||(n=n.toLowerCase()),e&&(n=R(n)),i(n))}}function tt(t,e,n,i){const r=i.tokenize(e);if(!r.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const s=new Set(r);let o=t.docTermFieldHits.get(n);o||(o=new Map,t.docTermFieldHits.set(n,o));for(const e of s)o.set(e,(o.get(e)||0)+1),t.df.set(e,(t.df.get(e)||0)+1)}function et(t,e,n,i){const{i:r,v:s,$:o}=e;if(void 0===s){if(o)for(let e=0;e<n;e++){const n=o[e];if(n)if(Array.isArray(n))for(const e of n)tt(t,e.v,r,i);else tt(t,n.v,r,i)}}else tt(t,s,r,i)}function nt(t,e){const n=t.docFieldCount.get(e);if(void 0===n)return;t.fieldCount-=n,t.docFieldCount.delete(e);const i=t.docTermFieldHits.get(e);if(i){for(const[e,n]of i){const i=(t.df.get(e)||0)-n;i<=0?t.df.delete(e):t.df.set(e,i)}t.docTermFieldHits.delete(e)}}function it(t,e){if(0===e.length)return;const n=Array.from(new Set(e)).sort(((t,e)=>t-e));for(const e of n)nt(t,e);const i=t=>{let e=0,i=n.length;for(;e<i;){const r=e+i>>>1;n[r]<t?e=r+1:i=r}return t-e},r=n[0],s=new Map;for(const[e,n]of t.docFieldCount)s.set(e>r?i(e):e,n);t.docFieldCount=s;const o=new Map;for(const[e,n]of t.docTermFieldHits)o.set(e>r?i(e):e,n);t.docTermFieldHits=o}var rt=class{constructor(t,e,n){this.options={...b,...e},this._keyStore=new D(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=G(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof k))throw new Error("Incorrect 'index' type");if(this._myIndex=e||S(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const t=Z({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=function(t,e,n){const i={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const r of t)et(i,r,e,n);return i}(this._myIndex.records,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}add(t){if(!v(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const t=Z({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});!function(t,e,n,i){et(t,e,n,i)}(this._invertedIndex,e,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let i=0,r=this._docs.length;i<r;i+=1)t(this._docs[i],i)&&(e.push(this._docs[i]),n.push(i));if(n.length){this._invertedIndex&&it(this._invertedIndex,n);const t=new Set(n);this._docs=this._docs.filter(((e,n)=>!t.has(n))),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(M);this._invertedIndex&&it(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map((t=>this._keyStore.get(t.id)||t))}search(t,e){const{limit:n=-1}=e||{},{includeMatches:i,includeScore:r,shouldSort:s,sortFn:o,ignoreFieldNorm:u}=this.options;if(p(t)&&!t.trim()){let t=this._docs.map(((t,e)=>({item:t,refIndex:e})));return y(n)&&n>-1&&(t=t.slice(0,n)),t}const c=s&&y(n)&&n>0&&p(t),h=o,a=(t,e)=>h(t,e)||t.idx-e.idx;let l;if(c){const e=new V(n,a);p(this._docs[0])?this._searchStringList(t,{heap:e,ignoreFieldNorm:u}):this._searchObjectList(t,{heap:e,ignoreFieldNorm:u}),l=e.extractSorted()}else l=p(t)?p(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),function(t,{ignoreFieldNorm:e=b.ignoreFieldNorm}){t.forEach((t=>{t.score=q(t.matches,{ignoreFieldNorm:e})}))}(l,{ignoreFieldNorm:u}),s&&l.sort(p(t)?a:h),y(n)&&n>-1&&(l=l.slice(0,n));return function(t,e,{includeMatches:n=b.includeMatches,includeScore:i=b.includeScore}={}){return t.map((t=>{const{idx:r}=t,s={item:e[r],refIndex:r};return n&&(s.matches=function(t){const e=[];return t.matches.forEach((t=>{if(!v(t.indices)||!t.indices.length)return;const n={indices:t.indices,value:t.value};t.key&&(n.key=t.key.id),t.idx>-1&&(n.refIndex=t.idx),e.push(n)})),e}(t)),i&&(s.score=t.score),s}))}(l,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const i=this._getSearcher(t),r=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{records:s}=this._myIndex,o=e?null:[];return s.forEach((({v:t,i:s,n:u})=>{if(!v(t))return;const c=i.searchIn(t);if(c.isMatch){const i={score:c.score,value:t,norm:u,indices:c.indices};r&&(i.matchedMask=c.matchedMask,i.matchedTerms=c.matchedTerms,i.termCount=c.termCount);const h=[i];if(!r||this._coversAllTokens(h)){const i={item:t,idx:s,matches:h};e?(i.score=q(i.matches,{ignoreFieldNorm:n}),e.insert(i)):o.push(i)}}})),o}_searchLogical(t){const e=H(t,this.options),n=this._normalizedKeys(),i=(t,e,r)=>{if(!("children"in t)){const{keyId:i,searcher:s}=t;let o;return null===i?(o=[],n.forEach(((t,n)=>{o.push(...this._findMatches({key:t,value:e[n],searcher:s}))}))):o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(e,i),searcher:s}),o&&o.length?[{idx:r,item:e,matches:o}]:[]}const{children:s,operator:o}=t,u=[];for(let t=0,n=s.length;t<n;t+=1){const n=i(s[t],e,r);if(n.length)u.push(...n);else if(o===J)return[]}return u},r=this._myIndex.records,s=new Map,o=[];return r.forEach((({$:t,i:n})=>{if(v(t)){const r=i(e,t,n);r.length&&(s.has(n)||(s.set(n,{idx:n,item:t,matches:[]}),o.push(s.get(n))),r.forEach((({matches:t})=>{s.get(n).matches.push(...t)})))}})),o}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const i=this._getSearcher(t),r=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{records:s}=this._myIndex,o=this._normalizedKeys(),u=e?null:[];return s.forEach((({$:t,i:s})=>{if(!v(t))return;const c=[];let h=!1,a=!1;if(o.forEach(((e,n)=>{const r=this._findMatches({key:e,value:t[n],searcher:i});r.length?(c.push(...r),r[0].hasInverse&&(a=!0)):h=!0})),(!a||!h)&&c.length&&(!r||this._coversAllTokens(c))){const i={idx:s,item:t,matches:c};e?(i.score=q(i.matches,{ignoreFieldNorm:n}),e.insert(i)):u.push(i)}})),u}_findMatches({key:t,value:e,searcher:n}){if(!v(e))return[];const i=[];if(g(e))e.forEach((({v:e,i:r,n:s})=>{if(!v(e))return;const o=n.searchIn(e);if(o.isMatch){const n={score:o.score,key:t,value:e,idx:r,norm:s,indices:o.indices,hasInverse:o.hasInverse};void 0!==o.termCount&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),i.push(n)}}));else{const{v:r,n:s}=e,o=n.searchIn(r);if(o.isMatch){const e={score:o.score,key:t,value:r,norm:s,indices:o.indices,hasInverse:o.hasInverse};void 0!==o.termCount&&(e.matchedMask=o.matchedMask,e.matchedTerms=o.matchedTerms,e.termCount=o.termCount),i.push(e)}}return i}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(void 0===e)return!0;if(e<=31){let n=0;for(let e=0;e<t.length;e++)n|=t[e].matchedMask||0;return n===2**e-1}const n=new Set;for(let e=0;e<t.length;e++){const i=t[e].matchedTerms;if(i)for(const t of i)n.add(t)}return n.size===e}};rt.version="7.5.0",rt.createIndex=S,rt.parseIndex=function(t,{getFn:e=b.getFn,fieldNormWeight:n=b.fieldNormWeight}={}){const{keys:i,records:r}=t,s=new k({getFn:e,fieldNormWeight:n});return s.setKeys(i),s.setIndexRecords(r),s},rt.config=b,rt.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error("Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.");return G(t,{...b,...n}).searchIn(e)},rt.parseQuery=H,U(class{constructor(t,{isCaseSensitive:e=b.isCaseSensitive,ignoreDiacritics:n=b.ignoreDiacritics,includeMatches:i=b.includeMatches,minMatchCharLength:r=b.minMatchCharLength,ignoreLocation:s=b.ignoreLocation,findAllMatches:o=b.findAllMatches,location:u=b.location,threshold:c=b.threshold,distance:h=b.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:r,findAllMatches:o,ignoreLocation:s,location:u,threshold:c,distance:h},t=e?t:t.toLowerCase(),t=n?R(t):t,this.pattern=t,this.query=function(t,e={}){return t.replace(/\\\|/g,"\0").split("|").map((t=>{const n=function(t){const e=[],n=t.length;let i=0;for(;i<n;){for(;i<n&&" "===t[i];)i++;if(i>=n)break;let r=i;for(;r<n&&" "!==t[r]&&'"'!==t[r];)r++;if(r<n&&'"'===t[r]){for(r++;r<n;){if('"'===t[r]){const e=r+1;if(e>=n||" "===t[e]){r++;break}if("$"===t[e]&&(e+1>=n||" "===t[e+1])){r+=2;break}}r++}e.push(t.substring(i,r)),i=r}else{for(;r<n&&" "!==t[r];)r++;e.push(t.substring(i,r)),i=r}}return e}(t.replace(/\u0000/g,"|").trim()).filter((t=>t&&!!t.trim())),i=[];for(let t=0,r=n.length;t<r;t+=1){const r=n[t];let s=!1,o=-1;for(;!s&&++o<z;){const t=T[o],n=O(r,t.multiRegex);n&&(i.push(t.create(n,e)),s=!0)}if(!s)for(o=-1;++o<z;){const t=T[o],n=O(r,t.singleRegex);if(n){i.push(t.create(n,e));break}}}return i}))}(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:r}=this.options;t=i?t:t.toLowerCase(),t=r?R(t):t;let s=0;const o=[];let u=0,c=!1;for(let i=0,r=e.length;i<r;i+=1){const r=e[i];o.length=0,s=0,c=!1;for(let e=0,i=r.length;e<i;e+=1){const i=r[e],{isMatch:h,indices:a,score:l}=i.search(t);if(!h){u=0,s=0,o.length=0,c=!1;break}s+=1,u+=l,i.type.startsWith("inverse")&&(c=!0),n&&(j.has(i.type)?o.push(...a):o.push(a))}if(s){const t={isMatch:!0,score:u/s};return c&&(t.hasInverse=!0),n&&(t.indices=N(o)),t}}return{isMatch:!1,score:1}}}),U(class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Z({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:i,fieldCount:r}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const t of n){this.termSearchers.push(new _(t,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const n=i.get(t)||0,s=Math.log(1+(r-n+.5)/(n+.5));this.idfWeights.push(s)}this.combineAll="all"===e.tokenMatch,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,i=0,r=0,s=0;const o=this.combineAll&&!this.useMask?new Set:null;for(let u=0;u<this.termSearchers.length;u++){const c=this.termSearchers[u].searchIn(t),h=this.idfWeights[u];i+=h,c.isMatch&&(r++,n+=h*(1-c.score),c.indices&&e.push(...c.indices),this.combineAll&&(this.useMask?s|=1<<u:o.add(u)))}if(0===r)return{isMatch:!1,score:1};const u={isMatch:!0,score:Math.max(.001,i>0?1-n/i:0)};return this.options.includeMatches&&e.length&&(u.indices=N(e)),this.combineAll&&(this.useMask?u.matchedMask=s:u.matchedTerms=o,u.termCount=this.numTerms),u}}),rt.use=function(...t){t.forEach((t=>U(t)))};var st=rt;const ot=1,ut=100,ct=20,ht={keys:["preferred_label"],includeScore:!0,ignoreDiacritics:!0,ignoreFieldNorm:!0,threshold:.6,minMatchCharLength:1,ignoreLocation:!0,distance:100},at="T.ex. målare, florist, kock",lt={format:(t,e,n)=>{const i=function(t,e){if(!t)return[];if(!e||0===e.trim().length)return[{text:t,isMatch:!1}];const n=t.toLowerCase(),i=e.toLowerCase().split(/\s+/).filter((t=>t.length>0)),r=new Set;if(i.forEach((t=>{let e=0;for(;-1!==(e=n.indexOf(t,e));){for(let n=0;n<t.length;n++)r.add(e+n);e+=t.length}})),0===r.size&&i.forEach((e=>{const n=function(t,e){const n=t.toLowerCase(),i=e.length;let r=99,s=-1,o=0;const u=Math.max(3,i-2),c=Math.min(n.length,i+2);for(let t=0;t<=n.length-u;t++)for(let i=u;i<=c&&t+i<=n.length;i++){const u=ft(e,n.slice(t,t+i));u<r&&(r=u,s=t,o=i)}return r<=Math.max(2,Math.floor(.25*i))&&-1!==s?{start:s,length:o}:null}(t,e);if(n)for(let t=0;t<n.length;t++)r.add(n.start+t)})),0===r.size)return[{text:t,isMatch:!1}];const s=[];let o="",u=r.has(0);for(let e=0;e<t.length;e++){const n=r.has(e);n!==u?(o.length>0&&s.push({text:o,isMatch:u}),o=t[e],u=n):o+=t[e]}return o.length>0&&s.push({text:o,isMatch:u}),s}(t,e);return n?[...i,{text:" ",isMatch:!1},{text:`(${n})`,isMetadata:!0}]:i}};function ft(t,e){const n=t.length,i=e.length,r=Array.from({length:n+1},(()=>new Array(i+1).fill(0)));for(let t=0;t<=n;t++)r[t][0]=t;for(let t=0;t<=i;t++)r[0][t]=t;for(let s=1;s<=n;s++)for(let n=1;n<=i;n++)r[s][n]=t[s-1]===e[n-1]?r[s-1][n-1]:1+Math.min(r[s-1][n],r[s][n-1],r[s-1][n-1]);return r[n][i]}s.setLevel(s.levels.DEBUG);const dt=t=>t?t.toLowerCase().trim():"";function gt(t,e){return t.id&&e.id?t.id===e.id&&(t.occupationId??t.occupation_name_id??"")===(e.occupationId??e.occupation_name_id??""):t.rawLabel===e.rawLabel}function At(t){return t.sort(((t,e)=>{const n=t.score??0,i=e.score??0;if(n!==i)return i-n;const r=t.weight??0,s=e.weight??0;return r!==s?s-r:t.displayLabel.localeCompare(e.displayLabel,"sv")}))}function pt(t){return t.map((t=>t.isMatch?`<strong>${t.text}</strong>`:t.isMetadata?`<span class="occupation-variant-label">${t.text}</span>`:t.text)).join("")}const yt=t=>t?t.replace(/ (\([^)]+\))/g,' <span class="occupation-variant-label">$1</span>'):"";function Ct(t,e,n){return t===e?1:n.length>1?n.every((e=>t.includes(e)))?.98:null:t.startsWith(e)?.99:t.includes(e)?.95:null}function vt(t,e){const n=t.length,i=e.length,r=Array.from({length:n+1},(()=>new Array(i+1).fill(0)));for(let t=0;t<=n;t++)r[t][0]=t;for(let t=0;t<=i;t++)r[0][t]=t;for(let s=1;s<=n;s++)for(let n=1;n<=i;n++)r[s][n]=t[s-1]===e[n-1]?r[s-1][n-1]:1+Math.min(r[s-1][n],r[s][n-1],r[s-1][n-1]);return r[n][i]}function wt(t,e){const n=t.toLowerCase().trim(),i=e.toLowerCase().trim();return i.includes(" ")?vt(n,i)<=Math.max(2,Math.floor(.25*n.length))&&Math.abs(n.length-i.length)<=2:null!==function(t,e){const n=t.toLowerCase(),i=e.length;let r=99;const s=Math.max(3,i-2),o=Math.min(n.length,i+2);for(let t=0;t<=n.length-s;t++)for(let i=s;i<=o&&t+i<=n.length;i++){const s=vt(e,n.slice(t,t+i));s<r&&(r=s)}return r<=Math.max(2,Math.floor(.25*i))?r:null}(i,n)}function mt(t,e){return(t.search_aliases??[]).some((t=>dt(t)===e))}function Mt(t,e,n){const i=function(t){return t.occupation_name_preferred_label?`${t.preferred_label||""} (${t.occupation_name_preferred_label})`:t.preferred_label||""}(t),r=lt.format(t.preferred_label||"",e,t.occupation_name_preferred_label);return{id:t.id,type:t.type,preferred_label:t.preferred_label||"",rawLabel:t.preferred_label||"",displayLabel:i,highlightedLabel:pt(r),displaySegments:r,weight:t.weight??0,score:n,occupationId:t.occupation_name_id,occupationLabel:t.occupation_name_preferred_label,ssyk_level_4_id:t.ssyk_level_4_id,ssyk_code_2012:t.ssyk_code_2012}}function Ft(t){return"job-title"===t.type?`${t.id}|${t.occupation_name_id??""}`:t.id}function Dt(t,e,n,i){if(!n)return[];if(!e||!Array.isArray(e))return s.warn("[searchConcepts] Ogiltig items array."),[];if(!t||t.length<1)return[];const r=dt(t),o=r.split(" ").filter((t=>t.length>0)),u=[],c=new Set;for(const n of e){const e=Ct(dt(n.preferred_label),r,o),i=mt(n,r)?1:e;null!==i&&(u.push(Mt(n,t,i)),c.add(Ft(n)))}if(u.length>0)return At(u).slice(0,i);if(n){const e=n.search(r);if(0===e.length)return[];const s=e[0].score??1,o=[];let u=!1;for(const n of e){const e=Ft(n.item);if(c.has(e))continue;const i=n.score??1,h=1-i;if(h<.4)continue;if(i>s+.12)continue;const a=dt(n.item.preferred_label),l=n.item.weight??0,f=wt(r,a);f&&i<=.25&&(u=!0);let d=.7*h+.1*l;f&&(d+=.12);const g=Math.min(.84,Math.max(.4,d));o.push(Mt(n.item,t,g)),c.add(e)}const h=At(o);if(0===h.length)return[];const a=u?Math.min(5,i):Math.min(3,i);return h.slice(0,a)}return[]}const Bt={toGenericItem:t=>({id:t.id,label:t.preferred_label||"",description:t.occupation_name_preferred_label,metadata:{original:t,type:t.type,ssyk_level_4_id:t.ssyk_level_4_id,weight:t.weight}}),searchResultToGenericItem(t,e){const n=lt.format(t.preferred_label||"",e,t.occupation_name_preferred_label);return{id:t.id,label:t.preferred_label||"",displaySegments:n,highlightedLabel:pt(n),metadata:{original:t,ssyk_level_4_id:t.ssyk_level_4_id,weight:t.weight}}},fromGenericItem:t=>({id:t.id,preferred_label:t.label,weight:t.metadata?.weight,...t.metadata?.original}),toPublicSelection(t,e){const n=t.id||"",i=t.preferred_label||t.rawLabel||"";if(!n)return{type:"manual-input",id:null,preferred_label:i};if("job-title"!==t.type&&"occupation-name"!==t.type)throw new Error(`Ogiltig intern yrkestyp för ${n}: ${t.type}`);const r={type:t.type,id:n,preferred_label:i};t.ssyk_code_2012&&(r.ssyk_code_2012=t.ssyk_code_2012);const s=t.occupation_name_id||t.occupationId;if("job-title"===t.type&&s){const n=t.occupation_name_preferred_label?.trim()||t.occupationLabel?.trim();r.related={type:"occupation-name",id:s,preferred_label:n||e?.(s)||s}}return r}};class Et{fuseInstance=null;items=[];constructor(t){this.items=t,this.fuseInstance=new st(t,ht)}search(t,e=20){return this.fuseInstance?Dt(t,this.items,this.fuseInstance,e).map((t=>Bt.toPublicSelection(t))):[]}searchAsGeneric(t,e=20){return this.fuseInstance?Dt(t,this.items,this.fuseInstance,e).map((t=>({id:t.id,label:t.displayLabel,description:t.occupationLabel,group:"job-title"===t.type?"Yrke":"Yrkesgrupp",metadata:{originalResult:t,highlightedLabel:t.highlightedLabel,score:t.score,weight:t.weight}}))):[]}updateData(t){this.items=t,this.fuseInstance=new st(t,ht)}}class xt extends Error{code;invalidIds;constructor(t,e,n){super(t),this.name="InvalidSelectionError",this.code=e,this.invalidIds=n}}export{ut as D,xt as I,lt as L,ct as M,at as P,Et as T,Bt as a,l as b,ot as c,yt as d,d as g,gt as i,s as l,f as r,pt as s}
|