UNPKG

company-autocomplete

Version:
2 lines (1 loc) 38 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).CompanyAutocomplete={})}(this,(function(t){"use strict";function e(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))}function o(t,e){var o,n,i,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(r=0)),r;)try{if(o=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,n=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(6===a[0]&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(t){a=[6,t],n=0}finally{o=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function n(t,e,o){if(o||2===arguments.length)for(var n,i=0,r=e.length;i<r;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var i={target:"body",api:"clearbit",queryDelay:500,placeholder:"请输入企业名称或统一社会信用代码",clearable:!0,backFill:!1,popupAppendToBody:!0,clearIcon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10s10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17L12 13.41L8.41 17L7 15.59L10.59 12L7 8.41L8.41 7L12 10.59L15.59 7L17 8.41L13.41 12L17 15.59z"/></svg>',autoFocus:!0,history:{enabled:!0,type:"localStorage",key:"company-history",showClear:!0,itemIcon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="m15.1 19.37l1 1.74c-.96.44-2.01.73-3.1.84v-2.02c.74-.09 1.44-.28 2.1-.56zM4.07 13H2.05c.11 1.1.4 2.14.84 3.1l1.74-1c-.28-.66-.47-1.36-.56-2.1zM15.1 4.63l1-1.74c-.96-.44-2-.73-3.1-.84v2.02c.74.09 1.44.28 2.1.56zM19.93 11h2.02c-.11-1.1-.4-2.14-.84-3.1l-1.74 1c.28.66.47 1.36.56 2.1zM8.9 19.37l-1 1.74c.96.44 2.01.73 3.1.84v-2.02c-.74-.09-1.44-.28-2.1-.56zM11 4.07V2.05c-1.1.11-2.14.4-3.1.84l1 1.74c.66-.28 1.36-.47 2.1-.56zm7.36 3.1l1.74-1.01c-.63-.87-1.4-1.64-2.27-2.27l-1.01 1.74c.59.45 1.1.96 1.54 1.54zM4.63 8.9l-1.74-1c-.44.96-.73 2-.84 3.1h2.02c.09-.74.28-1.44.56-2.1zm15.3 4.1c-.09.74-.28 1.44-.56 2.1l1.74 1c.44-.96.73-2.01.84-3.1h-2.02zm-3.1 5.36l1.01 1.74c.87-.63 1.64-1.4 2.27-2.27l-1.74-1.01c-.45.59-.96 1.1-1.54 1.54zM7.17 5.64l-1-1.75c-.88.64-1.64 1.4-2.27 2.28l1.74 1.01a7.7 7.7 0 0 1 1.53-1.54zM5.64 16.83l-1.74 1c.63.87 1.4 1.64 2.27 2.27l1.01-1.74a7.7 7.7 0 0 1-1.54-1.53zM13 7h-2v5.41l4.29 4.29l1.41-1.41l-3.7-3.7V7z"/></svg>',clearIcon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M15 2h-3.5l-1-1h-5l-1 1H1v2h14zm1 7c-.7 0-1.37.1-2 .29V5H2v12c0 1.1.9 2 2 2h5.68A6.999 6.999 0 0 0 23 16c0-3.87-3.13-7-7-7zm-7 7c0 .34.03.67.08 1H4V7h8v3.26c-1.81 1.27-3 3.36-3 5.74zm7 5c-2.76 0-5-2.24-5-5s2.24-5 5-5s5 2.24 5 5s-2.24 5-5 5z"/><path fill="currentColor" d="M16.5 12H15v5l3.6 2.1l.8-1.2l-2.9-1.7z"/></svg>'},onFetch:function(){},onSelect:function(){},onClear:function(){},onFocus:function(){},onBlur:function(){},onDropdownVisibleChange:function(){},showSubmitButton:!0,submitButtonLabel:"Submit",offsetTop:5,autoFlip:!1,submitCallback:function(){}},r=function(t){return"function"==typeof t},s=function(t,n){return e(void 0,void 0,void 0,(function(){var e,i,r,s,l,c,u;return o(this,(function(o){switch(o.label){case 0:e=0,i=n,o.label=1;case 1:if(!(e<i.length))return[3,8];r=i[e],o.label=2;case 2:return o.trys.push([2,6,,7]),s=a(r,"{id}",t),[4,fetch(s)];case 3:return 200!==(l=o.sent()).status?[3,5]:[4,l.blob()];case 4:return c=o.sent(),[2,URL.createObjectURL(c)];case 5:return[3,7];case 6:return u=o.sent(),console.error(u),[3,7];case 7:return e++,[3,1];case 8:return[2,""]}}))}))},a=function(t,e,o){return t.replace(new RegExp(e,"g"),o)},l=function(t,e,o){t.forEach((function(t){t.classList.remove(o)})),t[e].classList.add(o)},c=function(t){return t.replace(/(<([^>]+)>)/gi,"")},u=function(t){return t.enabled&&t.key?function(t){try{var e=JSON.parse(t);return Array.isArray(e)?e:[]}catch(t){return[]}}(("localStorage"===t.type?localStorage:sessionStorage).getItem(t.key)||""):[]};function p(t,e,o){void 0===e&&(e=0);var n={},i=n.start,r=n.middle,s=n.once;return function(t,e,o){void 0===e&&(e=0);var n,i=void 0===o?{}:o,r=i.start,s=void 0===r||r,a=i.middle,l=void 0===a||a,c=i.once,u=void 0!==c&&c,p=s,d=0,h=!1;function g(){for(var o=this,i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];if(!h){var a=Date.now()-d;d=Date.now(),s&&l&&a>=e&&(p=!0),p?(p=!1,t.apply(this,i),u&&g.cancel()):(l&&a<e||!l)&&(clearTimeout(n),n=setTimeout((function(){d=Date.now(),t.apply(o,i),u&&g.cancel()}),l?e-a:e))}}return g.cancel=function(){clearTimeout(n),h=!0},g}(t,e,{start:void 0!==i&&i,middle:void 0!==r&&r,once:void 0!==s&&s})}var d=function(t){return e(void 0,void 0,void 0,(function(){var e;return o(this,(function(o){switch(o.label){case 0:return t.length<2||t.length>=100?[2,[]]:(e="https://autocomplete.clearbit.com/v1/companies/suggest?query=".concat(t),[4,fetch(e,{method:"GET",mode:"cors"})]);case 1:return[4,o.sent().json()];case 2:return[2,o.sent().map((function(t){return{name:t.name,id:t.domain,avatar:t.logo}}))]}}))}))};const h=Math.min,g=Math.max,f=Math.round,m=Math.floor,v=t=>({x:t,y:t}),y={left:"right",right:"left",bottom:"top",top:"bottom"},b={start:"end",end:"start"};function x(t,e){return"function"==typeof t?t(e):t}function w(t){return t.split("-")[0]}function E(t){return t.split("-")[1]}function _(t){return"y"===t?"height":"width"}function S(t){return["top","bottom"].includes(w(t))?"y":"x"}function k(t){return"x"===S(t)?"y":"x"}function L(t){return t.replace(/start|end/g,(t=>b[t]))}function C(t){return t.replace(/left|right|bottom|top/g,(t=>y[t]))}function A(t){const{x:e,y:o,width:n,height:i}=t;return{width:n,height:i,top:o,left:e,right:e+n,bottom:o+i,x:e,y:o}}function T(t,e,o){let{reference:n,floating:i}=t;const r=S(e),s=k(e),a=_(s),l=w(e),c="y"===r,u=n.x+n.width/2-i.width/2,p=n.y+n.height/2-i.height/2,d=n[a]/2-i[a]/2;let h;switch(l){case"top":h={x:u,y:n.y-i.height};break;case"bottom":h={x:u,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:p};break;case"left":h={x:n.x-i.width,y:p};break;default:h={x:n.x,y:n.y}}switch(E(e)){case"start":h[s]-=d*(o&&c?-1:1);break;case"end":h[s]+=d*(o&&c?-1:1)}return h}async function R(t,e){var o;void 0===e&&(e={});const{x:n,y:i,platform:r,rects:s,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:d=!1,padding:h=0}=x(e,t),g=function(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}(h),f=a[d?"floating"===p?"reference":"floating":p],m=A(await r.getClippingRect({element:null==(o=await(null==r.isElement?void 0:r.isElement(f)))||o?f:f.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v="floating"===p?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(a.floating)),b=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},w=A(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(m.top-w.top+g.top)/b.y,bottom:(w.bottom-m.bottom+g.bottom)/b.y,left:(m.left-w.left+g.left)/b.x,right:(w.right-m.right+g.right)/b.x}}function z(){return"undefined"!=typeof window}function D(t){return F(t)?(t.nodeName||"").toLowerCase():"#document"}function W(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function B(t){var e;return null==(e=(F(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function F(t){return!!z()&&(t instanceof Node||t instanceof W(t).Node)}function I(t){return!!z()&&(t instanceof Element||t instanceof W(t).Element)}function H(t){return!!z()&&(t instanceof HTMLElement||t instanceof W(t).HTMLElement)}function O(t){return!(!z()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof W(t).ShadowRoot)}function M(t){const{overflow:e,overflowX:o,overflowY:n,display:i}=U(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(i)}function N(t){return["table","td","th"].includes(D(t))}function j(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function P(t){const e=q(),o=I(t)?U(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!o[t]&&"none"!==o[t]))||!!o.containerType&&"normal"!==o.containerType||!e&&!!o.backdropFilter&&"none"!==o.backdropFilter||!e&&!!o.filter&&"none"!==o.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(o.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(o.contain||"").includes(t)))}function q(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function V(t){return["html","body","#document"].includes(D(t))}function U(t){return W(t).getComputedStyle(t)}function Q(t){return I(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function G(t){if("html"===D(t))return t;const e=t.assignedSlot||t.parentNode||O(t)&&t.host||B(t);return O(e)?e.host:e}function J(t){const e=G(t);return V(e)?t.ownerDocument?t.ownerDocument.body:t.body:H(e)&&M(e)?e:J(e)}function K(t,e,o){var n;void 0===e&&(e=[]),void 0===o&&(o=!0);const i=J(t),r=i===(null==(n=t.ownerDocument)?void 0:n.body),s=W(i);if(r){const t=X(s);return e.concat(s,s.visualViewport||[],M(i)?i:[],t&&o?K(t):[])}return e.concat(i,K(i,[],o))}function X(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Y(t){const e=U(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=H(t),r=i?t.offsetWidth:o,s=i?t.offsetHeight:n,a=f(o)!==r||f(n)!==s;return a&&(o=r,n=s),{width:o,height:n,$:a}}function $(t){return I(t)?t:t.contextElement}function Z(t){const e=$(t);if(!H(e))return v(1);const o=e.getBoundingClientRect(),{width:n,height:i,$:r}=Y(e);let s=(r?f(o.width):o.width)/n,a=(r?f(o.height):o.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const tt=v(0);function et(t){const e=W(t);return q()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:tt}function ot(t,e,o,n){void 0===e&&(e=!1),void 0===o&&(o=!1);const i=t.getBoundingClientRect(),r=$(t);let s=v(1);e&&(n?I(n)&&(s=Z(n)):s=Z(t));const a=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==W(t))&&e}(r,o,n)?et(r):v(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,p=i.height/s.y;if(r){const t=W(r),e=n&&I(n)?W(n):n;let o=t,i=X(o);for(;i&&n&&e!==o;){const t=Z(i),e=i.getBoundingClientRect(),n=U(i),r=e.left+(i.clientLeft+parseFloat(n.paddingLeft))*t.x,s=e.top+(i.clientTop+parseFloat(n.paddingTop))*t.y;l*=t.x,c*=t.y,u*=t.x,p*=t.y,l+=r,c+=s,o=W(i),i=X(o)}}return A({width:u,height:p,x:l,y:c})}function nt(t,e){const o=Q(t).scrollLeft;return e?e.left+o:ot(B(t)).left+o}function it(t,e,o){void 0===o&&(o=!1);const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-(o?0:nt(t,n)),y:n.top+e.scrollTop}}function rt(t,e,o){let n;if("viewport"===e)n=function(t,e){const o=W(t),n=B(t),i=o.visualViewport;let r=n.clientWidth,s=n.clientHeight,a=0,l=0;if(i){r=i.width,s=i.height;const t=q();(!t||t&&"fixed"===e)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:r,height:s,x:a,y:l}}(t,o);else if("document"===e)n=function(t){const e=B(t),o=Q(t),n=t.ownerDocument.body,i=g(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=g(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-o.scrollLeft+nt(t);const a=-o.scrollTop;return"rtl"===U(n).direction&&(s+=g(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:a}}(B(t));else if(I(e))n=function(t,e){const o=ot(t,!0,"fixed"===e),n=o.top+t.clientTop,i=o.left+t.clientLeft,r=H(t)?Z(t):v(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:n*r.y}}(e,o);else{const o=et(t);n={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return A(n)}function st(t,e){const o=G(t);return!(o===e||!I(o)||V(o))&&("fixed"===U(o).position||st(o,e))}function at(t,e,o){const n=H(e),i=B(e),r="fixed"===o,s=ot(t,!0,r,e);let a={scrollLeft:0,scrollTop:0};const l=v(0);if(n||!n&&!r)if(("body"!==D(e)||M(i))&&(a=Q(e)),n){const t=ot(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=nt(i));const c=!i||n||r?v(0):it(i,a);return{x:s.left+a.scrollLeft-l.x-c.x,y:s.top+a.scrollTop-l.y-c.y,width:s.width,height:s.height}}function lt(t){return"static"===U(t).position}function ct(t,e){if(!H(t)||"fixed"===U(t).position)return null;if(e)return e(t);let o=t.offsetParent;return B(t)===o&&(o=o.ownerDocument.body),o}function ut(t,e){const o=W(t);if(j(t))return o;if(!H(t)){let e=G(t);for(;e&&!V(e);){if(I(e)&&!lt(e))return e;e=G(e)}return o}let n=ct(t,e);for(;n&&N(n)&&lt(n);)n=ct(n,e);return n&&V(n)&&lt(n)&&!P(n)?o:n||function(t){let e=G(t);for(;H(e)&&!V(e);){if(P(e))return e;if(j(e))return null;e=G(e)}return null}(t)||o}const pt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:o,offsetParent:n,strategy:i}=t;const r="fixed"===i,s=B(n),a=!!e&&j(e.floating);if(n===s||a&&r)return o;let l={scrollLeft:0,scrollTop:0},c=v(1);const u=v(0),p=H(n);if((p||!p&&!r)&&(("body"!==D(n)||M(s))&&(l=Q(n)),H(n))){const t=ot(n);c=Z(n),u.x=t.x+n.clientLeft,u.y=t.y+n.clientTop}const d=!s||p||r?v(0):it(s,l,!0);return{width:o.width*c.x,height:o.height*c.y,x:o.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:o.y*c.y-l.scrollTop*c.y+u.y+d.y}},getDocumentElement:B,getClippingRect:function(t){let{element:e,boundary:o,rootBoundary:n,strategy:i}=t;const r=[..."clippingAncestors"===o?j(e)?[]:function(t,e){const o=e.get(t);if(o)return o;let n=K(t,[],!1).filter((t=>I(t)&&"body"!==D(t))),i=null;const r="fixed"===U(t).position;let s=r?G(t):t;for(;I(s)&&!V(s);){const e=U(s),o=P(s);o||"fixed"!==e.position||(i=null),(r?!o&&!i:!o&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||M(s)&&!o&&st(t,s))?n=n.filter((t=>t!==s)):i=e,s=G(s)}return e.set(t,n),n}(e,this._c):[].concat(o),n],s=r[0],a=r.reduce(((t,o)=>{const n=rt(e,o,i);return t.top=g(n.top,t.top),t.right=h(n.right,t.right),t.bottom=h(n.bottom,t.bottom),t.left=g(n.left,t.left),t}),rt(e,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:ut,getElementRects:async function(t){const e=this.getOffsetParent||ut,o=this.getDimensions,n=await o(t.floating);return{reference:at(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:o}=Y(t);return{width:e,height:o}},getScale:Z,isElement:I,isRTL:function(t){return"rtl"===U(t).direction}};function dt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ht(t,e,o,n){void 0===n&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=n,c=$(t),u=i||r?[...c?K(c):[],...K(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",o,{passive:!0}),r&&t.addEventListener("resize",o)}));const p=c&&a?function(t,e){let o,n=null;const i=B(t);function r(){var t;clearTimeout(o),null==(t=n)||t.disconnect(),n=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),r();const c=t.getBoundingClientRect(),{left:u,top:p,width:d,height:f}=c;if(a||e(),!d||!f)return;const v={rootMargin:-m(p)+"px "+-m(i.clientWidth-(u+d))+"px "+-m(i.clientHeight-(p+f))+"px "+-m(u)+"px",threshold:g(0,h(1,l))||1};let y=!0;function b(e){const n=e[0].intersectionRatio;if(n!==l){if(!y)return s();n?s(!1,n):o=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==n||dt(c,t.getBoundingClientRect())||s(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch(t){n=new IntersectionObserver(b,v)}n.observe(t)}(!0),r}(c,o):null;let d,f=-1,v=null;s&&(v=new ResizeObserver((t=>{let[n]=t;n&&n.target===c&&v&&(v.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame((()=>{var t;null==(t=v)||t.observe(e)}))),o()})),c&&!l&&v.observe(c),v.observe(e));let y=l?ot(t):null;return l&&function e(){const n=ot(t);y&&!dt(y,n)&&o();y=n,d=requestAnimationFrame(e)}(),o(),()=>{var t;u.forEach((t=>{i&&t.removeEventListener("scroll",o),r&&t.removeEventListener("resize",o)})),null==p||p(),null==(t=v)||t.disconnect(),v=null,l&&cancelAnimationFrame(d)}}const gt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var o,n;const{x:i,y:r,placement:s,middlewareData:a}=e,l=await async function(t,e){const{placement:o,platform:n,elements:i}=t,r=await(null==n.isRTL?void 0:n.isRTL(i.floating)),s=w(o),a=E(o),l="y"===S(o),c=["left","top"].includes(s)?-1:1,u=r&&l?-1:1,p=x(e,t);let{mainAxis:d,crossAxis:h,alignmentAxis:g}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&"number"==typeof g&&(h="end"===a?-1*g:g),l?{x:h*u,y:d*c}:{x:d*c,y:h*u}}(e,t);return s===(null==(o=a.offset)?void 0:o.placement)&&null!=(n=a.arrow)&&n.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:s}}}}},ft=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var o,n;const{placement:i,middlewareData:r,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0,...m}=x(t,e);if(null!=(o=r.arrow)&&o.alignmentOffset)return{};const v=w(i),y=S(a),b=w(a)===a,A=await(null==l.isRTL?void 0:l.isRTL(c.floating)),T=d||(b||!f?[C(a)]:function(t){const e=C(t);return[L(t),e,L(e)]}(a)),z="none"!==g;!d&&z&&T.push(...function(t,e,o,n){const i=E(t);let r=function(t,e,o){const n=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return o?e?i:n:e?n:i;case"left":case"right":return e?r:s;default:return[]}}(w(t),"start"===o,n);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(L)))),r}(a,f,g,A));const D=[a,...T],W=await R(e,m),B=[];let F=(null==(n=r.flip)?void 0:n.overflows)||[];if(u&&B.push(W[v]),p){const t=function(t,e,o){void 0===o&&(o=!1);const n=E(t),i=k(t),r=_(i);let s="x"===i?n===(o?"end":"start")?"right":"left":"start"===n?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=C(s)),[s,C(s)]}(i,s,A);B.push(W[t[0]],W[t[1]])}if(F=[...F,{placement:i,overflows:B}],!B.every((t=>t<=0))){var I,H;const t=((null==(I=r.flip)?void 0:I.index)||0)+1,e=D[t];if(e)return{data:{index:t,overflows:F},reset:{placement:e}};let o=null==(H=F.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:H.placement;if(!o)switch(h){case"bestFit":{var O;const t=null==(O=F.filter((t=>{if(z){const e=S(t.placement);return e===y||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:O[0];t&&(o=t);break}case"initialPlacement":o=a}if(i!==o)return{reset:{placement:o}}}return{}}}},mt=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var o,n;const{placement:i,rects:r,platform:s,elements:a}=e,{apply:l=()=>{},...c}=x(t,e),u=await R(e,c),p=w(i),d=E(i),f="y"===S(i),{width:m,height:v}=r.floating;let y,b;"top"===p||"bottom"===p?(y=p,b=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(b=p,y="end"===d?"top":"bottom");const _=v-u.top-u.bottom,k=m-u.left-u.right,L=h(v-u[y],_),C=h(m-u[b],k),A=!e.middlewareData.shift;let T=L,z=C;if(null!=(o=e.middlewareData.shift)&&o.enabled.x&&(z=k),null!=(n=e.middlewareData.shift)&&n.enabled.y&&(T=_),A&&!d){const t=g(u.left,0),e=g(u.right,0),o=g(u.top,0),n=g(u.bottom,0);f?z=m-2*(0!==t||0!==e?t+e:g(u.left,u.right)):T=v-2*(0!==o||0!==n?o+n:g(u.top,u.bottom))}await l({...e,availableWidth:z,availableHeight:T});const D=await s.getDimensions(a.floating);return m!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}},vt=(t,e,o)=>{const n=new Map,i={platform:pt,...o},r={...i.platform,_c:n};return(async(t,e,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:s}=o,a=r.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(e));let c=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:p}=T(c,n,l),d=n,h={},g=0;for(let o=0;o<a.length;o++){const{name:r,fn:f}=a[o],{x:m,y:v,data:y,reset:b}=await f({x:u,y:p,initialPlacement:n,placement:d,strategy:i,middlewareData:h,rects:c,platform:s,elements:{reference:t,floating:e}});u=null!=m?m:u,p=null!=v?v:p,h={...h,[r]:{...h[r],...y}},b&&g<=50&&(g++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(c=!0===b.rects?await s.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:u,y:p}=T(c,d,l))),o=-1)}return{x:u,y:p,placement:d,strategy:i,middlewareData:h}})(t,e,{...i,platform:r})};var yt=["https://image.qcc.com/logo/{id}.jpg","https://image.qcc.com/auto/{id}.jpg"],bt=function(){function t(t){var e;void 0===t&&(t={}),this.suggestions=[],this.suggestionElement=document.createElement("div"),this.suggestionActivatedClassName="suggestion-popper--activated",this.inputWrapElement=document.createElement("div"),this.inputWrapHaveWordsClassName="company-autocomplete--words",this.inputWrapActivatedClassName="company-autocomplete--activated",this.options=Object.assign({},i,t),e=this.options.target,this.target="string"==typeof e?document.querySelector(this.options.target):this.options.target,this.render()}return t.prototype.render=function(){var t,e,o,i,s,a=this;if(this.target){var l=['<div class="company-autocomplete '.concat(this.options.showSubmitButton?"company-autocomplete--show-submit":"",'">'),'<div class="company-autocomplete__input">','<input type="text" placeholder="'.concat(this.options.placeholder,'" />'),this.options.clearable?'<div class="company-autocomplete__clear"><i class="company-autocomplete__clear-icon">'.concat(this.options.clearIcon,"</i></div>"):"","</div>",this.options.showSubmitButton?'<div class="company-autocomplete__submit">':"",this.options.showSubmitButton?'<button type="button">'.concat(this.options.submitButtonLabel,"</button>"):"",this.options.showSubmitButton?"</div>":"","</div>"];this.target.innerHTML=l.join(""),this.suggestionElement.classList.add("suggestion-popper"),this.clearSuggestion(),this.options.popupAppendToBody?document.body.appendChild(this.suggestionElement):this.target.appendChild(this.suggestionElement),this.inputWrapElement=this.target.querySelector(".company-autocomplete"),this.inputElement=this.inputWrapElement.querySelector("input");var c,d,h,g=this.inputWrapElement.querySelector("button");ht(this.inputWrapElement,this.suggestionElement,(function(){vt(a.inputWrapElement,a.suggestionElement,{middleware:n([gt(a.options.offsetTop),mt({apply:function(t){var e=t.rects;Object.assign(a.suggestionElement.style,{width:"".concat(e.reference.width,"px")})}})],a.options.autoFlip?[ft({fallbackPlacements:["top"]})]:[],!0)}).then((function(t){var e=t.x,o=t.y;Object.assign(a.suggestionElement.style,{left:"".concat(e,"px"),top:"".concat(o,"px")})}))})),null===(t=this.inputElement)||void 0===t||t.addEventListener("input",(function(){var t;a.keyboardActiveIndex=void 0,a.selectCompany=void 0;var e=(null===(t=a.inputElement)||void 0===t?void 0:t.value)||"";a.inputWrapElement.classList[e.length>0?"add":"remove"](a.inputWrapHaveWordsClassName),0===e.length&&(a.clearSuggestion(),a.hideSuggestion())})),null===(e=this.inputElement)||void 0===e||e.addEventListener("input",p((function(){var t,e=(null===(t=a.inputElement)||void 0===t?void 0:t.value)||"";e&&a.handleQuerySuggestion(e)}),this.options.queryDelay)),null===(o=this.inputElement)||void 0===o||o.addEventListener("click",(function(t){if(a.suggestions.length>0)a.showSuggestion();else{var e=t.target.value;e?a.handleQuerySuggestion(e):a.options.history.enabled&&a.handleSuggestionDom(u(a.options.history),"history")}})),null==g||g.addEventListener("click",(function(){var t;a.handleSubmit((null===(t=a.inputElement)||void 0===t?void 0:t.value)||"")})),c=this.suggestionElement,d=function(){a.hideSuggestion()},h=!1,document.addEventListener("click",(function(t){c.contains(t.target)||h||d(),h=c.contains(t.target)}),!0),this.suggestionElement.addEventListener("click",(function(t){if(t.target.closest(".suggestion")){var e=t.target.closest(".suggestion"),o=(null==e?void 0:e.dataset.name)||"";a.inputElement.value=o,a.suggestions=[],a.selectCompany={id:(null==e?void 0:e.dataset.id)||"",name:o},a.handleSelect(),a.hideSuggestion(),a.inputWrapElement.classList.add(a.inputWrapHaveWordsClassName)}var n;"remove-history-link"===t.target.id&&(("localStorage"===(n=a.options.history).type?localStorage:sessionStorage).removeItem(n.key),a.clearSuggestion(),a.hideSuggestion())})),this.inputClearElement=this.inputWrapElement.querySelector(".company-autocomplete__clear-icon"),this.inputClearElement&&(null===(i=this.inputClearElement)||void 0===i||i.addEventListener("click",(function(){a.handleClear()}))),this.options.autoFocus&&(null===(s=this.inputElement)||void 0===s||s.focus()),this.inputElement.addEventListener("focus",(function(){r(a.options.onFocus)&&a.options.onFocus()})),this.inputElement.addEventListener("blur",(function(){r(a.options.onBlur)&&a.options.onBlur()}))}},t.prototype.handleQuerySuggestion=function(t){var n,i,r=this;(n=t,i=this.options,e(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"clearbit"===i.api?[3,1]:[3,3];case 1:return[4,d(n)];case 2:return[2,t.sent()];case 3:return[2,[]]}}))}))).then((function(t){r.handleSuggestionDom(t),r.options.onFetch()}))},t.prototype.handleSuggestionDom=function(t,n){var i,r,a=this;if(void 0===n&&(n="fetch"),this.suggestions=t,0===t.length)return this.clearSuggestion(),void this.hideSuggestion();var l=['<div class="suggestion-popper__body">'];t.forEach((function(t){var e,o=c(t.name);l.push('<div class="suggestion" data-id="'.concat(t.id,'" data-name="').concat(o,'">')),t.avatar?l.push('<div class="suggestion__avatar"><img data-id="'.concat(t.id||"",'" alt="').concat(o,'" src="').concat(t.avatar||"",'"/></div>')):"history"===n&&l.push('<div class="suggestion__avatar"><i class="suggestion__avatar-icon">'.concat(null===(e=a.options.history)||void 0===e?void 0:e.itemIcon,"</i></div>")),l.push('<div class="suggestion__label">'.concat(t.name,"</div>")),l.push('<div class="suggestion__extra"></div>'),l.push("</div>")})),l.push("</div>"),l.push('<div class="suggestion-popper__footer">'),"history"===n&&(null===(i=this.options.history)||void 0===i?void 0:i.showClear)&&t.length>0&&l.push('<a id="remove-history-link" href="javascript:;"><i class="suggestion-popper__icon">'.concat((null===(r=this.options.history)||void 0===r?void 0:r.clearIcon)||"","</i>删除历史</a>")),l.push("</div>"),this.suggestionElement.innerHTML=l.join(""),this.suggestionElement.querySelectorAll("img").forEach((function(t){t.getAttribute("src")||function(t,n){e(void 0,void 0,void 0,(function(){var e,i,r;return o(this,(function(o){switch(o.label){case 0:return e=t.dataset.id||"",n.avatarUrl?(i=t,[4,s(e,[n.avatarUrl])]):[3,2];case 1:return i.src=o.sent(),[2];case 2:return"qcc_open"===n.api?[3,3]:[3,5];case 3:return r=t,[4,s(e,yt)];case 4:return r.src=o.sent(),[3,5];case 5:return[2]}}))}))}(t,a.options)})),this.showSuggestion()},t.prototype.handleSelect=function(){this.options.history.enabled&&this.selectCompany&&function(t,e){if(e.enabled&&e.key){var o="localStorage"===e.type?localStorage:sessionStorage,n=u(e),i=n.findIndex((function(e){return e.id===t.id}));i>-1&&n.splice(i,1),n.splice(0,0,t),o.setItem(e.key,JSON.stringify(n.length>5?n.slice(0,5):n))}}(this.selectCompany,this.options.history),this.options.onSelect(this.selectCompany)},t.prototype.handleSubmit=function(t){this.options.submitCallback({company:this.selectCompany,text:t})},t.prototype.showSuggestion=function(){this.inputWrapElement.classList.add(this.inputWrapActivatedClassName),this.suggestionElement.classList.add(this.suggestionActivatedClassName),this.keyDownHandler&&this.inputWrapElement.removeEventListener("keydown",this.keyDownHandler),this.keyDownHandler=this.handleKeyDown.bind(this),this.inputWrapElement.addEventListener("keydown",this.keyDownHandler),this.options.onDropdownVisibleChange(!0)},t.prototype.hideSuggestion=function(){this.inputWrapElement.classList.remove(this.inputWrapActivatedClassName),this.suggestionElement.classList.remove(this.suggestionActivatedClassName),this.inputWrapElement.removeEventListener("keydown",this.keyDownHandler),this.options.onDropdownVisibleChange(!1)},t.prototype.clearSuggestion=function(){this.suggestionElement.textContent="",this.suggestions=[]},t.prototype.handleKeyDown=function(t){var e;switch(t.key){case"Enter":this.handleSubmit(null===(e=t.target)||void 0===e?void 0:e.value);break;case"ArrowUp":this.keyboardActiveIndex?this.keyboardActiveIndex--:this.keyboardActiveIndex=this.suggestions.length-1,this.selectCompany=this.suggestions[this.keyboardActiveIndex],l(Array.from(this.suggestionElement.querySelectorAll(".suggestion")),this.keyboardActiveIndex,"suggestion--keyboard-active"),this.handleBackFill();break;case"ArrowDown":void 0===this.keyboardActiveIndex||this.keyboardActiveIndex>=this.suggestions.length-1?this.keyboardActiveIndex=0:this.keyboardActiveIndex++,this.selectCompany=this.suggestions[this.keyboardActiveIndex],l(Array.from(this.suggestionElement.querySelectorAll(".suggestion")),this.keyboardActiveIndex,"suggestion--keyboard-active"),this.handleBackFill();break;case"Escape":this.handleClear()}},t.prototype.handleBackFill=function(){var t;this.options.backFill&&(this.inputElement.value=c((null===(t=this.selectCompany)||void 0===t?void 0:t.name)||""))},t.prototype.handleClear=function(){this.selectCompany=void 0,this.inputElement.value="",this.clearSuggestion(),this.inputWrapElement.classList.remove(this.inputWrapHaveWordsClassName),this.options.onClear()},t}();!function(t,e){void 0===e&&(e={});var o=e.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}(':root{color-scheme:light;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--color-info:#999;--color-primary:#128bed;--color-primary-light-3:#0069bf;--color-danger:#ff6060;--text-color-primary:#333;--transition-box-shadow:box-shadow var(--transition-duration-fast) var(--transition-function-ease-in-out-bezier);--transition-duration-fast:0.2s;--transition-function-ease-in-out-bezier:cubic-bezier(0.645,0.045,0.355,1);--input-bg-color:#fff;--input-border-radius:2px;--input-border-color:#d8d8d8;--input-focus-border-color:var(--color-primary);--input-focus-border-outline:rgba(24,144,255,.2);--input-text-color:var(--text-color-primary);--input-icon-color:rgba(0,0,0,.25);--input-hover-icon-color:rgba(0,0,0,.45);--input-placeholder:#86909c;--font-size:14px;--line-height:32px;--input-height:calc(var(--line-height) - 2px);--button-text-color:#fff;--button-bg-color:var(--color-primary);--button-hover-bg-color:var(--color-primary-light-3);--popper-bg-color:#fff;--popper-body-bg-color:#f8fbfe;--popper-footer-bg-color:#fafafa;--popper-box-shadow:0 6px 16px 0 rgb(0 0 0/8%),0 3px 6px -4px rgba(0,0,0,.12),0 9px 28px 8px rgb(0 0 0/5%);--fill-color:#f2f8fe;--border-color:#eee}:root.dark{color-scheme:dark;--color-primary:#165c94;--color-primary-light-3:#165f99;--text-color-primary:#cfd3dc;--input-bg-color:transparent;--input-border-color:#454847;--input-placeholder:#a49b8d;--input-hover-icon-color:#a3a6ad;--input-icon-color:#8d9095;--popper-body-bg-color:#161618;--popper-footer-bg-color:#1d1e1f;--popper-bg-color:#1d1e1f;--fill-color:#262727;--border-color:#1d1e1f}.company-autocomplete{box-sizing:border-box;display:inline-flex;font-family:var(--font-family);font-size:var(--font-size);line-height:var(--line-height);position:relative;vertical-align:middle;width:100%}.company-autocomplete--show-submit .company-autocomplete__input{border-end-end-radius:0;border-start-end-radius:0}.company-autocomplete--show-submit .company-autocomplete__submit{inset-inline-start:-1px;position:relative}.company-autocomplete--words .company-autocomplete__clear{opacity:1;visibility:visible}.company-autocomplete--words .company-autocomplete__input{padding-right:30px}.company-autocomplete__input{align-items:center;background-color:var(--input-bg-color);background-image:none;border-radius:var(--input-border-radius);box-shadow:0 0 0 1px var(--input-border-color) inset;display:inline-flex;flex-grow:1;justify-content:center;padding:1px 10px;position:relative;transform:translateZ(0);transition:var(--transition-box-shadow)}.company-autocomplete__input:focus-within{box-shadow:0 0 0 1px var(--input-focus-border-color) inset,0 0 0 2px var(--input-focus-border-outline)}.company-autocomplete__clear{align-items:center;bottom:0;display:flex;opacity:0;position:absolute;right:10px;text-rendering:auto;top:0;transition:color .2s ease,opacity .3s ease;visibility:hidden}.company-autocomplete__clear-icon{color:var(--input-icon-color);cursor:pointer;height:16px;width:16px}.company-autocomplete__clear-icon svg{height:100%;width:100%}.company-autocomplete__clear-icon:hover{color:var(--input-hover-icon-color)}.company-autocomplete input[type=text]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:none;border:none;box-sizing:border-box;color:var(--input-text-color);flex-grow:1;font-size:inherit;height:var(--input-height);line-height:var(--input-height);outline:none;padding:0;width:100%}.company-autocomplete input[type=text]::-moz-placeholder{color:var(--input-placeholder)}.company-autocomplete input[type=text]::placeholder{color:var(--input-placeholder)}.company-autocomplete__submit{background-color:var(--button-bg-color);border-radius:0 var(--input-border-radius) var(--input-border-radius) 0;color:var(--button-text-color);cursor:pointer;padding:0 10px}.company-autocomplete__submit button{background:transparent;border:none;color:var(--button-text-color);outline:none}.company-autocomplete__submit:active,.company-autocomplete__submit:hover{background-color:var(--button-hover-bg-color)}.suggestion-popper{--footer-text-color:var(--color-info);--footer-hover-text-color:var(--color-primary);background:var(--popper-bg-color);border-radius:2px;box-shadow:var(--popper-box-shadow);box-sizing:border-box;color:var(--text-color-primary);display:none;left:0;padding:0;position:absolute;top:0;width:-moz-max-content;width:max-content;z-index:10}.suggestion-popper--activated{display:block}.suggestion-popper:empty{display:none}.suggestion-popper__body{padding:5px}.suggestion-popper__footer{background:var(--popper-footer-bg-color);border-radius:0 0 2px 2px;font-size:12px;line-height:22px;padding:5px 10px}.suggestion-popper__footer:empty{display:none}.suggestion-popper__footer a{align-items:center;color:var(--footer-text-color);display:inline-flex}.suggestion-popper__footer a svg{margin-right:5px}.suggestion-popper__footer a:hover{color:var(--footer-hover-text-color)}.suggestion-popper__icon{height:14px;margin-right:5px;width:14px}.suggestion-popper__icon svg{height:100%;width:100%}.suggestion-popper .suggestion{align-items:center;border-radius:var(--input-border-radius);color:var(--text-color-primary);cursor:pointer;display:flex;font-size:14px;line-height:22px;padding:5px 6px}.suggestion-popper .suggestion:hover,.suggestion-popper .suggestion:hover em{color:var(--color-primary)}.suggestion-popper .suggestion--keyboard-active{background-color:var(--fill-color);color:var(--color-primary)}.suggestion-popper .suggestion__avatar{display:flex;margin-right:5px}.suggestion-popper .suggestion__avatar:empty{display:none}.suggestion-popper .suggestion__avatar-icon{color:var(--input-icon-color);height:16px;width:16px}.suggestion-popper .suggestion__avatar-icon svg{height:100%;width:100%}.suggestion-popper .suggestion__avatar img{border:1px solid var(--border-color);border-radius:4px;height:22px;width:22px}.suggestion-popper .suggestion__avatar img:not([src]),.suggestion-popper .suggestion__avatar img[src=""]{visibility:hidden}.suggestion-popper .suggestion__label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.suggestion-popper .suggestion__label:empty{display:none}.suggestion-popper .suggestion__label em{color:var(--color-danger);display:initial;font-style:normal;font-weight:400;line-height:inherit;vertical-align:inherit}.suggestion-popper .suggestion__extra{margin-left:8px}.suggestion-popper .suggestion__extra:empty{display:none}'),t.CompanyAutocomplete=bt}));