/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
import { r as registerInstance, h, H as Host, a as getElement } from './index-Bf4Ol6Qt.js';
import { c as create$3, d as sharedLocalesSchema } from './types-BDhR4pDq.js';
import { m as manufacturerSchema, d as deadStockSchema } from './type-C2SCytyp.js';
import { d as distributerSchema } from './type-8o_W9bXK.js';
import { V as VehicleInfoLayout } from './vehicle-info-layout-Cp9U6H1C.js';
import { a as getLocaleLanguage, g as getSharedLocal } from './get-local-language-CE9dtbnG.js';
import { s as smartInvokable } from './smart-invokable-6IrGK81y.js';
import './cn-BK16Cn81.js';

const partLookupWrapperSchema = create$3({
    deadStock: deadStockSchema,
    distributor: distributerSchema,
    manufacturer: manufacturerSchema,
});

const partLookupCss = "*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.\\!pointer-events-none{pointer-events:none!important}.absolute{position:absolute}.\\!relative{position:relative!important}.relative{position:relative}.left-0{left:0}.top-0{top:0}.z-10{z-index:10}.block{display:block}.flex{display:flex}.hidden{display:none}.origin-left{transform-origin:left}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\\!overflow-hidden{overflow:hidden!important}.rounded-\\[4px\\]{border-radius:4px}.border{border-width:1px}.opacity-0{opacity:0}.opacity-100{opacity:1}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-500{transition-duration:.5s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.shift-skeleton{border-radius:4px;position:relative!important}.loading .shift-skeleton,.loading.shift-skeleton{border-style:none!important;overflow:hidden!important;pointer-events:none!important;position:relative!important}.shift-skeleton:after{background:linear-gradient(-45deg,#d4d8de,#e2e5e9,#d4d8de);background-size:300% 300%;border-radius:inherit!important;content:\"\";height:100%;left:0;opacity:0;pointer-events:none;position:absolute;top:0;transform-origin:left;transition-duration:.5s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);width:100%;z-index:10}.loading .shift-skeleton:after,.loading.shift-skeleton:after{--tw-scale-x:1;animation:shimmer 2s ease-in-out infinite;opacity:1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes shimmer{0%{background-position:100% 0}50%{background-position:0 100%}to{background-position:100% 0}}.vehicle-info-container{background-color:#fdfdfd;border:1px solid #dcdcdc;border-radius:5px;box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 hsla(0,0%,100%,.1);overflow:hidden;padding:0;position:relative;transition-duration:.5s;transition-property:all}::-webkit-scrollbar{height:10px;width:10px}::-webkit-scrollbar-track{background:#f6f6f6;border-radius:5px;border-top:1px solid #dcdcdc;border-top-left-radius:0;border-top-right-radius:0}::-webkit-scrollbar-thumb{background:#c5c5c5;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:#a1a1a1}.hide-scroll ::-webkit-scrollbar-thumb,.hide-scroll::-webkit-scrollbar-thumb,.loading ::-webkit-scrollbar-thumb{background:transparent}.vehicle-info-body{display:flex;flex-direction:column;overflow:hidden;position:relative;transition-duration:.5s;transition-property:all;transition-timing-function:ease-in-out}.vehicle-info-content{transition-duration:.5s;transition-property:all;width:100%}.vehicle-info-header{align-items:center;background-color:#f6f6f6;border:1px solid #ededed;display:flex;height:54px;justify-content:center;position:relative;text-align:center}.vehicle-info-header-action{align-items:center;display:flex;position:absolute;right:12px;top:50%;transform:translateY(-50%)}.vehicle-info-header-vin{display:inline-block;font-size:16px;transition-duration:.5s;transition-property:all}.vehicle-info-header-vin span{color:#ef4444}.loading .vehicle-info-header-vin{opacity:0;transform:scale(1.5);visibility:hidden}:host{all:initial!important;display:block;font-family:inherit!important;font-family:Noto Kufi Arabic,Nunito,Roboto,Arial,sans-serif!important}.part-lookup,.part-lookup *{font-family:Noto Kufi Arabic,Nunito,Roboto,Arial,sans-serif!important}.static{position:static}.h-\\[200px\\]{height:200px}.w-full{width:100%}.items-center{align-items:center}.justify-center{justify-content:center}.text-\\[26px\\]{font-size:26px}.text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.flex-col{flex-direction:column}.gap-\\[16px\\]{gap:16px}.p-\\[16px\\]{padding:16px}.pb-\\[16px\\]{padding-bottom:16px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.mx-auto{margin-left:auto;margin-right:auto}.me-2{margin-inline-end:.5rem}.ml-1{margin-left:.25rem}.mt-2{margin-top:.5rem}.mt-\\[32px\\]{margin-top:32px}.inline-flex{display:inline-flex}.h-\\[50px\\]{height:50px}.w-fit{width:fit-content}.max-w-full{max-width:100%}.flex-wrap{flex-wrap:wrap}.items-stretch{align-items:stretch}.gap-\\[8px\\]{gap:8px}.overflow-auto{overflow:auto}.overflow-x-auto{overflow-x:auto}.rounded-lg{border-radius:.5rem}.border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity,1))}.bg-\\[\\#f6f6f6\\]{--tw-bg-opacity:1;background-color:rgb(246 246 246/var(--tw-bg-opacity,1))}.bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.p-\\[2px\\]{padding:2px}.px-3{padding-left:.75rem;padding-right:.75rem}.px-\\[16px\\]{padding-left:16px;padding-right:16px}.py-1{padding-bottom:.25rem;padding-top:.25rem}.text-\\[16px\\]{font-size:16px}.text-\\[18px\\]{font-size:18px}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-\\[green\\]{--tw-text-opacity:1;color:rgb(0 128 0/var(--tw-text-opacity,1))}.text-\\[orange\\]{--tw-text-opacity:1;color:rgb(255 165 0/var(--tw-text-opacity,1))}.text-\\[red\\]{--tw-text-opacity:1;color:rgb(255 0 0/var(--tw-text-opacity,1))}.text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}@media (min-width:768px){.md\\:justify-between{justify-content:space-between}}.\\[\\&\\>div\\]\\:grow>div{flex-grow:1}.me-1{margin-inline-end:.25rem}.mb-\\[12px\\]{margin-bottom:12px}.w-\\[500px\\]{width:500px}.max-w-\\[250px\\]{max-width:250px}.max-w-\\[96vw\\]{max-width:96vw}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.gap-2{gap:.5rem}.gap-\\[32px\\]{gap:32px}.rounded-md{border-radius:.375rem}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.py-\\[10px\\]{padding-bottom:10px;padding-top:10px}.py-\\[12px\\]{padding-bottom:12px}.pt-\\[12px\\],.py-\\[12px\\]{padding-top:12px}.pt-\\[32px\\]{padding-top:32px}.pt-\\[8px\\]{padding-top:8px}.text-center{text-align:center}.text-\\[20px\\]{font-size:20px}.text-xl{font-size:1.25rem;line-height:1.75rem}.even\\:bg-slate-100:nth-child(2n){--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:bg-sky-100\\/50:hover{background-color:rgba(224,242,254,.5)}.\\!h-auto{height:auto!important}.min-w-full{min-width:100%}.resize{resize:both}.overflow-hidden{overflow:hidden}.\\!transition-none{transition-property:none!important}.\\!duration-0{transition-duration:0s!important}.\\!duration-500{transition-duration:.5s!important}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.\\!w-full{width:100%!important}.translate-x-\\[-200\\%\\]{--tw-translate-x:-200%}.translate-x-\\[-200\\%\\],.translate-y-\\[200\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[200\\%\\]{--tw-translate-y:200%}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.\\[\\&_\\*\\]\\:\\!pointer-events-none *{pointer-events:none!important}.my-auto{margin-bottom:auto;margin-top:auto}.table{display:table}.grid{display:grid}.size-\\[20px\\]{height:20px;width:20px}.size-\\[32px\\]{height:32px;width:32px}.size-full{height:100%;width:100%}.rotate-180{--tw-rotate:180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.place-items-center{place-items:center}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.bg-sky-100{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity,1))}.bg-sky-200{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity,1))}.bg-slate-100{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.bg-slate-200\\/70{background-color:rgba(226,232,240,.7)}.px-\\[12px\\]{padding-left:12px;padding-right:12px}.px-\\[6px\\]{padding-left:6px;padding-right:6px}.px-\\[8px\\]{padding-left:8px;padding-right:8px}.py-\\[16px\\]{padding-bottom:16px;padding-top:16px}.py-\\[6px\\]{padding-bottom:6px;padding-top:6px}.py-\\[8px\\]{padding-bottom:8px;padding-top:8px}.text-\\[13px\\]{font-size:13px}.text-slate-700{--tw-text-opacity:1;color:rgb(51 65 85/var(--tw-text-opacity,1))}.transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-300{transition-duration:.3s}.last\\:border-b-0:last-child{border-bottom-width:0}.hover\\:cursor-pointer:hover{cursor:pointer}.hover\\:bg-sky-200:hover{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity,1))}.hover\\:bg-slate-200\\/70:hover{background-color:rgba(226,232,240,.7)}";

const componentTags = {
    deadStock: 'dead-stock-lookup',
    distributor: 'distributor-lookup',
    manufacturer: 'manufacturer-lookup',
};
const PartLookup = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        // #region Localization
        this.language = 'en';
        this.locale = sharedLocalesSchema.getDefault();
        // #endregion
        // ====== Wrapper Logic
        this.activeElement = '';
        this.mockUrl = '';
        this.isDev = false;
        this.wrapperErrorState = '';
        this.isError = false;
        this.header = '';
        this.isLoading = false;
        this.searchGeneration = 0;
        this.syncErrorAcrossComponents = (newErrorMessage) => {
            this.isError = true;
            this.errorKey = newErrorMessage;
            smartInvokable.bind(this)(this.errorCallback, newErrorMessage);
            Object.values(this.componentsList).forEach(element => {
                if (element)
                    element.setErrorMessage(newErrorMessage);
            });
        };
        this.loadingStateChangingMiddleware = (newState) => {
            this.isLoading = newState;
            smartInvokable.bind(this)(this.loadingStateChange, newState);
        };
        this.onMockDataSetMiddleware = (newMockData) => {
            smartInvokable.bind(this)(this.loadedMockDatas, newMockData);
        };
    }
    async componentWillLoad() {
        await this.changeLanguage(this.language);
    }
    async changeLanguage(newLanguage) {
        const localeResponses = await Promise.all([getLocaleLanguage(newLanguage, 'partLookup', partLookupWrapperSchema), getSharedLocal(newLanguage)]);
        this.locale = localeResponses[1];
    }
    async componentDidLoad() {
        const deadStockLookup = this.el.shadowRoot.getElementById(componentTags.deadStock);
        const distributerLookup = this.el.shadowRoot.getElementById(componentTags.distributor);
        const manufacturerLookup = this.el.shadowRoot.getElementById(componentTags.manufacturer);
        this.componentsList = {
            [componentTags.deadStock]: deadStockLookup,
            [componentTags.distributor]: distributerLookup,
            [componentTags.manufacturer]: manufacturerLookup,
        };
        Object.values(this.componentsList).forEach(element => {
            if (!element)
                return;
            element.loadedMockDatas = this.onMockDataSetMiddleware;
            element.errorCallback = this.syncErrorAcrossComponents;
            element.loadingStateChange = this.loadingStateChangingMiddleware;
            element.loadedResponse = newResponse => this.handleLoadData(newResponse, element);
        });
    }
    async handleLoadData(newResponse, activeElement) {
        const generation = this.searchGeneration;
        this.isError = false;
        this.header = (newResponse === null || newResponse === void 0 ? void 0 : newResponse.partNumber) || '';
        smartInvokable.bind(this)(this.loadedResponse, newResponse);
        // Skip distributing to non-active components if a new search has started
        if (generation !== this.searchGeneration)
            return;
        Object.values(this.componentsList).forEach(element => {
            // @ts-ignore
            if (element !== null && element !== activeElement && newResponse)
                element.fetchData(newResponse);
        });
    }
    async errorListener(newState) {
        smartInvokable.bind(this)(this.errorCallback, newState);
    }
    async setBlazorRef(newBlazorRef) {
        this.blazorRef = newBlazorRef;
    }
    async fetchData(partNumber, quantity = '') {
        const activeElement = this.componentsList[this.activeElement] || null;
        this.wrapperErrorState = '';
        if (!activeElement)
            return;
        if (partNumber == '')
            return (this.wrapperErrorState = this.locale.errors.partNumberRequired);
        this.searchGeneration++;
        const searchingText = quantity.trim() || quantity.trim() === '0' ? `${partNumber.trim()}/${quantity.trim()}` : partNumber.trim();
        activeElement.fetchData(searchingText);
    }
    async getMockData() {
        const activeElement = this.componentsList[this.activeElement] || null;
        const mockData = await activeElement.getMockData();
        return mockData;
    }
    // #endregion
    render() {
        const props = {
            [componentTags.deadStock]: {},
            [componentTags.distributor]: {},
            [componentTags.manufacturer]: {},
        };
        try {
            if (this.childrenProps) {
                let parsedProps = {};
                if (typeof this.childrenProps === 'string')
                    parsedProps = JSON.parse(this.childrenProps);
                else if (typeof this.childrenProps === 'object')
                    parsedProps = this.childrenProps;
                Object.keys(props).forEach(key => {
                    if (typeof parsedProps[key] === 'object')
                        props[key] = parsedProps[key];
                });
            }
        }
        catch (error) {
            console.error(error);
        }
        if (!Object.values(componentTags).includes(this.activeElement))
            return h("div", { class: "w-full h-[200px] text-[26px] text-red-600 flex items-center justify-center" }, "Invalid tag");
        const componentList = {
            'dead-stock-lookup': (h("dead-stock-lookup", Object.assign({ coreOnly: true, isDev: this.isDev, "mock-url": this.mockUrl, language: this.language, endpoint: this.endpoint, id: componentTags.deadStock }, props[componentTags.deadStock]))),
            'distributor-lookup': (h("distributor-lookup", Object.assign({ coreOnly: true, isDev: this.isDev, "mock-url": this.mockUrl, language: this.language, endpoint: this.endpoint, id: componentTags.distributor }, props[componentTags.distributor]))),
            'manufacturer-lookup': (h("manufacturer-lookup", Object.assign({ coreOnly: true, isDev: this.isDev, "mock-url": this.mockUrl, language: this.language, endpoint: this.endpoint, id: componentTags.manufacturer }, props[componentTags.manufacturer]))),
        };
        return (h(Host, { class: "part-lookup", translate: "no" }, h(VehicleInfoLayout, { isError: this.isError, header: this.header, isLoading: this.isLoading, direction: this.locale.direction, errorMessage: this.locale.errors[this.errorKey] || this.locale.errors.wildCard }, h("shift-tab-content", { components: componentList, activeComponent: this.activeElement }))));
    }
    get el() { return getElement(this); }
    static get watchers() { return {
        "language": ["changeLanguage"],
        "wrapperErrorState": ["errorListener"]
    }; }
};
PartLookup.style = partLookupCss;

export { PartLookup as part_lookup };
