"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["6546"],{36750:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]])},53095:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]])},80552:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]])},9574:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]])},24130:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]])},40131:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]])},49488:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]])},98147:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]])},77508:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]])},34539:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Cross",[["path",{d:"M11 2a2 2 0 0 0-2 2v5H4a2 2 0 0 0-2 2v2c0 1.1.9 2 2 2h5v5c0 1.1.9 2 2 2h2a2 2 0 0 0 2-2v-5h5a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-5V4a2 2 0 0 0-2-2h-2z",key:"1t5g7j"}]])},41486:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]])},57469:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},94895:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},60823:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]])},72910:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},45208:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]])},41002:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]])},41694:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]])},68402:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]])},28549:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},66577:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]])},6453:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]])},22534:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},5958:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]])},98770:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]])},89733:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]])},96220:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]])},40367:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]])},46555:function(e,t,a){a.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,a(36150).Z)("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]])},58857:function(e,t,a){a.r(t),a.d(t,{GlobalSearch:()=>H});var i=a(7409),n=a(99282),l=a(16584),r=a(30396),o=a(72910);/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let c=(0,a(36150).Z)("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);var u=a(24840),p=a(98661),y=a(71171),s=a.n(y),d=a(53311),h=a(98848),k=a(19081),f=a(58175);function g(e){var{title:t,body:a,children:r}=e,o=(0,h._)(e,["title","body","children"]);return(0,l.tZ)(k.tu,(0,n._)((0,i._)({flex:"grow",alignItems:"center",justifyContent:"center",padding:20},o),{children:(0,l.tZ)(v,{title:t,body:a,children:r})}))}function v(e){let{title:t,body:a,children:i}=e;return(0,l.BX)(k.tu,{gap:12,alignItems:"center",children:[(0,l.BX)(k.tu,{gap:4,alignItems:"center",children:[(0,l.tZ)(f.xv.B3,{weight:"semibold",color:"primary",align:"center",children:t}),(0,l.tZ)(f.xv.B4,{color:"secondary",align:"center",children:a})]}),i]})}var b=a(68833),m=a(7882),M=a(63018),Z=a(98914),_=a(45578),x=a.n(_),w=a(60807),q=a(98012);let S=e=>{let{isOpen:t}=e,a=(0,w.aF)(),[i,n]=(0,r.eJ)([]),{result:l,hasLoadedOnce:o,isLoading:c,refetch:u}=(0,m.ib)({pathname:"/api/v1/search/history"}),{refetch:p}=(0,m.ib)({pathname:"/api/v1/search/history",method:"post"}),{refetch:y}=(0,m.ib)({pathname:"/api/v1/search/history",method:"delete"});(0,r.d4)(()=>{t&&!o&&!c&&a&&u()},[o,u,t,c,a]),(0,r.d4)(()=>{let e=k();if(null==l?void 0:l.length){var t;let a=null!==(t=null==l?void 0:l.sort((e,t)=>e.created>t.created?-1:1).map(s))&&void 0!==t?t:[];n(x()([...e,...a],"query"))}else n(e)},[l]);let s=e=>({type:"history",query:e.query}),d=()=>a?"ss-recent-search-global-".concat(null==a?void 0:a.id):"",h=()=>{if(!a||!localStorage)return[];let e=localStorage.getItem(d());return(e?JSON.parse(e):[]).filter(e=>new Date(e.expiry)>new Date).sort((e,t)=>e.expiryh().map(s),f=async e=>{let{query:t}=e;if(!a||!localStorage)return;let l=h().filter(e=>e.query!==t);localStorage.setItem(d(),JSON.stringify(l)),n(i.filter(e=>e.query!==t)),await y({query:{query:t}})};return{recentSearches:i,insertRecentSearch:async e=>{let{query:t}=e;if(!a||!localStorage)return;let i=h(),l=x()([{query:t,expiry:(0,q.Z)().add(1,"week").toDate()},...i],"query");localStorage.setItem(d(),JSON.stringify(l)),n(l.map(s)),await p({json:{query:t}})},removeRecentSearch:f,search:function*(e){let{query:t}=e;for(let e of i)e.query.includes(t)&&(yield{type:"history",query:e.query})}}};var L=a(25479),j=a(32071),z=a(60308),C=a(63651),V=a(47929);function R(e){return(0,C.n1t)(e,{utm_source:V.b3.globalSearch})}function H(e){let{isOpen:t,onClose:a,useLocalNavigation:y=!0,suggestedSearches:h}=e,{search:v}=function(e){let{isOpen:t}=e,{data:a}=(0,M._I)("/api/v1/client-search-cache",{auto:t,shouldRevalidate:!1});return{search:e=>(function*(e,t){let a=t.toUpperCase().trim();if(a&&e){for(let t of e.profiles)(0,j.u)([t.name]).some(e=>e.includes(a))&&(yield{type:"user",user:t});for(let t of e.publications)(0,j.u)([t.author_name,t.name]).some(e=>e.includes(a))&&(yield{type:"publication",publication:t});for(let t of e.categories)t.slug&&(0,j.u)([t.canonical_name,t.name]).some(e=>e.includes(a))&&(yield{type:"category",category:t})}})(a,e),get isLoaded(){return!!a}}}({isOpen:t}),{search:_}=function(){let{refetch:e}=(0,m.ib)({pathname:"/api/v1/platform/search",auto:!1});return{async search(t,a,i){let n=await e({query:{query:t,search_id:a,start_rank_at:i}});return n instanceof Error?(console.error(n),{results:[]}):n}}}(),{recentSearches:x,insertRecentSearch:w,removeRecentSearch:q,search:V}=S({isOpen:t}),{surfaces:H}=(0,L.ze)(),[{results:B,isLoading:J,ribbonResults:P},O]=(0,r.eJ)({results:[],ribbonResults:[],isLoading:!1}),[T,X]=(0,r.eJ)(""),[I,A]=(0,r.eJ)(),[E,G]=(0,r.eJ)("defaults"),N=(0,r.sO)({abort:null});(0,r.d4)(()=>{t&&X("")},[t]),(0,r.d4)(()=>{T||(U(),G("defaults"),O({results:D({queryResults:[...x,...h.map(e=>({type:"trending",query:e})).reverse()]}),ribbonResults:D({queryResults:H}),isLoading:!1}))},[T,x,h,H]),(0,r.d4)(()=>{T&&F(T)},[T]);let U=()=>{var e;(null===(e=N.current)||void 0===e?void 0:e.abort)&&(N.current.abort(),N.current.abort=null)};function D(e){let{queryResults:t}=e,a=[];return t.forEach(e=>{var t,l,r;if("publication"===e.type)a.push({id:"publication".concat(e.publication.publication_id,"-").concat(E),publication:(0,n._)((0,i._)({},e.publication),{logo_url:null!==(t=e.publication.logo_url)&&void 0!==t?t:void 0,url:R((0,z.TJI)(e.publication))}),type:"publication",trackingParameters:e.trackingParameters});else if("user"===e.type){let t=e.user.handle?(0,C.NJv)(e.user.handle):(0,C.GR3)(e.user.user_id,e.user.name);a.push({type:"user",user:(0,n._)((0,i._)({},e.user),{id:e.user.user_id,profile_url:R(t),is_pub_search:!1}),id:"user-".concat(e.user.user_id,"-").concat(E),trackingParameters:e.trackingParameters})}else if("post"===e.type)a.push({id:"post-".concat(e.post.slug,"-").concat(e.post.publication_id,"-").concat(E),type:"post",post:{title:e.post.title,subtitle:e.post.subtitle,url:R(e.post.url),body:e.post.truncated_body,audience:e.post.audience,date:e.post.post_date,image:e.post.cover_image,is_paywalled:["only_paid","founding"].includes(e.post.audience)}});else if("history"===e.type){let t={type:"action",title:"".concat(e.query),icon:o.Z,id:"search-history-".concat(e.query,"-").concat(E),displayValue:e.query,onRemove:()=>{q({query:e.query})},actionType:"history",url:R("".concat((0,C.ZJn)(),"/search/").concat(e.query))};a.unshift((0,n._)((0,i._)({},t),{onSelect:()=>{X(e.query),A((0,n._)((0,i._)({},t),{rank:-1}))}}))}else"trending"===e.type?a.unshift({type:"action",title:"".concat(e.query),icon:c,id:"search-suggestion-".concat(e.query,"-").concat(E),displayValue:e.query,actionType:"trending",url:R("".concat((0,C.ZJn)(),"/search/").concat(e.query))}):"category"===e.type?a.push({id:"category-".concat(e.category.slug,"-").concat(E),type:"category",category:{name:e.category.name,url:(0,C.XAP)(null!==(l=e.category.slug)&&void 0!==l?l:"recommendations"),slug:null!==(r=e.category.slug)&&void 0!==r?r:"",emoji:e.category.emoji}}):"visited-profile"===e.type?a.push({type:"visited-profile",id:"profile-surface-".concat(e.profile.id,"-").concat(E),profile:(0,n._)((0,i._)({},e.profile),{url:R((0,C.GR3)(e.profile.id,e.profile.name))})}):"visited-publication"===e.type&&a.push({type:"visited-publication",id:"publication-surface-".concat(e.publication.id,"-").concat(E),publication:(0,n._)((0,i._)({},e.publication),{url:R((0,z.TJI)(e.publication))})})}),a.map((e,t)=>{let l=(0,n._)((0,i._)({search_id:E,search_key:"global_search",result_count:a.length,score:-1,result_id:"generated-".concat(t),from_server:!1},e.trackingParameters),{rank:t});return(0,n._)((0,i._)({},e),{trackingParameters:l})})}let F=(0,m.Kt)(async e=>{O(e=>(0,n._)((0,i._)({},e),{isLoading:!0})),U();let t=new AbortController;N.current.abort=()=>t.abort();let a=s()();G(a);let l=new Set,r=new Set,o=[],c=0;for await(let a of v(e)){if(t.signal.aborted||o.length>=100)break;"user"===a.type&&l.add(a.user.user_id),"publication"===a.type&&r.add(a.publication.publication_id),o.push(a),++c%20==0&&await new Promise(e=>setTimeout(e,50))}for await(let a of V({query:e})){if(t.signal.aborted||o.length>=100)break;o.push(a),++c%20==0&&await new Promise(e=>setTimeout(e,50))}if(t.signal.aborted||(o.length&&O({results:D({queryResults:o}),ribbonResults:[],isLoading:e.length>=2}),e.length<2))return;let u=o.length,{results:p}=await _(e,a,u);if(t.signal.aborted)return;o.push(...p.filter(e=>"user"===e.type?!l.has(e.user.user_id):"publication"!==e.type||!r.has(e.publication.publication_id))),O({results:D({queryResults:o}),ribbonResults:[],isLoading:!1});let y={query:e,results:o.length,search_id:a};(0,b.j)(b.FP.GLOBAL_SEARCH_RESULTS_SHOWN,(0,n._)((0,i._)({},y),{clientsideResultCount:u}))},300,[v,V]),K=()=>{A(void 0),X(""),a()},Q=(0,p.useMemo)(()=>{let e="".concat((0,C.ZJn)(),"/search/").concat(T),t=T?[{id:"action-search-".concat(T),type:"action",icon:u.Z,url:R(T?e:"/search"),title:(0,l.BX)(f.xv.B3,{as:"span",children:["Search for"," ",(0,l.tZ)(f.xv.B3,{as:"span",weight:"bold",children:T})]}),displayValue:T,actionType:"escape-hatch",keepOpenOnSelect:!1}]:[],a=T&&"defaults"===E?[]:B;return t.concat(a)},[T,B,E]),W=(0,p.useMemo)(()=>T&&"defaults"===E?[]:P,[T,P,E]);return(0,l.tZ)(d.s,{onQueryChange:e=>X(e),results:Q,ribbonResults:W,placeholder:"People, publications, or topics",isOpen:t,onClose:K,onEnter:(e,t)=>{(0,b.j)(b.FP.GLOBAL_SEARCH_RESULT_CLICKED,(0,n._)((0,i._)({},e.trackingParameters),{result_type:e.type,action_type:"action"===e.type?e.actionType:void 0})),T&&w({query:T}),"user"===e.type&&(0,Z.uX)(e.user.profile_url,{newTab:t,local_navigation:y}),"publication"===e.type&&(0,Z.uX)(e.publication.url,{local_navigation:!1,newTab:t}),"post"===e.type&&(0,Z.uX)(e.post.url,{local_navigation:!1,newTab:t}),"category"===e.type&&(0,Z.uX)(e.category.url,{newTab:t,local_navigation:y}),"visited-profile"===e.type&&(0,Z.uX)(e.profile.url,{newTab:t,local_navigation:y}),"visited-publication"===e.type&&(0,Z.uX)(e.publication.url,{local_navigation:!1,newTab:t}),("action"!==e.type||(e.url&&(0,Z.uX)(e.url,{newTab:t,local_navigation:y}),!e.onSelect||(e.onSelect(),!e.keepOpenOnSelect)))&&K()},isLoading:J,value:I,noQueryZeroState:x.length>0||h.length>0?null:(0,l.BX)(k.tu,{justifyContent:"center",alignItems:"center",padding:8,flex:"grow",gap:12,children:[(0,l.tZ)(u.Z,{}),(0,l.tZ)(g,{title:"Search all of Substack",body:"Find people and publications",flex:"auto",padding:0})]})})}},32071:function(e,t,a){a.d(t,{u:()=>l});var i=a(39693),n=a.n(i);let l=e=>n()(e).map(e=>e.toUpperCase())}}]); //# sourceMappingURL=6546.fa85d126.js.map