1"use strict";(globalThis.webpackChunkreact_ts=globalThis.webpackChunkreact_ts||[]).push([[8645],{77708(e,a,l){l.d(a,{A:()=>f});var t=l(5544),i=l(9950),s=l(42461),o=l(52828),r=l(10300),n=l(86400),d=l(30525),c=l(22843),u=l(7732),m=l(89051),x=l(52960),h=l(98932),v=l(44140),p=l(64767),g=l(70124),b=l(44414);const f=e=>{let a=e.isEmergency,l=e.open,f=e.regularHours,y=e.handleSave,j=e.onClose,N=e.onEmergencyHoursSaved,w=e.onEmergencyDataReset,C=e.resetData,M=e.onResetDataChange;const k=(0,p.Bd)().t,A=(0,n.jLQ)(),S=(0,r.d4)(e=>e.auth).user,E=(0,i.useState)({}),P=(0,t.A)(E,2),R=P[0],I=P[1],L=(0,i.useState)((null===S||void 0===S?void 0:S.whatsappNumber)||(null===S||void 0===S?void 0:S.contactOnWhatsapp)||""),D=(0,t.A)(L,2),T=D[0],B=D[1],G=(0,i.useState)(()=>{const e=localStorage.getItem("timeFormat");return!!e&&"24"===e}),q=(0,t.A)(G,2),U=q[0],O=q[1],z=(0,i.useState)([]),F=(0,t.A)(z,2),K=F[0],H=F[1],V=(0,i.useState)([]),W=(0,t.A)(V,2),Z=W[0],$=W[1],_=(0,i.useState)([]),J=(0,t.A)(_,2),Q=J[0],Y=J[1],X=(0,i.useState)(1),ee=(0,t.A)(X,2),ae=ee[0],le=(ee[1],(0,i.useState)(!1)),te=(0,t.A)(le,2),ie=te[0],se=te[1],oe=(0,r.d4)(e=>e.userCategory).userCategories,re=((0,r.d4)(e=>e.client.categoriesByType),(0,r.d4)(e=>e.professional).emergencyAvailabilities),ne=e=>{O("24"===e),localStorage.setItem("timeFormat",e)};(0,i.useEffect)(()=>{I(f)},[f]),(0,i.useEffect)(()=>{l&&a&&null!==S&&void 0!==S&&S.id&&de()},[l,a,null===S||void 0===S?void 0:S.id]),(0,i.useEffect)(()=>{},[K,Z,Q,a]),(0,i.useEffect)(()=>{(null!==S&&void 0!==S&&S.whatsappNumber||null!==S&&void 0!==S&&S.contactOnWhatsapp)&&B(S.whatsappNumber||S.contactOnWhatsapp||"")},[null===S||void 0===S?void 0:S.whatsappNumber,null===S||void 0===S?void 0:S.contactOnWhatsapp]);const de=async()=>{if(null!==S&&void 0!==S&&S.id){console.log("=== Emergency Modal - Fetching Categories ==="),console.log("User ID:",S.id),console.log("Category Type:",ae),console.log("===========================================");try{const e=`${S.id}-${m.j8.Emergency}`,a=oe[e];if(a){const e=a.categoryIds||[],l=a.subCategories||[],t=a.serviceAreaIds||[];return console.log("Using cached emergency data:",{categories:e,subCategories:l,serviceAreas:t}),console.log("Cached service area details:",t.map(e=>({id:e.id,type:e.type,country:e.country}))),H(e.map(e=>({id:e.id,name:e.name,description:e.description||"",subcategories:e.subcategories||[],isEmergency:e.isEmergency,isRequireVerification:e.isRequireVerification,type:e.type}))),$(l.map(e=>({id:e,name:e,description:""}))),void Y(t.map(e=>{var a,l,t,i,s,o;return{id:String(e.id),name:e.name||"",province:e.province||"",country:{id:String((null===(a=e.country)||void 0===a?void 0:a.id)||""),name:(null===(l=e.country)||void 0===l?void 0:l.name)||"",code:(null===(t=e.country)||void 0===t?void 0:t.code)||(null===(i=e.country)||void 0===i?void 0:i.initial)||""},type:{id:Number(null===(s=e.type)||void 0===s?void 0:s.id)||1,name:(null===(o=e.type)||void 0===o?void 0:o.name)||"Default"},radius:Number(e.radius)||0,restrictions:e.restrictions||[],cities:e.cities||[],postalCodes:e.postalCodes||[],serviceTypes:e.serviceTypes||[],emergencyServices:Boolean(e.emergencyServices)||!1}}))}const l=await A((0,u.jD)({userId:S.id,type:m.j8.Emergency})).unwrap();if(l){const e=l.categoryIds||[],a=l.subCategories||[],t=l.serviceAreaIds||[];console.log("Emergency categories fetched:",e),console.log("Emergency subcategories fetched:",a),console.log("Emergency service areas fetched:",t),console.log("Service area details:",t.map(e=>({id:e.id,type:e.type,country:e.country}))),H(e.map(e=>({id:e.id,name:e.name,description:e.description||"",subcategories:e.subcategories||[],isEmergency:e.isEmergency,isRequireVerification:e.isRequireVerification,type:e.type}))),$(a.map(e=>({id:e,name:e,description:""}))),Y(t.map(e=>{var a,l,t,i,s,o;return{id:String(e.id),name:e.name||"",province:e.province||"",country:{id:String((null===(a=e.country)||void 0===a?void 0:a.id)||""),name:(null===(l=e.country)||void 0===l?void 0:l.name)||"",code:(null===(t=e.country)||void 0===t?void 0:t.code)||(null===(i=e.country)||void 0===i?void 0:i.initial)||""},type:{id:Number(null===(s=e.type)||void 0===s?void 0:s.id)||1,name:(null===(o=e.type)||void 0===o?void 0:o.name)||"Default"}
1,radius:Number(e.radius)||0,restrictions:e.restrictions||[],cities:e.cities||[],postalCodes:e.postalCodes||[],serviceTypes:e.serviceTypes||[],emergencyServices:Boolean(e.emergencyServices)||!1}}))}}catch(e){console.error("Error fetching emergency categories:",e)}}},ce=(e,a,l)=>{I(t=>{const i=t[e]||{start:"",end:"",active:!1};return"active"===a&&!0===l?{...t,[e]:{start:i.start||"09:00",end:i.end||"17:00",active:!0}}:{...t,[e]:{...i,[a]:l}}})};return l?(0,b.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,b.jsx)("div",{className:"bg-white rounded-xl shadow-lg p-6 w-full max-w-full sm:max-w-2xl lg:max-w-4xl max-h-[90vh] overflow-y-auto",children:(0,b.jsxs)("div",{className:"max-h-[80vh] overflow-y-auto text-left",children:[(0,b.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,b.jsx)("h3",{className:"text-xl font-semibold mb-4",children:k("availabilityModal.title")}),(0,b.jsx)("button",{onClick:j,className:"text-gray-500 hover:text-gray-700 text-2xl",children:"\xd7"})]}),(0,b.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),!a||T.trim()){if(a&&!ie){if(0===K.length)return void h.dI.showToast("error",k("toast.availabilities.validationError"),k("toast.availabilities.emergencyCategoryRequired"));if(0===Q.length)return void h.dI.showToast("error",k("toast.availabilities.validationError"),k("toast.availabilities.emergencyAreaRequired"))}if(a&&null!==S&&void 0!==S&&S.id&&T.trim()){const e=(null===S||void 0===S?void 0:S.whatsappNumber)||(null===S||void 0===S?void 0:S.contactOnWhatsapp)||"";if(T.trim()!==e)try{await A((0,x.Kg)({id:S.id,data:{...S,whatsappNumber:T.trim(),contactOnWhatsapp:!0}})),console.log("WhatsApp number updated successfully")}catch(l){console.error("Error updating WhatsApp number:",l)}}
1if(y(R),a&&null!==S&&void 0!==S&&S.id)try{if(ie){if(await A((0,u.$G)({userId:S.id,type:m.j8.Emergency,categoryIds:[],subCategories:[],serviceAreaIds:[]})),re&&re.length>0)for(const e of re)try{await A((0,v.AC)({id:e.id}))}catch(l){console.error("Error deleting emergency availability:",l)}console.log("Emergency data reset successfully"),h.dI.showToast("success",k("toast.titles.success"),k("toast.availabilities.emergencyDataReset")),setTimeout(()=>{w&&w()},100)}else await A((0,u.$G)({userId:S.id,type:m.j8.Emergency,categoryIds:K.length>0?K.map(e=>({id:e.id})):[],subCategories:Z.length>0?Z.map(e=>e.name):[],serviceAreaIds:Q.length>0?Q.map(e=>({id:e.id})):[]})),await A((0,u.$G)({userId:S.id,type:m.j8.Profile,categoryIds:[],subCategories:[],serviceAreaIds:[]})),console.log("Emergency categories and service areas saved successfully"),console.log("Profile categories and service areas cleared to ensure emergency data precedence");N&&N()}catch(l){console.error("Error saving emergency categories and service areas:",l)}j()}else h.dI.showToast("error",k("toast.availabilities.validationError"),k("toast.availabilities.whatsappRequired"))},className:"space-y-6",children:[a&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-6",children:(0,b.jsxs)("div",{className:"flex items-start",children:[(0,b.jsx)("div",{className:"w-6 h-6 bg-red-500 rounded-full flex items-center justify-center mr-3 mt-0.5",children:(0,b.jsx)(o.A,{className:"w-4 h-4 text-white"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h4",{className:"font-semibold text-red-800 mb-2",children:k("availabilityModal.importantNotice")}),(0,b.jsxs)("p",{className:"text-red-700 text-sm",children:[k("availabilityModal.emergencyNoticeMessage")," ",(0,b.jsx)("span",{className:"font-bold",children:k("availabilityModal.emergencyProfessional")}),". ",k("availabilityModal.emergencyNoticeDetails")]})]})]})}),(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:[k("availabilityModal.whatsappNumber")," ",(0,b.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,b.jsx)("span",{className:"text-black-500 text-sm",children:"+"})}),(0,b.jsx)("input",{type:"tel",value:T.replace(/^\+/,""),onChange:e=>{let a=e.target.value.replace(/\D/g,"");a&&(a="+"+a),B(a)},placeholder:k("availabilityModal.whatsappPlaceholder"),className:"w-full pl-8 pr-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",required:!0})]}),(0,b.jsx)("p",{className:"text-gray-600 text-sm mt-1",children:null!==S&&void 0!==S&&S.whatsappNumber||null!==S&&void 0!==S&&S.contactOnWhatsapp?k("availabilityModal.whatsappUpdateHint"):k("availabilityModal.whatsappRequiredHint")})]})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,b.jsx)("h4",{className:"font-medium",children:k(a?"availabilityModal.emergencyHours":"availabilityModal.regularHours")}),(0,b.jsxs)("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg p-1",children:[(0,b.jsx)("button",{type:"button",onClick:()=>ne("12"),className:"px-3 py-1 text-sm font-medium rounded-md transition-colors "+(U?"text-gray-600 hover:text-gray-900":"bg-white text-blue-600 shadow-sm"),children:"12h"}),(0,b.jsx)("button",{type:"button",onClick:()=>ne("24"),className:"px-3 py-1 text-sm font-medium rounded-md transition-colors "+(U?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"),children:"24h"})]})]}),["monday","tuesday","wednesday","thursday","friday","saturday","sunday"].map(e=>{var a,l,t,i,s;return(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-4 py-3 border-b last:border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[(0,b.jsx)("div",{className:"w-24 capitalize font-medium text-gray-700",children:k(`availabilityModal.days.${e}`)}),(0,b.jsxs)("label",{className:"relative inline-flex items-center cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:(null===(a=R[e])||void 0===a?void 0:a.active)||!1,onChange:a=>ce(e,"active",a.target.checked),className:"sr-only peer"}),(0,b.jsx)("div",{className:"w-11 h-6 bg-gray-200 rounded-full peer peer-checked:bg-blue-600 peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all"})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap w-full sm:w-auto
1sm:ml-auto",children:[(0,b.jsx)(g.A,{value:(null===(l=R[e])||void 0===l?void 0:l.start)||"09:00",onChange:a=>ce(e,"start",a),disabled:!(null!==(t=R[e])&&void 0!==t&&t.active),use24Hour:U,className:"flex-shrink-0"}),(0,b.jsx)("span",{className:"text-gray-500 text-sm",children:k("availabilityModal.to")}),(0,b.jsx)(g.A,{value:(null===(i=R[e])||void 0===i?void 0:i.end)||"17:00",onChange:a=>ce(e,"end",a),disabled:!(null!==(s=R[e])&&void 0!==s&&s.active),use24Hour:U,className:"flex-shrink-0"})]})]},e)})]}),a&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)("h4",{className:"font-medium mb-3",children:[k("availabilityModal.emergencyCategories")," ",(0,b.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:k("availabilityModal.categoriesHint")}),(0,b.jsx)(d.A,{selectedCategories:K,selectedSubcategories:Z,onCategoriesChange:H,onSubcategoriesChange:$,disabled:!1,professionalType:ae})]}),(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)("h4",{className:"font-medium mb-3",children:[k("availabilityModal.emergencyAreas")," ",(0,b.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:k("availabilityModal.areasHint")}),(0,b.jsx)(c.A,{selectedServiceAreas:Q,onServiceAreasChange:Y,disabled:!1})]})]}),(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between gap-4",children:[(0,b.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,b.jsx)("input",{type:"checkbox",id:"resetData",checked:a?ie:C,onChange:e=>{a?se(e.target.checked):M&&M(e.target.checked)},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),(0,b.jsx)("label",{htmlFor:"resetData",className:"text-sm text-gray-700",children:k(a?"availabilityModal.resetEmergency":"availabilityModal.resetRegular")})]}),a&&(0,b.jsx)("p",{className:"text-xs text-gray-500 mt-1 ml-6",children:k("availabilityModal.resetEmergencyDescription")}),(0,b.jsxs)("div",{className:"flex gap-4",children:[(0,b.jsx)(s.A,{type:"button",variant:"outline",onClick:j,children:k("availabilityModal.cancel")}),(0,b.jsx)(s.A,{type:"submit",children:k((a?ie:C)?"availabilityModal.resetAndSave":"availabilityModal.saveChanges")})]})]})]})]})})}):null}},84104(e,a,l){l.d(a,{A:()=>k});var t=l(43145),i=l(5763),s=l(5544),o=l(9950),r=l(94408),n=l(96479),d=l(10300),c=l(86400),u=l(83344),m=l(51859),x=l(49164),h=l(30525),v=l(22843),p=l(7732),g=l(45448),b=l(89051),f=l(60817),y=l(98932),j=l(45816),N=l(32794),w=l(64767),C=l(95351),M=l(44414);const k=e=>{var a,l,k,A,S,E,P,R;let I=e.isOpen,L=e.onClose,D=e.profileData,T=e.setProfileData,B=e.onDataSaved,G=e.isAdminEdit,q=void 0!==G&&G,U=e.adminUserId,O=void 0===U?null:U;const z=(0,w.Bd)(),F=z.t,K=z.i18n,H=(0,o.useState)(!1),V=(0,s.A)(H,2),W=V[0],Z=V[1],$=(0,o.useState)({name:(null===D||void 0===D?void 0:D.name)||"",title:(null===D||void 0===D?void 0:D.title)||"",email:(null===D||void 0===D?void 0:D.email)||"",phone:(null===D||void 0===D?void 0:D.phone)||"",bio:(null===D||void 0===D?void 0:D.bio)||"",hourlyRate:(null===D||void 0===D||null===(a=D.hourlyRate)||void 0===a?void 0:a.toString())||"",taxCode:(null===D||void 0===D?void 0:D.taxCode)||"",address:(null===D||void 0===D?void 0:D.address)||(null===D||void 0===D||null===(l=D.personal)||void 0===l?void 0:l.address)||"",latitude:(null===D||void 0===D?void 0:D.latitude)||(null===D||void 0===D||null===(k=D.personal)||void 0===k?void 0:k.latitude)||"",longitude:(null===D||void 0===D?void 0:D.longitude)||(null===D||void 0===D||null===(A=D.personal)||void 0===A?void 0:A.longitude)||"",province:(null===D||void 0===D?void 0:D.province)||(null===D||void 0===D||null===(S=D.personal)||void 0===S?void 0:S.province)||"",country:(null===D||void 0===D?void 0:D.country)||(null===D||void 0===D||null===(E=D.personal)||void 0===E?void 0:E.country)||void 0}),_=(0,s.A)($,2),J=_[0],Q=_[1],Y=(0,o.useState)(!1),X=(0,s.A)(Y,2),ee=X[0],ae=X[1],le=(0,o.useState)(""),te=(0,s.A)(le,2),ie=te[0],se=te[1],oe=o.useRef(null);o.useEffect(()=>{const e=e=>{oe.current&&!oe.current.contains(e.target)&&ae(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const re=[["+93","Afghanistan","AF"],["+355","Albania","AL"],["+213","Algeria","DZ"],["+376","Andorra","AD"],["+244","Angola","AO"],["+54","Argentina","AR"],["+374","Armenia","AM"],["+61","Australia","AU"],["+43","Austr
1ia","AT"],["+994","Azerbaijan","AZ"],["+973","Bahrain","BH"],["+880","Bangladesh","BD"],["+375","Belarus","BY"],["+32","Belgium","BE"],["+501","Belize","BZ"],["+229","Benin","BJ"],["+591","Bolivia","BO"],["+387","Bosnia","BA"],["+267","Botswana","BW"],["+55","Brazil","BR"],["+673","Brunei","BN"],["+359","Bulgaria","BG"],["+226","Burkina Faso","BF"],["+257","Burundi","BI"],["+855","Cambodia","KH"],["+237","Cameroon","CM"],["+1","Canada","CA"],["+238","Cape Verde","CV"],["+236","C. African Rep.","CF"],["+235","Chad","TD"],["+56","Chile","CL"],["+86","China","CN"],["+57","Colombia","CO"],["+506","Costa Rica","CR"],["+385","Croatia","HR"],["+53","Cuba","CU"],["+357","Cyprus","CY"],["+420","Czech Rep.","CZ"],["+243","DR Congo","CD"],["+45","Denmark","DK"],["+253","Djibouti","DJ"],["+809","Dominican Rep.","DO"],["+593","Ecuador","EC"],["+20","Egypt","EG"],["+503","El Salvador","SV"],["+240","Eq. Guinea","GQ"],["+291","Eritrea","ER"],["+372","Estonia","EE"],["+251","Ethiopia","ET"],["+358","Finland","FI"],["+33","France","FR"],["+241","Gabon","GA"],["+220","Gambia","GM"],["+995","Georgia","GE"],["+49","Germany","DE"],["+233","Ghana","GH"],["+30","Greece","GR"],["+502","Guatemala","GT"],["+224","Guinea","GN"],["+245","Guinea-Bissau","GW"],["+592","Guyana","GY"],["+509","Haiti","HT"],["+504","Honduras","HN"],["+852","Hong Kong","HK"],["+36","Hungary","HU"],["+354","Iceland","IS"],["+91","India","IN"],["+62","Indonesia","ID"],["+98","Iran","IR"],["+964","Iraq","IQ"],["+353","Ireland","IE"],["+972","Israel","IL"],["+39","Italy","IT"],["+225","Ivory Coast","CI"],["+1876","Jamaica","JM"],["+81","Japan","JP"],["+962","Jordan","JO"],["+7","Kazakhstan","KZ"],["+254","Kenya","KE"],["+965","Kuwait","KW"],["+996","Kyrgyzstan","KG"],["+856","Laos","LA"],["+371","Latvia","LV"],["+961","Lebanon","LB"],["+266","Lesotho","LS"],["+231","Liberia","LR"],["+218","Libya","LY"],["+423","Liechtenstein","LI"],["+370","Lithuania","LT"],["+352","Luxembourg","LU"],["+853","Macao","MO"],["+261","Madagascar","MG"],["+265","Malawi","MW"],["+60","Malaysia","MY"],["+960","Maldives","MV"],["+223","Mali","ML"],["+356","Malta","MT"],["+222","Mauritania","MR"],["+230","Mauritius","MU"],["+52","Mexico","MX"],["+373","Moldova","MD"],["+377","Monaco","MC"],["+976","Mongolia","MN"],["+382","Montenegro","ME"],["+212","Morocco","MA"],["+258","Mozambique","MZ"],["+95","Myanmar","MM"],["+264","Namibia","NA"],["+977","Nepal","NP"],["+31","Netherlands","NL"],["+64","New Zealand","NZ"],["+505","Nicaragua","NI"],["+227","Niger","NE"],["+234","Nigeria","NG"],["+850","N. Korea","KP"],["+389","N. Macedonia","MK"],["+47","Norway","NO"],["+968","Oman","OM"],["+92","Pakistan","PK"],["+507","Panama","PA"],["+675","Papua N. Guinea","PG"],["+595","Paraguay","PY"],["+51","Peru","PE"],["+63","Philippines","PH"],["+48","Poland","PL"],["+351","Portugal","PT"],["+974","Qatar","QA"],["+40","Romania","RO"],["+7","Russia","RU"],["+250","Rwanda","RW"],["+966","Saudi Arabia","SA"],["+221","Senegal","SN"],["+381","Serbia","RS"],["+232","Sierra Leone","SL"],["+65","Singapore","SG"],["+421","Slovakia","SK"],["+386","Slovenia","SI"],["+252","Somalia","SO"],["+27","South Africa","ZA"],["+82","South Korea","KR"],["+34","Spain","ES"],["+94","Sri Lanka","LK"],["+249","Sudan","SD"],["+597","Suriname","SR"],["+46","Sweden","SE"],["+41","Switzerland","CH"],["+963","Syria","SY"],["+886","Taiwan","TW"],["+992","Tajikistan","TJ"],["+255","Tanzania","TZ"],["+66","Thailand","TH"],["+228","Togo","TG"],["+216","Tunisia","TN"],["+90","Turkey","TR"],["+993","Turkmenistan","TM"],["+256","Uganda","UG"],["+380","Ukraine","UA"],["+971","UAE","AE"],["+44","United Kingdom","GB"],["+1","United States","US"],["+598","Uruguay","UY"],["+998","Uzbekistan","UZ"],["+58","Venezuela","VE"],["+84","Vietnam","VN"],["+967","Yemen","YE"],["+260","Zambia","ZM"],["+263","Zimbabwe","ZW"],["+1242","Bahamas","BS"],["+1246","Barbados","BB"],["+1268","Antigua","AG"],["+1345","Cayman Is.","KY"],["+1441","Bermuda","BM"],["+1473","Grenada","GD"],["+1671","Guam","GU"],["+1758","St. Lucia","LC"],["+1767","Dominica","DM"],["+1784","St. Vincent","VC"],["+1787","Puerto Rico","PR"],["+1868","Trinidad","TT"],["+1869","St. Kitts","KN"],["+211","South Sudan","SS"],["+239","Sao Tome","ST"],["+242","Congo Rep.","CG"],["+248","Seychelles","SC"],["+268","Eswatini","SZ"],["+269","Comoros","KM"],["+297","Aruba","AW"],["+383","Kosovo","XK"],["+590","Guadeloupe","GP"],["+596","Martinique","MQ"],["+599","Curacao","CW"],["+670","Timor-Leste","TL"],["+672","Norfolk Is.","NF"],["+676","Tonga","TO"],["+677","Solomon Is.","SB"],["+678","Vanuatu","VU"],["+679","Fiji","FJ"],["+680","Palau","PW"],["+685","Samoa","WS"],["+686","Kiribati","KI"],["+691","Micronesia","FM"],["+692","Marshall Is.","MH"],["+975","Bhutan","BT"]],ne=ie?re.filter(e=>e[0].includes(ie)||e[1].toLowerCase().includes(ie.toLowerCase())||e[2].toLowerCase().includes(ie.toLowerCase())):re,de=(0,o.useState)(()=>{const e=(null===D||void 0===D?void 0:D.phone)||"",a=["+93","+355","+213","+376","+244","+54","+374","+61","+43","+994","+973","+880","+375","+32","+501","+229","+591","+387","+267","+55","+673","+359","+226","+257","+855","+237","+1","+238","+236","+235","+56","+86","+57","+506","+385","+53","+357","+420","+243","+45","+253","+809","+593","+20","+503","+240","+291","+372","+251","+358","+33","+241","+220","+995","+49","+233","+30","+502","+224","+245","+592","+509","+504","+852","+36","+354","+91","+62","+98","+964","+353","+972","+39","+225","+1876","+81","+962","+7","+254","+965","+996","+856","+371","+961","+266","+231","+218","+423","+370","+352","+853","+261","+265","+60","+960","+223","+356","+222","+230","+52","+373","+377","+976","+382","+212","+258","+95","+264","+977","+31","+64","+505","+227","+234","+850","+389","+47","+968","+92","+507","+675","+595","+51","+63","+48","+351","+974","+40","+7","+250","+966","+221","+381","+232","+65","+421","+386","+252","+27","+82","+34","+94","+249","+597","+46","+41","+963","+886","+992","+255","+66","+228","+216","+90","+993","+256","+380","+971","+44","+1","+598","+998","+58","+84","+967","+260","+263"];for(const l of a)if(e.startsWith(l))return l;return"+1"}),ce=(0,s.A)(de,2),ue=ce[0],me=ce[1],xe=(0,d.d4)(e=>e.professional),he=(xe.availabilities,xe.emergencyAvailabilities),ve=(0,o.useState)([]),pe=(0,s.A)(ve,2),ge=pe[0],be=pe[1],fe=(0,o.useState)([]),ye=(0,s.A)(fe,2),je=ye[0],Ne=ye[1],we=(0,o.useState)([]),Ce=(0,s.A)(we,2),Me=(Ce[0],Ce[1]),ke=(0,o.useState)(0),Ae=(0,s.A)(ke,2),Se=Ae[0],Ee=Ae[1];(0,o.useEffect)(()=>{},[ge]);const Pe=(0,o.useState)([]),Re=(0,s.A)(Pe,2),Ie=Re[0],Le=Re[1],De=(0,d.d4)(u.XS),Te=(0,d.d4)(e=>e.auth).user,Be=(0,d.d4)(e=>e.userCategory).userCategories,Ge=((0,d.d4)(e=>e.client.categoriesByType),(0,c.jLQ)()),qe=(0,o.useState)({}),Ue=(0,s.A)(qe,2),Oe=Ue[0],ze=Ue[1],Fe=(0,o.useState)((()=>{var e,a,l;if(q&&null!==D&&void 0!==D&&null!==(e=D.role)&&void 0!==e&&e.id){return[x.Uv.professional,x.Uv.internationl_professional].includes(Number(D.role.id))?Number(D.role.id):x.Uv.professional}return[x.Uv.professional,x.Uv.internationl_professional].includes(Number(null===Te||void 0===Te||null===(a=Te.role)||void 0===a?void 0:a.id))?Number(null===Te||void 0===Te||null===(l=Te.role)||void 0===l?void 0:l.id):x.Uv.professional}
1)()),Ke=(0,s.A)(Fe,2),He=Ke[0],Ve=Ke[1],We=(0,o.useState)(1),Ze=(0,s.A)(We,2),$e=Ze[0],_e=Ze[1],Je=(0,o.useState)(!1),Qe=(0,s.A)(Je,2),Ye=Qe[0],Xe=Qe[1],ea=(0,o.useState)(""),aa=(0,s.A)(ea,2),la=aa[0],ta=aa[1],ia=(0,o.useState)(!1),sa=(0,s.A)(ia,2),oa=sa[0],ra=sa[1],na=(0,o.useState)(!0),da=(0,s.A)(na,2),ca=da[0],ua=da[1],ma=(0,o.useState)(!0),xa=(0,s.A)(ma,2),ha=xa[0],va=xa[1];(0,o.useEffect)(()=>{D&&Q(e=>{var a,l,t,i,s,o;return{...e,name:(null===D||void 0===D?void 0:D.name)||"",title:(null===D||void 0===D?void 0:D.title)||"",email:(null===D||void 0===D?void 0:D.email)||"",phone:(null===D||void 0===D?void 0:D.phone)||"",bio:(null===D||void 0===D?void 0:D.bio)||"",hourlyRate:(null===D||void 0===D||null===(a=D.hourlyRate)||void 0===a?void 0:a.toString())||"",taxCode:(null===D||void 0===D?void 0:D.taxCode)||"",address:(null===D||void 0===D?void 0:D.address)||(null===D||void 0===D||null===(l=D.personal)||void 0===l?void 0:l.address)||e.address,latitude:(null===D||void 0===D?void 0:D.latitude)||(null===D||void 0===D||null===(t=D.personal)||void 0===t?void 0:t.latitude)||e.latitude,longitude:(null===D||void 0===D?void 0:D.longitude)||(null===D||void 0===D||null===(i=D.personal)||void 0===i?void 0:i.longitude)||e.longitude,province:(null===D||void 0===D?void 0:D.province)||(null===D||void 0===D||null===(s=D.personal)||void 0===s?void 0:s.province)||e.province,country:(null===D||void 0===D?void 0:D.country)||(null===D||void 0===D||null===(o=D.personal)||void 0===o?void 0:o.country)||e.country}})},[D]),(0,o.useEffect)(()=>{const e=q?O:null===Te||void 0===Te?void 0:Te.id;I&&e&&pa()},[I,null===Te||void 0===Te?void 0:Te.id,q,O]),(0,o.useEffect)(()=>{He===x.Uv.internationl_professional&&_e(3)},[He]);const pa=async()=>{const e=q?O:null===Te||void 0===Te?void 0:Te.id;if(!e)return;const a=`kokobeo_categories_${e}`,l=localStorage.getItem(a);if(l)try{var t,i;const e=JSON.parse(l);if((null===(t=e.categories)||void 0===t?void 0:t.length)>0||(null===(i=e.serviceAreas)||void 0===i?void 0:i.length)>0)return be(e.categories||[]),Ne(e.subcategories||[]),Le(e.serviceAreas||[]),void console.log("Loaded from localStorage")}catch(r){console.error("localStorage parse error:",r)}const s=`${e}-${b.j8.Profile}`,o=Be[s];if(console.log("aaa",o),o){const e=o.categoryIds||[],a=o.subCategories||[],l=o.serviceAreaIds||[];return be(e.map(e=>({id:e.id,name:e.name,description:e.description||"",subcategories:e.subcategories||[],isEmergency:e.isEmergency,isRequireVerification:e.isRequireVerification,type:e.type}))),Ne(a.map(e=>({id:e,name:e,description:""}))),void Le(l.map(e=>{var a,l,t;return{id:e.id,name:e.name||"",province:e.province||"",country:{id:(null===(a=e.country)||void 0===a?void 0:a.id)||"",name:(null===(l=e.country)||void 0===l?void 0:l.name)||"",code:(null===(t=e.country)||void 0===t?void 0:t.code)||""},type:{id:1,name:"Default"},radius:0,restrictions:[],cities:[],postalCodes:[],serviceTypes:[],emergencyServices:!1}}))}try{const a=await Ge((0,p.jD)({userId:e,type:b.j8.Profile})).unwrap();if(a){const e=a.categoryIds||[],l=a.subCategories||[],t=a.serviceAreaIds||[];Me(e),be(e.map(e=>({id:e.id,name:e.name,description:e.description||"",subcategories:e.subcategories||[],isEmergency:e.isEmergency,isRequireVerification:e.isRequireVerification,type:e.type}))),Ne(l.map(e=>({id:e,name:e,description:""}))),Le(t.map(e=>{var a,l,t;return{id:e.id,name:e.name||"",province:e.province||"",country:{id:(null===(a=e.country)||void 0===a?void 0:a.id)||"",name:(null===(l=e.country)||void 0===l?void 0:l.name)||"",code:(null===(t=e.country)||void 0===t?void 0:t.code)||""},type:{id:1,name:"Default"},radius:0,restrictions:[],cities:[],postalCodes:[],serviceTypes:[],emergencyServices:!1}}))}}catch(n){console.error("Error fetching user categories:",n)}},ga=e=>{console.log("Professional type changed to:",e),Ve(e),e===x.Uv.professional?_e(1):e===x.Uv.internationl_professional&&_e(3),be([]),Ne([]),Le([]),Ee(e=>e+1)},ba=e=>{if(console.log("Category type changed to:",e),_e(e),be([]),Ne([]),Le([]),null!==Te&&void 0!==Te&&Te.id||q){q||(null===Te||void 0===Te||Te.id);Ge((0,g.Rn)({id:e}))}},fa=e=>{const a=e.target,l=a.name,t=a.value;Q({...J,[l]:t}),ze(e=>({...e,[l]:""}))};return(0,M.jsxs)(r.lG,{open:I,onClose:L,className:"fixed z-50 inset-0 overflow-y-auto",children:[(0,M.jsx)("div",{className:"flex items-center justify-center min-h-screen p-4 bg-black bg-opacity-30",children:(0,M.jsxs)(r.lG.Panel,{className:"w-full max-w-4xl rounded-2xl bg-white p-6 shadow-xl max-h-[90vh] overflow-y-auto",children:[(0,M.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,M.jsxs)("div",{className:"flex items-center gap-2",children:[(0,M.jsx)(r.lG.Title,{className:"text-lg font-semibold",children:F("editProfileModal.modalTitle")}),(0,M.jsx)("button",{onClick:()=>Z(!0),className:"w-6 h-6 rounded-full bg-blue-100 hover:bg-blue-200 text-blue-600 flex items-center justify-center text-sm font-bold transition-colors",title:"Come ottimizzare il profilo",children:"?"})]}),(0,M.jsx)("button",{onClick:()=>{De||L()},className:"text-gray-500 hover:text-black",children:(0,M.jsx)(n.A,{className:"w-5 h-5"})})]}),!(null!==Te&&void 0!==Te&&Te.phone)&&(0,M.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 mb-6",children:(0,M.jsxs)("div",{className:"flex items-start",children:[(0,M.jsx)("div",{className:"flex-shrink-0",children:(0,M.jsx)("svg",{className:"h-5 w-5 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,M.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),(0,M.jsxs)("div",{className:"ml-3",children:[(0,M.jsx)("h3",{className:"text-sm font-medium text-blue-800",children:F("editProfileModal.completeProfile")}),(0,M.jsx)("div",{className:"mt-1 text-sm text-blue-700",children:(0,M.jsx)("p",{children:F("editProfileModal.completeProfileMessage")})})]})]})}),ha&&!(null!==Te&&void 0!==Te&&Te.phone)&&(0,M.jsxs)("div",{className:"mb-4 bg-amber-50 border border-amber-200 rounded-lg p-3 sm:p-4 relative",children:[(0,M.jsx)("button",{type:"button",onClick:()=>va(!1),className:"absolute top-2 right-2 text-amber-600 hover:text-amber-800",children:(0,M.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,M.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,M.jsx)("div",{className:"pr-6",children:(0,M.jsxs)("ul",{className:"text-xs sm:text-sm text-amber-800 space-y-2 list-disc list-inside",children:[(0,M.jsx)("li",{children:F("editProfileModal.infoBannerPrivacy")}),(0,M.jsx)("li",{children:F("editProfileModal.infoBannerEmergency")})]})})]}),(0,M.jsxs)("div",{className:"space-y-4",children:[[{name:"name",label:F("editProfileModal.name"),type:"text",placeholder:F("editProfileModal.namePlaceholder")},{name:"title",label:F("editProfileModal.jobTitle"),type:"text",placeholder:F("editProfileModal.titlePlaceholder")},{name:"email",label:F("editProfileModal.email"),type:"email",placeholder:F("editProfileModal.emailPlaceholder")},{name:"hourlyRate",label:F("editProfileModal.hourlyRate"),type:"text",placeholder:F("editProfileModal.hourlyRatePlaceholder")}].map(e=>(0,M.jsxs)("div",{children:[(0,M.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:e.label}),(0,M.jsx)("input",{disabled:"email"===e.name,name:e.name,type:e.type,value:J[e.name],onChange:fa,placeholder:e.placeholder,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),Oe[e.name]&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-1",children:Oe[e.name]})]},e.name)),(0,M.jsxs)("div",{children:[(0,M.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:F("editProfileModal.phone")}),(0,M.jsxs)("div",{className:"relative flex mt-1",children:[(0,M.jsxs)("div",{ref:oe,className:"relative",style:{minWidth:"90px"},children:[(0,M.jsxs)("button",{type:"button",onClick:()=>{ae(!ee),se("")},className:"rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-sm px-2 py-2 w-full text-left flex items-center gap-1 hover:bg-gray-100",children:[(()=>{const e=re.find(e=>e[0]===ue);return e?e[2]:""})()," ",ue," ",(0,M.jsx)("svg",{className:"w-3 h-3 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,M.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),ee&&(0,M.jsxs)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white border border-gray-300 rounded-md shadow-lg",style:{width:"250px",maxHeight:"250px"},children:[(0,M.jsx)("div",{className:"p-2 border-b",children:(0,M.jsx)("input",{autoFocus:!0,t
1ype:"text",value:ie,onChange:e=>se(e.target.value),placeholder:{en:"Search country or code...",it:"Cerca paese o prefisso...",es:"Buscar pa\xeds o c\xf3digo...",fr:"Chercher pays ou code...",de:"Land oder Vorwahl suchen...",pt:"Buscar pa\xeds ou c\xf3digo...",nl:"Zoek land of code...",ru:"\u041f\u043e\u0438\u0441\u043a \u0441\u0442\u0440\u0430\u043d\u044b...",ja:"\u56fd\u540d\u307e\u305f\u306f\u30b3\u30fc\u30c9\u3092\u691c\u7d22...",zh:"\u641c\u7d22\u56fd\u5bb6\u6216\u533a\u53f7...",ko:"\uad6d\uac00 \ub610\ub294 \ucf54\ub4dc \uac80\uc0c9...",ar:"\u0627\u0628\u062d\u062b \u0639\u0646 \u0628\u0644\u062f \u0623\u0648 \u0631\u0645\u0632...",hi:"\u0926\u0947\u0936 \u092f\u093e \u0915\u094b\u0921 \u0916\u094b\u091c\u0947\u0902...",cs:"Hledat zemi nebo k\xf3d...",pl:"Szukaj kraju lub kodu..."}[K.language]||"Search country or code...",className:"w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500"})}),(0,M.jsx)("div",{style:{maxHeight:"200px",overflowY:"auto"},children:ne.map((e,a)=>(0,M.jsxs)("div",{onClick:()=>{const a=J.phone.replace(/^\+\d+/,"").replace(/^\+/,"");me(e[0]),Q({...J,phone:e[0]+a}),ae(!1)},className:"px-3 py-1.5 text-sm hover:bg-blue-50 cursor-pointer flex items-center gap-2",children:[(0,M.jsx)("span",{children:e[2]}),(0,M.jsx)("span",{className:"text-gray-600",children:e[1]}),(0,M.jsx)("span",{className:"text-gray-400 ml-auto",children:e[0]})]},a))})]})]}),(0,M.jsx)("input",{type:"tel",value:J.phone.startsWith(ue)?J.phone.slice(ue.length):J.phone.replace(/^\+/,""),onChange:e=>{const a=e.target.value.replace(/\D/g,"");Q({...J,phone:ue+a})},placeholder:"123 456 7890",className:"block w-full rounded-r-md border border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-3 text-sm"})]}),Oe.phone&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-1",children:Oe.phone})]}),(0,M.jsxs)("div",{className:"mt-4",children:[(0,M.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:F("editProfileModal.professionalType")}),(0,M.jsxs)("div",{className:"flex gap-6",children:[(0,M.jsxs)("label",{className:"inline-flex items-center",children:[(0,M.jsx)("input",{type:"radio",className:"h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500",checked:He===x.Uv.professional,onChange:()=>ga(x.Uv.professional)}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.nationalProfessional")})]}),(0,M.jsxs)("label",{className:"inline-flex items-center",children:[(0,M.jsx)("input",{type:"radio",className:"h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500",checked:He===x.Uv.internationl_professional,onChange:()=>ga(x.Uv.internationl_professional)}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.internationalProfessional")})]})]})]}),(0,M.jsxs)("div",{className:"mt-4",children:[(0,M.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:F("editProfileModal.categoryType")}),(0,M.jsxs)("div",{className:"flex gap-6",children:[He===x.Uv.professional&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)("label",{className:"inline-flex items-center",children:[(0,M.jsx)("input",{type:"radio",className:"h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500",checked:1===$e,onChange:()=>ba(1)}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.homeService")})]}),(0,M.jsxs)("label",{className:"inline-flex items-center",children:[(0,M.jsx)("input",{type:"radio",className:"h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500",checked:2===$e,onChange:()=>ba(2)}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.professionalService")})]})]}),He===x.Uv.internationl_professional&&(0,M.jsxs)("label",{className:"inline-flex items-center",children:[(0,M.jsx)("input",{type:"radio",className:"h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500",checked:3===$e,onChange:()=>ba(3)}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.internationalService")})]})]})]}),(!he||0===he.length||Number(null===Te||void 0===Te||null===(P=Te.role)||void 0===P?void 0:P.id)===x.Uv.internationl_professional)&&(0,M.jsxs)("div",{className:"mt-6",children:[(0,M.jsx)(h.A,{selectedCategories:ge,selectedSubcategories:je,onCategoriesChange:be,onSubcategoriesChange:Ne,disabled:!1,professionalType:$e,resetKey:Se}),Oe.categories&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-2",children:Oe.categories})]}),(!he||0===he.length)&&(0,M.jsxs)("div",{className:"mt-6",children:[(0,M.jsx)(v.A,{selectedServiceAreas:Ie,professionalType:He,onServiceAreasChange:Le,disabled:!1}),Oe.serviceAreas&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-2",children:Oe.serviceAreas})]}),(0,M.jsxs)("div",{children:[(0,M.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,M.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:F("editProfileModal.bio")}),(0,M.jsx)(N.A,{userId:q?"object"===typeof O?null===O||void 0===O?void 0:O.id:O:"object"===typeof(null===Te||void 0===Te?void 0:Te.id)?null===Te||void 0===Te||null===(R=Te.id)||void 0===R?void 0:R.id:null===Te||void 0===Te?void 0:Te.id,language:K.language,categories:ge,subcategories:je.map(e=>e.name),onBioGenerated:e=>{fa({target:{name:"bio",value:e}}),Oe.bio&&ze(e=>({...e,bio:""}))},disabled:De,className:"text-sm"})]}),(0,M.jsx)("textarea",{name:"bio",value:J.bio,onChange:fa,placeholder:F("editProfileModal.bioPlaceholder"),rows:3,maxLength:450,className:"w-full border rounded-md p-2"}
1),Oe.bio&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-1",children:Oe.bio})]})]}),(0,M.jsxs)("div",{className:"mt-6 p-4 bg-gray-50 rounded-lg",children:[(0,M.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,M.jsx)("input",{type:"checkbox",id:"professionalRequirements",checked:ca,onChange:e=>ua(e.target.checked),className:"mt-1 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),(0,M.jsxs)("label",{htmlFor:"professionalRequirements",className:"text-sm text-gray-700 leading-relaxed",children:[F("editProfileModal.professionalRequirements")," ",(0,M.jsx)("button",{type:"button",onClick:()=>ra(!0),className:"text-blue-600 underline hover:text-blue-800 transition-colors",children:F("editProfileModal.professionalRequirementsLink")})]})]}),Oe.professionalRequirements&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-2",children:Oe.professionalRequirements})]}),(0,M.jsxs)("div",{className:"flex flex-col sm:flex-row justify-end mt-6 gap-3",children:[(0,M.jsx)("button",{onClick:()=>{De||L()},className:"px-4 py-2 border rounded-md w-full sm:w-auto",children:F("editProfileModal.cancel")}),(0,M.jsx)("button",{onClick:async()=>{var e,a,l,s,o;const r=(()=>{const e={},a=J.name,l=J.title,t=J.email,i=J.phone,s=J.bio,o=J.hourlyRate;if(J.taxCode,a.trim()){const e=a.trim().split(" ");e.length<2||e[1]}else e.name=F("editProfileModal.nameRequired");return l.trim()||(e.title=F("editProfileModal.titleRequired")),t.trim()?/\S+@\S+\.\S+/.test(t)||(e.email=F("editProfileModal.emailInvalid")):e.email=F("editProfileModal.emailRequired"),i.trim()||(e.phone=F("editProfileModal.phoneRequired")),s.trim()?s.length>450&&(e.bio=F("editProfileModal.bioMaxLength")):e.bio=F("editProfileModal.bioRequired"),o.trim()?(isNaN(Number(o))||Number(o)<=0)&&(e.hourlyRate=F("editProfileModal.hourlyRateInvalid")):e.hourlyRate=F("editProfileModal.hourlyRateRequired"),ca||(e.professionalRequirements=F("editProfileModal.professionalRequirementsRequired")),e})();x.Uv.professional,Boolean(q?null===D||void 0===D?void 0:D.address:null===Te||void 0===Te?void 0:Te.address)||Boolean(J.address);if(Object.keys(r).length>0){ze(r);const e=Object.keys(r)[0],a=r[e];y.dI.showToast("error",F("contractMilestoneModal.fillRequiredFields"),a);const l=document.querySelector("[data-field="+e+"]")||document.querySelector("[name="+e+"]");return void(l&&l.scrollIntoView({behavior:"smooth",block:"center"}))}if((!he||0===he.length)&&(0==ge.length||0==Ie.length))return void y.dI.showToast("error",F("editProfileModal.required"),F("editProfileModal.categoryRequired"));const n=J.name.split(" "),d=(0,i.A)(n),u=d[0],m=(0,t.A)(d).slice(1).join(" "),h={email:J.email,firstName:u||(q?null===D||void 0===D?void 0:D.firstName:Te.firstName),lastName:m||(q?null===D||void 0===D?void 0:D.lastName:Te.lastName),bio:J.bio,hourlyRate:Number(J.hourlyRate),title:J.title,phone:J.phone,taxCode:J.taxCode,socialLinks:q?(null===D||void 0===D?void 0:D.socialLinks)||[""]:(null===Te||void 0===Te?void 0:Te.socialLinks)||[""],photo:{id:q?(null===D||void 0===D||null===(e=D.photo)||void 0===e?void 0:e.id)||"":(null===Te||void 0===Te||null===(a=Te.photo)||void 0===a?void 0:a.id)||""},role:{id:He.toString()},status:{id:q?(null===D||void 0===D||null===(l=D.status)||void 0===l?void 0:l.id)||(null===Te||void 0===Te||null===(s=Te.status)||void 0===s?void 0:s.id):null===Te||void 0===Te||null===(o=Te.status)||void 0===o?void 0:o.id},isPhoneVerified:J.phone===(null===Te||void 0===Te?void 0:Te.phone)&&(null===Te||void 0===Te?void 0:Te.isPhoneVerified),categories:ge.map(e=>({id:e.id})),subcategories:je.map(e=>({id:e.id}))},v={email:J.email,name:u+" "+m,title:J.title,bio:J.bio,hourlyRate:Number(J.hourlyRate),phone:J.phone,taxCode:J.taxCode};T(e=>({...e,personal:{...e.personal,...v}}));const g=q?O:Te.id;await Ge((0,c.KgG)({id:g,data:h}));try{console.log("About to save categories. selectedCategories:",ge),console.log("About to save categories. selectedSubcategories:",je),console.log("About to save categories. selectedServiceAreas:",Ie);const e=`kokobeo_categories_${g}`;if(localStorage.setItem(e,JSON.stringify({categories:ge,subcategories:je,serviceAreas:Ie})),console.log("Categories saved to localStorage:",e),ge.length>0||Ie.length>0){const e={userId:g,type:b.j8.Profile,categoryIds:ge.map(e=>({id:e.id})),subCategories:je.map(e=>e.name),serviceAreaIds:Ie.map(e=>({id:e.id}))};console.log("Saving user categories:",e),console.log("Selected categories:",ge),console.log("Selected subcategories:",je),console.log("Selected service areas:",Ie);await Ge((0,p.$G)({userId:g,type:b.j8.Profile,categoryIds:ge.length>0?ge.map(e=>({id:e.id})):[],subCategories:je.length>0?je.map(e=>e.name):[],serviceAreaIds:Ie.length>0?Ie.map(e=>({id:e.id})):[]})).unwrap();await Ge((0,p.$G)({userId:g,type:b.j8.Emergency,categoryIds:[],subCategories:[],serviceAreaIds:[]})),console.log("Profile categories and service areas saved successfully"),console.log("Emergency categories and service areas cleared to ensure profile data precedence")}}catch(f){console.error("Error saving user categories:",f)}B&&B(),L()},className:"px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-800 flex justify-center items-center w-full sm:w-auto",children:De?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(m.A,{size:5}),(0,M.jsx)("span",{className:"ml-2",children:F("editProfileModal.loading")})]}):F("editProfileModal.saveChanges")}
1)]}),(0,M.jsx)(C.A,{isOpen:W,onClose:()=>Z(!1)})]})}),(0,M.jsx)(r.lG,{open:Ye,onClose:()=>Xe(!1),className:"fixed z-[60] inset-0 overflow-y-auto",children:(0,M.jsx)("div",{className:"flex items-center justify-center min-h-screen p-4 bg-black bg-opacity-40",children:(0,M.jsxs)(r.lG.Panel,{className:"w-full max-w-2xl rounded-2xl bg-white p-6 shadow-xl max-h-[85vh] overflow-y-auto",children:[(0,M.jsx)(f.A,{editingLocation:!0,isEditing:!0,startEditingLocation:()=>{},editedProfile:{address:J.address,latitude:J.latitude,longitude:J.longitude,province:J.province,country:J.country},handleFieldChange:(e,a)=>{Q(l=>({...l,[e]:a}))},validationPersonalErrors:{},profileData:{personal:{address:J.address,latitude:J.latitude,longitude:J.longitude,province:J.province,country:J.country}},handleLocationSaveChanges:()=>{J.address?Xe(!1):ta("Please select a valid address.")},setEditingLocation:Xe,showEditIcon:!1,isCurrentUser:!0,canEdit:!0}),la&&(0,M.jsx)("p",{className:"text-sm text-red-600 mt-2",children:la})]})})}),(0,M.jsx)(j.A,{isOpen:oa,onClose:()=>ra(!1)})]})}},50951(e,a,l){l.d(a,{A:()=>c});var t=l(5544),i=l(9950),s=l(96479),o=l(42461),r=l(86400),n=l(64767),d=l(44414);const c=e=>{let a=e.open,l=e.onClose,c=e.onSave,u=e.initialData;const m=(0,n.Bd)().t,x=(0,i.useState)([]),h=(0,t.A)(x,2),v=h[0],p=h[1],g=(0,i.useState)([]),b=(0,t.A)(g,2),f=b[0],y=b[1],j=(0,i.useState)({}),N=(0,t.A)(j,2),w=N[0],C=N[1],M=(0,r.jLQ)();(0,i.useEffect)(()=>{(null===u||void 0===u?void 0:u.length)>0?(p(u),y(u.map(()=>""))):(p([{title:"",company:"",period:"",description:"",achievements:[]}]),y([""])),C({})},[a,u]);const k=(e,a,l)=>{p(t=>{const i=[...t],s={...i[e]};return s[a]=l,i[e]=s,i})};return a?(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 overflow-auto",children:(0,d.jsxs)("div",{className:"bg-white p-6 rounded-lg w-full max-w-2xl shadow-lg relative max-h-[80vh] overflow-y-auto",children:[(0,d.jsx)("button",{className:"absolute top-6 right-3",onClick:l,children:(0,d.jsx)(s.A,{className:"w-5 h-5"})}),(0,d.jsx)("h3",{className:"text-xl font-semibold mb-4",children:m("experienceModal.title")}),(0,d.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(()=>{const e={};return v.forEach((a,l)=>{const t={};a.title&&a.title.trim()||(t.title=m("experienceModal.errors.titleRequired")),a.company&&a.company.trim()||(t.company=m("experienceModal.errors.companyRequired")),a.peri
1od&&a.period.trim()||(t.period=m("experienceModal.errors.periodRequired")),a.description&&a.description.trim()||(t.description=m("experienceModal.errors.descriptionRequired")),a.achievements&&0!==a.achievements.filter(e=>""!==e.trim()).length||(t.achievements=m("experienceModal.errors.achievementsRequired")),Object.keys(t).length>0&&(e[l]=t)}),C(e),0===Object.keys(e).length})()&&(c(v),l())},className:"space-y-6",children:[(0,d.jsx)(o.A,{type:"button",onClick:()=>{p([...v,{title:"",company:"",period:"",description:"",achievements:[]}]),y([...f,""])},className:"mb-4",children:m("experienceModal.addNew")}),v.map((e,a)=>{var l,t,i,n,c;return(0,d.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,d.jsxs)("div",{className:"flex justify-between items-start",children:[(0,d.jsxs)("h4",{className:"font-medium",children:[m("experienceModal.experienceNumber")," ",a+1]}),(0,d.jsx)("button",{type:"button",onClick:()=>(async e=>{const a=v[e];null!==a&&void 0!==a&&a.id&&await M((0,r.poL)({id:a.id}));const l=[...v];l.splice(e,1),p(l);const t=[...f];t.splice(e,1),y(t)})(a),className:"text-gray-400 hover:text-gray-600",children:(0,d.jsx)(s.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:m("experienceModal.titleLabel")}),(0,d.jsx)("input",{type:"text",value:e.title,onChange:e=>k(a,"title",e.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(l=w[a])||void 0===l?void 0:l.title)&&(0,d.jsx)("p",{className:"text-red-500 text-sm mt-2",children:w[a].title})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:m("experienceModal.company")}),(0,d.jsx)("input",{type:"text",value:e.company,onChange:e=>k(a,"company",e.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(t=w[a])||void 0===t?void 0:t.company)&&(0,d.jsx)("p",{className:"text-red-500 text-sm mt-2",children:w[a].company})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:m("experienceModal.period")}),(0,d.jsx)("input",{type:"text",value:e.period,onChange:e=>k(a,"period",e.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(i=w[a])||void 0===i?void 0:i.period)&&(0,d.jsx)("p",{className:"text-red-500 text-sm mt-2",children:w[a].period})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:m("experienceModal.description")}),(0,d.jsx)("textarea",{value:e.description,onChange:e=>k(a,"description",e.target.value),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(n=w[a])||void 0===n?void 0:n.description)&&(0,d.jsx)("p",{className:"text-red-500 text-sm mt-2",children:w[a].description})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:m("experienceModal.achievements")}),(0,d.jsxs)("div",{className:"space-y-2",children:[e.achievements.map((e,l)=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:e,onChange:e=>{const t=e.target.value;p(e=>{const i=[...e],s=[...i[a].achievements];return s[l]=t,i[a]={...i[a],achievements:s},i})},className:"flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(0,d.jsx)("button",{type:"button",onClick:()=>((e,a)=>{const l=[...v];l[e].achievements.splice(a,1),p(l)})(a,l),className:"text-gray-400 hover:text-gray-600",children:(0,d.jsx)(s.A,{className:"w-4 h-4"})})]},l)),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("input",{type:"text",placeholder:m("experienceModal.addAchievementPlaceholder"),value:f[a],onChange:e=>{const l=[...f];l[a]=e.target.value,y(l)},className:"flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(0,d.jsx)(o.A,{type:"button",onClick:()=>(e=>{const a=f[e].trim();a&&(p(l=>{const t=[...l],i=[...t[e].achievements];return""!==a&&i.push(a),t[e]={...t[e],achievements:i},t}),y(a=>{const l=[...a];return l[e]="",l}))})(a),children:m("experienceModal.addButton")})]}),(null===(c=w[a])||void 0===c?void 0:c.achievements)&&(0,d.jsx)("p",{className:"text-red-500 text-sm mt-2",children:w[a].achievements})]})]})]},a)}),(0,d.jsxs)("div",{className:"flex justify-end gap-4",children:[(0,d.jsx)(o.A,{type:"button",variant:"outline",onClick:l,children:m("experienceModal.cancel")}),(0,d.jsx)(o.A,{type:"submit",children:m("experienceModal.saveChanges")}
1)]})]})]})}):null}},26110(e,a,l){l.d(a,{A:()=>m});var t=l(5544),i=l(9950),s=l(10300),o=l(86400),r=l(51859),n=l(83344),d=l(96479),c=l(64767),u=l(44414);const m=e=>{let a=e.open,l=e.onSave,m=e.onClose,x=e.initialData;const h=(0,c.Bd)().t,v=(0,i.useState)([]),p=(0,t.A)(v,2),g=p[0],b=p[1],f=(0,i.useState)({}),y=(0,t.A)(f,2),j=y[0],N=y[1],w=(0,o.jLQ)(),C=((0,s.d4)(e=>e.auth).user,(0,s.d4)(n.XS)),M=(e,a,l)=>{const t=[...g];t[e][a]=l,b(t),N("")};return(0,i.useEffect)(()=>{(null===x||void 0===x?void 0:x.length)>0?b(x.map(e=>({...e}))):b([{name:"",issuer:"",issueDate:"",expiryDate:"",noExpiry:!1}])},[a,x]),(0,i.useEffect)(()=>{a&&0===g.length&&b([{name:"",issuer:"",issueDate:"",expiryDate:"",noExpiry:!1}])},[a]),a?(0,u.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,u.jsxs)("div",{className:"bg-white rounded-xl shadow-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[(0,u.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,u.jsx)("h2",{className:"text-xl font-semibold",children:h("newCertificateModal.title")}),(0,u.jsx)("button",{onClick:m,className:"text-gray-500 hover:text-gray-700 text-2xl",children:"\xd7"})]}),(0,u.jsx)("button",{className:"bg-blue-600 text-white px-4 py-2 rounded-md mb-4 hover:bg-blue-700",onClick:()=>{b([{name:"",issuer:"",issueDate:"",expiryDate:"",noExpiry:!1},...g]),N("")},children:h("newCertificateModal.addNew")}),g.map((e,a)=>(0,u.jsxs)("div",{className:"border border-gray-300 rounded-md p-4 mb-4 relative",children:[(0,u.jsxs)("div",{className:"flex justify-between items-start",children:[(0,u.jsxs)("h4",{className:"font-medium mb-2",children:[h("newCertificateModal.certificationNumber")," ",a+1]}),(0,u.jsx)("button",{onClick:()=>(async e=>{const a=g[e];null!==a&&void 0!==a&&a.id&&await w((0,o.A1g)({id:a.id}));const l=[...g];l.splice(e,1),b(l)})(a),className:"text-gray-400 hover:text-gray-600",children:(0,u.jsx)(d.A,{className:"w-4 h-4"})})]}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newCertificateModal.name")}),(0,u.jsx)("input",{type:"text",placeholder:h("newCertificateModal.namePlaceholder"),value:e.name,onChange:e=>M(a,"name",e.target.value),className:"w-full mb-2 p-2 border rounded-md"}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newCertificateModal.issuer")}),(0,u.jsx)("input",{type:"text",placeholder:h("newCertificateModal.issuerPlaceholder"),value:e.issuer,onChange:e=>M(a,"issuer",e.target.value),className:"w-full mb-2 p-2 border rounded-md"}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newCertificateModal.dateIssued")}),(0,u.jsx)("input",{type:"number",placeholder:h("newCertificateModal.dateIssuedPlaceholder"),value:e.issueDate,onChange:e=>M(a,"issueDate",e.target.value),className:"w-full mb-2 p-2 border rounded-md",min:1900,max:2100}),(0,u.jsxs)("div",{className:"flex items-center mb-2",children:[(0,u.jsx)("input",{type:"checkbox",id:`noExpiry-${a}`,checked:e.noExpiry||!1,onChange:e=>{const l=[...g];l[a].noExpiry=e.target.checked,e.target.checked&&(l[a].expiryDate=""),b(l)},className:"mr-2"}),(0,u.jsx)("label",{htmlFor:`noExpiry-${a}`,className:"text-sm",children:h("newCertificateModal.noExpiry")})]}),!e.noExpiry&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newCertificateModal.expiryDate")}),(0,u.jsx)("input",{type:"number",placeholder:h("newCertificateModal.expiryDatePlaceholder"),value:e.expiryDate,onChange:e=>M(a,"expiryDate",e.target.value),className:"w-full p-2 border rounded-md",min:1900,max:2100})]}),j[a]&&(0,u.jsx)("div",{className:"text-red-600 text-sm mt-2",children:j[a]}),(0,u.jsx)("button",{onClick:()=>{var t;e.name.trim()&&e.issuer.trim()&&e.issueDate.trim()&&(e.noExpiry||null!==(t=e.expiryDate)&&void 0!==t&&t.trim())?(l(g),m()):N(e=>({...e,[a]:h("newCertificateModal.errors.fillAllFields")}))},className:"mt-3 px-3 py-1 bg-green-500 text-white rounded-md hover:bg-green-600 text-sm",children:h("newCertificateModal.saveSingle")||"Save"})]},a)),Object.keys(j).length>0&&(0,u.jsx)("div",{className:"text-red-600 text-sm mb-4",children:h("newCertificateModal.errors.fillAllFields")}),g.length>0&&(0,u.jsxs)("div",{className:"flex justify-end space-x-3 mt-6",children:[(0,u.jsx)("button",{onClick:m,className:"px-4 py-2 rounded-md border border-gray-300 text-gray-700 hover:bg-gray-100",children:h("newCertificateModal.close")}),(0,u.jsxs)("button",{onClick:async()=>
1{if(!g.every(e=>{var a;return e.name.trim()&&e.issuer.trim()&&e.issueDate.trim()&&(e.noExpiry||(null===(a=e.expiryDate)||void 0===a?void 0:a.trim()))})){const e=g.findIndex(e=>{var a;return!(e.name.trim()&&e.issuer.trim()&&e.issueDate.trim()&&(e.noExpiry||null!==(a=e.expiryDate)&&void 0!==a&&a.trim()))});return void N(a=>({...a,[e]:h("newCertificateModal.errors.fillAllFields")}))}0!==g.length?(l(g),m()):N(h("newCertificateModal.errors.addAtLeastOne"))},className:"px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-800 flex",children:[C?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.A,{size:5}),h("newCertificateModal.loading")]}):h("newCertificateModal.saveChanges")," "]})]})]})}):null}},12599(e,a,l){l.d(a,{A:()=>m});var t=l(5544),i=l(9950),s=l(10300),o=l(51859),r=l(83344),n=l(86400),d=l(96479),c=l(64767),u=l(44414);const m=e=>{let a=e.open,l=e.onSave,m=e.onClose,x=e.initialData;const h=(0,c.Bd)().t,v=(0,i.useState)([]),p=(0,t.A)(v,2),g=p[0],b=p[1],f=(0,i.useState)(""),y=(0,t.A)(f,2),j=y[0],N=y[1],w=(0,s.d4)(r.XS),C=(0,n.jLQ)(),M=(e,a,l)=>{const t=[...g];t[e][a]=l,b(t),N("")};return(0,i.useEffect)(()=>{(null===x||void 0===x?void 0:x.length)>0?b(x.map(e=>({...e}))):b([{degree:"",school:"",year:""}])},[a,x]),(0,i.useEffect)(()=>{a&&0===g.length&&b([{degree:"",school:"",year:""}])},[a]),a?(0,u.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,u.jsxs)("div",{className:"bg-white rounded-xl shadow-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[(0,u.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,u.jsx)("h2",{className:"text-xl font-semibold",children:h("newEducationModal.title")}),(0,u.jsx)("button",{onClick:m,className:"text-gray-500 hover:text-gray-700 text-2xl",children:"\xd7"})]}),(0,u.jsx)("button",{className:"bg-blue-600 text-white px-4 py-2 rounded-md mb-4 hover:bg-blue-700",onClick:()=>{b([...g,{degree:"",school:"",year:""}]),N("")},children:h("newEducationModal.addNew")}),g.map((e,a)=>(0,u.jsxs)("div",{className:"border border-gray-300 rounded-md p-4 mb-4 relative",children:[(0,u.jsxs)("div",{className:"flex justify-between items-start",children:[(0,u.jsxs)("h4",{className:"font-medium mb-2",children:[h("newEducationModal.educationNumber")," ",a+1]}),(0,u.jsx)("button",{onClick:()=>(async e=>{const a=g[e];null!==a&&void 0!==a&&a.id&&await C((0,n.TpJ)({id:a.id}));const l=[...g];l.splice(e,1),b(l)})(a),className:"text-gray-400 hover:text-gray-600",children:(0,u.jsx)(d.A,{className:"w-4 h-4"})})]}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newEducationModal.degree")}),(0,u.jsx)("input",{type:"text",value:e.degree,onChange:e=>M(a,"degree",e.target.value),className:"w-full mb-2 p-2 border rounded-md"}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newEducationModal.school")}),(0,u.jsx)("input",{type:"text",value:e.school,onChange:e=>M(a,"school",e.target.value),className:"w-full mb-2 p-2 border rounded-md"}),(0,u.jsx)("label",{className:"block text-sm font-medium mb-1",children:h("newEducationModal.year")}),(0,u.jsx)("input",{type:"number",value:e.year,onChange:e=>M(a,"year",e.target.value),className:"w-full mb-2 p-2 border rounded-md",min:1900,max:2100})]},a)),j&&(0,u.jsx)("div",{className:"text-red-600 text-sm mb-4",children:j}),g.length>0&&(0,u.jsxs)("div",{className:"flex justify-end space-x-3 mt-6",children:[(0,u.jsx)("button",{onClick:m,className:"px-4 py-2 rounded-md border border-gray-300 text-gray-700 hover:bg-gray-100",children:h("newEducationModal.close")}),(0,u.jsx)("button",{onClick:async()=>{g.every(e=>e.degree.trim()&&e.school.trim()&&(e=>{const a=parseInt(e);return a>=1900&&a<=4500})(e.year))?0!==g.length?(l(g),m()):N(h("newEducationModal.errors.addAtLeastOne")):N(h("newEducationModal.errors.fillAllFields"))},className:"px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-800 flex items-center gap-2",children:w?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.A,{size:5}),h("newEducationModal.loading")]}):h("newEducationModal.saveChanges")})]})]})}):null}},1361(e,a,l){l.d(a,{A:()=>u});var t=l(5544),i=l(9950),s=l(96479),o=l(42461),r=l(60348),n=l(86400),d=l(64767),c=l(44414);const u=e=>{let a=e.open,l=e.onClose,u=e.onSave,m=e.initialData;const x=(0,d.Bd)().t,h=(0,i.useState)([]),v=(0,t.A)(h,2),p=v[0],g=v[1],b=(0,i.useState)([]),f=(0,t.A)(b,2),y=f[0],j=f[1],N=(0,i.useState)({}),w=(0,t.A)(N,2),C=w[0],M=w[1],k=(0,n.jLQ)();(0,i.useEffect)(()=>{(null===m||void 0===m?void 0:m.length)>0?(g(m),j(m.map(()=>""))):(g([{title:"",link:"",description:"",technology:[]}]),j([""])),M({})},[a,m]);const A=(e,a,l)=>{g(t=>{const i=[...t],s={...i[e]};return s[a]=l,i[e]=s,i})};return a?(0,c.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 overflow-auto",children:(0,c.jsxs)("div",{className:"bg-white p-6 rounded-lg w-full max-w-2xl shadow-lg relative max-h-[80vh] overflow-y-auto",children:[(0,c.jsx)("button",{className:"absolute top-3 right-3",onClick:l,children:(0,c.jsx)(s.A,{className:"w-5 h-5"})}),(0,c.jsx)("h2",{className:"text-xl font-semibold mb-4",children:x("portfolioModal.title")}),(0,c.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(()=>{const e={};return p.forEach((a,l)=>{var t,i;const s={};null!==(t=a.title)&&void 0!==t&&t.trim()||(s.title=x("portfolioModal.titleRequired")),null!==(i=a.description)&&void 0!==i&&i.trim()||(s.description=x("portfolioModal.descriptionRequired")),a.technology&&0!==a.technology.length||(s.technology=x("portfolioModal.technologyRequired")),Object.keys(s).length>0&&(e[l]=s)}),M(e),0===Object.keys(e).length})()&&(u(p),l())},className:"space-y-6",children:[(0,c.jsx)(o.A,{type:"button",onClick:()=>{g([...p,{title:"",link:"",description:"",technology:[]}]),j([...y,""])},className:"mb-4",children:x("portfolioModal.addNewItem")}),p.map((e,a)=>{var l,t,i;return(0,c.jsxs)("div",{className:"border rounded-lg p-4 space-y-4",children:[(0,c.jsxs)("div",{className:"flex justify-between items-start",children:[(0,c.jsxs)("h4",{className:"font-medium",children:[x("portfolioModal.portfolioItem")," ",a+1]}),(0,c.jsx)("button",{type:"button",onClick:()=>(async e=>{const a=p[e];null!==a&&void 0!==a&&a.id&&await k((0,n.tLb)({id:a.id}));const l=[...p];l.splice(e,1),g(l);const t=[...y];t.splice(e,1),j(t)})(a),className:"text-gray-400 hover:text-gray-600",children:(0,c.jsx)(s.A,{className:"w-4 h-4"})})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:x("portfolioModal.titleLabel")}),(0,c.jsx)("input",{type:"text",value:e.title,onChange:e=>A(a,"title",e.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(l=C[a])||void 0===l?void 0:l.title)&&(0,c.jsx)("p",{className:"text-red-500 text-sm",children:C[a].title})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:x("portfolioModal.description")}),(0,c.jsx)("textarea",{value:e.description,onChange:e=>A(a,"description",e.target.value),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(null===(t=C[a])||void 0===t?void 0:t.description)&&(0,c.jsx)("p",{className:"text-red-500 text-sm",children:C[a].description})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:x("portfolioModal.link")}),(0,c.jsx)("input",{type:"url",value:e.link||"",onChange:e=>A(a,"link",e.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:x("portfolioModal.technologies")}),(0,c.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:e.technology.map((e,l)=>(0,c.jsxs)(r.E,{variant:void 0,className:"flex items-center gap-2 bg-blue-50 text-blue-700",children:[e,(0,c.jsx)("button",{type:"button",onClick:()=>((e,a)=>{g(l=>{const t=[...l],i={...t[e]},s=[...i.technology];return s.splice(a,1),i.technology=s,t[e]=i,t})})(a,l),className:"hover:text-blue-900",children:(0,c.jsx)(s.A,{className:"h-3 w-3"})})]},l))}),(0,c.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,c.jsx)("input",{type:"text",value:y[a],onChange:e=>{const l=[...y];l[a]=e.target.value,j(l)},placeholder:x("portfolioModal.addTechnology"),className:"flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(0,c.jsx)(o.A,{type:"button",onClick:e=>{e.preventDefault(),(e=>{const a=y[e].trim();a&&(g(l=>{const t=[...l],i={...t[e]},s=[...i.technology,a];return i.technology=s,t[e]=i,t}),j(a=>{const l=[...a];return l[e]="",l}))})(a)},children:x("portfolioModal.add")})]}),(null===(i=C[a])||void 0===i?void 0:i.technology)&&(0,c.jsx)("p",{className:"text-red-500 text-sm mt-1",children:C[a].technology})]})]},a)}),(0,c.jsxs)("div",{className:"flex justify-end gap-4",children:[(0,c.jsx)(o.A,{type:"button",variant:"outline",onClick:l,children:x("portfolioModal.cancel")}),(0,c.jsx)(o.A,{type:"submit",children:x("portfolioModal.saveChanges")}
1)]})]})]})}):null}},11633(e,a,l){l.d(a,{A:()=>m});var t=l(5544),i=l(9950),s=l(98932),o=l(96479),r=l(86400),n=l(49164),d=l(42461),c=l(64767),u=l(44414);const m=e=>{let a=e.open,l=e.allStaticSkills,m=e.skillsData,x=e.handleSave,h=e.onClose;const v=(0,c.Bd)().t,p=(0,i.useState)([]),g=(0,t.A)(p,2),b=g[0],f=g[1],y=(0,i.useState)({name:"",level:n.kL.beginner.toString()}),j=(0,t.A)(y,2),N=j[0],w=j[1],C=(0,r.jLQ)();return(0,i.useEffect)(()=>{if(m){const e=m.map(e=>{var a;return{id:e.id,name:e.name,level:(null===(a=Object.entries(n.NI).find(a=>(0,t.A)(a,2)[1]===e.level))||void 0===a?void 0:a[0])||"1",endorsements:e.endorsements,skillId:e.skillId}});f(e)}},[m]),a?(0,u.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,u.jsx)("div",{className:"bg-white rounded-xl shadow-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:(0,u.jsxs)("div",{className:"max-h-[80vh] overflow-y-auto text-left",children:[(0,u.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,u.jsx)("h3",{className:"text-xl font-semibold mb-4",children:v("skillsModal.title")}),(0,u.jsx)("button",{onClick:h,className:"text-gray-500 hover:text-gray-700 text-2xl",children:"\xd7"})]}),(0,u.jsxs)("form",{onSubmit:e=>{e.preventDefault(),b&&0!==b.length?(x(b),h()):s.dI.showToast("error",v("skillsModal.noSkillsError"),v("skillsModal.addAtLeastOneSkill"))},className:"space-y-6",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 mb-4",children:[(0,u.jsx)("input",{type:"text",value:N.name,onChange:e=>w({...N,name:e.target.value}),placeholder:v("skillsModal.newSkillName"),className:"w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),(0,u.jsxs)("select",{value:N.level,onChange:e=>w({...N,level:e.target.value}),className:"w-full sm:w-auto rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500",children:[(0,u.jsx)("option",{value:n.kL.beginner,children:v("skillsModal.beginner")}),(0,u.jsx)("option",{value:n.kL.intermediate,children:v("skillsModal.intermediate")}),(0,u.jsx)("option",{value:n.kL.advanced,children:v("skillsModal.advanced")}),(0,u.jsx)("option",{value:n.kL.expert,children:v("skillsModal.expert")})]}),(0,u.jsx)(d.A,{type:"button",onClick:async()=>{if(!N.name.trim())return;const e=N.name.trim().toLowerCase();if(b.some(a=>a.name.toLowerCase()===e))return void s.dI.showToast("warning",v("skillsModal.duplicateSkill"),v("skillsModal.skillAlreadyAdded"));const a=l.find(a=>a.name.toLowerCase()===e);let t="",i=N.name;if(a)t=a.id,i=a.name;else{const e=(await C((0,r.sLi)({name:N.name}))).payload;t=e.id,i=e.name}const o={name:i,level:{id:Number(N.level)},endorsements:0,skillId:{id:t}};f([...b,o]),w({name:"",level:n.kL.beginner.toString()})},className:"w-full sm:w-auto",children:v("skillsModal.add")})]}),(0,u.jsx)("div",{className:"space-y-4",children:b.map((e,a)=>(0,u.jsxs)("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[(0,u.jsx)("span",{className:"font-medium",children:e.name}),(0,u.jsxs)("select",{value:e.level,onChange:e=>{const l=[...b];l[a].level=e.target.value,f(l)},className:"w-full sm:w-auto rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500",children:[(0,u.jsx)("option",{value:n.kL.beginner,children:v("skillsModal.beginner")}),(0,u.jsx)("option",{value:n.kL.intermediate,children:v("skillsModal.intermediate")}),(0,u.jsx)("option",{value:n.kL.advanced,children:v("skillsModal.advanced")}),(0,u.jsx)("option",{value:n.kL.expert,children:v("skillsModal.expert")})]})]}),(0,u.jsxs)("div",{className:"text-sm text-gray-500",children:[e.endorsements," ",v("skillsModal.endorsements")]})]}),(0,u.jsx)("button",{type:"button",onClick:()=>(e=>{const a=b[e];null!==a&&void 0!==a&&a.id&&C((0,r.Deo)({id:a.id}));const l=[...b];l.splice(e,1),f(l)})(a),className:"ml-2 text-gray-400 hover:text-gray-600",children:(0,u.jsx)(o.A,{className:"w-4 h-4"})})]},a))})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-4",children:[(0,u.jsx)(d.A,{type:"button",variant:"outline",onClick:h,children:v("skillsModal.cancel")}),(0,u.jsx)(d.A,{type:"submit",children:v("skillsModal.saveChanges")}
1)]})]})]})})}):null}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.