UNPKG

company-autocomplete

Version:
2 lines (1 loc) 37.8 kB
function t(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 e(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 o(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 n={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(){}},i=function(t){return"function"==typeof t},r=function(o,n){return t(void 0,void 0,void 0,(function(){var t,i,r,a,l,c,u;return e(this,(function(e){switch(e.label){case 0:t=0,i=n,e.label=1;case 1:if(!(t<i.length))return[3,8];r=i[t],e.label=2;case 2:return e.trys.push([2,6,,7]),a=s(r,"{id}",o),[4,fetch(a)];case 3:return 200!==(l=e.sent()).status?[3,5]:[4,l.blob()];case 4:return c=e.sent(),[2,URL.createObjectURL(c)];case 5:return[3,7];case 6:return u=e.sent(),console.error(u),[3,7];case 7:return t++,[3,1];case 8:return[2,""]}}))}))},s=function(t,e,o){return t.replace(new RegExp(e,"g"),o)},a=function(t,e,o){t.forEach((function(t){t.classList.remove(o)})),t[e].classList.add(o)},l=function(t){return t.replace(/(<([^>]+)>)/gi,"")},c=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 u(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 p=function(o){return t(void 0,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return o.length<2||o.length>=100?[2,[]]:(t="https://autocomplete.clearbit.com/v1/companies/suggest?query=".concat(o),[4,fetch(t,{method:"GET",mode:"cors"})]);case 1:return[4,e.sent().json()];case 2:return[2,e.sent().map((function(t){return{name:t.name,id:t.domain,avatar:t.logo}}))]}}))}))};const d=Math.min,h=Math.max,g=Math.round,f=Math.floor,m=t=>({x:t,y:t}),v={left:"right",right:"left",bottom:"top",top:"bottom"},y={start:"end",end:"start"};function b(t,e){return"function"==typeof t?t(e):t}function x(t){return t.split("-")[0]}function w(t){return t.split("-")[1]}function E(t){return"y"===t?"height":"width"}function _(t){return["top","bottom"].includes(x(t))?"y":"x"}function S(t){return"x"===_(t)?"y":"x"}function k(t){return t.replace(/start|end/g,(t=>y[t]))}function L(t){return t.replace(/left|right|bottom|top/g,(t=>v[t]))}function C(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 A(t,e,o){let{reference:n,floating:i}=t;const r=_(e),s=S(e),a=E(s),l=x(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(w(e)){case"start":h[s]-=d*(o&&c?-1:1);break;case"end":h[s]+=d*(o&&c?-1:1)}return h}async function T(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}=b(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=C(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)),x=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},w=C(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(m.top-w.top+g.top)/x.y,bottom:(w.bottom-m.bottom+g.bottom)/x.y,left:(m.left-w.left+g.left)/x.x,right:(w.right-m.right+g.right)/x.x}}function R(){return"undefined"!=typeof window}function z(t){return B(t)?(t.nodeName||"").toLowerCase():"#document"}function D(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function W(t){var e;return null==(e=(B(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function B(t){return!!R()&&(t instanceof Node||t instanceof D(t).Node)}function F(t){return!!R()&&(t instanceof Element||t instanceof D(t).Element)}function I(t){return!!R()&&(t instanceof HTMLElement||t instanceof D(t).HTMLElement)}function H(t){return!(!R()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof D(t).ShadowRoot)}function O(t){const{overflow:e,overflowX:o,overflowY:n,display:i}=V(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(i)}function M(t){return["table","td","th"].includes(z(t))}function N(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function j(t){const e=P(),o=F(t)?V(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 P(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function q(t){return["html","body","#document"].includes(z(t))}function V(t){return D(t).getComputedStyle(t)}function U(t){return F(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Q(t){if("html"===z(t))return t;const e=t.assignedSlot||t.parentNode||H(t)&&t.host||W(t);return H(e)?e.host:e}function G(t){const e=Q(t);return q(e)?t.ownerDocument?t.ownerDocument.body:t.body:I(e)&&O(e)?e:G(e)}function J(t,e,o){var n;void 0===e&&(e=[]),void 0===o&&(o=!0);const i=G(t),r=i===(null==(n=t.ownerDocument)?void 0:n.body),s=D(i);if(r){const t=K(s);return e.concat(s,s.visualViewport||[],O(i)?i:[],t&&o?J(t):[])}return e.concat(i,J(i,[],o))}function K(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X(t){const e=V(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=I(t),r=i?t.offsetWidth:o,s=i?t.offsetHeight:n,a=g(o)!==r||g(n)!==s;return a&&(o=r,n=s),{width:o,height:n,$:a}}function Y(t){return F(t)?t:t.contextElement}function $(t){const e=Y(t);if(!I(e))return m(1);const o=e.getBoundingClientRect(),{width:n,height:i,$:r}=X(e);let s=(r?g(o.width):o.width)/n,a=(r?g(o.height):o.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const Z=m(0);function tt(t){const e=D(t);return P()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Z}function et(t,e,o,n){void 0===e&&(e=!1),void 0===o&&(o=!1);const i=t.getBoundingClientRect(),r=Y(t);let s=m(1);e&&(n?F(n)&&(s=$(n)):s=$(t));const a=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==D(t))&&e}(r,o,n)?tt(r):m(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=D(r),e=n&&F(n)?D(n):n;let o=t,i=K(o);for(;i&&n&&e!==o;){const t=$(i),e=i.getBoundingClientRect(),n=V(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=D(i),i=K(o)}}return C({width:u,height:p,x:l,y:c})}function ot(t,e){const o=U(t).scrollLeft;return e?e.left+o:et(W(t)).left+o}function nt(t,e,o){void 0===o&&(o=!1);const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-(o?0:ot(t,n)),y:n.top+e.scrollTop}}function it(t,e,o){let n;if("viewport"===e)n=function(t,e){const o=D(t),n=W(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=P();(!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=W(t),o=U(t),n=t.ownerDocument.body,i=h(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=h(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-o.scrollLeft+ot(t);const a=-o.scrollTop;return"rtl"===V(n).direction&&(s+=h(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:a}}(W(t));else if(F(e))n=function(t,e){const o=et(t,!0,"fixed"===e),n=o.top+t.clientTop,i=o.left+t.clientLeft,r=I(t)?$(t):m(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=tt(t);n={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return C(n)}function rt(t,e){const o=Q(t);return!(o===e||!F(o)||q(o))&&("fixed"===V(o).position||rt(o,e))}function st(t,e,o){const n=I(e),i=W(e),r="fixed"===o,s=et(t,!0,r,e);let a={scrollLeft:0,scrollTop:0};const l=m(0);if(n||!n&&!r)if(("body"!==z(e)||O(i))&&(a=U(e)),n){const t=et(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=ot(i));const c=!i||n||r?m(0):nt(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 at(t){return"static"===V(t).position}function lt(t,e){if(!I(t)||"fixed"===V(t).position)return null;if(e)return e(t);let o=t.offsetParent;return W(t)===o&&(o=o.ownerDocument.body),o}function ct(t,e){const o=D(t);if(N(t))return o;if(!I(t)){let e=Q(t);for(;e&&!q(e);){if(F(e)&&!at(e))return e;e=Q(e)}return o}let n=lt(t,e);for(;n&&M(n)&&at(n);)n=lt(n,e);return n&&q(n)&&at(n)&&!j(n)?o:n||function(t){let e=Q(t);for(;I(e)&&!q(e);){if(j(e))return e;if(N(e))return null;e=Q(e)}return null}(t)||o}const ut={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:o,offsetParent:n,strategy:i}=t;const r="fixed"===i,s=W(n),a=!!e&&N(e.floating);if(n===s||a&&r)return o;let l={scrollLeft:0,scrollTop:0},c=m(1);const u=m(0),p=I(n);if((p||!p&&!r)&&(("body"!==z(n)||O(s))&&(l=U(n)),I(n))){const t=et(n);c=$(n),u.x=t.x+n.clientLeft,u.y=t.y+n.clientTop}const d=!s||p||r?m(0):nt(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:W,getClippingRect:function(t){let{element:e,boundary:o,rootBoundary:n,strategy:i}=t;const r=[..."clippingAncestors"===o?N(e)?[]:function(t,e){const o=e.get(t);if(o)return o;let n=J(t,[],!1).filter((t=>F(t)&&"body"!==z(t))),i=null;const r="fixed"===V(t).position;let s=r?Q(t):t;for(;F(s)&&!q(s);){const e=V(s),o=j(s);o||"fixed"!==e.position||(i=null),(r?!o&&!i:!o&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||O(s)&&!o&&rt(t,s))?n=n.filter((t=>t!==s)):i=e,s=Q(s)}return e.set(t,n),n}(e,this._c):[].concat(o),n],s=r[0],a=r.reduce(((t,o)=>{const n=it(e,o,i);return t.top=h(n.top,t.top),t.right=d(n.right,t.right),t.bottom=d(n.bottom,t.bottom),t.left=h(n.left,t.left),t}),it(e,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:ct,getElementRects:async function(t){const e=this.getOffsetParent||ct,o=this.getDimensions,n=await o(t.floating);return{reference:st(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}=X(t);return{width:e,height:o}},getScale:$,isElement:F,isRTL:function(t){return"rtl"===V(t).direction}};function pt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function dt(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=Y(t),u=i||r?[...c?J(c):[],...J(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=W(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:g,height:m}=c;if(a||e(),!g||!m)return;const v={rootMargin:-f(p)+"px "+-f(i.clientWidth-(u+g))+"px "+-f(i.clientHeight-(p+m))+"px "+-f(u)+"px",threshold:h(0,d(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||pt(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 g,m=-1,v=null;s&&(v=new ResizeObserver((t=>{let[n]=t;n&&n.target===c&&v&&(v.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var t;null==(t=v)||t.observe(e)}))),o()})),c&&!l&&v.observe(c),v.observe(e));let y=l?et(t):null;return l&&function e(){const n=et(t);y&&!pt(y,n)&&o();y=n,g=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(g)}}const ht=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=x(o),a=w(o),l="y"===_(o),c=["left","top"].includes(s)?-1:1,u=r&&l?-1:1,p=b(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}}}}},gt=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}=b(t,e);if(null!=(o=r.arrow)&&o.alignmentOffset)return{};const v=x(i),y=_(a),C=x(a)===a,A=await(null==l.isRTL?void 0:l.isRTL(c.floating)),R=d||(C||!f?[L(a)]:function(t){const e=L(t);return[k(t),e,k(e)]}(a)),z="none"!==g;!d&&z&&R.push(...function(t,e,o,n){const i=w(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[]}}(x(t),"start"===o,n);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(k)))),r}(a,f,g,A));const D=[a,...R],W=await T(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=w(t),i=S(t),r=E(i);let s="x"===i?n===(o?"end":"start")?"right":"left":"start"===n?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=L(s)),[s,L(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=_(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{}}}},ft=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}=b(t,e),u=await T(e,c),p=x(i),g=w(i),f="y"===_(i),{width:m,height:v}=r.floating;let y,E;"top"===p||"bottom"===p?(y=p,E=g===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(E=p,y="end"===g?"top":"bottom");const S=v-u.top-u.bottom,k=m-u.left-u.right,L=d(v-u[y],S),C=d(m-u[E],k),A=!e.middlewareData.shift;let R=L,z=C;if(null!=(o=e.middlewareData.shift)&&o.enabled.x&&(z=k),null!=(n=e.middlewareData.shift)&&n.enabled.y&&(R=S),A&&!g){const t=h(u.left,0),e=h(u.right,0),o=h(u.top,0),n=h(u.bottom,0);f?z=m-2*(0!==t||0!==e?t+e:h(u.left,u.right)):R=v-2*(0!==o||0!==n?o+n:h(u.top,u.bottom))}await l({...e,availableWidth:z,availableHeight:R});const D=await s.getDimensions(a.floating);return m!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}},mt=(t,e,o)=>{const n=new Map,i={platform:ut,...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}=A(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}=A(c,d,l))),o=-1)}return{x:u,y:p,placement:d,strategy:i,middlewareData:h}})(t,e,{...i,platform:r})};var vt=["https://image.qcc.com/logo/{id}.jpg","https://image.qcc.com/auto/{id}.jpg"],yt=function(){function s(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({},n,t),e=this.options.target,this.target="string"==typeof e?document.querySelector(this.options.target):this.options.target,this.render()}return s.prototype.render=function(){var t,e,n,r,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 p,d,h,g=this.inputWrapElement.querySelector("button");dt(this.inputWrapElement,this.suggestionElement,(function(){mt(a.inputWrapElement,a.suggestionElement,{middleware:o([ht(a.options.offsetTop),ft({apply:function(t){var e=t.rects;Object.assign(a.suggestionElement.style,{width:"".concat(e.reference.width,"px")})}})],a.options.autoFlip?[gt({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",u((function(){var t,e=(null===(t=a.inputElement)||void 0===t?void 0:t.value)||"";e&&a.handleQuerySuggestion(e)}),this.options.queryDelay)),null===(n=this.inputElement)||void 0===n||n.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(c(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)||"")})),p=this.suggestionElement,d=function(){a.hideSuggestion()},h=!1,document.addEventListener("click",(function(t){p.contains(t.target)||h||d(),h=p.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===(r=this.inputClearElement)||void 0===r||r.addEventListener("click",(function(){a.handleClear()}))),this.options.autoFocus&&(null===(s=this.inputElement)||void 0===s||s.focus()),this.inputElement.addEventListener("focus",(function(){i(a.options.onFocus)&&a.options.onFocus()})),this.inputElement.addEventListener("blur",(function(){i(a.options.onBlur)&&a.options.onBlur()}))}},s.prototype.handleQuerySuggestion=function(o){var n,i,r=this;(n=o,i=this.options,t(void 0,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return"clearbit"===i.api?[3,1]:[3,3];case 1:return[4,p(n)];case 2:return[2,t.sent()];case 3:return[2,[]]}}))}))).then((function(t){r.handleSuggestionDom(t),r.options.onFetch()}))},s.prototype.handleSuggestionDom=function(o,n){var i,s,a=this;if(void 0===n&&(n="fetch"),this.suggestions=o,0===o.length)return this.clearSuggestion(),void this.hideSuggestion();var c=['<div class="suggestion-popper__body">'];o.forEach((function(t){var e,o=l(t.name);c.push('<div class="suggestion" data-id="'.concat(t.id,'" data-name="').concat(o,'">')),t.avatar?c.push('<div class="suggestion__avatar"><img data-id="'.concat(t.id||"",'" alt="').concat(o,'" src="').concat(t.avatar||"",'"/></div>')):"history"===n&&c.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>")),c.push('<div class="suggestion__label">'.concat(t.name,"</div>")),c.push('<div class="suggestion__extra"></div>'),c.push("</div>")})),c.push("</div>"),c.push('<div class="suggestion-popper__footer">'),"history"===n&&(null===(i=this.options.history)||void 0===i?void 0:i.showClear)&&o.length>0&&c.push('<a id="remove-history-link" href="javascript:;"><i class="suggestion-popper__icon">'.concat((null===(s=this.options.history)||void 0===s?void 0:s.clearIcon)||"","</i>删除历史</a>")),c.push("</div>"),this.suggestionElement.innerHTML=c.join(""),this.suggestionElement.querySelectorAll("img").forEach((function(o){o.getAttribute("src")||function(o,n){t(void 0,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return t=o.dataset.id||"",n.avatarUrl?(i=o,[4,r(t,[n.avatarUrl])]):[3,2];case 1:return i.src=e.sent(),[2];case 2:return"qcc_open"===n.api?[3,3]:[3,5];case 3:return s=o,[4,r(t,vt)];case 4:return s.src=e.sent(),[3,5];case 5:return[2]}}))}))}(o,a.options)})),this.showSuggestion()},s.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=c(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)},s.prototype.handleSubmit=function(t){this.options.submitCallback({company:this.selectCompany,text:t})},s.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)},s.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)},s.prototype.clearSuggestion=function(){this.suggestionElement.textContent="",this.suggestions=[]},s.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],a(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],a(Array.from(this.suggestionElement.querySelectorAll(".suggestion")),this.keyboardActiveIndex,"suggestion--keyboard-active"),this.handleBackFill();break;case"Escape":this.handleClear()}},s.prototype.handleBackFill=function(){var t;this.options.backFill&&(this.inputElement.value=l((null===(t=this.selectCompany)||void 0===t?void 0:t.name)||""))},s.prototype.handleClear=function(){this.selectCompany=void 0,this.inputElement.value="",this.clearSuggestion(),this.inputWrapElement.classList.remove(this.inputWrapHaveWordsClassName),this.options.onClear()},s}();!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}');export{yt as CompanyAutocomplete};